@webuildbots/webuildbots-sdk 11.1.2 → 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;
@@ -0,0 +1,25 @@
1
+ export default class IntentService {
2
+ private apiService;
3
+ private client;
4
+ constructor(token: string, client: string, rootURL?: string);
5
+ createIntent(title: string, utterances: string[], name: 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>;
17
+ getIntents(searchText?: string): Promise<any>;
18
+ deleteIntent(_id: string): Promise<any>;
19
+ createMapping(block: {
20
+ blockId: string;
21
+ module?: string;
22
+ }, intentId: string): Promise<any>;
23
+ deleteMapping(_id: string): Promise<any>;
24
+ getMappings(responseId?: string): Promise<any>;
25
+ }
@@ -0,0 +1,267 @@
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 IntentService = /** @class */ (function () {
44
+ function IntentService(token, client, rootURL) {
45
+ this.apiService = new ApiService_1.default(token, rootURL);
46
+ this.client = client;
47
+ }
48
+ IntentService.prototype.createIntent = function (title, utterances, name, groups, parentName, module, isWbbDocument) {
49
+ return __awaiter(this, void 0, void 0, function () {
50
+ var intent, res, options, e_1;
51
+ return __generator(this, function (_a) {
52
+ switch (_a.label) {
53
+ case 0:
54
+ intent = {
55
+ title: title,
56
+ utterances: utterances,
57
+ name: name,
58
+ created: new Date(),
59
+ groups: groups,
60
+ parentName: parentName,
61
+ module: module,
62
+ isWbbDocument: isWbbDocument
63
+ };
64
+ options = {
65
+ method: 'POST',
66
+ data: intent
67
+ };
68
+ _a.label = 1;
69
+ case 1:
70
+ _a.trys.push([1, 3, , 4]);
71
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/intent', this.client, options)];
72
+ case 2:
73
+ res = _a.sent();
74
+ return [3 /*break*/, 4];
75
+ case 3:
76
+ e_1 = _a.sent();
77
+ throw Error(e_1);
78
+ case 4: return [2 /*return*/, res];
79
+ }
80
+ });
81
+ });
82
+ };
83
+ IntentService.prototype.updateIntent = function (_id, body) {
84
+ return __awaiter(this, void 0, void 0, function () {
85
+ var oldIntent, intent, res, options, e_2;
86
+ return __generator(this, function (_a) {
87
+ switch (_a.label) {
88
+ case 0: return [4 /*yield*/, this.getIntent(_id)];
89
+ case 1:
90
+ oldIntent = _a.sent();
91
+ intent = {
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
101
+ };
102
+ options = {
103
+ method: 'PUT',
104
+ data: intent
105
+ };
106
+ _a.label = 2;
107
+ case 2:
108
+ _a.trys.push([2, 4, , 5]);
109
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/intent/' + _id, this.client, options)];
110
+ case 3:
111
+ res = _a.sent();
112
+ return [3 /*break*/, 5];
113
+ case 4:
114
+ e_2 = _a.sent();
115
+ throw Error(e_2);
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; })];
130
+ }
131
+ });
132
+ });
133
+ };
134
+ IntentService.prototype.getIntents = function (searchText) {
135
+ return __awaiter(this, void 0, void 0, function () {
136
+ var res, options, e_3;
137
+ return __generator(this, function (_a) {
138
+ switch (_a.label) {
139
+ case 0:
140
+ options = {
141
+ method: 'GET',
142
+ params: {
143
+ q: searchText
144
+ }
145
+ };
146
+ _a.label = 1;
147
+ case 1:
148
+ _a.trys.push([1, 3, , 4]);
149
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/intent', this.client, options)];
150
+ case 2:
151
+ res = _a.sent();
152
+ return [3 /*break*/, 4];
153
+ case 3:
154
+ e_3 = _a.sent();
155
+ throw Error(e_3);
156
+ case 4: return [2 /*return*/, res];
157
+ }
158
+ });
159
+ });
160
+ };
161
+ IntentService.prototype.deleteIntent = function (_id) {
162
+ return __awaiter(this, void 0, void 0, function () {
163
+ var res, options, e_4;
164
+ return __generator(this, function (_a) {
165
+ switch (_a.label) {
166
+ case 0:
167
+ options = {
168
+ method: 'DELETE'
169
+ };
170
+ _a.label = 1;
171
+ case 1:
172
+ _a.trys.push([1, 3, , 4]);
173
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/intent/' + _id, this.client, options)];
174
+ case 2:
175
+ res = _a.sent();
176
+ return [3 /*break*/, 4];
177
+ case 3:
178
+ e_4 = _a.sent();
179
+ throw Error(e_4);
180
+ case 4: return [2 /*return*/, res];
181
+ }
182
+ });
183
+ });
184
+ };
185
+ IntentService.prototype.createMapping = function (block, intentId) {
186
+ return __awaiter(this, void 0, void 0, function () {
187
+ var res, options, e_5;
188
+ return __generator(this, function (_a) {
189
+ switch (_a.label) {
190
+ case 0:
191
+ options = {
192
+ method: 'POST',
193
+ data: {
194
+ block: block,
195
+ intentId: intentId
196
+ }
197
+ };
198
+ _a.label = 1;
199
+ case 1:
200
+ _a.trys.push([1, 3, , 4]);
201
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/intent-mapping', this.client, options)];
202
+ case 2:
203
+ res = _a.sent();
204
+ return [3 /*break*/, 4];
205
+ case 3:
206
+ e_5 = _a.sent();
207
+ throw Error(e_5);
208
+ case 4: return [2 /*return*/, res];
209
+ }
210
+ });
211
+ });
212
+ };
213
+ IntentService.prototype.deleteMapping = function (_id) {
214
+ return __awaiter(this, void 0, void 0, function () {
215
+ var res, options, e_6;
216
+ return __generator(this, function (_a) {
217
+ switch (_a.label) {
218
+ case 0:
219
+ options = {
220
+ method: 'DELETE'
221
+ };
222
+ _a.label = 1;
223
+ case 1:
224
+ _a.trys.push([1, 3, , 4]);
225
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/intent-mapping/' + _id, this.client, options)];
226
+ case 2:
227
+ res = _a.sent();
228
+ return [3 /*break*/, 4];
229
+ case 3:
230
+ e_6 = _a.sent();
231
+ throw Error(e_6);
232
+ case 4: return [2 /*return*/, res];
233
+ }
234
+ });
235
+ });
236
+ };
237
+ IntentService.prototype.getMappings = function (responseId) {
238
+ return __awaiter(this, void 0, void 0, function () {
239
+ var res, options, e_7;
240
+ return __generator(this, function (_a) {
241
+ switch (_a.label) {
242
+ case 0:
243
+ options = {
244
+ method: 'GET'
245
+ };
246
+ _a.label = 1;
247
+ case 1:
248
+ _a.trys.push([1, 3, , 4]);
249
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/intent-mapping', this.client, options)];
250
+ case 2:
251
+ res = _a.sent();
252
+ return [3 /*break*/, 4];
253
+ case 3:
254
+ e_7 = _a.sent();
255
+ throw Error(e_7);
256
+ case 4:
257
+ if (res && responseId) {
258
+ res = res.filter(function (mapping) { return mapping.block.blockId == responseId; });
259
+ }
260
+ return [2 /*return*/, res];
261
+ }
262
+ });
263
+ });
264
+ };
265
+ return IntentService;
266
+ }());
267
+ exports.default = IntentService;
@@ -0,0 +1,25 @@
1
+ import { BlockTypes } from '../const/block-enums';
2
+ import BlockObj from '../interfaces/block';
3
+ export default class ResponseService {
4
+ private apiService;
5
+ private client;
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>;
22
+ deleteResponse(blockId: any): Promise<any>;
23
+ getResponses(searchText?: string, types?: any[], groups?: any[]): Promise<any>;
24
+ getResponse(id: any): Promise<any>;
25
+ }