@or-sdk/flows 0.28.0 → 0.29.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 +0 -13
- 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/CHANGELOG.md
CHANGED
|
@@ -3,19 +3,6 @@
|
|
|
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
|
-
|
|
19
6
|
### [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)
|
|
20
7
|
|
|
21
8
|
**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
|
+
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/Flows.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Flows.js","sourceRoot":"","sources":["../../src/Flows.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA8C;AAC9C,6CAAkI;AAClI,6CAAiI;AAEjI,yCAAwD;AACxD,qCAAsF;AACtF,iCAA6E;AAE7E;IAYE,eAAY,MAAmB;QACrB,IAAA,YAAY,GAAgD,MAAM,aAAtD,EAAE,KAAK,GAAyC,MAAM,MAA/C,EAAE,SAAS,GAA8B,MAAM,UAApC,EAAE,UAAU,GAAkB,MAAM,WAAxB,EAAE,WAAW,GAAK,MAAM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GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,EAAG,EAAP,CAAO,CAAC,CAAC;wBAEhC,WAAW,GAAK,IAAA,mBAAY,EAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,YAAtC,CAAuC;wBAE1D,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;4BACvB,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAC;yBACnC;wBAED,WAAO,IAAI,CAAC,QAAQ,uBACf,MAAM,KACT,IAAI,EAAE,IAAA,mBAAY,EAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAC5C,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,AA5QD,IA4QC;AA5QY,sBAAK"}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
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
|
}
|