@or-sdk/bots 0.26.0-beta.631.0 → 0.26.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.
- package/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/dist/cjs/Bots.js +78 -97
- package/dist/cjs/Bots.js.map +1 -1
- package/dist/cjs/constants.js +3 -5
- package/dist/cjs/constants.js.map +1 -1
- package/dist/esm/Bots.js +100 -97
- package/dist/esm/Bots.js.map +1 -1
- package/dist/esm/constants.js +1 -9
- package/dist/esm/constants.js.map +1 -1
- package/dist/types/Bots.d.ts +8 -7
- package/dist/types/Bots.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -3
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/types.d.ts +24 -3
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/Bots.ts +94 -84
- package/src/constants.ts +1 -12
- package/src/types.ts +28 -5
- package/tsconfig.esm.json +1 -1
- package/dist/cjs/utils/getListQuery.js +0 -24
- package/dist/cjs/utils/getListQuery.js.map +0 -1
- package/dist/cjs/utils/index.js +0 -9
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/esm/utils/getListQuery.js +0 -37
- package/dist/esm/utils/getListQuery.js.map +0 -1
- package/dist/esm/utils/index.js +0 -2
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/types/utils/getListQuery.d.ts +0 -6
- package/dist/types/utils/getListQuery.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts +0 -2
- package/dist/types/utils/index.d.ts.map +0 -1
- package/src/utils/getListQuery.ts +0 -39
- package/src/utils/index.ts +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.26.0](https://gitlab.com/onereach/platform/or-sdk-next/compare/@or-sdk/bots@0.25.6...@or-sdk/bots@0.26.0) (2022-10-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ⚠ BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* **data-hub-svc:** DataHub changed to DataHubSvc, now constructor needs `dataHubSvcUrl` instead of `dataHubUrl`
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **data-hub-svc:** DataHub changed to DataHubSvc, now constructor needs `dataHubSvcUrl` instead of `dataHubUrl` ([bf9c8ff](https://gitlab.com/onereach/platform/or-sdk-next/commit/bf9c8ff0c660e19f174ad04a135320c98152c4e7))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
6
19
|
### [0.25.6](https://gitlab.com/onereach/platform/or-sdk-next/compare/@or-sdk/bots@0.25.5...@or-sdk/bots@0.25.6) (2022-09-09)
|
|
7
20
|
|
|
8
21
|
**Note:** Version bump only for package @or-sdk/bots
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ import { Bots } from '@or-sdk/bots'
|
|
|
10
10
|
// with direct api url
|
|
11
11
|
const bots = new Bots({
|
|
12
12
|
token: 'my-account-token-string',
|
|
13
|
-
|
|
13
|
+
dataHubSvcUrl: 'http://example.data-hub-svc/endpoint'
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
// with service discovery(slower)
|
package/dist/cjs/Bots.js
CHANGED
|
@@ -46,145 +46,126 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
-
var t = {};
|
|
51
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
-
t[p] = s[p];
|
|
53
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
-
t[p[i]] = s[p[i]];
|
|
57
|
-
}
|
|
58
|
-
return t;
|
|
59
|
-
};
|
|
60
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
50
|
exports.Bots = void 0;
|
|
62
|
-
var
|
|
63
|
-
var
|
|
51
|
+
var base_1 = require("@or-sdk/base");
|
|
52
|
+
var data_hub_svc_1 = require("@or-sdk/data-hub-svc");
|
|
64
53
|
var tags_1 = require("@or-sdk/tags");
|
|
65
|
-
var utils_1 = require("./utils");
|
|
66
54
|
var Bots = (function () {
|
|
67
55
|
function Bots(params) {
|
|
68
|
-
var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId,
|
|
69
|
-
this.
|
|
56
|
+
var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId, dataHubSvcUrl = params.dataHubSvcUrl;
|
|
57
|
+
this.dataHubSvc = new data_hub_svc_1.DataHubSvc({
|
|
70
58
|
token: token,
|
|
71
59
|
discoveryUrl: discoveryUrl,
|
|
72
60
|
accountId: accountId,
|
|
73
|
-
|
|
61
|
+
dataHubSvcUrl: dataHubSvcUrl,
|
|
74
62
|
});
|
|
75
63
|
this.tags = new tags_1.Tags({
|
|
76
64
|
token: token,
|
|
77
65
|
discoveryUrl: discoveryUrl,
|
|
78
66
|
accountId: accountId,
|
|
79
|
-
|
|
67
|
+
dataHubSvcUrl: dataHubSvcUrl,
|
|
80
68
|
});
|
|
81
69
|
}
|
|
82
|
-
Bots.prototype.
|
|
70
|
+
Bots.prototype.listBots = function (params, paginationOptions) {
|
|
71
|
+
if (params === void 0) { params = {}; }
|
|
72
|
+
if (paginationOptions === void 0) { paginationOptions = {}; }
|
|
83
73
|
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
var includeQuery, paramsToSend, result;
|
|
84
75
|
return __generator(this, function (_a) {
|
|
85
76
|
switch (_a.label) {
|
|
86
|
-
case 0:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
77
|
+
case 0:
|
|
78
|
+
includeQuery = {};
|
|
79
|
+
if (params.includeDeleted === false || (params.includeDeleted === undefined && params.includeExisting !== false)) {
|
|
80
|
+
includeQuery = { isDeleted: false };
|
|
81
|
+
}
|
|
82
|
+
if (params.includeExisting === false) {
|
|
83
|
+
includeQuery = { isDeleted: true };
|
|
84
|
+
}
|
|
85
|
+
paramsToSend = __assign(__assign(__assign(__assign({}, params), { query: __assign(__assign({}, params.query), includeQuery) }), paginationOptions), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {});
|
|
86
|
+
delete paramsToSend.includeDeleted;
|
|
87
|
+
delete paramsToSend.includeExisting;
|
|
88
|
+
return [4, this.dataHubSvc.makeRequest({
|
|
89
|
+
method: 'GET',
|
|
90
|
+
route: 'bots',
|
|
91
|
+
params: paramsToSend,
|
|
92
|
+
})];
|
|
90
93
|
case 1:
|
|
91
|
-
_a.sent();
|
|
92
|
-
return [2];
|
|
94
|
+
result = _a.sent();
|
|
95
|
+
return [2, (0, base_1.makeList)(result)];
|
|
93
96
|
}
|
|
94
97
|
});
|
|
95
98
|
});
|
|
96
99
|
};
|
|
97
|
-
Bots.prototype.
|
|
100
|
+
Bots.prototype.getBot = function (id, params) {
|
|
98
101
|
if (params === void 0) { params = {}; }
|
|
99
102
|
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
query: (0, utils_1.getListQuery)({
|
|
107
|
-
crossAccount: this.dataHub.isCrossAccount,
|
|
108
|
-
projection: projection,
|
|
109
|
-
}),
|
|
110
|
-
variables: variables,
|
|
111
|
-
};
|
|
112
|
-
return [2, this.dataHub.getFullList('POST', '/graphql', data)];
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
return [2, this.dataHubSvc.makeRequest({
|
|
105
|
+
method: 'GET',
|
|
106
|
+
route: "bots/".concat(id),
|
|
107
|
+
params: __assign(__assign({}, params), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
108
|
+
})];
|
|
113
109
|
});
|
|
114
110
|
});
|
|
115
111
|
};
|
|
116
|
-
Bots.prototype.
|
|
112
|
+
Bots.prototype.saveBot = function (source) {
|
|
117
113
|
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
-
var
|
|
114
|
+
var result;
|
|
119
115
|
return __generator(this, function (_a) {
|
|
120
116
|
switch (_a.label) {
|
|
121
|
-
case 0:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
case 1: return [2, _a.sent()];
|
|
117
|
+
case 0: return [4, this.dataHubSvc.makeRequest({
|
|
118
|
+
method: 'POST',
|
|
119
|
+
route: "bots/".concat((source.id && source.id !== 'new') ? source.id : 'new'),
|
|
120
|
+
data: {
|
|
121
|
+
bot: (source.id && source.id !== 'new') ? source : __assign(__assign({}, source), { id: 'new' }),
|
|
122
|
+
},
|
|
123
|
+
params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
124
|
+
})];
|
|
125
|
+
case 1:
|
|
126
|
+
result = _a.sent();
|
|
127
|
+
return [2, (0, data_hub_svc_1.setDiff)(source, result)];
|
|
133
128
|
}
|
|
134
129
|
});
|
|
135
130
|
});
|
|
136
131
|
};
|
|
137
|
-
Bots.prototype.
|
|
132
|
+
Bots.prototype.deleteBot = function (botId, temporarily) {
|
|
133
|
+
if (temporarily === void 0) { temporarily = true; }
|
|
138
134
|
return __awaiter(this, void 0, void 0, function () {
|
|
139
|
-
var route, data;
|
|
140
135
|
return __generator(this, function (_a) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
route
|
|
144
|
-
data
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
route: route,
|
|
150
|
-
data: data,
|
|
151
|
-
})];
|
|
152
|
-
case 1: return [2, _a.sent()];
|
|
153
|
-
}
|
|
136
|
+
return [2, this.dataHubSvc.makeRequest({
|
|
137
|
+
method: 'DELETE',
|
|
138
|
+
route: "bots/".concat(botId),
|
|
139
|
+
data: {
|
|
140
|
+
temporarily: temporarily,
|
|
141
|
+
},
|
|
142
|
+
params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
143
|
+
})];
|
|
154
144
|
});
|
|
155
145
|
});
|
|
156
146
|
};
|
|
157
|
-
Bots.prototype.
|
|
147
|
+
Bots.prototype.recoverBot = function (botId) {
|
|
158
148
|
return __awaiter(this, void 0, void 0, function () {
|
|
159
|
-
var variables, operationName, data, result;
|
|
160
149
|
return __generator(this, function (_a) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
method: 'POST',
|
|
181
|
-
route: '/graphql',
|
|
182
|
-
data: data,
|
|
183
|
-
})];
|
|
184
|
-
case 1:
|
|
185
|
-
result = _a.sent();
|
|
186
|
-
return [2, this.dataHub.subscribe(result.data[operationName].requestId)];
|
|
187
|
-
}
|
|
150
|
+
return [2, this.dataHubSvc.makeRequest({
|
|
151
|
+
method: 'PATCH',
|
|
152
|
+
route: "bots/".concat(botId),
|
|
153
|
+
params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
154
|
+
})];
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
Bots.prototype.downloadTemplate = function (botTemplateId) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
+
return __generator(this, function (_a) {
|
|
161
|
+
return [2, this.dataHubSvc.makeRequest({
|
|
162
|
+
method: 'PUT',
|
|
163
|
+
route: 'bots',
|
|
164
|
+
data: {
|
|
165
|
+
botId: botTemplateId,
|
|
166
|
+
},
|
|
167
|
+
params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
168
|
+
})];
|
|
188
169
|
});
|
|
189
170
|
});
|
|
190
171
|
};
|
package/dist/cjs/Bots.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bots.js","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Bots.js","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA8C;AAC9C,qDAA2D;AAE3D,qCAAsF;AAEtF;IAIE,cAAY,MAAkB;QACpB,IAAA,KAAK,GAA6C,MAAM,MAAnD,EAAE,YAAY,GAA+B,MAAM,aAArC,EAAE,SAAS,GAAoB,MAAM,UAA1B,EAAE,aAAa,GAAK,MAAM,cAAX,CAAY;QAEjE,IAAI,CAAC,UAAU,GAAG,IAAI,yBAAU,CAAC;YAC/B,KAAK,OAAA;YACL,YAAY,cAAA;YACZ,SAAS,WAAA;YACT,aAAa,eAAA;SACd,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,WAAI,CAAC;YACnB,KAAK,OAAA;YACL,YAAY,cAAA;YACZ,SAAS,WAAA;YACT,aAAa,eAAA;SACd,CAAC,CAAC;IACL,CAAC;IAQY,uBAAQ,GAArB,UAAsB,MAA2B,EAAE,iBAAyC;QAAtE,uBAAA,EAAA,WAA2B;QAAE,kCAAA,EAAA,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,EAAC;;;;KACJ;IAQY,yBAAU,GAAvB,UAAwB,MAAW,EAAE,QAAkB;;;;;4BACxC,WAAM,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAA;;wBAAtD,IAAI,GAAG,SAA+C;wBACtD,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,EAAG,EAAP,CAAO,CAAC,CAAC;wBAEhC,WAAW,GAAK,IAAA,mBAAY,EAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,YAAtC,CAAuC;wBAE1D,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;4BACvB,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAC;yBACnC;wBAED,WAAO,IAAI,CAAC,OAAO,uBACd,MAAM,KACT,IAAI,EAAE,IAAA,mBAAY,EAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAC5C,EAAC;;;;KACJ;IAEH,WAAC;AAAD,CAAC,AAxMD,IAwMC;AAxMY,oBAAI"}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
exports.QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n }\n }\n}";
|
|
7
|
-
exports.ENTITY_NAME = 'BOT';
|
|
3
|
+
exports.DATA_HUB_SVC_SERVICE_KEY = void 0;
|
|
4
|
+
var data_hub_svc_1 = require("@or-sdk/data-hub-svc");
|
|
5
|
+
Object.defineProperty(exports, "DATA_HUB_SVC_SERVICE_KEY", { enumerable: true, get: function () { return data_hub_svc_1.DATA_HUB_SVC_SERVICE_KEY; } });
|
|
8
6
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,qDAAgE;AAAvD,wHAAA,wBAAwB,OAAA"}
|
package/dist/esm/Bots.js
CHANGED
|
@@ -1,123 +1,126 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { makeList } from '@or-sdk/base';
|
|
11
|
+
import { DataHubSvc, setDiff } from '@or-sdk/data-hub-svc';
|
|
3
12
|
import { Tags, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
|
|
4
|
-
import { getListQuery } from './utils';
|
|
5
13
|
export class Bots {
|
|
6
|
-
dataHub;
|
|
7
|
-
tags;
|
|
8
14
|
constructor(params) {
|
|
9
|
-
const { token, discoveryUrl, accountId,
|
|
10
|
-
this.
|
|
15
|
+
const { token, discoveryUrl, accountId, dataHubSvcUrl } = params;
|
|
16
|
+
this.dataHubSvc = new DataHubSvc({
|
|
11
17
|
token,
|
|
12
18
|
discoveryUrl,
|
|
13
19
|
accountId,
|
|
14
|
-
|
|
20
|
+
dataHubSvcUrl,
|
|
15
21
|
});
|
|
16
22
|
this.tags = new Tags({
|
|
17
23
|
token,
|
|
18
24
|
discoveryUrl,
|
|
19
25
|
accountId,
|
|
20
|
-
|
|
26
|
+
dataHubSvcUrl,
|
|
21
27
|
});
|
|
22
28
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
listBots(params = {}, paginationOptions = {}) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
let includeQuery = {};
|
|
32
|
+
if (params.includeDeleted === false || (params.includeDeleted === undefined && params.includeExisting !== false)) {
|
|
33
|
+
includeQuery = { isDeleted: false };
|
|
34
|
+
}
|
|
35
|
+
if (params.includeExisting === false) {
|
|
36
|
+
includeQuery = { isDeleted: true };
|
|
37
|
+
}
|
|
38
|
+
const paramsToSend = Object.assign(Object.assign(Object.assign(Object.assign({}, params), { query: Object.assign(Object.assign({}, params.query), includeQuery) }), paginationOptions), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {});
|
|
39
|
+
delete paramsToSend.includeDeleted;
|
|
40
|
+
delete paramsToSend.includeExisting;
|
|
41
|
+
const result = yield this.dataHubSvc.makeRequest({
|
|
42
|
+
method: 'GET',
|
|
43
|
+
route: 'bots',
|
|
44
|
+
params: paramsToSend,
|
|
45
|
+
});
|
|
46
|
+
return makeList(result);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
getBot(id, params = {}) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
return this.dataHubSvc.makeRequest({
|
|
52
|
+
method: 'GET',
|
|
53
|
+
route: `bots/${id}`,
|
|
54
|
+
params: Object.assign(Object.assign({}, params), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
55
|
+
});
|
|
56
|
+
});
|
|
28
57
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
const data = {
|
|
43
|
-
operationName: this.dataHub.getOperationName(OperationNames.LIST),
|
|
44
|
-
query: getListQuery({
|
|
45
|
-
crossAccount: this.dataHub.isCrossAccount,
|
|
46
|
-
projection,
|
|
47
|
-
}),
|
|
48
|
-
variables,
|
|
49
|
-
};
|
|
50
|
-
return this.dataHub.getFullList('POST', '/graphql', data);
|
|
58
|
+
saveBot(source) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const result = yield this.dataHubSvc.makeRequest({
|
|
61
|
+
method: 'POST',
|
|
62
|
+
route: `bots/${(source.id && source.id !== 'new') ? source.id : 'new'}`,
|
|
63
|
+
data: {
|
|
64
|
+
bot: (source.id && source.id !== 'new') ? source : Object.assign(Object.assign({}, source), { id: 'new' }),
|
|
65
|
+
},
|
|
66
|
+
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
67
|
+
});
|
|
68
|
+
return setDiff(source, result);
|
|
69
|
+
});
|
|
51
70
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
deleteBot(botId, temporarily = true) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
return this.dataHubSvc.makeRequest({
|
|
74
|
+
method: 'DELETE',
|
|
75
|
+
route: `bots/${botId}`,
|
|
76
|
+
data: {
|
|
77
|
+
temporarily,
|
|
78
|
+
},
|
|
79
|
+
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
80
|
+
});
|
|
62
81
|
});
|
|
63
82
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
route,
|
|
72
|
-
data,
|
|
83
|
+
recoverBot(botId) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
return this.dataHubSvc.makeRequest({
|
|
86
|
+
method: 'PATCH',
|
|
87
|
+
route: `bots/${botId}`,
|
|
88
|
+
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
89
|
+
});
|
|
73
90
|
});
|
|
74
91
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
const operationName = this.dataHub.getOperationName(OperationNames.DELETE_TEMPORARILY);
|
|
87
|
-
const data = {
|
|
88
|
-
operationName,
|
|
89
|
-
query: QUERY_DELETE,
|
|
90
|
-
variables,
|
|
91
|
-
};
|
|
92
|
-
const result = await this.dataHub.makeRequest({
|
|
93
|
-
method: 'POST',
|
|
94
|
-
route: '/graphql',
|
|
95
|
-
data,
|
|
92
|
+
downloadTemplate(botTemplateId) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
return this.dataHubSvc.makeRequest({
|
|
95
|
+
method: 'PUT',
|
|
96
|
+
route: 'bots',
|
|
97
|
+
data: {
|
|
98
|
+
botId: botTemplateId,
|
|
99
|
+
},
|
|
100
|
+
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
101
|
+
});
|
|
96
102
|
});
|
|
97
|
-
return this.dataHub.subscribe(result.data[operationName].requestId);
|
|
98
103
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
tags: addTagsIds(source.tags, newIds),
|
|
104
|
+
addTags(source, tagNames) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const tags = yield this.tags.getMultipleTagsByName(tagNames, true);
|
|
107
|
+
const tagIds = tags.map(tag => tag.id);
|
|
108
|
+
const { newIds } = filterTagIds(source.tags, tagIds);
|
|
109
|
+
if (!newIds.length) {
|
|
110
|
+
throw Error('No tags to add.');
|
|
111
|
+
}
|
|
112
|
+
return this.saveBot(Object.assign(Object.assign({}, source), { tags: addTagsIds(source.tags, newIds) }));
|
|
109
113
|
});
|
|
110
114
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
tags: removeTagIds(source.tags, existingIds),
|
|
115
|
+
removeTags(source, tagNames) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const tags = yield this.tags.getMultipleTagsByName(tagNames);
|
|
118
|
+
const tagIds = tags.map(tag => tag.id);
|
|
119
|
+
const { existingIds } = filterTagIds(source.tags, tagIds);
|
|
120
|
+
if (!existingIds.length) {
|
|
121
|
+
throw Error('No tags to remove.');
|
|
122
|
+
}
|
|
123
|
+
return this.saveBot(Object.assign(Object.assign({}, source), { tags: removeTagIds(source.tags, existingIds) }));
|
|
121
124
|
});
|
|
122
125
|
}
|
|
123
126
|
}
|
package/dist/esm/Bots.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bots.js","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Bots.js","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,IAAI,E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E,CAAC,GAAG,CAAC,EAAG,CAAC,CAAC;YAExC,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAErD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;gBAClB,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAC;aAChC;YAED,OAAO,IAAI,CAAC,OAAO,iCACd,MAAM,KACT,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IACrC,CAAC;QACL,CAAC;KAAA;IAQY,UAAU,CAAC,MAAW,EAAE,QAAkB;;YACrD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAG,CAAC,CAAC;YAExC,MAAM,EAAE,WAAW,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAE1D,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;gBACvB,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAC;aACnC;YAED,OAAO,IAAI,CAAC,OAAO,iCACd,MAAM,KACT,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAC5C,CAAC;QACL,CAAC;KAAA;CAEF"}
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
|
|
3
|
-
deleteTemporarily(entity: $entity, data: $data) {
|
|
4
|
-
... on AsyncRequest {
|
|
5
|
-
requestId
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
}`;
|
|
9
|
-
export const ENTITY_NAME = 'BOT';
|
|
1
|
+
export { DATA_HUB_SVC_SERVICE_KEY } from '@or-sdk/data-hub-svc';
|
|
10
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/types/Bots.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BotsConfig, Bot, ListBotsParams,
|
|
1
|
+
import { List } from '@or-sdk/base';
|
|
2
|
+
import { BotsConfig, Bot, ListBotsParams, PaginationOptions, GetBotsParams, DownloadTemplateResult } from './types';
|
|
3
3
|
import { Taggable } from '@or-sdk/tags';
|
|
4
4
|
export declare class Bots implements Taggable<Bot> {
|
|
5
|
-
private readonly
|
|
5
|
+
private readonly dataHubSvc;
|
|
6
6
|
private readonly tags;
|
|
7
7
|
constructor(params: BotsConfig);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
getBot(id: string): Promise<Bot>;
|
|
8
|
+
listBots(params?: ListBotsParams, paginationOptions?: PaginationOptions): Promise<List<Bot>>;
|
|
9
|
+
getBot(id: string, params?: GetBotsParams): Promise<Bot>;
|
|
11
10
|
saveBot(source: Bot): Promise<Bot>;
|
|
12
|
-
deleteBot(botId: string): Promise<
|
|
11
|
+
deleteBot(botId: string, temporarily?: boolean): Promise<void>;
|
|
12
|
+
recoverBot(botId: string): Promise<void>;
|
|
13
|
+
downloadTemplate(botTemplateId: string): Promise<DownloadTemplateResult>;
|
|
13
14
|
addTags(source: Bot, tagNames: string[]): Promise<Bot>;
|
|
14
15
|
removeTags(source: Bot, tagNames: string[]): Promise<Bot>;
|
|
15
16
|
}
|
package/dist/types/Bots.d.ts.map
CHANGED
|
@@ -1 +1 @@
|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G,OAAO,CAAC,GAAG,CAAC;CAgBvE"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export declare const QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n }\n }\n}";
|
|
3
|
-
export declare const ENTITY_NAME = "BOT";
|
|
1
|
+
export { DATA_HUB_SVC_SERVICE_KEY } from '@or-sdk/data-hub-svc';
|
|
4
2
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Token } from '@or-sdk/base';
|
|
2
2
|
export declare type BotsConfig = {
|
|
3
3
|
token: Token;
|
|
4
4
|
discoveryUrl?: string;
|
|
5
5
|
accountId?: string;
|
|
6
|
-
|
|
6
|
+
dataHubSvcUrl?: string;
|
|
7
7
|
};
|
|
8
8
|
export declare type Bot = {
|
|
9
9
|
id?: string;
|
|
@@ -22,10 +22,31 @@ export declare type Bot = {
|
|
|
22
22
|
schemaVersion?: number;
|
|
23
23
|
tags?: string[];
|
|
24
24
|
};
|
|
25
|
-
export declare type ListBotsResponse = List<Bot>;
|
|
26
25
|
export declare type ListBotsParams = {
|
|
27
26
|
includeDeleted?: boolean;
|
|
28
27
|
includeExisting?: boolean;
|
|
28
|
+
query?: {
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
};
|
|
31
|
+
projection?: string[];
|
|
32
|
+
sandbox?: boolean;
|
|
33
|
+
group?: string[];
|
|
34
|
+
};
|
|
35
|
+
export declare type PaginationOptions = {
|
|
36
|
+
limit?: number;
|
|
37
|
+
offset?: number;
|
|
38
|
+
};
|
|
39
|
+
export declare type GetBotsParams = {
|
|
40
|
+
query?: {
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
};
|
|
29
43
|
projection?: string[];
|
|
44
|
+
sandbox?: boolean;
|
|
45
|
+
};
|
|
46
|
+
export declare type DownloadTemplateResult = {
|
|
47
|
+
id: string;
|
|
48
|
+
data: {
|
|
49
|
+
label: string;
|
|
50
|
+
};
|
|
30
51
|
};
|
|
31
52
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,oBAAY,UAAU,GAAG;IAIvB,KAAK,EAAE,KAAK,CAAC;IAKb,YAAY,CAAC,EAAE,MAAM,CAAC;IAKtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,oBAAY,GAAG,GAAG;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE;YACN,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,CAAC;IACF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,oBAAY,cAAc,GAAG;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,KAAK,CAAC,EAAE;QACN,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE;QACN,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,oBAAY,sBAAsB,GAAG;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@or-sdk/bots",
|
|
3
|
-
"version": "0.26.0
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"dev": "pnpm build:watch:esm"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@or-sdk/base": "^0.
|
|
21
|
-
"@or-sdk/data-hub": "^
|
|
22
|
-
"@or-sdk/tags": "^0.26.0
|
|
20
|
+
"@or-sdk/base": "^0.26.7",
|
|
21
|
+
"@or-sdk/data-hub-svc": "^2.0.0",
|
|
22
|
+
"@or-sdk/tags": "^0.26.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"concurrently": "^6.4.0",
|
|
@@ -27,5 +27,6 @@
|
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
|
-
}
|
|
30
|
+
},
|
|
31
|
+
"gitHead": "33b5f8276be1644a5e3567c87e19174e910a61ef"
|
|
31
32
|
}
|
package/src/Bots.ts
CHANGED
|
@@ -1,73 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
QUERY_DELETE,
|
|
5
|
-
ENTITY_NAME,
|
|
6
|
-
} from './constants';
|
|
1
|
+
import { List, makeList } from '@or-sdk/base';
|
|
2
|
+
import { DataHubSvc, setDiff } from '@or-sdk/data-hub-svc';
|
|
3
|
+
import { BotsConfig, Bot, ListBotsParams, PaginationOptions, GetBotsParams, DownloadTemplateResult } from './types';
|
|
7
4
|
import { Tags, Taggable, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
|
|
8
|
-
import { getListQuery } from './utils';
|
|
9
5
|
|
|
10
6
|
export class Bots implements Taggable<Bot> {
|
|
11
|
-
private readonly
|
|
7
|
+
private readonly dataHubSvc: DataHubSvc;
|
|
12
8
|
private readonly tags: Tags;
|
|
13
9
|
|
|
14
10
|
constructor(params: BotsConfig) {
|
|
15
|
-
const { token, discoveryUrl, accountId,
|
|
11
|
+
const { token, discoveryUrl, accountId, dataHubSvcUrl } = params;
|
|
16
12
|
|
|
17
|
-
this.
|
|
13
|
+
this.dataHubSvc = new DataHubSvc({
|
|
18
14
|
token,
|
|
19
15
|
discoveryUrl,
|
|
20
16
|
accountId,
|
|
21
|
-
|
|
17
|
+
dataHubSvcUrl,
|
|
22
18
|
});
|
|
23
19
|
this.tags = new Tags({
|
|
24
20
|
token,
|
|
25
21
|
discoveryUrl,
|
|
26
22
|
accountId,
|
|
27
|
-
|
|
23
|
+
dataHubSvcUrl,
|
|
28
24
|
});
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
async init() {
|
|
32
|
-
await Promise.all([
|
|
33
|
-
this.dataHub.init(),
|
|
34
|
-
this.tags.init(),
|
|
35
|
-
]);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
27
|
/**
|
|
40
28
|
* List bots
|
|
41
29
|
* ```typescript
|
|
42
30
|
* const botList = await bots.listBots();
|
|
43
31
|
* ```
|
|
44
32
|
*/
|
|
45
|
-
public async listBots(params: ListBotsParams = {}): Promise<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
33
|
+
public async listBots(params: ListBotsParams = {}, paginationOptions: PaginationOptions = {}): Promise<List<Bot>> {
|
|
34
|
+
let includeQuery = {};
|
|
35
|
+
|
|
36
|
+
if (params.includeDeleted === false || (params.includeDeleted === undefined && params.includeExisting !== false)) {
|
|
37
|
+
includeQuery = { isDeleted: false };
|
|
38
|
+
}
|
|
39
|
+
if (params.includeExisting === false) {
|
|
40
|
+
includeQuery = { isDeleted: true };
|
|
41
|
+
}
|
|
54
42
|
|
|
55
|
-
|
|
56
|
-
|
|
43
|
+
const paramsToSend = {
|
|
44
|
+
...params,
|
|
45
|
+
query: {
|
|
46
|
+
...params.query,
|
|
47
|
+
...includeQuery,
|
|
57
48
|
},
|
|
58
|
-
...
|
|
49
|
+
...paginationOptions,
|
|
50
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
59
51
|
};
|
|
60
52
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
};
|
|
53
|
+
delete paramsToSend.includeDeleted;
|
|
54
|
+
delete paramsToSend.includeExisting;
|
|
55
|
+
|
|
56
|
+
const result = await this.dataHubSvc.makeRequest<Bot[]>({
|
|
57
|
+
method: 'GET',
|
|
58
|
+
route: 'bots',
|
|
59
|
+
params: paramsToSend,
|
|
60
|
+
});
|
|
69
61
|
|
|
70
|
-
return
|
|
62
|
+
return makeList<Bot>(result);
|
|
71
63
|
}
|
|
72
64
|
|
|
73
65
|
/**
|
|
@@ -76,18 +68,14 @@ export class Bots implements Taggable<Bot> {
|
|
|
76
68
|
* const bot = await bots.getBot('bot-id');
|
|
77
69
|
* ```
|
|
78
70
|
*/
|
|
79
|
-
public async getBot(id: string): Promise<Bot> {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const params = {
|
|
83
|
-
includeDeleted: false,
|
|
84
|
-
includeExisting: true,
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
return await this.dataHub.makeRequest<Bot>({
|
|
71
|
+
public async getBot(id: string, params: GetBotsParams = {}): Promise<Bot> {
|
|
72
|
+
return this.dataHubSvc.makeRequest<Bot>({
|
|
88
73
|
method: 'GET',
|
|
89
|
-
route
|
|
90
|
-
params
|
|
74
|
+
route: `bots/${id}`,
|
|
75
|
+
params: {
|
|
76
|
+
...params,
|
|
77
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
78
|
+
},
|
|
91
79
|
});
|
|
92
80
|
}
|
|
93
81
|
|
|
@@ -100,17 +88,21 @@ export class Bots implements Taggable<Bot> {
|
|
|
100
88
|
* ```
|
|
101
89
|
*/
|
|
102
90
|
public async saveBot(source: Bot): Promise<Bot> {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
const data = {
|
|
106
|
-
bot: source,
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
return await this.dataHub.makeRequest<Bot>({
|
|
91
|
+
const result = await this.dataHubSvc.makeRequest<{ id: string; }>({
|
|
110
92
|
method: 'POST',
|
|
111
|
-
route
|
|
112
|
-
data
|
|
93
|
+
route: `bots/${(source.id && source.id !== 'new') ? source.id : 'new'}`,
|
|
94
|
+
data: {
|
|
95
|
+
bot: (source.id && source.id !== 'new') ? source : {
|
|
96
|
+
...source,
|
|
97
|
+
id: 'new', //TODO: remove later
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
params: {
|
|
101
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
102
|
+
},
|
|
113
103
|
});
|
|
104
|
+
|
|
105
|
+
return setDiff<Bot>(source, result);
|
|
114
106
|
}
|
|
115
107
|
|
|
116
108
|
/**
|
|
@@ -119,34 +111,52 @@ export class Bots implements Taggable<Bot> {
|
|
|
119
111
|
* await bots.deleteBot('bot-id');
|
|
120
112
|
* ```
|
|
121
113
|
*/
|
|
122
|
-
public async deleteBot(botId: string): Promise<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const variables = {
|
|
128
|
-
entity: ENTITY_NAME,
|
|
114
|
+
public async deleteBot(botId: string, temporarily = true): Promise<void> {
|
|
115
|
+
return this.dataHubSvc.makeRequest<void>({
|
|
116
|
+
method: 'DELETE',
|
|
117
|
+
route: `bots/${botId}`,
|
|
129
118
|
data: {
|
|
130
|
-
|
|
131
|
-
subscribe: true,
|
|
119
|
+
temporarily,
|
|
132
120
|
},
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
operationName,
|
|
139
|
-
query: QUERY_DELETE,
|
|
140
|
-
variables,
|
|
141
|
-
};
|
|
121
|
+
params: {
|
|
122
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
}
|
|
142
126
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Recover bot
|
|
129
|
+
* ```typescript
|
|
130
|
+
* await bots.recoverBot('bot-id');
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
public async recoverBot(botId: string): Promise<void> {
|
|
134
|
+
return this.dataHubSvc.makeRequest<void>({
|
|
135
|
+
method: 'PATCH',
|
|
136
|
+
route: `bots/${botId}`,
|
|
137
|
+
params: {
|
|
138
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
139
|
+
},
|
|
147
140
|
});
|
|
141
|
+
}
|
|
148
142
|
|
|
149
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Download bot template to account
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const result = await bots.downloadTemplate('bot-template-id');
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
public async downloadTemplate(botTemplateId: string): Promise<DownloadTemplateResult> {
|
|
150
|
+
return this.dataHubSvc.makeRequest<DownloadTemplateResult>({
|
|
151
|
+
method: 'PUT',
|
|
152
|
+
route: 'bots',
|
|
153
|
+
data: {
|
|
154
|
+
botId: botTemplateId,
|
|
155
|
+
},
|
|
156
|
+
params: {
|
|
157
|
+
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
158
|
+
},
|
|
159
|
+
});
|
|
150
160
|
}
|
|
151
161
|
|
|
152
162
|
/**
|
package/src/constants.ts
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
|
|
4
|
-
deleteTemporarily(entity: $entity, data: $data) {
|
|
5
|
-
... on AsyncRequest {
|
|
6
|
-
requestId
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
}`;
|
|
10
|
-
|
|
11
|
-
export const ENTITY_NAME = 'BOT';
|
|
12
|
-
|
|
1
|
+
export { DATA_HUB_SVC_SERVICE_KEY } from '@or-sdk/data-hub-svc';
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Token } from '@or-sdk/base';
|
|
2
2
|
|
|
3
3
|
export type BotsConfig = {
|
|
4
4
|
/**
|
|
@@ -17,9 +17,9 @@ export type BotsConfig = {
|
|
|
17
17
|
accountId?: string;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Url of OneReach
|
|
20
|
+
* Url of OneReach DataHubSvc api
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
dataHubSvcUrl?: string;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export type Bot = {
|
|
@@ -40,10 +40,33 @@ export type Bot = {
|
|
|
40
40
|
tags?: string[];
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
export type ListBotsResponse = List<Bot>;
|
|
44
|
-
|
|
45
43
|
export type ListBotsParams = {
|
|
46
44
|
includeDeleted?: boolean;
|
|
47
45
|
includeExisting?: boolean;
|
|
46
|
+
query?: {
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
};
|
|
48
49
|
projection?: string[];
|
|
50
|
+
sandbox?: boolean;
|
|
51
|
+
group?: string[];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type PaginationOptions = {
|
|
55
|
+
limit?: number;
|
|
56
|
+
offset?: number;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type GetBotsParams = {
|
|
60
|
+
query?: {
|
|
61
|
+
[key: string]: unknown;
|
|
62
|
+
};
|
|
63
|
+
projection?: string[];
|
|
64
|
+
sandbox?: boolean;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type DownloadTemplateResult = {
|
|
68
|
+
id: string;
|
|
69
|
+
data: {
|
|
70
|
+
label: string;
|
|
71
|
+
};
|
|
49
72
|
};
|
package/tsconfig.esm.json
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var data_hub_1 = require("@or-sdk/data-hub");
|
|
4
|
-
function getListQuery(_a) {
|
|
5
|
-
var _b = _a.projection, projection = _b === void 0 ? [] : _b, _c = _a.crossAccount, crossAccount = _c === void 0 ? false : _c;
|
|
6
|
-
var baseProjection = [
|
|
7
|
-
'id',
|
|
8
|
-
'data',
|
|
9
|
-
'data.label',
|
|
10
|
-
'data.color',
|
|
11
|
-
'data.description',
|
|
12
|
-
'data.iconUrl',
|
|
13
|
-
'data.password',
|
|
14
|
-
'data.deploy',
|
|
15
|
-
'data.deploy.logsTTL',
|
|
16
|
-
'tags',
|
|
17
|
-
'dateModified',
|
|
18
|
-
];
|
|
19
|
-
return crossAccount ?
|
|
20
|
-
"query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {\n listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {\n records {\n ... on Bot {".concat((0, data_hub_1.getQueryProjectionPart)(projection.length ? projection : baseProjection), "\n }\n }\n last\n }\n}") :
|
|
21
|
-
"query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {\n list(entity: $entity, params: $params, sandbox: $sandbox) {\n records {\n ... on Bot {".concat((0, data_hub_1.getQueryProjectionPart)(projection.length ? projection : baseProjection), "\n }\n }\n last\n }\n}");
|
|
22
|
-
}
|
|
23
|
-
exports.default = getListQuery;
|
|
24
|
-
//# sourceMappingURL=getListQuery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getListQuery.js","sourceRoot":"","sources":["../../../src/utils/getListQuery.ts"],"names":[],"mappings":";;AAAA,6CAA0D;AAE1D,SAAS,YAAY,CAAC,EAAyF;QAAvF,kBAAe,EAAf,UAAU,mBAAG,EAAE,KAAA,EAAE,oBAAoB,EAApB,YAAY,mBAAG,KAAK,KAAA;IAC3D,IAAM,cAAc,GAAG;QACrB,IAAI;QACJ,MAAM;QACN,YAAY;QACZ,YAAY;QACZ,kBAAkB;QAClB,cAAc;QACd,eAAe;QACf,aAAa;QACb,qBAAqB;QACrB,MAAM;QACN,cAAc;KACf,CAAC;IAEF,OAAO,YAAY,CAAC,CAAC;QACnB,oNAGgB,IAAA,iCAAsB,EAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,uCAKzF,CAAC,CAAC;QACA,sLAGgB,IAAA,iCAAsB,EAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,uCAKzF,CAAC;AACH,CAAC;AAED,kBAAe,YAAY,CAAC"}
|
package/dist/cjs/utils/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getListQuery = void 0;
|
|
7
|
-
var getListQuery_1 = require("./getListQuery");
|
|
8
|
-
Object.defineProperty(exports, "getListQuery", { enumerable: true, get: function () { return __importDefault(getListQuery_1).default; } });
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;AAIA,+CAAyD;AAAhD,6HAAA,OAAO,OAAgB"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { getQueryProjectionPart } from '@or-sdk/data-hub';
|
|
2
|
-
function getListQuery({ projection = [], crossAccount = false }) {
|
|
3
|
-
const baseProjection = [
|
|
4
|
-
'id',
|
|
5
|
-
'data',
|
|
6
|
-
'data.label',
|
|
7
|
-
'data.color',
|
|
8
|
-
'data.description',
|
|
9
|
-
'data.iconUrl',
|
|
10
|
-
'data.password',
|
|
11
|
-
'data.deploy',
|
|
12
|
-
'data.deploy.logsTTL',
|
|
13
|
-
'tags',
|
|
14
|
-
'dateModified',
|
|
15
|
-
];
|
|
16
|
-
return crossAccount ?
|
|
17
|
-
`query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {
|
|
18
|
-
listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {
|
|
19
|
-
records {
|
|
20
|
-
... on Bot {${getQueryProjectionPart(projection.length ? projection : baseProjection)}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
last
|
|
24
|
-
}
|
|
25
|
-
}` :
|
|
26
|
-
`query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {
|
|
27
|
-
list(entity: $entity, params: $params, sandbox: $sandbox) {
|
|
28
|
-
records {
|
|
29
|
-
... on Bot {${getQueryProjectionPart(projection.length ? projection : baseProjection)}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
last
|
|
33
|
-
}
|
|
34
|
-
}`;
|
|
35
|
-
}
|
|
36
|
-
export default getListQuery;
|
|
37
|
-
//# sourceMappingURL=getListQuery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getListQuery.js","sourceRoot":"","sources":["../../../src/utils/getListQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,SAAS,YAAY,CAAC,EAAE,UAAU,GAAG,EAAE,EAAE,YAAY,GAAG,KAAK,EAAkD;IAC7G,MAAM,cAAc,GAAG;QACrB,IAAI;QACJ,MAAM;QACN,YAAY;QACZ,YAAY;QACZ,kBAAkB;QAClB,cAAc;QACd,eAAe;QACf,aAAa;QACb,qBAAqB;QACrB,MAAM;QACN,cAAc;KACf,CAAC;IAEF,OAAO,YAAY,CAAC,CAAC;QACnB;;;oBAGgB,sBAAsB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC;;;;;EAKzF,CAAC,CAAC;QACA;;;oBAGgB,sBAAsB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC;;;;;EAKzF,CAAC;AACH,CAAC;AAED,eAAe,YAAY,CAAC"}
|
package/dist/esm/utils/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getListQuery.d.ts","sourceRoot":"","sources":["../../../src/utils/getListQuery.ts"],"names":[],"mappings":"AAEA,iBAAS,YAAY,CAAC,EAAE,UAAe,EAAE,YAAoB,EAAE,EAAE;IAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;CAAC,GAAG,MAAM,CAkCvH;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { getQueryProjectionPart } from '@or-sdk/data-hub';
|
|
2
|
-
|
|
3
|
-
function getListQuery({ projection = [], crossAccount = false }: {projection: string[]; crossAccount: boolean;}): string {
|
|
4
|
-
const baseProjection = [
|
|
5
|
-
'id',
|
|
6
|
-
'data',
|
|
7
|
-
'data.label',
|
|
8
|
-
'data.color',
|
|
9
|
-
'data.description',
|
|
10
|
-
'data.iconUrl',
|
|
11
|
-
'data.password',
|
|
12
|
-
'data.deploy',
|
|
13
|
-
'data.deploy.logsTTL',
|
|
14
|
-
'tags',
|
|
15
|
-
'dateModified',
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
return crossAccount ?
|
|
19
|
-
`query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {
|
|
20
|
-
listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {
|
|
21
|
-
records {
|
|
22
|
-
... on Bot {${getQueryProjectionPart(projection.length ? projection : baseProjection)}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
last
|
|
26
|
-
}
|
|
27
|
-
}` :
|
|
28
|
-
`query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {
|
|
29
|
-
list(entity: $entity, params: $params, sandbox: $sandbox) {
|
|
30
|
-
records {
|
|
31
|
-
... on Bot {${getQueryProjectionPart(projection.length ? projection : baseProjection)}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
last
|
|
35
|
-
}
|
|
36
|
-
}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default getListQuery;
|