@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.38 → 0.0.1-alpha.39

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.
@@ -15,6 +15,11 @@ export declare class ContactMethodClient {
15
15
  validate(form: any): void;
16
16
  private handleContactCategoryList;
17
17
  private handleForm;
18
+ addContactMethod(contactMethod: any): {
19
+ contactMethods: any;
20
+ type: string;
21
+ noPadding: boolean;
22
+ };
18
23
  private handleContactMethodList;
19
24
  private handleSingleContactMethod;
20
25
  private submit;
@@ -162,6 +162,14 @@ var ContactMethodClient = /** @class */ (function () {
162
162
  });
163
163
  this.printMessage(contactMethods.id, contactMethods, title);
164
164
  };
165
+ ContactMethodClient.prototype.addContactMethod = function (contactMethod) {
166
+ contactMethod.expanded = true;
167
+ this.updateForm(contactMethod, {
168
+ submit: 'Submit',
169
+ errors: undefined,
170
+ });
171
+ return this.printMessage(contactMethod.id, contactMethod);
172
+ };
165
173
  ContactMethodClient.prototype.handleContactMethodList = function (input, contactMethods) {
166
174
  var title = input.split('/')[2];
167
175
  var newGuid = uuidv4();
@@ -214,6 +222,7 @@ var ContactMethodClient = /** @class */ (function () {
214
222
  isUser: false,
215
223
  },
216
224
  ]);
225
+ return message;
217
226
  }
218
227
  else {
219
228
  if (title)
@@ -236,6 +245,7 @@ var ContactMethodClient = /** @class */ (function () {
236
245
  contactMethods: contactMethods,
237
246
  entry: entry,
238
247
  });
248
+ return message;
239
249
  }
240
250
  };
