@rockcarver/frodo-lib 2.0.0-2 → 2.0.0-4

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.
Files changed (155) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/cjs/api/AgentApi.js +64 -16
  3. package/cjs/api/AgentApi.js.map +1 -1
  4. package/cjs/api/ApiTypes.js +0 -55
  5. package/cjs/api/ApiTypes.js.map +1 -1
  6. package/cjs/api/BaseApi.js +21 -11
  7. package/cjs/api/BaseApi.js.map +1 -1
  8. package/cjs/api/cloud/SecretsApi.js +7 -14
  9. package/cjs/api/cloud/SecretsApi.js.map +1 -1
  10. package/cjs/api/cloud/SecretsApi.test.js.map +1 -1
  11. package/cjs/index.js +6 -0
  12. package/cjs/index.js.map +1 -1
  13. package/cjs/ops/AdminOps.js +254 -60
  14. package/cjs/ops/AdminOps.js.map +1 -1
  15. package/cjs/ops/AgentOps.js +352 -108
  16. package/cjs/ops/AgentOps.js.map +1 -1
  17. package/cjs/ops/AuthenticateOps.js +262 -65
  18. package/cjs/ops/AuthenticateOps.js.map +1 -1
  19. package/cjs/ops/CirclesOfTrustOps.js +16 -4
  20. package/cjs/ops/CirclesOfTrustOps.js.map +1 -1
  21. package/cjs/ops/ConnectionProfileOps.js +163 -40
  22. package/cjs/ops/ConnectionProfileOps.js.map +1 -1
  23. package/cjs/ops/EmailTemplateOps.js +7 -1
  24. package/cjs/ops/EmailTemplateOps.js.map +1 -1
  25. package/cjs/ops/IdpOps.js +55 -12
  26. package/cjs/ops/IdpOps.js.map +1 -1
  27. package/cjs/ops/JourneyOps.js +645 -136
  28. package/cjs/ops/JourneyOps.js.map +1 -1
  29. package/cjs/ops/NodeOps.js +96 -24
  30. package/cjs/ops/NodeOps.js.map +1 -1
  31. package/cjs/ops/OAuth2ClientOps.js +45 -11
  32. package/cjs/ops/OAuth2ClientOps.js.map +1 -1
  33. package/cjs/ops/OpsTypes.js +0 -23
  34. package/cjs/ops/OpsTypes.js.map +1 -1
  35. package/cjs/ops/OrganizationOps.js +44 -10
  36. package/cjs/ops/OrganizationOps.js.map +1 -1
  37. package/cjs/ops/PolicyOps.js +86 -24
  38. package/cjs/ops/PolicyOps.js.map +1 -1
  39. package/cjs/ops/PolicySetOps.js +72 -18
  40. package/cjs/ops/PolicySetOps.js.map +1 -1
  41. package/cjs/ops/ResourceTypeOps.js +24 -6
  42. package/cjs/ops/ResourceTypeOps.js.map +1 -1
  43. package/cjs/ops/Saml2Ops.js +121 -42
  44. package/cjs/ops/Saml2Ops.js.map +1 -1
  45. package/cjs/ops/Saml2Ops.test.js.map +1 -1
  46. package/cjs/ops/ScriptOps.js +73 -17
  47. package/cjs/ops/ScriptOps.js.map +1 -1
  48. package/cjs/ops/ServiceOps.js +152 -35
  49. package/cjs/ops/ServiceOps.js.map +1 -1
  50. package/cjs/ops/ThemeOps.js +20 -5
  51. package/cjs/ops/ThemeOps.js.map +1 -1
  52. package/cjs/ops/cloud/FeatureOps.js +4 -1
  53. package/cjs/ops/cloud/FeatureOps.js.map +1 -1
  54. package/cjs/ops/cloud/SecretsOps.js.map +1 -1
  55. package/cjs/ops/cloud/ServiceAccountOps.js +24 -6
  56. package/cjs/ops/cloud/ServiceAccountOps.js.map +1 -1
  57. package/cjs/ops/cloud/StartupOps.js +55 -11
  58. package/cjs/ops/cloud/StartupOps.js.map +1 -1
  59. package/cjs/ops/utils/Console.js +47 -22
  60. package/cjs/ops/utils/Console.js.map +1 -1
  61. package/cjs/ops/utils/DataProtection.js +12 -5
  62. package/cjs/ops/utils/DataProtection.js.map +1 -1
  63. package/cjs/ops/utils/DataProtection.test.js.map +1 -1
  64. package/cjs/ops/utils/ExportImportUtils.js +15 -8
  65. package/cjs/ops/utils/ExportImportUtils.js.map +1 -1
  66. package/cjs/ops/utils/ScriptValidationUtils.js +33 -8
  67. package/cjs/ops/utils/ScriptValidationUtils.js.map +1 -1
  68. package/cjs/ops/utils/ScriptValidationUtils.test.js.map +1 -1
  69. package/cjs/utils/SetupPollyForFrodoLib.js +67 -19
  70. package/cjs/utils/SetupPollyForFrodoLib.js.map +1 -1
  71. package/esm/api/AgentApi.mjs +64 -16
  72. package/esm/api/ApiTypes.mjs +1 -50
  73. package/esm/api/BaseApi.mjs +21 -11
  74. package/esm/api/cloud/SecretsApi.mjs +0 -5
  75. package/esm/api/cloud/SecretsApi.test.mjs +3 -3
  76. package/esm/index.mjs +1 -1
  77. package/esm/ops/AdminOps.mjs +254 -60
  78. package/esm/ops/AgentOps.mjs +352 -104
  79. package/esm/ops/AuthenticateOps.mjs +262 -65
  80. package/esm/ops/CirclesOfTrustOps.mjs +16 -4
  81. package/esm/ops/ConnectionProfileOps.mjs +163 -40
  82. package/esm/ops/EmailTemplateOps.mjs +5 -0
  83. package/esm/ops/IdpOps.mjs +55 -12
  84. package/esm/ops/JourneyOps.mjs +639 -132
  85. package/esm/ops/NodeOps.mjs +90 -19
  86. package/esm/ops/OAuth2ClientOps.mjs +45 -11
  87. package/esm/ops/OpsTypes.mjs +1 -22
  88. package/esm/ops/OrganizationOps.mjs +44 -10
  89. package/esm/ops/PolicyOps.mjs +86 -24
  90. package/esm/ops/PolicySetOps.mjs +72 -18
  91. package/esm/ops/ResourceTypeOps.mjs +24 -6
  92. package/esm/ops/Saml2Ops.mjs +120 -39
  93. package/esm/ops/Saml2Ops.test.mjs +10 -11
  94. package/esm/ops/ScriptOps.mjs +73 -17
  95. package/esm/ops/ServiceOps.mjs +152 -35
  96. package/esm/ops/ThemeOps.mjs +20 -5
  97. package/esm/ops/cloud/FeatureOps.mjs +4 -1
  98. package/esm/ops/cloud/ServiceAccountOps.mjs +24 -6
  99. package/esm/ops/cloud/StartupOps.mjs +55 -11
  100. package/esm/ops/utils/Console.mjs +33 -9
  101. package/esm/ops/utils/DataProtection.mjs +9 -2
  102. package/esm/ops/utils/DataProtection.test.mjs +8 -2
  103. package/esm/ops/utils/ExportImportUtils.mjs +15 -8
  104. package/esm/ops/utils/ScriptValidationUtils.mjs +30 -8
  105. package/esm/ops/utils/ScriptValidationUtils.test.mjs +14 -3
  106. package/esm/utils/SetupPollyForFrodoLib.mjs +64 -18
  107. package/package.json +1 -1
  108. package/types/api/AgentApi.d.ts +6 -6
  109. package/types/api/AgentApi.d.ts.map +1 -1
  110. package/types/api/ApiTypes.d.ts +12 -49
  111. package/types/api/ApiTypes.d.ts.map +1 -1
  112. package/types/api/BaseApi.d.ts.map +1 -1
  113. package/types/api/cloud/SecretsApi.d.ts +1 -4
  114. package/types/api/cloud/SecretsApi.d.ts.map +1 -1
  115. package/types/index.d.ts +1 -1
  116. package/types/index.d.ts.map +1 -1
  117. package/types/ops/AdminOps.d.ts.map +1 -1
  118. package/types/ops/AgentOps.d.ts +3 -6
  119. package/types/ops/AgentOps.d.ts.map +1 -1
  120. package/types/ops/AuthenticateOps.d.ts.map +1 -1
  121. package/types/ops/CirclesOfTrustOps.d.ts.map +1 -1
  122. package/types/ops/ConnectionProfileOps.d.ts.map +1 -1
  123. package/types/ops/EmailTemplateOps.d.ts +4 -0
  124. package/types/ops/EmailTemplateOps.d.ts.map +1 -1
  125. package/types/ops/IdpOps.d.ts.map +1 -1
  126. package/types/ops/JourneyOps.d.ts +10 -5
  127. package/types/ops/JourneyOps.d.ts.map +1 -1
  128. package/types/ops/NodeOps.d.ts +10 -4
  129. package/types/ops/NodeOps.d.ts.map +1 -1
  130. package/types/ops/OAuth2ClientOps.d.ts.map +1 -1
  131. package/types/ops/OpsTypes.d.ts +2 -12
  132. package/types/ops/OpsTypes.d.ts.map +1 -1
  133. package/types/ops/OrganizationOps.d.ts.map +1 -1
  134. package/types/ops/PolicyOps.d.ts.map +1 -1
  135. package/types/ops/PolicySetOps.d.ts.map +1 -1
  136. package/types/ops/ResourceTypeOps.d.ts.map +1 -1
  137. package/types/ops/Saml2Ops.d.ts +0 -6
  138. package/types/ops/Saml2Ops.d.ts.map +1 -1
  139. package/types/ops/ScriptOps.d.ts.map +1 -1
  140. package/types/ops/ServiceOps.d.ts.map +1 -1
  141. package/types/ops/ThemeOps.d.ts.map +1 -1
  142. package/types/ops/cloud/FeatureOps.d.ts.map +1 -1
  143. package/types/ops/cloud/SecretsOps.d.ts +1 -1
  144. package/types/ops/cloud/SecretsOps.d.ts.map +1 -1
  145. package/types/ops/cloud/ServiceAccountOps.d.ts.map +1 -1
  146. package/types/ops/cloud/StartupOps.d.ts.map +1 -1
  147. package/types/ops/utils/Console.d.ts +34 -7
  148. package/types/ops/utils/Console.d.ts.map +1 -1
  149. package/types/ops/utils/DataProtection.d.ts +5 -1
  150. package/types/ops/utils/DataProtection.d.ts.map +1 -1
  151. package/types/ops/utils/ExportImportUtils.d.ts.map +1 -1
  152. package/types/ops/utils/ScriptValidationUtils.d.ts +14 -4
  153. package/types/ops/utils/ScriptValidationUtils.d.ts.map +1 -1
  154. package/types/utils/SetupPollyForFrodoLib.d.ts +5 -1
  155. package/types/utils/SetupPollyForFrodoLib.d.ts.map +1 -1
