@webuildbots/webuildbots-sdk 11.1.1 → 11.2.0

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.
@@ -0,0 +1,265 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var ApiService_1 = __importDefault(require("./ApiService"));
43
+ var EntityService = /** @class */ (function () {
44
+ function EntityService(token, client, rootURL) {
45
+ this.apiService = new ApiService_1.default(token, rootURL);
46
+ this.client = client;
47
+ }
48
+ EntityService.prototype.createEntity = function (title, values, name, template, module, isWbbDocument) {
49
+ return __awaiter(this, void 0, void 0, function () {
50
+ var entity, res, options, e_1;
51
+ return __generator(this, function (_a) {
52
+ switch (_a.label) {
53
+ case 0:
54
+ entity = {
55
+ title: title,
56
+ values: values,
57
+ name: name,
58
+ created: new Date(),
59
+ template: template,
60
+ module: module,
61
+ isWbbDocument: isWbbDocument
62
+ };
63
+ options = {
64
+ method: 'POST',
65
+ data: entity
66
+ };
67
+ _a.label = 1;
68
+ case 1:
69
+ _a.trys.push([1, 3, , 4]);
70
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/entity', this.client, options)];
71
+ case 2:
72
+ res = _a.sent();
73
+ return [3 /*break*/, 4];
74
+ case 3:
75
+ e_1 = _a.sent();
76
+ throw Error(e_1);
77
+ case 4: return [2 /*return*/, res];
78
+ }
79
+ });
80
+ });
81
+ };
82
+ EntityService.prototype.updateEntity = function (_id, body) {
83
+ return __awaiter(this, void 0, void 0, function () {
84
+ var oldEntity, entity, res, options, e_2;
85
+ return __generator(this, function (_a) {
86
+ switch (_a.label) {
87
+ case 0: return [4 /*yield*/, this.getEntity(_id)];
88
+ case 1:
89
+ oldEntity = _a.sent();
90
+ entity = {
91
+ _id: _id,
92
+ title: body.title,
93
+ values: body.values,
94
+ name: body.name || oldEntity[0].name,
95
+ template: body.template,
96
+ module: body.module,
97
+ isWbbDocument: body.isWbbDocument,
98
+ created: body.created || oldEntity[0].created
99
+ };
100
+ options = {
101
+ method: 'PUT',
102
+ data: entity
103
+ };
104
+ _a.label = 2;
105
+ case 2:
106
+ _a.trys.push([2, 4, , 5]);
107
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/intent/' + _id, this.client, options)];
108
+ case 3:
109
+ res = _a.sent();
110
+ return [3 /*break*/, 5];
111
+ case 4:
112
+ e_2 = _a.sent();
113
+ throw Error(e_2);
114
+ case 5: return [2 /*return*/, res];
115
+ }
116
+ });
117
+ });
118
+ };
119
+ EntityService.prototype.getEntity = function (id) {
120
+ return __awaiter(this, void 0, void 0, function () {
121
+ var fetchResponse;
122
+ return __generator(this, function (_a) {
123
+ switch (_a.label) {
124
+ case 0: return [4 /*yield*/, this.getEntities()];
125
+ case 1:
126
+ fetchResponse = _a.sent();
127
+ return [2 /*return*/, fetchResponse.data.filter(function (entity) { return entity._id == id; })];
128
+ }
129
+ });
130
+ });
131
+ };
132
+ EntityService.prototype.getEntities = function (searchText) {
133
+ return __awaiter(this, void 0, void 0, function () {
134
+ var res, options, e_3;
135
+ return __generator(this, function (_a) {
136
+ switch (_a.label) {
137
+ case 0:
138
+ options = {
139
+ method: 'GET',
140
+ params: {
141
+ q: searchText
142
+ }
143
+ };
144
+ _a.label = 1;
145
+ case 1:
146
+ _a.trys.push([1, 3, , 4]);
147
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/entity', this.client, options)];
148
+ case 2:
149
+ res = _a.sent();
150
+ return [3 /*break*/, 4];
151
+ case 3:
152
+ e_3 = _a.sent();
153
+ throw Error(e_3);
154
+ case 4: return [2 /*return*/, res];
155
+ }
156
+ });
157
+ });
158
+ };
159
+ EntityService.prototype.deleteEntity = function (_id) {
160
+ return __awaiter(this, void 0, void 0, function () {
161
+ var res, options, e_4;
162
+ return __generator(this, function (_a) {
163
+ switch (_a.label) {
164
+ case 0:
165
+ options = {
166
+ method: 'DELETE'
167
+ };
168
+ _a.label = 1;
169
+ case 1:
170
+ _a.trys.push([1, 3, , 4]);
171
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/intent/' + _id, this.client, options)];
172
+ case 2:
173
+ res = _a.sent();
174
+ return [3 /*break*/, 4];
175
+ case 3:
176
+ e_4 = _a.sent();
177
+ throw Error(e_4);
178
+ case 4: return [2 /*return*/, res];
179
+ }
180
+ });
181
+ });
182
+ };
183
+ EntityService.prototype.createMapping = function (block, entityId) {
184
+ return __awaiter(this, void 0, void 0, function () {
185
+ var res, options, e_5;
186
+ return __generator(this, function (_a) {
187
+ switch (_a.label) {
188
+ case 0:
189
+ options = {
190
+ method: 'POST',
191
+ data: {
192
+ block: block,
193
+ entityId: entityId
194
+ }
195
+ };
196
+ _a.label = 1;
197
+ case 1:
198
+ _a.trys.push([1, 3, , 4]);
199
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/entity-mapping', this.client, options)];
200
+ case 2:
201
+ res = _a.sent();
202
+ return [3 /*break*/, 4];
203
+ case 3:
204
+ e_5 = _a.sent();
205
+ throw Error(e_5);
206
+ case 4: return [2 /*return*/, res];
207
+ }
208
+ });
209
+ });
210
+ };
211
+ EntityService.prototype.deleteMapping = function (_id) {
212
+ return __awaiter(this, void 0, void 0, function () {
213
+ var res, options, e_6;
214
+ return __generator(this, function (_a) {
215
+ switch (_a.label) {
216
+ case 0:
217
+ options = {
218
+ method: 'DELETE'
219
+ };
220
+ _a.label = 1;
221
+ case 1:
222
+ _a.trys.push([1, 3, , 4]);
223
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/entity-mapping/' + _id, this.client, options)];
224
+ case 2:
225
+ res = _a.sent();
226
+ return [3 /*break*/, 4];
227
+ case 3:
228
+ e_6 = _a.sent();
229
+ throw Error(e_6);
230
+ case 4: return [2 /*return*/, res];
231
+ }
232
+ });
233
+ });
234
+ };
235
+ EntityService.prototype.getMappings = function (responseId) {
236
+ return __awaiter(this, void 0, void 0, function () {
237
+ var res, options, e_7;
238
+ return __generator(this, function (_a) {
239
+ switch (_a.label) {
240
+ case 0:
241
+ options = {
242
+ method: 'GET'
243
+ };
244
+ _a.label = 1;
245
+ case 1:
246
+ _a.trys.push([1, 3, , 4]);
247
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/entity-mapping', this.client, options)];
248
+ case 2:
249
+ res = _a.sent();
250
+ return [3 /*break*/, 4];
251
+ case 3:
252
+ e_7 = _a.sent();
253
+ throw Error(e_7);
254
+ case 4:
255
+ if (res && responseId) {
256
+ res = res.filter(function (mapping) { return mapping.block.blockId == responseId; });
257
+ }
258
+ return [2 /*return*/, res];
259
+ }
260
+ });
261
+ });
262
+ };
263
+ return EntityService;
264
+ }());
265
+ exports.default = EntityService;
@@ -1,9 +1,19 @@
1
1
  export default class IntentService {
2
2
  private apiService;
3
3
  private client;
4
- constructor(token: any, client: any, rootURL: any);
4
+ constructor(token: string, client: string, rootURL?: string);
5
5
  createIntent(title: string, utterances: string[], name: string, groups?: string[], parentName?: string, module?: string, isWbbDocument?: boolean): Promise<any>;
6
- updateIntent(_id: string, title: string, utterances: string[], name: string, created: string, groups?: string[], parentName?: string, module?: string, isWbbDocument?: boolean): Promise<any>;
6
+ updateIntent(_id: string, body: {
7
+ title?: string;
8
+ utterances?: string[];
9
+ name?: string;
10
+ created?: string;
11
+ groups?: string[];
12
+ parentName?: string;
13
+ module?: string;
14
+ isWbbDocument?: boolean;
15
+ }): Promise<any>;
16
+ getIntent(id: any): Promise<any>;
7
17
  getIntents(searchText?: string): Promise<any>;
8
18
  deleteIntent(_id: string): Promise<any>;
9
19
  createMapping(block: {
@@ -63,7 +63,7 @@ var IntentService = /** @class */ (function () {
63
63
  };
64
64
  options = {
65
65
  method: 'POST',
66
- body: intent
66
+ data: intent
67
67
  };
68
68
  _a.label = 1;
69
69
  case 1:
@@ -80,56 +80,73 @@ var IntentService = /** @class */ (function () {
80
80
  });
81
81
  });
82
82
  };
83
- IntentService.prototype.updateIntent = function (_id, title, utterances, name, created, groups, parentName, module, isWbbDocument) {
83
+ IntentService.prototype.updateIntent = function (_id, body) {
84
84
  return __awaiter(this, void 0, void 0, function () {
85
- var intent, res, options, e_2;
85
+ var oldIntent, intent, res, options, e_2;
86
86
  return __generator(this, function (_a) {
87
87
  switch (_a.label) {
88
- case 0:
88
+ case 0: return [4 /*yield*/, this.getIntent(_id)];
89
+ case 1:
90
+ oldIntent = _a.sent();
89
91
  intent = {
90
- title: title,
91
- utterances: utterances,
92
- name: name,
93
- groups: groups,
94
- parentName: parentName,
95
- module: module,
96
- isWbbDocument: isWbbDocument,
97
- created: created
92
+ _id: _id,
93
+ title: body.title,
94
+ utterances: body.utterances,
95
+ name: body.name || oldIntent[0].name,
96
+ groups: body.groups,
97
+ parentName: body.parentName,
98
+ module: body.module,
99
+ isWbbDocument: body.isWbbDocument,
100
+ created: body.created || oldIntent[0].created
98
101
  };
99
102
  options = {
100
103
  method: 'PUT',
101
- body: intent
104
+ data: intent
102
105
  };
103
- _a.label = 1;
104
- case 1:
105
- _a.trys.push([1, 3, , 4]);
106
- return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/intent/' + _id, this.client, options)];
106
+ _a.label = 2;
107
107
  case 2:
108
- res = _a.sent();
109
- return [3 /*break*/, 4];
108
+ _a.trys.push([2, 4, , 5]);
109
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/intent/' + _id, this.client, options)];
110
110
  case 3:
111
+ res = _a.sent();
112
+ return [3 /*break*/, 5];
113
+ case 4:
111
114
  e_2 = _a.sent();
112
115
  throw Error(e_2);
113
- case 4: return [2 /*return*/, res];
116
+ case 5: return [2 /*return*/, res];
117
+ }
118
+ });
119
+ });
120
+ };
121
+ IntentService.prototype.getIntent = function (id) {
122
+ return __awaiter(this, void 0, void 0, function () {
123
+ var fetchResponse;
124
+ return __generator(this, function (_a) {
125
+ switch (_a.label) {
126
+ case 0: return [4 /*yield*/, this.getIntents()];
127
+ case 1:
128
+ fetchResponse = _a.sent();
129
+ return [2 /*return*/, fetchResponse.data.intents.filter(function (intent) { return intent._id == id; })];
114
130
  }
115
131
  });
116
132
  });
117
133
  };
118
134
  IntentService.prototype.getIntents = function (searchText) {
119
135
  return __awaiter(this, void 0, void 0, function () {
120
- var res, options, query, endpoint, e_3;
136
+ var res, options, e_3;
121
137
  return __generator(this, function (_a) {
122
138
  switch (_a.label) {
123
139
  case 0:
124
140
  options = {
125
- method: 'GET'
141
+ method: 'GET',
142
+ params: {
143
+ q: searchText
144
+ }
126
145
  };
127
- query = "?q=" + searchText;
128
- endpoint = 'api/agent/knowlbase/intent';
129
146
  _a.label = 1;
130
147
  case 1:
131
148
  _a.trys.push([1, 3, , 4]);
132
- return [4 /*yield*/, this.apiService.hitApi(searchText ? endpoint + query : endpoint, this.client, options)];
149
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/intent', this.client, options)];
133
150
  case 2:
134
151
  res = _a.sent();
135
152
  return [3 /*break*/, 4];
@@ -173,7 +190,7 @@ var IntentService = /** @class */ (function () {
173
190
  case 0:
174
191
  options = {
175
192
  method: 'POST',
176
- body: {
193
+ data: {
177
194
  block: block,
178
195
  intentId: intentId
179
196
  }
@@ -1,23 +1,25 @@
1
1
  import { BlockTypes } from '../const/block-enums';
2
- import { Languages } from '../const/languages-enums';
2
+ import BlockObj from '../interfaces/block';
3
3
  export default class ResponseService {
4
4
  private apiService;
5
5
  private client;
6
- constructor(token: any, client: any, rootURL: any);
7
- createResponse(title: {
8
- language: Languages;
9
- value: string;
10
- }, module: string, description: string, type: BlockTypes, name?: import("../const/block-enums").CommonGroups, group?: import("../const/block-enums").CommonGroups, variable?: {
11
- title: string;
12
- value: string;
13
- }, formFieldCallbackArgs?: any, next?: string): Promise<any>;
14
- updateResponse(blockId: any, title?: {
15
- language: Languages;
16
- value: string;
17
- }, module?: string, description?: string, type?: BlockTypes, name?: string, group?: string, variable?: {
18
- title: string;
19
- value: string;
20
- }, formFieldCallbackArgs?: any, next?: string): Promise<any>;
6
+ constructor(token: string, client: any, rootURL?: string);
7
+ private formatBlockValues;
8
+ createResponse(content: BlockObj['content'], module: string, description: string, type: BlockTypes, name?: string, group?: string, formFieldCallbackArgs?: BlockObj['formFieldCallback'], next?: string, functionObj?: BlockObj['function']): Promise<any>;
9
+ updateResponse(blockId: any, body: {
10
+ version?: number;
11
+ type?: BlockTypes;
12
+ created?: string;
13
+ content?: BlockObj['content'];
14
+ module?: string;
15
+ description?: string;
16
+ name?: string;
17
+ group?: string;
18
+ formFieldCallbackArgs?: any;
19
+ next?: string;
20
+ function?: BlockObj['function'];
21
+ }): Promise<any>;
21
22
  deleteResponse(blockId: any): Promise<any>;
22
23
  getResponses(searchText?: string, types?: any[], groups?: any[]): Promise<any>;
24
+ getResponse(id: any): Promise<any>;
23
25
  }