@or-sdk/bots 0.15.0 → 0.18.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/dist/cjs/Bots.js +17 -15
- package/dist/cjs/Bots.js.map +1 -1
- package/dist/cjs/constants.js +2 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/esm/Bots.js +17 -15
- package/dist/esm/Bots.js.map +1 -1
- package/dist/esm/constants.js +22 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/types.d.ts +1 -0
- package/package.json +5 -5
- package/src/Bots.ts +24 -12
- package/src/constants.ts +23 -0
- package/src/types.ts +4 -0
package/dist/cjs/Bots.js
CHANGED
|
@@ -53,14 +53,16 @@ var constants_1 = require("./constants");
|
|
|
53
53
|
var tags_1 = require("@or-sdk/tags");
|
|
54
54
|
var Bots = (function () {
|
|
55
55
|
function Bots(params) {
|
|
56
|
-
var token = params.token, discoveryUrl = params.discoveryUrl;
|
|
56
|
+
var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId;
|
|
57
57
|
this.dataHub = new data_hub_1.DataHub({
|
|
58
58
|
token: token,
|
|
59
59
|
discoveryUrl: discoveryUrl,
|
|
60
|
+
accountId: accountId,
|
|
60
61
|
});
|
|
61
62
|
this.tags = new tags_1.Tags({
|
|
62
63
|
token: token,
|
|
63
64
|
discoveryUrl: discoveryUrl,
|
|
65
|
+
accountId: accountId,
|
|
64
66
|
});
|
|
65
67
|
}
|
|
66
68
|
Bots.prototype.init = function () {
|
|
@@ -82,19 +84,15 @@ var Bots = (function () {
|
|
|
82
84
|
return __awaiter(this, void 0, void 0, function () {
|
|
83
85
|
var variables, data;
|
|
84
86
|
return __generator(this, function (_a) {
|
|
85
|
-
variables = {
|
|
86
|
-
entity: constants_1.ENTITY_NAME,
|
|
87
|
-
params: {
|
|
87
|
+
variables = __assign({ entity: constants_1.ENTITY_NAME, params: {
|
|
88
88
|
queryParams: {},
|
|
89
89
|
includeDeleted: false,
|
|
90
90
|
includeExisting: true,
|
|
91
91
|
limit: 30,
|
|
92
|
-
},
|
|
93
|
-
sandbox: false,
|
|
94
|
-
};
|
|
92
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false });
|
|
95
93
|
data = {
|
|
96
|
-
operationName: 'list',
|
|
97
|
-
query: constants_1.QUERY_LIST,
|
|
94
|
+
operationName: this.dataHub.getOperationName('list'),
|
|
95
|
+
query: this.dataHub.isCrossAccount ? constants_1.QUERY_LIST_CROSSACCOUNT : constants_1.QUERY_LIST,
|
|
98
96
|
variables: variables,
|
|
99
97
|
};
|
|
100
98
|
return [2, this.dataHub.getFullList('POST', '/graphql', data)];
|
|
@@ -107,7 +105,7 @@ var Bots = (function () {
|
|
|
107
105
|
return __generator(this, function (_a) {
|
|
108
106
|
switch (_a.label) {
|
|
109
107
|
case 0:
|
|
110
|
-
route = "/v2/".concat(this.dataHub.currentAccountId, "/bot/").concat(id);
|
|
108
|
+
route = "/v2/".concat(this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current', "/bot/").concat(id);
|
|
111
109
|
params = {
|
|
112
110
|
includeDeleted: false,
|
|
113
111
|
includeExisting: true,
|
|
@@ -128,7 +126,7 @@ var Bots = (function () {
|
|
|
128
126
|
return __generator(this, function (_a) {
|
|
129
127
|
switch (_a.label) {
|
|
130
128
|
case 0:
|
|
131
|
-
route = "/v2/".concat(this.dataHub.currentAccountId, "/bot/").concat(source.id ? source.id : 'new');
|
|
129
|
+
route = "/v2/".concat(this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current', "/bot/").concat(source.id ? source.id : 'new');
|
|
132
130
|
data = {
|
|
133
131
|
bot: source,
|
|
134
132
|
};
|
|
@@ -144,10 +142,13 @@ var Bots = (function () {
|
|
|
144
142
|
};
|
|
145
143
|
Bots.prototype.deleteBot = function (botId) {
|
|
146
144
|
return __awaiter(this, void 0, void 0, function () {
|
|
147
|
-
var variables, data,
|
|
145
|
+
var variables, operationName, data, result;
|
|
148
146
|
return __generator(this, function (_a) {
|
|
149
147
|
switch (_a.label) {
|
|
150
148
|
case 0:
|
|
149
|
+
if (this.dataHub.isCrossAccount) {
|
|
150
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
151
|
+
}
|
|
151
152
|
variables = {
|
|
152
153
|
entity: constants_1.ENTITY_NAME,
|
|
153
154
|
data: {
|
|
@@ -155,8 +156,9 @@ var Bots = (function () {
|
|
|
155
156
|
subscribe: true,
|
|
156
157
|
},
|
|
157
158
|
};
|
|
159
|
+
operationName = this.dataHub.getOperationName('deleteTemporarily');
|
|
158
160
|
data = {
|
|
159
|
-
operationName:
|
|
161
|
+
operationName: operationName,
|
|
160
162
|
query: constants_1.QUERY_DELETE,
|
|
161
163
|
variables: variables,
|
|
162
164
|
};
|
|
@@ -166,8 +168,8 @@ var Bots = (function () {
|
|
|
166
168
|
data: data,
|
|
167
169
|
})];
|
|
168
170
|
case 1:
|
|
169
|
-
|
|
170
|
-
return [2, this.dataHub.subscribe(requestId)];
|
|
171
|
+
result = _a.sent();
|
|
172
|
+
return [2, this.dataHub.subscribe(result.data[operationName].requestId)];
|
|
171
173
|
}
|
|
172
174
|
});
|
|
173
175
|
});
|
package/dist/cjs/Bots.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bots.js","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"Bots.js","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAAkH;AAElH,yCAKqB;AACrB,qCAAsF;AAStF;IAUE,cAAY,MAAkB;QACpB,IAAA,KAAK,GAA8B,MAAM,MAApC,EAAE,YAAY,GAAgB,MAA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,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,AAtLD,IAsLC;AAtLY,oBAAI"}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ENTITY_NAME = exports.QUERY_DELETE = exports.QUERY_LIST = void 0;
|
|
3
|
+
exports.ENTITY_NAME = exports.QUERY_DELETE = exports.QUERY_LIST_CROSSACCOUNT = exports.QUERY_LIST = void 0;
|
|
4
4
|
exports.QUERY_LIST = "query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {\n list(entity: $entity, params: $params, sandbox: $sandbox) {\n records {\n ... on Bot {\n id\n data {\n label\n color\n description\n iconUrl\n password\n deploy {\n logsTTL\n }\n }\n tags\n dateModified\n }\n }\n last\n }\n}";
|
|
5
|
+
exports.QUERY_LIST_CROSSACCOUNT = "query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {\n listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {\n records {\n ... on Bot {\n id\n data {\n label\n color\n description\n iconUrl\n password\n deploy {\n logsTTL\n }\n }\n tags\n dateModified\n }\n }\n last\n }\n}";
|
|
5
6
|
exports.QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n }\n }\n}";
|
|
6
7
|
exports.ENTITY_NAME = 'BOT';
|
|
7
8
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,ibAqBxB,CAAC;AAEU,QAAA,YAAY,GAAG,yLAM1B,CAAC;AAEU,QAAA,WAAW,GAAG,KAAK,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,ibAqBxB,CAAC;AAEU,QAAA,uBAAuB,GAAG,+cAqBrC,CAAC;AAEU,QAAA,YAAY,GAAG,yLAM1B,CAAC;AAEU,QAAA,WAAW,GAAG,KAAK,CAAC"}
|
package/dist/esm/Bots.js
CHANGED
|
@@ -8,18 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { DataHub } from '@or-sdk/data-hub';
|
|
11
|
-
import { QUERY_LIST, QUERY_DELETE, ENTITY_NAME } from './constants';
|
|
11
|
+
import { QUERY_LIST, QUERY_DELETE, ENTITY_NAME, QUERY_LIST_CROSSACCOUNT, } from './constants';
|
|
12
12
|
import { Tags, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
|
|
13
13
|
export class Bots {
|
|
14
14
|
constructor(params) {
|
|
15
|
-
const { token, discoveryUrl } = params;
|
|
15
|
+
const { token, discoveryUrl, accountId } = params;
|
|
16
16
|
this.dataHub = new DataHub({
|
|
17
17
|
token,
|
|
18
18
|
discoveryUrl,
|
|
19
|
+
accountId,
|
|
19
20
|
});
|
|
20
21
|
this.tags = new Tags({
|
|
21
22
|
token,
|
|
22
23
|
discoveryUrl,
|
|
24
|
+
accountId,
|
|
23
25
|
});
|
|
24
26
|
}
|
|
25
27
|
init() {
|
|
@@ -32,19 +34,15 @@ export class Bots {
|
|
|
32
34
|
}
|
|
33
35
|
listBots() {
|
|
34
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const variables = {
|
|
36
|
-
entity: ENTITY_NAME,
|
|
37
|
-
params: {
|
|
37
|
+
const variables = Object.assign({ entity: ENTITY_NAME, params: {
|
|
38
38
|
queryParams: {},
|
|
39
39
|
includeDeleted: false,
|
|
40
40
|
includeExisting: true,
|
|
41
41
|
limit: 30,
|
|
42
|
-
},
|
|
43
|
-
sandbox: false,
|
|
44
|
-
};
|
|
42
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false });
|
|
45
43
|
const data = {
|
|
46
|
-
operationName: 'list',
|
|
47
|
-
query: QUERY_LIST,
|
|
44
|
+
operationName: this.dataHub.getOperationName('list'),
|
|
45
|
+
query: this.dataHub.isCrossAccount ? QUERY_LIST_CROSSACCOUNT : QUERY_LIST,
|
|
48
46
|
variables,
|
|
49
47
|
};
|
|
50
48
|
return this.dataHub.getFullList('POST', '/graphql', data);
|
|
@@ -52,7 +50,7 @@ export class Bots {
|
|
|
52
50
|
}
|
|
53
51
|
getBot(id) {
|
|
54
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
const route = `/v2/${this.dataHub.currentAccountId}/bot/${id}`;
|
|
53
|
+
const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/bot/${id}`;
|
|
56
54
|
const params = {
|
|
57
55
|
includeDeleted: false,
|
|
58
56
|
includeExisting: true,
|
|
@@ -66,7 +64,7 @@ export class Bots {
|
|
|
66
64
|
}
|
|
67
65
|
saveBot(source) {
|
|
68
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
const route = `/v2/${this.dataHub.currentAccountId}/bot/${source.id ? source.id : 'new'}`;
|
|
67
|
+
const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/bot/${source.id ? source.id : 'new'}`;
|
|
70
68
|
const data = {
|
|
71
69
|
bot: source,
|
|
72
70
|
};
|
|
@@ -79,6 +77,9 @@ export class Bots {
|
|
|
79
77
|
}
|
|
80
78
|
deleteBot(botId) {
|
|
81
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
if (this.dataHub.isCrossAccount) {
|
|
81
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
82
|
+
}
|
|
82
83
|
const variables = {
|
|
83
84
|
entity: ENTITY_NAME,
|
|
84
85
|
data: {
|
|
@@ -86,17 +87,18 @@ export class Bots {
|
|
|
86
87
|
subscribe: true,
|
|
87
88
|
},
|
|
88
89
|
};
|
|
90
|
+
const operationName = this.dataHub.getOperationName('deleteTemporarily');
|
|
89
91
|
const data = {
|
|
90
|
-
operationName
|
|
92
|
+
operationName,
|
|
91
93
|
query: QUERY_DELETE,
|
|
92
94
|
variables,
|
|
93
95
|
};
|
|
94
|
-
const
|
|
96
|
+
const result = yield this.dataHub.makeRequest({
|
|
95
97
|
method: 'POST',
|
|
96
98
|
route: '/graphql',
|
|
97
99
|
data,
|
|
98
100
|
});
|
|
99
|
-
return this.dataHub.subscribe(requestId);
|
|
101
|
+
return this.dataHub.subscribe(result.data[operationName].requestId);
|
|
100
102
|
});
|
|
101
103
|
}
|
|
102
104
|
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":";;;;;;;;;AACA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"Bots.js","sourceRoot":"","sources":["../../src/Bots.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,OAAO,EAAyE,MAAM,kBAAkB,CAAC;AAElH,OAAO,EACL,UAAU,EACV,YAAY,EACZ,WAAW,EACX,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,IAAI,EAAY,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CA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C,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
|
@@ -20,6 +20,28 @@ export const QUERY_LIST = `query list($entity: EntityType!, $params: ListInput!,
|
|
|
20
20
|
last
|
|
21
21
|
}
|
|
22
22
|
}`;
|
|
23
|
+
export const QUERY_LIST_CROSSACCOUNT = `query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {
|
|
24
|
+
listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {
|
|
25
|
+
records {
|
|
26
|
+
... on Bot {
|
|
27
|
+
id
|
|
28
|
+
data {
|
|
29
|
+
label
|
|
30
|
+
color
|
|
31
|
+
description
|
|
32
|
+
iconUrl
|
|
33
|
+
password
|
|
34
|
+
deploy {
|
|
35
|
+
logsTTL
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
tags
|
|
39
|
+
dateModified
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
last
|
|
43
|
+
}
|
|
44
|
+
}`;
|
|
23
45
|
export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
|
|
24
46
|
deleteTemporarily(entity: $entity, data: $data) {
|
|
25
47
|
... on AsyncRequest {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;EAqBxB,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;EAM1B,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;EAqBxB,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;EAqBrC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;EAM1B,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const QUERY_LIST = "query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {\n list(entity: $entity, params: $params, sandbox: $sandbox) {\n records {\n ... on Bot {\n id\n data {\n label\n color\n description\n iconUrl\n password\n deploy {\n logsTTL\n }\n }\n tags\n dateModified\n }\n }\n last\n }\n}";
|
|
2
|
+
export declare const QUERY_LIST_CROSSACCOUNT = "query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {\n listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {\n records {\n ... on Bot {\n id\n data {\n label\n color\n description\n iconUrl\n password\n deploy {\n logsTTL\n }\n }\n tags\n dateModified\n }\n }\n last\n }\n}";
|
|
2
3
|
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
4
|
export declare const ENTITY_NAME = "BOT";
|
package/dist/types/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.18.0",
|
|
3
3
|
"name": "@or-sdk/bots",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@or-sdk/base": "^0.
|
|
27
|
-
"@or-sdk/data-hub": "^0.
|
|
28
|
-
"@or-sdk/tags": "^0.
|
|
26
|
+
"@or-sdk/base": "^0.18.0",
|
|
27
|
+
"@or-sdk/data-hub": "^0.18.0",
|
|
28
|
+
"@or-sdk/tags": "^0.18.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "ad94e1383fbf7d40e63d762f1afb30c0530898f1"
|
|
31
31
|
}
|
package/src/Bots.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { List } from '@or-sdk/base';
|
|
2
|
-
import { DataHub, GraphqlResponse, GraphqlResponseCheckExecution } from '@or-sdk/data-hub';
|
|
2
|
+
import { DataHub, GraphqlResponse, GraphqlResponseCheckExecution, GraphqlResponseDelete } from '@or-sdk/data-hub';
|
|
3
3
|
import { BotsConfig, Bot } from './types';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
QUERY_LIST,
|
|
6
|
+
QUERY_DELETE,
|
|
7
|
+
ENTITY_NAME,
|
|
8
|
+
QUERY_LIST_CROSSACCOUNT,
|
|
9
|
+
} from './constants';
|
|
5
10
|
import { Tags, Taggable, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
|
|
6
11
|
|
|
7
12
|
/**
|
|
@@ -19,19 +24,20 @@ export class Bots implements Taggable<Bot> {
|
|
|
19
24
|
* ```typescript
|
|
20
25
|
* import { Bots } from '@or-sdk/bots'
|
|
21
26
|
* const bots = new Bots({token: 'my-account-token-string', discoveryUrl: 'http://example.bots/endpoint'});
|
|
22
|
-
* await bots.init();
|
|
23
27
|
* ```
|
|
24
28
|
*/
|
|
25
29
|
constructor(params: BotsConfig) {
|
|
26
|
-
const { token, discoveryUrl } = params;
|
|
30
|
+
const { token, discoveryUrl, accountId } = params;
|
|
27
31
|
|
|
28
32
|
this.dataHub = new DataHub({
|
|
29
33
|
token,
|
|
30
34
|
discoveryUrl,
|
|
35
|
+
accountId,
|
|
31
36
|
});
|
|
32
37
|
this.tags = new Tags({
|
|
33
38
|
token,
|
|
34
39
|
discoveryUrl,
|
|
40
|
+
accountId,
|
|
35
41
|
});
|
|
36
42
|
}
|
|
37
43
|
|
|
@@ -57,12 +63,12 @@ export class Bots implements Taggable<Bot> {
|
|
|
57
63
|
includeExisting: true,
|
|
58
64
|
limit: 30,
|
|
59
65
|
},
|
|
60
|
-
sandbox: false,
|
|
66
|
+
... this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false },
|
|
61
67
|
};
|
|
62
68
|
|
|
63
69
|
const data = {
|
|
64
|
-
operationName: 'list',
|
|
65
|
-
query: QUERY_LIST,
|
|
70
|
+
operationName: this.dataHub.getOperationName('list'),
|
|
71
|
+
query: this.dataHub.isCrossAccount ? QUERY_LIST_CROSSACCOUNT : QUERY_LIST,
|
|
66
72
|
variables,
|
|
67
73
|
};
|
|
68
74
|
|
|
@@ -76,7 +82,7 @@ export class Bots implements Taggable<Bot> {
|
|
|
76
82
|
* ```
|
|
77
83
|
*/
|
|
78
84
|
public async getBot(id: string): Promise<Bot> {
|
|
79
|
-
const route = `/v2/${this.dataHub.currentAccountId}/bot/${id}`;
|
|
85
|
+
const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/bot/${id}`;
|
|
80
86
|
|
|
81
87
|
const params = {
|
|
82
88
|
includeDeleted: false,
|
|
@@ -99,7 +105,7 @@ export class Bots implements Taggable<Bot> {
|
|
|
99
105
|
* ```
|
|
100
106
|
*/
|
|
101
107
|
public async saveBot(source: Bot): Promise<Bot> {
|
|
102
|
-
const route = `/v2/${this.dataHub.currentAccountId}/bot/${source.id ? source.id : 'new'}`;
|
|
108
|
+
const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/bot/${source.id ? source.id : 'new'}`;
|
|
103
109
|
|
|
104
110
|
const data = {
|
|
105
111
|
bot: source,
|
|
@@ -119,6 +125,10 @@ export class Bots implements Taggable<Bot> {
|
|
|
119
125
|
* ```
|
|
120
126
|
*/
|
|
121
127
|
public async deleteBot(botId: string): Promise<GraphqlResponseCheckExecution> {
|
|
128
|
+
if (this.dataHub.isCrossAccount) {
|
|
129
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
130
|
+
}
|
|
131
|
+
|
|
122
132
|
const variables = {
|
|
123
133
|
entity: ENTITY_NAME,
|
|
124
134
|
data: {
|
|
@@ -127,19 +137,21 @@ export class Bots implements Taggable<Bot> {
|
|
|
127
137
|
},
|
|
128
138
|
};
|
|
129
139
|
|
|
140
|
+
const operationName = this.dataHub.getOperationName('deleteTemporarily');
|
|
141
|
+
|
|
130
142
|
const data = {
|
|
131
|
-
operationName
|
|
143
|
+
operationName,
|
|
132
144
|
query: QUERY_DELETE,
|
|
133
145
|
variables,
|
|
134
146
|
};
|
|
135
147
|
|
|
136
|
-
const
|
|
148
|
+
const result = await this.dataHub.makeRequest<GraphqlResponse<void>>({
|
|
137
149
|
method: 'POST',
|
|
138
150
|
route: '/graphql',
|
|
139
151
|
data,
|
|
140
152
|
});
|
|
141
153
|
|
|
142
|
-
return this.dataHub.subscribe(requestId);
|
|
154
|
+
return this.dataHub.subscribe((result.data[operationName] as GraphqlResponseDelete).requestId);
|
|
143
155
|
}
|
|
144
156
|
|
|
145
157
|
/**
|
package/src/constants.ts
CHANGED
|
@@ -21,6 +21,29 @@ export const QUERY_LIST = `query list($entity: EntityType!, $params: ListInput!,
|
|
|
21
21
|
}
|
|
22
22
|
}`;
|
|
23
23
|
|
|
24
|
+
export const QUERY_LIST_CROSSACCOUNT = `query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {
|
|
25
|
+
listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {
|
|
26
|
+
records {
|
|
27
|
+
... on Bot {
|
|
28
|
+
id
|
|
29
|
+
data {
|
|
30
|
+
label
|
|
31
|
+
color
|
|
32
|
+
description
|
|
33
|
+
iconUrl
|
|
34
|
+
password
|
|
35
|
+
deploy {
|
|
36
|
+
logsTTL
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
tags
|
|
40
|
+
dateModified
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
last
|
|
44
|
+
}
|
|
45
|
+
}`;
|
|
46
|
+
|
|
24
47
|
export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
|
|
25
48
|
deleteTemporarily(entity: $entity, data: $data) {
|
|
26
49
|
... on AsyncRequest {
|