@or-sdk/deployments 1.3.0-beta.647.0 → 2.0.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/Deployments.js +57 -126
  4. package/dist/cjs/Deployments.js.map +1 -1
  5. package/dist/cjs/constants.js +3 -15
  6. package/dist/cjs/constants.js.map +1 -1
  7. package/dist/esm/Deployments.js +105 -155
  8. package/dist/esm/Deployments.js.map +1 -1
  9. package/dist/esm/constants.js +1 -57
  10. package/dist/esm/constants.js.map +1 -1
  11. package/dist/types/Deployments.d.ts +6 -6
  12. package/dist/types/Deployments.d.ts.map +1 -1
  13. package/dist/types/constants.d.ts +1 -7
  14. package/dist/types/constants.d.ts.map +1 -1
  15. package/dist/types/types.d.ts +17 -3
  16. package/dist/types/types.d.ts.map +1 -1
  17. package/package.json +5 -4
  18. package/src/Deployments.ts +50 -144
  19. package/src/constants.ts +1 -63
  20. package/src/types.ts +21 -4
  21. package/tsconfig.esm.json +1 -1
  22. package/dist/cjs/utils/getDeleteQuery.js +0 -12
  23. package/dist/cjs/utils/getDeleteQuery.js.map +0 -1
  24. package/dist/cjs/utils/getGetQuery.js +0 -12
  25. package/dist/cjs/utils/getGetQuery.js.map +0 -1
  26. package/dist/cjs/utils/getListQuery.js +0 -12
  27. package/dist/cjs/utils/getListQuery.js.map +0 -1
  28. package/dist/cjs/utils/index.js +0 -13
  29. package/dist/cjs/utils/index.js.map +0 -1
  30. package/dist/esm/utils/getDeleteQuery.js +0 -17
  31. package/dist/esm/utils/getDeleteQuery.js.map +0 -1
  32. package/dist/esm/utils/getGetQuery.js +0 -20
  33. package/dist/esm/utils/getGetQuery.js.map +0 -1
  34. package/dist/esm/utils/getListQuery.js +0 -25
  35. package/dist/esm/utils/getListQuery.js.map +0 -1
  36. package/dist/esm/utils/index.js +0 -4
  37. package/dist/esm/utils/index.js.map +0 -1
  38. package/dist/types/utils/getDeleteQuery.d.ts +0 -6
  39. package/dist/types/utils/getDeleteQuery.d.ts.map +0 -1
  40. package/dist/types/utils/getGetQuery.d.ts +0 -6
  41. package/dist/types/utils/getGetQuery.d.ts.map +0 -1
  42. package/dist/types/utils/getListQuery.d.ts +0 -6
  43. package/dist/types/utils/getListQuery.d.ts.map +0 -1
  44. package/dist/types/utils/index.d.ts +0 -4
  45. package/dist/types/utils/index.d.ts.map +0 -1
  46. package/src/utils/getDeleteQuery.ts +0 -18
  47. package/src/utils/getGetQuery.ts +0 -21
  48. package/src/utils/getListQuery.ts +0 -26
  49. package/src/utils/index.ts +0 -7
