@webuildbots/webuildbots-sdk 11.1.2 → 11.2.1

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,7 @@
1
+ import BlockBuilder from './block-builder';
2
+ export default class KnowledgeBaseBB extends BlockBuilder {
3
+ constructor();
4
+ addContent(text: string, url?: string): this;
5
+ setLastScrape(): this;
6
+ setAutoUpdate(autoUpdate: boolean): this;
7
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ var block_enums_1 = require("../../const/block-enums");
20
+ var block_builder_1 = __importDefault(require("./block-builder"));
21
+ var KnowledgeBaseBB = /** @class */ (function (_super) {
22
+ __extends(KnowledgeBaseBB, _super);
23
+ function KnowledgeBaseBB() {
24
+ var _this = _super.call(this) || this;
25
+ _this.block.type = block_enums_1.BlockTypes.KNOWLEDGE_BASE;
26
+ _this.block.content.kb = {
27
+ autoUpdate: false
28
+ };
29
+ return _this;
30
+ }
31
+ KnowledgeBaseBB.prototype.addContent = function (text, url) {
32
+ this.block.content.kb.text = text;
33
+ this.block.content.kb.url = url;
34
+ return this;
35
+ };
36
+ KnowledgeBaseBB.prototype.setLastScrape = function () {
37
+ this.block.content.kb.lastScrape = new Date();
38
+ return this;
39
+ };
40
+ KnowledgeBaseBB.prototype.setAutoUpdate = function (autoUpdate) {
41
+ this.block.content.kb.autoUpdate = autoUpdate;
42
+ return this;
43
+ };
44
+ return KnowledgeBaseBB;
45
+ }(block_builder_1.default));
46
+ exports.default = KnowledgeBaseBB;
@@ -0,0 +1,26 @@
1
+ export declare enum AuditTypes {
2
+ EDIT_ENTITY = "EDIT_ENTITY",
3
+ CREATE_ENTITY = "CREATE_ENTITY",
4
+ DELETE_ENTITY = "DELETE_ENTITY",
5
+ EDIT_INTENT = "EDIT_INTENT",
6
+ CREATE_INTENT = "CREATE_INTENT",
7
+ DELETE_INTENT = "DELETE_INTENT",
8
+ CREATE_BUILD = "CREATE_BUILD",
9
+ DELETE_QUESTION = "DELETE_QUESTION",
10
+ COMPLETE_TAKEOVER = "COMPLETE_TAKEOVER",
11
+ EDIT_BLOCK = "EDIT_BLOCK",
12
+ CREATE_BLOCK = "CREATE_BLOCK",
13
+ DELETE_BLOCK = "DELETE_BLOCK",
14
+ CREATE_AGENT = "CREATE_AGENT",
15
+ EDIT_AGENT = "EDIT_AGENT",
16
+ DELETE_AGENT = "DELETE_AGENT",
17
+ CREATE_FORM = "CREATE_FORM",
18
+ EDIT_FORM = "EDIT_FORM",
19
+ DELETE_FORM = "DELETE_FORM",
20
+ START_TAKEOVER = "START_TAKEOVER",
21
+ GENERATE_UTTERANCES = "GENERATE_UTTERANCES",
22
+ CREATE_ENTITY_MAPPING = "CREATE_ENTITY_MAPPING",
23
+ DELETE_ENTITY_MAPPING = "DELETE_ENTITY_MAPPING",
24
+ CREATE_INTENT_MAPPING = "CREATE_INTENT_MAPPING",
25
+ DELETE_INTENT_MAPPING = "DELETE_INTENT_MAPPING"
26
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuditTypes = void 0;
4
+ var AuditTypes;
5
+ (function (AuditTypes) {
6
+ AuditTypes["EDIT_ENTITY"] = "EDIT_ENTITY";
7
+ AuditTypes["CREATE_ENTITY"] = "CREATE_ENTITY";
8
+ AuditTypes["DELETE_ENTITY"] = "DELETE_ENTITY";
9
+ AuditTypes["EDIT_INTENT"] = "EDIT_INTENT";
10
+ AuditTypes["CREATE_INTENT"] = "CREATE_INTENT";
11
+ AuditTypes["DELETE_INTENT"] = "DELETE_INTENT";
12
+ AuditTypes["CREATE_BUILD"] = "CREATE_BUILD";
13
+ AuditTypes["DELETE_QUESTION"] = "DELETE_QUESTION";
14
+ AuditTypes["COMPLETE_TAKEOVER"] = "COMPLETE_TAKEOVER";
15
+ AuditTypes["EDIT_BLOCK"] = "EDIT_BLOCK";
16
+ AuditTypes["CREATE_BLOCK"] = "CREATE_BLOCK";
17
+ AuditTypes["DELETE_BLOCK"] = "DELETE_BLOCK";
18
+ AuditTypes["CREATE_AGENT"] = "CREATE_AGENT";
19
+ AuditTypes["EDIT_AGENT"] = "EDIT_AGENT";
20
+ AuditTypes["DELETE_AGENT"] = "DELETE_AGENT";
21
+ AuditTypes["CREATE_FORM"] = "CREATE_FORM";
22
+ AuditTypes["EDIT_FORM"] = "EDIT_FORM";
23
+ AuditTypes["DELETE_FORM"] = "DELETE_FORM";
24
+ AuditTypes["START_TAKEOVER"] = "START_TAKEOVER";
25
+ AuditTypes["GENERATE_UTTERANCES"] = "GENERATE_UTTERANCES";
26
+ AuditTypes["CREATE_ENTITY_MAPPING"] = "CREATE_ENTITY_MAPPING";
27
+ AuditTypes["DELETE_ENTITY_MAPPING"] = "DELETE_ENTITY_MAPPING";
28
+ AuditTypes["CREATE_INTENT_MAPPING"] = "CREATE_INTENT_MAPPING";
29
+ AuditTypes["DELETE_INTENT_MAPPING"] = "DELETE_INTENT_MAPPING";
30
+ })(AuditTypes = exports.AuditTypes || (exports.AuditTypes = {}));
@@ -14,7 +14,8 @@ export declare enum BlockTypes {
14
14
  FUNCTION = "function",
15
15
  DEV_SWITCH = "dev-switch",
16
16
  VARIABLE = "variable",
17
- MEDIA = "media"
17
+ MEDIA = "media",
18
+ KNOWLEDGE_BASE = "kb"
18
19
  }
19
20
  export declare enum ChoiceTypes {
20
21
  QREPLY = "qreply",
@@ -20,6 +20,7 @@ var BlockTypes;
20
20
  BlockTypes["DEV_SWITCH"] = "dev-switch";
21
21
  BlockTypes["VARIABLE"] = "variable";
22
22
  BlockTypes["MEDIA"] = "media";
23
+ BlockTypes["KNOWLEDGE_BASE"] = "kb";
23
24
  })(BlockTypes = exports.BlockTypes || (exports.BlockTypes = {}));
24
25
  var ChoiceTypes;
25
26
  (function (ChoiceTypes) {
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import BlockBuilder from './builder/block/block-builder';
2
2
  import BasicBB from './builder/block/basic-bb';
3
+ import KnowledgeBaseBB from './builder/block/kb-bb';
3
4
  import GalleryBB from './builder/block/gallery-bb';
4
5
  import ComplexBB from './builder/block/complex-bb';
5
6
  import DevSwitchBB from './builder/block/dev-switch-bb';
@@ -23,4 +24,9 @@ import ResponseBuilder from './builder/response-builder';
23
24
  import { WebhookRequest, WebhookResponse, ResponseUnitType, ResponseUnit, BlockPointer, Client, JWTPayload } from './interfaces/webhook';
24
25
  import LogicBB from './builder/block/logic-bb';
25
26
  import ImageBB from './builder/block/image-bb';
26
- export { BlockBuilder, ComplexBB, FunctionBB, EmailFormTableBB, UnsetFormBB, MediaBB, ImageBB, SelectBB, TextBB, VideoBB, DevSwitchBB, LogicBB, BlockCB, ChoiceBuilder, DefinedCB, DefinedIB, ExtensionCB, LocationCB, PhoneCB, UrlCB, GalleryBB, BasicBB, ItemBuilder, WebhookResponse, WebhookRequest, ResponseUnit, ResponseUnitType, BlockPointer, ResponseBuilder, Client, JWTPayload };
27
+ import ResponseService from './services/ResponseService';
28
+ import EntityService from './services/EntityService';
29
+ import IntentService from './services/IntentService';
30
+ import AIService from './services/AIService';
31
+ import AuditService from './services/AuditService';
32
+ export { BlockBuilder, ComplexBB, FunctionBB, EmailFormTableBB, UnsetFormBB, MediaBB, ImageBB, SelectBB, TextBB, VideoBB, DevSwitchBB, LogicBB, BlockCB, ChoiceBuilder, DefinedCB, DefinedIB, ExtensionCB, LocationCB, PhoneCB, UrlCB, GalleryBB, BasicBB, KnowledgeBaseBB, ItemBuilder, WebhookResponse, WebhookRequest, ResponseUnit, ResponseUnitType, BlockPointer, ResponseBuilder, Client, JWTPayload, ResponseService, IntentService, EntityService, AIService, AuditService };
package/lib/index.js CHANGED
@@ -3,11 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ResponseBuilder = exports.ResponseUnitType = exports.ItemBuilder = exports.BasicBB = exports.GalleryBB = exports.UrlCB = exports.PhoneCB = exports.LocationCB = exports.ExtensionCB = exports.DefinedIB = exports.DefinedCB = exports.ChoiceBuilder = exports.BlockCB = exports.LogicBB = exports.DevSwitchBB = exports.VideoBB = exports.TextBB = exports.SelectBB = exports.ImageBB = exports.MediaBB = exports.UnsetFormBB = exports.EmailFormTableBB = exports.FunctionBB = exports.ComplexBB = exports.BlockBuilder = void 0;
6
+ exports.AuditService = exports.AIService = exports.EntityService = exports.IntentService = exports.ResponseService = exports.ResponseBuilder = exports.ResponseUnitType = exports.ItemBuilder = exports.KnowledgeBaseBB = exports.BasicBB = exports.GalleryBB = exports.UrlCB = exports.PhoneCB = exports.LocationCB = exports.ExtensionCB = exports.DefinedIB = exports.DefinedCB = exports.ChoiceBuilder = exports.BlockCB = exports.LogicBB = exports.DevSwitchBB = exports.VideoBB = exports.TextBB = exports.SelectBB = exports.ImageBB = exports.MediaBB = exports.UnsetFormBB = exports.EmailFormTableBB = exports.FunctionBB = exports.ComplexBB = exports.BlockBuilder = void 0;
7
7
  var block_builder_1 = __importDefault(require("./builder/block/block-builder"));
8
8
  exports.BlockBuilder = block_builder_1.default;
9
9
  var basic_bb_1 = __importDefault(require("./builder/block/basic-bb"));
10
10
  exports.BasicBB = basic_bb_1.default;
11
+ var kb_bb_1 = __importDefault(require("./builder/block/kb-bb"));
12
+ exports.KnowledgeBaseBB = kb_bb_1.default;
11
13
  var gallery_bb_1 = __importDefault(require("./builder/block/gallery-bb"));
12
14
  exports.GalleryBB = gallery_bb_1.default;
13
15
  var complex_bb_1 = __importDefault(require("./builder/block/complex-bb"));
@@ -54,3 +56,13 @@ var logic_bb_1 = __importDefault(require("./builder/block/logic-bb"));
54
56
  exports.LogicBB = logic_bb_1.default;
55
57
  var image_bb_1 = __importDefault(require("./builder/block/image-bb"));
56
58
  exports.ImageBB = image_bb_1.default;
59
+ var ResponseService_1 = __importDefault(require("./services/ResponseService"));
60
+ exports.ResponseService = ResponseService_1.default;
61
+ var EntityService_1 = __importDefault(require("./services/EntityService"));
62
+ exports.EntityService = EntityService_1.default;
63
+ var IntentService_1 = __importDefault(require("./services/IntentService"));
64
+ exports.IntentService = IntentService_1.default;
65
+ var AIService_1 = __importDefault(require("./services/AIService"));
66
+ exports.AIService = AIService_1.default;
67
+ var AuditService_1 = __importDefault(require("./services/AuditService"));
68
+ exports.AuditService = AuditService_1.default;
@@ -0,0 +1,15 @@
1
+ import { BlockTypes } from '../const/block-enums';
2
+ export interface BlockFormState {
3
+ _id: string;
4
+ blockVersion: number;
5
+ blockId: string;
6
+ content: any;
7
+ created: string;
8
+ defaultChoice?: any;
9
+ function?: any;
10
+ group: string;
11
+ meta: any;
12
+ name: string;
13
+ type: BlockTypes.TEXT | BlockTypes.COMPLEX | BlockTypes.MEDIA | undefined;
14
+ version: number;
15
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -120,6 +120,12 @@ export default interface BlockObj {
120
120
  };
121
121
  serialized?: string;
122
122
  }>;
123
+ kb?: {
124
+ lastScrape?: Date;
125
+ url?: string;
126
+ text?: string;
127
+ autoUpdate?: boolean;
128
+ };
123
129
  };
124
130
  function?: {
125
131
  name?: string;
@@ -0,0 +1,9 @@
1
+ export default class AIService {
2
+ private apiService;
3
+ private client;
4
+ private GPT3_MODEL_NAME;
5
+ constructor(token: string, client: string, rootURL?: string);
6
+ buildModel(note: string, emailNotification: boolean): Promise<any>;
7
+ generateUtterances(utterances: string[], numAlternatives?: number, modelName?: string): Promise<any>;
8
+ getTasks(): Promise<any>;
9
+ }
@@ -0,0 +1,131 @@
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 AIService = /** @class */ (function () {
44
+ function AIService(token, client, rootURL) {
45
+ this.GPT3_MODEL_NAME = 'text-davinci-003';
46
+ this.apiService = new ApiService_1.default(token, rootURL);
47
+ this.client = client;
48
+ }
49
+ AIService.prototype.buildModel = function (note, emailNotification) {
50
+ return __awaiter(this, void 0, void 0, function () {
51
+ var res, options, e_1;
52
+ return __generator(this, function (_a) {
53
+ switch (_a.label) {
54
+ case 0:
55
+ options = {
56
+ method: 'POST',
57
+ data: { note: note, emailNotification: emailNotification }
58
+ };
59
+ _a.label = 1;
60
+ case 1:
61
+ _a.trys.push([1, 3, , 4]);
62
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/build-model', this.client, options)];
63
+ case 2:
64
+ res = _a.sent();
65
+ return [3 /*break*/, 4];
66
+ case 3:
67
+ e_1 = _a.sent();
68
+ throw Error(e_1);
69
+ case 4: return [2 /*return*/, res];
70
+ }
71
+ });
72
+ });
73
+ };
74
+ AIService.prototype.generateUtterances = function (utterances, numAlternatives, modelName) {
75
+ if (numAlternatives === void 0) { numAlternatives = 10; }
76
+ if (modelName === void 0) { modelName = this.GPT3_MODEL_NAME; }
77
+ return __awaiter(this, void 0, void 0, function () {
78
+ var emptyArray, res, options, e_2;
79
+ return __generator(this, function (_a) {
80
+ switch (_a.label) {
81
+ case 0:
82
+ if (!utterances.length) {
83
+ emptyArray = [];
84
+ return [2 /*return*/, { data: { data: emptyArray } }];
85
+ }
86
+ options = {
87
+ method: 'POST',
88
+ data: { utterances: utterances, numAlternatives: numAlternatives, modelName: modelName }
89
+ };
90
+ _a.label = 1;
91
+ case 1:
92
+ _a.trys.push([1, 3, , 4]);
93
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/generate-utterances', this.client, options)];
94
+ case 2:
95
+ res = _a.sent();
96
+ return [3 /*break*/, 4];
97
+ case 3:
98
+ e_2 = _a.sent();
99
+ throw Error(e_2);
100
+ case 4: return [2 /*return*/, res];
101
+ }
102
+ });
103
+ });
104
+ };
105
+ AIService.prototype.getTasks = function () {
106
+ return __awaiter(this, void 0, void 0, function () {
107
+ var res, options, e_3;
108
+ return __generator(this, function (_a) {
109
+ switch (_a.label) {
110
+ case 0:
111
+ options = {
112
+ method: 'GET'
113
+ };
114
+ _a.label = 1;
115
+ case 1:
116
+ _a.trys.push([1, 3, , 4]);
117
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/knowlbase/build-tasks', this.client, options)];
118
+ case 2:
119
+ res = _a.sent();
120
+ return [3 /*break*/, 4];
121
+ case 3:
122
+ e_3 = _a.sent();
123
+ throw Error(e_3);
124
+ case 4: return [2 /*return*/, res];
125
+ }
126
+ });
127
+ });
128
+ };
129
+ return AIService;
130
+ }());
131
+ exports.default = AIService;
@@ -0,0 +1,20 @@
1
+ export default class ApiService {
2
+ private sdkToken;
3
+ private baseURL;
4
+ constructor(sdkToken: any, rootURL?: string);
5
+ hitApi(endpoint: any, client: any, options: any): Promise<{
6
+ status: {
7
+ httpCode: number;
8
+ statusText: string;
9
+ };
10
+ data: any;
11
+ error: any;
12
+ } | {
13
+ status: {
14
+ httpCode: any;
15
+ statusText: any;
16
+ };
17
+ data: any;
18
+ error: any;
19
+ }>;
20
+ }
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ var axios_1 = __importDefault(require("axios"));
54
+ var ApiService = /** @class */ (function () {
55
+ function ApiService(sdkToken, rootURL) {
56
+ if (rootURL === void 0) { rootURL = 'https://backend.logicdialog.ai'; }
57
+ this.sdkToken = sdkToken;
58
+ this.sdkToken = sdkToken;
59
+ this.baseURL = rootURL;
60
+ }
61
+ ApiService.prototype.hitApi = function (endpoint, client, options) {
62
+ var _a, _b;
63
+ return __awaiter(this, void 0, void 0, function () {
64
+ var headers, response, data, error_1, errorMessage;
65
+ var _c;
66
+ return __generator(this, function (_d) {
67
+ switch (_d.label) {
68
+ case 0:
69
+ _d.trys.push([0, 2, , 3]);
70
+ headers = __assign((_c = { Authorization: 'Bearer ' + this.sdkToken, Accept: 'application/json', 'wbb-client': client, 'Access-Control-Allow-Origin': '*', origin: new URL(this.baseURL).origin }, _c['Content-Type'] = 'text/plain', _c), options.headers);
71
+ return [4 /*yield*/, axios_1.default(__assign(__assign({}, options), { url: this.baseURL + "/" + endpoint, headers: headers }))];
72
+ case 1:
73
+ response = _d.sent();
74
+ data = ((_a = response.data) === null || _a === void 0 ? void 0 : _a.data) || response.data;
75
+ return [2 /*return*/, {
76
+ status: { httpCode: response.status, statusText: response.statusText },
77
+ data: data,
78
+ error: null
79
+ }];
80
+ case 2:
81
+ error_1 = _d.sent();
82
+ errorMessage = error_1.response
83
+ ? (_b = error_1.response.data) === null || _b === void 0 ? void 0 : _b.error : error_1.message;
84
+ return [2 /*return*/, {
85
+ status: {
86
+ httpCode: error_1.response.status,
87
+ statusText: error_1.response.statusText
88
+ },
89
+ data: null,
90
+ error: errorMessage
91
+ }];
92
+ case 3: return [2 /*return*/];
93
+ }
94
+ });
95
+ });
96
+ };
97
+ return ApiService;
98
+ }());
99
+ exports.default = ApiService;
@@ -0,0 +1,8 @@
1
+ import { AuditTypes } from '../const/audit-types';
2
+ export default class AIService {
3
+ private apiService;
4
+ private client;
5
+ constructor(token: string, client: string, rootURL?: string);
6
+ createAudit(type: AuditTypes, data: any, userId?: string): Promise<any>;
7
+ getAudit(type?: string, action?: string, from?: string, to?: string, artifact?: string): Promise<any>;
8
+ }
@@ -0,0 +1,100 @@
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 AIService = /** @class */ (function () {
44
+ function AIService(token, client, rootURL) {
45
+ this.apiService = new ApiService_1.default(token, rootURL);
46
+ this.client = client;
47
+ }
48
+ AIService.prototype.createAudit = function (type, data, userId) {
49
+ return __awaiter(this, void 0, void 0, function () {
50
+ var res, options, e_1;
51
+ return __generator(this, function (_a) {
52
+ switch (_a.label) {
53
+ case 0:
54
+ options = {
55
+ method: 'POST',
56
+ data: { type: type, data: data, userId: userId }
57
+ };
58
+ _a.label = 1;
59
+ case 1:
60
+ _a.trys.push([1, 3, , 4]);
61
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/audit', this.client, options)];
62
+ case 2:
63
+ res = _a.sent();
64
+ return [3 /*break*/, 4];
65
+ case 3:
66
+ e_1 = _a.sent();
67
+ throw Error(e_1);
68
+ case 4: return [2 /*return*/, res];
69
+ }
70
+ });
71
+ });
72
+ };
73
+ AIService.prototype.getAudit = function (type, action, from, to, artifact) {
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ var res, options, e_2;
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0:
79
+ options = {
80
+ method: 'GET',
81
+ params: { type: type, action: action, from: from, to: to, artifact: artifact }
82
+ };
83
+ _a.label = 1;
84
+ case 1:
85
+ _a.trys.push([1, 3, , 4]);
86
+ return [4 /*yield*/, this.apiService.hitApi('api/agent/audit', this.client, options)];
87
+ case 2:
88
+ res = _a.sent();
89
+ return [3 /*break*/, 4];
90
+ case 3:
91
+ e_2 = _a.sent();
92
+ throw Error(e_2);
93
+ case 4: return [2 /*return*/, res];
94
+ }
95
+ });
96
+ });
97
+ };
98
+ return AIService;
99
+ }());
100
+ exports.default = AIService;
@@ -0,0 +1,24 @@
1
+ export default class EntityService {
2
+ private apiService;
3
+ private client;
4
+ constructor(token: string, client: string, rootURL?: string);
5
+ createEntity(title: string, values: Record<string, any>[], name: string, template?: string, module?: string, isWbbDocument?: boolean): Promise<any>;
6
+ updateEntity(_id: string, body: {
7
+ title?: string;
8
+ values?: Record<string, any>[];
9
+ name?: string;
10
+ created?: string;
11
+ template?: string;
12
+ module?: string;
13
+ isWbbDocument?: boolean;
14
+ }): Promise<any>;
15
+ getEntity(id: any): Promise<any>;
16
+ getEntities(searchText?: string): Promise<any>;
17
+ deleteEntity(_id: string): Promise<any>;
18
+ createMapping(block: {
19
+ blockId: string;
20
+ module?: string;
21
+ }, entityId: string): Promise<any>;
22
+ deleteMapping(_id: string): Promise<any>;
23
+ getMappings(responseId?: string): Promise<any>;
24
+ }