241
251
  ContactMethodClient.prototype.loadContactMethods = function (dataType, id) {
@@ -11,11 +11,13 @@ export declare class HttpClient {
11
11
  firstHit(): void;
12
12
  handleUpdate(action: string): void;
13
13
  handleInput(action: string): void;
14
+ handleCategories(): void;
14
15
  handlePhrase(phrase: string): void;
15
16
  private postAndHandleTheData;
16
17
  private postAndHandleTheUpdateData;
17
18
  private getHttpOptions;
18
19
  private constructInputEnvelope;
20
+ private constructCategoriesEnvelope;
19
21
  private constructPhraseEnvelope;
20
22
  private constructFirstHitEnvelope;
21
23
  private handleResponseData;
@@ -42,6 +42,11 @@ var HttpClient = /** @class */ (function () {
42
42
  var envelope = this.constructInputEnvelope(action);
43
43
  this.postAndHandleTheData(envelope, action);
44
44
  };
45
+ // for category burger
46
+ HttpClient.prototype.handleCategories = function () {
47
+ var envelope = this.constructCategoriesEnvelope();
48
+ this.postAndHandleTheData(envelope);
49
+ };
45
50
  // for text entries by user
46
51
  HttpClient.prototype.handlePhrase = function (phrase) {
47
52
  var envelope = this.constructPhraseEnvelope(phrase);
@@ -87,6 +92,18 @@ var HttpClient = /** @class */ (function () {
87
92
  clientId: this.clientId,
88
93
  };
89
94
  };
95
+ HttpClient.prototype.constructCategoriesEnvelope = function () {
96
+ return {
97
+ action: {
98
+ content: {
99
+ $type: 'Humany.Matching.Bots.Conversations.Actions.BrowseCategories, Humany.Matching',
100
+ },
101
+ key: 'browseCategories',
102
+ },
103
+ globalState: StoreHelper.getGlobalState(),
104
+ clientId: this.clientId,
105
+ };
106
+ };
90
107
  HttpClient.prototype.constructPhraseEnvelope = function (phrase) {
91
108
  return {
92
109
  command: { phrase: phrase },
@@ -46,7 +46,8 @@ var __values = (this && this.__values) || function(o) {
46
46
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
47
47
  };
48
48
  import { DataType } from '@telia-ace/knowledge-widget-types-grid';
49
- import { ConversationMessageListItemType } from '@telia-ace/widget-conversation';
49
+ import { ConversationMessageListItemType, } from '@telia-ace/widget-conversation';
50
+ import { ContactMethodClient } from '../client/contact-method.client';
50
51
  import { ServerEntryTypeEnum } from '../contract/enum/server-entry-type.enum';
51
52
  import { StoreHelper } from '../helper/store.helper';
52
53
  var EntryInterface = /** @class */ (function () {
@@ -106,26 +107,20 @@ var EntryInterface = /** @class */ (function () {
106
107
  };
107
108
  EntryInterface.prototype.transformContactMethod = function (entry) {
108
109
  return __awaiter(this, void 0, void 0, function () {
109
- var dataClient, contactMethods, contactMethod;
110
+ var dataClient, contactMethod, cmClient;
110
111
  return __generator(this, function (_a) {
111
112
  switch (_a.label) {
112
113
  case 0: return [4 /*yield*/, this.container.getAsync('dataClient')];
113
114
  case 1:
114
115
  dataClient = _a.sent();
115
- contactMethods = [];
116
116
  return [4 /*yield*/, dataClient.fetch(DataType.ContactMethod, {
117
117
  contactMethodId: entry.content.id,
118
118
  })];
119
119
  case 2:
120
120
  contactMethod = _a.sent();
121
- if (contactMethod) {
122
- contactMethod.expanded = true;
123
- contactMethods.push(contactMethod);
124
- }
125
- return [2 /*return*/, {
126
- type: 'ace-knowledge-contact-method',
127
- contactMethods: contactMethods,
128
- }];
121
+ cmClient = new ContactMethodClient(this.container);
122
+ cmClient.addContactMethod(contactMethod);
123
+ return [2 /*return*/];
129
124
  }
130
125
  });
131
126
  });
package/lib/plugin.js CHANGED
@@ -36,12 +36,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  import { ContactMethodPlatform } from '@telia-ace/knowledge-widget-adapters';
38
38
  import { DataClient } from '@telia-ace/knowledge-widget-types-grid';
39
- import { ConversationPlatform, registerCustomMessageComponent } from '@telia-ace/widget-conversation';
39
+ import { ConversationPlatform, registerCustomMessageComponent, } from '@telia-ace/widget-conversation';
40
40
  import { v4 } from 'uuid';
41
41
  import ChatClient from './client/chat.client';
42
42
  import { ContactMethodClient } from './client/contact-method.client';
43
43
  import { HttpClient } from './client/http.client';
44
44
  import MiddlewareClient from './client/middleware.client';
45
+ import { getContactMethodEntry } from './utils';
45
46
  var getKnowledgeBotEndpoint = function (container, component /*: ComponentNodeController */
46
47
  // ComponentNodeController type differs from component passed into registerProvider
47
48
  ) {
@@ -93,6 +94,12 @@ var KnowledgeBotProviderPlugin = function (container) { return __awaiter(void 0,
93
94
  cmClient.validate(input.form);
94
95
  });
95
96
  component.actions.create('submit', function (input) {
97
+ var _a;
98
+ if ((_a = input === null || input === void 0 ? void 0 : input.form) === null || _a === void 0 ? void 0 : _a.schema.id) {
99
+ var contactMethodEntry = getContactMethodEntry(input.form.schema.id);
100
+ if (contactMethodEntry) {
101
+ }
102
+ }
96
103
  var cmClient = new ContactMethodClient(container);
97
104
  cmClient.validate(input.form);
98
105
  });
@@ -118,8 +125,12 @@ var KnowledgeBotProviderPlugin = function (container) { return __awaiter(void 0,
118
125
  cmClient.handleContactMethod(input);
119
126
  return next(input);
120
127
  }
121
- var middlewareClient = new MiddlewareClient(container);
122
128
  var httpClient = new HttpClient(endpoint, clientId, container);
129
+ if (input == 'burger-clicked') {
130
+ httpClient.handleCategories();
131
+ return next(input);
132
+ }
133
+ var middlewareClient = new MiddlewareClient(container);
123
134
  // this is an update check, as it requires
124
135
  // a lot different logic and no user message
125
136
  if (middlewareClient.checkForUpdate(input)) {
package/lib/utils.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const getContactMethodEntry: (contactMethodId: string) => import("./contract/model/http/server-entry.model").ServerEntry | undefined;
package/lib/utils.js ADDED
@@ -0,0 +1,5 @@
1
+ import { StoreHelper } from './helper/store.helper';
2
+ export var getContactMethodEntry = function (contactMethodId) {
3
+ var entries = StoreHelper.getEntryStore();
4
+ return entries.find(function (e) { return e.content.id === +contactMethodId; });
5
+ };
@@ -15,6 +15,11 @@ export declare class ContactMethodClient {
15
15
  validate(form: any): void;
16
16
  private handleContactCategoryList;
17
17
  private handleForm;
18
+ addContactMethod(contactMethod: any): {
19
+ contactMethods: any;
20
+ type: string;
21
+ noPadding: boolean;
22
+ };
18
23
  private handleContactMethodList;
19
24
  private handleSingleContactMethod;
20
25
  private submit;
@@ -162,6 +162,14 @@ var ContactMethodClient = /** @class */ (function () {
162
162
  });
163
163
  this.printMessage(contactMethods.id, contactMethods, title);
164
164
  };
165
+ ContactMethodClient.prototype.addContactMethod = function (contactMethod) {
166
+ contactMethod.expanded = true;
167
+ this.updateForm(contactMethod, {
168
+ submit: 'Submit',
169
+ errors: undefined,
170
+ });
171
+ return this.printMessage(contactMethod.id, contactMethod);
172
+ };
165
173
  ContactMethodClient.prototype.handleContactMethodList = function (input, contactMethods) {
166
174
  var title = input.split('/')[2];
167
175
  var newGuid = uuidv4();
@@ -214,6 +222,7 @@ var ContactMethodClient = /** @class */ (function () {
214
222
  isUser: false,
215
223
  },
216
224
  ]);
225
+ return message;
217
226
  }
218
227
  else {
219
228
  if (title)
@@ -236,6 +245,7 @@ var ContactMethodClient = /** @class */ (function () {
236
245
  contactMethods: contactMethods,
237
246
  entry: entry,
238
247
  });
248
+ return message;
239
249
  }
240
250
  };
241
251
  ContactMethodClient.prototype.loadContactMethods = function (dataType, id) {
@@ -11,11 +11,13 @@ export declare class HttpClient {
11
11
  firstHit(): void;
12
12
  handleUpdate(action: string): void;
13
13
  handleInput(action: string): void;
14
+ handleCategories(): void;
14
15
  handlePhrase(phrase: string): void;
15
16
  private postAndHandleTheData;
16
17
  private postAndHandleTheUpdateData;
17
18
  private getHttpOptions;
18
19
  private constructInputEnvelope;
20
+ private constructCategoriesEnvelope;
19
21
  private constructPhraseEnvelope;
20
22
  private constructFirstHitEnvelope;
21
23
  private handleResponseData;
@@ -42,6 +42,11 @@ var HttpClient = /** @class */ (function () {
42
42
  var envelope = this.constructInputEnvelope(action);
43
43
  this.postAndHandleTheData(envelope, action);
44
44
  };
45
+ // for category burger
46
+ HttpClient.prototype.handleCategories = function () {
47
+ var envelope = this.constructCategoriesEnvelope();
48
+ this.postAndHandleTheData(envelope);
49
+ };
45
50
  // for text entries by user
46
51
  HttpClient.prototype.handlePhrase = function (phrase) {
47
52
  var envelope = this.constructPhraseEnvelope(phrase);
@@ -87,6 +92,18 @@ var HttpClient = /** @class */ (function () {
87
92
  clientId: this.clientId,
88
93
  };
89
94
  };
95
+ HttpClient.prototype.constructCategoriesEnvelope = function () {
96
+ return {
97
+ action: {
98
+ content: {
99
+ $type: 'Humany.Matching.Bots.Conversations.Actions.BrowseCategories, Humany.Matching',
100
+ },
101
+ key: 'browseCategories',
102
+ },
103
+ globalState: StoreHelper.getGlobalState(),
104
+ clientId: this.clientId,
105
+ };
106
+ };
90
107
  HttpClient.prototype.constructPhraseEnvelope = function (phrase) {
91
108
  return {
92
109
  command: { phrase: phrase },
@@ -46,7 +46,8 @@ var __values = (this && this.__values) || function(o) {
46
46
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
47
47
  };
48
48
  import { DataType } from '@telia-ace/knowledge-widget-types-grid';
49
- import { ConversationMessageListItemType } from '@telia-ace/widget-conversation';
49
+ import { ConversationMessageListItemType, } from '@telia-ace/widget-conversation';
50
+ import { ContactMethodClient } from '../client/contact-method.client';
50
51
  import { ServerEntryTypeEnum } from '../contract/enum/server-entry-type.enum';
51
52
  import { StoreHelper } from '../helper/store.helper';
52
53
  var EntryInterface = /** @class */ (function () {
@@ -106,26 +107,20 @@ var EntryInterface = /** @class */ (function () {
106
107
  };
107
108
  EntryInterface.prototype.transformContactMethod = function (entry) {
108
109
  return __awaiter(this, void 0, void 0, function () {
109
- var dataClient, contactMethods, contactMethod;
110
+ var dataClient, contactMethod, cmClient;
110
111
  return __generator(this, function (_a) {
111
112
  switch (_a.label) {
112
113
  case 0: return [4 /*yield*/, this.container.getAsync('dataClient')];
113
114
  case 1:
114
115
  dataClient = _a.sent();
115
- contactMethods = [];
116
116
  return [4 /*yield*/, dataClient.fetch(DataType.ContactMethod, {
117
117
  contactMethodId: entry.content.id,
118
118
  })];
119
119
  case 2:
120
120
  contactMethod = _a.sent();
121
- if (contactMethod) {
122
- contactMethod.expanded = true;
123
- contactMethods.push(contactMethod);
124
- }
125
- return [2 /*return*/, {
126
- type: 'ace-knowledge-contact-method',
127
- contactMethods: contactMethods,
128
- }];
121
+ cmClient = new ContactMethodClient(this.container);
122
+ cmClient.addContactMethod(contactMethod);
123
+ return [2 /*return*/];
129
124
  }
130
125
  });
131
126
  });
package/lib-esm/plugin.js CHANGED
@@ -36,12 +36,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  import { ContactMethodPlatform } from '@telia-ace/knowledge-widget-adapters';
38
38
  import { DataClient } from '@telia-ace/knowledge-widget-types-grid';
39
- import { ConversationPlatform, registerCustomMessageComponent } from '@telia-ace/widget-conversation';
39
+ import { ConversationPlatform, registerCustomMessageComponent, } from '@telia-ace/widget-conversation';
40
40
  import { v4 } from 'uuid';
41
41
  import ChatClient from './client/chat.client';
42
42
  import { ContactMethodClient } from './client/contact-method.client';
43
43
  import { HttpClient } from './client/http.client';
44
44
  import MiddlewareClient from './client/middleware.client';
45
+ import { getContactMethodEntry } from './utils';
45
46
  var getKnowledgeBotEndpoint = function (container, component /*: ComponentNodeController */
46
47
  // ComponentNodeController type differs from component passed into registerProvider
47
48
  ) {
@@ -93,6 +94,12 @@ var KnowledgeBotProviderPlugin = function (container) { return __awaiter(void 0,
93
94
  cmClient.validate(input.form);
94
95
  });
95
96
  component.actions.create('submit', function (input) {
97
+ var _a;
98
+ if ((_a = input === null || input === void 0 ? void 0 : input.form) === null || _a === void 0 ? void 0 : _a.schema.id) {
99
+ var contactMethodEntry = getContactMethodEntry(input.form.schema.id);
100
+ if (contactMethodEntry) {
101
+ }
102
+ }
96
103
  var cmClient = new ContactMethodClient(container);
97
104
  cmClient.validate(input.form);
98
105
  });
@@ -118,8 +125,12 @@ var KnowledgeBotProviderPlugin = function (container) { return __awaiter(void 0,
118
125
  cmClient.handleContactMethod(input);
119
126
  return next(input);
120
127
  }
121
- var middlewareClient = new MiddlewareClient(container);
122
128
  var httpClient = new HttpClient(endpoint, clientId, container);
129
+ if (input == 'burger-clicked') {
130
+ httpClient.handleCategories();
131
+ return next(input);
132
+ }
133
+ var middlewareClient = new MiddlewareClient(container);
123
134
  // this is an update check, as it requires
124
135
  // a lot different logic and no user message
125
136
  if (middlewareClient.checkForUpdate(input)) {
@@ -0,0 +1 @@
1
+ export declare const getContactMethodEntry: (contactMethodId: string) => import("./contract/model/http/server-entry.model").ServerEntry | undefined;
@@ -0,0 +1,5 @@
1
+ import { StoreHelper } from './helper/store.helper';
2
+ export var getContactMethodEntry = function (contactMethodId) {
3
+ var entries = StoreHelper.getEntryStore();
4
+ return entries.find(function (e) { return e.content.id === +contactMethodId; });
5
+ };
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.38",
3
+ "version": "0.0.1-alpha.39",
4
4
  "description": "Bot Provider Plugin ACE Knowledge Widgets.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Telia Company AB",
@@ -25,10 +25,10 @@
25
25
  "sideEffects": false,
26
26
  "typings": "lib/index.d.ts",
27
27
  "dependencies": {
28
- "@telia-ace/knowledge-widget-adapters": "^1.0.7",
29
- "@telia-ace/knowledge-widget-types-grid": "^1.0.7",
28
+ "@telia-ace/knowledge-widget-adapters": "^1.0.8",
29
+ "@telia-ace/knowledge-widget-types-grid": "^1.0.8",
30
30
  "@telia-ace/knowledge-widget-ui": "^1.0.7",
31
- "@telia-ace/widget-conversation": "^1.0.6",
31
+ "@telia-ace/widget-conversation": "^1.0.7",
32
32
  "@telia-ace/widget-forms": "^1.0.6",
33
33
  "@telia-ace/widget-services": "^1.0.4",
34
34
  "@webprovisions/bootstrapping": "^1.0.12",
@@ -41,5 +41,5 @@
41
41
  "devDependencies": {
42
42
  "@types/uuid": "^8.3.4"
43
43
  },
44
- "gitHead": "f926c4ce9547bb480c1c83dd7269387456e0e985"
44
+ "gitHead": "7cc9d6b80523ae90df0ef4ef67cb4e20689b10cb"
45
45
  }