package/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.0.0](https://gitlab.com/onereach/platform/or-sdk-next/compare/@or-sdk/deployments@1.2.5...@or-sdk/deployments@2.0.0) (2022-10-21)
7
+
8
+
9
+ ### ⚠ BREAKING CHANGES
10
+
11
+ * **data-hub-svc:** DataHub changed to DataHubSvc, now constructor needs `dataHubSvcUrl` instead of `dataHubUrl`
12
+
13
+ ### Features
14
+
15
+ * **data-hub-svc:** DataHub changed to DataHubSvc, now constructor needs `dataHubSvcUrl` instead of `dataHubUrl` ([bf9c8ff](https://gitlab.com/onereach/platform/or-sdk-next/commit/bf9c8ff0c660e19f174ad04a135320c98152c4e7))
16
+
17
+
18
+
6
19
  ### [1.2.5](https://gitlab.com/onereach/platform/or-sdk-next/compare/@or-sdk/deployments@1.2.4...@or-sdk/deployments@1.2.5) (2022-09-09)
7
20
 
8
21
  **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
- dataHubUrl: 'http://example.deployments/endpoint'
13
+ dataHubSvcUrl: 'http://example.data-hub-svc/endpoint'
14
14
  });
15
15
 
16
16
  // with service discovery(slower)
@@ -48,49 +48,40 @@ 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 data_hub_1 = require("@or-sdk/data-hub");
52
- var constants_1 = require("./constants");
53
- var utils_1 = require("./utils");
51
+ var base_1 = require("@or-sdk/base");
52
+ var data_hub_svc_1 = require("@or-sdk/data-hub-svc");
54
53
  var Deployments = (function () {
55
54
  function Deployments(params) {
56
- var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId, dataHubUrl = params.dataHubUrl;
57
- this.dataHub = new data_hub_1.DataHub({
55
+ var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId, dataHubSvcUrl = params.dataHubSvcUrl;
56
+ this.dataHubSvc = new data_hub_svc_1.DataHubSvc({
58
57
  token: token,
59
58
  discoveryUrl: discoveryUrl,
60
59
  accountId: accountId,
61
- dataHubUrl: dataHubUrl,
60
+ dataHubSvcUrl: dataHubSvcUrl,
62
61
  });
63
62
  }
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;
63
+ Deployments.prototype.listDeployments = function (params, paginationOptions) {
64
+ if (params === void 0) { params = {}; }
65
+ if (paginationOptions === void 0) { paginationOptions = {}; }
66
66
  return __awaiter(this, void 0, void 0, function () {
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)];
67
+ var result;
68
+ return __generator(this, function (_a) {
69
+ switch (_a.label) {
70
+ case 0: return [4, this.dataHubSvc.makeRequest({
71
+ method: 'GET',
72
+ route: 'deployments',
73
+ params: __assign(__assign(__assign({}, params), paginationOptions), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
74
+ })];
75
+ case 1:
76
+ result = _a.sent();
77
+ return [2, (0, base_1.makeList)(result)];
78
+ }
89
79
  });
90
80
  });
91
81
  };
92
- Deployments.prototype.listActiveDeployments = function (projection) {
82
+ Deployments.prototype.listActiveDeployments = function (projection, paginationOptions) {
93
83
  if (projection === void 0) { projection = []; }
84
+ if (paginationOptions === void 0) { paginationOptions = {}; }
94
85
  return __awaiter(this, void 0, void 0, function () {
95
86
  return __generator(this, function (_a) {
96
87
  return [2, this.listDeployments({
@@ -98,7 +89,7 @@ var Deployments = (function () {
98
89
  dateDeactivated: 0,
99
90
  },
100
91
  projection: projection,
101
- })];
92
+ }, paginationOptions)];
102
93
  });
103
94
  });
104
95
  };
@@ -156,132 +147,72 @@ var Deployments = (function () {
156
147
  });
157
148
  });
158
149
  };
