@or-sdk/flows 0.27.3-beta.557.0 → 0.27.3-beta.579.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/README.md +1 -1
- package/dist/cjs/Flows.js +126 -101
- package/dist/cjs/Flows.js.map +1 -1
- package/dist/cjs/constants.js +5 -3
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/Flows.js +87 -73
- package/dist/esm/Flows.js.map +1 -1
- package/dist/esm/constants.js +9 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/types/Flows.d.ts +7 -8
- package/dist/types/Flows.d.ts.map +1 -1
- package/dist/types/constants.d.ts +3 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +10 -45
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/Flows.ts +115 -126
- package/src/constants.ts +11 -1
- package/src/index.ts +0 -2
- package/src/types.ts +11 -50
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
|
+
dataHubUrl: 'http://example.flows/endpoint',
|
|
14
14
|
deployerUrl: 'http://example.flows/endpoint'
|
|
15
15
|
});
|
|
16
16
|
|
package/dist/cjs/Flows.js
CHANGED
|
@@ -46,21 +46,31 @@ 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
|
+
};
|
|
49
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
59
|
exports.Flows = void 0;
|
|
51
60
|
var base_1 = require("@or-sdk/base");
|
|
52
|
-
var
|
|
61
|
+
var data_hub_1 = require("@or-sdk/data-hub");
|
|
53
62
|
var deployer_1 = require("@or-sdk/deployer");
|
|
63
|
+
var constants_1 = require("./constants");
|
|
54
64
|
var tags_1 = require("@or-sdk/tags");
|
|
55
65
|
var utils_1 = require("./utils");
|
|
56
66
|
var Flows = (function () {
|
|
57
67
|
function Flows(params) {
|
|
58
|
-
var discoveryUrl = params.discoveryUrl, token = params.token, accountId = params.accountId,
|
|
59
|
-
this.
|
|
68
|
+
var discoveryUrl = params.discoveryUrl, token = params.token, accountId = params.accountId, dataHubUrl = params.dataHubUrl, deployerUrl = params.deployerUrl;
|
|
69
|
+
this.dataHub = new data_hub_1.DataHub({
|
|
60
70
|
token: token,
|
|
61
71
|
discoveryUrl: discoveryUrl,
|
|
62
72
|
accountId: accountId,
|
|
63
|
-
|
|
73
|
+
dataHubUrl: dataHubUrl,
|
|
64
74
|
});
|
|
65
75
|
this.deployer = new deployer_1.Deployer({
|
|
66
76
|
token: token,
|
|
@@ -72,97 +82,147 @@ var Flows = (function () {
|
|
|
72
82
|
token: token,
|
|
73
83
|
discoveryUrl: discoveryUrl,
|
|
74
84
|
accountId: accountId,
|
|
75
|
-
|
|
85
|
+
dataHubUrl: dataHubUrl,
|
|
76
86
|
});
|
|
77
87
|
}
|
|
78
|
-
Flows.prototype.
|
|
79
|
-
if (params === void 0) { params = {}; }
|
|
80
|
-
if (paginationOptions === void 0) { paginationOptions = {}; }
|
|
88
|
+
Flows.prototype.init = function () {
|
|
81
89
|
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
-
var includeQuery, paramsToSend, result;
|
|
83
90
|
return __generator(this, function (_a) {
|
|
84
91
|
switch (_a.label) {
|
|
85
|
-
case 0:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
})];
|
|
92
|
+
case 0: return [4, Promise.all([
|
|
93
|
+
this.dataHub.init(),
|
|
94
|
+
this.deployer.init(),
|
|
95
|
+
this.tags.init(),
|
|
96
|
+
])];
|
|
101
97
|
case 1:
|
|
102
|
-
|
|
103
|
-
return [2
|
|
98
|
+
_a.sent();
|
|
99
|
+
return [2];
|
|
104
100
|
}
|
|
105
101
|
});
|
|
106
102
|
});
|
|
107
103
|
};
|
|
108
|
-
Flows.prototype.
|
|
109
|
-
if (params === void 0) { params = {}; }
|
|
104
|
+
Flows.prototype.listFlows = function (botId, params) {
|
|
110
105
|
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
+
var requestParams, route, result, flowList, query, projection;
|
|
111
107
|
return __generator(this, function (_a) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
switch (_a.label) {
|
|
109
|
+
case 0:
|
|
110
|
+
requestParams = __assign({ includeDeleted: false, includeExisting: true, projection: [
|
|
111
|
+
'id',
|
|
112
|
+
'version',
|
|
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
|
+
}
|
|
117
146
|
});
|
|
118
147
|
});
|
|
119
148
|
};
|
|
120
|
-
Flows.prototype.
|
|
149
|
+
Flows.prototype.getFlow = function (id) {
|
|
121
150
|
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
-
var
|
|
151
|
+
var route, params;
|
|
123
152
|
return __generator(this, function (_a) {
|
|
124
153
|
switch (_a.label) {
|
|
125
|
-
case 0:
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
154
|
+
case 0:
|
|
155
|
+
route = "/v2/".concat(this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current', "/flow/").concat(id);
|
|
156
|
+
params = {
|
|
157
|
+
includeDeleted: false,
|
|
158
|
+
includeExisting: true,
|
|
159
|
+
sandbox: false,
|
|
160
|
+
};
|
|
161
|
+
return [4, this.dataHub.makeRequest({
|
|
162
|
+
method: 'GET',
|
|
163
|
+
route: route,
|
|
164
|
+
params: params,
|
|
165
|
+
})];
|
|
166
|
+
case 1: return [2, _a.sent()];
|
|
137
167
|
}
|
|
138
168
|
});
|
|
139
169
|
});
|
|
140
170
|
};
|
|
141
|
-
Flows.prototype.
|
|
142
|
-
if (temporarily === void 0) { temporarily = true; }
|
|
171
|
+
Flows.prototype.saveFlow = function (source) {
|
|
143
172
|
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
-
var
|
|
173
|
+
var route, data;
|
|
145
174
|
return __generator(this, function (_a) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
175
|
+
switch (_a.label) {
|
|
176
|
+
case 0:
|
|
177
|
+
route = "/v2/".concat(this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current', "/flow/").concat(source.id ? source.id : 'new');
|
|
178
|
+
data = {
|
|
179
|
+
flow: source,
|
|
180
|
+
previousVersion: source.id ? source.version : undefined,
|
|
181
|
+
};
|
|
182
|
+
return [4, this.dataHub.makeRequest({
|
|
183
|
+
method: 'POST',
|
|
184
|
+
route: route,
|
|
185
|
+
data: data,
|
|
186
|
+
})];
|
|
187
|
+
case 1: return [2, _a.sent()];
|
|
188
|
+
}
|
|
155
189
|
});
|
|
156
190
|
});
|
|
157
191
|
};
|
|
158
|
-
Flows.prototype.
|
|
192
|
+
Flows.prototype.deleteFlow = function (source, flowAlias) {
|
|
193
|
+
if (flowAlias === void 0) { flowAlias = 'dev'; }
|
|
159
194
|
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
+
var variables, operationName, data, result;
|
|
160
196
|
return __generator(this, function (_a) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
197
|
+
switch (_a.label) {
|
|
198
|
+
case 0:
|
|
199
|
+
if (this.dataHub.isCrossAccount) {
|
|
200
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
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
|
+
}
|
|
166
226
|
});
|
|
167
227
|
});
|
|
168
228
|
};
|
|
@@ -182,25 +242,6 @@ var Flows = (function () {
|
|
|
182
242
|
});
|
|
183
243
|
});
|
|
184
244
|
};
|
|
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
|
-
};
|
|
204
245
|
Flows.prototype.addTags = function (source, tagNames) {
|
|
205
246
|
return __awaiter(this, void 0, void 0, function () {
|
|
206
247
|
var tags, tagIds, newIds;
|
|
@@ -237,22 +278,6 @@ var Flows = (function () {
|
|
|
237
278
|
});
|
|
238
279
|
});
|
|
239
280
|
};
|
|
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
|
-
};
|
|
256
281
|
Flows.listUnusedStepTemplates = function (source) {
|
|
257
282
|
return (0, utils_1.listUnusedStepTemplates)(source);
|
|
258
283
|
};
|
package/dist/cjs/Flows.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flows.js","sourceRoot":"","sources":["../../src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|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEPLOYER_SERVICE_KEY = exports.
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "
|
|
3
|
+
exports.ENTITY_NAME = exports.QUERY_DELETE = exports.DEPLOYER_SERVICE_KEY = 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
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';
|
|
8
10
|
//# 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;AAC7B,6CAAwD;AAA/C,gHAAA,oBAAoB,OAAA;AAEhB,QAAA,YAAY,GAAG,yLAM1B,CAAC;AAEU,QAAA,WAAW,GAAG,MAAM,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -18,5 +18,4 @@ 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);
|
|
22
21
|
//# 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"}
|
package/dist/esm/Flows.js
CHANGED
|
@@ -8,18 +8,19 @@ 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 { DataHub, OperationNames } from '@or-sdk/data-hub';
|
|
12
12
|
import { Deployer } from '@or-sdk/deployer';
|
|
13
|
+
import { QUERY_DELETE, ENTITY_NAME } from './constants';
|
|
13
14
|
import { Tags, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
|
|
14
15
|
import { listUnusedStepTemplates, deleteUnusedStepTemplates } from './utils';
|
|
15
16
|
export class Flows {
|
|
16
17
|
constructor(params) {
|
|
17
|
-
const { discoveryUrl, token, accountId,
|
|
18
|
-
this.
|
|
18
|
+
const { discoveryUrl, token, accountId, dataHubUrl, deployerUrl } = params;
|
|
19
|
+
this.dataHub = new DataHub({
|
|
19
20
|
token,
|
|
20
21
|
discoveryUrl,
|
|
21
22
|
accountId,
|
|
22
|
-
|
|
23
|
+
dataHubUrl,
|
|
23
24
|
});
|
|
24
25
|
this.deployer = new Deployer({
|
|
25
26
|
token,
|
|
@@ -31,72 +32,108 @@ export class Flows {
|
|
|
31
32
|
token,
|
|
32
33
|
discoveryUrl,
|
|
33
34
|
accountId,
|
|
34
|
-
|
|
35
|
+
dataHubUrl,
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
+
init() {
|
|
38
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
yield Promise.all([
|
|
41
|
+
this.dataHub.init(),
|
|
42
|
+
this.deployer.init(),
|
|
43
|
+
this.tags.init(),
|
|
44
|
+
]);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
listFlows(botId, params) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const requestParams = Object.assign({ includeDeleted: false, includeExisting: true, projection: [
|
|
50
|
+
'id',
|
|
51
|
+
'version',
|
|
52
|
+
'botId',
|
|
53
|
+
'data.label',
|
|
54
|
+
'data.color',
|
|
55
|
+
'data.description',
|
|
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);
|
|
55
80
|
});
|
|
56
81
|
}
|
|
57
|
-
getFlow(id
|
|
82
|
+
getFlow(id) {
|
|
58
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
|
|
84
|
+
const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/flow/${id}`;
|
|
85
|
+
const params = {
|
|
86
|
+
includeDeleted: false,
|
|
87
|
+
includeExisting: true,
|
|
88
|
+
sandbox: false,
|
|
89
|
+
};
|
|
90
|
+
return yield this.dataHub.makeRequest({
|
|
60
91
|
method: 'GET',
|
|
61
|
-
route
|
|
62
|
-
params
|
|
92
|
+
route,
|
|
93
|
+
params,
|
|
63
94
|
});
|
|
64
95
|
});
|
|
65
96
|
}
|
|
66
97
|
saveFlow(source) {
|
|
67
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
const
|
|
99
|
+
const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/flow/${source.id ? source.id : 'new'}`;
|
|
100
|
+
const data = {
|
|
101
|
+
flow: source,
|
|
102
|
+
previousVersion: source.id ? source.version : undefined,
|
|
103
|
+
};
|
|
104
|
+
return yield this.dataHub.makeRequest({
|
|
69
105
|
method: 'POST',
|
|
70
|
-
route
|
|
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 } : {}),
|
|
106
|
+
route,
|
|
107
|
+
data,
|
|
76
108
|
});
|
|
77
|
-
return setDiff(source, result);
|
|
78
109
|
});
|
|
79
110
|
}
|
|
80
|
-
deleteFlow(
|
|
111
|
+
deleteFlow(source, flowAlias = 'dev') {
|
|
81
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
113
|
+
if (this.dataHub.isCrossAccount) {
|
|
114
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
115
|
+
}
|
|
116
|
+
const variables = {
|
|
117
|
+
entity: ENTITY_NAME,
|
|
86
118
|
data: {
|
|
87
|
-
|
|
119
|
+
id: source.id,
|
|
120
|
+
flowAlias,
|
|
121
|
+
subscribe: true,
|
|
122
|
+
role: source.data.deploy.role,
|
|
88
123
|
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
124
|
+
};
|
|
125
|
+
const operationName = this.dataHub.getOperationName(OperationNames.DELETE_TEMPORARILY);
|
|
126
|
+
const data = {
|
|
127
|
+
operationName,
|
|
128
|
+
query: QUERY_DELETE,
|
|
129
|
+
variables,
|
|
130
|
+
};
|
|
131
|
+
const result = yield this.dataHub.makeRequest({
|
|
132
|
+
method: 'POST',
|
|
133
|
+
route: '/graphql',
|
|
134
|
+
data,
|
|
99
135
|
});
|
|
136
|
+
return this.dataHub.subscribe(result.data[operationName].requestId);
|
|
100
137
|
});
|
|
101
138
|
}
|
|
102
139
|
activateFlow(source, interactiveDebug = false) {
|
|
@@ -109,16 +146,6 @@ export class Flows {
|
|
|
109
146
|
return this.deployer.deactivateFlow(source, flowAlias, deleteLambda);
|
|
110
147
|
});
|
|
111
148
|
}
|
|
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
|
-
}
|
|
122
149
|
addTags(source, tagNames) {
|
|
123
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
151
|
const tags = yield this.tags.getMultipleTagsByName(tagNames, true);
|
|
@@ -141,19 +168,6 @@ export class Flows {
|
|
|
141
168
|
return this.saveFlow(Object.assign(Object.assign({}, source), { tags: removeTagIds(source.tags, existingIds) }));
|
|
142
169
|
});
|
|
143
170
|
}
|
|
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
|
-
}
|
|
157
171
|
static listUnusedStepTemplates(source) {
|
|
158
172
|
return listUnusedStepTemplates(source);
|
|
159
173
|
}
|
package/dist/esm/Flows.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flows.js","sourceRoot":"","sources":["../../src/Flows.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Flows.js","sourceRoot":"","sources":["../../src/Flows.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAyE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClI,OAAO,EAAE,QAAQ,EAAuF,MAA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CAAC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;YAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAG,CAAC,CAAC;YAExC,MAAM,EAAE,WAAW,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAE1D,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;gBACvB,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAC;aACnC;YAED,OAAO,IAAI,CAAC,QAAQ,iCACf,MAAM,KACT,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAC5C,CAAC;QACL,CAAC;KAAA;IAQM,MAAM,CAAC,uBAAuB,CAAC,MAAY;QAChD,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAUM,MAAM,CAAC,yBAAyB,CAAC,MAAY,EAAE,gBAAwC,EAAE;QAC9F,OAAO,yBAAyB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC1D,CAAC;CAEF"}
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DATA_HUB_SERVICE_KEY } from '@or-sdk/data-hub';
|
|
2
2
|
export { DEPLOYER_SERVICE_KEY } from '@or-sdk/deployer';
|
|
3
|
+
export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
|
|
4
|
+
deleteTemporarily(entity: $entity, data: $data) {
|
|
5
|
+
... on AsyncRequest {
|
|
6
|
+
requestId
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}`;
|
|
10
|
+
export const ENTITY_NAME = 'FLOW';
|
|
3
11
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;EAM1B,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC"}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,cAAc,SAAS,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,cAAc,SAAS,CAAC"}
|
package/dist/types/Flows.d.ts
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { List } from '@or-sdk/base';
|
|
2
|
+
import { GraphqlResponseCheckExecution } from '@or-sdk/data-hub';
|
|
2
3
|
import { Flow, PollingResultActivateSuccess, PollingResultDeactivateSuccess, StepTemplateRaw } from '@or-sdk/deployer';
|
|
3
|
-
import { FlowsConfig, ListFlowsParams, StepTemplateToDelete
|
|
4
|
+
import { FlowsConfig, ListFlowsParams, StepTemplateToDelete } from './types';
|
|
4
5
|
import { Taggable } from '@or-sdk/tags';
|
|
5
6
|
export declare class Flows implements Taggable<Flow> {
|
|
6
|
-
private readonly
|
|
7
|
+
private readonly dataHub;
|
|
7
8
|
private readonly deployer;
|
|
8
9
|
private readonly tags;
|
|
9
10
|
constructor(params: FlowsConfig);
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
listFlows(botId?: string, params?: ListFlowsParams): Promise<List<Flow>>;
|
|
13
|
+
getFlow(id: string): Promise<Flow>;
|
|
12
14
|
saveFlow(source: Flow): Promise<Flow>;
|
|
13
|
-
deleteFlow(
|
|
14
|
-
recoverFlow(flowId: string): Promise<void>;
|
|
15
|
+
deleteFlow(source: Flow, flowAlias?: string): Promise<GraphqlResponseCheckExecution>;
|
|
15
16
|
activateFlow(source: Flow, interactiveDebug?: boolean): Promise<PollingResultActivateSuccess>;
|
|
16
17
|
deactivateFlow(source: Flow, flowAlias: string, deleteLambda?: boolean): Promise<PollingResultDeactivateSuccess>;
|
|
17
|
-
listDataOuts(paginationOptions?: PaginationOptions, params?: ListDataOutsParams): Promise<List<DataOut>>;
|
|
18
18
|
addTags(source: Flow, tagNames: string[]): Promise<Flow>;
|
|
19
19
|
removeTags(source: Flow, tagNames: string[]): Promise<Flow>;
|
|
20
|
-
downloadTemplate(flowTemplateId: string, botId: string, shouldUpdateSteps?: boolean): Promise<DownloadTemplateResult>;
|
|
21
20
|
static listUnusedStepTemplates(source: Flow): StepTemplateRaw[];
|
|
22
21
|
static deleteUnusedStepTemplates(source: Flow, stepTemplates?: StepTemplateToDelete[]): Flow;
|
|
23
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flows.d.ts","sourceRoot":"","sources":["../../src/Flows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Flows.d.ts","sourceRoot":"","sources":["../../src/Flows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAW,6BAA6B,EAA0D,MAAM,kBAAkB,CAAC;AAClI,OAAO,EAAY,IAAI,EAAE,4BAA4B,EAAE,8BAA8B,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjI,OAAO,EAAE,WAAW,EAAoB,eAAe,EAAE,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1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DATA_HUB_SERVICE_KEY } from '@or-sdk/data-hub';
|
|
2
2
|
export { DEPLOYER_SERVICE_KEY } from '@or-sdk/deployer';
|
|
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}";
|
|
4
|
+
export declare const ENTITY_NAME = "FLOW";
|
|
3
5
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,eAAO,MAAM,YAAY,4LAMvB,CAAC;AAEH,eAAO,MAAM,WAAW,SAAS,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,cAAc,SAAS,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,cAAc,SAAS,CAAC"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,59 +1,24 @@
|
|
|
1
1
|
import { Token } from '@or-sdk/base';
|
|
2
|
+
import { Flow } from '@or-sdk/deployer';
|
|
2
3
|
export declare type FlowsConfig = {
|
|
3
4
|
token: Token;
|
|
4
5
|
discoveryUrl?: string;
|
|
5
6
|
accountId?: string;
|
|
6
|
-
|
|
7
|
+
dataHubUrl?: string;
|
|
7
8
|
deployerUrl?: string;
|
|
8
9
|
};
|
|
9
|
-
export declare type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
[key: string]: unknown;
|
|
14
|
-
};
|
|
15
|
-
projection?: string[];
|
|
16
|
-
group?: string[];
|
|
17
|
-
sandbox?: boolean;
|
|
18
|
-
};
|
|
19
|
-
export declare type ListDataOutsParams = {
|
|
20
|
-
query?: {
|
|
21
|
-
[key: string]: unknown;
|
|
22
|
-
};
|
|
23
|
-
projection?: string[];
|
|
24
|
-
group?: string[];
|
|
25
|
-
sandbox?: boolean;
|
|
26
|
-
};
|
|
27
|
-
export declare type PaginationOptions = {
|
|
28
|
-
limit?: number;
|
|
29
|
-
offset?: number;
|
|
30
|
-
};
|
|
31
|
-
export declare type GetFlowParams = {
|
|
32
|
-
query?: {
|
|
33
|
-
[key: string]: unknown;
|
|
34
|
-
};
|
|
35
|
-
projection?: string[];
|
|
36
|
-
sandbox?: boolean;
|
|
10
|
+
export declare type FlowListResponse = {
|
|
11
|
+
count: number;
|
|
12
|
+
items: Flow[];
|
|
13
|
+
last?: string;
|
|
37
14
|
};
|
|
38
|
-
export declare type
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
type: string;
|
|
43
|
-
ttl: number;
|
|
44
|
-
meta: string;
|
|
45
|
-
outputExample: string;
|
|
46
|
-
stepLabel: string;
|
|
47
|
-
stepId: string;
|
|
15
|
+
export declare type ListFlowsParams = {
|
|
16
|
+
includeDeleted: boolean;
|
|
17
|
+
includeExisting: boolean;
|
|
18
|
+
projection: string[];
|
|
48
19
|
};
|
|
49
20
|
export declare type StepTemplateToDelete = {
|
|
50
21
|
id: string;
|
|
51
22
|
[key: string]: unknown;
|
|
52
23
|
};
|
|
53
|
-
export declare type DownloadTemplateResult = {
|
|
54
|
-
id: string;
|
|
55
|
-
data: {
|
|
56
|
-
label: string;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
24
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,oBAAY,WAAW,GAAG;IAIxB,KAAK,EAAE,KAAK,CAAC;IAKb,YAAY,CAAC,EAAE,MAAM,CAAC;IAKtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,UAAU,CAAC,EAAE,MAAM,CAAC;IAKpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,oBAAY,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,oBAAY,eAAe,GAAG;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,oBAAY,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@or-sdk/flows",
|
|
3
|
-
"version": "0.27.3-beta.
|
|
3
|
+
"version": "0.27.3-beta.579.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"dev": "pnpm build:watch:esm"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@or-sdk/base": "^0.26.
|
|
21
|
-
"@or-sdk/data-hub
|
|
22
|
-
"@or-sdk/deployer": "^0.25.2-beta.
|
|
23
|
-
"@or-sdk/tags": "^0.25.3-beta.
|
|
20
|
+
"@or-sdk/base": "^0.26.4-beta.579.0",
|
|
21
|
+
"@or-sdk/data-hub": "^0.25.2-beta.579.0",
|
|
22
|
+
"@or-sdk/deployer": "^0.25.2-beta.579.0",
|
|
23
|
+
"@or-sdk/tags": "^0.25.3-beta.579.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"concurrently": "^6.4.0",
|
package/src/Flows.ts
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import { List, makeList } from '@or-sdk/base';
|
|
2
|
-
import {
|
|
2
|
+
import { DataHub, GraphqlResponseCheckExecution, GraphqlResponse, GraphqlResponseDelete, OperationNames } from '@or-sdk/data-hub';
|
|
3
3
|
import { Deployer, Flow, PollingResultActivateSuccess, PollingResultDeactivateSuccess, StepTemplateRaw } from '@or-sdk/deployer';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
ListFlowsParams,
|
|
7
|
-
StepTemplateToDelete,
|
|
8
|
-
PaginationOptions,
|
|
9
|
-
DownloadTemplateResult,
|
|
10
|
-
ListDataOutsParams, DataOut, GetFlowParams,
|
|
11
|
-
} from './types';
|
|
4
|
+
import { FlowsConfig, FlowListResponse, ListFlowsParams, StepTemplateToDelete } from './types';
|
|
5
|
+
import { QUERY_DELETE, ENTITY_NAME } from './constants';
|
|
12
6
|
import { Tags, Taggable, filterTagIds, addTagsIds, removeTagIds } from '@or-sdk/tags';
|
|
13
7
|
import { listUnusedStepTemplates, deleteUnusedStepTemplates } from './utils';
|
|
14
8
|
|
|
15
9
|
export class Flows implements Taggable<Flow> {
|
|
16
|
-
private readonly
|
|
10
|
+
private readonly dataHub: DataHub;
|
|
17
11
|
private readonly deployer: Deployer;
|
|
18
12
|
private readonly tags: Tags;
|
|
19
13
|
|
|
14
|
+
/**
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { Flows } from '@or-sdk/flows'
|
|
17
|
+
* const flows = new Flows({token: 'my-account-token-string', baseUrl: 'http://example.flows/endpoint'});
|
|
18
|
+
* await flows.init();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
20
21
|
constructor(params: FlowsConfig) {
|
|
21
|
-
const { discoveryUrl, token, accountId,
|
|
22
|
+
const { discoveryUrl, token, accountId, dataHubUrl, deployerUrl } = params;
|
|
22
23
|
|
|
23
|
-
this.
|
|
24
|
+
this.dataHub = new DataHub({
|
|
24
25
|
token,
|
|
25
26
|
discoveryUrl,
|
|
26
27
|
accountId,
|
|
27
|
-
|
|
28
|
+
dataHubUrl,
|
|
28
29
|
});
|
|
29
30
|
this.deployer = new Deployer({
|
|
30
31
|
token,
|
|
@@ -36,46 +37,72 @@ export class Flows implements Taggable<Flow> {
|
|
|
36
37
|
token,
|
|
37
38
|
discoveryUrl,
|
|
38
39
|
accountId,
|
|
39
|
-
|
|
40
|
+
dataHubUrl,
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
async init() {
|
|
45
|
+
await Promise.all([
|
|
46
|
+
this.dataHub.init(),
|
|
47
|
+
this.deployer.init(),
|
|
48
|
+
this.tags.init(),
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
|
|
43
52
|
/**
|
|
44
|
-
* List
|
|
53
|
+
* List identifiers
|
|
54
|
+
*
|
|
55
|
+
* If botId is passed - lists flows from the specified bot
|
|
45
56
|
* ```typescript
|
|
46
|
-
* const flowsList = await flows.listFlows();
|
|
57
|
+
* const flowsList = await flows.listFlows('bot-id');
|
|
47
58
|
* ```
|
|
48
59
|
*/
|
|
49
|
-
public async listFlows(botId?: string, params
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
public async listFlows(botId?: string, params?: ListFlowsParams): Promise<List<Flow>> {
|
|
61
|
+
const requestParams = {
|
|
62
|
+
// defaults
|
|
63
|
+
includeDeleted: false,
|
|
64
|
+
includeExisting: true,
|
|
65
|
+
projection: [
|
|
66
|
+
'id',
|
|
67
|
+
'version',
|
|
68
|
+
'botId',
|
|
69
|
+
'data.label',
|
|
70
|
+
'data.color',
|
|
71
|
+
'data.description',
|
|
72
|
+
'data.isHidden',
|
|
73
|
+
'tags',
|
|
74
|
+
'dateModified',
|
|
75
|
+
],
|
|
58
76
|
|
|
59
|
-
|
|
77
|
+
// overrides
|
|
60
78
|
...params,
|
|
61
|
-
query: {
|
|
62
|
-
...params.query,
|
|
63
|
-
...includeQuery,
|
|
64
|
-
},
|
|
65
|
-
...paginationOptions,
|
|
66
|
-
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
67
79
|
};
|
|
68
80
|
|
|
69
|
-
|
|
70
|
-
delete paramsToSend.includeExisting;
|
|
81
|
+
const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/flows`;
|
|
71
82
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
let result: FlowListResponse;
|
|
84
|
+
let flowList: Flow[] = [];
|
|
85
|
+
const query: { botId?: string; last?: string; } = { botId: botId ? botId : undefined };
|
|
86
|
+
const projection = JSON.stringify(requestParams.projection);
|
|
87
|
+
|
|
88
|
+
do {
|
|
89
|
+
result = await this.dataHub.makeRequest({
|
|
90
|
+
method: 'GET',
|
|
91
|
+
route,
|
|
92
|
+
params: {
|
|
93
|
+
includeDeleted: requestParams.includeDeleted,
|
|
94
|
+
includeExisting: requestParams.includeExisting,
|
|
95
|
+
projection,
|
|
96
|
+
query: JSON.stringify(query),
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
flowList = [...flowList, ...result.items];
|
|
101
|
+
query.last = result.last;
|
|
77
102
|
|
|
78
|
-
|
|
103
|
+
} while (result.last);
|
|
104
|
+
|
|
105
|
+
return makeList<Flow>(flowList);
|
|
79
106
|
}
|
|
80
107
|
|
|
81
108
|
/**
|
|
@@ -84,14 +111,19 @@ export class Flows implements Taggable<Flow> {
|
|
|
84
111
|
* const flow = await flows.getFlow('flow-id');
|
|
85
112
|
* ```
|
|
86
113
|
*/
|
|
87
|
-
public async getFlow(id: string
|
|
88
|
-
|
|
114
|
+
public async getFlow(id: string): Promise<Flow> {
|
|
115
|
+
const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/flow/${id}`;
|
|
116
|
+
|
|
117
|
+
const params = {
|
|
118
|
+
includeDeleted: false,
|
|
119
|
+
includeExisting: true,
|
|
120
|
+
sandbox: false,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
return await this.dataHub.makeRequest<Flow>({
|
|
89
124
|
method: 'GET',
|
|
90
|
-
route
|
|
91
|
-
params
|
|
92
|
-
...params,
|
|
93
|
-
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
94
|
-
},
|
|
125
|
+
route,
|
|
126
|
+
params,
|
|
95
127
|
});
|
|
96
128
|
}
|
|
97
129
|
|
|
@@ -104,59 +136,56 @@ export class Flows implements Taggable<Flow> {
|
|
|
104
136
|
* ```
|
|
105
137
|
*/
|
|
106
138
|
public async saveFlow(source: Flow): Promise<Flow> {
|
|
107
|
-
const
|
|
139
|
+
const route = `/v2/${this.dataHub.currentAccountId ? this.dataHub.currentAccountId : 'current'}/flow/${source.id ? source.id : 'new'}`;
|
|
140
|
+
|
|
141
|
+
const data = {
|
|
142
|
+
flow: source,
|
|
143
|
+
previousVersion: source.id ? source.version : undefined,
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
return await this.dataHub.makeRequest<Flow>({
|
|
108
147
|
method: 'POST',
|
|
109
|
-
route
|
|
110
|
-
data
|
|
111
|
-
flow: (source.id && source.id !== 'new') ? source : {
|
|
112
|
-
...source,
|
|
113
|
-
id: 'new', //TODO: remove later
|
|
114
|
-
},
|
|
115
|
-
previousVersion: (source.id && source.id !== 'new') ? source.version : undefined,
|
|
116
|
-
},
|
|
117
|
-
params: {
|
|
118
|
-
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
119
|
-
},
|
|
148
|
+
route,
|
|
149
|
+
data,
|
|
120
150
|
});
|
|
121
|
-
|
|
122
|
-
return setDiff<Flow>(source, result);
|
|
123
151
|
}
|
|
124
152
|
|
|
125
153
|
/**
|
|
126
154
|
* Delete flow
|
|
127
155
|
* ```typescript
|
|
128
|
-
* await flows.deleteFlow(
|
|
156
|
+
* const result = await flows.deleteFlow(flowSource, flowAlias);
|
|
129
157
|
* ```
|
|
130
158
|
*/
|
|
131
|
-
public async deleteFlow(
|
|
132
|
-
|
|
159
|
+
public async deleteFlow(source: Flow, flowAlias = 'dev'): Promise<GraphqlResponseCheckExecution> {
|
|
160
|
+
if (this.dataHub.isCrossAccount) {
|
|
161
|
+
throw Error('Cross-account deleting is not implemented.');
|
|
162
|
+
}
|
|
133
163
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
route: `flows/${flowId}`,
|
|
164
|
+
const variables = {
|
|
165
|
+
entity: ENTITY_NAME,
|
|
137
166
|
data: {
|
|
138
|
-
|
|
167
|
+
id: source.id,
|
|
168
|
+
flowAlias,
|
|
169
|
+
subscribe: true,
|
|
170
|
+
role: source.data.deploy.role,
|
|
139
171
|
},
|
|
140
|
-
|
|
141
|
-
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
}
|
|
172
|
+
};
|
|
145
173
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
},
|
|
174
|
+
const operationName = this.dataHub.getOperationName(OperationNames.DELETE_TEMPORARILY);
|
|
175
|
+
|
|
176
|
+
const data = {
|
|
177
|
+
operationName,
|
|
178
|
+
query: QUERY_DELETE,
|
|
179
|
+
variables,
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const result = await this.dataHub.makeRequest<GraphqlResponse<void>>({
|
|
183
|
+
method: 'POST',
|
|
184
|
+
route: '/graphql',
|
|
185
|
+
data,
|
|
159
186
|
});
|
|
187
|
+
|
|
188
|
+
return this.dataHub.subscribe((result.data[operationName] as GraphqlResponseDelete).requestId);
|
|
160
189
|
}
|
|
161
190
|
|
|
162
191
|
/**
|
|
@@ -179,26 +208,6 @@ export class Flows implements Taggable<Flow> {
|
|
|
179
208
|
return this.deployer.deactivateFlow(source, flowAlias, deleteLambda);
|
|
180
209
|
}
|
|
181
210
|
|
|
182
|
-
/**
|
|
183
|
-
* List data outs
|
|
184
|
-
* ```typescript
|
|
185
|
-
* const result = await flows.downloadTemplate('flow-template-id', 'bot-id');
|
|
186
|
-
* ```
|
|
187
|
-
*/
|
|
188
|
-
public async listDataOuts(paginationOptions: PaginationOptions = {}, params: ListDataOutsParams = {}): Promise<List<DataOut>> {
|
|
189
|
-
const result = await this.dataHubSvc.makeRequest<DataOut[]>({
|
|
190
|
-
method: 'GET',
|
|
191
|
-
route: '/flows/data-outs',
|
|
192
|
-
params: {
|
|
193
|
-
...params,
|
|
194
|
-
...paginationOptions,
|
|
195
|
-
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
196
|
-
},
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
return makeList<DataOut>(result);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
211
|
/**
|
|
203
212
|
* Add tags
|
|
204
213
|
* ```typescript
|
|
@@ -243,26 +252,6 @@ export class Flows implements Taggable<Flow> {
|
|
|
243
252
|
});
|
|
244
253
|
}
|
|
245
254
|
|
|
246
|
-
/**
|
|
247
|
-
* Download flow template to account
|
|
248
|
-
* ```typescript
|
|
249
|
-
* const result = await flows.downloadTemplate('flow-template-id', 'bot-id');
|
|
250
|
-
* ```
|
|
251
|
-
*/
|
|
252
|
-
public async downloadTemplate(flowTemplateId: string, botId: string, shouldUpdateSteps = false): Promise<DownloadTemplateResult> {
|
|
253
|
-
return this.dataHubSvc.makeRequest<DownloadTemplateResult>({
|
|
254
|
-
method: 'PUT',
|
|
255
|
-
route: `flows/${botId}`,
|
|
256
|
-
data: {
|
|
257
|
-
flowId: flowTemplateId,
|
|
258
|
-
shouldUpdateSteps,
|
|
259
|
-
},
|
|
260
|
-
params: {
|
|
261
|
-
... this.dataHubSvc.isCrossAccount ? { accountId: this.dataHubSvc.currentAccountId } : {},
|
|
262
|
-
},
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
|
|
266
255
|
/**
|
|
267
256
|
* List unused step templates from flow source
|
|
268
257
|
* ```typescript
|
package/src/constants.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DATA_HUB_SERVICE_KEY } from '@or-sdk/data-hub';
|
|
2
2
|
export { DEPLOYER_SERVICE_KEY } from '@or-sdk/deployer';
|
|
3
|
+
|
|
4
|
+
export const QUERY_DELETE = `mutation deleteTemporarily($entity: EntityType!, $data: DeleteInput!) {
|
|
5
|
+
deleteTemporarily(entity: $entity, data: $data) {
|
|
6
|
+
... on AsyncRequest {
|
|
7
|
+
requestId
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}`;
|
|
11
|
+
|
|
12
|
+
export const ENTITY_NAME = 'FLOW';
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Token } from '@or-sdk/base';
|
|
2
|
+
import { Flow } from '@or-sdk/deployer';
|
|
2
3
|
|
|
3
4
|
export type FlowsConfig = {
|
|
4
5
|
/**
|
|
@@ -17,9 +18,9 @@ export type FlowsConfig = {
|
|
|
17
18
|
accountId?: string;
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
|
-
* Url of OneReach
|
|
21
|
+
* Url of OneReach DataHub api
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
dataHubUrl?: string;
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Url of OneReach Deployer api
|
|
@@ -27,59 +28,19 @@ export type FlowsConfig = {
|
|
|
27
28
|
deployerUrl?: string;
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
export type
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
[key: string]: unknown;
|
|
35
|
-
};
|
|
36
|
-
projection?: string[];
|
|
37
|
-
group?: string[];
|
|
38
|
-
sandbox?: boolean;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export type ListDataOutsParams = {
|
|
42
|
-
query?: {
|
|
43
|
-
[key: string]: unknown;
|
|
44
|
-
};
|
|
45
|
-
projection?: string[];
|
|
46
|
-
group?: string[];
|
|
47
|
-
sandbox?: boolean;
|
|
31
|
+
export type FlowListResponse = {
|
|
32
|
+
count: number;
|
|
33
|
+
items: Flow[];
|
|
34
|
+
last?: string;
|
|
48
35
|
};
|
|
49
36
|
|
|
50
|
-
export type
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
export type GetFlowParams = {
|
|
56
|
-
query?: {
|
|
57
|
-
[key: string]: unknown;
|
|
58
|
-
};
|
|
59
|
-
projection?: string[];
|
|
60
|
-
sandbox?: boolean;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export type DataOut = {
|
|
64
|
-
flowId: string;
|
|
65
|
-
botId: string;
|
|
66
|
-
name: string;
|
|
67
|
-
type: string;
|
|
68
|
-
ttl: number;
|
|
69
|
-
meta: string;
|
|
70
|
-
outputExample: string;
|
|
71
|
-
stepLabel: string;
|
|
72
|
-
stepId: string;
|
|
37
|
+
export type ListFlowsParams = {
|
|
38
|
+
includeDeleted: boolean;
|
|
39
|
+
includeExisting: boolean;
|
|
40
|
+
projection: string[];
|
|
73
41
|
};
|
|
74
42
|
|
|
75
43
|
export type StepTemplateToDelete = {
|
|
76
44
|
id: string;
|
|
77
45
|
[key: string]: unknown;
|
|
78
46
|
};
|
|
79
|
-
|
|
80
|
-
export type DownloadTemplateResult = {
|
|
81
|
-
id: string;
|
|
82
|
-
data: {
|
|
83
|
-
label: string;
|
|
84
|
-
};
|
|
85
|
-
};
|