@rockcarver/frodo-cli 2.0.0-32 → 2.0.0-33

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 (120) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/esm/cli/FrodoCommand.js +8 -1
  3. package/esm/cli/FrodoCommand.js.map +1 -1
  4. package/esm/cli/admin/admin-export-full-cloud-config.js +44 -0
  5. package/esm/cli/admin/admin-export-full-cloud-config.js.map +1 -0
  6. package/esm/cli/admin/admin.js +1 -0
  7. package/esm/cli/admin/admin.js.map +1 -1
  8. package/esm/cli/authz/authz-policy-export.js +1 -1
  9. package/esm/cli/authz/authz-policy-export.js.map +1 -1
  10. package/esm/cli/authz/authz-policy-import.js +1 -1
  11. package/esm/cli/authz/authz-policy-import.js.map +1 -1
  12. package/esm/cli/authz/authz-policy-list.js +2 -2
  13. package/esm/cli/authz/authz-policy-list.js.map +1 -1
  14. package/esm/cli/authz/authz-set-delete.js +2 -2
  15. package/esm/cli/authz/authz-set-delete.js.map +1 -1
  16. package/esm/cli/authz/authz-set-export.js +1 -1
  17. package/esm/cli/authz/authz-set-export.js.map +1 -1
  18. package/esm/cli/authz/authz-set-import.js +1 -1
  19. package/esm/cli/authz/authz-set-import.js.map +1 -1
  20. package/esm/cli/authz/authz-set-list.js +1 -1
  21. package/esm/cli/authz/authz-set-list.js.map +1 -1
  22. package/esm/cli/authz/authz-type-delete.js +3 -3
  23. package/esm/cli/authz/authz-type-delete.js.map +1 -1
  24. package/esm/cli/authz/authz-type-export.js +2 -2
  25. package/esm/cli/authz/authz-type-export.js.map +1 -1
  26. package/esm/cli/authz/authz-type-import.js +2 -2
  27. package/esm/cli/authz/authz-type-import.js.map +1 -1
  28. package/esm/cli/authz/authz-type-list.js +1 -1
  29. package/esm/cli/authz/authz-type-list.js.map +1 -1
  30. package/esm/cli/email/email-template-export.js +3 -3
  31. package/esm/cli/email/email-template-export.js.map +1 -1
  32. package/esm/cli/email/email-template-import.js +4 -4
  33. package/esm/cli/email/email-template-import.js.map +1 -1
  34. package/esm/cli/email/email-template-list.js +1 -1
  35. package/esm/cli/email/email-template-list.js.map +1 -1
  36. package/esm/cli/idm/idm-count.js +1 -1
  37. package/esm/cli/idm/idm-count.js.map +1 -1
  38. package/esm/cli/idm/idm-export.js +3 -3
  39. package/esm/cli/idm/idm-export.js.map +1 -1
  40. package/esm/cli/idm/idm-list.js +2 -2
  41. package/esm/cli/idm/idm-list.js.map +1 -1
  42. package/esm/cli/idp/idp-export.js +3 -3
  43. package/esm/cli/idp/idp-export.js.map +1 -1
  44. package/esm/cli/idp/idp-import.js +4 -4
  45. package/esm/cli/idp/idp-import.js.map +1 -1
  46. package/esm/cli/idp/idp-list.js +1 -1
  47. package/esm/cli/idp/idp-list.js.map +1 -1
  48. package/esm/cli/journey/journey-delete.js +6 -2
  49. package/esm/cli/journey/journey-delete.js.map +1 -1
  50. package/esm/cli/journey/journey-disable.js +4 -10
  51. package/esm/cli/journey/journey-disable.js.map +1 -1
  52. package/esm/cli/journey/journey-enable.js +4 -10
  53. package/esm/cli/journey/journey-enable.js.map +1 -1
  54. package/esm/cli/journey/journey-import.js +4 -4
  55. package/esm/cli/journey/journey-import.js.map +1 -1
  56. package/esm/cli/journey/journey-list.js +1 -1
  57. package/esm/cli/journey/journey-list.js.map +1 -1
  58. package/esm/cli/saml/saml-cot-export.js +3 -3
  59. package/esm/cli/saml/saml-cot-export.js.map +1 -1
  60. package/esm/cli/saml/saml-cot-list.js +1 -1
  61. package/esm/cli/saml/saml-cot-list.js.map +1 -1
  62. package/esm/cli/saml/saml-describe.js +1 -1
  63. package/esm/cli/saml/saml-describe.js.map +1 -1
  64. package/esm/cli/saml/saml-import.js +4 -4
  65. package/esm/cli/saml/saml-import.js.map +1 -1
  66. package/esm/cli/saml/saml-list.js +1 -1
  67. package/esm/cli/saml/saml-list.js.map +1 -1
  68. package/esm/cli/saml/saml-metadata-export.js +1 -1
  69. package/esm/cli/saml/saml-metadata-export.js.map +1 -1
  70. package/esm/cli/script/script-export.js +2 -6
  71. package/esm/cli/script/script-export.js.map +1 -1
  72. package/esm/cli/theme/theme-delete.js +3 -3
  73. package/esm/cli/theme/theme-delete.js.map +1 -1
  74. package/esm/cli/theme/theme-export.js +4 -4
  75. package/esm/cli/theme/theme-export.js.map +1 -1
  76. package/esm/cli/theme/theme-import.js +4 -4
  77. package/esm/cli/theme/theme-import.js.map +1 -1
  78. package/esm/cli/theme/theme-list.js +1 -1
  79. package/esm/cli/theme/theme-list.js.map +1 -1
  80. package/esm/ops/AdminFederationOps.js +28 -26
  81. package/esm/ops/AdminFederationOps.js.map +1 -1
  82. package/esm/ops/AdminOps.js +112 -0
  83. package/esm/ops/AdminOps.js.map +1 -0
  84. package/esm/ops/AgentOps.js +59 -51
  85. package/esm/ops/AgentOps.js.map +1 -1
  86. package/esm/ops/ApplicationOps.js +19 -13
  87. package/esm/ops/ApplicationOps.js.map +1 -1
  88. package/esm/ops/CirclesOfTrustOps.js +28 -26
  89. package/esm/ops/CirclesOfTrustOps.js.map +1 -1
  90. package/esm/ops/EmailTemplateOps.js +78 -94
  91. package/esm/ops/EmailTemplateOps.js.map +1 -1
  92. package/esm/ops/IdmOps.js +8 -31
  93. package/esm/ops/IdmOps.js.map +1 -1
  94. package/esm/ops/IdpOps.js +49 -54
  95. package/esm/ops/IdpOps.js.map +1 -1
  96. package/esm/ops/JourneyOps.js +91 -70
  97. package/esm/ops/JourneyOps.js.map +1 -1
  98. package/esm/ops/OAuth2ClientOps.js +13 -11
  99. package/esm/ops/OAuth2ClientOps.js.map +1 -1
  100. package/esm/ops/PolicyOps.js +31 -26
  101. package/esm/ops/PolicyOps.js.map +1 -1
  102. package/esm/ops/PolicySetOps.js +42 -39
  103. package/esm/ops/PolicySetOps.js.map +1 -1
  104. package/esm/ops/ResourceTypeOps.js +19 -16
  105. package/esm/ops/ResourceTypeOps.js.map +1 -1
  106. package/esm/ops/Saml2Ops.js +49 -45
  107. package/esm/ops/Saml2Ops.js.map +1 -1
  108. package/esm/ops/ScriptOps.js +36 -55
  109. package/esm/ops/ScriptOps.js.map +1 -1
  110. package/esm/ops/SecretsOps.js +13 -11
  111. package/esm/ops/SecretsOps.js.map +1 -1
  112. package/esm/ops/ThemeOps.js +111 -130
  113. package/esm/ops/ThemeOps.js.map +1 -1
  114. package/esm/ops/VariablesOps.js +14 -12
  115. package/esm/ops/VariablesOps.js.map +1 -1
  116. package/esm/utils/Console.js +68 -30
  117. package/esm/utils/Console.js.map +1 -1
  118. package/esm/utils/ExportImportUtils.js +4 -12
  119. package/esm/utils/ExportImportUtils.js.map +1 -1
  120. package/package.json +2 -2
