@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.28 → 0.0.1-alpha.30

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.
@@ -25,7 +25,8 @@ var HttpClient = /** @class */ (function () {
25
25
  _this.chatClient.processMessageArrayAndStoreIt(o);
26
26
  else {
27
27
  var envelope = _this.constructFirstHitEnvelope();
28
- _this.postAndHandleTheData(envelope);
28
+ var response = _this.postAndHandleTheData(envelope);
29
+ console.log('response from first hit', response);
29
30
  }
30
31
  });
31
32
  };
@@ -57,6 +58,7 @@ var HttpClient = /** @class */ (function () {
57
58
  })
58
59
  .then(function (data) {
59
60
  _this.handleResponseData(data, action);
61
+ return data;
60
62
  })
61
63
  .catch(function (err) { return console.log(err); });
62
64
  };
@@ -5,7 +5,6 @@ export default class MiddlewareClient {
5
5
  private processor;
6
6
  private entryInterface;
7
7
  private chatClient;
8
- private container;
9
8
  constructor(container: Container);
10
9
  static initialize(container: any, widget: any): void;
11
10
  handleEntries(entries: ServerEntry[], action?: string): Promise<void>;
@@ -46,7 +46,6 @@ var MiddlewareClient = /** @class */ (function () {
46
46
  this.processor = new ProcessorInterface();
47
47
  this.entryInterface = new EntryInterface(container);
48
48
  this.chatClient = new ChatClient(container);
49
- this.container = container;
50
49
  }
51
50
  MiddlewareClient.initialize = function (container, widget) {
52
51
  MiddlewareHelper.setContainer(container);
@@ -49,9 +49,6 @@ import { ConversationMessageListItemType, } from '@humany/widget-conversation';
49
49
  import { DataType } from '@humany/widget-types-grid';
50
50
  import { ServerEntryTypeEnum } from '../contract/enum/server-entry-type.enum';
51
51
  import { StoreHelper } from '../helper/store.helper';
52
- import { toContactMethod } from './convert';
53
- import mocked from './_mocked-contact-method.json';
54
- // TODO: toContactMethod and mocked.json should be removed
55
52
  var EntryInterface = /** @class */ (function () {
56
53
  function EntryInterface(container) {
57
54
  this.container = container;
@@ -108,24 +105,25 @@ var EntryInterface = /** @class */ (function () {
108
105
  };
109
106
  EntryInterface.prototype.transformContactMethod = function (entry) {
110
107
  return __awaiter(this, void 0, void 0, function () {
111
- var dataClient, response, contactMethod;
108
+ var dataClient, contactMethods, contactMethod;
112
109
  return __generator(this, function (_a) {
113
110
  switch (_a.label) {
114
111
  case 0: return [4 /*yield*/, this.container.getAsync('dataClient')];
115
112
  case 1:
116
113
  dataClient = _a.sent();
117
- console.log('fetching contact method with id', entry);
114
+ contactMethods = [];
118
115
  return [4 /*yield*/, dataClient.fetch(DataType.ContactMethod, {
119
116
  contactMethodId: entry.content.id,
120
117
  })];
121
118
  case 2:
122
- response = _a.sent();
123
- console.log('response', response);
124
- contactMethod = toContactMethod(mocked.ContactMethod);
125
- contactMethod.expanded = true; // TODO: ?
119
+ contactMethod = _a.sent();
120
+ if (contactMethod) {
121
+ contactMethod.expanded = true;
122
+ contactMethods.push(contactMethod);
123
+ }
126
124
  return [2 /*return*/, {
127
125
  type: 'ace-knowledge-contact-method',
128
- contactMethods: [contactMethod],
126
+ contactMethods: contactMethods,
129
127
  }];
130
128
  }
131
129
  });
@@ -168,12 +166,7 @@ var EntryInterface = /** @class */ (function () {
168
166
  }
169
167
  finally { if (e_1) throw e_1.error; }
170
168
  return [7 /*endfinally*/];
171
- case 8:
172
- // entryArray.forEach((o) => {
173
- // let x = this.transform(o);
174
- // if (!!x) returnArray.push(x);
175
- // });
176
- return [2 /*return*/, returnArray];
169
+ case 8: return [2 /*return*/, returnArray];
177
170
  }
178
171
  });
179
172
  });
@@ -25,7 +25,8 @@ var HttpClient = /** @class */ (function () {
25
25
  _this.chatClient.processMessageArrayAndStoreIt(o);
26
26
  else {
27
27
  var envelope = _this.constructFirstHitEnvelope();
28
- _this.postAndHandleTheData(envelope);
28
+ var response = _this.postAndHandleTheData(envelope);
29
+ console.log('response from first hit', response);
29
30
  }
30
31
  });
31
32
  };
@@ -57,6 +58,7 @@ var HttpClient = /** @class */ (function () {
57
58
  })
58
59
  .then(function (data) {
59
60
  _this.handleResponseData(data, action);
61
+ return data;
60
62
  })
61
63
  .catch(function (err) { return console.log(err); });
62
64
  };
@@ -5,7 +5,6 @@ export default class MiddlewareClient {
5
5
  private processor;
6
6
  private entryInterface;
7
7
  private chatClient;
8
- private container;
9
8
  constructor(container: Container);
10
9
  static initialize(container: any, widget: any): void;
11
10
  handleEntries(entries: ServerEntry[], action?: string): Promise<void>;
@@ -46,7 +46,6 @@ var MiddlewareClient = /** @class */ (function () {
46
46
  this.processor = new ProcessorInterface();
47
47
  this.entryInterface = new EntryInterface(container);
48
48
  this.chatClient = new ChatClient(container);
49
- this.container = container;
50
49
  }
51
50
  MiddlewareClient.initialize = function (container, widget) {
52
51
  MiddlewareHelper.setContainer(container);
@@ -49,9 +49,6 @@ import { ConversationMessageListItemType, } from '@humany/widget-conversation';
49
49
  import { DataType } from '@humany/widget-types-grid';
50
50
  import { ServerEntryTypeEnum } from '../contract/enum/server-entry-type.enum';
51
51
  import { StoreHelper } from '../helper/store.helper';
52
- import { toContactMethod } from './convert';
53
- import mocked from './_mocked-contact-method.json';
54
- // TODO: toContactMethod and mocked.json should be removed
55
52
  var EntryInterface = /** @class */ (function () {
56
53
  function EntryInterface(container) {
57
54
  this.container = container;
@@ -108,24 +105,25 @@ var EntryInterface = /** @class */ (function () {
108
105
  };
109
106
  EntryInterface.prototype.transformContactMethod = function (entry) {
110
107
  return __awaiter(this, void 0, void 0, function () {
111
- var dataClient, response, contactMethod;
108
+ var dataClient, contactMethods, contactMethod;
112
109
  return __generator(this, function (_a) {
113
110
  switch (_a.label) {
114
111
  case 0: return [4 /*yield*/, this.container.getAsync('dataClient')];
115
112
  case 1:
116
113
  dataClient = _a.sent();
117
- console.log('fetching contact method with id', entry);
114
+ contactMethods = [];
118
115
  return [4 /*yield*/, dataClient.fetch(DataType.ContactMethod, {
119
116
  contactMethodId: entry.content.id,
120
117
  })];
121
118
  case 2:
122
- response = _a.sent();
123
- console.log('response', response);
124
- contactMethod = toContactMethod(mocked.ContactMethod);
125
- contactMethod.expanded = true; // TODO: ?
119
+ contactMethod = _a.sent();
120
+ if (contactMethod) {
121
+ contactMethod.expanded = true;
122
+ contactMethods.push(contactMethod);
123
+ }
126
124
  return [2 /*return*/, {
127
125
  type: 'ace-knowledge-contact-method',
128
- contactMethods: [contactMethod],
126
+ contactMethods: contactMethods,
129
127
  }];
130
128
  }
131
129
  });
@@ -168,12 +166,7 @@ var EntryInterface = /** @class */ (function () {
168
166
  }
169
167
  finally { if (e_1) throw e_1.error; }
170
168
  return [7 /*endfinally*/];
171
- case 8:
172
- // entryArray.forEach((o) => {
173
- // let x = this.transform(o);
174
- // if (!!x) returnArray.push(x);
175
- // });
176
- return [2 /*return*/, returnArray];
169
+ case 8: return [2 /*return*/, returnArray];
177
170
  }
178
171
  });
179
172
  });
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.28",
3
+ "version": "0.0.1-alpha.30",
4
4
  "description": "Bot Provider Plugin ACE Knowledge Widgets.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Telia Company AB",