@or-sdk/deployments 1.2.2-next.558.0 → 1.2.3-beta.588.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 +8 -0
- package/README.md +1 -1
- package/dist/cjs/Deployments.js +126 -57
- package/dist/cjs/Deployments.js.map +1 -1
- package/dist/cjs/constants.js +15 -3
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/utils/getDeleteQuery.js +12 -0
- package/dist/cjs/utils/getDeleteQuery.js.map +1 -0
- package/dist/cjs/utils/getGetQuery.js +12 -0
- package/dist/cjs/utils/getGetQuery.js.map +1 -0
- package/dist/cjs/utils/getListQuery.js +12 -0
- package/dist/cjs/utils/getListQuery.js.map +1 -0
- package/dist/cjs/utils/index.js +13 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/esm/Deployments.js +99 -39
- package/dist/esm/Deployments.js.map +1 -1
- package/dist/esm/constants.js +57 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/utils/getDeleteQuery.js +17 -0
- package/dist/esm/utils/getDeleteQuery.js.map +1 -0
- package/dist/esm/utils/getGetQuery.js +20 -0
- package/dist/esm/utils/getGetQuery.js.map +1 -0
- package/dist/esm/utils/getListQuery.js +25 -0
- package/dist/esm/utils/getListQuery.js.map +1 -0
- package/dist/esm/utils/index.js +4 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/types/Deployments.d.ts +6 -6
- package/dist/types/Deployments.d.ts.map +1 -1
- package/dist/types/constants.d.ts +7 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/types.d.ts +3 -17
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/getDeleteQuery.d.ts +6 -0
- package/dist/types/utils/getDeleteQuery.d.ts.map +1 -0
- package/dist/types/utils/getGetQuery.d.ts +6 -0
- package/dist/types/utils/getGetQuery.d.ts.map +1 -0
- 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 +4 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/Deployments.ts +144 -50
- package/src/constants.ts +63 -1
- package/src/types.ts +4 -21
- package/src/utils/getDeleteQuery.ts +18 -0
- package/src/utils/getGetQuery.ts +21 -0
- package/src/utils/getListQuery.ts +26 -0
- package/src/utils/index.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
### [1.2.2](https://gitlab.com/onereach/platform/or-sdk-next/compare/@or-sdk/deployments@1.2.1...@or-sdk/deployments@1.2.2) (2022-08-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @or-sdk/deployments
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
### [1.2.1](https://gitlab.com/onereach/platform/or-sdk-next/compare/@or-sdk/deployments@1.2.0...@or-sdk/deployments@1.2.1) (2022-08-15)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @or-sdk/deployments
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ import { Deployments } from '@or-sdk/deployments'
|
|
|
10
10
|
// with direct api url
|
|
11
11
|
const deployments = new Deployments({
|
|
12
12
|
token: 'my-account-token-string',
|
|
13
|
-
|
|
13
|
+
dataHubUrl: 'http://example.deployments/endpoint'
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
// with service discovery(slower)
|
package/dist/cjs/Deployments.js
CHANGED
|
@@ -48,40 +48,49 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
exports.Deployments = void 0;
|
|
51
|
-
var
|
|
52
|
-
var
|
|
51
|
+
var data_hub_1 = require("@or-sdk/data-hub");
|
|
52
|
+
var constants_1 = require("./constants");
|
|
53
|
+
var utils_1 = require("./utils");
|
|
53
54
|
var Deployments = (function () {
|
|
54
55
|
function Deployments(params) {
|
|
55
|
-
var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId,
|
|
56
|
-
this.
|
|
56
|
+
var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId, dataHubUrl = params.dataHubUrl;
|
|
57
|
+
this.dataHub = new data_hub_1.DataHub({
|
|
57
58
|
token: token,
|
|
58
59
|
discoveryUrl: discoveryUrl,
|
|
59
60
|
accountId: accountId,
|
|
60
|
-
|
|
61
|
+
dataHubUrl: dataHubUrl,
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
|
-
Deployments.prototype.listDeployments = function (
|
|
64
|
-
|
|
65
|
-
if (paginationOptions === void 0) { paginationOptions = {}; }
|
|
64
|
+
Deployments.prototype.listDeployments = function (_a) {
|
|
65
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.query, query = _c === void 0 ? {} : _c, _d = _b.projection, projection = _d === void 0 ? [] : _d;
|
|
66
66
|
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
-
var
|
|
68
|
-
return __generator(this, function (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
var variables, operationName, data;
|
|
68
|
+
return __generator(this, function (_e) {
|
|
69
|
+
variables = __assign({ entity: constants_1.ENTITY_NAME, params: {
|
|
70
|
+
ids: query.id ?
|
|
71
|
+
Array.isArray(query.id) ?
|
|
72
|
+
query.id :
|
|
73
|
+
query.id.split(',') :
|
|
74
|
+
undefined,
|
|
75
|
+
queryParams: Array.isArray(query.id) ? __assign(__assign({}, query), { id: query.id.join(',') }) :
|
|
76
|
+
query,
|
|
77
|
+
limit: 30,
|
|
78
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false });
|
|
79
|
+
operationName = this.dataHub.getOperationName(data_hub_1.OperationNames.LIST);
|
|
80
|
+
data = {
|
|
81
|
+
operationName: operationName,
|
|
82
|
+
query: (0, utils_1.getListQuery)({
|
|
83
|
+
crossAccount: this.dataHub.isCrossAccount,
|
|
84
|
+
projection: projection,
|
|
85
|
+
}),
|
|
86
|
+
variables: variables,
|
|
87
|
+
};
|
|
88
|
+
return [2, this.dataHub.getFullList('POST', '/graphql', data)];
|
|
79
89
|
});
|
|
80
90
|
});
|
|
81
91
|
};
|
|
82
|
-
Deployments.prototype.listActiveDeployments = function (projection
|
|
92
|
+
Deployments.prototype.listActiveDeployments = function (projection) {
|
|
83
93
|
if (projection === void 0) { projection = []; }
|
|
84
|
-
if (paginationOptions === void 0) { paginationOptions = {}; }
|
|
85
94
|
return __awaiter(this, void 0, void 0, function () {
|
|
86
95
|
return __generator(this, function (_a) {
|
|
87
96
|
return [2, this.listDeployments({
|
|
@@ -89,7 +98,7 @@ var Deployments = (function () {
|
|
|
89
98
|
dateDeactivated: 0,
|
|
90
99
|
},
|
|
91
100
|
projection: projection,
|
|
92
|
-
}
|
|
101
|
+
})];
|
|
93
102
|
});
|
|
94
103
|
});
|
|
95
104
|
};
|
|
@@ -147,72 +156,132 @@ var Deployments = (function () {
|
|
|
147
156
|
});
|
|
148
157
|
});
|
|
149
158
|
};
|
|
150
|
-
Deployments.prototype.getDeployment = function (
|
|
151
|
-
if (
|
|
159
|
+
Deployments.prototype.getDeployment = function (deploymentId, projection) {
|
|
160
|
+
if (projection === void 0) { projection = []; }
|
|
152
161
|
return __awaiter(this, void 0, void 0, function () {
|
|
162
|
+
var variables, operationName, data, result;
|
|
153
163
|
return __generator(this, function (_a) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
164
|
+
switch (_a.label) {
|
|
165
|
+
case 0:
|
|
166
|
+
variables = __assign({ entity: constants_1.ENTITY_NAME, params: {
|
|
167
|
+
id: deploymentId,
|
|
168
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {});
|
|
169
|
+
operationName = this.dataHub.getOperationName(data_hub_1.OperationNames.GET);
|
|
170
|
+
data = {
|
|
171
|
+
operationName: operationName,
|
|
172
|
+
query: (0, utils_1.getGetQuery)({
|
|
173
|
+
crossAccount: this.dataHub.isCrossAccount,
|
|
174
|
+
projection: projection,
|
|
175
|
+
}),
|
|
176
|
+
variables: variables,
|
|
177
|
+
};
|
|
178
|
+
return [4, this.dataHub.makeRequest({
|
|
179
|
+
method: 'POST',
|
|
180
|
+
route: '/graphql',
|
|
181
|
+
data: data,
|
|
182
|
+
})];
|
|
183
|
+
case 1:
|
|
184
|
+
result = _a.sent();
|
|
185
|
+
return [2, result.data[operationName]];
|
|
186
|
+
}
|
|
159
187
|
});
|
|
160
188
|
});
|
|
161
189
|
};
|
|
162
|
-
Deployments.prototype.deleteDeployment = function (
|
|
190
|
+
Deployments.prototype.deleteDeployment = function (deploymentId, projection) {
|
|
191
|
+
if (projection === void 0) { projection = []; }
|
|
163
192
|
return __awaiter(this, void 0, void 0, function () {
|
|
193
|
+
var variables, operationName, data, result;
|
|
164
194
|
return __generator(this, function (_a) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
195
|
+
switch (_a.label) {
|
|
196
|
+
case 0:
|
|
197
|
+
if (this.dataHub.isCrossAccount) {
|
|
198
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
199
|
+
}
|
|
200
|
+
variables = {
|
|
201
|
+
entity: constants_1.ENTITY_NAME,
|
|
202
|
+
data: {
|
|
203
|
+
id: deploymentId,
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
operationName = this.dataHub.getOperationName(data_hub_1.OperationNames.DELETE);
|
|
207
|
+
data = {
|
|
208
|
+
operationName: operationName,
|
|
209
|
+
query: (0, utils_1.getDeleteQuery)({
|
|
210
|
+
crossAccount: this.dataHub.isCrossAccount,
|
|
211
|
+
projection: projection,
|
|
212
|
+
}),
|
|
213
|
+
variables: variables,
|
|
214
|
+
};
|
|
215
|
+
return [4, this.dataHub.makeRequest({
|
|
216
|
+
method: 'POST',
|
|
217
|
+
route: '/graphql',
|
|
218
|
+
data: data,
|
|
219
|
+
})];
|
|
220
|
+
case 1:
|
|
221
|
+
result = _a.sent();
|
|
222
|
+
return [2, result.data[operationName]];
|
|
223
|
+
}
|
|
170
224
|
});
|
|
171
225
|
});
|
|
172
226
|
};
|
|
173
227
|
Deployments.prototype.saveDeployment = function (source) {
|
|
174
228
|
return __awaiter(this, void 0, void 0, function () {
|
|
175
229
|
return __generator(this, function (_a) {
|
|
176
|
-
return [2,
|
|
230
|
+
return [2, source.id ? this.updateDeployment(source) : this.createDeployment(source)];
|
|
177
231
|
});
|
|
178
232
|
});
|
|
179
233
|
};
|
|
180
234
|
Deployments.prototype.createDeployment = function (source) {
|
|
181
235
|
return __awaiter(this, void 0, void 0, function () {
|
|
182
|
-
var result;
|
|
236
|
+
var variables, operationName, data, result;
|
|
183
237
|
return __generator(this, function (_a) {
|
|
184
238
|
switch (_a.label) {
|
|
185
|
-
case 0:
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
239
|
+
case 0:
|
|
240
|
+
variables = __assign({ entity: constants_1.ENTITY_NAME, data: {
|
|
241
|
+
body: source,
|
|
242
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {});
|
|
243
|
+
operationName = this.dataHub.getOperationName(data_hub_1.OperationNames.CREATE);
|
|
244
|
+
data = {
|
|
245
|
+
operationName: operationName,
|
|
246
|
+
query: this.dataHub.isCrossAccount ? constants_1.QUERY_CREATE_CROSSACCOUNT : constants_1.QUERY_CREATE,
|
|
247
|
+
variables: variables,
|
|
248
|
+
};
|
|
249
|
+
return [4, this.dataHub.makeRequest({
|
|
250
|
+
method: 'POST',
|
|
251
|
+
route: '/graphql',
|
|
252
|
+
data: data,
|
|
253
|
+
})];
|
|
193
254
|
case 1:
|
|
194
255
|
result = _a.sent();
|
|
195
|
-
return [2,
|
|
256
|
+
return [2, result.data[operationName]];
|
|
196
257
|
}
|
|
197
258
|
});
|
|
198
259
|
});
|
|
199
260
|
};
|
|
200
261
|
Deployments.prototype.updateDeployment = function (source) {
|
|
201
262
|
return __awaiter(this, void 0, void 0, function () {
|
|
202
|
-
var result;
|
|
263
|
+
var variables, operationName, data, result;
|
|
203
264
|
return __generator(this, function (_a) {
|
|
204
265
|
switch (_a.label) {
|
|
205
|
-
case 0:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
266
|
+
case 0:
|
|
267
|
+
variables = __assign({ entity: constants_1.ENTITY_NAME, data: {
|
|
268
|
+
id: source.id,
|
|
269
|
+
body: source,
|
|
270
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {});
|
|
271
|
+
operationName = this.dataHub.getOperationName(data_hub_1.OperationNames.UPDATE);
|
|
272
|
+
data = {
|
|
273
|
+
operationName: operationName,
|
|
274
|
+
query: this.dataHub.isCrossAccount ? constants_1.QUERY_UPDATE_CROSSACCOUNT : constants_1.QUERY_UPDATE,
|
|
275
|
+
variables: variables,
|
|
276
|
+
};
|
|
277
|
+
return [4, this.dataHub.makeRequest({
|
|
278
|
+
method: 'POST',
|
|
279
|
+
route: '/graphql',
|
|
280
|
+
data: data,
|
|
281
|
+
})];
|
|
213
282
|
case 1:
|
|
214
283
|
result = _a.sent();
|
|
215
|
-
return [2,
|
|
284
|
+
return [2, result.data[operationName]];
|
|
216
285
|
}
|
|
217
286
|
});
|
|
218
287
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Deployments.js","sourceRoot":"","sources":["../../src/Deployments.ts"],"names":[],"mappings":";;;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I,CAAC,aAAa,CAAe,EAAC;;;;KACjD;IACH,kBAAC;AAAD,CAAC,AA9RD,IA8RC;AA9RY,kCAAW"}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
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_UPDATE_CROSSACCOUNT = exports.QUERY_UPDATE = exports.QUERY_CREATE_CROSSACCOUNT = exports.QUERY_CREATE = exports.DEFAULT_PROJECTION_LIST = 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.DEFAULT_PROJECTION_LIST = [
|
|
7
|
+
'id',
|
|
8
|
+
'data',
|
|
9
|
+
'botId',
|
|
10
|
+
'flowId',
|
|
11
|
+
'dateDeactivated',
|
|
12
|
+
];
|
|
13
|
+
exports.QUERY_CREATE = "mutation create($entity: EntityType!, $data: CreateInput!) {\n create(entity: $entity, data: $data) {\n ... on Deployment {\n id\n data\n botId\n flowId\n dateDeactivated\n }\n }\n}\n";
|
|
14
|
+
exports.QUERY_CREATE_CROSSACCOUNT = "mutation createCrossAccount($entity: EntityType!, $data: CreateInput!, $accountId: String!) {\n createCrossAccount(entity: $entity, data: $data, accountId: $accountId) {\n ... on Deployment {\n id\n data\n botId\n flowId\n dateDeactivated\n }\n }\n}\n";
|
|
15
|
+
exports.QUERY_UPDATE = "mutation update($entity: EntityType!, $data: UpdateInput!) {\n update(entity: $entity, data: $data) {\n ... on Deployment {\n id\n data\n botId\n flowId\n dateDeactivated\n }\n }\n}\n";
|
|
16
|
+
exports.QUERY_UPDATE_CROSSACCOUNT = "mutation updateCrossAccount($entity: EntityType!, $data: UpdateInput!, $accountId: String!) {\n updateCrossAccount(entity: $entity, data: $data, accountId: $accountId) {\n ... on Deployment {\n id\n data\n botId\n flowId\n dateDeactivated\n }\n }\n}\n";
|
|
17
|
+
exports.ENTITY_NAME = 'DEPLOYMENT';
|
|
6
18
|
//# 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,uBAAuB,GAAG;IACrC,IAAI;IACJ,MAAM;IACN,OAAO;IACP,QAAQ;IACR,iBAAiB;CAClB,CAAC;AAEW,QAAA,YAAY,GAAG,sOAW3B,CAAC;AAEW,QAAA,yBAAyB,GAAG,0SAWxC,CAAC;AAEW,QAAA,YAAY,GAAG,sOAW3B,CAAC;AAEW,QAAA,yBAAyB,GAAG,0SAWxC,CAAC;AAEW,QAAA,WAAW,GAAG,YAAY,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var data_hub_1 = require("@or-sdk/data-hub");
|
|
4
|
+
var constants_1 = require("../constants");
|
|
5
|
+
function getDeleteQuery(_a) {
|
|
6
|
+
var _b = _a.projection, projection = _b === void 0 ? [] : _b, _c = _a.crossAccount, crossAccount = _c === void 0 ? false : _c;
|
|
7
|
+
return crossAccount ?
|
|
8
|
+
"query getCrossAccount($entity: EntityType!, $params: GetInput!, $accountId: String!) {\n getCrossAccount(entity: $entity, params: $params, accountId: $accountId)\n}" :
|
|
9
|
+
"mutation delete($entity: EntityType!, $data: DeleteInput!) {\n delete(entity: $entity, data: $data) {\n ... on Deployment {".concat((0, data_hub_1.getQueryProjectionPart)(projection.length ? projection : constants_1.DEFAULT_PROJECTION_LIST), "\n }\n }\n}\n");
|
|
10
|
+
}
|
|
11
|
+
exports.default = getDeleteQuery;
|
|
12
|
+
//# sourceMappingURL=getDeleteQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDeleteQuery.js","sourceRoot":"","sources":["../../../src/utils/getDeleteQuery.ts"],"names":[],"mappings":";;AAAA,6CAA0D;AAC1D,0CAAuD;AAEvD,SAAS,cAAc,CAAC,EAAyF;QAAvF,kBAAe,EAAf,UAAU,mBAAG,EAAE,KAAA,EAAE,oBAAoB,EAApB,YAAY,mBAAG,KAAK,KAAA;IAC7D,OAAO,YAAY,CAAC,CAAC;QACnB,uKAEF,CAAC,CAAC;QACA,yIAEqB,IAAA,iCAAsB,EAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,mCAAuB,CAAC,sBAIxG,CAAC;AACF,CAAC;AAED,kBAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var data_hub_1 = require("@or-sdk/data-hub");
|
|
4
|
+
var constants_1 = require("../constants");
|
|
5
|
+
function getGetQuery(_a) {
|
|
6
|
+
var _b = _a.projection, projection = _b === void 0 ? [] : _b, _c = _a.crossAccount, crossAccount = _c === void 0 ? false : _c;
|
|
7
|
+
return crossAccount ?
|
|
8
|
+
"query getCrossAccount($entity: EntityType!, $params: GetInput!, $accountId: String!) {\n getCrossAccount(entity: $entity, params: $params, accountId: $accountId) {\n ... on Deployment {".concat((0, data_hub_1.getQueryProjectionPart)(projection.length ? projection : constants_1.DEFAULT_PROJECTION_LIST), "\n }\n }\n}") :
|
|
9
|
+
"query get($entity: EntityType!, $params: GetInput!) {\n get(entity: $entity, params: $params) {\n ... on Deployment {".concat((0, data_hub_1.getQueryProjectionPart)(projection.length ? projection : constants_1.DEFAULT_PROJECTION_LIST), "\n }\n }\n}\n");
|
|
10
|
+
}
|
|
11
|
+
exports.default = getGetQuery;
|
|
12
|
+
//# sourceMappingURL=getGetQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getGetQuery.js","sourceRoot":"","sources":["../../../src/utils/getGetQuery.ts"],"names":[],"mappings":";;AAAA,6CAA0D;AAC1D,0CAAuD;AAEvD,SAAS,WAAW,CAAC,EAAyF;QAAvF,kBAAe,EAAf,UAAU,mBAAG,EAAE,KAAA,EAAE,oBAAoB,EAApB,YAAY,mBAAG,KAAK,KAAA;IAC1D,OAAO,YAAY,CAAC,CAAC;QACnB,uMAEqB,IAAA,iCAAsB,EAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,mCAAuB,CAAC,oBAGvG,CAAC,CAAC;QACA,mIAEqB,IAAA,iCAAsB,EAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,mCAAuB,CAAC,sBAIxG,CAAC;AACF,CAAC;AAED,kBAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var data_hub_1 = require("@or-sdk/data-hub");
|
|
4
|
+
var constants_1 = require("../constants");
|
|
5
|
+
function getListQuery(_a) {
|
|
6
|
+
var _b = _a.projection, projection = _b === void 0 ? [] : _b, _c = _a.crossAccount, crossAccount = _c === void 0 ? false : _c;
|
|
7
|
+
return crossAccount ?
|
|
8
|
+
"query listCrossAccount($entity: EntityType!, $params: ListInput!, $accountId: String!) {\n listCrossAccount(entity: $entity, params: $params, accountId: $accountId) {\n records {\n ... on Deployment {".concat((0, data_hub_1.getQueryProjectionPart)(projection.length ? projection : constants_1.DEFAULT_PROJECTION_LIST), "\n }\n }\n last\n }\n}") :
|
|
9
|
+
"query list($entity: EntityType!, $params: ListInput!, $sandbox: Boolean) {\n list(entity: $entity, params: $params, sandbox: $sandbox) {\n records {\n ... on Deployment {".concat((0, data_hub_1.getQueryProjectionPart)(projection.length ? projection : constants_1.DEFAULT_PROJECTION_LIST), "\n }\n }\n last\n }\n}");
|
|
10
|
+
}
|
|
11
|
+
exports.default = getListQuery;
|
|
12
|
+
//# sourceMappingURL=getListQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getListQuery.js","sourceRoot":"","sources":["../../../src/utils/getListQuery.ts"],"names":[],"mappings":";;AAAA,6CAA0D;AAC1D,0CAAuD;AAEvD,SAAS,YAAY,CAAC,EAAyF;QAAvF,kBAAe,EAAf,UAAU,mBAAG,EAAE,KAAA,EAAE,oBAAoB,EAApB,YAAY,mBAAG,KAAK,KAAA;IAC3D,OAAO,YAAY,CAAC,CAAC;QACnB,2NAGuB,IAAA,iCAAsB,EAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,mCAAuB,CAAC,uCAKzG,CAAC,CAAC;QACA,6LAGuB,IAAA,iCAAsB,EAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,mCAAuB,CAAC,uCAKzG,CAAC;AACH,CAAC;AAED,kBAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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.getDeleteQuery = exports.getGetQuery = 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
|
+
var getGetQuery_1 = require("./getGetQuery");
|
|
10
|
+
Object.defineProperty(exports, "getGetQuery", { enumerable: true, get: function () { return __importDefault(getGetQuery_1).default; } });
|
|
11
|
+
var getDeleteQuery_1 = require("./getDeleteQuery");
|
|
12
|
+
Object.defineProperty(exports, "getDeleteQuery", { enumerable: true, get: function () { return __importDefault(getDeleteQuery_1).default; } });
|
|
13
|
+
//# 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;AAChC,6CAAuD;AAA9C,2HAAA,OAAO,OAAe;AAC/B,mDAA6D;AAApD,iIAAA,OAAO,OAAkB"}
|
package/dist/esm/Deployments.js
CHANGED
|
@@ -7,36 +7,51 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { DataHub, OperationNames } from '@or-sdk/data-hub';
|
|
11
|
+
import { ENTITY_NAME, QUERY_CREATE, QUERY_CREATE_CROSSACCOUNT, QUERY_UPDATE, QUERY_UPDATE_CROSSACCOUNT, } from './constants';
|
|
12
|
+
import { getGetQuery, getListQuery, getDeleteQuery } from './utils';
|
|
12
13
|
export class Deployments {
|
|
13
14
|
constructor(params) {
|
|
14
|
-
const { token, discoveryUrl, accountId,
|
|
15
|
-
this.
|
|
15
|
+
const { token, discoveryUrl, accountId, dataHubUrl } = params;
|
|
16
|
+
this.dataHub = new DataHub({
|
|
16
17
|
token,
|
|
17
18
|
discoveryUrl,
|
|
18
19
|
accountId,
|
|
19
|
-
|
|
20
|
+
dataHubUrl,
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
|
-
listDeployments(
|
|
23
|
+
listDeployments({ query = {}, projection = [] } = {}) {
|
|
23
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const variables = Object.assign({ entity: ENTITY_NAME, params: {
|
|
26
|
+
ids: query.id ?
|
|
27
|
+
Array.isArray(query.id) ?
|
|
28
|
+
query.id :
|
|
29
|
+
query.id.split(',') :
|
|
30
|
+
undefined,
|
|
31
|
+
queryParams: Array.isArray(query.id) ? Object.assign(Object.assign({}, query), { id: query.id.join(',') }) :
|
|
32
|
+
query,
|
|
33
|
+
limit: 30,
|
|
34
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false });
|
|
35
|
+
const operationName = this.dataHub.getOperationName(OperationNames.LIST);
|
|
36
|
+
const data = {
|
|
37
|
+
operationName,
|
|
38
|
+
query: getListQuery({
|
|
39
|
+
crossAccount: this.dataHub.isCrossAccount,
|
|
40
|
+
projection,
|
|
41
|
+
}),
|
|
42
|
+
variables,
|
|
43
|
+
};
|
|
44
|
+
return this.dataHub.getFullList('POST', '/graphql', data);
|
|
30
45
|
});
|
|
31
46
|
}
|
|
32
|
-
listActiveDeployments(projection = []
|
|
47
|
+
listActiveDeployments(projection = []) {
|
|
33
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
49
|
return this.listDeployments({
|
|
35
50
|
query: {
|
|
36
51
|
dateDeactivated: 0,
|
|
37
52
|
},
|
|
38
53
|
projection,
|
|
39
|
-
}
|
|
54
|
+
});
|
|
40
55
|
});
|
|
41
56
|
}
|
|
42
57
|
listDeploymentsByBotId(botId, projection = []) {
|
|
@@ -81,53 +96,98 @@ export class Deployments {
|
|
|
81
96
|
});
|
|
82
97
|
});
|
|
83
98
|
}
|
|
84
|
-
getDeployment(
|
|
99
|
+
getDeployment(deploymentId, projection = []) {
|
|
85
100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
const variables = Object.assign({ entity: ENTITY_NAME, params: {
|
|
102
|
+
id: deploymentId,
|
|
103
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {});
|
|
104
|
+
const operationName = this.dataHub.getOperationName(OperationNames.GET);
|
|
105
|
+
const data = {
|
|
106
|
+
operationName,
|
|
107
|
+
query: getGetQuery({
|
|
108
|
+
crossAccount: this.dataHub.isCrossAccount,
|
|
109
|
+
projection,
|
|
110
|
+
}),
|
|
111
|
+
variables,
|
|
112
|
+
};
|
|
113
|
+
const result = yield this.dataHub.makeRequest({
|
|
114
|
+
method: 'POST',
|
|
115
|
+
route: '/graphql',
|
|
116
|
+
data,
|
|
90
117
|
});
|
|
118
|
+
return result.data[operationName];
|
|
91
119
|
});
|
|
92
120
|
}
|
|
93
|
-
deleteDeployment(
|
|
121
|
+
deleteDeployment(deploymentId, projection = []) {
|
|
94
122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
123
|
+
if (this.dataHub.isCrossAccount) {
|
|
124
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
125
|
+
}
|
|
126
|
+
const variables = {
|
|
127
|
+
entity: ENTITY_NAME,
|
|
128
|
+
data: {
|
|
129
|
+
id: deploymentId,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
const operationName = this.dataHub.getOperationName(OperationNames.DELETE);
|
|
133
|
+
const data = {
|
|
134
|
+
operationName,
|
|
135
|
+
query: getDeleteQuery({
|
|
136
|
+
crossAccount: this.dataHub.isCrossAccount,
|
|
137
|
+
projection,
|
|
138
|
+
}),
|
|
139
|
+
variables,
|
|
140
|
+
};
|
|
141
|
+
const result = yield this.dataHub.makeRequest({
|
|
142
|
+
method: 'POST',
|
|
143
|
+
route: '/graphql',
|
|
144
|
+
data,
|
|
99
145
|
});
|
|
146
|
+
return result.data[operationName];
|
|
100
147
|
});
|
|
101
148
|
}
|
|
102
149
|
saveDeployment(source) {
|
|
103
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
return
|
|
151
|
+
return source.id ? this.updateDeployment(source) : this.createDeployment(source);
|
|
105
152
|
});
|
|
106
153
|
}
|
|
107
154
|
createDeployment(source) {
|
|
108
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
const
|
|
156
|
+
const variables = Object.assign({ entity: ENTITY_NAME, data: {
|
|
157
|
+
body: source,
|
|
158
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {});
|
|
159
|
+
const operationName = this.dataHub.getOperationName(OperationNames.CREATE);
|
|
160
|
+
const data = {
|
|
161
|
+
operationName,
|
|
162
|
+
query: this.dataHub.isCrossAccount ? QUERY_CREATE_CROSSACCOUNT : QUERY_CREATE,
|
|
163
|
+
variables,
|
|
164
|
+
};
|
|
165
|
+
const result = yield this.dataHub.makeRequest({
|
|
110
166
|
method: 'POST',
|
|
111
|
-
route: '
|
|
112
|
-
data
|
|
113
|
-
deployment: Object.assign(Object.assign({}, source), { id: 'new' }),
|
|
114
|
-
},
|
|
115
|
-
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
167
|
+
route: '/graphql',
|
|
168
|
+
data,
|
|
116
169
|
});
|
|
117
|
-
return
|
|
170
|
+
return result.data[operationName];
|
|
118
171
|
});
|
|
119
172
|
}
|
|
120
173
|
updateDeployment(source) {
|
|
121
174
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
-
const
|
|
175
|
+
const variables = Object.assign({ entity: ENTITY_NAME, data: {
|
|
176
|
+
id: source.id,
|
|
177
|
+
body: source,
|
|
178
|
+
} }, this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {});
|
|
179
|
+
const operationName = this.dataHub.getOperationName(OperationNames.UPDATE);
|
|
180
|
+
const data = {
|
|
181
|
+
operationName,
|
|
182
|
+
query: this.dataHub.isCrossAccount ? QUERY_UPDATE_CROSSACCOUNT : QUERY_UPDATE,
|
|
183
|
+
variables,
|
|
184
|
+
};
|
|
185
|
+
const result = yield this.dataHub.makeRequest({
|
|
123
186
|
method: 'POST',
|
|
124
|
-
route:
|
|
125
|
-
data
|
|
126
|
-
deployment: source,
|
|
127
|
-
},
|
|
128
|
-
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
187
|
+
route: '/graphql',
|
|
188
|
+
data,
|
|
129
189
|
});
|
|
130
|
-
return
|
|
190
|
+
return result.data[operationName];
|
|
131
191
|
});
|
|
132
192
|
}
|
|
133
193
|
}
|