@or-sdk/flows 0.27.0-beta.427.0 → 0.27.1-beta.531.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 +67 -0
- package/dist/cjs/Flows.js +158 -361
- package/dist/cjs/Flows.js.map +1 -1
- package/dist/cjs/constants.js +7 -2
- package/dist/cjs/constants.js.map +1 -1
- package/dist/esm/Flows.js +123 -276
- package/dist/esm/Flows.js.map +1 -1
- package/dist/esm/constants.js +10 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/types/Flows.d.ts +16 -91
- package/dist/types/Flows.d.ts.map +1 -0
- package/dist/types/constants.d.ts +5 -1
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +5 -22
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils/deleteUnusedStepTemplates.d.ts +1 -0
- package/dist/types/utils/deleteUnusedStepTemplates.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/listUnusedStepTemplates.d.ts +1 -0
- package/dist/types/utils/listUnusedStepTemplates.d.ts.map +1 -0
- package/package.json +12 -14
- package/src/Flows.ts +147 -432
- package/src/constants.ts +11 -1
- package/src/types.ts +6 -26
- package/tsconfig.dev.json +2 -2
- package/tsconfig.esm.json +6 -3
- package/tsconfig.types.json +2 -1
package/dist/cjs/Flows.js
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __assign = (this && this.__assign) || function () {
|
|
18
3
|
__assign = Object.assign || function(t) {
|
|
19
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -61,422 +46,234 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
61
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
47
|
}
|
|
63
48
|
};
|
|
64
|
-
var
|
|
65
|
-
|
|
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));
|
|
66
57
|
};
|
|
67
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
68
59
|
exports.Flows = void 0;
|
|
69
60
|
var base_1 = require("@or-sdk/base");
|
|
70
|
-
var
|
|
71
|
-
var
|
|
61
|
+
var data_hub_1 = require("@or-sdk/data-hub");
|
|
62
|
+
var deployer_1 = require("@or-sdk/deployer");
|
|
72
63
|
var constants_1 = require("./constants");
|
|
64
|
+
var tags_1 = require("@or-sdk/tags");
|
|
73
65
|
var utils_1 = require("./utils");
|
|
74
|
-
var Flows = (function (
|
|
75
|
-
__extends(Flows, _super);
|
|
66
|
+
var Flows = (function () {
|
|
76
67
|
function Flows(params) {
|
|
77
|
-
var
|
|
78
|
-
|
|
79
|
-
_this = _super.call(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({
|
|
80
70
|
token: token,
|
|
81
71
|
discoveryUrl: discoveryUrl,
|
|
82
|
-
serviceKey: constants_1.SERVICE_KEY,
|
|
83
72
|
accountId: accountId,
|
|
84
|
-
|
|
85
|
-
}) || this;
|
|
86
|
-
_this.deployerUrl = deployerUrl;
|
|
87
|
-
_this.sdkApiUrl = sdkApiUrl;
|
|
88
|
-
return _this;
|
|
89
|
-
}
|
|
90
|
-
Flows.prototype.init = function () {
|
|
91
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
-
return __generator(this, function (_a) {
|
|
93
|
-
return [2];
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
Flows.prototype.deleteFlow = function (flow, flowAlias, temporarily) {
|
|
98
|
-
if (flowAlias === void 0) { flowAlias = 'dev'; }
|
|
99
|
-
if (temporarily === void 0) { temporarily = true; }
|
|
100
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
-
return __generator(this, function (_a) {
|
|
102
|
-
return [2, this.callApiV2({
|
|
103
|
-
route: "/flows/".concat(flow.id),
|
|
104
|
-
data: {
|
|
105
|
-
flowAlias: flowAlias,
|
|
106
|
-
temporarily: temporarily,
|
|
107
|
-
},
|
|
108
|
-
method: 'delete',
|
|
109
|
-
})];
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
Flows.prototype.recoverFlow = function (flow) {
|
|
114
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
-
return __generator(this, function (_a) {
|
|
116
|
-
return [2, this.callApiV2({
|
|
117
|
-
route: "/flows/".concat(flow.id),
|
|
118
|
-
method: 'patch',
|
|
119
|
-
})];
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
Flows.prototype.getFlowById = function (id, projection, sandbox) {
|
|
124
|
-
if (sandbox === void 0) { sandbox = false; }
|
|
125
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
-
return __generator(this, function (_a) {
|
|
127
|
-
return [2, this.callApiV2({
|
|
128
|
-
route: "/flows/".concat(id),
|
|
129
|
-
params: {
|
|
130
|
-
projection: projection,
|
|
131
|
-
sandbox: sandbox,
|
|
132
|
-
},
|
|
133
|
-
})];
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
Flows.prototype.getFlows = function (_a) {
|
|
138
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.query, query = _c === void 0 ? {} : _c, projection = _b.projection, _d = _b.includeDeleted, includeDeleted = _d === void 0 ? false : _d, _e = _b.includeExisting, includeExisting = _e === void 0 ? true : _e, _f = _b.sandbox, sandbox = _f === void 0 ? false : _f, limit = _b.limit, offset = _b.offset;
|
|
139
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
140
|
-
return __generator(this, function (_g) {
|
|
141
|
-
if (typeof query.id === 'string')
|
|
142
|
-
query.id = query.id.split('.');
|
|
143
|
-
if (includeDeleted && !includeExisting)
|
|
144
|
-
query.isDeleted = true;
|
|
145
|
-
if (!includeDeleted && includeExisting)
|
|
146
|
-
query.isDeleted = false;
|
|
147
|
-
return [2, this.callApiV2({
|
|
148
|
-
route: '/flows',
|
|
149
|
-
params: {
|
|
150
|
-
projection: projection,
|
|
151
|
-
query: query,
|
|
152
|
-
sandbox: sandbox,
|
|
153
|
-
limit: limit,
|
|
154
|
-
offset: offset,
|
|
155
|
-
},
|
|
156
|
-
})];
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
Flows.prototype.getFlowEvents = function (_a) {
|
|
161
|
-
var flowId = _a.flowId, _b = _a.alias, alias = _b === void 0 ? 'prod' : _b;
|
|
162
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
163
|
-
return __generator(this, function (_c) {
|
|
164
|
-
return [2, this.callApiV2({
|
|
165
|
-
url: this.sdkApiUrl,
|
|
166
|
-
route: "".concat(this.sdkApiUrl, "/event-manager/get-flow-events/").concat(flowId, "/").concat(alias),
|
|
167
|
-
})];
|
|
168
|
-
});
|
|
73
|
+
dataHubUrl: dataHubUrl,
|
|
169
74
|
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return [2, this.callApiV2({
|
|
176
|
-
url: this.sdkApiUrl,
|
|
177
|
-
route: "".concat(this.sdkApiUrl, "event-manager/get-trigger-flows"),
|
|
178
|
-
data: { triggers: triggers },
|
|
179
|
-
method: 'post',
|
|
180
|
-
})];
|
|
181
|
-
});
|
|
75
|
+
this.deployer = new deployer_1.Deployer({
|
|
76
|
+
token: token,
|
|
77
|
+
discoveryUrl: discoveryUrl,
|
|
78
|
+
accountId: accountId,
|
|
79
|
+
deployerUrl: deployerUrl,
|
|
182
80
|
});
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
route: '/flows/versions',
|
|
189
|
-
params: { query: query },
|
|
190
|
-
})];
|
|
191
|
-
});
|
|
81
|
+
this.tags = new tags_1.Tags({
|
|
82
|
+
token: token,
|
|
83
|
+
discoveryUrl: discoveryUrl,
|
|
84
|
+
accountId: accountId,
|
|
85
|
+
dataHubUrl: dataHubUrl,
|
|
192
86
|
});
|
|
193
|
-
}
|
|
194
|
-
Flows.prototype.
|
|
87
|
+
}
|
|
88
|
+
Flows.prototype.init = function () {
|
|
195
89
|
return __awaiter(this, void 0, void 0, function () {
|
|
196
|
-
var data;
|
|
197
90
|
return __generator(this, function (_a) {
|
|
198
91
|
switch (_a.label) {
|
|
199
|
-
case 0: return [4,
|
|
92
|
+
case 0: return [4, Promise.all([
|
|
93
|
+
this.dataHub.init(),
|
|
94
|
+
this.deployer.init(),
|
|
95
|
+
this.tags.init(),
|
|
96
|
+
])];
|
|
200
97
|
case 1:
|
|
201
|
-
|
|
202
|
-
return [2
|
|
98
|
+
_a.sent();
|
|
99
|
+
return [2];
|
|
203
100
|
}
|
|
204
101
|
});
|
|
205
102
|
});
|
|
206
103
|
};
|
|
207
|
-
Flows.prototype.
|
|
104
|
+
Flows.prototype.listFlows = function (botId, params) {
|
|
208
105
|
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
+
var requestParams, route, result, flowList, query, projection;
|
|
209
107
|
return __generator(this, function (_a) {
|
|
210
|
-
|
|
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
|
+
}
|
|
211
146
|
});
|
|
212
147
|
});
|
|
213
148
|
};
|
|
214
|
-
Flows.prototype.
|
|
149
|
+
Flows.prototype.getFlow = function (id) {
|
|
215
150
|
return __awaiter(this, void 0, void 0, function () {
|
|
216
|
-
var
|
|
151
|
+
var route, params;
|
|
217
152
|
return __generator(this, function (_a) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if (filter) {
|
|
233
|
-
queryParams.filter = filter;
|
|
234
|
-
}
|
|
235
|
-
if (relativeTime) {
|
|
236
|
-
queryParams.relativeTime = relativeTime;
|
|
153
|
+
switch (_a.label) {
|
|
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()];
|
|
237
167
|
}
|
|
238
|
-
return [2, this.callApiV2({
|
|
239
|
-
url: this.deployerUrl,
|
|
240
|
-
route: "/flows/".concat(flowId, "/logs"),
|
|
241
|
-
params: queryParams,
|
|
242
|
-
})];
|
|
243
168
|
});
|
|
244
169
|
});
|
|
245
170
|
};
|
|
246
|
-
Flows.prototype.saveFlow = function (
|
|
247
|
-
var _b = _a === void 0 ? {} : _a, previousVersion = _b.previousVersion;
|
|
171
|
+
Flows.prototype.saveFlow = function (source) {
|
|
248
172
|
return __awaiter(this, void 0, void 0, function () {
|
|
249
|
-
var
|
|
250
|
-
return __generator(this, function (
|
|
251
|
-
switch (
|
|
173
|
+
var route, data;
|
|
174
|
+
return __generator(this, function (_a) {
|
|
175
|
+
switch (_a.label) {
|
|
252
176
|
case 0:
|
|
253
|
-
flow.id
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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,
|
|
261
186
|
})];
|
|
262
|
-
case 1:
|
|
263
|
-
_c = _d.sent(), id = _c.id, version = _c.version;
|
|
264
|
-
return [2, __assign(__assign({}, flow), { id: id, version: version })];
|
|
187
|
+
case 1: return [2, _a.sent()];
|
|
265
188
|
}
|
|
266
189
|
});
|
|
267
190
|
});
|
|
268
191
|
};
|
|
269
|
-
Flows.prototype.
|
|
270
|
-
|
|
271
|
-
query: { botId: botId },
|
|
272
|
-
projection: projection,
|
|
273
|
-
});
|
|
274
|
-
};
|
|
275
|
-
Flows.prototype.getRemoteDataOutsByBotId = function (id) {
|
|
192
|
+
Flows.prototype.deleteFlow = function (source, flowAlias) {
|
|
193
|
+
if (flowAlias === void 0) { flowAlias = 'dev'; }
|
|
276
194
|
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
-
var
|
|
195
|
+
var variables, operationName, data, result;
|
|
278
196
|
return __generator(this, function (_a) {
|
|
279
197
|
switch (_a.label) {
|
|
280
|
-
case 0:
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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,
|
|
284
209
|
},
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
},
|
|
297
|
-
name: { ne: null },
|
|
298
|
-
botId: id,
|
|
299
|
-
flowId: flows.map(function (flow) { return flow.id; }),
|
|
300
|
-
},
|
|
301
|
-
},
|
|
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,
|
|
302
221
|
})];
|
|
303
|
-
case
|
|
304
|
-
|
|
305
|
-
return [2,
|
|
306
|
-
var flowLabel = lodash_1.default.get(flow, 'data.label', 'No name flow');
|
|
307
|
-
acc[flow.id] = lodash_1.default.map(dataOuts, function (dataOut) { return (__assign(__assign({}, dataOut), { flowLabel: flowLabel })); });
|
|
308
|
-
return acc;
|
|
309
|
-
}, {})];
|
|
222
|
+
case 1:
|
|
223
|
+
result = _a.sent();
|
|
224
|
+
return [2, this.dataHub.subscribe(result.data[operationName].requestId)];
|
|
310
225
|
}
|
|
311
226
|
});
|
|
312
227
|
});
|
|
313
228
|
};
|
|
314
|
-
Flows.
|
|
315
|
-
|
|
316
|
-
id: stepId || (0, uuid_1.v4)(),
|
|
317
|
-
icon: 'add',
|
|
318
|
-
iconType: 'default',
|
|
319
|
-
iconUrl: '',
|
|
320
|
-
shape: 'empty',
|
|
321
|
-
type: 'empty',
|
|
322
|
-
pinLabel: true,
|
|
323
|
-
stepInputData: {},
|
|
324
|
-
};
|
|
325
|
-
};
|
|
326
|
-
Flows.getEmptyFlow = function (botId) {
|
|
327
|
-
var defaultLambdaMemorySize = 1024;
|
|
328
|
-
var defaultLambdaTimeout = 30;
|
|
329
|
-
return {
|
|
330
|
-
botId: botId,
|
|
331
|
-
data: {
|
|
332
|
-
label: '',
|
|
333
|
-
description: '',
|
|
334
|
-
deploy: {
|
|
335
|
-
memory: defaultLambdaMemorySize,
|
|
336
|
-
timeout: defaultLambdaTimeout,
|
|
337
|
-
role: 'USER',
|
|
338
|
-
},
|
|
339
|
-
meta: {},
|
|
340
|
-
color: null,
|
|
341
|
-
categories: null,
|
|
342
|
-
annotations: null,
|
|
343
|
-
stepTemplates: [],
|
|
344
|
-
trees: {
|
|
345
|
-
main: {
|
|
346
|
-
position: {
|
|
347
|
-
x: 0,
|
|
348
|
-
y: 0,
|
|
349
|
-
},
|
|
350
|
-
steps: [this.getEmptyStep()],
|
|
351
|
-
},
|
|
352
|
-
},
|
|
353
|
-
},
|
|
354
|
-
};
|
|
355
|
-
};
|
|
356
|
-
Flows.getNewFlow = function (botId, flowTemplate) {
|
|
229
|
+
Flows.prototype.activateFlow = function (source, interactiveDebug) {
|
|
230
|
+
if (interactiveDebug === void 0) { interactiveDebug = false; }
|
|
357
231
|
return __awaiter(this, void 0, void 0, function () {
|
|
358
|
-
var flow, template;
|
|
359
232
|
return __generator(this, function (_a) {
|
|
360
|
-
|
|
361
|
-
template = lodash_1.default.omit(flowTemplate, ['id', 'botId', 'dateCreated', 'dateModified', 'version']);
|
|
362
|
-
flow.data.steps = lodash_1.default.get(template, 'data.steps.length') > 0 ? [] : flow.data.steps;
|
|
363
|
-
return [2, lodash_1.default.merge(flow, template)];
|
|
233
|
+
return [2, this.deployer.activateFlow(source, interactiveDebug)];
|
|
364
234
|
});
|
|
365
235
|
});
|
|
366
236
|
};
|
|
367
|
-
Flows.prototype.
|
|
368
|
-
if (
|
|
369
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
370
|
-
return __generator(this, function (_a) {
|
|
371
|
-
return [2, this.getFlows(__assign(__assign({}, params), { query: { botId: botId } }))];
|
|
372
|
-
});
|
|
373
|
-
});
|
|
374
|
-
};
|
|
375
|
-
Flows.prototype.getFlow = function (id) {
|
|
237
|
+
Flows.prototype.deactivateFlow = function (source, flowAlias, deleteLambda) {
|
|
238
|
+
if (deleteLambda === void 0) { deleteLambda = false; }
|
|
376
239
|
return __awaiter(this, void 0, void 0, function () {
|
|
377
240
|
return __generator(this, function (_a) {
|
|
378
|
-
return [2, this.
|
|
241
|
+
return [2, this.deployer.deactivateFlow(source, flowAlias, deleteLambda)];
|
|
379
242
|
});
|
|
380
243
|
});
|
|
381
244
|
};
|
|
382
|
-
|
|
383
|
-
get: function () {
|
|
384
|
-
return this.targetAccountId ? "".concat(this.deployerUrl, "/accounts/").concat(this.targetAccountId, "/flows/deploy") : "".concat(this.deployerUrl, "/flows/deploy");
|
|
385
|
-
},
|
|
386
|
-
enumerable: false,
|
|
387
|
-
configurable: true
|
|
388
|
-
});
|
|
389
|
-
Object.defineProperty(Flows.prototype, "checkUrl", {
|
|
390
|
-
get: function () {
|
|
391
|
-
return this.targetAccountId ? "".concat(this.deployerUrl, "/accounts/").concat(this.targetAccountId, "/flows/check") : "".concat(this.deployerUrl, "/flows/check");
|
|
392
|
-
},
|
|
393
|
-
enumerable: false,
|
|
394
|
-
configurable: true
|
|
395
|
-
});
|
|
396
|
-
Flows.prototype._pollResult = function (flowId, requestId, headers, progresCallback) {
|
|
245
|
+
Flows.prototype.addTags = function (source, tagNames) {
|
|
397
246
|
return __awaiter(this, void 0, void 0, function () {
|
|
398
|
-
var
|
|
247
|
+
var tags, tagIds, newIds;
|
|
399
248
|
return __generator(this, function (_a) {
|
|
400
249
|
switch (_a.label) {
|
|
401
|
-
case 0:
|
|
402
|
-
counter = 0;
|
|
403
|
-
_a.label = 1;
|
|
250
|
+
case 0: return [4, this.tags.getMultipleTagsByName(tagNames, true)];
|
|
404
251
|
case 1:
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
url: "".concat(this.checkUrl),
|
|
411
|
-
route: "/".concat(flowId, "/").concat(requestId),
|
|
412
|
-
})];
|
|
413
|
-
case 3:
|
|
414
|
-
result = _a.sent();
|
|
415
|
-
if (lodash_1.default.isFunction(progresCallback)) {
|
|
416
|
-
progresCallback(result);
|
|
252
|
+
tags = _a.sent();
|
|
253
|
+
tagIds = tags.map(function (tag) { return tag.id; });
|
|
254
|
+
newIds = (0, tags_1.filterTagIds)(source.tags, tagIds).newIds;
|
|
255
|
+
if (!newIds.length) {
|
|
256
|
+
throw Error('No tags to add.');
|
|
417
257
|
}
|
|
418
|
-
|
|
419
|
-
if (result.errorData) {
|
|
420
|
-
throw result;
|
|
421
|
-
}
|
|
422
|
-
return [2, result];
|
|
423
|
-
}
|
|
424
|
-
_a.label = 4;
|
|
425
|
-
case 4:
|
|
426
|
-
if (counter < 100) return [3, 1];
|
|
427
|
-
_a.label = 5;
|
|
428
|
-
case 5: throw new Error('Activation duration is too long');
|
|
429
|
-
}
|
|
430
|
-
});
|
|
431
|
-
});
|
|
432
|
-
};
|
|
433
|
-
Flows.prototype.activateFlow = function (flow, progresCallback) {
|
|
434
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
435
|
-
var flowAlias, requestId;
|
|
436
|
-
return __generator(this, function (_a) {
|
|
437
|
-
switch (_a.label) {
|
|
438
|
-
case 0:
|
|
439
|
-
flowAlias = "v-".concat(Date.now());
|
|
440
|
-
return [4, this.callApiV2({
|
|
441
|
-
url: this.deployUrl,
|
|
442
|
-
route: '',
|
|
443
|
-
method: 'post',
|
|
444
|
-
data: {
|
|
445
|
-
flowId: flow.id,
|
|
446
|
-
flowAlias: flowAlias,
|
|
447
|
-
interactiveDebug: flow.interactiveDebug,
|
|
448
|
-
role: lodash_1.default.get(flow, 'data.deploy.role'),
|
|
449
|
-
},
|
|
450
|
-
})];
|
|
451
|
-
case 1:
|
|
452
|
-
requestId = (_a.sent()).requestId;
|
|
453
|
-
return [2, this._pollResult(flow.id, requestId, null, progresCallback)];
|
|
258
|
+
return [2, this.saveFlow(__assign(__assign({}, source), { tags: (0, tags_1.addTagsIds)(source.tags, newIds) }))];
|
|
454
259
|
}
|
|
455
260
|
});
|
|
456
261
|
});
|
|
457
262
|
};
|
|
458
|
-
Flows.prototype.
|
|
459
|
-
if (deleteLambda === void 0) { deleteLambda = false; }
|
|
263
|
+
Flows.prototype.removeTags = function (source, tagNames) {
|
|
460
264
|
return __awaiter(this, void 0, void 0, function () {
|
|
461
|
-
var
|
|
265
|
+
var tags, tagIds, existingIds;
|
|
462
266
|
return __generator(this, function (_a) {
|
|
463
267
|
switch (_a.label) {
|
|
464
|
-
case 0: return [4, this.
|
|
465
|
-
url: this.deployUrl,
|
|
466
|
-
route: '',
|
|
467
|
-
method: 'delete',
|
|
468
|
-
data: {
|
|
469
|
-
flow: {
|
|
470
|
-
id: flow.id,
|
|
471
|
-
},
|
|
472
|
-
flowAlias: flowAlias,
|
|
473
|
-
role: lodash_1.default.get(flow, 'data.deploy.role'),
|
|
474
|
-
deleteLambda: deleteLambda,
|
|
475
|
-
},
|
|
476
|
-
})];
|
|
268
|
+
case 0: return [4, this.tags.getMultipleTagsByName(tagNames)];
|
|
477
269
|
case 1:
|
|
478
|
-
|
|
479
|
-
|
|
270
|
+
tags = _a.sent();
|
|
271
|
+
tagIds = tags.map(function (tag) { return tag.id; });
|
|
272
|
+
existingIds = (0, tags_1.filterTagIds)(source.tags, tagIds).existingIds;
|
|
273
|
+
if (!existingIds.length) {
|
|
274
|
+
throw Error('No tags to remove.');
|
|
275
|
+
}
|
|
276
|
+
return [2, this.saveFlow(__assign(__assign({}, source), { tags: (0, tags_1.removeTagIds)(source.tags, existingIds) }))];
|
|
480
277
|
}
|
|
481
278
|
});
|
|
482
279
|
});
|
|
@@ -489,6 +286,6 @@ var Flows = (function (_super) {
|
|
|
489
286
|
return (0, utils_1.deleteUnusedStepTemplates)(source, stepTemplates);
|
|
490
287
|
};
|
|
491
288
|
return Flows;
|
|
492
|
-
}(
|
|
289
|
+
}());
|
|
493
290
|
exports.Flows = Flows;
|
|
494
291
|
//# sourceMappingURL=Flows.js.map
|