159
- Deployments.prototype.getDeployment = function (deploymentId, projection) {
160
- if (projection === void 0) { projection = []; }
150
+ Deployments.prototype.getDeployment = function (id, params) {
151
+ if (params === void 0) { params = {}; }
161
152
  return __awaiter(this, void 0, void 0, function () {
162
- var variables, operationName, data, result;
163
153
  return __generator(this, function (_a) {
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
- }
154
+ return [2, this.dataHubSvc.makeRequest({
155
+ method: 'GET',
156
+ route: "deployments/".concat(id),
157
+ params: __assign(__assign({}, Array.isArray(params) ? { projection: params } : params), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
158
+ })];
187
159
  });
188
160
  });
189
161
  };
190
- Deployments.prototype.deleteDeployment = function (deploymentId, projection) {
191
- if (projection === void 0) { projection = []; }
162
+ Deployments.prototype.deleteDeployment = function (id) {
192
163
  return __awaiter(this, void 0, void 0, function () {
193
- var variables, operationName, data, result;
194
164
  return __generator(this, function (_a) {
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
- }
165
+ return [2, this.dataHubSvc.makeRequest({
166
+ method: 'DELETE',
167
+ route: "deployments/".concat(id),
168
+ params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
169
+ })];
224
170
  });
225
171
  });
226
172
  };
227
173
  Deployments.prototype.saveDeployment = function (source) {
228
174
  return __awaiter(this, void 0, void 0, function () {
229
175
  return __generator(this, function (_a) {
230
- return [2, source.id ? this.updateDeployment(source) : this.createDeployment(source)];
176
+ return [2, (source.id && source.id !== 'new') ? this.updateDeployment(source) : this.createDeployment(source)];
231
177
  });
232
178
  });
233
179
  };
234
180
  Deployments.prototype.createDeployment = function (source) {
235
181
  return __awaiter(this, void 0, void 0, function () {
236
- var variables, operationName, data, result;
182
+ var result;
237
183
  return __generator(this, function (_a) {
238
184
  switch (_a.label) {
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
- })];
185
+ case 0: return [4, this.dataHubSvc.makeRequest({
186
+ method: 'POST',
187
+ route: 'deployments/new',
188
+ data: {
189
+ deployment: __assign(__assign({}, source), { id: 'new' }),
190
+ },
191
+ params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
192
+ })];
254
193
  case 1:
255
194
  result = _a.sent();
256
- return [2, result.data[operationName]];
195
+ return [2, (0, data_hub_svc_1.setDiff)(source, result)];
257
196
  }
258
197
  });
259
198
  });
260
199
  };
261
200
  Deployments.prototype.updateDeployment = function (source) {
262
201
  return __awaiter(this, void 0, void 0, function () {
263
- var variables, operationName, data, result;
202
+ var result;
264
203
  return __generator(this, function (_a) {
265
204
  switch (_a.label) {
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
- })];
205
+ case 0: return [4, this.dataHubSvc.makeRequest({
206
+ method: 'POST',
207
+ route: "deployments/".concat(source.id),
208
+ data: {
209
+ deployment: source,
210
+ },
211
+ params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
212
+ })];
282
213
  case 1:
283
214
  result = _a.sent();
284
- return [2, result.data[operationName]];
215
+ return [2, (0, data_hub_svc_1.setDiff)(source, result)];
285
216
  }
286
217
  });
