@rockcarver/frodo-lib 0.12.1 → 0.12.2-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 +5 -1
- package/cjs/api/BaseApi.js +36 -8
- package/cjs/api/BaseApi.js.map +1 -1
- package/cjs/api/NodeApi.js +190 -0
- package/cjs/api/NodeApi.js.map +1 -0
- package/cjs/api/NodeApi.test.js.map +1 -0
- package/cjs/api/StartupApi.js +21 -8
- package/cjs/api/StartupApi.js.map +1 -1
- package/cjs/api/StartupApi.test.js.map +1 -0
- package/cjs/api/TreeApi.js +28 -161
- package/cjs/api/TreeApi.js.map +1 -1
- package/cjs/api/TreeApi.test.js.map +1 -0
- package/cjs/index.js +15 -5
- package/cjs/index.js.map +1 -1
- package/cjs/ops/IdpOps.js +1 -1
- package/cjs/ops/IdpOps.js.map +1 -1
- package/cjs/ops/JourneyOps.js +202 -203
- package/cjs/ops/JourneyOps.js.map +1 -1
- package/cjs/ops/StartupOps.js +61 -71
- package/cjs/ops/StartupOps.js.map +1 -1
- package/cjs/ops/utils/Console.js +3 -2
- package/cjs/ops/utils/Console.js.map +1 -1
- package/esm/api/BaseApi.mjs +35 -7
- package/esm/api/NodeApi.mjs +114 -0
- package/esm/api/NodeApi.test.mjs +105 -0
- package/esm/api/StartupApi.mjs +18 -8
- package/esm/api/StartupApi.test.mjs +56 -0
- package/esm/api/TreeApi.mjs +27 -99
- package/esm/api/TreeApi.test.mjs +175 -0
- package/esm/index.mjs +7 -5
- package/esm/ops/IdpOps.mjs +1 -1
- package/esm/ops/JourneyOps.mjs +165 -154
- package/esm/ops/StartupOps.mjs +59 -62
- package/esm/ops/utils/Console.mjs +3 -2
- package/package.json +7 -4
- package/types/api/AuthenticateApi.d.ts +2 -0
- package/types/api/AuthenticateApi.d.ts.map +1 -0
- package/types/api/BaseApi.d.ts +50 -0
- package/types/api/BaseApi.d.ts.map +1 -0
- package/types/api/CirclesOfTrustApi.d.ts +24 -0
- package/types/api/CirclesOfTrustApi.d.ts.map +1 -0
- package/types/api/EmailTemplateApi.d.ts +22 -0
- package/types/api/EmailTemplateApi.d.ts.map +1 -0
- package/types/api/IdmConfigApi.d.ts +39 -0
- package/types/api/IdmConfigApi.d.ts.map +1 -0
- package/types/api/LogApi.d.ts +4 -0
- package/types/api/LogApi.d.ts.map +1 -0
- package/types/api/ManagedObjectApi.d.ts +21 -0
- package/types/api/ManagedObjectApi.d.ts.map +1 -0
- package/types/api/NodeApi.d.ts +38 -0
- package/types/api/NodeApi.d.ts.map +1 -0
- package/types/api/OAuth2ClientApi.d.ts +18 -0
- package/types/api/OAuth2ClientApi.d.ts.map +1 -0
- package/types/api/OAuth2OIDCApi.d.ts +22 -0
- package/types/api/OAuth2OIDCApi.d.ts.map +1 -0
- package/types/api/OAuth2ProviderApi.d.ts +5 -0
- package/types/api/OAuth2ProviderApi.d.ts.map +1 -0
- package/types/api/RealmApi.d.ts +30 -0
- package/types/api/RealmApi.d.ts.map +1 -0
- package/types/api/Saml2Api.d.ts +52 -0
- package/types/api/Saml2Api.d.ts.map +1 -0
- package/types/api/ScriptApi.d.ts +24 -0
- package/types/api/ScriptApi.d.ts.map +1 -0
- package/types/api/SecretsApi.d.ts +10 -0
- package/types/api/SecretsApi.d.ts.map +1 -0
- package/types/api/ServerInfoApi.d.ts +10 -0
- package/types/api/ServerInfoApi.d.ts.map +1 -0
- package/types/api/SocialIdentityProvidersApi.d.ts +31 -0
- package/types/api/SocialIdentityProvidersApi.d.ts.map +1 -0
- package/types/api/StartupApi.d.ts +14 -0
- package/types/api/StartupApi.d.ts.map +1 -0
- package/types/api/ThemeApi.d.ts +54 -0
- package/types/api/ThemeApi.d.ts.map +1 -0
- package/types/api/TreeApi.d.ts +24 -0
- package/types/api/TreeApi.d.ts.map +1 -0
- package/types/api/VariablesApi.d.ts +32 -0
- package/types/api/VariablesApi.d.ts.map +1 -0
- package/types/api/utils/ApiUtils.d.ts +29 -0
- package/types/api/utils/ApiUtils.d.ts.map +1 -0
- package/types/api/utils/Base64.d.ts +30 -0
- package/types/api/utils/Base64.d.ts.map +1 -0
- package/types/index.d.ts +26 -0
- package/types/index.d.ts.map +1 -0
- package/types/ops/AdminOps.d.ts +11 -0
- package/types/ops/AdminOps.d.ts.map +1 -0
- package/types/ops/AuthenticateOps.d.ts +6 -0
- package/types/ops/AuthenticateOps.d.ts.map +1 -0
- package/types/ops/CirclesOfTrustOps.d.ts +40 -0
- package/types/ops/CirclesOfTrustOps.d.ts.map +1 -0
- package/types/ops/ConnectionProfileOps.d.ts +47 -0
- package/types/ops/ConnectionProfileOps.d.ts.map +1 -0
- package/types/ops/EmailTemplateOps.d.ts +40 -0
- package/types/ops/EmailTemplateOps.d.ts.map +1 -0
- package/types/ops/IdmOps.d.ts +27 -0
- package/types/ops/IdmOps.d.ts.map +1 -0
- package/types/ops/IdpOps.d.ts +45 -0
- package/types/ops/IdpOps.d.ts.map +1 -0
- package/types/ops/JourneyOps.d.ts +145 -0
- package/types/ops/JourneyOps.d.ts.map +1 -0
- package/types/ops/LogOps.d.ts +5 -0
- package/types/ops/LogOps.d.ts.map +1 -0
- package/types/ops/ManagedObjectOps.d.ts +14 -0
- package/types/ops/ManagedObjectOps.d.ts.map +1 -0
- package/types/ops/OAuth2ClientOps.d.ts +24 -0
- package/types/ops/OAuth2ClientOps.d.ts.map +1 -0
- package/types/ops/OrganizationOps.d.ts +11 -0
- package/types/ops/OrganizationOps.d.ts.map +1 -0
- package/types/ops/RealmOps.d.ts +22 -0
- package/types/ops/RealmOps.d.ts.map +1 -0
- package/types/ops/SamlOps.d.ts +51 -0
- package/types/ops/SamlOps.d.ts.map +1 -0
- package/types/ops/ScriptOps.d.ts +30 -0
- package/types/ops/ScriptOps.d.ts.map +1 -0
- package/types/ops/SecretsOps.d.ts +63 -0
- package/types/ops/SecretsOps.d.ts.map +1 -0
- package/types/ops/StartupOps.d.ts +25 -0
- package/types/ops/StartupOps.d.ts.map +1 -0
- package/types/ops/ThemeOps.d.ts +66 -0
- package/types/ops/ThemeOps.d.ts.map +1 -0
- package/types/ops/VariablesOps.d.ts +39 -0
- package/types/ops/VariablesOps.d.ts.map +1 -0
- package/types/ops/utils/Console.d.ts +63 -0
- package/types/ops/utils/Console.d.ts.map +1 -0
- package/types/ops/utils/DataProtection.d.ts +6 -0
- package/types/ops/utils/DataProtection.d.ts.map +1 -0
- package/types/ops/utils/ExportImportUtils.d.ts +22 -0
- package/types/ops/utils/ExportImportUtils.d.ts.map +1 -0
- package/types/ops/utils/OpsUtils.d.ts +27 -0
- package/types/ops/utils/OpsUtils.d.ts.map +1 -0
- package/types/ops/utils/Wordwrap.d.ts +1 -0
- package/types/ops/utils/Wordwrap.d.ts.map +1 -0
- package/types/storage/SessionStorage.d.ts +47 -0
- package/types/storage/SessionStorage.d.ts.map +1 -0
- package/types/storage/StaticStorage.d.ts +14 -0
- package/types/storage/StaticStorage.d.ts.map +1 -0
package/cjs/ops/JourneyOps.js
CHANGED
|
@@ -9,18 +9,19 @@ exports.describeTree = describeTree;
|
|
|
9
9
|
exports.exportJourneyToFile = exportJourneyToFile;
|
|
10
10
|
exports.exportJourneysToFile = exportJourneysToFile;
|
|
11
11
|
exports.exportJourneysToFiles = exportJourneysToFiles;
|
|
12
|
-
exports.
|
|
12
|
+
exports.exportTree = exportTree;
|
|
13
|
+
exports.findOrphanedNodes = findOrphanedNodes;
|
|
13
14
|
exports.importFirstJourneyFromFile = importFirstJourneyFromFile;
|
|
14
15
|
exports.importJourneyFromFile = importJourneyFromFile;
|
|
15
16
|
exports.importJourneysFromFile = importJourneysFromFile;
|
|
16
17
|
exports.importJourneysFromFiles = importJourneysFromFiles;
|
|
18
|
+
exports.importTree = importTree;
|
|
19
|
+
exports.isCustom = isCustom;
|
|
17
20
|
exports.listJourneys = listJourneys;
|
|
18
|
-
exports.
|
|
21
|
+
exports.removeOrphanedNodes = removeOrphanedNodes;
|
|
19
22
|
|
|
20
23
|
var _fs = _interopRequireDefault(require("fs"));
|
|
21
24
|
|
|
22
|
-
var _yesno = _interopRequireDefault(require("yesno"));
|
|
23
|
-
|
|
24
25
|
var _uuid = require("uuid");
|
|
25
26
|
|
|
26
27
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
@@ -31,6 +32,8 @@ var _OpsUtils = require("./utils/OpsUtils");
|
|
|
31
32
|
|
|
32
33
|
var _SessionStorage = _interopRequireDefault(require("../storage/SessionStorage"));
|
|
33
34
|
|
|
35
|
+
var _NodeApi = require("../api/NodeApi");
|
|
36
|
+
|
|
34
37
|
var _TreeApi = require("../api/TreeApi");
|
|
35
38
|
|
|
36
39
|
var _EmailTemplateApi = require("../api/EmailTemplateApi");
|
|
@@ -68,9 +71,10 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
68
71
|
var containerNodes = ['PageNode', 'CustomPageNode'];
|
|
69
72
|
var scriptedNodes = ['ConfigProviderNode', 'ScriptedDecisionNode', 'ClientScriptNode', 'SocialProviderHandlerNode', 'CustomScriptNode'];
|
|
70
73
|
var emailTemplateNodes = ['EmailSuspendNode', 'EmailTemplateNode'];
|
|
71
|
-
var emptyScriptPlaceholder = '[Empty]';
|
|
74
|
+
var emptyScriptPlaceholder = '[Empty]';
|
|
72
75
|
|
|
73
|
-
function
|
|
76
|
+
// use a function vs a template variable to avoid problems in loops
|
|
77
|
+
function createSingleTreeExportTemplate() {
|
|
74
78
|
return {
|
|
75
79
|
meta: {},
|
|
76
80
|
innerNodes: {},
|
|
@@ -83,10 +87,10 @@ function getSingleTreeFileDataTemplate() {
|
|
|
83
87
|
circlesOfTrust: {},
|
|
84
88
|
tree: {}
|
|
85
89
|
};
|
|
86
|
-
}
|
|
87
|
-
|
|
90
|
+
}
|
|
88
91
|
|
|
89
|
-
function
|
|
92
|
+
// use a function vs a template variable to avoid problems in loops
|
|
93
|
+
function createMultipleTreesExportTemplate() {
|
|
90
94
|
return {
|
|
91
95
|
meta: {},
|
|
92
96
|
trees: {}
|
|
@@ -103,14 +107,23 @@ function getMultipleTreesFileDataTemplate() {
|
|
|
103
107
|
|
|
104
108
|
function getSaml2NodeDependencies(_x, _x2, _x3) {
|
|
105
109
|
return _getSaml2NodeDependencies.apply(this, arguments);
|
|
106
|
-
}
|
|
110
|
+
} // export async function getTreeNodes(treeObject) {
|
|
111
|
+
// const nodeList = Object.entries(treeObject.nodes);
|
|
112
|
+
// const results = await Promise.allSettled(
|
|
113
|
+
// nodeList.map(
|
|
114
|
+
// async ([nodeId, nodeInfo]) => await getNode(nodeId, nodeInfo['nodeType'])
|
|
115
|
+
// )
|
|
116
|
+
// );
|
|
117
|
+
// const nodes = results.filter((r) => r.status === 'fulfilled');
|
|
118
|
+
// nodes.map((f) => {
|
|
119
|
+
// return f.status;
|
|
120
|
+
// });
|
|
121
|
+
// const failedList = results.filter((r) => r.status === 'rejected');
|
|
122
|
+
// return nodes;
|
|
123
|
+
// }
|
|
124
|
+
|
|
107
125
|
/**
|
|
108
|
-
*
|
|
109
|
-
* dependencies. The export data can be written to a file as is
|
|
110
|
-
* (but it doesn't contain meta data).
|
|
111
|
-
* @param {Object} treeObject tree object
|
|
112
|
-
* @param {Object} exportData export data
|
|
113
|
-
* @param {Object} options options object
|
|
126
|
+
* Export options
|
|
114
127
|
*/
|
|
115
128
|
|
|
116
129
|
|
|
@@ -150,7 +163,7 @@ function _getSaml2NodeDependencies() {
|
|
|
150
163
|
}
|
|
151
164
|
});
|
|
152
165
|
|
|
153
|
-
return function (
|
|
166
|
+
return function (_x32) {
|
|
154
167
|
return _ref.apply(this, arguments);
|
|
155
168
|
};
|
|
156
169
|
}());
|
|
@@ -184,19 +197,32 @@ function _getSaml2NodeDependencies() {
|
|
|
184
197
|
return _getSaml2NodeDependencies.apply(this, arguments);
|
|
185
198
|
}
|
|
186
199
|
|
|
187
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Create export data for a tree with all its nodes and dependencies. The export data can be written to a file as is.
|
|
202
|
+
* @param {string} treeId tree id/name
|
|
203
|
+
* @param {ExportOptions} options export options
|
|
204
|
+
* @returns {Promise<SingleTreeExportTemplate>} a promise that resolves to an object containing the tree and all its nodes and dependencies
|
|
205
|
+
*/
|
|
206
|
+
function exportTree(_x4) {
|
|
188
207
|
return _exportTree.apply(this, arguments);
|
|
189
208
|
}
|
|
190
209
|
/**
|
|
191
210
|
* Export journey by id/name to file
|
|
192
|
-
* @param {
|
|
193
|
-
* @param {
|
|
194
|
-
* @param {
|
|
211
|
+
* @param {string} journeyId journey id/name
|
|
212
|
+
* @param {string} file optional export file name
|
|
213
|
+
* @param {ExportOptions} options export options
|
|
195
214
|
*/
|
|
196
215
|
|
|
197
216
|
|
|
198
217
|
function _exportTree() {
|
|
199
|
-
_exportTree = _asyncToGenerator(function* (
|
|
218
|
+
_exportTree = _asyncToGenerator(function* (treeId) {
|
|
219
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
220
|
+
useStringArrays: true,
|
|
221
|
+
deps: true,
|
|
222
|
+
verbose: false
|
|
223
|
+
};
|
|
224
|
+
var treeObject = yield (0, _TreeApi.getTree)(treeId);
|
|
225
|
+
var exportData = createSingleTreeExportTemplate();
|
|
200
226
|
var {
|
|
201
227
|
useStringArrays,
|
|
202
228
|
deps,
|
|
@@ -223,7 +249,7 @@ function _exportTree() {
|
|
|
223
249
|
var themes = []; // get all the nodes
|
|
224
250
|
|
|
225
251
|
for (var [nodeId, nodeInfo] of Object.entries(treeObject.nodes)) {
|
|
226
|
-
nodePromises.push((0,
|
|
252
|
+
nodePromises.push((0, _NodeApi.getNode)(nodeId, nodeInfo['nodeType']));
|
|
227
253
|
}
|
|
228
254
|
|
|
229
255
|
if (verbose && nodePromises.length > 0) (0, _Console.printMessage)(' - Nodes:');
|
|
@@ -288,7 +314,7 @@ function _exportTree() {
|
|
|
288
314
|
|
|
289
315
|
if (containerNodes.includes(nodeType)) {
|
|
290
316
|
for (var innerNode of nodeObject.nodes) {
|
|
291
|
-
innerNodePromises.push((0,
|
|
317
|
+
innerNodePromises.push((0, _NodeApi.getNode)(innerNode._id, innerNode.nodeType));
|
|
292
318
|
} // frodo supports themes in platform deployments
|
|
293
319
|
|
|
294
320
|
|
|
@@ -455,16 +481,19 @@ function _exportTree() {
|
|
|
455
481
|
});
|
|
456
482
|
});
|
|
457
483
|
}
|
|
484
|
+
|
|
485
|
+
return exportData;
|
|
458
486
|
});
|
|
459
487
|
return _exportTree.apply(this, arguments);
|
|
460
488
|
}
|
|
461
489
|
|
|
462
|
-
function exportJourneyToFile(
|
|
490
|
+
function exportJourneyToFile(_x5, _x6, _x7) {
|
|
463
491
|
return _exportJourneyToFile.apply(this, arguments);
|
|
464
492
|
}
|
|
465
493
|
/**
|
|
466
494
|
* Export all journeys to file
|
|
467
|
-
* @param {
|
|
495
|
+
* @param {string} file optional export file name
|
|
496
|
+
* @param {ExportOptions} options export options
|
|
468
497
|
*/
|
|
469
498
|
|
|
470
499
|
|
|
@@ -480,37 +509,26 @@ function _exportJourneyToFile() {
|
|
|
480
509
|
}
|
|
481
510
|
|
|
482
511
|
if (!verbose) (0, _Console.createProgressIndicator)(undefined, "".concat(journeyId), 'indeterminate');
|
|
483
|
-
yield (0, _TreeApi.getTree)(journeyId).then( /*#__PURE__*/function () {
|
|
484
|
-
var _ref2 = _asyncToGenerator(function* (response) {
|
|
485
|
-
var treeData = response.data;
|
|
486
|
-
var fileData = getSingleTreeFileDataTemplate();
|
|
487
512
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
return function (_x36) {
|
|
500
|
-
return _ref2.apply(this, arguments);
|
|
501
|
-
};
|
|
502
|
-
}()).catch(err => {
|
|
503
|
-
(0, _Console.stopProgressIndicator)(err.message, 'fail');
|
|
504
|
-
});
|
|
513
|
+
try {
|
|
514
|
+
var fileData = yield exportTree(journeyId, options);
|
|
515
|
+
if (verbose) (0, _Console.createProgressIndicator)(undefined, "".concat(journeyId), 'indeterminate');
|
|
516
|
+
(0, _ExportImportUtils.saveJsonToFile)(fileData, fileName);
|
|
517
|
+
(0, _Console.stopProgressIndicator)("Exported ".concat(journeyId['brightCyan'], " to ").concat(fileName['brightCyan'], "."), 'success');
|
|
518
|
+
} catch (error) {
|
|
519
|
+
if (verbose) (0, _Console.createProgressIndicator)(undefined, "".concat(journeyId), 'indeterminate');
|
|
520
|
+
(0, _Console.stopProgressIndicator)("Error exporting journey ".concat(journeyId, ": ").concat(error), 'fail');
|
|
521
|
+
}
|
|
505
522
|
});
|
|
506
523
|
return _exportJourneyToFile.apply(this, arguments);
|
|
507
524
|
}
|
|
508
525
|
|
|
509
|
-
function exportJourneysToFile(
|
|
526
|
+
function exportJourneysToFile(_x8, _x9) {
|
|
510
527
|
return _exportJourneysToFile.apply(this, arguments);
|
|
511
528
|
}
|
|
512
529
|
/**
|
|
513
530
|
* Export all journeys to separate files
|
|
531
|
+
* @param {ExportOptions} options export options
|
|
514
532
|
*/
|
|
515
533
|
|
|
516
534
|
|
|
@@ -522,20 +540,16 @@ function _exportJourneysToFile() {
|
|
|
522
540
|
fileName = (0, _ExportImportUtils.getTypedFilename)("all".concat((0, _ExportImportUtils.getRealmString)(), "Journeys"), 'journeys');
|
|
523
541
|
}
|
|
524
542
|
|
|
525
|
-
var trees =
|
|
526
|
-
var fileData =
|
|
543
|
+
var trees = yield (0, _TreeApi.getTrees)();
|
|
544
|
+
var fileData = createMultipleTreesExportTemplate();
|
|
527
545
|
(0, _Console.createProgressIndicator)(trees.length, 'Exporting journeys...');
|
|
528
546
|
|
|
529
547
|
for (var tree of trees) {
|
|
530
548
|
(0, _Console.updateProgressIndicator)("".concat(tree._id));
|
|
531
549
|
|
|
532
550
|
try {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
var exportData = getSingleTreeFileDataTemplate();
|
|
536
|
-
delete exportData.meta; // eslint-disable-next-line no-await-in-loop
|
|
537
|
-
|
|
538
|
-
yield exportTree(treeData, exportData, options);
|
|
551
|
+
var exportData = yield exportTree(tree._id, options);
|
|
552
|
+
delete exportData.meta;
|
|
539
553
|
fileData.trees[tree._id] = exportData;
|
|
540
554
|
} catch (error) {
|
|
541
555
|
(0, _Console.printMessage)("Error exporting journey ".concat(tree._id, ": ").concat(error), 'error');
|
|
@@ -548,30 +562,28 @@ function _exportJourneysToFile() {
|
|
|
548
562
|
return _exportJourneysToFile.apply(this, arguments);
|
|
549
563
|
}
|
|
550
564
|
|
|
551
|
-
function exportJourneysToFiles(
|
|
565
|
+
function exportJourneysToFiles(_x10) {
|
|
552
566
|
return _exportJourneysToFiles.apply(this, arguments);
|
|
553
567
|
}
|
|
554
568
|
/**
|
|
555
|
-
*
|
|
556
|
-
* @param {String} journeyId journey id/name
|
|
557
|
-
* @returns {Object} object containing all journey data
|
|
569
|
+
* Import options
|
|
558
570
|
*/
|
|
559
571
|
|
|
560
572
|
|
|
561
573
|
function _exportJourneysToFiles() {
|
|
562
574
|
_exportJourneysToFiles = _asyncToGenerator(function* (options) {
|
|
563
|
-
var trees =
|
|
575
|
+
var trees = yield (0, _TreeApi.getTrees)();
|
|
564
576
|
(0, _Console.createProgressIndicator)(trees.length, 'Exporting journeys...');
|
|
565
577
|
|
|
566
578
|
for (var tree of trees) {
|
|
567
579
|
(0, _Console.updateProgressIndicator)("".concat(tree._id));
|
|
568
|
-
var fileName = (0, _ExportImportUtils.getTypedFilename)("".concat(tree._id), 'journey');
|
|
569
|
-
|
|
570
|
-
var treeData = (yield (0, _TreeApi.getTree)(tree._id)).data;
|
|
571
|
-
var exportData = getSingleTreeFileDataTemplate(); // eslint-disable-next-line no-await-in-loop
|
|
580
|
+
var fileName = (0, _ExportImportUtils.getTypedFilename)("".concat(tree._id), 'journey');
|
|
572
581
|
|
|
573
|
-
|
|
574
|
-
|
|
582
|
+
try {
|
|
583
|
+
var exportData = yield exportTree(tree._id, options);
|
|
584
|
+
(0, _ExportImportUtils.saveJsonToFile)(exportData, fileName);
|
|
585
|
+
} catch (error) {// do we need to report status here?
|
|
586
|
+
}
|
|
575
587
|
}
|
|
576
588
|
|
|
577
589
|
(0, _Console.stopProgressIndicator)('Done');
|
|
@@ -579,35 +591,12 @@ function _exportJourneysToFiles() {
|
|
|
579
591
|
return _exportJourneysToFiles.apply(this, arguments);
|
|
580
592
|
}
|
|
581
593
|
|
|
582
|
-
function getJourneyData(_x13) {
|
|
583
|
-
return _getJourneyData.apply(this, arguments);
|
|
584
|
-
}
|
|
585
594
|
/**
|
|
586
595
|
* Helper to import a tree with all dependencies from an import data object (typically read from a file)
|
|
587
|
-
* @param {
|
|
588
|
-
* @param {
|
|
596
|
+
* @param {SingleTreeExportTemplate} treeObject tree object containing tree and all its dependencies
|
|
597
|
+
* @param {ImportOptions} options import options
|
|
589
598
|
*/
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
function _getJourneyData() {
|
|
593
|
-
_getJourneyData = _asyncToGenerator(function* (journeyId) {
|
|
594
|
-
(0, _Console.createProgressIndicator)(undefined, "".concat(journeyId), 'indeterminate');
|
|
595
|
-
var journeyData = getSingleTreeFileDataTemplate();
|
|
596
|
-
var treeData = (yield (0, _TreeApi.getTree)(journeyId).catch(err => {
|
|
597
|
-
(0, _Console.stopProgressIndicator)(null, 'success');
|
|
598
|
-
(0, _Console.printMessage)(err, 'error');
|
|
599
|
-
}))['data'];
|
|
600
|
-
(0, _Console.updateProgressIndicator)();
|
|
601
|
-
yield exportTree(treeData, journeyData, {
|
|
602
|
-
useStringArrays: true
|
|
603
|
-
});
|
|
604
|
-
(0, _Console.stopProgressIndicator)(null, 'success');
|
|
605
|
-
return journeyData;
|
|
606
|
-
});
|
|
607
|
-
return _getJourneyData.apply(this, arguments);
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
function importTree(_x14, _x15) {
|
|
599
|
+
function importTree(_x11, _x12) {
|
|
611
600
|
return _importTree.apply(this, arguments);
|
|
612
601
|
}
|
|
613
602
|
/**
|
|
@@ -623,12 +612,8 @@ function importTree(_x14, _x15) {
|
|
|
623
612
|
function _importTree() {
|
|
624
613
|
_importTree = _asyncToGenerator(function* (treeObject, options) {
|
|
625
614
|
var {
|
|
626
|
-
reUuid
|
|
627
|
-
|
|
628
|
-
var {
|
|
629
|
-
deps
|
|
630
|
-
} = options;
|
|
631
|
-
var {
|
|
615
|
+
reUuid,
|
|
616
|
+
deps,
|
|
632
617
|
verbose
|
|
633
618
|
} = options;
|
|
634
619
|
if (verbose) (0, _Console.printMessage)("\n- ".concat(treeObject.tree._id, "\n"), 'info', false);
|
|
@@ -682,8 +667,8 @@ function _importTree() {
|
|
|
682
667
|
var themes = {};
|
|
683
668
|
|
|
684
669
|
for (var theme of treeObject.themes) {
|
|
685
|
-
if (verbose) (0, _Console.printMessage)(" - ".concat(theme
|
|
686
|
-
themes[theme
|
|
670
|
+
if (verbose) (0, _Console.printMessage)(" - ".concat(theme['_id'], " (").concat(theme['name'], ")"), 'info');
|
|
671
|
+
themes[theme['_id']] = theme;
|
|
687
672
|
}
|
|
688
673
|
|
|
689
674
|
try {
|
|
@@ -775,17 +760,17 @@ function _importTree() {
|
|
|
775
760
|
|
|
776
761
|
yield (0, _CirclesOfTrustApi.createCircleOfTrust)(cotData) // eslint-disable-next-line no-unused-vars
|
|
777
762
|
.catch( /*#__PURE__*/function () {
|
|
778
|
-
var
|
|
763
|
+
var _ref2 = _asyncToGenerator(function* (createCotErr) {
|
|
779
764
|
if (createCotErr.response.status === 409 || createCotErr.response.status === 500) {
|
|
780
765
|
yield (0, _CirclesOfTrustApi.updateCircleOfTrust)(cotId, cotData).catch( /*#__PURE__*/function () {
|
|
781
|
-
var
|
|
766
|
+
var _ref3 = _asyncToGenerator(function* (updateCotErr) {
|
|
782
767
|
(0, _Console.printMessage)(createCotErr.response.data, 'error');
|
|
783
768
|
(0, _Console.printMessage)(updateCotErr.response.data, 'error');
|
|
784
769
|
throw new Error("Error creating/updating circle of trust ".concat(cotId));
|
|
785
770
|
});
|
|
786
771
|
|
|
787
|
-
return function (
|
|
788
|
-
return
|
|
772
|
+
return function (_x34) {
|
|
773
|
+
return _ref3.apply(this, arguments);
|
|
789
774
|
};
|
|
790
775
|
}());
|
|
791
776
|
} else {
|
|
@@ -794,8 +779,8 @@ function _importTree() {
|
|
|
794
779
|
}
|
|
795
780
|
});
|
|
796
781
|
|
|
797
|
-
return function (
|
|
798
|
-
return
|
|
782
|
+
return function (_x33) {
|
|
783
|
+
return _ref2.apply(this, arguments);
|
|
799
784
|
};
|
|
800
785
|
}());
|
|
801
786
|
};
|
|
@@ -842,7 +827,7 @@ function _importTree() {
|
|
|
842
827
|
|
|
843
828
|
try {
|
|
844
829
|
// eslint-disable-next-line no-await-in-loop
|
|
845
|
-
yield (0,
|
|
830
|
+
yield (0, _NodeApi.putNode)(newUuid, nodeType, innerNodeData);
|
|
846
831
|
} catch (nodeImportError) {
|
|
847
832
|
if (nodeImportError.response.status === 400 && nodeImportError.response.data.message === 'Data validation failed for the attribute, Script') {
|
|
848
833
|
throw new Error("Missing script ".concat(innerNodeData['script'], " referenced by inner node ").concat(innerNodeId).concat(innerNodeId === newUuid ? '' : " [".concat(newUuid, "]"), " (").concat(innerNodeData['_type']['_id'], ") in journey ").concat(treeId, "."));
|
|
@@ -892,7 +877,7 @@ function _importTree() {
|
|
|
892
877
|
|
|
893
878
|
try {
|
|
894
879
|
// eslint-disable-next-line no-await-in-loop
|
|
895
|
-
yield (0,
|
|
880
|
+
yield (0, _NodeApi.putNode)(newUuid, _nodeType, nodeData);
|
|
896
881
|
} catch (nodeImportError) {
|
|
897
882
|
if (nodeImportError.response.status === 400 && nodeImportError.response.data.message === 'Data validation failed for the attribute, Script') {
|
|
898
883
|
throw new Error("Missing script ".concat(nodeData['script'], " referenced by node ").concat(nodeId).concat(nodeId === newUuid ? '' : " [".concat(newUuid, "]"), " (").concat(nodeData['_type']['_id'], ") in journey ").concat(treeId, "."));
|
|
@@ -922,7 +907,7 @@ function _importTree() {
|
|
|
922
907
|
// Set the identityResource for the tree to the selected resource.
|
|
923
908
|
|
|
924
909
|
|
|
925
|
-
if (treeObject.tree.identityResource && treeObject.tree
|
|
910
|
+
if (treeObject.tree.identityResource && treeObject.tree['identityResource'].endsWith('user')) {
|
|
926
911
|
treeObject.tree.identityResource = "managed/".concat((0, _OpsUtils.getRealmManagedUser)());
|
|
927
912
|
if (verbose) (0, _Console.printMessage)(" - identityResource: ".concat(treeObject.tree.identityResource), 'info', false);
|
|
928
913
|
}
|
|
@@ -961,14 +946,14 @@ function _importTree() {
|
|
|
961
946
|
return _importTree.apply(this, arguments);
|
|
962
947
|
}
|
|
963
948
|
|
|
964
|
-
function resolveDependencies(
|
|
949
|
+
function resolveDependencies(_x13, _x14, _x15, _x16) {
|
|
965
950
|
return _resolveDependencies.apply(this, arguments);
|
|
966
951
|
}
|
|
967
952
|
/**
|
|
968
953
|
* Import a journey from file
|
|
969
|
-
* @param {
|
|
970
|
-
* @param {
|
|
971
|
-
* @param {
|
|
954
|
+
* @param {string} journeyId journey id/name
|
|
955
|
+
* @param {string} file import file name
|
|
956
|
+
* @param {ImportOptions} options import options
|
|
972
957
|
*/
|
|
973
958
|
|
|
974
959
|
|
|
@@ -1031,13 +1016,13 @@ function _resolveDependencies() {
|
|
|
1031
1016
|
return _resolveDependencies.apply(this, arguments);
|
|
1032
1017
|
}
|
|
1033
1018
|
|
|
1034
|
-
function importJourneyFromFile(
|
|
1019
|
+
function importJourneyFromFile(_x17, _x18, _x19) {
|
|
1035
1020
|
return _importJourneyFromFile.apply(this, arguments);
|
|
1036
1021
|
}
|
|
1037
1022
|
/**
|
|
1038
1023
|
* Import first journey from file
|
|
1039
|
-
* @param {
|
|
1040
|
-
* @param {
|
|
1024
|
+
* @param {string} file import file name
|
|
1025
|
+
* @param {ImportOptions} options import options
|
|
1041
1026
|
*/
|
|
1042
1027
|
|
|
1043
1028
|
|
|
@@ -1048,7 +1033,7 @@ function _importJourneyFromFile() {
|
|
|
1048
1033
|
} = options;
|
|
1049
1034
|
|
|
1050
1035
|
_fs.default.readFile(file, 'utf8', /*#__PURE__*/function () {
|
|
1051
|
-
var
|
|
1036
|
+
var _ref4 = _asyncToGenerator(function* (err, data) {
|
|
1052
1037
|
if (err) throw err;
|
|
1053
1038
|
var journeyData = JSON.parse(data); // check if this is a file with multiple trees and get journey by id
|
|
1054
1039
|
|
|
@@ -1061,7 +1046,7 @@ function _importJourneyFromFile() {
|
|
|
1061
1046
|
|
|
1062
1047
|
if (journeyData && journeyId === journeyData.tree._id) {
|
|
1063
1048
|
// attempt dependency resolution for single tree import
|
|
1064
|
-
var installedJourneys = (yield (0, _TreeApi.getTrees)()).
|
|
1049
|
+
var installedJourneys = (yield (0, _TreeApi.getTrees)()).map(x => x._id);
|
|
1065
1050
|
var unresolvedJourneys = {};
|
|
1066
1051
|
var resolvedJourneys = [];
|
|
1067
1052
|
(0, _Console.createProgressIndicator)(undefined, 'Resolving dependencies', 'indeterminate');
|
|
@@ -1093,21 +1078,21 @@ function _importJourneyFromFile() {
|
|
|
1093
1078
|
}
|
|
1094
1079
|
});
|
|
1095
1080
|
|
|
1096
|
-
return function (
|
|
1097
|
-
return
|
|
1081
|
+
return function (_x35, _x36) {
|
|
1082
|
+
return _ref4.apply(this, arguments);
|
|
1098
1083
|
};
|
|
1099
1084
|
}());
|
|
1100
1085
|
});
|
|
1101
1086
|
return _importJourneyFromFile.apply(this, arguments);
|
|
1102
1087
|
}
|
|
1103
1088
|
|
|
1104
|
-
function importFirstJourneyFromFile(
|
|
1089
|
+
function importFirstJourneyFromFile(_x20, _x21) {
|
|
1105
1090
|
return _importFirstJourneyFromFile.apply(this, arguments);
|
|
1106
1091
|
}
|
|
1107
1092
|
/**
|
|
1108
1093
|
* Helper to import multiple trees from a tree map
|
|
1109
1094
|
* @param {Object} treesMap map of trees object
|
|
1110
|
-
* @param {
|
|
1095
|
+
* @param {ImportOptions} options import options
|
|
1111
1096
|
*/
|
|
1112
1097
|
|
|
1113
1098
|
|
|
@@ -1118,7 +1103,7 @@ function _importFirstJourneyFromFile() {
|
|
|
1118
1103
|
} = options;
|
|
1119
1104
|
|
|
1120
1105
|
_fs.default.readFile(file, 'utf8', /*#__PURE__*/function () {
|
|
1121
|
-
var
|
|
1106
|
+
var _ref5 = _asyncToGenerator(function* (err, data) {
|
|
1122
1107
|
if (err) throw err;
|
|
1123
1108
|
|
|
1124
1109
|
var journeyData = _lodash.default.cloneDeep(JSON.parse(data));
|
|
@@ -1141,7 +1126,7 @@ function _importFirstJourneyFromFile() {
|
|
|
1141
1126
|
|
|
1142
1127
|
if (journeyData && journeyId) {
|
|
1143
1128
|
// attempt dependency resolution for single tree import
|
|
1144
|
-
var installedJourneys = (yield (0, _TreeApi.getTrees)()).
|
|
1129
|
+
var installedJourneys = (yield (0, _TreeApi.getTrees)()).map(x => x._id);
|
|
1145
1130
|
var unresolvedJourneys = {};
|
|
1146
1131
|
var resolvedJourneys = [];
|
|
1147
1132
|
(0, _Console.createProgressIndicator)(undefined, 'Resolving dependencies', 'indeterminate');
|
|
@@ -1173,27 +1158,27 @@ function _importFirstJourneyFromFile() {
|
|
|
1173
1158
|
|
|
1174
1159
|
});
|
|
1175
1160
|
|
|
1176
|
-
return function (
|
|
1177
|
-
return
|
|
1161
|
+
return function (_x37, _x38) {
|
|
1162
|
+
return _ref5.apply(this, arguments);
|
|
1178
1163
|
};
|
|
1179
1164
|
}());
|
|
1180
1165
|
});
|
|
1181
1166
|
return _importFirstJourneyFromFile.apply(this, arguments);
|
|
1182
1167
|
}
|
|
1183
1168
|
|
|
1184
|
-
function importAllTrees(
|
|
1169
|
+
function importAllTrees(_x22, _x23) {
|
|
1185
1170
|
return _importAllTrees.apply(this, arguments);
|
|
1186
1171
|
}
|
|
1187
1172
|
/**
|
|
1188
1173
|
* Import all journeys from file
|
|
1189
|
-
* @param {
|
|
1190
|
-
* @param {
|
|
1174
|
+
* @param {string} file import file name
|
|
1175
|
+
* @param {ImportOptions} options import options
|
|
1191
1176
|
*/
|
|
1192
1177
|
|
|
1193
1178
|
|
|
1194
1179
|
function _importAllTrees() {
|
|
1195
1180
|
_importAllTrees = _asyncToGenerator(function* (treesMap, options) {
|
|
1196
|
-
var installedJourneys = (yield (0, _TreeApi.getTrees)()).
|
|
1181
|
+
var installedJourneys = (yield (0, _TreeApi.getTrees)()).map(x => x._id);
|
|
1197
1182
|
var unresolvedJourneys = {};
|
|
1198
1183
|
var resolvedJourneys = [];
|
|
1199
1184
|
(0, _Console.createProgressIndicator)(undefined, 'Resolving dependencies', 'indeterminate');
|
|
@@ -1226,12 +1211,12 @@ function _importAllTrees() {
|
|
|
1226
1211
|
return _importAllTrees.apply(this, arguments);
|
|
1227
1212
|
}
|
|
1228
1213
|
|
|
1229
|
-
function importJourneysFromFile(
|
|
1214
|
+
function importJourneysFromFile(_x24, _x25) {
|
|
1230
1215
|
return _importJourneysFromFile.apply(this, arguments);
|
|
1231
1216
|
}
|
|
1232
1217
|
/**
|
|
1233
1218
|
* Import all journeys from separate files
|
|
1234
|
-
* @param {
|
|
1219
|
+
* @param {ImportOptions} options import options
|
|
1235
1220
|
*/
|
|
1236
1221
|
|
|
1237
1222
|
|
|
@@ -1246,7 +1231,7 @@ function _importJourneysFromFile() {
|
|
|
1246
1231
|
return _importJourneysFromFile.apply(this, arguments);
|
|
1247
1232
|
}
|
|
1248
1233
|
|
|
1249
|
-
function importJourneysFromFiles(
|
|
1234
|
+
function importJourneysFromFiles(_x26) {
|
|
1250
1235
|
return _importJourneysFromFiles.apply(this, arguments);
|
|
1251
1236
|
}
|
|
1252
1237
|
/**
|
|
@@ -1309,10 +1294,37 @@ function describeTree(treeData) {
|
|
|
1309
1294
|
treeMap['nodeTypes'] = nodeTypeMap;
|
|
1310
1295
|
treeMap['scripts'] = scriptsMap;
|
|
1311
1296
|
treeMap['emailTemplates'] = emailTemplatesMap;
|
|
1297
|
+
(0, _Console.printMessage)("\nJourney: ".concat(treeMap['treeName']), 'data');
|
|
1298
|
+
(0, _Console.printMessage)('========');
|
|
1299
|
+
(0, _Console.printMessage)('\nNodes:', 'data');
|
|
1300
|
+
|
|
1301
|
+
if (Object.entries(treeMap['nodeTypes']).length) {
|
|
1302
|
+
for (var [name, count] of Object.entries(treeMap['nodeTypes'])) {
|
|
1303
|
+
(0, _Console.printMessage)("- ".concat(name, ": ").concat(count), 'data');
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
if (Object.entries(treeMap['scripts']).length) {
|
|
1308
|
+
(0, _Console.printMessage)('\nScripts:', 'data');
|
|
1309
|
+
|
|
1310
|
+
for (var [_name, desc] of Object.entries(treeMap['scripts'])) {
|
|
1311
|
+
(0, _Console.printMessage)("- ".concat(_name, ": ").concat(desc), 'data');
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
if (Object.entries(treeMap['emailTemplates']).length) {
|
|
1316
|
+
(0, _Console.printMessage)('\nEmail Templates:', 'data');
|
|
1317
|
+
|
|
1318
|
+
for (var [_id] of Object.entries(treeMap['emailTemplates'])) {
|
|
1319
|
+
(0, _Console.printMessage)("- ".concat(_id), 'data');
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1312
1323
|
return treeMap;
|
|
1313
1324
|
}
|
|
1314
1325
|
/**
|
|
1315
1326
|
* Find all node configuration objects that are no longer referenced by any tree
|
|
1327
|
+
* @returns {Promise<unknown[]>} a promise that resolves to an array of orphaned nodes
|
|
1316
1328
|
*/
|
|
1317
1329
|
|
|
1318
1330
|
|
|
@@ -1322,6 +1334,7 @@ function findOrphanedNodes() {
|
|
|
1322
1334
|
/**
|
|
1323
1335
|
* Remove orphaned nodes
|
|
1324
1336
|
* @param {[Object]} orphanedNodes Pass in an array of orphaned node configuration objects to remove
|
|
1337
|
+
* @returns {Promise<unknown[]>} a promise that resolves to an array nodes that encountered errors deleting
|
|
1325
1338
|
*/
|
|
1326
1339
|
|
|
1327
1340
|
|
|
@@ -1330,13 +1343,13 @@ function _findOrphanedNodes() {
|
|
|
1330
1343
|
var allNodes = [];
|
|
1331
1344
|
var orphanedNodes = [];
|
|
1332
1345
|
var types = [];
|
|
1333
|
-
var allJourneys =
|
|
1346
|
+
var allJourneys = yield (0, _TreeApi.getTrees)();
|
|
1334
1347
|
var errorMessage = '';
|
|
1335
1348
|
var errorTypes = [];
|
|
1336
1349
|
(0, _Console.createProgressIndicator)(undefined, "Counting total nodes...", 'indeterminate');
|
|
1337
1350
|
|
|
1338
1351
|
try {
|
|
1339
|
-
types =
|
|
1352
|
+
types = yield (0, _NodeApi.getNodeTypes)();
|
|
1340
1353
|
} catch (error) {
|
|
1341
1354
|
(0, _Console.printMessage)('Error retrieving all available node types:', 'error');
|
|
1342
1355
|
(0, _Console.printMessage)(error.response.data, 'error');
|
|
@@ -1346,7 +1359,7 @@ function _findOrphanedNodes() {
|
|
|
1346
1359
|
for (var type of types) {
|
|
1347
1360
|
try {
|
|
1348
1361
|
// eslint-disable-next-line no-await-in-loop, no-loop-func
|
|
1349
|
-
(yield (0,
|
|
1362
|
+
(yield (0, _NodeApi.getNodesByType)(type._id)).forEach(node => {
|
|
1350
1363
|
allNodes.push(node);
|
|
1351
1364
|
(0, _Console.updateProgressIndicator)("".concat(allNodes.length, " total nodes").concat(errorMessage));
|
|
1352
1365
|
});
|
|
@@ -1375,7 +1388,7 @@ function _findOrphanedNodes() {
|
|
|
1375
1388
|
|
|
1376
1389
|
if (containerNodes.includes(node.nodeType)) {
|
|
1377
1390
|
// eslint-disable-next-line no-await-in-loop
|
|
1378
|
-
var containerNode =
|
|
1391
|
+
var containerNode = yield (0, _NodeApi.getNode)(nodeId, node.nodeType);
|
|
1379
1392
|
containerNode.nodes.forEach(n => {
|
|
1380
1393
|
activeNodes.push(n._id);
|
|
1381
1394
|
(0, _Console.updateProgressIndicator)("".concat(activeNodes.length, " active nodes"));
|
|
@@ -1395,54 +1408,33 @@ function _findOrphanedNodes() {
|
|
|
1395
1408
|
return _findOrphanedNodes.apply(this, arguments);
|
|
1396
1409
|
}
|
|
1397
1410
|
|
|
1398
|
-
function removeOrphanedNodes(
|
|
1411
|
+
function removeOrphanedNodes(_x27) {
|
|
1399
1412
|
return _removeOrphanedNodes.apply(this, arguments);
|
|
1400
1413
|
}
|
|
1401
|
-
/**
|
|
1402
|
-
* Prune orphaned nodes
|
|
1403
|
-
*/
|
|
1404
|
-
|
|
1405
1414
|
|
|
1406
1415
|
function _removeOrphanedNodes() {
|
|
1407
1416
|
_removeOrphanedNodes = _asyncToGenerator(function* (orphanedNodes) {
|
|
1417
|
+
var errorNodes = [];
|
|
1408
1418
|
(0, _Console.createProgressIndicator)(orphanedNodes.length, 'Removing orphaned nodes...');
|
|
1409
1419
|
|
|
1410
1420
|
for (var node of orphanedNodes) {
|
|
1411
|
-
(0, _Console.updateProgressIndicator)("Removing ".concat(node
|
|
1421
|
+
(0, _Console.updateProgressIndicator)("Removing ".concat(node['_id'], "..."));
|
|
1412
1422
|
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1423
|
+
try {
|
|
1424
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1425
|
+
yield (0, _NodeApi.deleteNode)(node['_id'], node['_type']['_id']);
|
|
1426
|
+
} catch (deleteError) {
|
|
1427
|
+
errorNodes.push(node);
|
|
1428
|
+
(0, _Console.printMessage)(" ".concat(deleteError), 'error');
|
|
1429
|
+
}
|
|
1416
1430
|
}
|
|
1417
1431
|
|
|
1418
1432
|
(0, _Console.stopProgressIndicator)("Removed ".concat(orphanedNodes.length, " orphaned nodes."));
|
|
1433
|
+
return errorNodes;
|
|
1419
1434
|
});
|
|
1420
1435
|
return _removeOrphanedNodes.apply(this, arguments);
|
|
1421
1436
|
}
|
|
1422
1437
|
|
|
1423
|
-
function prune() {
|
|
1424
|
-
return _prune.apply(this, arguments);
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
function _prune() {
|
|
1428
|
-
_prune = _asyncToGenerator(function* () {
|
|
1429
|
-
var orphanedNodes = yield findOrphanedNodes();
|
|
1430
|
-
|
|
1431
|
-
if (orphanedNodes.length > 0) {
|
|
1432
|
-
var ok = yield (0, _yesno.default)({
|
|
1433
|
-
question: 'Prune (permanently delete) orphaned nodes? (y|n):'
|
|
1434
|
-
});
|
|
1435
|
-
|
|
1436
|
-
if (ok) {
|
|
1437
|
-
yield removeOrphanedNodes(orphanedNodes);
|
|
1438
|
-
}
|
|
1439
|
-
} else {
|
|
1440
|
-
(0, _Console.printMessage)('No orphaned nodes found.');
|
|
1441
|
-
}
|
|
1442
|
-
});
|
|
1443
|
-
return _prune.apply(this, arguments);
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
1438
|
var OOTB_NODE_TYPES_7 = ['AcceptTermsAndConditionsNode', 'AccountActiveDecisionNode', 'AccountLockoutNode', 'AgentDataStoreDecisionNode', 'AnonymousSessionUpgradeNode', 'AnonymousUserNode', 'AttributeCollectorNode', 'AttributePresentDecisionNode', 'AttributeValueDecisionNode', 'AuthLevelDecisionNode', 'ChoiceCollectorNode', 'ConsentNode', 'CookiePresenceDecisionNode', 'CreateObjectNode', 'CreatePasswordNode', 'DataStoreDecisionNode', 'DeviceGeoFencingNode', 'DeviceLocationMatchNode', 'DeviceMatchNode', 'DeviceProfileCollectorNode', 'DeviceSaveNode', 'DeviceTamperingVerificationNode', 'DisplayUserNameNode', 'EmailSuspendNode', 'EmailTemplateNode', 'IdentifyExistingUserNode', 'IncrementLoginCountNode', 'InnerTreeEvaluatorNode', 'IotAuthenticationNode', 'IotRegistrationNode', 'KbaCreateNode', 'KbaDecisionNode', 'KbaVerifyNode', 'LdapDecisionNode', 'LoginCountDecisionNode', 'MessageNode', 'MetadataNode', 'MeterNode', 'ModifyAuthLevelNode', 'OneTimePasswordCollectorDecisionNode', 'OneTimePasswordGeneratorNode', 'OneTimePasswordSmsSenderNode', 'OneTimePasswordSmtpSenderNode', 'PageNode', 'PasswordCollectorNode', 'PatchObjectNode', 'PersistentCookieDecisionNode', 'PollingWaitNode', 'ProfileCompletenessDecisionNode', 'ProvisionDynamicAccountNode', 'ProvisionIdmAccountNode', 'PushAuthenticationSenderNode', 'PushResultVerifierNode', 'QueryFilterDecisionNode', 'RecoveryCodeCollectorDecisionNode', 'RecoveryCodeDisplayNode', 'RegisterLogoutWebhookNode', 'RemoveSessionPropertiesNode', 'RequiredAttributesDecisionNode', 'RetryLimitDecisionNode', 'ScriptedDecisionNode', 'SelectIdPNode', 'SessionDataNode', 'SetFailureUrlNode', 'SetPersistentCookieNode', 'SetSessionPropertiesNode', 'SetSuccessUrlNode', 'SocialFacebookNode', 'SocialGoogleNode', 'SocialNode', 'SocialOAuthIgnoreProfileNode', 'SocialOpenIdConnectNode', 'SocialProviderHandlerNode', 'TermsAndConditionsDecisionNode', 'TimeSinceDecisionNode', 'TimerStartNode', 'TimerStopNode', 'UsernameCollectorNode', 'ValidatedPasswordNode', 'ValidatedUsernameNode', 'WebAuthnAuthenticationNode', 'WebAuthnDeviceStorageNode', 'WebAuthnRegistrationNode', 'ZeroPageLoginNode', 'product-CertificateCollectorNode', 'product-CertificateUserExtractorNode', 'product-CertificateValidationNode', 'product-KerberosNode', 'product-ReCaptchaNode', 'product-Saml2Node', 'product-WriteFederationInformationNode'];
|
|
1447
1439
|
var OOTB_NODE_TYPES_7_1 = ['PushRegistrationNode', 'GetAuthenticatorAppNode', 'MultiFactorRegistrationOptionsNode', 'OptOutMultiFactorAuthenticationNode'].concat(OOTB_NODE_TYPES_7);
|
|
1448
1440
|
var OOTB_NODE_TYPES_7_2 = ['OathRegistrationNode', 'OathTokenVerifierNode', 'PassthroughAuthenticationNode', 'ConfigProviderNode', 'DebugNode'].concat(OOTB_NODE_TYPES_7_1);
|
|
@@ -1454,7 +1446,7 @@ var OOTB_NODE_TYPES_6 = ['AbstractSocialAuthLoginNode', 'AccountLockoutNode', 'A
|
|
|
1454
1446
|
* @returns {boolean} True if the journey/tree contains any custom nodes, false otherwise.
|
|
1455
1447
|
*/
|
|
1456
1448
|
|
|
1457
|
-
function isCustom(
|
|
1449
|
+
function isCustom(_x28) {
|
|
1458
1450
|
return _isCustom.apply(this, arguments);
|
|
1459
1451
|
}
|
|
1460
1452
|
/**
|
|
@@ -1467,8 +1459,7 @@ function isCustom(_x31) {
|
|
|
1467
1459
|
function _isCustom() {
|
|
1468
1460
|
_isCustom = _asyncToGenerator(function* (journey) {
|
|
1469
1461
|
var ootbNodeTypes = [];
|
|
1470
|
-
var nodeList = journey.nodes;
|
|
1471
|
-
// console.log(storage.session.getAmVersion());
|
|
1462
|
+
var nodeList = journey.nodes;
|
|
1472
1463
|
|
|
1473
1464
|
switch (_SessionStorage.default.session.getAmVersion()) {
|
|
1474
1465
|
case '7.1.0':
|
|
@@ -1476,7 +1467,6 @@ function _isCustom() {
|
|
|
1476
1467
|
break;
|
|
1477
1468
|
|
|
1478
1469
|
case '7.2.0':
|
|
1479
|
-
// console.log("here");
|
|
1480
1470
|
ootbNodeTypes = OOTB_NODE_TYPES_7_2.slice(0);
|
|
1481
1471
|
break;
|
|
1482
1472
|
|
|
@@ -1522,7 +1512,7 @@ function _isCustom() {
|
|
|
1522
1512
|
|
|
1523
1513
|
if (containerNodes.includes(nodeList[node].nodeType)) {
|
|
1524
1514
|
results.push( // eslint-disable-next-line no-await-in-loop
|
|
1525
|
-
|
|
1515
|
+
yield (0, _NodeApi.getNode)(node, nodeList[node].nodeType));
|
|
1526
1516
|
}
|
|
1527
1517
|
}
|
|
1528
1518
|
}
|
|
@@ -1551,7 +1541,7 @@ function listJourneys() {
|
|
|
1551
1541
|
}
|
|
1552
1542
|
/**
|
|
1553
1543
|
* Delete a journey
|
|
1554
|
-
* @param {
|
|
1544
|
+
* @param {string} journeyId journey id/name
|
|
1555
1545
|
* @param {Object} options deep=true also delete all the nodes and inner nodes, verbose=true print verbose info
|
|
1556
1546
|
*/
|
|
1557
1547
|
|
|
@@ -1563,7 +1553,7 @@ function _listJourneys() {
|
|
|
1563
1553
|
var journeys = [];
|
|
1564
1554
|
|
|
1565
1555
|
try {
|
|
1566
|
-
journeys =
|
|
1556
|
+
journeys = yield (0, _TreeApi.getTrees)();
|
|
1567
1557
|
} catch (error) {
|
|
1568
1558
|
(0, _Console.printMessage)("".concat(error.message), 'error');
|
|
1569
1559
|
(0, _Console.printMessage)(error.response.data, 'error');
|
|
@@ -1597,7 +1587,7 @@ function _listJourneys() {
|
|
|
1597
1587
|
return _listJourneys.apply(this, arguments);
|
|
1598
1588
|
}
|
|
1599
1589
|
|
|
1600
|
-
function deleteJourney(
|
|
1590
|
+
function deleteJourney(_x29, _x30) {
|
|
1601
1591
|
return _deleteJourney.apply(this, arguments);
|
|
1602
1592
|
}
|
|
1603
1593
|
/**
|
|
@@ -1608,7 +1598,7 @@ function deleteJourney(_x32, _x33) {
|
|
|
1608
1598
|
|
|
1609
1599
|
function _deleteJourney() {
|
|
1610
1600
|
_deleteJourney = _asyncToGenerator(function* (journeyId, options) {
|
|
1611
|
-
var
|
|
1601
|
+
var progress = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
1612
1602
|
var {
|
|
1613
1603
|
deep
|
|
1614
1604
|
} = options;
|
|
@@ -1618,10 +1608,10 @@ function _deleteJourney() {
|
|
|
1618
1608
|
var status = {
|
|
1619
1609
|
nodes: {}
|
|
1620
1610
|
};
|
|
1621
|
-
if (
|
|
1622
|
-
if (
|
|
1611
|
+
if (progress) (0, _Console.createProgressIndicator)(undefined, "Deleting ".concat(journeyId, "..."), 'indeterminate');
|
|
1612
|
+
if (progress && verbose) (0, _Console.stopProgressIndicator)();
|
|
1623
1613
|
return (0, _TreeApi.deleteTree)(journeyId).then( /*#__PURE__*/function () {
|
|
1624
|
-
var
|
|
1614
|
+
var _ref6 = _asyncToGenerator(function* (deleteTreeResponse) {
|
|
1625
1615
|
status['status'] = 'success';
|
|
1626
1616
|
var nodePromises = [];
|
|
1627
1617
|
if (verbose) (0, _Console.printMessage)("Deleted ".concat(journeyId, " (tree)"), 'info');
|
|
@@ -1632,16 +1622,16 @@ function _deleteJourney() {
|
|
|
1632
1622
|
if (containerNodes.includes(nodeObject['nodeType'])) {
|
|
1633
1623
|
try {
|
|
1634
1624
|
// eslint-disable-next-line no-await-in-loop
|
|
1635
|
-
var
|
|
1625
|
+
var containerNode = yield (0, _NodeApi.getNode)(nodeId, nodeObject['nodeType']);
|
|
1636
1626
|
if (verbose) (0, _Console.printMessage)("Read ".concat(nodeId, " (").concat(nodeObject['nodeType'], ") from ").concat(journeyId), 'info');
|
|
1637
1627
|
|
|
1638
1628
|
var _loop6 = function _loop6(innerNodeObject) {
|
|
1639
|
-
nodePromises.push((0,
|
|
1629
|
+
nodePromises.push((0, _NodeApi.deleteNode)(innerNodeObject._id, innerNodeObject.nodeType).then(response2 => {
|
|
1640
1630
|
status.nodes[innerNodeObject._id] = {
|
|
1641
1631
|
status: 'success'
|
|
1642
1632
|
};
|
|
1643
1633
|
if (verbose) (0, _Console.printMessage)("Deleted ".concat(innerNodeObject._id, " (").concat(innerNodeObject.nodeType, ") from ").concat(journeyId), 'info');
|
|
1644
|
-
return response2
|
|
1634
|
+
return response2;
|
|
1645
1635
|
}).catch(error => {
|
|
1646
1636
|
status.nodes[innerNodeObject._id] = {
|
|
1647
1637
|
status: 'error',
|
|
@@ -1651,35 +1641,44 @@ function _deleteJourney() {
|
|
|
1651
1641
|
}));
|
|
1652
1642
|
};
|
|
1653
1643
|
|
|
1654
|
-
for (var innerNodeObject of
|
|
1644
|
+
for (var innerNodeObject of containerNode.nodes) {
|
|
1655
1645
|
_loop6(innerNodeObject);
|
|
1656
1646
|
} // finally delete the container node
|
|
1657
1647
|
|
|
1658
1648
|
|
|
1659
|
-
nodePromises.push((0,
|
|
1660
|
-
status.nodes[
|
|
1649
|
+
nodePromises.push((0, _NodeApi.deleteNode)(containerNode._id, containerNode['_type']['_id']).then(response2 => {
|
|
1650
|
+
status.nodes[containerNode._id] = {
|
|
1661
1651
|
status: 'success'
|
|
1662
1652
|
};
|
|
1663
|
-
if (verbose) (0, _Console.printMessage)("Deleted ".concat(
|
|
1664
|
-
return response2
|
|
1653
|
+
if (verbose) (0, _Console.printMessage)("Deleted ".concat(containerNode._id, " (").concat(containerNode['_type']['_id'], ") from ").concat(journeyId), 'info');
|
|
1654
|
+
return response2;
|
|
1665
1655
|
}).catch(error => {
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1656
|
+
var _error$response, _error$response$data;
|
|
1657
|
+
|
|
1658
|
+
if ((error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.code) === 500 && error.response.data.message === 'Unable to read SMS config: Node did not exist') {
|
|
1659
|
+
status.nodes[containerNode._id] = {
|
|
1660
|
+
status: 'success'
|
|
1661
|
+
};
|
|
1662
|
+
if (verbose) (0, _Console.printMessage)("Deleted ".concat(containerNode._id, " (").concat(containerNode['_type']['_id'], ") from ").concat(journeyId), 'info');
|
|
1663
|
+
} else {
|
|
1664
|
+
status.nodes[containerNode._id] = {
|
|
1665
|
+
status: 'error',
|
|
1666
|
+
error
|
|
1667
|
+
};
|
|
1668
|
+
if (verbose) (0, _Console.printMessage)("Error deleting container node ".concat(containerNode._id, " (").concat(containerNode['_type']['_id'], ") from ").concat(journeyId, ": ").concat(error.response.data.message), 'error');
|
|
1669
|
+
}
|
|
1671
1670
|
}));
|
|
1672
1671
|
} catch (error) {
|
|
1673
1672
|
if (verbose) (0, _Console.printMessage)("Error getting container node ".concat(nodeId, " (").concat(nodeObject['nodeType'], ") from ").concat(journeyId, ": ").concat(error), 'error');
|
|
1674
1673
|
}
|
|
1675
1674
|
} else {
|
|
1676
1675
|
// delete the node
|
|
1677
|
-
nodePromises.push((0,
|
|
1676
|
+
nodePromises.push((0, _NodeApi.deleteNode)(nodeId, nodeObject['nodeType']).then(response => {
|
|
1678
1677
|
status.nodes[nodeId] = {
|
|
1679
1678
|
status: 'success'
|
|
1680
1679
|
};
|
|
1681
1680
|
if (verbose) (0, _Console.printMessage)("Deleted ".concat(nodeId, " (").concat(nodeObject['nodeType'], ") from ").concat(journeyId), 'info');
|
|
1682
|
-
return response
|
|
1681
|
+
return response;
|
|
1683
1682
|
}).catch(error => {
|
|
1684
1683
|
status.nodes[nodeId] = {
|
|
1685
1684
|
status: 'error',
|
|
@@ -1690,7 +1689,7 @@ function _deleteJourney() {
|
|
|
1690
1689
|
}
|
|
1691
1690
|
};
|
|
1692
1691
|
|
|
1693
|
-
for (var [nodeId, nodeObject] of Object.entries(deleteTreeResponse.
|
|
1692
|
+
for (var [nodeId, nodeObject] of Object.entries(deleteTreeResponse.nodes)) {
|
|
1694
1693
|
yield* _loop5(nodeId, nodeObject);
|
|
1695
1694
|
}
|
|
1696
1695
|
} // wait until all the node calls are complete
|
|
@@ -1698,7 +1697,7 @@ function _deleteJourney() {
|
|
|
1698
1697
|
|
|
1699
1698
|
yield Promise.allSettled(nodePromises); // report status
|
|
1700
1699
|
|
|
1701
|
-
if (
|
|
1700
|
+
if (progress) {
|
|
1702
1701
|
var nodeCount = 0;
|
|
1703
1702
|
var errorCount = 0;
|
|
1704
1703
|
|
|
@@ -1717,8 +1716,8 @@ function _deleteJourney() {
|
|
|
1717
1716
|
return status;
|
|
1718
1717
|
});
|
|
1719
1718
|
|
|
1720
|
-
return function (
|
|
1721
|
-
return
|
|
1719
|
+
return function (_x39) {
|
|
1720
|
+
return _ref6.apply(this, arguments);
|
|
1722
1721
|
};
|
|
1723
1722
|
}()).catch(error => {
|
|
1724
1723
|
status['status'] = 'error';
|
|
@@ -1731,7 +1730,7 @@ function _deleteJourney() {
|
|
|
1731
1730
|
return _deleteJourney.apply(this, arguments);
|
|
1732
1731
|
}
|
|
1733
1732
|
|
|
1734
|
-
function deleteJourneys(
|
|
1733
|
+
function deleteJourneys(_x31) {
|
|
1735
1734
|
return _deleteJourneys.apply(this, arguments);
|
|
1736
1735
|
}
|
|
1737
1736
|
|
|
@@ -1741,7 +1740,7 @@ function _deleteJourneys() {
|
|
|
1741
1740
|
verbose
|
|
1742
1741
|
} = options;
|
|
1743
1742
|
var status = {};
|
|
1744
|
-
var trees =
|
|
1743
|
+
var trees = yield (0, _TreeApi.getTrees)();
|
|
1745
1744
|
(0, _Console.createProgressIndicator)(trees.length, 'Deleting journeys...');
|
|
1746
1745
|
|
|
1747
1746
|
for (var tree of trees) {
|