@or-sdk/bots 0.25.5-next.600.0 → 0.25.6
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 +16 -0
- package/README.md +1 -1
- package/dist/cjs/Bots.js +97 -78
- package/dist/cjs/Bots.js.map +1 -1
- package/dist/cjs/constants.js +5 -3
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/utils/getListQuery.js +24 -0
- package/dist/cjs/utils/getListQuery.js.map +1 -0
- package/dist/cjs/utils/index.js +9 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/esm/Bots.js +74 -61
- package/dist/esm/Bots.js.map +1 -1
- package/dist/esm/constants.js +9 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/utils/getListQuery.js +37 -0
- package/dist/esm/utils/getListQuery.js.map +1 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/types/Bots.d.ts +7 -8
- package/dist/types/Bots.d.ts.map +1 -1
- package/dist/types/constants.d.ts +3 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/types.d.ts +3 -24
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/getListQuery.d.ts +6 -0
- package/dist/types/utils/getListQuery.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/package.json +6 -5
- package/src/Bots.ts +84 -94
- package/src/constants.ts +12 -1
- package/src/types.ts +5 -28
- package/src/utils/getListQuery.ts +39 -0
- package/src/utils/index.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.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
|
+
|
|
8
|
+
**Note:** Version bump only for package @or-sdk/bots
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### [0.25.5](https://gitlab.com/onereach/platform/or-sdk-next/compare/@or-sdk/bots@0.25.4...@or-sdk/bots@0.25.5) (2022-09-09)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @or-sdk/bots
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
### [0.25.4](https://gitlab.com/onereach/platform/or-sdk-next/compare/@or-sdk/bots@0.25.3...@or-sdk/bots@0.25.4) (2022-08-29)
|
|
7
23
|
|
|
8
24
|
**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
|
+
dataHubUrl: 'http://example.bots/endpoint'
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
// with service discovery(slower)
|
package/dist/cjs/Bots.js
CHANGED
|
@@ -46,126 +46,145 @@ 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
|
+
};
|
|
49
60
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
61
|
exports.Bots = void 0;
|
|
51
|
-
var
|
|
52
|
-
var
|
|
62
|
+
var data_hub_1 = require("@or-sdk/data-hub");
|
|
63
|
+
var constants_1 = require("./constants");
|
|
53
64
|
var tags_1 = require("@or-sdk/tags");
|
|
65
|
+
var utils_1 = require("./utils");
|
|
54
66
|
var Bots = (function () {
|
|
55
67
|
function Bots(params) {
|
|
56
|
-
var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId,
|
|
57
|
-
this.
|
|
68
|
+
var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId, dataHubUrl = params.dataHubUrl;
|
|
69
|
+
this.dataHub = new data_hub_1.DataHub({
|
|
58
70
|
token: token,
|
|
59
71
|
discoveryUrl: discoveryUrl,
|
|
60
72
|
accountId: accountId,
|
|
61
|
-
|
|
73
|
+
dataHubUrl: dataHubUrl,
|
|
62
74
|
});
|
|
63
75
|
this.tags = new tags_1.Tags({
|
|
64
76
|
token: token,
|
|
65
77
|
discoveryUrl: discoveryUrl,
|
|
66
78
|
accountId: accountId,
|
|
67
|
-
|
|
79
|
+
dataHubUrl: dataHubUrl,
|
|
68
80
|
});
|
|
69
81
|
}
|
|
70
|
-
Bots.prototype.
|
|
71
|
-
if (params === void 0) { params = {}; }
|
|
72
|
-
if (paginationOptions === void 0) { paginationOptions = {}; }
|
|
82
|
+
Bots.prototype.init = function () {
|
|
73
83
|
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
-
var includeQuery, paramsToSend, result;
|
|
75
84
|
return __generator(this, function (_a) {
|
|
76
85
|
switch (_a.label) {
|
|
77
|
-
case 0:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
})];
|
|
86
|
+
case 0: return [4, Promise.all([
|
|
87
|
+
this.dataHub.init(),
|
|
88
|
+
this.tags.init(),
|
|
89
|
+
])];
|
|
93
90
|
case 1:
|
|
94
|
-
|
|
95
|
-
return [2
|
|
91
|
+
_a.sent();
|
|
92
|
+
return [2];
|
|
96
93
|
}
|
|
97
94
|
});
|
|
98
95
|
});
|
|
99
96
|
};
|
|
100
|
-
Bots.prototype.
|
|
97
|
+
Bots.prototype.listBots = function (params) {
|
|
101
98
|
if (params === void 0) { params = {}; }
|
|
102
99
|
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
var _a, projection, varPrams, variables, data;
|
|
101
|
+
return __generator(this, function (_b) {
|
|
102
|
+
_a = params.projection, projection = _a === void 0 ? [] : _a, varPrams = __rest(params, ["projection"]);
|
|
103
|
+
variables = __assign({ entity: constants_1.ENTITY_NAME, params: __assign({ queryParams: {}, includeDeleted: false, includeExisting: true, limit: 30 }, varPrams) }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false });
|
|
104
|
+
data = {
|
|
105
|
+
operationName: this.dataHub.getOperationName(data_hub_1.OperationNames.LIST),
|
|
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)];
|
|
109
113
|
});
|
|
110
114
|
});
|
|
111
115
|
};
|
|
112
|
-
Bots.prototype.
|
|
116
|
+
Bots.prototype.getBot = function (id) {
|
|
113
117
|
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
-
var
|
|
118
|
+
var route, params;
|
|
115
119
|
return __generator(this, function (_a) {
|
|
116
120
|
switch (_a.label) {
|
|
117
|
-
case 0:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
case 0:
|
|
122
|
+
route = "/v2/".concat(this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current', "/bot/").concat(id);
|
|
123
|
+
params = {
|
|
124
|
+
includeDeleted: false,
|
|
125
|
+
includeExisting: true,
|
|
126
|
+
};
|
|
127
|
+
return [4, this.dataHub.makeRequest({
|
|
128
|
+
method: 'GET',
|
|
129
|
+
route: route,
|
|
130
|
+
params: params,
|
|
131
|
+
})];
|
|
132
|
+
case 1: return [2, _a.sent()];
|
|
128
133
|
}
|
|
129
134
|
});
|
|
130
135
|
});
|
|
131
136
|
};
|
|
132
|
-
Bots.prototype.
|
|
133
|
-
if (temporarily === void 0) { temporarily = true; }
|
|
134
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
135
|
-
return __generator(this, function (_a) {
|
|
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
|
-
})];
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
Bots.prototype.recoverBot = function (botId) {
|
|
137
|
+
Bots.prototype.saveBot = function (source) {
|
|
148
138
|
return __awaiter(this, void 0, void 0, function () {
|
|
139
|
+
var route, data;
|
|
149
140
|
return __generator(this, function (_a) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
route: "
|
|
153
|
-
|
|
154
|
-
|
|
141
|
+
switch (_a.label) {
|
|
142
|
+
case 0:
|
|
143
|
+
route = "/v2/".concat(this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current', "/bot/").concat(source.id ? source.id : 'new');
|
|
144
|
+
data = {
|
|
145
|
+
bot: source,
|
|
146
|
+
};
|
|
147
|
+
return [4, this.dataHub.makeRequest({
|
|
148
|
+
method: 'POST',
|
|
149
|
+
route: route,
|
|
150
|
+
data: data,
|
|
151
|
+
})];
|
|
152
|
+
case 1: return [2, _a.sent()];
|
|
153
|
+
}
|
|
155
154
|
});
|
|
156
155
|
});
|
|
157
156
|
};
|
|
158
|
-
Bots.prototype.
|
|
157
|
+
Bots.prototype.deleteBot = function (botId) {
|
|
159
158
|
return __awaiter(this, void 0, void 0, function () {
|
|
159
|
+
var variables, operationName, data, result;
|
|
160
160
|
return __generator(this, function (_a) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
161
|
+
switch (_a.label) {
|
|
162
|
+
case 0:
|
|
163
|
+
if (this.dataHub.isCrossAccount) {
|
|
164
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
165
|
+
}
|
|
166
|
+
variables = {
|
|
167
|
+
entity: constants_1.ENTITY_NAME,
|
|
168
|
+
data: {
|
|
169
|
+
id: botId,
|
|
170
|
+
subscribe: true,
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
operationName = this.dataHub.getOperationName(data_hub_1.OperationNames.DELETE_TEMPORARILY);
|
|
174
|
+
data = {
|
|
175
|
+
operationName: operationName,
|
|
176
|
+
query: constants_1.QUERY_DELETE,
|
|
177
|
+
variables: variables,
|
|
178
|
+
};
|
|
179
|
+
return [4, this.dataHub.makeRequest({
|
|
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
|
+
}
|
|
169
188
|
});
|
|
170
189
|
});
|
|
171
190
|
};
|
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,6CAAkI;AAElI,yCAGqB;AACrB,qCAAsF;AACtF,iCAAuC;AAEvC;IAIE,cAAY,MAAkB;QACpB,IAAA,KAAK,GAA0C,MAAM,MAAhD,EAAE,YAAY,GAA4B,MAAM,aAAlC,EAAE,SAAS,GAAiB,MAAM,UAAvB,EAAE,UAAU,GAAK,MAAM,WAAX,CAAY;QAE9D,IAAI,CAAC,OAAO,GAAG,IAAI,kBAAO,CAAC;YACzB,KAAK,OAAA;YACL,YAAY,cAAA;YACZ,SAAS,WAAA;YACT,UAAU,YAAA;SACX,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,WAAI,CAAC;YACnB,KAAK,OAAA;YACL,YAAY,cAAA;YACZ,SAAS,WAAA;YACT,UAAU,YAAA;SACX,CAAC,CAAC;IACL,CAAC;IAEK,mBAAI,GAAV;;;;4BACE,WAAM,OAAO,CAAC,GAAG,CAAC;4BAChB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;4BACnB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;yBACjB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Y,EAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAC5C,EAAC;;;;KACJ;IAEH,WAAC;AAAD,CAAC,AA1LD,IA0LC;AA1LY,oBAAI"}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "
|
|
3
|
+
exports.ENTITY_NAME = exports.QUERY_DELETE = exports.DATA_HUB_SERVICE_KEY = void 0;
|
|
4
|
+
var data_hub_1 = require("@or-sdk/data-hub");
|
|
5
|
+
Object.defineProperty(exports, "DATA_HUB_SERVICE_KEY", { enumerable: true, get: function () { return data_hub_1.DATA_HUB_SERVICE_KEY; } });
|
|
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';
|
|
6
8
|
//# 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,6CAAwD;AAA/C,gHAAA,oBAAoB,OAAA;AAEhB,QAAA,YAAY,GAAG,yLAM1B,CAAC;AAEU,QAAA,WAAW,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;AAIA,+CAAyD;AAAhD,6HAAA,OAAO,OAAgB"}
|
package/dist/esm/Bots.js
CHANGED
|
@@ -7,98 +7,111 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import { DataHub, OperationNames } from '@or-sdk/data-hub';
|
|
22
|
+
import { QUERY_DELETE, ENTITY_NAME, } from './constants';
|
|
12
23
|
import { Tags, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
|
|
24
|
+
import { getListQuery } from './utils';
|
|
13
25
|
export class Bots {
|
|
14
26
|
constructor(params) {
|
|
15
|
-
const { token, discoveryUrl, accountId,
|
|
16
|
-
this.
|
|
27
|
+
const { token, discoveryUrl, accountId, dataHubUrl } = params;
|
|
28
|
+
this.dataHub = new DataHub({
|
|
17
29
|
token,
|
|
18
30
|
discoveryUrl,
|
|
19
31
|
accountId,
|
|
20
|
-
|
|
32
|
+
dataHubUrl,
|
|
21
33
|
});
|
|
22
34
|
this.tags = new Tags({
|
|
23
35
|
token,
|
|
24
36
|
discoveryUrl,
|
|
25
37
|
accountId,
|
|
26
|
-
|
|
38
|
+
dataHubUrl,
|
|
27
39
|
});
|
|
28
40
|
}
|
|
29
|
-
|
|
41
|
+
init() {
|
|
30
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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);
|
|
43
|
+
yield Promise.all([
|
|
44
|
+
this.dataHub.init(),
|
|
45
|
+
this.tags.init(),
|
|
46
|
+
]);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
|
|
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
|
-
});
|
|
57
|
-
}
|
|
58
|
-
saveBot(source) {
|
|
49
|
+
listBots(params = {}) {
|
|
59
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
const { projection = [] } = params, varPrams = __rest(params, ["projection"]);
|
|
52
|
+
const variables = Object.assign({ entity: ENTITY_NAME, params: Object.assign({ queryParams: {}, includeDeleted: false, includeExisting: true, limit: 30 }, varPrams) }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false });
|
|
53
|
+
const data = {
|
|
54
|
+
operationName: this.dataHub.getOperationName(OperationNames.LIST),
|
|
55
|
+
query: getListQuery({
|
|
56
|
+
crossAccount: this.dataHub.isCrossAccount,
|
|
57
|
+
projection,
|
|
58
|
+
}),
|
|
59
|
+
variables,
|
|
60
|
+
};
|
|
61
|
+
return this.dataHub.getFullList('POST', '/graphql', data);
|
|
69
62
|
});
|
|
70
63
|
}
|
|
71
|
-
|
|
64
|
+
getBot(id) {
|
|
72
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/bot/${id}`;
|
|
67
|
+
const params = {
|
|
68
|
+
includeDeleted: false,
|
|
69
|
+
includeExisting: true,
|
|
70
|
+
};
|
|
71
|
+
return yield this.dataHub.makeRequest({
|
|
72
|
+
method: 'GET',
|
|
73
|
+
route,
|
|
74
|
+
params,
|
|
80
75
|
});
|
|
81
76
|
});
|
|
82
77
|
}
|
|
83
|
-
|
|
78
|
+
saveBot(source) {
|
|
84
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/bot/${source.id ? source.id : 'new'}`;
|
|
81
|
+
const data = {
|
|
82
|
+
bot: source,
|
|
83
|
+
};
|
|
84
|
+
return yield this.dataHub.makeRequest({
|
|
85
|
+
method: 'POST',
|
|
86
|
+
route,
|
|
87
|
+
data,
|
|
89
88
|
});
|
|
90
89
|
});
|
|
91
90
|
}
|
|
92
|
-
|
|
91
|
+
deleteBot(botId) {
|
|
93
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
if (this.dataHub.isCrossAccount) {
|
|
94
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
95
|
+
}
|
|
96
|
+
const variables = {
|
|
97
|
+
entity: ENTITY_NAME,
|
|
97
98
|
data: {
|
|
98
|
-
|
|
99
|
+
id: botId,
|
|
100
|
+
subscribe: true,
|
|
99
101
|
},
|
|
100
|
-
|
|
102
|
+
};
|
|
103
|
+
const operationName = this.dataHub.getOperationName(OperationNames.DELETE_TEMPORARILY);
|
|
104
|
+
const data = {
|
|
105
|
+
operationName,
|
|
106
|
+
query: QUERY_DELETE,
|
|
107
|
+
variables,
|
|
108
|
+
};
|
|
109
|
+
const result = yield this.dataHub.makeRequest({
|
|
110
|
+
method: 'POST',
|
|
111
|
+
route: '/graphql',
|
|
112
|
+
data,
|
|
101
113
|
});
|
|
114
|
+
return this.dataHub.subscribe(result.data[operationName].requestId);
|
|
102
115
|
});
|
|
103
116
|
}
|
|
104
117
|
addTags(source, tagNames) {
|
package/dist/esm/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,OAAO,EAAE,OAAO,EAAyE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElI,OAAO,EACL,YAAY,EACZ,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,IAAI,EAAY,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,OAAO,IAAI;IAIf,YAAY,MAAkB;QAC5B,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QAE9D,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC;YACzB,KAAK;YACL,YAAY;YACZ,SAAS;YACT,UAAU;SACX,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC;YACnB,KAAK;YACL,YAAY;YACZ,SAAS;YACT,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IAEK,IAAI;;YACR,MAAM,OAAO,CAAC,GAAG,CAAC;gBAChB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;gBACnB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;aACjB,CAAC,CAAC;QACL,CAAC;KAAA;IASY,QAAQ,CAAC,SAAyB,EAAE;;YAC/C,MAAM,EAAE,UAAU,GAAG,EAAE,KAAkB,MAA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MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,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,2 +1,10 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DATA_HUB_SERVICE_KEY } from '@or-sdk/data-hub';
|
|
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';
|
|
2
10
|
//# 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,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;EAM1B,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/types/Bots.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BotsConfig, Bot, ListBotsParams,
|
|
1
|
+
import { GraphqlResponseCheckExecution } from '@or-sdk/data-hub';
|
|
2
|
+
import { BotsConfig, Bot, ListBotsParams, ListBotsResponse } 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 dataHub;
|
|
6
6
|
private readonly tags;
|
|
7
7
|
constructor(params: BotsConfig);
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
init(): Promise<void>;
|
|
9
|
+
listBots(params?: ListBotsParams): Promise<ListBotsResponse>;
|
|
10
|
+
getBot(id: string): Promise<Bot>;
|
|
10
11
|
saveBot(source: Bot): Promise<Bot>;
|
|
11
|
-
deleteBot(botId: string
|
|
12
|
-
recoverBot(botId: string): Promise<void>;
|
|
13
|
-
downloadTemplate(botTemplateId: string): Promise<DownloadTemplateResult>;
|
|
12
|
+
deleteBot(botId: string): Promise<GraphqlResponseCheckExecution>;
|
|
14
13
|
addTags(source: Bot, tagNames: string[]): Promise<Bot>;
|
|
15
14
|
removeTags(source: Bot, tagNames: string[]): Promise<Bot>;
|
|
16
15
|
}
|
package/dist/types/Bots.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bots.d.ts","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Bots.d.ts","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,6BAA6B,EAAyC,MAAM,kBAAkB,CAAC;AAClI,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAK5E,OAAO,EAAQ,QAAQ,EAA0C,MAAM,cAAc,CAAC;AAGtF,qBAAa,IAAK,YAAW,QAAQ,CAAC,GAAG,CAAC;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAO;gBAEhB,MAAM,EAAE,UAAU;IAiBxB,IAAI;IAcG,QAAQ,CAAC,MAAM,GAAE,cAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkChE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAuBhC,OAAO,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAoBlC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAoChE,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAsBtD,UAAU,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;CAgBvE"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DATA_HUB_SERVICE_KEY } from '@or-sdk/data-hub';
|
|
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";
|
|
2
4
|
//# 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,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,eAAO,MAAM,YAAY,4LAMvB,CAAC;AAEH,eAAO,MAAM,WAAW,QAAQ,CAAC"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Token } from '@or-sdk/base';
|
|
1
|
+
import { List, 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
|
+
dataHubUrl?: string;
|
|
7
7
|
};
|
|
8
8
|
export declare type Bot = {
|
|
9
9
|
id?: string;
|
|
@@ -22,31 +22,10 @@ export declare type Bot = {
|
|
|
22
22
|
schemaVersion?: number;
|
|
23
23
|
tags?: string[];
|
|
24
24
|
};
|
|
25
|
+
export declare type ListBotsResponse = List<Bot>;
|
|
25
26
|
export declare type ListBotsParams = {
|
|
26
27
|
includeDeleted?: boolean;
|
|
27
28
|
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
|
-
};
|
|
43
29
|
projection?: string[];
|
|
44
|
-
sandbox?: boolean;
|
|
45
|
-
};
|
|
46
|
-
export declare type DownloadTemplateResult = {
|
|
47
|
-
id: string;
|
|
48
|
-
data: {
|
|
49
|
-
label: string;
|
|
50
|
-
};
|
|
51
30
|
};
|
|
52
31
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE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.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@or-sdk/bots",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.6",
|
|
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.26.
|
|
21
|
-
"@or-sdk/data-hub
|
|
22
|
-
"@or-sdk/tags": "^0.25.
|
|
20
|
+
"@or-sdk/base": "^0.26.7",
|
|
21
|
+
"@or-sdk/data-hub": "^0.25.5",
|
|
22
|
+
"@or-sdk/tags": "^0.25.6"
|
|
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": "7a9ce11ecc97143569b65f3d00fc587a0021a985"
|
|
31
32
|
}
|
package/src/Bots.ts
CHANGED
|
@@ -1,65 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { DataHub, GraphqlResponse, GraphqlResponseCheckExecution, GraphqlResponseDelete, OperationNames } from '@or-sdk/data-hub';
|
|
2
|
+
import { BotsConfig, Bot, ListBotsParams, ListBotsResponse } from './types';
|
|
3
|
+
import {
|
|
4
|
+
QUERY_DELETE,
|
|
5
|
+
ENTITY_NAME,
|
|
6
|
+
} from './constants';
|
|
4
7
|
import { Tags, Taggable, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
|
|
8
|
+
import { getListQuery } from './utils';
|
|
5
9
|
|
|
6
10
|
export class Bots implements Taggable<Bot> {
|
|
7
|
-
private readonly
|
|
11
|
+
private readonly dataHub: DataHub;
|
|
8
12
|
private readonly tags: Tags;
|
|
9
13
|
|
|
10
14
|
constructor(params: BotsConfig) {
|
|
11
|
-
const { token, discoveryUrl, accountId,
|
|
15
|
+
const { token, discoveryUrl, accountId, dataHubUrl } = params;
|
|
12
16
|
|
|
13
|
-
this.
|
|
17
|
+
this.dataHub = new DataHub({
|
|
14
18
|
token,
|
|
15
19
|
discoveryUrl,
|
|
16
20
|
accountId,
|
|
17
|
-
|
|
21
|
+
dataHubUrl,
|
|
18
22
|
});
|
|
19
23
|
this.tags = new Tags({
|
|
20
24
|
token,
|
|
21
25
|
discoveryUrl,
|
|
22
26
|
accountId,
|
|
23
|
-
|
|
27
|
+
dataHubUrl,
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
30
|
|
|
31
|
+
async init() {
|
|
32
|
+
await Promise.all([
|
|
33
|
+
this.dataHub.init(),
|
|
34
|
+
this.tags.init(),
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
27
39
|
/**
|
|
28
40
|
* List bots
|
|
29
41
|
* ```typescript
|
|
30
42
|
* const botList = await bots.listBots();
|
|
31
43
|
* ```
|
|
32
44
|
*/
|
|
33
|
-
public async listBots(params: ListBotsParams = {}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
public async listBots(params: ListBotsParams = {}): Promise<ListBotsResponse> {
|
|
46
|
+
const { projection = [], ...varPrams } = params;
|
|
47
|
+
const variables = {
|
|
48
|
+
entity: ENTITY_NAME,
|
|
49
|
+
params: {
|
|
50
|
+
queryParams: {},
|
|
51
|
+
includeDeleted: false,
|
|
52
|
+
includeExisting: true,
|
|
53
|
+
limit: 30,
|
|
42
54
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
query: {
|
|
46
|
-
...params.query,
|
|
47
|
-
...includeQuery,
|
|
55
|
+
// overrides
|
|
56
|
+
...varPrams,
|
|
48
57
|
},
|
|
49
|
-
...
|
|
50
|
-
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
58
|
+
... this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false },
|
|
51
59
|
};
|
|
52
60
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
+
const data = {
|
|
62
|
+
operationName: this.dataHub.getOperationName(OperationNames.LIST),
|
|
63
|
+
query: getListQuery({
|
|
64
|
+
crossAccount: this.dataHub.isCrossAccount,
|
|
65
|
+
projection,
|
|
66
|
+
}),
|
|
67
|
+
variables,
|
|
68
|
+
};
|
|
61
69
|
|
|
62
|
-
return
|
|
70
|
+
return this.dataHub.getFullList<Bot>('POST', '/graphql', data);
|
|
63
71
|
}
|
|
64
72
|
|
|
65
73
|
/**
|
|
@@ -68,14 +76,18 @@ export class Bots implements Taggable<Bot> {
|
|
|
68
76
|
* const bot = await bots.getBot('bot-id');
|
|
69
77
|
* ```
|
|
70
78
|
*/
|
|
71
|
-
public async getBot(id: string
|
|
72
|
-
|
|
79
|
+
public async getBot(id: string): Promise<Bot> {
|
|
80
|
+
const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/bot/${id}`;
|
|
81
|
+
|
|
82
|
+
const params = {
|
|
83
|
+
includeDeleted: false,
|
|
84
|
+
includeExisting: true,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return await this.dataHub.makeRequest<Bot>({
|
|
73
88
|
method: 'GET',
|
|
74
|
-
route
|
|
75
|
-
params
|
|
76
|
-
...params,
|
|
77
|
-
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
78
|
-
},
|
|
89
|
+
route,
|
|
90
|
+
params,
|
|
79
91
|
});
|
|
80
92
|
}
|
|
81
93
|
|
|
@@ -88,21 +100,17 @@ export class Bots implements Taggable<Bot> {
|
|
|
88
100
|
* ```
|
|
89
101
|
*/
|
|
90
102
|
public async saveBot(source: Bot): Promise<Bot> {
|
|
91
|
-
const
|
|
103
|
+
const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/bot/${source.id ? source.id : 'new'}`;
|
|
104
|
+
|
|
105
|
+
const data = {
|
|
106
|
+
bot: source,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return await this.dataHub.makeRequest<Bot>({
|
|
92
110
|
method: 'POST',
|
|
93
|
-
route
|
|
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
|
-
},
|
|
111
|
+
route,
|
|
112
|
+
data,
|
|
103
113
|
});
|
|
104
|
-
|
|
105
|
-
return setDiff<Bot>(source, result);
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
/**
|
|
@@ -111,52 +119,34 @@ export class Bots implements Taggable<Bot> {
|
|
|
111
119
|
* await bots.deleteBot('bot-id');
|
|
112
120
|
* ```
|
|
113
121
|
*/
|
|
114
|
-
public async deleteBot(botId: string
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
public async deleteBot(botId: string): Promise<GraphqlResponseCheckExecution> {
|
|
123
|
+
if (this.dataHub.isCrossAccount) {
|
|
124
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const variables = {
|
|
128
|
+
entity: ENTITY_NAME,
|
|
118
129
|
data: {
|
|
119
|
-
|
|
130
|
+
id: botId,
|
|
131
|
+
subscribe: true,
|
|
120
132
|
},
|
|
121
|
-
|
|
122
|
-
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
}
|
|
133
|
+
};
|
|
126
134
|
|
|
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
|
-
},
|
|
140
|
-
});
|
|
141
|
-
}
|
|
135
|
+
const operationName = this.dataHub.getOperationName(OperationNames.DELETE_TEMPORARILY);
|
|
142
136
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
data: {
|
|
154
|
-
botId: botTemplateId,
|
|
155
|
-
},
|
|
156
|
-
params: {
|
|
157
|
-
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
158
|
-
},
|
|
137
|
+
const data = {
|
|
138
|
+
operationName,
|
|
139
|
+
query: QUERY_DELETE,
|
|
140
|
+
variables,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const result = await this.dataHub.makeRequest<GraphqlResponse<void>>({
|
|
144
|
+
method: 'POST',
|
|
145
|
+
route: '/graphql',
|
|
146
|
+
data,
|
|
159
147
|
});
|
|
148
|
+
|
|
149
|
+
return this.dataHub.subscribe((result.data[operationName] as GraphqlResponseDelete).requestId);
|
|
160
150
|
}
|
|
161
151
|
|
|
162
152
|
/**
|
package/src/constants.ts
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DATA_HUB_SERVICE_KEY } from '@or-sdk/data-hub';
|
|
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
|
+
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Token } from '@or-sdk/base';
|
|
1
|
+
import { List, 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 DataHub api
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
dataHubUrl?: string;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export type Bot = {
|
|
@@ -40,33 +40,10 @@ export type Bot = {
|
|
|
40
40
|
tags?: string[];
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
export type ListBotsResponse = List<Bot>;
|
|
44
|
+
|
|
43
45
|
export type ListBotsParams = {
|
|
44
46
|
includeDeleted?: boolean;
|
|
45
47
|
includeExisting?: boolean;
|
|
46
|
-
query?: {
|
|
47
|
-
[key: string]: unknown;
|
|
48
|
-
};
|
|
49
48
|
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
|
-
};
|
|
72
49
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
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;
|