287
218
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Deployments.js","sourceRoot":"","sources":["../../src/Deployments.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAA4E;AAE5E,yCAMqB;AACrB,iCAAoE;AAEpE;IASE,qBAAY,MAAyB;QAC3B,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;IACL,CAAC;IAQY,qCAAe,GAA5B,UAA6B,EAAoF;YAApF,qBAAyD,EAA2B,KAAA,EAAlF,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EAAE,kBAAe,EAAf,UAAU,mB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Y_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';
3
+ exports.DATA_HUB_SVC_SERVICE_KEY = void 0;
4
+ var data_hub_svc_1 = require("@or-sdk/data-hub-svc");
5
+ Object.defineProperty(exports, "DATA_HUB_SVC_SERVICE_KEY", { enumerable: true, get: function () { return data_hub_svc_1.DATA_HUB_SVC_SERVICE_KEY; } });
18
6
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,qDAAgE;AAAvD,wHAAA,wBAAwB,OAAA"}
@@ -1,184 +1,134 @@
1
- import { DataHub, OperationNames } from '@or-sdk/data-hub';
2
- import { ENTITY_NAME, QUERY_CREATE, QUERY_CREATE_CROSSACCOUNT, QUERY_UPDATE, QUERY_UPDATE_CROSSACCOUNT, } from './constants';
3
- import { getGetQuery, getListQuery, getDeleteQuery } from './utils';
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { makeList } from '@or-sdk/base';
11
+ import { DataHubSvc, setDiff } from '@or-sdk/data-hub-svc';
4
12
  export class Deployments {
5
- dataHub;
6
13
  constructor(params) {
7
- const { token, discoveryUrl, accountId, dataHubUrl } = params;
8
- this.dataHub = new DataHub({
14
+ const { token, discoveryUrl, accountId, dataHubSvcUrl } = params;
15
+ this.dataHubSvc = new DataHubSvc({
9
16
  token,
10
17
  discoveryUrl,
11
18
  accountId,
12
- dataHubUrl,
19
+ dataHubSvcUrl,
13
20
  });
14
21
  }
15
- async listDeployments({ query = {}, projection = [] } = {}) {
16
- const variables = {
17
- entity: ENTITY_NAME,
18
- params: {
19
- ids: query.id ?
20
- Array.isArray(query.id) ?
21
- query.id :
22
- query.id.split(',') :
23
- undefined,
24
- queryParams: Array.isArray(query.id) ?
25
- {
26
- ...query,
27
- id: query.id.join(','),
28
- } :
29
- query,
30
- limit: 30,
31
- },
32
- ...this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : { sandbox: false },
33
- };
34
- const operationName = this.dataHub.getOperationName(OperationNames.LIST);
35
- const data = {
36
- operationName,
37
- query: getListQuery({
38
- crossAccount: this.dataHub.isCrossAccount,
39
- projection,
40
- }),
41
- variables,
42
- };
43
- return this.dataHub.getFullList('POST', '/graphql', data);
44
- }
45
- async listActiveDeployments(projection = []) {
46
- return this.listDeployments({
47
- query: {
48
- dateDeactivated: 0,
49
- },
50
- projection,
22
+ listDeployments(params = {}, paginationOptions = {}) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ const result = yield this.dataHubSvc.makeRequest({
25
+ method: 'GET',
26
+ route: 'deployments',
27
+ params: Object.assign(Object.assign(Object.assign({}, params), paginationOptions), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
28
+ });
29
+ return makeList(result);
51
30
  });
52
31
  }
53
- async listDeploymentsByBotId(botId, projection = []) {
54
- return this.listDeployments({
55
- query: {
56
- botId,
57
- },
58
- projection,
32
+ listActiveDeployments(projection = [], paginationOptions = {}) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ return this.listDeployments({
35
+ query: {
36
+ dateDeactivated: 0,
37
+ },
38
+ projection,
39
+ }, paginationOptions);
59
40
  });
60
41
  }
61
- async listActiveDeploymentsByBotId(botId, projection = []) {
62
- return this.listDeployments({
63
- query: {
64
- botId,
65
- dateDeactivated: 0,
66
- },
67
- projection,
42
+ listDeploymentsByBotId(botId, projection = []) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ return this.listDeployments({
45
+ query: {
46
+ botId,
47
+ },
48
+ projection,
49
+ });
68
50
  });
69
51
  }
70
- async listDeploymentsByFlowId(flowId, projection = []) {
71
- return this.listDeployments({
72
- query: {
73
- flowId,
74
- },
75
- projection,
52
+ listActiveDeploymentsByBotId(botId, projection = []) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ return this.listDeployments({
55
+ query: {
56
+ botId,
57
+ dateDeactivated: 0,
58
+ },
59
+ projection,
60
+ });
76
61
  });
77
62
  }
78
- async listActiveDeploymentsByFlowId(flowId, projection = []) {
79
- return this.listDeployments({
80
- query: {
81
- flowId,
82
- dateDeactivated: 0,
83
- },
84
- projection,
63
+ listDeploymentsByFlowId(flowId, projection = []) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ return this.listDeployments({
66
+ query: {
67
+ flowId,
68
+ },
69
+ projection,
70
+ });
85
71
  });
86
72
  }
87
- async getDeployment(deploymentId, projection = []) {
88
- const variables = {
89
- entity: ENTITY_NAME,
90
- params: {
91
- id: deploymentId,
92
- },
93
- ...this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {},
94
- };
95
- const operationName = this.dataHub.getOperationName(OperationNames.GET);
96
- const data = {
97
- operationName,
98
- query: getGetQuery({
99
- crossAccount: this.dataHub.isCrossAccount,
73
+ listActiveDeploymentsByFlowId(flowId, projection = []) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ return this.listDeployments({
76
+ query: {
77
+ flowId,
78
+ dateDeactivated: 0,
79
+ },
100
80
  projection,
101
- }),
102
- variables,
103
- };
104
- const result = await this.dataHub.makeRequest({
105
- method: 'POST',
106
- route: '/graphql',
107
- data,
81
+ });
108
82
  });
109
- return result.data[operationName];
110
83
  }
111
- async deleteDeployment(deploymentId, projection = []) {
112
- if (this.dataHub.isCrossAccount) {
113
- throw Error('Cross-account deleting is not implemented.');
114
- }
115
- const variables = {
116
- entity: ENTITY_NAME,
117
- data: {
118
- id: deploymentId,
119
- },
120
- };
121
- const operationName = this.dataHub.getOperationName(OperationNames.DELETE);
122
- const data = {
123
- operationName,
124
- query: getDeleteQuery({
125
- crossAccount: this.dataHub.isCrossAccount,
126
- projection,
127
- }),
128
- variables,
129
- };
130
- const result = await this.dataHub.makeRequest({
131
- method: 'POST',
132
- route: '/graphql',
133
- data,
84
+ getDeployment(id, params = {}) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ return this.dataHubSvc.makeRequest({
87
+ method: 'GET',
88
+ route: `deployments/${id}`,
89
+ params: Object.assign(Object.assign({}, Array.isArray(params) ? { projection: params } : params), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
90
+ });
134
91
  });
135
- return result.data[operationName];
136
92
  }
137
- async saveDeployment(source) {
138
- return source.id ? this.updateDeployment(source) : this.createDeployment(source);
93
+ deleteDeployment(id) {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ return this.dataHubSvc.makeRequest({
96
+ method: 'DELETE',
97
+ route: `deployments/${id}`,
98
+ params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
99
+ });
100
+ });
101
+ }
102
+ saveDeployment(source) {
103
+ return __awaiter(this, void 0, void 0, function* () {
104
+ return (source.id && source.id !== 'new') ? this.updateDeployment(source) : this.createDeployment(source);
105
+ });
139
106
  }
140
- async createDeployment(source) {
141
- const variables = {
142
- entity: ENTITY_NAME,
143
- data: {
144
- body: source,
145
- },
146
- ...this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {},
147
- };
148
- const operationName = this.dataHub.getOperationName(OperationNames.CREATE);
149
- const data = {
150
- operationName,
151
- query: this.dataHub.isCrossAccount ? QUERY_CREATE_CROSSACCOUNT : QUERY_CREATE,
152
- variables,
153
- };
154
- const result = await this.dataHub.makeRequest({
155
- method: 'POST',
156
- route: '/graphql',
157
- data,
107
+ createDeployment(source) {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ const result = yield this.dataHubSvc.makeRequest({
110
+ method: 'POST',
111
+ route: 'deployments/new',
112
+ data: {
113
+ deployment: Object.assign(Object.assign({}, source), { id: 'new' }),
114
+ },
115
+ params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
116
+ });
117
+ return setDiff(source, result);
158
118
  });
159
- return result.data[operationName];
160
119
  }
161
- async updateDeployment(source) {
162
- const variables = {
163
- entity: ENTITY_NAME,
164
- data: {
165
- id: source.id,
166
- body: source,
167
- },
168
- ...this.dataHub.isCrossAccount ? { accountId: this.dataHub.currentAccountId } : {},
169
- };
170
- const operationName = this.dataHub.getOperationName(OperationNames.UPDATE);
171
- const data = {
172
- operationName,
173
- query: this.dataHub.isCrossAccount ? QUERY_UPDATE_CROSSACCOUNT : QUERY_UPDATE,
174
- variables,
175
- };
176
- const result = await this.dataHub.makeRequest({
177
- method: 'POST',
178
- route: '/graphql',
179
- data,
120
+ updateDeployment(source) {
121
+ return __awaiter(this, void 0, void 0, function* () {
122
+ const result = yield this.dataHubSvc.makeRequest({
123
+ method: 'POST',
124
+ route: `deployments/${source.id}`,
125
+ data: {
126
+ deployment: source,
127
+ },
128
+ params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
129
+ });
130
+ return setDiff(source, result);
180
131
  });
181
- return result.data[operationName];
182
132
  }
183
133
  }
184
134
  //# sourceMappingURL=Deployments.js.map