@@ -16,7 +16,6 @@ import { decode, encode, encodeBase64Url, isBase64Encoded } from '../api/utils/B
16
16
  import { getSocialIdentityProviders, putProviderByTypeAndId } from '../api/SocialIdentityProvidersApi';
17
17
  import { getThemes, putThemes } from './ThemeOps';
18
18
  import { putScript } from './ScriptOps';
19
- import { JourneyClassification } from './OpsTypes';
20
19
  export default class JourneyOps {
21
20
  constructor(state) {
22
21
  this.state = state;
@@ -237,7 +236,7 @@ export default class JourneyOps {
237
236
  * - premium: utilizes nodes, which come at a premium
238
237
  * - custom: utilizes nodes not included in the ForgeRock platform release
239
238
  * @param {SingleTreeExportInterface} journey journey export data
240
- * @returns {JourneyClassification[]} an array of one or multiple classifications
239
+ * @returns {JourneyClassificationType[]} an array of one or multiple classifications
241
240
  */
242
241
  getJourneyClassification(journey) {
243
242
  return getJourneyClassification({
@@ -294,6 +293,13 @@ export default class JourneyOps {
294
293
  });
295
294
  }
296
295
  }
296
+ export let JourneyClassification = /*#__PURE__*/function (JourneyClassification) {
297
+ JourneyClassification["STANDARD"] = "standard";
298
+ JourneyClassification["CUSTOM"] = "custom";
299
+ JourneyClassification["CLOUD"] = "cloud";
300
+ JourneyClassification["PREMIUM"] = "premium";
301
+ return JourneyClassification;
302
+ }({});
297
303
  const containerNodes = ['PageNode', 'CustomPageNode'];
298
304
  const scriptedNodes = ['ConfigProviderNode', 'ScriptedDecisionNode', 'ClientScriptNode', 'SocialProviderHandlerNode', 'CustomScriptNode'];
299
305
  const emailTemplateNodes = ['EmailSuspendNode', 'EmailTemplateNode'];
@@ -377,7 +383,11 @@ async function getSaml2NodeDependencies(nodeObject, allProviders, allCirclesOfTr
377
383
  }
378
384
  saml2EntityPromises.push(providerResponse);
379
385
  } catch (error) {
380
- printMessage(error.message, 'error');
386
+ printMessage({
387
+ message: error.message,
388
+ type: 'error',
389
+ state
390
+ });
381
391
  }
382
392
  }
383
393
  }
@@ -405,7 +415,11 @@ async function getSaml2NodeDependencies(nodeObject, allProviders, allCirclesOfTr
405
415
  };
406
416
  return saml2NodeDependencies;
407
417
  } catch (error) {
408
- printMessage(error.message, 'error');
418
+ printMessage({
419
+ message: error.message,
420
+ type: 'error',
421
+ state
422
+ });
409
423
  const saml2NodeDependencies = {
410
424
  saml2Entities: [],
411
425
  circlesOfTrust: []
@@ -441,13 +455,29 @@ export async function exportJourney({
441
455
  deps
442
456
  } = options;
443
457
  const verbose = state.getDebug();
444
- if (verbose) printMessage(`\n- ${treeObject._id}\n`, 'info', false);
458
+ if (verbose) printMessage({
459
+ message: `\n- ${treeObject._id}\n`,
460
+ type: 'info',
461
+ newline: false,
462
+ state
463
+ });
445
464
 
446
465
  // Process tree
447
- if (verbose) printMessage(' - Flow');
466
+ if (verbose) printMessage({
467
+ message: ' - Flow',
468
+ state
469
+ });
448
470
  exportData.tree = treeObject;
449
- if (verbose && treeObject.identityResource) printMessage(` - identityResource: ${treeObject.identityResource}`, 'info');
450
- if (verbose) printMessage(` - Done`, 'info');
471
+ if (verbose && treeObject.identityResource) printMessage({
472
+ message: ` - identityResource: ${treeObject.identityResource}`,
473
+ state,
474
+ type: 'info'
475
+ });
476
+ if (verbose) printMessage({
477
+ message: ` - Done`,
478
+ type: 'info',
479
+ state
480
+ });
451
481
  const nodePromises = [];
452
482
  const scriptPromises = [];
453
483
  const emailTemplatePromises = [];
@@ -461,7 +491,11 @@ export async function exportJourney({
461
491
  state
462
492
  });
463
493
  } catch (error) {
464
- printMessage(error, 'error');
494
+ printMessage({
495
+ message: error,
496
+ type: 'error',
497
+ state
498
+ });
465
499
  }
466
500
  }
467
501
  let allSaml2Providers = null;
@@ -477,14 +511,22 @@ export async function exportJourney({
477
511
  state
478
512
  }));
479
513
  }
480
- if (verbose && nodePromises.length > 0) printMessage(' - Nodes:');
514
+ if (verbose && nodePromises.length > 0) printMessage({
515
+ message: ' - Nodes:',
516
+ state
517
+ });
481
518
  const nodeObjects = await Promise.all(nodePromises);
482
519
 
483
520
  // iterate over every node in tree
484
521
  for (const nodeObject of nodeObjects) {
485
522
  const nodeId = nodeObject._id;
486
523
  const nodeType = nodeObject._type._id;
487
- if (verbose) printMessage(` - ${nodeId} (${nodeType})`, 'info', true);
524
+ if (verbose) printMessage({
525
+ message: ` - ${nodeId} (${nodeType})`,
526
+ type: 'info',
527
+ newline: true,
528
+ state
529
+ });
488
530
  exportData.nodes[nodeObject._id] = nodeObject;
489
531
 
490
532
  // handle script node types
@@ -509,7 +551,11 @@ export async function exportJourney({
509
551
  if (error.isAxiosError && error.response.status) {
510
552
  message = error.response.statusText;
511
553
  }
512
- printMessage(`\n${message}: Email Template "${nodeObject.emailTemplateName}"`, 'error');
554
+ printMessage({
555
+ message: `\n${message}: Email Template "${nodeObject.emailTemplateName}"`,
556
+ type: 'error',
557
+ state
558
+ });
513
559
  }
514
560
  }
515
561
  }