@@ -14,17 +14,17 @@ async (host, realm, user, password, options, command) => {
14
14
  // import by name
15
15
  if (options.file && options.themeName && (await getTokens())) {
16
16
  verboseMessage(`Importing theme with name "${options.themeName}" into realm "${state.getRealm()}"...`);
17
- importThemeByName(options.themeName, options.file);
17
+ await importThemeByName(options.themeName, options.file);
18
18
  }
19
19
  // import by id
20
20
  else if (options.file && options.themeId && (await getTokens())) {
21
21
  verboseMessage(`Importing theme with id "${options.themeId}" into realm "${state.getRealm()}"...`);
22
- importThemeById(options.themeId, options.file);
22
+ await importThemeById(options.themeId, options.file);
23
23
  }
24
24
  // --all -a
25
25
  else if (options.all && options.file && (await getTokens())) {
26
26
  verboseMessage(`Importing all themes from a single file (${options.file})...`);
27
- importThemesFromFile(options.file);
27
+ await importThemesFromFile(options.file);
28
28
  }
29
29
  // --all-separate -A
30
30
  else if (options.allSeparate && !options.file && (await getTokens())) {
@@ -34,7 +34,7 @@ async (host, realm, user, password, options, command) => {
34
34
  // import single theme from file
35
35
  else if (options.file && (await getTokens())) {
36
36
  verboseMessage(`Importing first theme from file "${options.file}" into realm "${state.getRealm()}"...`);
37
- importFirstThemeFromFile(options.file);
37
+ await importFirstThemeFromFile(options.file);
38
38
  }
39
39
  // unrecognized combination of options or no options
40
40
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"theme-import.js","names":["frodo","state","Option","importFirstThemeFromFile","importThemeById","importThemeByName","importThemesFromFile","importThemesFromFiles","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","file","themeName","getRealm","themeId","all","allSeparate","help","process","exitCode","parse"],"sources":["../../../src/cli/theme/theme-import.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n importFirstThemeFromFile,\n importThemeById,\n importThemeByName,\n importThemesFromFile,\n importThemesFromFiles,\n} from '../../ops/ThemeOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo theme import');\n\nprogram\n .description('Import themes.')\n .addOption(\n new Option(\n '-n, --theme-name <name>',\n 'Name of the theme. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-i, --theme-id <uuid>',\n 'Uuid of the theme. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file <file>',\n 'Name of the file to import the theme(s) from.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Import all the themes from single file. Ignored with -n or -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all the themes from separate files (*.json) in the current directory. Ignored with -n or -i or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // import by name\n if (options.file && options.themeName && (await getTokens())) {\n verboseMessage(\n `Importing theme with name \"${\n options.themeName\n }\" into realm \"${state.getRealm()}\"...`\n );\n importThemeByName(options.themeName, options.file);\n }\n // import by id\n else if (options.file && options.themeId && (await getTokens())) {\n verboseMessage(\n `Importing theme with id \"${\n options.themeId\n }\" into realm \"${state.getRealm()}\"...`\n );\n importThemeById(options.themeId, options.file);\n }\n // --all -a\n else if (options.all && options.file && (await getTokens())) {\n verboseMessage(\n `Importing all themes from a single file (${options.file})...`\n );\n importThemesFromFile(options.file);\n }\n // --all-separate -A\n else if (options.allSeparate && !options.file && (await getTokens())) {\n verboseMessage(\n 'Importing all themes from separate files in current directory...'\n );\n importThemesFromFiles();\n }\n // import single theme from file\n else if (options.file && (await getTokens())) {\n verboseMessage(\n `Importing first theme from file \"${\n options.file\n }\" into realm \"${state.getRealm()}\"...`\n );\n importFirstThemeFromFile(options.file);\n }\n // unrecognized combination of options or no options\n else {\n printMessage(\n 'Unrecognized combination of options or no options...',\n 'error'\n );\n program.help();\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SACEC,wBAAwB,EACxBC,eAAe,EACfC,iBAAiB,EACjBC,oBAAoB,EACpBC,qBAAqB,QAChB,oBAAoB;AAC3B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGX,KAAK,CAACY,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,oBAAoB,CAAC;AAEtDG,OAAO,CACJC,WAAW,CAAC,gBAAgB,CAAC,CAC7BC,SAAS,CACR,IAAIb,MAAM,CACR,yBAAyB,EACzB,yDACF,CACF,CAAC,CACAa,SAAS,CACR,IAAIb,MAAM,CACR,uBAAuB,EACvB,yDACF,CACF,CAAC,CACAa,SAAS,CACR,IAAIb,MAAM,CACR,mBAAmB,EACnB,+CACF,CACF,CAAC,CACAa,SAAS,CACR,IAAIb,MAAM,CACR,WAAW,EACX,gEACF,CACF,CAAC,CACAa,SAAS,CACR,IAAIb,MAAM,CACR,oBAAoB,EACpB,2GACF,CACF,CAAC,CACAc,MAAM;AACL;AACA,OAAOC,IAAI,EAA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5CF,cAAc,CACX,oCACCY,OAAO,CAACG,IACT,iBAAgBvB,KAAK,CAACyB,QAAQ,CAAC,CAAE,MACpC,CAAC;IACDvB,wBAAwB,CAACkB,OAAO,CAACG,IAAI,CAAC;EACxC;EACA;EAAA,KACK;IACHhB,YAAY,CACV,sDAAsD,EACtD,OACF,CAAC;IACDK,OAAO,CAACiB,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHnB,OAAO,CAACoB,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"theme-import.js","names":["frodo","state","Option","importFirstThemeFromFile","importThemeById","importThemeByName","importThemesFromFile","importThemesFromFiles","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","file","themeName","getRealm","themeId","all","allSeparate","help","process","exitCode","parse"],"sources":["../../../src/cli/theme/theme-import.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n importFirstThemeFromFile,\n importThemeById,\n importThemeByName,\n importThemesFromFile,\n importThemesFromFiles,\n} from '../../ops/ThemeOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo theme import');\n\nprogram\n .description('Import themes.')\n .addOption(\n new Option(\n '-n, --theme-name <name>',\n 'Name of the theme. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-i, --theme-id <uuid>',\n 'Uuid of the theme. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file <file>',\n 'Name of the file to import the theme(s) from.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Import all the themes from single file. Ignored with -n or -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all the themes from separate files (*.json) in the current directory. Ignored with -n or -i or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // import by name\n if (options.file && options.themeName && (await getTokens())) {\n verboseMessage(\n `Importing theme with name \"${\n options.themeName\n }\" into realm \"${state.getRealm()}\"...`\n );\n await importThemeByName(options.themeName, options.file);\n }\n // import by id\n else if (options.file && options.themeId && (await getTokens())) {\n verboseMessage(\n `Importing theme with id \"${\n options.themeId\n }\" into realm \"${state.getRealm()}\"...`\n );\n await importThemeById(options.themeId, options.file);\n }\n // --all -a\n else if (options.all && options.file && (await getTokens())) {\n verboseMessage(\n `Importing all themes from a single file (${options.file})...`\n );\n await importThemesFromFile(options.file);\n }\n // --all-separate -A\n else if (options.allSeparate && !options.file && (await getTokens())) {\n verboseMessage(\n 'Importing all themes from separate files in current directory...'\n );\n importThemesFromFiles();\n }\n // import single theme from file\n else if (options.file && (await getTokens())) {\n verboseMessage(\n `Importing first theme from file \"${\n options.file\n }\" into realm \"${state.getRealm()}\"...`\n );\n await importFirstThemeFromFile(options.file);\n }\n // unrecognized combination of options or no options\n else {\n printMessage(\n 'Unrecognized combination of options or no options...',\n 'error'\n );\n program.help();\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SACEC,wBAAwB,EACxBC,eAAe,EACfC,iBAAiB,EACjBC,oBAAoB,EACpBC,qBAAqB,QAChB,oBAAoB;AAC3B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGX,KAAK,CAACY,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,oBAAoB,CAAC;AAEtDG,OAAO,CACJC,WAAW,CAAC,g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AC,CAAC,EAAE;IAC3DF,cAAc,CACX,4CAA2CY,OAAO,CAACG,IAAK,MAC3D,CAAC;IACD,MAAMlB,oBAAoB,CAACe,OAAO,CAACG,IAAI,CAAC;EAC1C;EACA;EAAA,KACK,IAAIH,OAAO,CAACQ,WAAW,IAAI,CAACR,OAAO,CAACG,IAAI,KAAK,MAAMb,SAAS,CAAC,CAAC,CAAC,EAAE;IACpEF,cAAc,CACZ,kEACF,CAAC;IACDF,qBAAqB,CAAC,CAAC;EACzB;EACA;EAAA,KACK,IAAIc,OAAO,CAACG,IAAI,KAAK,MAAMb,SAAS,CAAC,CAAC,CAAC,EAAE;IAC5CF,cAAc,CACX,oCACCY,OAAO,CAACG,IACT,iBAAgBvB,KAAK,CAACyB,QAAQ,CAAC,CAAE,MACpC,CAAC;IACD,MAAMvB,wBAAwB,CAACkB,OAAO,CAACG,IAAI,CAAC;EAC9C;EACA;EAAA,KACK;IACHhB,YAAY,CACV,sDAAsD,EACtD,OACF,CAAC;IACDK,OAAO,CAACiB,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHnB,OAAO,CAACoB,KAAK,CAAC,CAAC"}
@@ -13,7 +13,7 @@ async (host, realm, user, password, options, command) => {
13
13
  command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
14
14
  if (await getTokens()) {
15
15
  verboseMessage(`Listing themes in realm "${state.getRealm()}"...`);
16
- listThemes(options.long);
16
+ await listThemes(options.long);
17
17
  } else {
18
18
  process.exitCode = 1;
19
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"theme-list.js","names":["frodo","state","Option","listThemes","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","getRealm","long","process","exitCode","parse"],"sources":["../../../src/cli/theme/theme-list.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { listThemes } from '../../ops/ThemeOps';\nimport { verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo theme list');\n\nprogram\n .description('List themes.')\n .addOption(\n new Option('-l, --long', 'Long with more fields.').default(false, 'false')\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n verboseMessage(`Listing themes in realm \"${state.getRealm()}\"...`);\n listThemes(options.long);\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGN,KAAK,CAACO,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,kBAAkB,CAAC;AAEpDG,OAAO,CACJC,WAAW,CAAC,cAAc,CAAC,CAC3BC,SAAS,CACR,IAAIR,MAAM,CAAC,YAAY,EAAE,wBAAwB,CAAC,CAACS,OAAO,CAAC,KAAK,EAAE,OAAO,CAC3E,CAAC,CACAC,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD,IAAI,MAAMZ,SAAS,CAAC,CAAC,EAAE;IACrBF,cAAc,CAAE,4BAA2BH,KAAK,CAACmB,QAAQ,CAAC,CAAE,MAAK,CAAC;IAClEjB,UAAU,CAACc,OAAO,CAACI,IAAI,CAAC;EAC1B,CAAC,MAAM;IACLC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHf,OAAO,CAACgB,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"theme-list.js","names":["frodo","state","Option","listThemes","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","getRealm","long","process","exitCode","parse"],"sources":["../../../src/cli/theme/theme-list.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { listThemes } from '../../ops/ThemeOps';\nimport { verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo theme list');\n\nprogram\n .description('List themes.')\n .addOption(\n new Option('-l, --long', 'Long with more fields.').default(false, 'false')\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n verboseMessage(`Listing themes in realm \"${state.getRealm()}\"...`);\n await listThemes(options.long);\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGN,KAAK,CAACO,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,kBAAkB,CAAC;AAEpDG,OAAO,CACJC,WAAW,CAAC,cAAc,CAAC,CAC3BC,SAAS,CACR,IAAIR,MAAM,CAAC,YAAY,EAAE,wBAAwB,CAAC,CAACS,OAAO,CAAC,KAAK,EAAE,OAAO,CAC3E,CAAC,CACAC,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD,IAAI,MAAMZ,SAAS,CAAC,CAAC,EAAE;IACrBF,cAAc,CAAE,4BAA2BH,KAAK,CAACmB,QAAQ,CAAC,CAAE,MAAK,CAAC;IAClE,MAAMjB,UAAU,CAACc,OAAO,CAACI,IAAI,CAAC;EAChC,CAAC,MAAM;IACLC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHf,OAAO,CAACgB,KAAK,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { frodo } from '@rockcarver/frodo-lib';
2
2
  import fs from 'fs';
3
- import { createProgressBar, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
3
+ import { createProgressIndicator, debugMessage, printMessage, stopProgressIndicator, updateProgressIndicator } from '../utils/Console';
4
4
  import { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
5
5
  const {
6
6
  readAdminFederationProviders,
@@ -48,15 +48,15 @@ export async function exportAdminFederationProviderToFile(providerId, file = '')
48
48
  fileName = getTypedFilename(providerId, 'admin.federation');
49
49
  }
50
50
  const filePath = getFilePath(fileName, true);
51
- createProgressBar(1, `Exporting ${providerId}`);
51
+ const indicatorId = createProgressIndicator('determinate', 1, `Exporting ${providerId}`);
52
52
  try {
53
- updateProgressBar(`Writing file ${filePath}`);
53
+ updateProgressIndicator(indicatorId, `Writing file ${filePath}`);
54
54
  const fileData = await exportAdminFederationProvider(providerId);
55
55
  saveJsonToFile(fileData, filePath);
56
- stopProgressBar(`Exported ${providerId['brightCyan']} to ${filePath['brightCyan']}.`);
56
+ stopProgressIndicator(indicatorId, `Exported ${providerId['brightCyan']} to ${filePath['brightCyan']}.`);
57
57
  outcome = true;
58
58
  } catch (err) {
59
- stopProgressBar(`${err}`);
59
+ stopProgressIndicator(indicatorId, `${err}`);
60
60
  printMessage(`${err}`, 'error');
61
61
  }
62
62
  return outcome;
@@ -69,7 +69,7 @@ export async function exportAdminFederationProviderToFile(providerId, file = '')
69
69
  */
70
70
  export async function exportAdminFederationProvidersToFile(file = '') {
71
71
  let outcome = false;
72
- showSpinner(`Exporting all providers...`);
72
+ const spinnerId = createProgressIndicator('indeterminate', 0, `Exporting all providers...`);
73
73
  try {
74
74
  let fileName = file;
75
75
  if (!fileName) {
@@ -78,11 +78,11 @@ export async function exportAdminFederationProvidersToFile(file = '') {
78
78
  const filePath = getFilePath(fileName, true);
79
79
  const fileData = await exportAdminFederationProviders();
80
80
  saveJsonToFile(fileData, filePath);
81
- succeedSpinner(`Exported all providers to ${filePath}`);
81
+ stopProgressIndicator(spinnerId, `Exported all providers to ${filePath}`, 'success');
82
82
  outcome = true;
83
83
  } catch (error) {
84
84
  var _error$response;
85
- failSpinner(`Error exporting all providers.`);
85
+ stopProgressIndicator(spinnerId, `Error exporting all providers.`, 'fail');
86
86
  printMessage(((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || error, 'error');
87
87
  }
88
88
  return outcome;
@@ -94,20 +94,21 @@ export async function exportAdminFederationProvidersToFile(file = '') {
94
94
  */
95
95
  export async function exportAdminFederationProvidersToFiles() {
96
96
  let outcome = false;
97
+ let indicatorId;
97
98
  try {
98
99
  const allIdpsData = await readAdminFederationProviders();
99
- createProgressBar(allIdpsData.length, 'Exporting providers');
100
+ indicatorId = createProgressIndicator('determinate', allIdpsData.length, 'Exporting providers');
100
101
  for (const idpData of allIdpsData) {
101
- updateProgressBar(`Writing provider ${idpData._id}`);
102
+ updateProgressIndicator(indicatorId, `Writing provider ${idpData._id}`);
102
103
  const fileName = getTypedFilename(idpData._id, 'admin.federation');
103
104
  const fileData = await exportAdminFederationProvider(idpData._id);
104
105
  saveJsonToFile(fileData, getFilePath(fileName, true));
105
106
  }
106
- stopProgressBar(`${allIdpsData.length} providers exported.`);
107
+ stopProgressIndicator(indicatorId, `${allIdpsData.length} providers exported.`);
107
108
  outcome = true;
108
109
  } catch (error) {
109
110
  var _error$response2;
110
- failSpinner(`Error exporting all providers.`);
111
+ stopProgressIndicator(indicatorId, `Error exporting all providers.`, 'fail');
111
112
  printMessage(((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) || error, 'error');
112
113
  }
113
114
  return outcome;
@@ -122,16 +123,16 @@ export async function exportAdminFederationProvidersToFiles() {
122
123
  export async function importAdminFederationProviderFromFile(providerId, file) {
123
124
  let outcome = false;
124
125
  const filePath = getFilePath(file);
125
- showSpinner(`Importing provider ${providerId} from ${filePath}...`);
126
+ const spinnerId = createProgressIndicator('indeterminate', 0, `Importing provider ${providerId} from ${filePath}...`);
126
127
  try {
127
128
  const data = fs.readFileSync(filePath, 'utf8');
128
129
  const fileData = JSON.parse(data);
129
130
  await importAdminFederationProvider(providerId, fileData);
130
- succeedSpinner(`Successfully imported provider ${providerId} from ${filePath}.`);
131
+ stopProgressIndicator(spinnerId, `Successfully imported provider ${providerId} from ${filePath}.`, 'success');
131
132
  outcome = true;
132
133
  } catch (error) {
133
134
  var _error$response3;
134
- failSpinner(`Error importing provider ${providerId} from ${filePath}.`);
135
+ stopProgressIndicator(spinnerId, `Error importing provider ${providerId} from ${filePath}.`, 'fail');
135
136
  printMessage(((_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || error, 'error');
136
137
  }
137
138
  return outcome;
@@ -146,16 +147,16 @@ export async function importFirstAdminFederationProviderFromFile(file) {
146
147
  let outcome = false;
147
148
  debugMessage(`cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: begin`);
148
149
  const filePath = getFilePath(file);
149
- showSpinner(`Importing first provider from ${filePath}...`);
150
+ const spinnerId = createProgressIndicator('indeterminate', 0, `Importing first provider from ${filePath}...`);
150
151
  try {
151
152
  const data = fs.readFileSync(filePath, 'utf8');
152
153
  const fileData = JSON.parse(data);
153
154
  await importFirstAdminFederationProvider(fileData);
154
- succeedSpinner(`Successfully imported first provider from ${filePath}.`);
155
+ stopProgressIndicator(spinnerId, `Successfully imported first provider from ${filePath}.`, 'success');
155
156
  outcome = true;
156
157
  } catch (error) {
157
158
  var _error$response4;
158
- failSpinner(`Error importing first provider from ${filePath}.`);
159
+ stopProgressIndicator(spinnerId, `Error importing first provider from ${filePath}.`, 'fail');
159
160
  printMessage(((_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.data) || error, 'error');
160
161
  }
161
162
  debugMessage(`cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: end`);
@@ -171,16 +172,16 @@ export async function importAdminFederationProvidersFromFile(file) {
171
172
  let outcome = false;
172
173
  debugMessage(`cli.AdminFederationOps.importAdminFederationProvidersFromFile: begin`);
173
174
  const filePath = getFilePath(file);
174
- showSpinner(`Importing providers from ${filePath}...`);
175
+ const spinnerId = createProgressIndicator('indeterminate', 0, `Importing providers from ${filePath}...`);
175
176
  try {
176
177
  const data = fs.readFileSync(filePath, 'utf8');
177
178
  const fileData = JSON.parse(data);
178
179
  await importAdminFederationProviders(fileData);
179
- succeedSpinner(`Imported providers from ${filePath}.`);
180
+ stopProgressIndicator(spinnerId, `Imported providers from ${filePath}.`, 'success');
180
181
  outcome = true;
181
182
  } catch (error) {
182
183
  var _error$response5;
183
- failSpinner(`Error importing ${filePath}.`);
184
+ stopProgressIndicator(spinnerId, `Error importing ${filePath}.`, 'fail');
184
185
  printMessage(((_error$response5 = error.response) === null || _error$response5 === void 0 ? void 0 : _error$response5.data) || error, 'error');
185
186
  }
186
187
  debugMessage(`cli.AdminFederationOps.importAdminFederationProvidersFromFile: end`);
@@ -193,11 +194,12 @@ export async function importAdminFederationProvidersFromFile(file) {
193
194
  */
194
195
  export async function importAdminFederationProvidersFromFiles() {
195
196
  const errors = [];
197
+ let indicatorId;
196
198
  try {
197
199
  debugMessage(`cli.AdminFederationOps.importAdminFederationProvidersFromFiles: begin`);
198
200
  const names = fs.readdirSync(getWorkingDirectory());
199
201
  const files = names.filter(name => name.toLowerCase().endsWith('.admin.federation.json')).map(name => getFilePath(name));
200
- createProgressBar(files.length, 'Importing providers...');
202
+ indicatorId = createProgressIndicator('determinate', files.length, 'Importing providers...');
201
203
  let total = 0;
202
204
  for (const file of files) {
203
205
  try {
@@ -206,17 +208,17 @@ export async function importAdminFederationProvidersFromFiles() {
206
208
  const count = Object.keys(fileData.idp).length;
207
209
  total += count;
208
210
  await importAdminFederationProviders(fileData);
209
- updateProgressBar(`Imported ${count} provider(s) from ${file}`);
211
+ updateProgressIndicator(indicatorId, `Imported ${count} provider(s) from ${file}`);
210
212
  } catch (error) {
211
213
  errors.push(error);
212
- updateProgressBar(`Error importing provider(s) from ${file}`);
214
+ updateProgressIndicator(indicatorId, `Error importing provider(s) from ${file}`);
213
215
  printMessage(error, 'error');
214
216
  }
215
217
  }
216
- stopProgressBar(`Finished importing ${total} provider(s) from ${files.length} file(s).`);
218
+ stopProgressIndicator(indicatorId, `Finished importing ${total} provider(s) from ${files.length} file(s).`);
217
219
  } catch (error) {
218
220
  errors.push(error);
219
- stopProgressBar(`Error importing provider(s) from file(s).`);
221
+ stopProgressIndicator(indicatorId, `Error importing provider(s) from file(s).`);
220
222
  printMessage(error, 'error');
221
223
  }
222
224
  debugMessage(`cli.AdminFederationOps.importAdminFederationProvidersFromFiles: end`);
@@ -1 +1 @@
1
- {"version":3,"file":"AdminFederationOps.js","names":["frodo","fs","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","readAdminFederationProviders","exportAdminFederationProvider","exportAdminFederationProviders","importAdminFederationProvider","importAdminFederationProviders","importFirstAdminFederationProvider","cloud","adminFed","getFilePath","getWorkingDirectory","utils","listAdminFederationProviders","outcome","providers","sort","a","b","_id","localeCompare","forEach","socialIdentityProvider","err","message","exportAdminFederationProviderToFile","providerId","file","fileName","filePath","fileData","exportAdminFederationProvidersToFile","error","_error$response","response","data","exportAdminFederationProvidersToFiles","allIdpsData","length","idpData","_error$response2","importAdminFederationProviderFromFile","readFileSync","JSON","parse","_error$response3","importFirstAdminFederationProviderFromFile","_error$response4","importAdminFederationProvidersFromFile","_error$response5","importAdminFederationProvidersFromFiles","errors","names","readdirSync","files","filter","name","toLowerCase","endsWith","map","total","count","Object","keys","idp","push"],"sources":["../../src/ops/AdminFederationOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\n\nimport {\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\n\nconst {\n readAdminFederationProviders,\n exportAdminFederationProvider,\n exportAdminFederationProviders,\n importAdminFederationProvider,\n importAdminFederationProviders,\n importFirstAdminFederationProvider,\n} = frodo.cloud.adminFed;\n\nconst { getFilePath, getWorkingDirectory } = frodo.utils;\n\n/**\n * List providers\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listAdminFederationProviders(): Promise<boolean> {\n let outcome = false;\n try {\n const providers = await readAdminFederationProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n outcome = true;\n } catch (err) {\n printMessage(`listAdminFederationProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProviderToFile(\n providerId: string,\n file = ''\n): Promise<boolean> {\n let outcome = false;\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'admin.federation');\n }\n const filePath = getFilePath(fileName, true);\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${filePath}`);\n const fileData = await exportAdminFederationProvider(providerId);\n saveJsonToFile(fileData, filePath);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${filePath['brightCyan']}.`\n );\n outcome = true;\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFile(\n file = ''\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Exporting all providers...`);\n try {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allProviders`, 'admin.federation');\n }\n const filePath = getFilePath(fileName, true);\n const fileData = await exportAdminFederationProviders();\n saveJsonToFile(fileData, filePath);\n succeedSpinner(`Exported all providers to ${filePath}`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting all providers.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers to individual files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFiles(): Promise<boolean> {\n let outcome = false;\n try {\n const allIdpsData = await readAdminFederationProviders();\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressBar(`Writing provider ${idpData._id}`);\n const fileName = getTypedFilename(idpData._id, 'admin.federation');\n const fileData = await exportAdminFederationProvider(idpData._id);\n saveJsonToFile(fileData, getFilePath(fileName, true));\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting all providers.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing provider ${providerId} from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importAdminFederationProvider(providerId, fileData);\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${filePath}.`\n );\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstAdminFederationProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: begin`\n );\n const filePath = getFilePath(file);\n showSpinner(`Importing first provider from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstAdminFederationProvider(fileData);\n succeedSpinner(`Successfully imported first provider from ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing first provider from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: end`\n );\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: begin`\n );\n const filePath = getFilePath(file);\n showSpinner(`Importing providers from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importAdminFederationProviders(fileData);\n succeedSpinner(`Imported providers from ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: end`\n );\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFiles(): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: begin`\n );\n const names = fs.readdirSync(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.admin.federation.json'))\n .map((name) => getFilePath(name));\n createProgressBar(files.length, 'Importing providers...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await importAdminFederationProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing provider(s) from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${files.length} file(s).`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing provider(s) from file(s).`);\n printMessage(error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: end`\n );\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAE7E,MAAM;EACJC,4BAA4B;EAC5BC,6BAA6B;EAC7BC,8BAA8B;EAC9BC,6BAA6B;EAC7BC,8BAA8B;EAC9BC;AACF,CAAC,GA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Q,CAAC,wBAAwB,CAAC,CAAC,CACvEC,GAAG,CAAEH,IAAI,IAAK9C,WAAW,CAAC8C,IAAI,CAAC,CAAC;IACnChE,iBAAiB,CAAC8D,KAAK,CAAChB,MAAM,EAAE,wBAAwB,CAAC;IACzD,IAAIsB,KAAK,GAAG,CAAC;IACb,KAAK,MAAMjC,IAAI,IAAI2B,KAAK,EAAE;MACxB,IAAI;QACF,MAAMnB,IAAI,GAAG5C,EAAE,CAACmD,YAAY,CAACf,IAAI,EAAE,MAAM,CAAC;QAC1C,MAAMG,QAAQ,GAAGa,IAAI,CAACC,KAAK,CAACT,IAAI,CAAC;QACjC,MAAM0B,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACjC,QAAQ,CAACkC,GAAG,CAAC,CAAC1B,MAAM;QAC9CsB,KAAK,IAAIC,KAAK;QACd,MAAMvD,8BAA8B,CAACwB,QAAQ,CAAC;QAC9C/B,iBAAiB,CAAE,YAAW8D,KAAM,qBAAoBlC,IAAK,EAAC,CAAC;MACjE,CAAC,CAAC,OAAOK,KAAK,EAAE;QACdmB,MAAM,CAACc,IAAI,CAACjC,KAAK,CAAC;QAClBjC,iBAAiB,CAAE,oCAAmC4B,IAAK,EAAC,CAAC;QAC7DhC,YAAY,CAACqC,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACAnC,eAAe,CACZ,sBAAqB+D,KAAM,qBAAoBN,KAAK,CAAChB,MAAO,WAC/D,CAAC;EACH,CAAC,CAAC,OAAON,KAAK,EAAE;IACdmB,MAAM,CAACc,IAAI,CAACjC,KAAK,CAAC;IAClBnC,eAAe,CAAE,2CAA0C,CAAC;IAC5DF,YAAY,CAACqC,KAAK,EAAE,OAAO,CAAC;EAC9B;EACAvC,YAAY,CACT,qEACH,CAAC;EACD,OAAO,CAAC,KAAK0D,MAAM,CAACb,MAAM;AAC5B"}
1
+ {"version":3,"file":"AdminFederationOps.js","names":["frodo","fs","createProgressIndicator","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","getTypedFilename","saveJsonToFile","readAdminFederationProviders","exportAdminFederationProvider","exportAdminFederationProviders","importAdminFederationProvider","importAdminFederationProviders","importFirstAdminFederationProvider","cloud","adminFed","getFilePath","getWorkingDirectory","utils","listAdminFederationProviders","outcome","providers","sort","a","b","_id","localeCompare","forEach","socialIdentityProvider","err","message","exportAdminFederationProviderToFile","providerId","file","fileName","filePath","indicatorId","fileData","exportAdminFederationProvidersToFile","spinnerId","error","_error$response","response","data","exportAdminFederationProvidersToFiles","allIdpsData","length","idpData","_error$response2","importAdminFederationProviderFromFile","readFileSync","JSON","parse","_error$response3","importFirstAdminFederationProviderFromFile","_error$response4","importAdminFederationProvidersFromFile","_error$response5","importAdminFederationProvidersFromFiles","errors","names","readdirSync","files","filter","name","toLowerCase","endsWith","map","total","count","Object","keys","idp","push"],"sources":["../../src/ops/AdminFederationOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\n\nimport {\n createProgressIndicator,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\n\nconst {\n readAdminFederationProviders,\n exportAdminFederationProvider,\n exportAdminFederationProviders,\n importAdminFederationProvider,\n importAdminFederationProviders,\n importFirstAdminFederationProvider,\n} = frodo.cloud.adminFed;\n\nconst { getFilePath, getWorkingDirectory } = frodo.utils;\n\n/**\n * List providers\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listAdminFederationProviders(): Promise<boolean> {\n let outcome = false;\n try {\n const providers = await readAdminFederationProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n outcome = true;\n } catch (err) {\n printMessage(`listAdminFederationProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProviderToFile(\n providerId: string,\n file = ''\n): Promise<boolean> {\n let outcome = false;\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'admin.federation');\n }\n const filePath = getFilePath(fileName, true);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting ${providerId}`\n );\n try {\n updateProgressIndicator(indicatorId, `Writing file ${filePath}`);\n const fileData = await exportAdminFederationProvider(providerId);\n saveJsonToFile(fileData, filePath);\n stopProgressIndicator(\n indicatorId,\n `Exported ${providerId['brightCyan']} to ${filePath['brightCyan']}.`\n );\n outcome = true;\n } catch (err) {\n stopProgressIndicator(indicatorId, `${err}`);\n printMessage(`${err}`, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFile(\n file = ''\n): Promise<boolean> {\n let outcome = false;\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Exporting all providers...`\n );\n try {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allProviders`, 'admin.federation');\n }\n const filePath = getFilePath(fileName, true);\n const fileData = await exportAdminFederationProviders();\n saveJsonToFile(fileData, filePath);\n stopProgressIndicator(\n spinnerId,\n `Exported all providers to ${filePath}`,\n 'success'\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(spinnerId, `Error exporting all providers.`, 'fail');\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers to individual files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFiles(): Promise<boolean> {\n let outcome = false;\n let indicatorId: string;\n try {\n const allIdpsData = await readAdminFederationProviders();\n indicatorId = createProgressIndicator(\n 'determinate',\n allIdpsData.length,\n 'Exporting providers'\n );\n for (const idpData of allIdpsData) {\n updateProgressIndicator(indicatorId, `Writing provider ${idpData._id}`);\n const fileName = getTypedFilename(idpData._id, 'admin.federation');\n const fileData = await exportAdminFederationProvider(idpData._id);\n saveJsonToFile(fileData, getFilePath(fileName, true));\n }\n stopProgressIndicator(\n indicatorId,\n `${allIdpsData.length} providers exported.`\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error exporting all providers.`,\n 'fail'\n );\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing provider ${providerId} from ${filePath}...`\n );\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importAdminFederationProvider(providerId, fileData);\n stopProgressIndicator(\n spinnerId,\n `Successfully imported provider ${providerId} from ${filePath}.`,\n 'success'\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(\n spinnerId,\n `Error importing provider ${providerId} from ${filePath}.`,\n 'fail'\n );\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstAdminFederationProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: begin`\n );\n const filePath = getFilePath(file);\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing first provider from ${filePath}...`\n );\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstAdminFederationProvider(fileData);\n stopProgressIndicator(\n spinnerId,\n `Successfully imported first provider from ${filePath}.`,\n 'success'\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(\n spinnerId,\n `Error importing first provider from ${filePath}.`,\n 'fail'\n );\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: end`\n );\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: begin`\n );\n const filePath = getFilePath(file);\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing providers from ${filePath}...`\n );\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importAdminFederationProviders(fileData);\n stopProgressIndicator(\n spinnerId,\n `Imported providers from ${filePath}.`,\n 'success'\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(spinnerId, `Error importing ${filePath}.`, 'fail');\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: end`\n );\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFiles(): Promise<boolean> {\n const errors = [];\n let indicatorId: string;\n try {\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: begin`\n );\n const names = fs.readdirSync(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.admin.federation.json'))\n .map((name) => getFilePath(name));\n indicatorId = createProgressIndicator(\n 'determinate',\n files.length,\n 'Importing providers...'\n );\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await importAdminFederationProviders(fileData);\n updateProgressIndicator(\n indicatorId,\n `Imported ${count} provider(s) from ${file}`\n );\n } catch (error) {\n errors.push(error);\n updateProgressIndicator(\n indicatorId,\n `Error importing provider(s) from ${file}`\n );\n printMessage(error, 'error');\n }\n }\n stopProgressIndicator(\n indicatorId,\n `Finished importing ${total} provider(s) from ${files.length} file(s).`\n );\n } catch (error) {\n errors.push(error);\n stopProgressIndicator(\n indicatorId,\n `Error importing provider(s) from file(s).`\n );\n printMessage(error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: end`\n );\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,uBAAuB,EACvBC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,QAClB,kBAAkB;AACzB,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAE7E,MAAM;EACJC,4BAA4B;EAC5BC,6BAA6B;EAC7BC,8BAA8B;EAC9BC,6BAA6B;EAC7BC,8BAA8B;EAC9BC;AACF,CAAC,GAAGd,KAAK,CAACe,KAAK,CAACC,QAAQ;AAExB,MAAM;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GAAGlB,KAAK,CAACmB,KAAK;;AAExD;AACA;AACA;AACA;AACA,OAAO,eAAeC,4BAA4BA,CAAA,EAAqB;EACrE,IAAIC,OAAO,GAAG,KAAK;EACnB,IAAI;IACF,MAAMC,SAAS,GAAG,MAAMb,4BAA4B,CAAC,CAAC;IACtDa,SAAS,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IACpDJ,SAAS,CAACM,OAAO,CAAEC,sBAAsB,IAAK;MAC5CzB,YAAY,CAAE,GAAEyB,sBAAsB,CAACH,GAAI,EAAC,EAAE,MAAM,CAAC;IACvD,CAAC,CAAC;IACFL,OAAO,GAAG,IAAI;EAChB,CAAC,CAAC,O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rockcarver/frodo-lib';
2
+ import fs from 'fs';
3
+ import { extractScriptToFile } from './ScriptOps';
4
+ const {
5
+ getRealmName,
6
+ getTypedFilename,
7
+ titleCase,
8
+ saveJsonToFile,
9
+ getFilePath,
10
+ getWorkingDirectory
11
+ } = frodo.utils;
12
+ const {
13
+ exportFullConfiguration
14
+ } = frodo.admin;
15
+
16
+ /**
17
+ * Export everything to separate files
18
+ * @param file file name
19
+ * @param {FullExportOptions} options export options
20
+ */
21
+ export async function exportEverythingToFile(file, options = {
22
+ useStringArrays: true,
23
+ noDecode: false
24
+ }) {
25
+ const exportData = await exportFullConfiguration(options);
26
+ let fileName = getTypedFilename(`${titleCase(getRealmName(state.getRealm()))}`, `everything`);
27
+ if (file) {
28
+ fileName = file;
29
+ }
30
+ saveJsonToFile(exportData, getFilePath(fileName, true));
31
+ }
32
+
33
+ /**
34
+ * Export everything to separate files
35
+ * @param extract Extracts the scripts from the exports into separate files if true
36
+ * @param {FullExportOptions} options export options
37
+ */
38
+ export async function exportEverythingToFiles(extract = false, options = {
39
+ useStringArrays: true,
40
+ noDecode: false
41
+ }) {
42
+ const exportData = await exportFullConfiguration(options);
43
+ delete exportData.meta;
44
+ const baseDirectory = getWorkingDirectory(true);
45
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
46
+ Object.entries(exportData).forEach(([type, obj]) => {
47
+ if (obj) {
48
+ if (!fs.existsSync(`${baseDirectory}/${type}`)) {
49
+ fs.mkdirSync(`${baseDirectory}/${type}`);
50
+ }
51
+ if (type == 'saml') {
52
+ const samlData = {
53
+ saml: {
54
+ cot: {},
55
+ hosted: {},
56
+ metadata: {},
57
+ remote: {}
58
+ }
59
+ };
60
+ if (obj.cot) {
61
+ if (!fs.existsSync(`${baseDirectory}/cot`)) {
62
+ fs.mkdirSync(`${baseDirectory}/cot`);
63
+ }
64
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
+ Object.entries(obj.cot).forEach(([id, value]) => {
66
+ samlData.saml.cot = {
67
+ [id]: value
68
+ };
69
+ saveJsonToFile(samlData, `${baseDirectory}/cot/${getTypedFilename(id, 'cot.saml')}`);
70
+ });
71
+ samlData.saml.cot = {};
72
+ }
73
+ Object.entries(obj.hosted).concat(Object.entries(obj.remote))
74
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
+ .forEach(([id, value]) => {
76
+ const filename = getTypedFilename(value.entityId ? value.entityId : id, type);
77
+ const samlType = obj.hosted[id] ? 'hosted' : 'remote';
78
+ samlData.saml[samlType][id] = value;
79
+ samlData.saml.metadata = {
80
+ [id]: obj.metadata[id]
81
+ };
82
+ saveJsonToFile(samlData, `${baseDirectory}/${type}/${filename}`);
83
+ samlData.saml[samlType] = {};
84
+ });
85
+ } else if (type == 'authentication') {
86
+ const fileName = getTypedFilename(`${frodo.utils.getRealmName(state.getRealm())}Realm`, 'authentication.settings');
87
+ saveJsonToFile({
88
+ authentication: obj
89
+ }, `${baseDirectory}/${type}/${fileName}`);
90
+ } else {
91
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
+ Object.entries(obj).forEach(([id, value]) => {
93
+ const filename = type == 'config' ? `${id}.json` : getTypedFilename(value.name ? value.name : id, type);
94
+ if (type == 'config' && filename.includes('/')) {
95
+ fs.mkdirSync(`${baseDirectory}/${type}/${filename.slice(0, filename.lastIndexOf('/'))}`, {
96
+ recursive: true
97
+ });
98
+ }
99
+ if (extract && type == 'script') {
100
+ extractScriptToFile(exportData, id, type);
101
+ }
102
+ saveJsonToFile({
103
+ [type]: {
104
+ [id]: value
105
+ }
106
+ }, `${baseDirectory}/${type}/${filename}`);
107
+ });
108
+ }
109
+ }
110
+ });
111
+ }
112
+ //# sourceMappingURL=AdminOps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdminOps.js","names":["frodo","state","fs","extractScriptToFile","getRealmName","getTypedFilename","titleCase","saveJsonToFile","getFilePath","getWorkingDirectory","utils","exportFullConfiguration","admin","exportEverythingToFile","file","options","useStringArrays","noDecode","exportData","fileName","getRealm","exportEverythingToFiles","extract","meta","baseDirectory","Object","entries","forEach","type","obj","existsSync","mkdirSync","samlData","saml","cot","hosted","metadata","remote","id","value","concat","filename","entityId","samlType","authentication","name","includes","slice","lastIndexOf","recursive"],"sources":["../../src/ops/AdminOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport {\n FullExportInterface,\n FullExportOptions,\n} from '@rockcarver/frodo-lib/types/ops/AdminOps';\nimport { ScriptExportInterface } from '@rockcarver/frodo-lib/types/ops/ScriptOps';\nimport fs from 'fs';\n\nimport { extractScriptToFile } from './ScriptOps';\n\nconst {\n getRealmName,\n getTypedFilename,\n titleCase,\n saveJsonToFile,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst { exportFullConfiguration } = frodo.admin;\n\n/**\n * Export everything to separate files\n * @param file file name\n * @param {FullExportOptions} options export options\n */\nexport async function exportEverythingToFile(\n file,\n options: FullExportOptions = {\n useStringArrays: true,\n noDecode: false,\n }\n): Promise<void> {\n const exportData = await exportFullConfiguration(options);\n let fileName = getTypedFilename(\n `${titleCase(getRealmName(state.getRealm()))}`,\n `everything`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, getFilePath(fileName, true));\n}\n\n/**\n * Export everything to separate files\n * @param extract Extracts the scripts from the exports into separate files if true\n * @param {FullExportOptions} options export options\n */\nexport async function exportEverythingToFiles(\n extract = false,\n options: FullExportOptions = {\n useStringArrays: true,\n noDecode: false,\n }\n): Promise<void> {\n const exportData: FullExportInterface =\n await exportFullConfiguration(options);\n delete exportData.meta;\n const baseDirectory = getWorkingDirectory(true);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(exportData).forEach(([type, obj]: [string, any]) => {\n if (obj) {\n if (!fs.existsSync(`${baseDirectory}/${type}`)) {\n fs.mkdirSync(`${baseDirectory}/${type}`);\n }\n if (type == 'saml') {\n const samlData = {\n saml: {\n cot: {},\n hosted: {},\n metadata: {},\n remote: {},\n },\n };\n if (obj.cot) {\n if (!fs.existsSync(`${baseDirectory}/cot`)) {\n fs.mkdirSync(`${baseDirectory}/cot`);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(obj.cot).forEach(([id, value]: [string, any]) => {\n samlData.saml.cot = {\n [id]: value,\n };\n saveJsonToFile(\n samlData,\n `${baseDirectory}/cot/${getTypedFilename(id, 'cot.saml')}`\n );\n });\n samlData.saml.cot = {};\n }\n Object.entries(obj.hosted)\n .concat(Object.entries(obj.remote))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .forEach(([id, value]: [string, any]) => {\n const filename = getTypedFilename(\n value.entityId ? value.entityId : id,\n type\n );\n const samlType = obj.hosted[id] ? 'hosted' : 'remote';\n samlData.saml[samlType][id] = value;\n samlData.saml.metadata = {\n [id]: obj.metadata[id],\n };\n saveJsonToFile(samlData, `${baseDirectory}/${type}/${filename}`);\n samlData.saml[samlType] = {};\n });\n } else if (type == 'authentication') {\n const fileName = getTypedFilename(\n `${frodo.utils.getRealmName(state.getRealm())}Realm`,\n 'authentication.settings'\n );\n saveJsonToFile(\n {\n authentication: obj,\n },\n `${baseDirectory}/${type}/${fileName}`\n );\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(obj).forEach(([id, value]: [string, any]) => {\n const filename =\n type == 'config'\n ? `${id}.json`\n : getTypedFilename(value.name ? value.name : id, type);\n if (type == 'config' && filename.includes('/')) {\n fs.mkdirSync(\n `${baseDirectory}/${type}/${filename.slice(\n 0,\n filename.lastIndexOf('/')\n )}`,\n {\n recursive: true,\n }\n );\n }\n if (extract && type == 'script') {\n extractScriptToFile(exportData as ScriptExportInterface, id, type);\n }\n saveJsonToFile(\n {\n [type]: {\n [id]: value,\n },\n },\n `${baseDirectory}/${type}/${filename}`\n );\n });\n }\n }\n });\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAMpD,OAAOC,EAAE,MAAM,IAAI;AAEn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