@or-sdk/flows 0.29.0 → 1.0.1-beta.700.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/dist/cjs/Flows.js +101 -126
- package/dist/cjs/Flows.js.map +1 -1
- package/dist/cjs/constants.js +3 -5
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/Flows.js +73 -87
- package/dist/esm/Flows.js.map +1 -1
- package/dist/esm/constants.js +1 -9
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/Flows.d.ts +8 -7
- package/dist/types/Flows.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -3
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +45 -10
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +5 -6
- package/src/Flows.ts +126 -115
- package/src/constants.ts +1 -11
- package/src/index.ts +2 -0
- package/src/types.ts +50 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.28.0](https://gitlab.com/onereach/platform/or-sdk-next/compare/@or-sdk/flows@0.27.7...@or-sdk/flows@0.28.0) (2022-10-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ⚠ BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* **data-hub-svc:** DataHub changed to DataHubSvc, now constructor needs `dataHubSvcUrl` instead of `dataHubUrl`
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **data-hub-svc:** DataHub changed to DataHubSvc, now constructor needs `dataHubSvcUrl` instead of `dataHubUrl` ([bf9c8ff](https://gitlab.com/onereach/platform/or-sdk-next/commit/bf9c8ff0c660e19f174ad04a135320c98152c4e7))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
6
19
|
### [0.27.7](https://gitlab.com/onereach/platform/or-sdk-next/compare/@or-sdk/flows@0.27.6...@or-sdk/flows@0.27.7) (2022-09-09)
|
|
7
20
|
|
|
8
21
|
**Note:** Version bump only for package @or-sdk/flows
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ import { Flows } from '@or-sdk/flows'
|
|
|
10
10
|
// with direct api url
|
|
11
11
|
const flows = new Flows({
|
|
12
12
|
token: 'my-account-token-string',
|
|
13
|
-
|
|
13
|
+
dataHubSvcUrl: 'http://example.data-hub-svc/endpoint',
|
|
14
14
|
deployerUrl: 'http://example.flows/endpoint'
|
|
15
15
|
});
|
|
16
16
|
|
package/dist/cjs/Flows.js
CHANGED
|
@@ -46,31 +46,21 @@ 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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
-
if (ar || !(i in from)) {
|
|
52
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
-
ar[i] = from[i];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
-
};
|
|
58
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
50
|
exports.Flows = void 0;
|
|
60
51
|
var base_1 = require("@or-sdk/base");
|
|
61
|
-
var
|
|
52
|
+
var data_hub_svc_1 = require("@or-sdk/data-hub-svc");
|
|
62
53
|
var deployer_1 = require("@or-sdk/deployer");
|
|
63
|
-
var constants_1 = require("./constants");
|
|
64
54
|
var tags_1 = require("@or-sdk/tags");
|
|
65
55
|
var utils_1 = require("./utils");
|
|
66
56
|
var Flows = (function () {
|
|
67
57
|
function Flows(params) {
|
|
68
|
-
var discoveryUrl = params.discoveryUrl, token = params.token, accountId = params.accountId,
|
|
69
|
-
this.
|
|
58
|
+
var discoveryUrl = params.discoveryUrl, token = params.token, accountId = params.accountId, dataHubSvcUrl = params.dataHubSvcUrl, deployerUrl = params.deployerUrl;
|
|
59
|
+
this.dataHubSvc = new data_hub_svc_1.DataHubSvc({
|
|
70
60
|
token: token,
|
|
71
61
|
discoveryUrl: discoveryUrl,
|
|
72
62
|
accountId: accountId,
|
|
73
|
-
|
|
63
|
+
dataHubSvcUrl: dataHubSvcUrl,
|
|
74
64
|
});
|
|
75
65
|
this.deployer = new deployer_1.Deployer({
|
|
76
66
|
token: token,
|
|
@@ -82,147 +72,97 @@ var Flows = (function () {
|
|
|
82
72
|
token: token,
|
|
83
73
|
discoveryUrl: discoveryUrl,
|
|
84
74
|
accountId: accountId,
|
|
85
|
-
|
|
75
|
+
dataHubSvcUrl: dataHubSvcUrl,
|
|
86
76
|
});
|
|
87
77
|
}
|
|
88
|
-
Flows.prototype.
|
|
78
|
+
Flows.prototype.listFlows = function (botId, params, paginationOptions) {
|
|
79
|
+
if (params === void 0) { params = {}; }
|
|
80
|
+
if (paginationOptions === void 0) { paginationOptions = {}; }
|
|
89
81
|
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
+
var includeQuery, paramsToSend, result;
|
|
90
83
|
return __generator(this, function (_a) {
|
|
91
84
|
switch (_a.label) {
|
|
92
|
-
case 0:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
85
|
+
case 0:
|
|
86
|
+
includeQuery = {};
|
|
87
|
+
if (params.includeDeleted === false || (params.includeDeleted === undefined && params.includeExisting !== false)) {
|
|
88
|
+
includeQuery = { isDeleted: false };
|
|
89
|
+
}
|
|
90
|
+
if (params.includeExisting === false) {
|
|
91
|
+
includeQuery = { isDeleted: true };
|
|
92
|
+
}
|
|
93
|
+
paramsToSend = __assign(__assign(__assign(__assign({}, params), { query: __assign(__assign({}, params.query), includeQuery) }), paginationOptions), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {});
|
|
94
|
+
delete paramsToSend.includeDeleted;
|
|
95
|
+
delete paramsToSend.includeExisting;
|
|
96
|
+
return [4, this.dataHubSvc.makeRequest({
|
|
97
|
+
method: 'GET',
|
|
98
|
+
route: 'flows',
|
|
99
|
+
params: paramsToSend,
|
|
100
|
+
})];
|
|
97
101
|
case 1:
|
|
98
|
-
_a.sent();
|
|
99
|
-
return [2];
|
|
102
|
+
result = _a.sent();
|
|
103
|
+
return [2, (0, base_1.makeList)(result)];
|
|
100
104
|
}
|
|
101
105
|
});
|
|
102
106
|
});
|
|
103
107
|
};
|
|
104
|
-
Flows.prototype.
|
|
108
|
+
Flows.prototype.getFlow = function (id, params) {
|
|
109
|
+
if (params === void 0) { params = {}; }
|
|
105
110
|
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
-
var requestParams, route, result, flowList, query, projection;
|
|
107
111
|
return __generator(this, function (_a) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
'botId',
|
|
114
|
-
'data.label',
|
|
115
|
-
'data.color',
|
|
116
|
-
'data.description',
|
|
117
|
-
'data.isHidden',
|
|
118
|
-
'tags',
|
|
119
|
-
'dateModified',
|
|
120
|
-
] }, params);
|
|
121
|
-
route = "/v2/".concat(this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current', "/flows");
|
|
122
|
-
flowList = [];
|
|
123
|
-
query = { botId: botId ? botId : undefined };
|
|
124
|
-
projection = JSON.stringify(requestParams.projection);
|
|
125
|
-
_a.label = 1;
|
|
126
|
-
case 1: return [4, this.dataHub.makeRequest({
|
|
127
|
-
method: 'GET',
|
|
128
|
-
route: route,
|
|
129
|
-
params: {
|
|
130
|
-
includeDeleted: requestParams.includeDeleted,
|
|
131
|
-
includeExisting: requestParams.includeExisting,
|
|
132
|
-
projection: projection,
|
|
133
|
-
query: JSON.stringify(query),
|
|
134
|
-
},
|
|
135
|
-
})];
|
|
136
|
-
case 2:
|
|
137
|
-
result = _a.sent();
|
|
138
|
-
flowList = __spreadArray(__spreadArray([], flowList, true), result.items, true);
|
|
139
|
-
query.last = result.last;
|
|
140
|
-
_a.label = 3;
|
|
141
|
-
case 3:
|
|
142
|
-
if (result.last) return [3, 1];
|
|
143
|
-
_a.label = 4;
|
|
144
|
-
case 4: return [2, (0, base_1.makeList)(flowList)];
|
|
145
|
-
}
|
|
112
|
+
return [2, this.dataHubSvc.makeRequest({
|
|
113
|
+
method: 'GET',
|
|
114
|
+
route: "flows/".concat(id),
|
|
115
|
+
params: __assign(__assign({}, params), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
116
|
+
})];
|
|
146
117
|
});
|
|
147
118
|
});
|
|
148
119
|
};
|
|
149
|
-
Flows.prototype.
|
|
120
|
+
Flows.prototype.saveFlow = function (source) {
|
|
150
121
|
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
-
var
|
|
122
|
+
var result;
|
|
152
123
|
return __generator(this, function (_a) {
|
|
153
124
|
switch (_a.label) {
|
|
154
|
-
case 0:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
case 1: return [2, _a.sent()];
|
|
125
|
+
case 0: return [4, this.dataHubSvc.makeRequest({
|
|
126
|
+
method: 'POST',
|
|
127
|
+
route: "flows/".concat((source.id && source.id !== 'new') ? source.id : 'new'),
|
|
128
|
+
data: {
|
|
129
|
+
flow: (source.id && source.id !== 'new') ? source : __assign(__assign({}, source), { id: 'new' }),
|
|
130
|
+
previousVersion: (source.id && source.id !== 'new') ? source.version : undefined,
|
|
131
|
+
},
|
|
132
|
+
params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
133
|
+
})];
|
|
134
|
+
case 1:
|
|
135
|
+
result = _a.sent();
|
|
136
|
+
return [2, (0, data_hub_svc_1.setDiff)(source, result)];
|
|
167
137
|
}
|
|
168
138
|
});
|
|
169
139
|
});
|
|
170
140
|
};
|
|
171
|
-
Flows.prototype.
|
|
141
|
+
Flows.prototype.deleteFlow = function (flowId, temporarily) {
|
|
142
|
+
if (temporarily === void 0) { temporarily = true; }
|
|
172
143
|
return __awaiter(this, void 0, void 0, function () {
|
|
173
|
-
var
|
|
144
|
+
var flowSourceId;
|
|
174
145
|
return __generator(this, function (_a) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
route: route,
|
|
185
|
-
data: data,
|
|
186
|
-
})];
|
|
187
|
-
case 1: return [2, _a.sent()];
|
|
188
|
-
}
|
|
146
|
+
flowSourceId = typeof flowId === 'string' ? flowId : flowId.id;
|
|
147
|
+
return [2, this.dataHubSvc.makeRequest({
|
|
148
|
+
method: 'DELETE',
|
|
149
|
+
route: "flows/".concat(flowId),
|
|
150
|
+
data: {
|
|
151
|
+
temporarily: temporarily,
|
|
152
|
+
},
|
|
153
|
+
params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
154
|
+
})];
|
|
189
155
|
});
|
|
190
156
|
});
|
|
191
157
|
};
|
|
192
|
-
Flows.prototype.
|
|
193
|
-
if (flowAlias === void 0) { flowAlias = 'dev'; }
|
|
158
|
+
Flows.prototype.recoverFlow = function (flowId) {
|
|
194
159
|
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
-
var variables, operationName, data, result;
|
|
196
160
|
return __generator(this, function (_a) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
variables = {
|
|
203
|
-
entity: constants_1.ENTITY_NAME,
|
|
204
|
-
data: {
|
|
205
|
-
id: source.id,
|
|
206
|
-
flowAlias: flowAlias,
|
|
207
|
-
subscribe: true,
|
|
208
|
-
role: source.data.deploy.role,
|
|
209
|
-
},
|
|
210
|
-
};
|
|
211
|
-
operationName = this.dataHub.getOperationName(data_hub_1.OperationNames.DELETE_TEMPORARILY);
|
|
212
|
-
data = {
|
|
213
|
-
operationName: operationName,
|
|
214
|
-
query: constants_1.QUERY_DELETE,
|
|
215
|
-
variables: variables,
|
|
216
|
-
};
|
|
217
|
-
return [4, this.dataHub.makeRequest({
|
|
218
|
-
method: 'POST',
|
|
219
|
-
route: '/graphql',
|
|
220
|
-
data: data,
|
|
221
|
-
})];
|
|
222
|
-
case 1:
|
|
223
|
-
result = _a.sent();
|
|
224
|
-
return [2, this.dataHub.subscribe(result.data[operationName].requestId)];
|
|
225
|
-
}
|
|
161
|
+
return [2, this.dataHubSvc.makeRequest({
|
|
162
|
+
method: 'PATCH',
|
|
163
|
+
route: "flows/".concat(flowId),
|
|
164
|
+
params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
165
|
+
})];
|
|
226
166
|
});
|
|
227
167
|
});
|
|
228
168
|
};
|
|
@@ -242,6 +182,25 @@ var Flows = (function () {
|
|
|
242
182
|
});
|
|
243
183
|
});
|
|
244
184
|
};
|
|
185
|
+
Flows.prototype.listDataOuts = function (paginationOptions, params) {
|
|
186
|
+
if (paginationOptions === void 0) { paginationOptions = {}; }
|
|
187
|
+
if (params === void 0) { params = {}; }
|
|
188
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
189
|
+
var result;
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
switch (_a.label) {
|
|
192
|
+
case 0: return [4, this.dataHubSvc.makeRequest({
|
|
193
|
+
method: 'GET',
|
|
194
|
+
route: '/flows/data-outs',
|
|
195
|
+
params: __assign(__assign(__assign({}, params), paginationOptions), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
196
|
+
})];
|
|
197
|
+
case 1:
|
|
198
|
+
result = _a.sent();
|
|
199
|
+
return [2, (0, base_1.makeList)(result)];
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
};
|
|
245
204
|
Flows.prototype.addTags = function (source, tagNames) {
|
|
246
205
|
return __awaiter(this, void 0, void 0, function () {
|
|
247
206
|
var tags, tagIds, newIds;
|
|
@@ -278,6 +237,22 @@ var Flows = (function () {
|
|
|
278
237
|
});
|
|
279
238
|
});
|
|
280
239
|
};
|
|
240
|
+
Flows.prototype.downloadTemplate = function (flowTemplateId, botId, shouldUpdateSteps) {
|
|
241
|
+
if (shouldUpdateSteps === void 0) { shouldUpdateSteps = false; }
|
|
242
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
243
|
+
return __generator(this, function (_a) {
|
|
244
|
+
return [2, this.dataHubSvc.makeRequest({
|
|
245
|
+
method: 'PUT',
|
|
246
|
+
route: "flows/".concat(botId),
|
|
247
|
+
data: {
|
|
248
|
+
flowId: flowTemplateId,
|
|
249
|
+
shouldUpdateSteps: shouldUpdateSteps,
|
|
250
|
+
},
|
|
251
|
+
params: __assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
252
|
+
})];
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
};
|
|
281
256
|
Flows.listUnusedStepTemplates = function (source) {
|
|
282
257
|
return (0, utils_1.listUnusedStepTemplates)(source);
|
|
283
258
|
};
|
package/dist/cjs/Flows.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flows.js","sourceRoot":"","sources":["../../src/Flows.ts"],"names":[],"mappings":"
|
|
1
|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AK,EAAE,gBAAS,KAAK,CAAE;wBACvB,IAAI,EAAE;4BACJ,MAAM,EAAE,cAAc;4BACtB,iBAAiB,mBAAA;yBAClB;wBACD,MAAM,eACA,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAC1F;qBACF,CAAC,EAAC;;;KACJ;IAQa,6BAAuB,GAArC,UAAsC,MAAY;QAChD,OAAO,IAAA,+BAAuB,EAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAUa,+BAAyB,GAAvC,UAAwC,MAAY,EAAE,aAA0C;QAA1C,8BAAA,EAAA,kBAA0C;QAC9F,OAAO,IAAA,iCAAyB,EAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC1D,CAAC;IAEH,YAAC;AAAD,CAAC,AAjRD,IAiRC;AAjRY,sBAAK"}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "
|
|
3
|
+
exports.DEPLOYER_SERVICE_KEY = 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; } });
|
|
6
6
|
var deployer_1 = require("@or-sdk/deployer");
|
|
7
7
|
Object.defineProperty(exports, "DEPLOYER_SERVICE_KEY", { enumerable: true, get: function () { return deployer_1.DEPLOYER_SERVICE_KEY; } });
|
|
8
|
-
exports.QUERY_DELETE = "mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {\n deleteTemporarily(entity: $entity, data: $data) {\n ... on AsyncRequest {\n requestId\n }\n }\n}";
|
|
9
|
-
exports.ENTITY_NAME = 'FLOW';
|
|
10
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,qDAAgE;AAAvD,wHAAA,wBAAwB,OAAA;AACjC,6CAAwD;AAA/C,gHAAA,oBAAoB,OAAA"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -18,4 +18,5 @@ exports.Flows = void 0;
|
|
|
18
18
|
var Flows_1 = require("./Flows");
|
|
19
19
|
Object.defineProperty(exports, "Flows", { enumerable: true, get: function () { return Flows_1.Flows; } });
|
|
20
20
|
__exportStar(require("./types"), exports);
|
|
21
|
+
__exportStar(require("./constants"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,0CAAwB;AACxB,8CAA4B"}
|
package/dist/esm/Flows.js
CHANGED
|
@@ -8,19 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { makeList } from '@or-sdk/base';
|
|
11
|
-
import {
|
|
11
|
+
import { DataHubSvc, setDiff } from '@or-sdk/data-hub-svc';
|
|
12
12
|
import { Deployer } from '@or-sdk/deployer';
|
|
13
|
-
import { QUERY_DELETE, ENTITY_NAME } from './constants';
|
|
14
13
|
import { Tags, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
|
|
15
14
|
import { listUnusedStepTemplates, deleteUnusedStepTemplates } from './utils';
|
|
16
15
|
export class Flows {
|
|
17
16
|
constructor(params) {
|
|
18
|
-
const { discoveryUrl, token, accountId,
|
|
19
|
-
this.
|
|
17
|
+
const { discoveryUrl, token, accountId, dataHubSvcUrl, deployerUrl } = params;
|
|
18
|
+
this.dataHubSvc = new DataHubSvc({
|
|
20
19
|
token,
|
|
21
20
|
discoveryUrl,
|
|
22
21
|
accountId,
|
|
23
|
-
|
|
22
|
+
dataHubSvcUrl,
|
|
24
23
|
});
|
|
25
24
|
this.deployer = new Deployer({
|
|
26
25
|
token,
|
|
@@ -32,108 +31,72 @@ export class Flows {
|
|
|
32
31
|
token,
|
|
33
32
|
discoveryUrl,
|
|
34
33
|
accountId,
|
|
35
|
-
|
|
34
|
+
dataHubSvcUrl,
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
|
-
|
|
37
|
+
listFlows(botId, params = {}, paginationOptions = {}) {
|
|
39
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
'data.isHidden',
|
|
57
|
-
'tags',
|
|
58
|
-
'dateModified',
|
|
59
|
-
] }, params);
|
|
60
|
-
const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/flows`;
|
|
61
|
-
let result;
|
|
62
|
-
let flowList = [];
|
|
63
|
-
const query = { botId: botId ? botId : undefined };
|
|
64
|
-
const projection = JSON.stringify(requestParams.projection);
|
|
65
|
-
do {
|
|
66
|
-
result = yield this.dataHub.makeRequest({
|
|
67
|
-
method: 'GET',
|
|
68
|
-
route,
|
|
69
|
-
params: {
|
|
70
|
-
includeDeleted: requestParams.includeDeleted,
|
|
71
|
-
includeExisting: requestParams.includeExisting,
|
|
72
|
-
projection,
|
|
73
|
-
query: JSON.stringify(query),
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
flowList = [...flowList, ...result.items];
|
|
77
|
-
query.last = result.last;
|
|
78
|
-
} while (result.last);
|
|
79
|
-
return makeList(flowList);
|
|
39
|
+
let includeQuery = {};
|
|
40
|
+
if (params.includeDeleted === false || (params.includeDeleted === undefined && params.includeExisting !== false)) {
|
|
41
|
+
includeQuery = { isDeleted: false };
|
|
42
|
+
}
|
|
43
|
+
if (params.includeExisting === false) {
|
|
44
|
+
includeQuery = { isDeleted: true };
|
|
45
|
+
}
|
|
46
|
+
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 } : {});
|
|
47
|
+
delete paramsToSend.includeDeleted;
|
|
48
|
+
delete paramsToSend.includeExisting;
|
|
49
|
+
const result = yield this.dataHubSvc.makeRequest({
|
|
50
|
+
method: 'GET',
|
|
51
|
+
route: 'flows',
|
|
52
|
+
params: paramsToSend,
|
|
53
|
+
});
|
|
54
|
+
return makeList(result);
|
|
80
55
|
});
|
|
81
56
|
}
|
|
82
|
-
getFlow(id) {
|
|
57
|
+
getFlow(id, params = {}) {
|
|
83
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
|
|
85
|
-
const params = {
|
|
86
|
-
includeDeleted: false,
|
|
87
|
-
includeExisting: true,
|
|
88
|
-
sandbox: false,
|
|
89
|
-
};
|
|
90
|
-
return yield this.dataHub.makeRequest({
|
|
59
|
+
return this.dataHubSvc.makeRequest({
|
|
91
60
|
method: 'GET',
|
|
92
|
-
route
|
|
93
|
-
params,
|
|
61
|
+
route: `flows/${id}`,
|
|
62
|
+
params: Object.assign(Object.assign({}, params), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
94
63
|
});
|
|
95
64
|
});
|
|
96
65
|
}
|
|
97
66
|
saveFlow(source) {
|
|
98
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
const
|
|
100
|
-
const data = {
|
|
101
|
-
flow: source,
|
|
102
|
-
previousVersion: source.id ? source.version : undefined,
|
|
103
|
-
};
|
|
104
|
-
return yield this.dataHub.makeRequest({
|
|
68
|
+
const result = yield this.dataHubSvc.makeRequest({
|
|
105
69
|
method: 'POST',
|
|
106
|
-
route
|
|
107
|
-
data
|
|
70
|
+
route: `flows/${(source.id && source.id !== 'new') ? source.id : 'new'}`,
|
|
71
|
+
data: {
|
|
72
|
+
flow: (source.id && source.id !== 'new') ? source : Object.assign(Object.assign({}, source), { id: 'new' }),
|
|
73
|
+
previousVersion: (source.id && source.id !== 'new') ? source.version : undefined,
|
|
74
|
+
},
|
|
75
|
+
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
108
76
|
});
|
|
77
|
+
return setDiff(source, result);
|
|
109
78
|
});
|
|
110
79
|
}
|
|
111
|
-
deleteFlow(
|
|
80
|
+
deleteFlow(flowId, temporarily = true) {
|
|
112
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
entity: ENTITY_NAME,
|
|
82
|
+
const flowSourceId = typeof flowId === 'string' ? flowId : flowId.id;
|
|
83
|
+
return this.dataHubSvc.makeRequest({
|
|
84
|
+
method: 'DELETE',
|
|
85
|
+
route: `flows/${flowId}`,
|
|
118
86
|
data: {
|
|
119
|
-
|
|
120
|
-
flowAlias,
|
|
121
|
-
subscribe: true,
|
|
122
|
-
role: source.data.deploy.role,
|
|
87
|
+
temporarily,
|
|
123
88
|
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
data,
|
|
89
|
+
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
recoverFlow(flowId) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
return this.dataHubSvc.makeRequest({
|
|
96
|
+
method: 'PATCH',
|
|
97
|
+
route: `flows/${flowId}`,
|
|
98
|
+
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
135
99
|
});
|
|
136
|
-
return this.dataHub.subscribe(result.data[operationName].requestId);
|
|
137
100
|
});
|
|
138
101
|
}
|
|
139
102
|
activateFlow(source, interactiveDebug = false) {
|
|
@@ -146,6 +109,16 @@ export class Flows {
|
|
|
146
109
|
return this.deployer.deactivateFlow(source, flowAlias, deleteLambda);
|
|
147
110
|
});
|
|
148
111
|
}
|
|
112
|
+
listDataOuts(paginationOptions = {}, params = {}) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
const result = yield this.dataHubSvc.makeRequest({
|
|
115
|
+
method: 'GET',
|
|
116
|
+
route: '/flows/data-outs',
|
|
117
|
+
params: Object.assign(Object.assign(Object.assign({}, params), paginationOptions), this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
118
|
+
});
|
|
119
|
+
return makeList(result);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
149
122
|
addTags(source, tagNames) {
|
|
150
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
124
|
const tags = yield this.tags.getMultipleTagsByName(tagNames, true);
|
|
@@ -168,6 +141,19 @@ export class Flows {
|
|
|
168
141
|
return this.saveFlow(Object.assign(Object.assign({}, source), { tags: removeTagIds(source.tags, existingIds) }));
|
|
169
142
|
});
|
|
170
143
|
}
|
|
144
|
+
downloadTemplate(flowTemplateId, botId, shouldUpdateSteps = false) {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
return this.dataHubSvc.makeRequest({
|
|
147
|
+
method: 'PUT',
|
|
148
|
+
route: `flows/${botId}`,
|
|
149
|
+
data: {
|
|
150
|
+
flowId: flowTemplateId,
|
|
151
|
+
shouldUpdateSteps,
|
|
152
|
+
},
|
|
153
|
+
params: Object.assign({}, this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {}),
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
171
157
|
static listUnusedStepTemplates(source) {
|
|
172
158
|
return listUnusedStepTemplates(source);
|
|
173
159
|
}
|