@@ -581,12 +627,20 @@ export async function exportJourney({
581
627
  }
582
628
 
583
629
  // Process inner nodes
584
- if (verbose && innerNodePromises.length > 0) printMessage(' - Inner nodes:');
630
+ if (verbose && innerNodePromises.length > 0) printMessage({
631
+ message: ' - Inner nodes:',
632
+ state
633
+ });
585
634
  const innerNodeDataResults = await Promise.all(innerNodePromises);
586
635
  for (const innerNodeObject of innerNodeDataResults) {
587
636
  const innerNodeId = innerNodeObject._id;
588
637
  const innerNodeType = innerNodeObject._type._id;
589
- if (verbose) printMessage(` - ${innerNodeId} (${innerNodeType})`, 'info', true);
638
+ if (verbose) printMessage({
639
+ message: ` - ${innerNodeId} (${innerNodeType})`,
640
+ type: 'info',
641
+ newline: true,
642
+ state
643
+ });
590
644
  exportData.innerNodes[innerNodeId] = innerNodeObject;
591
645
 
592
646
  // handle script node types
@@ -611,14 +665,22 @@ export async function exportJourney({
611
665
  if (error.isAxiosError && error.response.status) {
612
666
  message = error.response.statusText;
613
667
  }
614
- printMessage(`\n${message}: Email Template "${innerNodeObject.emailTemplateName}"`, 'error');
668
+ printMessage({
669
+ message: `\n${message}: Email Template "${innerNodeObject.emailTemplateName}"`,
670
+ type: 'error',
671
+ state
672
+ });
615
673
  }
616
674
  }
617
675
  }
618
676
 
619
677
  // handle SAML2 node dependencies
620
678
  if (deps && innerNodeType === 'product-Saml2Node') {
621
- printMessage('SAML2 inner node', 'error');
679
+ printMessage({
680
+ message: 'SAML2 inner node',
681
+ type: 'error',
682
+ state
683
+ });
622
684
  if (!allSaml2Providers) {
623
685
  // eslint-disable-next-line no-await-in-loop
624
686
  allSaml2Providers = (await getProviders({
@@ -653,11 +715,19 @@ export async function exportJourney({
653
715
  }
654
716
 
655
717
  // Process email templates
656
- if (verbose && emailTemplatePromises.length > 0) printMessage(' - Email templates:');
718
+ if (verbose && emailTemplatePromises.length > 0) printMessage({
719
+ message: ' - Email templates:',
720
+ state
721
+ });
657
722
  const settledEmailTemplatePromises = await Promise.allSettled(emailTemplatePromises);
658
723
  for (const settledPromise of settledEmailTemplatePromises) {
659
724
  if (settledPromise.status === 'fulfilled' && settledPromise.value) {
660
- if (verbose) printMessage(` - ${settledPromise.value._id.split('/')[1]}${settledPromise.value.displayName ? ` (${settledPromise.value.displayName})` : ''}`, 'info', true);
725
+ if (verbose) printMessage({
726
+ message: ` - ${settledPromise.value._id.split('/')[1]}${settledPromise.value.displayName ? ` (${settledPromise.value.displayName})` : ''}`,
727
+ type: 'info',
728
+ newline: true,
729
+ state
730
+ });
661
731
  exportData.emailTemplates[settledPromise.value._id.split('/')[1]] = settledPromise.value;
662
732
  }
663
733
  }
@@ -666,14 +736,28 @@ export async function exportJourney({
666
736
  const saml2NodeDependencies = await Promise.all(saml2ConfigPromises);
667
737
  for (const saml2NodeDependency of saml2NodeDependencies) {
668
738
  if (saml2NodeDependency) {
669
- if (verbose) printMessage(' - SAML2 entity providers:');
739
+ if (verbose) printMessage({
740
+ message: ' - SAML2 entity providers:',
741
+ state
742
+ });
670
743
  for (const saml2Entity of saml2NodeDependency.saml2Entities) {
671
- if (verbose) printMessage(` - ${saml2Entity.entityLocation} ${saml2Entity.entityId}`, 'info');
744
+ if (verbose) printMessage({
745
+ message: ` - ${saml2Entity.entityLocation} ${saml2Entity.entityId}`,
746
+ type: 'info',
747
+ state
748
+ });
672
749
  exportData.saml2Entities[saml2Entity._id] = saml2Entity;
673
750
  }
674
- if (verbose) printMessage(' - SAML2 circles of trust:');
751
+ if (verbose) printMessage({
752
+ message: ' - SAML2 circles of trust:',
753
+ state
754
+ });
675
755
  for (const circleOfTrust of saml2NodeDependency.circlesOfTrust) {
676
- if (verbose) printMessage(` - ${circleOfTrust._id}`, 'info');
756
+ if (verbose) printMessage({
757
+ message: ` - ${circleOfTrust._id}`,
758
+ type: 'info',
759
+ state
760
+ });
677
761
  exportData.circlesOfTrust[circleOfTrust._id] = circleOfTrust;
678
762
  }
679
763
  }
@@ -682,12 +766,19 @@ export async function exportJourney({
682
766
  // Process socialIdentityProviders
683
767
  const socialProviders = await Promise.resolve(socialProviderPromise);
684
768
  if (socialProviders) {
685
- if (verbose) printMessage(' - OAuth2/OIDC (social) identity providers:');
769
+ if (verbose) printMessage({
770
+ message: ' - OAuth2/OIDC (social) identity providers:',
771
+ state
772
+ });
686
773
  for (const socialProvider of socialProviders.result) {
687
774
  // If the list of socialIdentityProviders needs to be filtered based on the
688
775
  // filteredProviders property of a SelectIdPNode do it here.
689
776
  if (socialProvider && (!filteredSocialProviders || filteredSocialProviders.length === 0 || filteredSocialProviders.includes(socialProvider._id))) {
690
- if (verbose) printMessage(` - ${socialProvider._id}`, 'info');
777
+ if (verbose) printMessage({
778
+ message: ` - ${socialProvider._id}`,
779
+ type: 'info',
780
+ state
781
+ });
691
782
  scriptPromises.push(getScript({
692
783
  scriptId: socialProvider.transform,
693
784
  state
@@ -698,11 +789,19 @@ export async function exportJourney({
698
789
  }
699
790
 
700
791
  // Process scripts
701
- if (verbose && scriptPromises.length > 0) printMessage(' - Scripts:');
792
+ if (verbose && scriptPromises.length > 0) printMessage({
793
+ message: ' - Scripts:',
794
+ state
795
+ });
702
796
  const scriptObjects = await Promise.all(scriptPromises);
703
797
  for (const scriptObject of scriptObjects) {
704
798
  if (scriptObject) {
705
- if (verbose) printMessage(` - ${scriptObject._id} (${scriptObject.name})`, 'info', true);
799
+ if (verbose) printMessage({
800
+ message: ` - ${scriptObject._id} (${scriptObject.name})`,
801
+ type: 'info',
802
+ newline: true,
803
+ state
804
+ });
706
805
  scriptObject.script = useStringArrays ? convertBase64TextToArray(scriptObject.script) : JSON.stringify(decode(scriptObject.script));
707
806
  exportData.scripts[scriptObject._id] = scriptObject;
708
807
  }
@@ -710,7 +809,10 @@ export async function exportJourney({
710
809
 
711
810
  // Process themes
712
811
  if (themePromise) {
713
- if (verbose) printMessage(' - Themes:');
812
+ if (verbose) printMessage({
813
+ message: ' - Themes:',
814
+ state
815
+ });
714
816
  try {
715
817
  const themePromiseResults = await Promise.resolve(themePromise);
716
818
  for (const themeObject of themePromiseResults) {
@@ -719,18 +821,38 @@ export async function exportJourney({
719
821
  // has the theme been specified by id or name in a page node?
720
822
  themes.includes(themeObject._id) || themes.includes(themeObject.name) || // has this journey been linked to a theme?
721
823
  (_themeObject$linkedTr = themeObject.linkedTrees) !== null && _themeObject$linkedTr !== void 0 && _themeObject$linkedTr.includes(treeObject._id))) {
722
- if (verbose) printMessage(` - ${themeObject._id} (${themeObject.name})`, 'info');
824
+ if (verbose) printMessage({
825
+ message: ` - ${themeObject._id} (${themeObject.name})`,
826
+ type: 'info',
827
+ state
828
+ });
723
829
  exportData.themes.push(themeObject);
724
830
  }
725
831
  }
726
832
  } catch (error) {
727
- printMessage(error.response.data, 'error');
728
- printMessage('Error handling themes: ' + error.message, 'error');
833
+ printMessage({
834
+ message: error.response.data,
835
+ type: 'error',
836
+ state
837
+ });
838
+ printMessage({
839
+ message: 'Error handling themes: ' + error.message,
840
+ type: 'error',
841
+ state
842
+ });
729
843
  }
730
844
  }
731
845
  } catch (error) {
732
- printMessage(error.response.data, 'error');
733
- printMessage('Error exporting tree: ' + treeId + ' - ' + error.message, 'error');
846
+ printMessage({
847
+ message: error.response.data,
848
+ type: 'error',
849
+ state
850
+ });
851
+ printMessage({
852
+ message: 'Error exporting tree: ' + treeId + ' - ' + error.message,
853
+ type: 'error',
854
+ state
855
+ });
734
856
  }
735
857
  return exportData;
736
858
  }
@@ -783,16 +905,29 @@ export async function importJourney({
783
905
  deps
784
906
  } = options;
785
907
  const verbose = state.getDebug();
786
- if (verbose) printMessage(`\n- ${treeObject.tree._id}\n`, 'info', false);
908
+ if (verbose) printMessage({
909
+ message: `\n- ${treeObject.tree._id}\n`,
910
+ type: 'info',
911
+ newline: false,
912
+ state
913
+ });
787
914
  let newUuid = '';
788
915
  const uuidMap = {};
789
916
  const treeId = treeObject.tree._id;
790
917
 
791
918
  // Process scripts
792
919
  if (deps && treeObject.scripts && Object.entries(treeObject.scripts).length > 0) {
793
- if (verbose) printMessage(' - Scripts:');
920
+ if (verbose) printMessage({
921
+ message: ' - Scripts:',
922
+ state
923
+ });
794
924
  for (const [scriptId, scriptObject] of Object.entries(treeObject.scripts)) {
795
- if (verbose) printMessage(` - ${scriptId} (${scriptObject['name']})`, 'info', false);
925
+ if (verbose) printMessage({
926
+ message: ` - ${scriptId} (${scriptObject['name']})`,
927
+ type: 'info',
928
+ newline: false,
929
+ state
930
+ });
796
931
  // is the script stored as an array of strings or just b64 blob?
797
932
  if (Array.isArray(scriptObject['script'])) {
798
933
  scriptObject['script'] = convertTextArrayToBase64(scriptObject['script']);
@@ -808,15 +943,26 @@ export async function importJourney({
808
943
  } catch (error) {
809
944
  throw new Error(`Error importing script ${scriptObject['name']} (${scriptId}) in journey ${treeId}: ${error.message}`);
810
945
  }
811
- if (verbose) printMessage('');
946
+ if (verbose) printMessage({
947
+ message: '',
948
+ state
949
+ });
812
950
  }
813
951
  }
814
952
 
815
953
  // Process email templates
816
954
  if (deps && treeObject.emailTemplates && Object.entries(treeObject.emailTemplates).length > 0) {
817
- if (verbose) printMessage(' - Email templates:');
955
+ if (verbose) printMessage({
956
+ message: ' - Email templates:',
957
+ state
958
+ });
818
959
  for (const [templateId, templateData] of Object.entries(treeObject.emailTemplates)) {
819
- if (verbose) printMessage(` - ${templateId}`, 'info', false);
960
+ if (verbose) printMessage({
961
+ message: ` - ${templateId}`,
962
+ type: 'info',
963
+ newline: false,
964
+ state
965
+ });
820
966
  try {
821
967
  await putEmailTemplate({
822
968
  templateId,
@@ -824,19 +970,33 @@ export async function importJourney({
824
970
  state
825
971
  });
826
972
  } catch (error) {
827
- printMessage(error.response.data, 'error');
973
+ printMessage({
974
+ message: error.response.data,
975
+ type: 'error',
976
+ state
977
+ });
828
978
  throw new Error(`Error importing email templates: ${error.message}`);
829
979
  }
830
- if (verbose) printMessage('');
980
+ if (verbose) printMessage({
981
+ message: '',
982
+ state
983
+ });
831
984
  }
832
985
  }
833
986
 
834
987
  // Process themes
835
988
  if (deps && treeObject.themes && treeObject.themes.length > 0) {
836
- if (verbose) printMessage(' - Themes:');
989
+ if (verbose) printMessage({
990
+ message: ' - Themes:',
991
+ state
992
+ });
837
993
  const themes = new Map();
838
994
  for (const theme of treeObject.themes) {
839
- if (verbose) printMessage(` - ${theme['_id']} (${theme['name']})`, 'info');
995
+ if (verbose) printMessage({
996
+ message: ` - ${theme['_id']} (${theme['name']})`,
997
+ type: 'info',
998
+ state
999
+ });
840
1000
  themes[theme['_id']] = theme;
841
1001
  }
842
1002
  try {
@@ -851,9 +1011,16 @@ export async function importJourney({
851
1011
 
852
1012
  // Process social providers
853
1013
  if (deps && treeObject.socialIdentityProviders && Object.entries(treeObject.socialIdentityProviders).length > 0) {
854
- if (verbose) printMessage(' - OAuth2/OIDC (social) identity providers:');
1014
+ if (verbose) printMessage({
1015
+ message: ' - OAuth2/OIDC (social) identity providers:',
1016
+ state
1017
+ });
855
1018
  for (const [providerId, providerData] of Object.entries(treeObject.socialIdentityProviders)) {
856
- if (verbose) printMessage(` - ${providerId}`, 'info');
1019
+ if (verbose) printMessage({
1020
+ message: ` - ${providerId}`,
1021
+ type: 'info',
1022
+ state
1023
+ });
857
1024
  try {
858
1025
  await putProviderByTypeAndId({
859
1026
  type: providerData['_type']['_id'],
@@ -874,12 +1041,20 @@ export async function importJourney({
874
1041
  });
875
1042
  } catch (importError2) {
876
1043
  var _importError$response4;
877
- printMessage(((_importError$response4 = importError.response) === null || _importError$response4 === void 0 ? void 0 : _importError$response4.data) || importError, 'error');
1044
+ printMessage({
1045
+ message: ((_importError$response4 = importError.response) === null || _importError$response4 === void 0 ? void 0 : _importError$response4.data) || importError,
1046
+ type: 'error',
1047
+ state
1048
+ });
878
1049
  throw new Error(`Error importing provider ${providerId} in journey ${treeId}: ${importError}`);
879
1050
  }
880
1051
  } else {
881
1052
  var _importError$response5;
882
- printMessage(((_importError$response5 = importError.response) === null || _importError$response5 === void 0 ? void 0 : _importError$response5.data) || importError, 'error');
1053
+ printMessage({
1054
+ message: ((_importError$response5 = importError.response) === null || _importError$response5 === void 0 ? void 0 : _importError$response5.data) || importError,
1055
+ type: 'error',
1056
+ state
1057
+ });
883
1058
  throw new Error(`\nError importing provider ${providerId} in journey ${treeId}: ${importError}`);
884
1059
  }
885
1060
  }
@@ -888,12 +1063,19 @@ export async function importJourney({
888
1063
 
889
1064
  // Process saml providers
890
1065
  if (deps && treeObject.saml2Entities && Object.entries(treeObject.saml2Entities).length > 0) {
891
- if (verbose) printMessage(' - SAML2 entity providers:');
1066
+ if (verbose) printMessage({
1067
+ message: ' - SAML2 entity providers:',
1068
+ state
1069
+ });
892
1070
  for (const [, providerData] of Object.entries(treeObject.saml2Entities)) {
893
1071
  delete providerData['_rev'];
894
1072
  const entityId = providerData['entityId'];
895
1073
  const entityLocation = providerData['entityLocation'];
896
- if (verbose) printMessage(` - ${entityLocation} ${entityId}`, 'info');
1074
+ if (verbose) printMessage({
1075
+ message: ` - ${entityLocation} ${entityId}`,
1076
+ type: 'info',
1077
+ state
1078
+ });
897
1079
  let metaData = null;
898
1080
  if (entityLocation === 'remote') {
899
1081
  if (Array.isArray(providerData['base64EntityXML'])) {
@@ -917,7 +1099,11 @@ export async function importJourney({
917
1099
  state
918
1100
  }).catch(createProviderErr => {
919
1101
  var _createProviderErr$re;
920
- printMessage(((_createProviderErr$re = createProviderErr.response) === null || _createProviderErr$re === void 0 ? void 0 : _createProviderErr$re.data) || createProviderErr, 'error');
1102
+ printMessage({
1103
+ message: ((_createProviderErr$re = createProviderErr.response) === null || _createProviderErr$re === void 0 ? void 0 : _createProviderErr$re.data) || createProviderErr,
1104
+ type: 'error',
1105
+ state
1106
+ });
921
1107
  throw new Error(`Error creating provider ${entityId}`);
922
1108
  });
923
1109
  } else {
@@ -927,7 +1113,11 @@ export async function importJourney({
927
1113
  state
928
1114
  }).catch(updateProviderErr => {
929
1115
  var _updateProviderErr$re;
930
- printMessage(((_updateProviderErr$re = updateProviderErr.response) === null || _updateProviderErr$re === void 0 ? void 0 : _updateProviderErr$re.data) || updateProviderErr, 'error');
1116
+ printMessage({
1117
+ message: ((_updateProviderErr$re = updateProviderErr.response) === null || _updateProviderErr$re === void 0 ? void 0 : _updateProviderErr$re.data) || updateProviderErr,
1118
+ type: 'error',
1119
+ state
1120
+ });
931
1121
  throw new Error(`Error updating provider ${entityId}`);
932
1122
  });
933
1123
  }
@@ -936,10 +1126,17 @@ export async function importJourney({
936
1126
 
937
1127
  // Process circles of trust
938
1128
  if (deps && treeObject.circlesOfTrust && Object.entries(treeObject.circlesOfTrust).length > 0) {
939
- if (verbose) printMessage(' - SAML2 circles of trust:');
1129
+ if (verbose) printMessage({
1130
+ message: ' - SAML2 circles of trust:',
1131
+ state
1132
+ });
940
1133
  for (const [cotId, cotData] of Object.entries(treeObject.circlesOfTrust)) {
941
1134
  delete cotData['_rev'];
942
- if (verbose) printMessage(` - ${cotId}`, 'info');
1135
+ if (verbose) printMessage({
1136
+ message: ` - ${cotId}`,
1137
+ type: 'info',
1138
+ state
1139
+ });
943
1140
  try {
944
1141
  await createCircleOfTrust({
945
1142
  cotData,
@@ -956,13 +1153,25 @@ export async function importJourney({
956
1153
  });
957
1154
  } catch (updateCotErr) {
958
1155
  var _createCotErr$respons3, _updateCotErr$respons;
959
- printMessage(((_createCotErr$respons3 = createCotErr.response) === null || _createCotErr$respons3 === void 0 ? void 0 : _createCotErr$respons3.data) || createCotErr, 'error');
960
- printMessage(((_updateCotErr$respons = updateCotErr.response) === null || _updateCotErr$respons === void 0 ? void 0 : _updateCotErr$respons.data) || updateCotErr, 'error');
1156
+ printMessage({
1157
+ message: ((_createCotErr$respons3 = createCotErr.response) === null || _createCotErr$respons3 === void 0 ? void 0 : _createCotErr$respons3.data) || createCotErr,
1158
+ type: 'error',
1159
+ state
1160
+ });
1161
+ printMessage({
1162
+ message: ((_updateCotErr$respons = updateCotErr.response) === null || _updateCotErr$respons === void 0 ? void 0 : _updateCotErr$respons.data) || updateCotErr,
1163
+ type: 'error',
1164
+ state
1165
+ });
961
1166
  throw new Error(`Error creating/updating circle of trust ${cotId}`);
962
1167
  }
963
1168
  } else {
964
1169
  var _createCotErr$respons4;
965
- printMessage(((_createCotErr$respons4 = createCotErr.response) === null || _createCotErr$respons4 === void 0 ? void 0 : _createCotErr$respons4.data) || createCotErr, 'error');
1170
+ printMessage({
1171
+ message: ((_createCotErr$respons4 = createCotErr.response) === null || _createCotErr$respons4 === void 0 ? void 0 : _createCotErr$respons4.data) || createCotErr,
1172
+ type: 'error',
1173
+ state
1174
+ });
966
1175
  throw new Error(`Error creating circle of trust ${cotId}`);
967
1176
  }
968
1177
  }
@@ -979,7 +1188,12 @@ export async function importJourney({
979
1188
  innerNodes = treeObject.innernodes;
980
1189
  }
981
1190
  if (Object.entries(innerNodes).length > 0) {
982
- if (verbose) printMessage(' - Inner nodes:', 'text', true);
1191
+ if (verbose) printMessage({
1192
+ message: ' - Inner nodes:',
1193
+ type: 'text',
1194
+ newline: true,
1195
+ state
1196
+ });
983
1197
  for (const [innerNodeId, innerNodeData] of Object.entries(innerNodes)) {
984
1198
  delete innerNodeData['_rev'];
985
1199
  const nodeType = innerNodeData['_type']['_id'];
@@ -990,7 +1204,12 @@ export async function importJourney({
990
1204
  uuidMap[innerNodeId] = newUuid;
991
1205
  }
992
1206
  innerNodeData['_id'] = newUuid;
993
- if (verbose) printMessage(` - ${newUuid}${reUuid ? '*' : ''} (${nodeType})`, 'info', false);
1207
+ if (verbose) printMessage({
1208
+ message: ` - ${newUuid}${reUuid ? '*' : ''} (${nodeType})`,
1209
+ type: 'info',
1210
+ newline: false,
1211
+ state
1212
+ });
994
1213
 
995
1214
  // If the node has an identityResource config setting
996
1215
  // and the identityResource ends in 'user'
@@ -1000,7 +1219,12 @@ export async function importJourney({
1000
1219
  innerNodeData['identityResource'] = `managed/${getRealmManagedUser({
1001
1220
  state
1002
1221
  })}`;
1003
- if (verbose) printMessage(`\n - identityResource: ${innerNodeData['identityResource']}`, 'info', false);
1222
+ if (verbose) printMessage({
1223
+ message: `\n - identityResource: ${innerNodeData['identityResource']}`,
1224
+ type: 'info',
1225
+ newline: false,
1226
+ state
1227
+ });
1004
1228
  }
1005
1229
  try {
1006
1230
  await putNode({
@@ -1020,7 +1244,12 @@ export async function importJourney({
1020
1244
  validAttributes.push('_id');
1021
1245
  for (const attribute of Object.keys(innerNodeData)) {
1022
1246
  if (!validAttributes.includes(attribute)) {
1023
- if (verbose) printMessage(`\n - Removing invalid attribute: ${attribute}`, 'warn', false);
1247
+ if (verbose) printMessage({
1248
+ message: `\n - Removing invalid attribute: ${attribute}`,
1249
+ type: 'warn',
1250
+ newline: false,
1251
+ state
1252
+ });
1024
1253
  delete innerNodeData[attribute];
1025
1254
  }
1026
1255
  }
@@ -1032,21 +1261,35 @@ export async function importJourney({
1032
1261
  state
1033
1262
  });
1034
1263
  } catch (nodeImportError2) {
1035
- printMessage(nodeImportError2.response.data, 'error');
1264
+ printMessage({
1265
+ message: nodeImportError2.response.data,
1266
+ type: 'error',
1267
+ state
1268
+ });
1036
1269
  throw new Error(`Error importing node ${innerNodeId}${innerNodeId === newUuid ? '' : ` [${newUuid}]`} in journey ${treeId}`);
1037
1270
  }
1038
1271
  } else {
1039
- printMessage(nodeImportError.response.data, 'error');
1272
+ printMessage({
1273
+ message: nodeImportError.response.data,
1274
+ type: 'error',
1275
+ state
1276
+ });
1040
1277
  throw new Error(`Error importing inner node ${innerNodeId}${innerNodeId === newUuid ? '' : ` [${newUuid}]`} in journey ${treeId}`);
1041
1278
  }
1042
1279
  }
1043
- if (verbose) printMessage('');
1280
+ if (verbose) printMessage({
1281
+ message: '',
1282
+ state
1283
+ });
1044
1284
  }
1045
1285
  }
1046
1286
 
1047
1287
  // Process nodes
1048
1288
  if (treeObject.nodes && Object.entries(treeObject.nodes).length > 0) {
1049
- if (verbose) printMessage(' - Nodes:');
1289
+ if (verbose) printMessage({
1290
+ message: ' - Nodes:',
1291
+ state
1292
+ });
1050
1293
  // eslint-disable-next-line prefer-const
1051
1294
  for (let [nodeId, nodeData] of Object.entries(treeObject.nodes)) {
1052
1295
  delete nodeData['_rev'];
@@ -1064,7 +1307,12 @@ export async function importJourney({
1064
1307
  nodeData = JSON.parse(replaceAll(JSON.stringify(nodeData), currentId, uuidMap[currentId]));
1065
1308
  }
1066
1309
  }
1067
- if (verbose) printMessage(` - ${newUuid}${reUuid ? '*' : ''} (${nodeType})`, 'info', false);
1310
+ if (verbose) printMessage({
1311
+ message: ` - ${newUuid}${reUuid ? '*' : ''} (${nodeType})`,
1312
+ type: 'info',
1313
+ newline: false,
1314
+ state
1315
+ });
1068
1316
 
1069
1317
  // If the node has an identityResource config setting
1070
1318
  // and the identityResource ends in 'user'
@@ -1074,7 +1322,12 @@ export async function importJourney({
1074
1322
  nodeData['identityResource'] = `managed/${getRealmManagedUser({
1075
1323
  state
1076
1324
  })}`;
1077
- if (verbose) printMessage(`\n - identityResource: ${nodeData['identityResource']}`, 'info', false);
1325
+ if (verbose) printMessage({
1326
+ message: `\n - identityResource: ${nodeData['identityResource']}`,
1327
+ type: 'info',
1328
+ newline: false,
1329
+ state
1330
+ });
1078
1331
  }
1079
1332
  try {
1080
1333
  await putNode({
@@ -1094,7 +1347,12 @@ export async function importJourney({
1094
1347
  validAttributes.push('_id');
1095
1348
  for (const attribute of Object.keys(nodeData)) {
1096
1349
  if (!validAttributes.includes(attribute)) {
1097
- if (verbose) printMessage(`\n - Removing invalid attribute: ${attribute}`, 'warn', false);
1350
+ if (verbose) printMessage({
1351
+ message: `\n - Removing invalid attribute: ${attribute}`,
1352
+ type: 'warn',
1353
+ newline: false,
1354
+ state
1355
+ });
1098
1356
  delete nodeData[attribute];
1099
1357
  }
1100
1358
  }
@@ -1106,20 +1364,34 @@ export async function importJourney({
1106
1364
  state
1107
1365
  });
1108
1366
  } catch (nodeImportError2) {
1109
- printMessage(nodeImportError2.response.data, 'error');
1367
+ printMessage({
1368
+ message: nodeImportError2.response.data,
1369
+ type: 'error',
1370
+ state
1371
+ });
1110
1372
  throw new Error(`Error importing node ${nodeId}${nodeId === newUuid ? '' : ` [${newUuid}]`} in journey ${treeId}`);
1111
1373
  }
1112
1374
  } else {
1113
- printMessage(nodeImportError.response.data, 'error');
1375
+ printMessage({
1376
+ message: nodeImportError.response.data,
1377
+ type: 'error',
1378
+ state
1379
+ });
1114
1380
  throw new Error(`Error importing node ${nodeId}${nodeId === newUuid ? '' : ` [${newUuid}]`} in journey ${treeId}`);
1115
1381
  }
1116
1382
  }
1117
- if (verbose) printMessage('');
1383
+ if (verbose) printMessage({
1384
+ message: '',
1385
+ state
1386
+ });
1118
1387
  }
1119
1388
  }
1120
1389
 
1121
1390
  // Process tree
1122
- if (verbose) printMessage(' - Flow');
1391
+ if (verbose) printMessage({
1392
+ message: ' - Flow',
1393
+ state
1394
+ });
1123
1395
  if (reUuid) {
1124
1396
  let journeyText = JSON.stringify(treeObject.tree, null, 2);
1125
1397
  for (const [oldId, newId] of Object.entries(uuidMap)) {
@@ -1135,7 +1407,12 @@ export async function importJourney({
1135
1407
  treeObject.tree.identityResource = `managed/${getRealmManagedUser({
1136
1408
  state
1137
1409
  })}`;
1138
- if (verbose) printMessage(` - identityResource: ${treeObject.tree.identityResource}`, 'info', false);
1410
+ if (verbose) printMessage({
1411
+ message: ` - identityResource: ${treeObject.tree.identityResource}`,
1412
+ type: 'info',
1413
+ newline: false,
1414
+ state
1415
+ });
1139
1416
  }
1140
1417
  delete treeObject.tree._rev;
1141
1418
  try {
@@ -1144,7 +1421,12 @@ export async function importJourney({
1144
1421
  treeData: treeObject.tree,
1145
1422
  state
1146
1423
  });
1147
- if (verbose) printMessage(`\n - Done`, 'info', true);
1424
+ if (verbose) printMessage({
1425
+ message: `\n - Done`,
1426
+ type: 'info',
1427
+ newline: true,
1428
+ state
1429
+ });
1148
1430
  } catch (importError) {
1149
1431
  var _importError$response6, _importError$response7, _importError$response8;
1150
1432
  if (((_importError$response6 = importError.response) === null || _importError$response6 === void 0 ? void 0 : _importError$response6.status) === 400 && ((_importError$response7 = importError.response) === null || _importError$response7 === void 0 ? void 0 : (_importError$response8 = _importError$response7.data) === null || _importError$response8 === void 0 ? void 0 : _importError$response8.message) === 'Invalid attribute specified.') {
@@ -1154,7 +1436,12 @@ export async function importJourney({
1154
1436
  validAttributes.push('_id');
1155
1437
  for (const attribute of Object.keys(treeObject.tree)) {
1156
1438
  if (!validAttributes.includes(attribute)) {
1157
- if (verbose) printMessage(`\n - Removing invalid attribute: ${attribute}`, 'warn', false);
1439
+ if (verbose) printMessage({
1440
+ message: `\n - Removing invalid attribute: ${attribute}`,
1441
+ type: 'warn',
1442
+ newline: false,
1443
+ state
1444
+ });
1158
1445
  delete treeObject.tree[attribute];
1159
1446
  }
1160
1447
  }
@@ -1164,15 +1451,31 @@ export async function importJourney({
1164
1451
  treeData: treeObject.tree,
1165
1452
  state
1166
1453
  });
1167
- if (verbose) printMessage(`\n - Done`, 'info', true);
1454
+ if (verbose) printMessage({
1455
+ message: `\n - Done`,
1456
+ type: 'info',
1457
+ newline: true,
1458
+ state
1459
+ });
1168
1460
  } catch (importError2) {
1169
- printMessage(importError2.response.data, 'error');
1461
+ printMessage({
1462
+ message: importError2.response.data,
1463
+ type: 'error',
1464
+ state
1465
+ });
1170
1466
  throw new Error(`Error importing journey flow ${treeId}`);
1171
1467
  }
1172
1468
  } else {
1173
1469
  var _importError$response9, _importError$response10;
1174
- printMessage(((_importError$response9 = importError.response) === null || _importError$response9 === void 0 ? void 0 : _importError$response9.data) || importError, 'error');
1175
- debugMessage(((_importError$response10 = importError.response) === null || _importError$response10 === void 0 ? void 0 : _importError$response10.data) || importError);
1470
+ printMessage({
1471
+ message: ((_importError$response9 = importError.response) === null || _importError$response9 === void 0 ? void 0 : _importError$response9.data) || importError,
1472
+ type: 'error',
1473
+ state
1474
+ });
1475
+ debugMessage({
1476
+ message: ((_importError$response10 = importError.response) === null || _importError$response10 === void 0 ? void 0 : _importError$response10.data) || importError,
1477
+ state
1478
+ });
1176
1479
  throw new Error(`\nError importing journey flow ${treeId}`);
1177
1480
  }
1178
1481
  }
@@ -1251,17 +1554,38 @@ export async function importAllJourneys({
1251
1554
  })).result.map(x => x._id);
1252
1555
  const unresolvedJourneys = {};
1253
1556
  const resolvedJourneys = [];
1254
- createProgressIndicator(undefined, 'Resolving dependencies', 'indeterminate');
1557
+ createProgressIndicator({
1558
+ total: undefined,
1559
+ message: 'Resolving dependencies',
1560
+ type: 'indeterminate',
1561
+ state
1562
+ });
1255
1563
  await resolveDependencies(installedJourneys, treesMap, unresolvedJourneys, resolvedJourneys);
1256
1564
  if (Object.keys(unresolvedJourneys).length === 0) {
1257
- stopProgressIndicator(`Resolved all dependencies.`, 'success');
1565
+ stopProgressIndicator({
1566
+ message: `Resolved all dependencies.`,
1567
+ status: 'success',
1568
+ state
1569
+ });
1258
1570
  } else {
1259
- stopProgressIndicator(`${Object.keys(unresolvedJourneys).length} journeys with unresolved dependencies:`, 'fail');
1571
+ stopProgressIndicator({
1572
+ message: `${Object.keys(unresolvedJourneys).length} journeys with unresolved dependencies:`,
1573
+ status: 'fail',
1574
+ state
1575
+ });
1260
1576
  for (const journey of Object.keys(unresolvedJourneys)) {
1261
- printMessage(` - ${journey} requires ${unresolvedJourneys[journey]}`, 'info');
1577
+ printMessage({
1578
+ message: ` - ${journey} requires ${unresolvedJourneys[journey]}`,
1579
+ type: 'info',
1580
+ state
1581
+ });
1262
1582
  }
1263
1583
  }
1264
- createProgressIndicator(resolvedJourneys.length, 'Importing');
1584
+ createProgressIndicator({
1585
+ total: resolvedJourneys.length,
1586
+ message: 'Importing',
1587
+ state
1588
+ });
1265
1589
  for (const tree of resolvedJourneys) {
1266
1590
  try {
1267
1591
  // eslint-disable-next-line no-await-in-loop
@@ -1270,12 +1594,22 @@ export async function importAllJourneys({
1270
1594
  options,
1271
1595
  state
1272
1596
  });
1273
- updateProgressIndicator(`${tree}`);
1597
+ updateProgressIndicator({
1598
+ message: `${tree}`,
1599
+ state
1600
+ });
1274
1601
  } catch (error) {
1275
- printMessage(`\n${error.message}`, 'error');
1602
+ printMessage({
1603
+ message: `\n${error.message}`,
1604
+ type: 'error',
1605
+ state
1606
+ });
1276
1607
  }
1277
1608
  }
1278
- stopProgressIndicator('Done');
1609
+ stopProgressIndicator({
1610
+ message: 'Done',
1611
+ state
1612
+ });
1279
1613
  }
1280
1614
 
1281
1615
  /**
@@ -1314,7 +1648,10 @@ export function getNodeRef(nodeObj, singleTreeExport) {
1314
1648
  * @returns {TreeExportResolverInterface} tree export
1315
1649
  */
1316
1650
  export const onlineTreeExportResolver = async function (treeId, state) {
1317
- debugMessage(`onlineTreeExportResolver(${treeId})`);
1651
+ debugMessage({
1652
+ message: `onlineTreeExportResolver(${treeId})`,
1653
+ state
1654
+ });
1318
1655
  return await exportJourney({
1319
1656
  treeId,
1320
1657
  options: {
@@ -1332,7 +1669,10 @@ export const onlineTreeExportResolver = async function (treeId, state) {
1332
1669
  * @returns {TreeExportResolverInterface} tree export
1333
1670
  */
1334
1671
  export const fileByIdTreeExportResolver = async function (treeId, state) {
1335
- debugMessage(`fileByIdTreeExportResolver(${treeId})`);
1672
+ debugMessage({
1673
+ message: `fileByIdTreeExportResolver(${treeId})`,
1674
+ state
1675
+ });
1336
1676
  let treeExport = createSingleTreeExportTemplate({
1337
1677
  state
1338
1678
  });
@@ -1341,7 +1681,10 @@ export const fileByIdTreeExportResolver = async function (treeId, state) {
1341
1681
  var _jsonData$tree;
1342
1682
  const file = files.pop();
1343
1683
  const jsonData = JSON.parse(fs.readFileSync(file, 'utf8'));
1344
- debugMessage(`fileByIdTreeExportResolver: resolved '${treeId}' to ${file}`);
1684
+ debugMessage({
1685
+ message: `fileByIdTreeExportResolver: resolved '${treeId}' to ${file}`,
1686
+ state
1687
+ });
1345
1688
  // did we resolve the tree we were asked to resolved?
1346
1689
  if (((_jsonData$tree = jsonData.tree) === null || _jsonData$tree === void 0 ? void 0 : _jsonData$tree._id) === treeId) {
1347
1690
  treeExport = jsonData;
@@ -1351,7 +1694,10 @@ export const fileByIdTreeExportResolver = async function (treeId, state) {
1351
1694
  treeExport = jsonData.trees[treeId];
1352
1695
  }
1353
1696
  } catch (error) {
1354
- debugMessage(`fileByIdTreeExportResolver: unable to resolve '${treeId}' to a file.`);
1697
+ debugMessage({
1698
+ message: `fileByIdTreeExportResolver: unable to resolve '${treeId}' to a file.`,
1699
+ state
1700
+ });
1355
1701
  }
1356
1702
  return treeExport;
1357
1703
  };
@@ -1364,7 +1710,10 @@ export const fileByIdTreeExportResolver = async function (treeId, state) {
1364
1710
  */
1365
1711
  export function createFileParamTreeExportResolver(file, state) {
1366
1712
  const fileParamTreeExportResolver = async function (treeId) {
1367
- debugMessage(`fileParamTreeExportResolver(${treeId})`);
1713
+ debugMessage({
1714
+ message: `fileParamTreeExportResolver(${treeId})`,
1715
+ state
1716
+ });
1368
1717
  let treeExport = createSingleTreeExportTemplate({
1369
1718
  state
1370
1719
  });
@@ -1388,7 +1737,10 @@ export function createFileParamTreeExportResolver(file, state) {
1388
1737
  }
1389
1738
  return treeExport;
1390
1739
  };
1391
- debugMessage(`fileParamTreeExportResolver: file=${file}`);
1740
+ debugMessage({
1741
+ message: `fileParamTreeExportResolver: file=${file}`,
1742
+ state
1743
+ });
1392
1744
  return fileParamTreeExportResolver;
1393
1745
  }
1394
1746
 
@@ -1405,7 +1757,10 @@ export async function getTreeDescendents({
1405
1757
  resolvedTreeIds = [],
1406
1758
  state
1407
1759
  }) {
1408
- debugMessage(`getTreeDependencies(${treeExport.tree._id}, [${resolvedTreeIds.join(', ')}])`);
1760
+ debugMessage({
1761
+ message: `getTreeDependencies(${treeExport.tree._id}, [${resolvedTreeIds.join(', ')}])`,
1762
+ state
1763
+ });
1409
1764
  if (!resolvedTreeIds.includes(treeExport.tree._id)) {
1410
1765
  resolvedTreeIds.push(treeExport.tree._id);
1411
1766
  }
@@ -1417,7 +1772,10 @@ export async function getTreeDescendents({
1417
1772
  const innerTreeId = treeExport.nodes[nodeId].tree;
1418
1773
  if (node.nodeType === 'InnerTreeEvaluatorNode' && !resolvedTreeIds.includes(innerTreeId)) {
1419
1774
  const innerTreeExport = await resolveTreeExport(innerTreeId, state);
1420
- debugMessage(`resolved inner tree: ${innerTreeExport.tree._id}`);
1775
+ debugMessage({
1776
+ message: `resolved inner tree: ${innerTreeExport.tree._id}`,
1777
+ state
1778
+ });
1421
1779
  // resolvedTreeIds.push(innerTreeId);
1422
1780
  dependencies.push(await getTreeDescendents({
1423
1781
  treeExport: innerTreeExport,
@@ -1446,14 +1804,27 @@ export async function findOrphanedNodes({
1446
1804
  })).result;
1447
1805
  let errorMessage = '';
1448
1806
  const errorTypes = [];
1449
- createProgressIndicator(undefined, `Counting total nodes...`, 'indeterminate');
1807
+ createProgressIndicator({
1808
+ total: undefined,
1809
+ message: `Counting total nodes...`,
1810
+ type: 'indeterminate',
1811
+ state
1812
+ });
1450
1813
  try {
1451
1814
  types = (await getNodeTypes({
1452
1815
  state
1453
1816
  })).result;
1454
1817
  } catch (error) {
1455
- printMessage('Error retrieving all available node types:', 'error');
1456
- printMessage(error.response.data, 'error');
1818
+ printMessage({
1819
+ message: 'Error retrieving all available node types:',
1820
+ type: 'error',
1821
+ state
1822
+ });
1823
+ printMessage({
1824
+ message: error.response.data,
1825
+ type: 'error',
1826
+ state
1827
+ });
1457
1828
  return [];
1458
1829
  }
1459
1830
  for (const type of types) {
@@ -1465,26 +1836,48 @@ export async function findOrphanedNodes({
1465
1836
  })).result;
1466
1837
  for (const node of nodes) {
1467
1838
  allNodes.push(node);
1468
- updateProgressIndicator(`${allNodes.length} total nodes${errorMessage}`);
1839
+ updateProgressIndicator({
1840
+ message: `${allNodes.length} total nodes${errorMessage}`,
1841
+ state
1842
+ });
1469
1843
  }
1470
1844
  } catch (error) {
1471
1845
  errorTypes.push(type._id);
1472
1846
  errorMessage = ` (Skipped type(s): ${errorTypes})`['yellow'];
1473
- updateProgressIndicator(`${allNodes.length} total nodes${errorMessage}`);
1847
+ updateProgressIndicator({
1848
+ message: `${allNodes.length} total nodes${errorMessage}`,
1849
+ state
1850
+ });
1474
1851
  }
1475
1852
  }
1476
1853
  if (errorTypes.length > 0) {
1477
- stopProgressIndicator(`${allNodes.length} total nodes${errorMessage}`, 'warn');
1854
+ stopProgressIndicator({
1855
+ message: `${allNodes.length} total nodes${errorMessage}`,
1856
+ state,
1857
+ status: 'warn'
1858
+ });
1478
1859
  } else {
1479
- stopProgressIndicator(`${allNodes.length} total nodes`, 'success');
1860
+ stopProgressIndicator({
1861
+ message: `${allNodes.length} total nodes`,
1862
+ status: 'success',
1863
+ state
1864
+ });
1480
1865
  }
1481
- createProgressIndicator(undefined, 'Counting active nodes...', 'indeterminate');
1866
+ createProgressIndicator({
1867
+ total: undefined,
1868
+ message: 'Counting active nodes...',
1869
+ type: 'indeterminate',
1870
+ state
1871
+ });
1482
1872
  const activeNodes = [];
1483
1873
  for (const journey of allJourneys) {
1484
1874
  for (const nodeId in journey.nodes) {
1485
1875
  if ({}.hasOwnProperty.call(journey.nodes, nodeId)) {
1486
1876
  activeNodes.push(nodeId);
1487
- updateProgressIndicator(`${activeNodes.length} active nodes`);
1877
+ updateProgressIndicator({
1878
+ message: `${activeNodes.length} active nodes`,
1879
+ state
1880
+ });
1488
1881
  const node = journey.nodes[nodeId];
1489
1882
  if (containerNodes.includes(node.nodeType)) {
1490
1883
  const containerNode = await getNode({
@@ -1494,19 +1887,35 @@ export async function findOrphanedNodes({
1494
1887
  });
1495
1888
  for (const innerNode of containerNode.nodes) {
1496
1889
  activeNodes.push(innerNode._id);
1497
- updateProgressIndicator(`${activeNodes.length} active nodes`);
1890
+ updateProgressIndicator({
1891
+ message: `${activeNodes.length} active nodes`,
1892
+ state
1893
+ });
1498
1894
  }
1499
1895
  }
1500
1896
  }
1501
1897
  }
1502
1898
  }
1503
- stopProgressIndicator(`${activeNodes.length} active nodes`, 'success');
1504
- createProgressIndicator(undefined, 'Calculating orphaned nodes...', 'indeterminate');
1899
+ stopProgressIndicator({
1900
+ message: `${activeNodes.length} active nodes`,
1901
+ status: 'success',
1902
+ state
1903
+ });
1904
+ createProgressIndicator({
1905
+ total: undefined,
1906
+ message: 'Calculating orphaned nodes...',
1907
+ type: 'indeterminate',
1908
+ state
1909
+ });
1505
1910
  const diff = allNodes.filter(x => !activeNodes.includes(x._id));
1506
1911
  for (const orphanedNode of diff) {
1507
1912
  orphanedNodes.push(orphanedNode);
1508
1913
  }
1509
- stopProgressIndicator(`${orphanedNodes.length} orphaned nodes`, 'success');
1914
+ stopProgressIndicator({
1915
+ message: `${orphanedNodes.length} orphaned nodes`,
1916
+ status: 'success',
1917
+ state
1918
+ });
1510
1919
  return orphanedNodes;
1511
1920
  }
1512
1921
 
@@ -1520,9 +1929,16 @@ export async function removeOrphanedNodes({
1520
1929
  state
1521
1930
  }) {
1522
1931
  const errorNodes = [];
1523
- createProgressIndicator(orphanedNodes.length, 'Removing orphaned nodes...');
1932
+ createProgressIndicator({
1933
+ total: orphanedNodes.length,
1934
+ message: 'Removing orphaned nodes...',
1935
+ state
1936
+ });
1524
1937
  for (const node of orphanedNodes) {
1525
- updateProgressIndicator(`Removing ${node['_id']}...`);
1938
+ updateProgressIndicator({
1939
+ message: `Removing ${node['_id']}...`,
1940
+ state
1941
+ });
1526
1942
  try {
1527
1943
  // eslint-disable-next-line no-await-in-loop
1528
1944
  await deleteNode({
@@ -1532,10 +1948,17 @@ export async function removeOrphanedNodes({
1532
1948
  });
1533
1949
  } catch (deleteError) {
1534
1950
  errorNodes.push(node);
1535
- printMessage(` ${deleteError}`, 'error');
1951
+ printMessage({
1952
+ message: ` ${deleteError}`,
1953
+ type: 'error',
1954
+ state
1955
+ });
1536
1956
  }
1537
1957
  }
1538
- stopProgressIndicator(`Removed ${orphanedNodes.length} orphaned nodes.`);
1958
+ stopProgressIndicator({
1959
+ message: `Removed ${orphanedNodes.length} orphaned nodes.`,
1960
+ state
1961
+ });
1539
1962
  return errorNodes;
1540
1963
  }
1541
1964
 
@@ -1639,15 +2062,26 @@ export async function deleteJourney({
1639
2062
  const status = {
1640
2063
  nodes: {}
1641
2064
  };
1642
- if (progress) createProgressIndicator(undefined, `Deleting ${journeyId}...`, 'indeterminate');
1643
- if (progress && verbose) stopProgressIndicator();
2065
+ if (progress) createProgressIndicator({
2066
+ total: undefined,
2067
+ message: `Deleting ${journeyId}...`,
2068
+ type: 'indeterminate',
2069
+ state
2070
+ });
2071
+ if (progress && verbose) stopProgressIndicator({
2072
+ state
2073
+ });
1644
2074
  return deleteTree({
1645
2075
  treeId: journeyId,
1646
2076
  state
1647
2077
  }).then(async deleteTreeResponse => {
1648
2078
  status['status'] = 'success';
1649
2079
  const nodePromises = [];
1650
- if (verbose) printMessage(`Deleted ${journeyId} (tree)`, 'info');
2080
+ if (verbose) printMessage({
2081
+ message: `Deleted ${journeyId} (tree)`,
2082
+ type: 'info',
2083
+ state
2084
+ });
1651
2085
  if (deep) {
1652
2086
  for (const [nodeId, nodeObject] of Object.entries(deleteTreeResponse.nodes)) {
1653
2087
  // delete inner nodes (nodes inside container nodes)
@@ -1659,7 +2093,11 @@ export async function deleteJourney({
1659
2093
  nodeType: nodeObject['nodeType'],
1660
2094
  state
1661
2095
  });
1662
- if (verbose) printMessage(`Read ${nodeId} (${nodeObject['nodeType']}) from ${journeyId}`, 'info');
2096
+ if (verbose) printMessage({
2097
+ message: `Read ${nodeId} (${nodeObject['nodeType']}) from ${journeyId}`,
2098
+ type: 'info',
2099
+ state
2100
+ });
1663
2101
  for (const innerNodeObject of containerNode.nodes) {
1664
2102
  nodePromises.push(deleteNode({
1665
2103
  nodeId: innerNodeObject._id,
@@ -1669,14 +2107,22 @@ export async function deleteJourney({
1669
2107
  status.nodes[innerNodeObject._id] = {
1670
2108
  status: 'success'
1671
2109
  };
1672
- if (verbose) printMessage(`Deleted ${innerNodeObject._id} (${innerNodeObject.nodeType}) from ${journeyId}`, 'info');
2110
+ if (verbose) printMessage({
2111
+ message: `Deleted ${innerNodeObject._id} (${innerNodeObject.nodeType}) from ${journeyId}`,
2112
+ type: 'info',
2113
+ state
2114
+ });
1673
2115
  return response2;
1674
2116
  }).catch(error => {
1675
2117
  status.nodes[innerNodeObject._id] = {
1676
2118
  status: 'error',
1677
2119
  error
1678
2120
  };
1679
- if (verbose) printMessage(`Error deleting inner node ${innerNodeObject._id} (${innerNodeObject.nodeType}) from ${journeyId}: ${error}`, 'error');
2121
+ if (verbose) printMessage({
2122
+ message: `Error deleting inner node ${innerNodeObject._id} (${innerNodeObject.nodeType}) from ${journeyId}: ${error}`,
2123
+ type: 'error',
2124
+ state
2125
+ });
1680
2126
  }));
1681
2127
  }
1682
2128
  // finally delete the container node
@@ -1688,7 +2134,11 @@ export async function deleteJourney({
1688
2134
  status.nodes[containerNode._id] = {
1689
2135
  status: 'success'
1690
2136
  };
1691
- if (verbose) printMessage(`Deleted ${containerNode._id} (${containerNode['_type']['_id']}) from ${journeyId}`, 'info');
2137
+ if (verbose) printMessage({
2138
+ message: `Deleted ${containerNode._id} (${containerNode['_type']['_id']}) from ${journeyId}`,
2139
+ type: 'info',
2140
+ state
2141
+ });
1692
2142
  return response2;
1693
2143
  }).catch(error => {
1694
2144
  var _error$response, _error$response$data;
@@ -1696,17 +2146,29 @@ export async function deleteJourney({
1696
2146
  status.nodes[containerNode._id] = {
1697
2147
  status: 'success'
1698
2148
  };
1699
- if (verbose) printMessage(`Deleted ${containerNode._id} (${containerNode['_type']['_id']}) from ${journeyId}`, 'info');
2149
+ if (verbose) printMessage({
2150
+ message: `Deleted ${containerNode._id} (${containerNode['_type']['_id']}) from ${journeyId}`,
2151
+ type: 'info',
2152
+ state
2153
+ });
1700
2154
  } else {
1701
2155
  status.nodes[containerNode._id] = {
1702
2156
  status: 'error',
1703
2157
  error
1704
2158
  };
1705
- if (verbose) printMessage(`Error deleting container node ${containerNode._id} (${containerNode['_type']['_id']}) from ${journeyId}: ${error.response.data.message}`, 'error');
2159
+ if (verbose) printMessage({
2160
+ message: `Error deleting container node ${containerNode._id} (${containerNode['_type']['_id']}) from ${journeyId}: ${error.response.data.message}`,
2161
+ type: 'error',
2162
+ state
2163
+ });
1706
2164
  }
1707
2165
  }));
1708
2166
  } catch (error) {
1709
- if (verbose) printMessage(`Error getting container node ${nodeId} (${nodeObject['nodeType']}) from ${journeyId}: ${error}`, 'error');
2167
+ if (verbose) printMessage({
2168
+ message: `Error getting container node ${nodeId} (${nodeObject['nodeType']}) from ${journeyId}: ${error}`,
2169
+ type: 'error',
2170
+ state
2171
+ });
1710
2172
  }
1711
2173
  } else {
1712
2174
  // delete the node
@@ -1718,14 +2180,22 @@ export async function deleteJourney({
1718
2180
  status.nodes[nodeId] = {
1719
2181
  status: 'success'
1720
2182
  };
1721
- if (verbose) printMessage(`Deleted ${nodeId} (${nodeObject['nodeType']}) from ${journeyId}`, 'info');
2183
+ if (verbose) printMessage({
2184
+ message: `Deleted ${nodeId} (${nodeObject['nodeType']}) from ${journeyId}`,
2185
+ type: 'info',
2186
+ state
2187
+ });
1722
2188
  return response;
1723
2189
  }).catch(error => {
1724
2190
  status.nodes[nodeId] = {
1725
2191
  status: 'error',
1726
2192
  error
1727
2193
  };
1728
- if (verbose) printMessage(`Error deleting node ${nodeId} (${nodeObject['nodeType']}) from ${journeyId}: ${error}`, 'error');
2194
+ if (verbose) printMessage({
2195
+ message: `Error deleting node ${nodeId} (${nodeObject['nodeType']}) from ${journeyId}: ${error}`,
2196
+ type: 'error',
2197
+ state
2198
+ });
1729
2199
  }));
1730
2200
  }
1731
2201
  }
@@ -1742,17 +2212,33 @@ export async function deleteJourney({
1742
2212
  if (status.nodes[node].status === 'error') errorCount += 1;
1743
2213
  }
1744
2214
  if (errorCount === 0) {
1745
- stopProgressIndicator(`Deleted ${journeyId} and ${nodeCount - errorCount}/${nodeCount} nodes.`, 'success');
2215
+ stopProgressIndicator({
2216
+ message: `Deleted ${journeyId} and ${nodeCount - errorCount}/${nodeCount} nodes.`,
2217
+ status: 'success',
2218
+ state
2219
+ });
1746
2220
  } else {
1747
- stopProgressIndicator(`Deleted ${journeyId} and ${nodeCount - errorCount}/${nodeCount} nodes.`, 'fail');
2221
+ stopProgressIndicator({
2222
+ message: `Deleted ${journeyId} and ${nodeCount - errorCount}/${nodeCount} nodes.`,
2223
+ status: 'fail',
2224
+ state
2225
+ });
1748
2226
  }
1749
2227
  }
1750
2228
  return status;
1751
2229
  }).catch(error => {
1752
2230
  status['status'] = 'error';
1753
2231
  status['error'] = error;
1754
- stopProgressIndicator(`Error deleting ${journeyId}.`, 'fail');
1755
- if (verbose) printMessage(`Error deleting tree ${journeyId}: ${error}`, 'error');
2232
+ stopProgressIndicator({
2233
+ message: `Error deleting ${journeyId}.`,
2234
+ status: 'fail',
2235
+ state
2236
+ });
2237
+ if (verbose) printMessage({
2238
+ message: `Error deleting tree ${journeyId}: ${error}`,
2239
+ type: 'error',
2240
+ state
2241
+ });
1756
2242
  return status;
1757
2243
  });
1758
2244
  }
@@ -1772,16 +2258,26 @@ export async function deleteJourneys({
1772
2258
  const trees = (await getTrees({
1773
2259
  state
1774
2260
  })).result;
1775
- createProgressIndicator(trees.length, 'Deleting journeys...');
2261
+ createProgressIndicator({
2262
+ total: trees.length,
2263
+ message: 'Deleting journeys...',
2264
+ state
2265
+ });
1776
2266
  for (const tree of trees) {
1777
- if (verbose) printMessage('');
2267
+ if (verbose) printMessage({
2268
+ message: '',
2269
+ state
2270
+ });
1778
2271
  options['progress'] = false;
1779
2272
  status[tree._id] = await deleteJourney({
1780
2273
  journeyId: tree._id,
1781
2274
  options,
1782
2275
  state
1783
2276
  });
1784
- updateProgressIndicator(`${tree._id}`);
2277
+ updateProgressIndicator({
2278
+ message: `${tree._id}`,
2279
+ state
2280
+ });
1785
2281
  // introduce a 100ms wait to allow the progress bar to update before the next verbose message prints from the async function
1786
2282
  if (verbose)
1787
2283
  // eslint-disable-next-line no-await-in-loop
@@ -1801,7 +2297,10 @@ export async function deleteJourneys({
1801
2297
  if (status[journey].nodes[node].status === 'error') nodeErrorCount += 1;
1802
2298
  }
1803
2299
  }
1804
- stopProgressIndicator(`Deleted ${journeyCount - journeyErrorCount}/${journeyCount} journeys and ${nodeCount - nodeErrorCount}/${nodeCount} nodes.`);
2300
+ stopProgressIndicator({
2301
+ message: `Deleted ${journeyCount - journeyErrorCount}/${journeyCount} journeys and ${nodeCount - nodeErrorCount}/${nodeCount} nodes.`,
2302
+ state
2303
+ });
1805
2304
  return status;
1806
2305
  }
1807
2306
 
@@ -1828,7 +2327,11 @@ export async function enableJourney({
1828
2327
  });
1829
2328
  return newTreeObject['enabled'] === true;
1830
2329
  } catch (error) {
1831
- printMessage(error.response.data, 'error');
2330
+ printMessage({
2331
+ message: error.response.data,
2332
+ type: 'error',
2333
+ state
2334
+ });
1832
2335
  return false;
1833
2336
  }
1834
2337
  }
@@ -1856,7 +2359,11 @@ export async function disableJourney({
1856
2359
  });
1857
2360
  return newTreeObject['enabled'] === false;
1858
2361
  } catch (error) {
1859
- printMessage(error.response.data, 'error');
2362
+ printMessage({
2363
+ message: error.response.data,
2364
+ type: 'error',
2365
+ state
2366
+ });
1860
2367
  return false;
1861
2368
  }
1862
2369
  }