@rockcarver/frodo-cli 0.19.3-1 → 0.19.3-3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.19.3-3] - 2023-01-07
11
+
12
+ ## [0.19.3-2] - 2023-01-05
13
+
10
14
  ## [0.19.3-1] - 2022-12-31
11
15
 
12
16
  ## [0.19.3-0] - 2022-12-31
@@ -835,7 +839,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
835
839
  - Fixed problem with adding connection profiles
836
840
  - Miscellaneous bug fixes
837
841
 
838
- [Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.19.3-1...HEAD
842
+ [Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.19.3-3...HEAD
843
+
844
+ [0.19.3-3]: https://github.com/rockcarver/frodo-cli/compare/v0.19.3-2...v0.19.3-3
845
+
846
+ [0.19.3-2]: https://github.com/rockcarver/frodo-cli/compare/v0.19.3-1...v0.19.3-2
839
847
 
840
848
  [0.19.3-1]: https://github.com/rockcarver/frodo-cli/compare/v0.19.3-0...v0.19.3-1
841
849
 
@@ -2,7 +2,7 @@ import { FrodoCommand } from '../FrodoCommand';
2
2
  import { Option } from 'commander';
3
3
  import { Authenticate } from '@rockcarver/frodo-lib';
4
4
  import { printMessage, verboseMessage } from '../../utils/Console';
5
- import { exportAllConfigEntities, exportAllRawConfigEntities, exportConfigEntity } from '../../ops/IdmOps';
5
+ import { exportAllConfigEntities, exportAllRawConfigEntities, exportConfigEntity, warnAboutOfflineConnectorServers } from '../../ops/IdmOps';
6
6
  const {
7
7
  getTokens
8
8
  } = Authenticate;
@@ -20,11 +20,13 @@ async (host, realm, user, password, options, command) => {
20
20
  else if (options.allSeparate && options.directory && options.entitiesFile && options.envFile && (await getTokens())) {
21
21
  verboseMessage(`Exporting IDM configuration objects specified in ${options.entitiesFile} into separate files in ${options.directory} using ${options.envFile} for variable replacement...`);
22
22
  exportAllConfigEntities(options.directory, options.entitiesFile, options.envFile);
23
+ warnAboutOfflineConnectorServers();
23
24
  }
24
25
  // --all-separate -A without variable replacement
25
26
  else if (options.allSeparate && options.directory && (await getTokens())) {
26
27
  verboseMessage(`Exporting all IDM configuration objects into separate files in ${options.directory}...`);
27
28
  exportAllRawConfigEntities(options.directory);
29
+ warnAboutOfflineConnectorServers();
28
30
  }
29
31
  // unrecognized combination of options or no options
30
32
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"idm-export.js","names":["FrodoCommand","Option","Authenticate","printMessage","verboseMessage","exportAllConfigEntities","exportAllRawConfigEntities","exportConfigEntity","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","name","file","allSeparate","directory","entitiesFile","envFile","help","process","exitCode","parse"],"sources":["cli/idm/idm-export.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport {\n exportAllConfigEntities,\n exportAllRawConfigEntities,\n exportConfigEntity,\n} from '../../ops/IdmOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo idm export');\n\nprogram\n .description('Export IDM configuration objects.')\n .addOption(\n new Option(\n '-N, --name <name>',\n 'Config entity name. E.g. \"managed\", \"sync\", \"provisioner-<connector-name>\", etc.'\n )\n )\n .addOption(new Option('-f, --file [file]', 'Export file. Ignored with -A.'))\n .addOption(\n new Option(\n '-E, --entities-file [entities-file]',\n 'Name of the entity file. Ignored with -A.'\n )\n )\n .addOption(\n new Option(\n '-e, --env-file [envfile]',\n 'Name of the env file. Ignored with -A.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Export all IDM configuration objects into a single file in directory -D. Ignored with -N.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all IDM configuration objects into separate JSON files in directory -D. Ignored with -N, and -a.'\n )\n )\n .addOption(\n new Option(\n '-D, --directory <directory>',\n 'Export directory. Required with and ignored without -a/-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 // export by id/name\n if (options.name && (await getTokens())) {\n verboseMessage(`Exporting object \"${options.name}\"...`);\n exportConfigEntity(options.name, options.file);\n }\n // --all-separate -A\n else if (\n options.allSeparate &&\n options.directory &&\n options.entitiesFile &&\n options.envFile &&\n (await getTokens())\n ) {\n verboseMessage(\n `Exporting IDM configuration objects specified in ${options.entitiesFile} into separate files in ${options.directory} using ${options.envFile} for variable replacement...`\n );\n exportAllConfigEntities(\n options.directory,\n options.entitiesFile,\n options.envFile\n );\n }\n // --all-separate -A without variable replacement\n else if (\n options.allSeparate &&\n options.directory &&\n (await getTokens())\n ) {\n verboseMessage(\n `Exporting all IDM configuration objects into separate files in ${options.directory}...`\n );\n exportAllRawConfigEntities(options.directory);\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,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SACEC,uBAAuB,EACvBC,0BAA0B,EAC1BC,kBAAkB,QACb,kBAAkB;AAEzB,MAAM;EAAEC;AAAU,CAAC,GAAGN,YAAY;AAElC,MAAMO,OAAO,GAAG,IAAIT,YAAY,CAAC,kBAAkB,CAAC;AAEpDS,OAAO,CACJC,WAAW,CAAC,mCAAmC,CAAC,CAChDC,SAAS,CACR,IAAIV,M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P,OAAO,CAACQ,OAAO,CAChB;EACH;EACA;EAAA,KACK,IACHR,OAAO,CAACK,WAAW,IACnBL,OAAO,CAACM,SAAS,KAChB,MAAMf,SAAS,EAAE,CAAC,EACnB;IACAJ,cAAc,CACX,kEAAiEa,OAAO,CAACM,SAAU,KAAI,CACzF;IACDjB,0BAA0B,CAACW,OAAO,CAACM,SAAS,CAAC;EAC/C;EACA;EAAA,KACK;IACHpB,YAAY,CACV,sDAAsD,EACtD,OAAO,CACR;IACDM,OAAO,CAACiB,IAAI,EAAE;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHnB,OAAO,CAACoB,KAAK,EAAE"}
1
+ {"version":3,"file":"idm-export.js","names":["FrodoCommand","Option","Authenticate","printMessage","verboseMessage","exportAllConfigEntities","exportAllRawConfigEntities","exportConfigEntity","warnAboutOfflineConnectorServers","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","name","file","allSeparate","directory","entitiesFile","envFile","help","process","exitCode","parse"],"sources":["cli/idm/idm-export.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport {\n exportAllConfigEntities,\n exportAllRawConfigEntities,\n exportConfigEntity,\n warnAboutOfflineConnectorServers,\n} from '../../ops/IdmOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo idm export');\n\nprogram\n .description('Export IDM configuration objects.')\n .addOption(\n new Option(\n '-N, --name <name>',\n 'Config entity name. E.g. \"managed\", \"sync\", \"provisioner-<connector-name>\", etc.'\n )\n )\n .addOption(new Option('-f, --file [file]', 'Export file. Ignored with -A.'))\n .addOption(\n new Option(\n '-E, --entities-file [entities-file]',\n 'Name of the entity file. Ignored with -A.'\n )\n )\n .addOption(\n new Option(\n '-e, --env-file [envfile]',\n 'Name of the env file. Ignored with -A.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Export all IDM configuration objects into a single file in directory -D. Ignored with -N.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all IDM configuration objects into separate JSON files in directory -D. Ignored with -N, and -a.'\n )\n )\n .addOption(\n new Option(\n '-D, --directory <directory>',\n 'Export directory. Required with and ignored without -a/-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 // export by id/name\n if (options.name && (await getTokens())) {\n verboseMessage(`Exporting object \"${options.name}\"...`);\n exportConfigEntity(options.name, options.file);\n }\n // --all-separate -A\n else if (\n options.allSeparate &&\n options.directory &&\n options.entitiesFile &&\n options.envFile &&\n (await getTokens())\n ) {\n verboseMessage(\n `Exporting IDM configuration objects specified in ${options.entitiesFile} into separate files in ${options.directory} using ${options.envFile} for variable replacement...`\n );\n exportAllConfigEntities(\n options.directory,\n options.entitiesFile,\n options.envFile\n );\n warnAboutOfflineConnectorServers();\n }\n // --all-separate -A without variable replacement\n else if (\n options.allSeparate &&\n options.directory &&\n (await getTokens())\n ) {\n verboseMessage(\n `Exporting all IDM configuration objects into separate files in ${options.directory}...`\n );\n exportAllRawConfigEntities(options.directory);\n warnAboutOfflineConnectorServers();\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,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SACEC,uBAAuB,EACvBC,0BAA0B,EAC1BC,kBAAkB,EAClBC,gCAAgC,QAC3B,kBAAkB;AAEzB,MAAM;EAAEC;AAAU,C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O,YAAa,2BAA0BP,OAAO,CAACM,SAAU,UAASN,OAAO,CAACQ,OAAQ,8BAA6B,CAC5K;IACDrB,uBAAuB,CACrBa,OAAO,CAACM,SAAS,EACjBN,OAAO,CAACO,YAAY,EACpBP,OAAO,CAACQ,OAAO,CAChB;IACDlB,gCAAgC,EAAE;EACpC;EACA;EAAA,KACK,IACHU,OAAO,CAACK,WAAW,IACnBL,OAAO,CAACM,SAAS,KAChB,MAAMf,SAAS,EAAE,CAAC,EACnB;IACAL,cAAc,CACX,kEAAiEc,OAAO,CAACM,SAAU,KAAI,CACzF;IACDlB,0BAA0B,CAACY,OAAO,CAACM,SAAS,CAAC;IAC7ChB,gCAAgC,EAAE;EACpC;EACA;EAAA,KACK;IACHL,YAAY,CACV,sDAAsD,EACtD,OAAO,CACR;IACDO,OAAO,CAACiB,IAAI,EAAE;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHnB,OAAO,CAACoB,KAAK,EAAE"}
@@ -1,7 +1,7 @@
1
1
  import { FrodoCommand } from '../FrodoCommand';
2
2
  import { Authenticate } from '@rockcarver/frodo-lib';
3
3
  import { verboseMessage } from '../../utils/Console';
4
- import { listAllConfigEntities } from '../../ops/IdmOps';
4
+ import { listAllConfigEntities, warnAboutOfflineConnectorServers } from '../../ops/IdmOps';
5
5
  const {
6
6
  getTokens
7
7
  } = Authenticate;
@@ -17,6 +17,7 @@ async (host, realm, user, password, options, command) => {
17
17
  if (await getTokens()) {
18
18
  verboseMessage('Listing all IDM configuration objects...');
19
19
  listAllConfigEntities();
20
+ warnAboutOfflineConnectorServers();
20
21
  } else {
21
22
  process.exitCode = 1;
22
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"idm-list.js","names":["FrodoCommand","Authenticate","verboseMessage","listAllConfigEntities","getTokens","program","description","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","process","exitCode","parse"],"sources":["cli/idm/idm-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console';\nimport { listAllConfigEntities } from '../../ops/IdmOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo idm list');\n\nprogram\n .description('List IDM configuration objects.')\n // .addOption(\n // new Option('-l, --long', 'Long with all 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 all IDM configuration objects...');\n listAllConfigEntities();\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,qBAAqB,QAAQ,kBAAkB;AAExD,MAAM;EAAEC;AAAU,CAAC,GAAGH,YAAY;AAElC,MAAMI,OAAO,GAAG,IAAIL,YAAY,CAAC,gBAAgB,CAAC;AAElDK,OAAO,CACJC,WAAW,CAAC,iCAAiC;AAC9C;AACA;AACA;AAAA,CACCC,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,OAAO,CACR;EACD,IAAI,MAAMT,SAAS,EAAE,EAAE;IACrBF,cAAc,CAAC,0CAA0C,CAAC;IAC1DC,qBAAqB,EAAE;EACzB,CAAC,MAAM;IACLY,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHX,OAAO,CAACY,KAAK,EAAE"}
1
+ {"version":3,"file":"idm-list.js","names":["FrodoCommand","Authenticate","verboseMessage","listAllConfigEntities","warnAboutOfflineConnectorServers","getTokens","program","description","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","process","exitCode","parse"],"sources":["cli/idm/idm-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console';\nimport {\n listAllConfigEntities,\n warnAboutOfflineConnectorServers,\n} from '../../ops/IdmOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo idm list');\n\nprogram\n .description('List IDM configuration objects.')\n // .addOption(\n // new Option('-l, --long', 'Long with all 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 all IDM configuration objects...');\n listAllConfigEntities();\n warnAboutOfflineConnectorServers();\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SACEC,qBAAqB,EACrBC,gCAAgC,QAC3B,kBAAkB;AAEzB,MAAM;EAAEC;AAAU,CAAC,GAAGJ,YAAY;AAElC,MAAMK,OAAO,GAAG,IAAIN,YAAY,CAAC,gBAAgB,CAAC;AAElDM,OAAO,CACJC,WAAW,CAAC,iCAAiC;AAC9C;AACA;AACA;AAAA,CACCC,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,OAAO,CACR;EACD,IAAI,MAAMT,SAAS,EAAE,EAAE;IACrBH,cAAc,CAAC,0CAA0C,CAAC;IAC1DC,qBAAqB,EAAE;IACvBC,gCAAgC,EAAE;EACpC,CAAC,MAAM;IACLY,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHX,OAAO,CAACY,KAAK,EAAE"}
@@ -1,19 +1,11 @@
1
1
  import { FrodoCommand } from '../FrodoCommand';
2
2
  import { Option } from 'commander';
3
- import { Authenticate, Script } from '@rockcarver/frodo-lib';
3
+ import { Authenticate } from '@rockcarver/frodo-lib';
4
4
  import { printMessage, verboseMessage } from '../../utils/Console';
5
+ import { exportScriptByNameToFile, exportScriptsToFile, exportScriptsToFiles } from '../../ops/ScriptOps';
5
6
  const {
6
7
  getTokens
7
8
  } = Authenticate;
8
- const {
9
- exportScriptByName
10
- } = Script;
11
- const {
12
- exportScriptsToFile
13
- } = Script;
14
- const {
15
- exportScriptsToFiles
16
- } = Script;
17
9
  const program = new FrodoCommand('frodo script export');
18
10
  program.description('Export scripts.').addOption(new Option('-n, --script-name <name>', 'Name of the script. If specified, -a and -A are ignored.'))
19
11
  // .addOption(
@@ -31,17 +23,17 @@ async (host, realm, user, password, options, command) => {
31
23
  // export by name
32
24
  if ((options.scriptName || options.script) && (await getTokens())) {
33
25
  verboseMessage('Exporting script...');
34
- exportScriptByName(options.scriptName || options.script, options.file);
26
+ await exportScriptByNameToFile(options.scriptName || options.script, options.file);
35
27
  }
36
28
  // -a / --all
37
29
  else if (options.all && (await getTokens())) {
38
30
  verboseMessage('Exporting all scripts to a single file...');
39
- exportScriptsToFile(options.file);
31
+ await exportScriptsToFile(options.file);
40
32
  }
41
33
  // -A / --all-separate
42
34
  else if (options.allSeparate && (await getTokens())) {
43
35
  verboseMessage('Exporting all scripts to separate files...');
44
- exportScriptsToFiles();
36
+ await exportScriptsToFiles();
45
37
  }
46
38
  // unrecognized combination of options or no options
47
39
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"script-export.js","names":["FrodoCommand","Option","Authenticate","Script","printMessage","verboseMessage","getTokens","exportScriptByName","exportScriptsToFile","exportScriptsToFiles","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","scriptName","script","file","all","allSeparate","help","process","exitCode","parse"],"sources":["cli/script/script-export.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate, Script } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\nconst { exportScriptByName } = Script;\nconst { exportScriptsToFile } = Script;\nconst { exportScriptsToFiles } = Script;\n\nconst program = new FrodoCommand('frodo script export');\n\nprogram\n .description('Export scripts.')\n .addOption(\n new Option(\n '-n, --script-name <name>',\n 'Name of the script. If specified, -a and -A are ignored.'\n )\n )\n // .addOption(\n // new Option(\n // '-i, --script-id <uuid>',\n // 'Uuid of the script. If specified, -a and -A are ignored.'\n // )\n // )\n .addOption(new Option('-f, --file <file>', 'Name of the export file.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Export all scripts to a single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all scripts to separate files (*.script.json) in the current directory. Ignored with -i or -a.'\n )\n )\n // deprecated option\n .addOption(\n new Option(\n '-s, --script <script>',\n 'DEPRECATED! Use -n/--script-name instead. Name of the script.'\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 // export by name\n if ((options.scriptName || options.script) && (await getTokens())) {\n verboseMessage('Exporting script...');\n exportScriptByName(options.scriptName || options.script, options.file);\n }\n // -a / --all\n else if (options.all && (await getTokens())) {\n verboseMessage('Exporting all scripts to a single file...');\n exportScriptsToFile(options.file);\n }\n // -A / --all-separate\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting all scripts to separate files...');\n exportScriptsToFiles();\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,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,EAAEC,MAAM,QAAQ,uBAAuB;AAC5D,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAElE,MAAM;EAAEC;AAAU,CAAC,GAAGJ,YAAY;AAClC,MAAM;EAAEK;AAAmB,CAAC,GAAGJ,MAAM;AACrC,MAAM;EAAEK;AAAoB,CAAC,GAAGL,MAAM;AACtC,MAAM;EAAEM;AAAqB,CAAC,GAAGN,MAAM;AAEvC,MAAMO,OAAO,GAAG,IAAIV,YAAY,CAAC,qBAAqB,CAAC;AAEvDU,OAAO,CACJC,WAAW,CAAC,iBAAiB,CAAC,CAC9BC,SAAS,CACR,IAAIX,MAAM,CACR,0BAA0B,EAC1B,0DAA0D,CAC3D;AAEH;AACA;AACA;AACA;AACA;AACA;AAAA,CACCW,SAAS,CAAC,IAAIX,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC,CAAC,CACtEW,SAAS,CACR,IAAIX,MAAM,CACR,WAAW,EACX,uDAAuD,CACxD,CACF,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,oBAAoB,EACpB,uGAAuG,CACxG;AAEH;AAAA,CACCW,SAAS,CACR,IAAIX,MAAM,CACR,uBAAuB,EACvB,+DAA+D,CAChE,CACF,CACAY,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,OAAO,CACR;EACD;EACA,IAAI,CAACD,OAAO,CAACG,UAAU,IAAIH,OAAO,CAACI,MAAM,MAAM,MAAMhB,SAAS,EAAE,CAAC,EAAE;IACjED,cAAc,CAAC,qBAAqB,CAAC;IACrCE,kBAAkB,CAACW,OAAO,CAACG,UAAU,IAAIH,OAAO,CAACI,MAAM,EAAEJ,OAAO,CAACK,IAAI,CAAC;EACxE;EACA;EAAA,KACK,IAAIL,OAAO,CAACM,GAAG,KAAK,MAAMlB,SAAS,EAAE,CAAC,EAAE;IAC3CD,cAAc,CAAC,2CAA2C,CAAC;IAC3DG,mBAAmB,CAACU,OAAO,CAACK,IAAI,CAAC;EACnC;EACA;EAAA,KACK,IAAIL,OAAO,CAACO,WAAW,KAAK,MAAMnB,SAAS,EAAE,CAAC,EAAE;IACnDD,cAAc,CAAC,4CAA4C,CAAC;IAC5DI,oBAAoB,EAAE;EACxB;EACA;EAAA,KACK;IACHL,YAAY,CACV,sDAAsD,EACtD,OAAO,CACR;IACDM,OAAO,CAACgB,IAAI,EAAE;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHlB,OAAO,CAACmB,KAAK,EAAE"}
1
+ {"version":3,"file":"script-export.js","names":["FrodoCommand","Option","Authenticate","printMessage","verboseMessage","exportScriptByNameToFile","exportScriptsToFile","exportScriptsToFiles","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","scriptName","script","file","all","allSeparate","help","process","exitCode","parse"],"sources":["cli/script/script-export.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport {\n exportScriptByNameToFile,\n exportScriptsToFile,\n exportScriptsToFiles,\n} from '../../ops/ScriptOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo script export');\n\nprogram\n .description('Export scripts.')\n .addOption(\n new Option(\n '-n, --script-name <name>',\n 'Name of the script. If specified, -a and -A are ignored.'\n )\n )\n // .addOption(\n // new Option(\n // '-i, --script-id <uuid>',\n // 'Uuid of the script. If specified, -a and -A are ignored.'\n // )\n // )\n .addOption(new Option('-f, --file <file>', 'Name of the export file.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Export all scripts to a single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all scripts to separate files (*.script.json) in the current directory. Ignored with -i or -a.'\n )\n )\n // deprecated option\n .addOption(\n new Option(\n '-s, --script <script>',\n 'DEPRECATED! Use -n/--script-name instead. Name of the script.'\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 // export by name\n if ((options.scriptName || options.script) && (await getTokens())) {\n verboseMessage('Exporting script...');\n await exportScriptByNameToFile(\n options.scriptName || options.script,\n options.file\n );\n }\n // -a / --all\n else if (options.all && (await getTokens())) {\n verboseMessage('Exporting all scripts to a single file...');\n await exportScriptsToFile(options.file);\n }\n // -A / --all-separate\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting all scripts to separate files...');\n await exportScriptsToFiles();\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,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SACEC,wBAAwB,EACxBC,mBAAmB,EACnBC,oBAAoB,QACf,qBAAqB;AAE5B,MAAM;EAAEC;AAAU,CAAC,GAAGN,YAAY;AAElC,MAAMO,OAAO,GAAG,IAAIT,YAAY,CAAC,qBAAqB,CAAC;AAEvDS,OAAO,CACJC,WAAW,CAAC,iBAAiB,C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CACR;IACDM,OAAO,CAACgB,IAAI,EAAE;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHlB,OAAO,CAACmB,KAAK,EAAE"}
@@ -1,13 +1,11 @@
1
1
  import { FrodoCommand } from '../FrodoCommand';
2
2
  import { Option } from 'commander';
3
- import { Authenticate, Script, state } from '@rockcarver/frodo-lib';
3
+ import { Authenticate, state } from '@rockcarver/frodo-lib';
4
4
  import { verboseMessage } from '../../utils/Console';
5
+ import { importScriptsFromFile } from '../../ops/ScriptOps';
5
6
  const {
6
7
  getTokens
7
8
  } = Authenticate;
8
- const {
9
- importScriptsFromFile
10
- } = Script;
11
9
  const program = new FrodoCommand('frodo script import');
12
10
  program.description('Import scripts.').addOption(new Option('-f, --file <file>', 'Name of the file to import.')).addOption(new Option('-n, --script-name <name>', 'Name of the script. If specified, -a and -A are ignored.')).addOption(new Option('--re-uuid', 'Re-UUID. Create a new UUID for the script upon import. Use this to duplicate a script or create a new version of the same script. Note that you must also choose a new name using -n/--script-name to avoid import errors.').default(false, 'false'))
13
11
  // deprecated option
@@ -1 +1 @@
1
- {"version":3,"file":"script-import.js","names":["FrodoCommand","Option","Authenticate","Script","state","verboseMessage","getTokens","importScriptsFromFile","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","getRealm","scriptName","script","file","reUuid","process","exitCode","parse"],"sources":["cli/script/script-import.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate, Script, state } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\n\nconst { importScriptsFromFile } = Script;\n\nconst program = new FrodoCommand('frodo script import');\n\nprogram\n .description('Import scripts.')\n .addOption(new Option('-f, --file <file>', 'Name of the file to import.'))\n .addOption(\n new Option(\n '-n, --script-name <name>',\n 'Name of the script. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '--re-uuid',\n 'Re-UUID. Create a new UUID for the script upon import. Use this to duplicate a script or create a new version of the same script. Note that you must also choose a new name using -n/--script-name to avoid import errors.'\n ).default(false, 'false')\n )\n // deprecated option\n .addOption(\n new Option(\n '-s, --script <script>',\n 'DEPRECATED! Use -n/--script-name instead. Name of the script.'\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 if (await getTokens()) {\n verboseMessage(\n `Importing script(s) into realm \"${state.getRealm()}\"...`\n );\n importScriptsFromFile(\n options.scriptName || options.script,\n options.file,\n options.reUuid\n );\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,EAAEC,MAAM,EAAEC,KAAK,QAAQ,uBAAuB;AACnE,SAASC,cAAc,QAAQ,qBAAqB;AAEpD,MAAM;EAAEC;AAAU,CAAC,GAAGJ,YAAY;AAElC,MAAM;EAAEK;AAAsB,CAAC,GAAGJ,MAAM;AAExC,MAAMK,OAAO,GAAG,IAAIR,YAAY,CAAC,qBAAqB,CAAC;AAEvDQ,OAAO,CACJC,WAAW,CAAC,iBAAiB,CAAC,CAC9BC,SAAS,CAAC,IAAIT,MAAM,CAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC,CACzES,SAAS,CACR,IAAIT,MAAM,CACR,0BAA0B,EAC1B,0DAA0D,CAC3D,CACF,CACAS,SAAS,CACR,IAAIT,MAAM,CACR,WAAW,EACX,4NAA4N,CAC7N,CAACU,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC;AAE3B;AAAA,CACCD,SAAS,CACR,IAAIT,MAAM,CACR,uBAAuB,EACvB,+DAA+D,CAChE,CACF,CACAW,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,OAAO,CACR;EACD,IAAI,MAAMZ,SAAS,EAAE,EAAE;IACrBD,cAAc,CACX,mCAAkCD,KAAK,CAACgB,QAAQ,EAAG,MAAK,CAC1D;IACDb,qBAAqB,CACnBU,OAAO,CAACI,UAAU,IAAIJ,OAAO,CAACK,MAAM,EACpCL,OAAO,CAACM,IAAI,EACZN,OAAO,CAACO,MAAM,CACf;EACH,CAAC,MAAM;IACLC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHlB,OAAO,CAACmB,KAAK,EAAE"}
1
+ {"version":3,"file":"script-import.js","names":["FrodoCommand","Option","Authenticate","state","verboseMessage","importScriptsFromFile","getTokens","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","getRealm","scriptName","script","file","reUuid","process","exitCode","parse"],"sources":["cli/script/script-import.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console';\nimport { importScriptsFromFile } from '../../ops/ScriptOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo script import');\n\nprogram\n .description('Import scripts.')\n .addOption(new Option('-f, --file <file>', 'Name of the file to import.'))\n .addOption(\n new Option(\n '-n, --script-name <name>',\n 'Name of the script. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '--re-uuid',\n 'Re-UUID. Create a new UUID for the script upon import. Use this to duplicate a script or create a new version of the same script. Note that you must also choose a new name using -n/--script-name to avoid import errors.'\n ).default(false, 'false')\n )\n // deprecated option\n .addOption(\n new Option(\n '-s, --script <script>',\n 'DEPRECATED! Use -n/--script-name instead. Name of the script.'\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 if (await getTokens()) {\n verboseMessage(\n `Importing script(s) into realm \"${state.getRealm()}\"...`\n );\n importScriptsFromFile(\n options.scriptName || options.script,\n options.file,\n options.reUuid\n );\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,qBAAqB,QAAQ,qBAAqB;AAE3D,MAAM;EAAEC;AAAU,CAAC,GAAGJ,YAAY;AAElC,MAAMK,OAAO,GAAG,IAAIP,YAAY,CAAC,qBAAqB,CAAC;AAEvDO,OAAO,CACJC,WAAW,CAAC,iBAAiB,CAAC,CAC9BC,SAAS,CAAC,IAAIR,MAAM,CAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC,CACzEQ,SAAS,CACR,IAAIR,MAAM,CACR,0BAA0B,EAC1B,0DAA0D,CAC3D,CACF,CACAQ,SAAS,CACR,IAAIR,MAAM,CACR,WAAW,EACX,4NAA4N,CAC7N,CAACS,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC;AAE3B;AAAA,CACCD,SAAS,CACR,IAAIR,MAAM,CACR,uBAAuB,EACvB,+DAA+D,CAChE,CACF,CACAU,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,OAAO,CACR;EACD,IAAI,MAAMX,SAAS,EAAE,EAAE;IACrBF,cAAc,CACX,mCAAkCD,KAAK,CAACgB,QAAQ,EAAG,MAAK,CAC1D;IACDd,qBAAqB,CACnBW,OAAO,CAACI,UAAU,IAAIJ,OAAO,CAACK,MAAM,EACpCL,OAAO,CAACM,IAAI,EACZN,OAAO,CAACO,MAAM,CACf;EACH,CAAC,MAAM;IACLC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHlB,OAAO,CAACmB,KAAK,EAAE"}
@@ -1,13 +1,11 @@
1
1
  import { FrodoCommand } from '../FrodoCommand';
2
2
  import { Option } from 'commander';
3
- import { Authenticate, Script, state } from '@rockcarver/frodo-lib';
3
+ import { Authenticate, state } from '@rockcarver/frodo-lib';
4
4
  import { verboseMessage } from '../../utils/Console';
5
+ import { listScripts } from '../../ops/ScriptOps';
5
6
  const {
6
7
  getTokens
7
8
  } = Authenticate;
8
- const {
9
- listScripts
10
- } = Script;
11
9
  const program = new FrodoCommand('frodo script list');
12
10
  program.description('List scripts.').addOption(new Option('-l, --long', 'Long with all fields.').default(false, 'false')).action(
13
11
  // implement command logic inside action handler
@@ -1 +1 @@
1
- {"version":3,"file":"script-list.js","names":["FrodoCommand","Option","Authenticate","Script","state","verboseMessage","getTokens","listScripts","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","getRealm","long","process","exitCode","parse"],"sources":["cli/script/script-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate, Script, state } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\nconst { listScripts } = Script;\n\nconst program = new FrodoCommand('frodo script list');\n\nprogram\n .description('List scripts.')\n .addOption(\n new Option('-l, --long', 'Long with all 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 scripts in realm \"${state.getRealm()}\"...`);\n await listScripts(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,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,EAAEC,MAAM,EAAEC,KAAK,QAAQ,uBAAuB;AACnE,SAASC,cAAc,QAAQ,qBAAqB;AAEpD,MAAM;EAAEC;AAAU,CAAC,GAAGJ,YAAY;AAClC,MAAM;EAAEK;AAAY,CAAC,GAAGJ,MAAM;AAE9B,MAAMK,OAAO,GAAG,IAAIR,YAAY,CAAC,mBAAmB,CAAC;AAErDQ,OAAO,CACJC,WAAW,CAAC,eAAe,CAAC,CAC5BC,SAAS,CACR,IAAIT,MAAM,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAACU,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAC1E,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,OAAO,CACR;EACD,IAAI,MAAMZ,SAAS,EAAE,EAAE;IACrBD,cAAc,CAAE,6BAA4BD,KAAK,CAACgB,QAAQ,EAAG,MAAK,CAAC;IACnE,MAAMb,WAAW,CAACU,OAAO,CAACI,IAAI,CAAC;EACjC,CAAC,MAAM;IACLC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHf,OAAO,CAACgB,KAAK,EAAE"}
1
+ {"version":3,"file":"script-list.js","names":["FrodoCommand","Option","Authenticate","state","verboseMessage","listScripts","getTokens","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","getRealm","long","process","exitCode","parse"],"sources":["cli/script/script-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console';\nimport { listScripts } from '../../ops/ScriptOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo script list');\n\nprogram\n .description('List scripts.')\n .addOption(\n new Option('-l, --long', 'Long with all 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 scripts in realm \"${state.getRealm()}\"...`);\n await listScripts(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,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,WAAW,QAAQ,qBAAqB;AAEjD,MAAM;EAAEC;AAAU,CAAC,GAAGJ,YAAY;AAElC,MAAMK,OAAO,GAAG,IAAIP,YAAY,CAAC,mBAAmB,CAAC;AAErDO,OAAO,CACJC,WAAW,CAAC,eAAe,CAAC,CAC5BC,SAAS,CACR,IAAIR,MAAM,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAACS,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAC1E,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,OAAO,CACR;EACD,IAAI,MAAMX,SAAS,EAAE,EAAE;IACrBF,cAAc,CAAE,6BAA4BD,KAAK,CAACgB,QAAQ,EAAG,MAAK,CAAC;IACnE,MAAMd,WAAW,CAACW,OAAO,CAACI,IAAI,CAAC;EACjC,CAAC,MAAM;IACLC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHf,OAAO,CAACgB,KAAK,EAAE"}
package/esm/ops/IdmOps.js CHANGED
@@ -18,8 +18,26 @@ const {
18
18
  getAllConfigEntities,
19
19
  getConfigEntity,
20
20
  putConfigEntity,
21
- queryAllManagedObjectsByType
21
+ queryAllManagedObjectsByType,
22
+ testConnectorServers
22
23
  } = Idm;
24
+
25
+ /**
26
+ * Warn about and list offline remote connector servers
27
+ */
28
+ export async function warnAboutOfflineConnectorServers() {
29
+ try {
30
+ const all = await testConnectorServers();
31
+ const offline = all.filter(status => !status.ok);
32
+ if (offline.length) {
33
+ printMessage(`\n\nThe following connector server(s) are offline and their connectors and configuration unavailable:\n ${offline.join('\n')}`, 'warn');
34
+ }
35
+ } catch (error) {
36
+ printMessage(error, 'error');
37
+ printMessage(`Error getting offline connector servers: ${error.message}`, 'error');
38
+ }
39
+ }
40
+
23
41
  /**
24
42
  * List all IDM configuration objects
25
43
  */
@@ -1 +1 @@
1
- {"version":3,"file":"IdmOps.js","names":["fs","fse","path","propertiesReader","replaceall","Idm","Utils","ValidationUtils","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","readFiles","unSubstituteEnvParams","validateScriptHooks","getAllConfigEntities","getConfigEntity","putConfigEntity","queryAllManagedObjectsByType","listAllConfigEntities","configurations","configEntity","_id","getAllConfigEntitiesError","exportConfigEntity","id","file","fileName","writeFile","JSON","stringify","err","exportAllRawConfigEntities","directory","existsSync","mkdirSync","undefined","entityPromises","push","catch","getConfigEntityError","response","status","data","message","results","Promise","all","item","outputFile","exportAllConfigEntities","entitiesFile","envFile","entriesToExport","readFile","entriesData","parse","idm","envParams","includes","configEntityString","each","key","value","error","importConfigEntity","entityId","validate","entityData","readFileSync","resolve","process","cwd","jsObject","isValid","putConfigEntityError","importAllRawConfigEntities","baseDirectory","files","jsonFiles","filter","toLowerCase","endsWith","map","content","substring","length","everyScriptValid","isScriptValid","allSettled","errors","result","reason","importAllConfigEntities","entriesToImport","envReader","unsubstituted","countManagedObjects","type","count","resultCount","pagedResultsCookie","totalPagedResultsPolicy","totalPagedResults","remainingPagedResults"],"sources":["ops/IdmOps.ts"],"sourcesContent":["/* eslint-disable no-await-in-loop */\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\n\nimport { Idm, Utils, ValidationUtils } from '@rockcarver/frodo-lib';\nimport {\n createProgressIndicator,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename } from '../utils/ExportImportUtils';\n\nconst { readFiles, unSubstituteEnvParams } = Utils;\nconst { validateScriptHooks } = ValidationUtils;\nconst {\n getAllConfigEntities,\n getConfigEntity,\n putConfigEntity,\n queryAllManagedObjectsByType,\n} = Idm;\n/**\n * List all IDM configuration objects\n */\nexport async function listAllConfigEntities() {\n try {\n const { configurations } = await getAllConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export an IDM configuration object.\n * @param {String} id the desired configuration object\n * @param {String} file optional export file\n */\nexport async function exportConfigEntity(id, file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`${id}`, 'idm');\n }\n const configEntity = await getConfigEntity(id);\n fs.writeFile(fileName, JSON.stringify(configEntity, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${id} export to file`, 'error');\n }\n return '';\n });\n}\n\n/**\n * Export all IDM configuration objects into separate JSON files in a directory specified by <directory>\n * @param {String} directory export directory\n */\nexport async function exportAllRawConfigEntities(directory) {\n try {\n const { configurations } = await getAllConfigEntities();\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n entityPromises.push(\n getConfigEntity(configEntity._id).catch((getConfigEntityError) => {\n if (\n !(\n getConfigEntityError.response?.status === 403 &&\n getConfigEntityError.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n ) &&\n // https://bugster.forgerock.org/jira/browse/OPENIDM-18270\n !(\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.message ===\n 'No configuration exists for id org.apache.felix.fileinstall/openidm'\n )\n ) {\n printMessage(getConfigEntityError.response?.data, 'error');\n printMessage(\n `Error getting config entity ${configEntity._id}: ${getConfigEntityError}`,\n 'error'\n );\n }\n })\n );\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n fse.outputFile(\n `${directory}/${item._id}.json`,\n JSON.stringify(item, null, 2),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator('Exported config objects.', 'success');\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export all IDM configuration objects\n * @param {String} directory export directory\n * @param {String} entitiesFile JSON file that specifies the config entities to export/import\n * @param {String} envFile File that defines environment specific variables for replacement during configuration export/import\n */\nexport async function exportAllConfigEntities(\n directory,\n entitiesFile,\n envFile\n) {\n let entriesToExport = [];\n // read list of entities to export\n fs.readFile(entitiesFile, 'utf8', async (err, data) => {\n if (err) throw err;\n const entriesData = JSON.parse(data);\n entriesToExport = entriesData.idm;\n // console.log(`entriesToExport ${entriesToExport}`);\n\n // read list of configs to parameterize for environment specific values\n const envParams = propertiesReader(envFile);\n\n try {\n const { configurations } = await getAllConfigEntities();\n // create export directory if not exist\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(getConfigEntity(configEntity._id));\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n let configEntityString = JSON.stringify(item, null, 2);\n envParams.each((key, value) => {\n configEntityString = replaceall(\n value,\n `\\${${key}}`,\n configEntityString\n );\n });\n fse.outputFile(\n `${directory}/${item._id}.json`,\n configEntityString,\n (error) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${error}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator(null, 'success');\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n });\n}\n\n/**\n * Import an IDM configuration object.\n * @param entityId the configuration object to import\n * @param file optional file to import\n */\nexport async function importConfigEntity(\n entityId: string,\n file?: string,\n validate?: boolean\n) {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const entityData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n\n const jsObject = JSON.parse(entityData);\n const isValid = validateScriptHooks(jsObject);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await putConfigEntity(entityId, entityData);\n } catch (putConfigEntityError) {\n printMessage(putConfigEntityError, 'error');\n printMessage(`Error: ${putConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>\n * @param baseDirectory export directory\n * @param validate validate script hooks\n */\nexport async function importAllRawConfigEntities(\n baseDirectory: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ path, content }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles.map((file) => {\n return putConfigEntity(file.entityId, file.content);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Import all IDM configuration objects\n * @param baseDirectory import directory\n * @param entitiesFile JSON file that specifies the config entities to export/import\n * @param envFile File that defines environment specific variables for replacement during configuration export/import\n * @param validate validate script hooks\n */\nexport async function importAllConfigEntities(\n baseDirectory: string,\n entitiesFile: string,\n envFile: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const entriesToImport = JSON.parse(fs.readFileSync(entitiesFile, 'utf8')).idm;\n\n const envReader = propertiesReader(envFile);\n\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content, path }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles\n .filter(({ entityId }) => {\n return entriesToImport.includes(entityId);\n })\n .map(({ entityId, content }) => {\n const unsubstituted = unSubstituteEnvParams(content, envReader);\n return putConfigEntity(entityId, unsubstituted);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Count number of managed objects of a given type\n * @param {String} type managed object type, e.g. alpha_user\n */\nexport async function countManagedObjects(type) {\n let count = 0;\n let result = {\n result: [],\n resultCount: 0,\n pagedResultsCookie: null,\n totalPagedResultsPolicy: 'NONE',\n totalPagedResults: -1,\n remainingPagedResults: -1,\n };\n try {\n do {\n result = await queryAllManagedObjectsByType(\n type,\n [],\n result.pagedResultsCookie\n );\n count += result.resultCount;\n } while (result.pagedResultsCookie);\n printMessage(`${type}: ${count}`);\n } catch (error) {\n printMessage(error.response.data, 'error');\n printMessage(`Error querying managed objects by type: ${error}`, 'error');\n }\n}\n"],"mappings":"AAAA;AACA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAC1B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,gBAAgB,MAAM,mBAAmB;AAChD,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,GAAG,EAAEC,KAAK,EAAEC,eAAe,QAAQ,uBAAuB;AACnE,SACEC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GAAG,CAAC;EACb,IAAIR,MAAM,GAAG;IACXA,MAAM,EAAE,EAAE;IACVS,WAAW,EAAE,CAAC;IACdC,kBAAkB,EAAE,IAAI;IACxBC,uBAAuB,EAAE,MAAM;IAC/BC,iBAAiB,EAAE,CAAC,CAAC;IACrBC,qBAAqB,EAAE,CAAC;EAC1B,CAAC;EACD,IAAI;IACF,GAAG;MACDb,MAAM,GAAG,MAAMzE,4BAA4B,CACzCgF,IAAI,EACJ,EAAE,EACFP,MAAM,CAACU,kBAAkB,CAC1B;MACDF,KAAK,IAAIR,MAAM,CAACS,WAAW;IAC7B,CAAC,QAAQT,MAAM,CAACU,kBAAkB;IAClC5F,YAAY,CAAE,GAAEyF,IAAK,KAAIC,KAAM,EAAC,CAAC;EACnC,CAAC,CAAC,OAAOnC,KAAK,EAAE;IACdvD,YAAY,CAACuD,KAAK,CAACvB,QAAQ,CAACE,IAAI,EAAE,OAAO,CAAC;IAC1ClC,YAAY,CAAE,2CAA0CuD,KAAM,EAAC,EAAE,OAAO,CAAC;EAC3E;AACF"}
1
+ {"version":3,"file":"IdmOps.js","names":["fs","fse","path","propertiesReader","replaceall","Idm","Utils","ValidationUtils","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","readFiles","unSubstituteEnvParams","validateScriptHooks","getAllConfigEntities","getConfigEntity","putConfigEntity","queryAllManagedObjectsByType","testConnectorServers","warnAboutOfflineConnectorServers","all","offline","filter","status","ok","length","join","error","message","listAllConfigEntities","configurations","configEntity","_id","getAllConfigEntitiesError","exportConfigEntity","id","file","fileName","writeFile","JSON","stringify","err","exportAllRawConfigEntities","directory","existsSync","mkdirSync","undefined","entityPromises","push","catch","getConfigEntityError","response","data","results","Promise","item","outputFile","exportAllConfigEntities","entitiesFile","envFile","entriesToExport","readFile","entriesData","parse","idm","envParams","includes","configEntityString","each","key","value","importConfigEntity","entityId","validate","entityData","readFileSync","resolve","process","cwd","jsObject","isValid","putConfigEntityError","importAllRawConfigEntities","baseDirectory","files","jsonFiles","toLowerCase","endsWith","map","content","substring","everyScriptValid","isScriptValid","allSettled","errors","result","reason","importAllConfigEntities","entriesToImport","envReader","unsubstituted","countManagedObjects","type","count","resultCount","pagedResultsCookie","totalPagedResultsPolicy","totalPagedResults","remainingPagedResults"],"sources":["ops/IdmOps.ts"],"sourcesContent":["/* eslint-disable no-await-in-loop */\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\n\nimport { Idm, Utils, ValidationUtils } from '@rockcarver/frodo-lib';\nimport {\n createProgressIndicator,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename } from '../utils/ExportImportUtils';\n\nconst { readFiles, unSubstituteEnvParams } = Utils;\nconst { validateScriptHooks } = ValidationUtils;\nconst {\n getAllConfigEntities,\n getConfigEntity,\n putConfigEntity,\n queryAllManagedObjectsByType,\n testConnectorServers,\n} = Idm;\n\n/**\n * Warn about and list offline remote connector servers\n */\nexport async function warnAboutOfflineConnectorServers() {\n try {\n const all = await testConnectorServers();\n const offline = all.filter((status) => !status.ok);\n if (offline.length) {\n printMessage(\n `\\n\\nThe following connector server(s) are offline and their connectors and configuration unavailable:\\n ${offline.join(\n '\\n'\n )}`,\n 'warn'\n );\n }\n } catch (error) {\n printMessage(error, 'error');\n printMessage(\n `Error getting offline connector servers: ${error.message}`,\n 'error'\n );\n }\n}\n\n/**\n * List all IDM configuration objects\n */\nexport async function listAllConfigEntities() {\n try {\n const { configurations } = await getAllConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export an IDM configuration object.\n * @param {String} id the desired configuration object\n * @param {String} file optional export file\n */\nexport async function exportConfigEntity(id, file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`${id}`, 'idm');\n }\n const configEntity = await getConfigEntity(id);\n fs.writeFile(fileName, JSON.stringify(configEntity, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${id} export to file`, 'error');\n }\n return '';\n });\n}\n\n/**\n * Export all IDM configuration objects into separate JSON files in a directory specified by <directory>\n * @param {String} directory export directory\n */\nexport async function exportAllRawConfigEntities(directory) {\n try {\n const { configurations } = await getAllConfigEntities();\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n entityPromises.push(\n getConfigEntity(configEntity._id).catch((getConfigEntityError) => {\n if (\n !(\n getConfigEntityError.response?.status === 403 &&\n getConfigEntityError.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n ) &&\n // https://bugster.forgerock.org/jira/browse/OPENIDM-18270\n !(\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.message ===\n 'No configuration exists for id org.apache.felix.fileinstall/openidm'\n )\n ) {\n printMessage(getConfigEntityError.response?.data, 'error');\n printMessage(\n `Error getting config entity ${configEntity._id}: ${getConfigEntityError}`,\n 'error'\n );\n }\n })\n );\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n fse.outputFile(\n `${directory}/${item._id}.json`,\n JSON.stringify(item, null, 2),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator('Exported config objects.', 'success');\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export all IDM configuration objects\n * @param {String} directory export directory\n * @param {String} entitiesFile JSON file that specifies the config entities to export/import\n * @param {String} envFile File that defines environment specific variables for replacement during configuration export/import\n */\nexport async function exportAllConfigEntities(\n directory,\n entitiesFile,\n envFile\n) {\n let entriesToExport = [];\n // read list of entities to export\n fs.readFile(entitiesFile, 'utf8', async (err, data) => {\n if (err) throw err;\n const entriesData = JSON.parse(data);\n entriesToExport = entriesData.idm;\n // console.log(`entriesToExport ${entriesToExport}`);\n\n // read list of configs to parameterize for environment specific values\n const envParams = propertiesReader(envFile);\n\n try {\n const { configurations } = await getAllConfigEntities();\n // create export directory if not exist\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(getConfigEntity(configEntity._id));\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n let configEntityString = JSON.stringify(item, null, 2);\n envParams.each((key, value) => {\n configEntityString = replaceall(\n value,\n `\\${${key}}`,\n configEntityString\n );\n });\n fse.outputFile(\n `${directory}/${item._id}.json`,\n configEntityString,\n (error) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${error}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator(null, 'success');\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n });\n}\n\n/**\n * Import an IDM configuration object.\n * @param entityId the configuration object to import\n * @param file optional file to import\n */\nexport async function importConfigEntity(\n entityId: string,\n file?: string,\n validate?: boolean\n) {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const entityData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n\n const jsObject = JSON.parse(entityData);\n const isValid = validateScriptHooks(jsObject);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await putConfigEntity(entityId, entityData);\n } catch (putConfigEntityError) {\n printMessage(putConfigEntityError, 'error');\n printMessage(`Error: ${putConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>\n * @param baseDirectory export directory\n * @param validate validate script hooks\n */\nexport async function importAllRawConfigEntities(\n baseDirectory: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ path, content }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles.map((file) => {\n return putConfigEntity(file.entityId, file.content);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Import all IDM configuration objects\n * @param baseDirectory import directory\n * @param entitiesFile JSON file that specifies the config entities to export/import\n * @param envFile File that defines environment specific variables for replacement during configuration export/import\n * @param validate validate script hooks\n */\nexport async function importAllConfigEntities(\n baseDirectory: string,\n entitiesFile: string,\n envFile: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const entriesToImport = JSON.parse(fs.readFileSync(entitiesFile, 'utf8')).idm;\n\n const envReader = propertiesReader(envFile);\n\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content, path }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles\n .filter(({ entityId }) => {\n return entriesToImport.includes(entityId);\n })\n .map(({ entityId, content }) => {\n const unsubstituted = unSubstituteEnvParams(content, envReader);\n return putConfigEntity(entityId, unsubstituted);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Count number of managed objects of a given type\n * @param {String} type managed object type, e.g. alpha_user\n */\nexport async function countManagedObjects(type) {\n let count = 0;\n let result = {\n result: [],\n resultCount: 0,\n pagedResultsCookie: null,\n totalPagedResultsPolicy: 'NONE',\n totalPagedResults: -1,\n remainingPagedResults: -1,\n };\n try {\n do {\n result = await queryAllManagedObjectsByType(\n type,\n [],\n result.pagedResultsCookie\n );\n count += result.resultCount;\n } while (result.pagedResultsCookie);\n printMessage(`${type}: ${count}`);\n } catch (error) {\n printMessage(error.response.data, 'error');\n printMessage(`Error querying managed objects by type: ${error}`, 'error');\n }\n}\n"],"mappings":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IAAK,KAAIC,KAAM,EAAC,CAAC;EACnC,CAAC,CAAC,OAAO5E,KAAK,EAAE;IACdnB,YAAY,CAACmB,KAAK,CAACwB,QAAQ,CAACC,IAAI,EAAE,OAAO,CAAC;IAC1C5C,YAAY,CAAE,2CAA0CmB,KAAM,EAAC,EAAE,OAAO,CAAC;EAC3E;AACF"}
@@ -11,11 +11,11 @@ const {
11
11
  getProviderMetadata,
12
12
  getProviderMetadataUrl,
13
13
  getSaml2ProviderStub,
14
- getRawProviders,
15
- getRawProvider,
14
+ getRawSaml2Providers,
15
+ getRawSaml2Provider,
16
16
  importSaml2Provider,
17
17
  importSaml2Providers,
18
- putRawProvider
18
+ putRawSaml2Provider
19
19
  } = Saml2;
20
20
  const {
21
21
  getTypedFilename,
@@ -297,7 +297,7 @@ export async function importSaml2ProvidersFromFiles() {
297
297
  * List entity providers
298
298
  */
299
299
  export async function listRawSaml2Providers() {
300
- const providerList = (await getRawProviders()).result;
300
+ const providerList = (await getRawSaml2Providers()).result;
301
301
  providerList.sort((a, b) => a._id.localeCompare(b._id));
302
302
  for (const provider of providerList) {
303
303
  printMessage(`${provider._id}`, 'data');
@@ -317,7 +317,7 @@ export async function exportRawSaml2ProviderToFile(entityId, file = null) {
317
317
  }
318
318
  createProgressBar(1, `Exporting raw entity provider: ${entityId}`);
319
319
  try {
320
- const rawData = await getRawProvider(entityId);
320
+ const rawData = await getRawSaml2Provider(entityId);
321
321
  updateProgressBar(`Writing file ${fileName}`);
322
322
  saveTextToFile(JSON.stringify(rawData, null, 2), fileName);
323
323
  stopProgressBar(`Exported raw entity provider ${entityId} to ${fileName}.`);
@@ -338,7 +338,7 @@ export async function exportRawSaml2ProvidersToFile(file = null) {
338
338
  fileName = getTypedFilename(`all${getRealmString()}ProvidersRaw`, 'raw.saml');
339
339
  }
340
340
  try {
341
- const samlApplicationList = (await getRawProviders()).result;
341
+ const samlApplicationList = (await getRawSaml2Providers()).result;
342
342
  saveToFile('application', samlApplicationList, '_id', fileName);
343
343
  printMessage(`All RAW saml entity providers exported to: ${fileName}`, 'info');
344
344
  } catch (error) {
@@ -352,14 +352,14 @@ export async function exportRawSaml2ProvidersToFile(file = null) {
352
352
  * Export all entity providers to individual files
353
353
  */
354
354
  export async function exportRawSaml2ProvidersToFiles() {
355
- const samlApplicationList = (await getRawProviders()).result;
355
+ const samlApplicationList = (await getRawSaml2Providers()).result;
356
356
  let hasError = false;
357
357
  createProgressBar(samlApplicationList.length, 'Exporting RAW providers');
358
358
  let exportedAmount = 0;
359
359
  for (const item of samlApplicationList) {
360
360
  updateProgressBar(`Exporting provider ${item.entityId}`);
361
361
  try {
362
- const samlApplicationData = await getRawProvider(item._id);
362
+ const samlApplicationData = await getRawSaml2Provider(item._id);
363
363
  const fileName = getTypedFilename(`${item._id}${getRealmString()}ProviderRaw`, 'raw.saml');
364
364
  saveToFile('application', [samlApplicationData], '_id', fileName);
365
365
  exportedAmount++;
@@ -391,7 +391,7 @@ file) {
391
391
  // remove the "_rev" data before PUT
392
392
  delete samlEntityData.application[id]._rev;
393
393
  try {
394
- await putRawProvider(id, samlEntityData.application[id]);
394
+ await putRawSaml2Provider(id, samlEntityData.application[id]);
395
395
  } catch (error) {
396
396
  printMessage(`Unable to import: ${id}`, 'error');
397
397
  }
@@ -416,7 +416,7 @@ export async function importFirstRawSaml2ProviderFromFile(file) {
416
416
  // remove the "_rev" data before PUT
417
417
  delete samlEntityData.application[id]._rev;
418
418
  try {
419
- await putRawProvider(id, samlEntityData.application[id]);
419
+ await putRawSaml2Provider(id, samlEntityData.application[id]);
420
420
  } catch (error) {
421
421
  printMessage(`Unable to import: ${id}`, 'error');
422
422
  }
@@ -448,7 +448,7 @@ export async function importRawSaml2ProvidersFromFile(file) {
448
448
  for (const id in samlEntityData.application) {
449
449
  // remove the "_rev" data before PUT
450
450
  delete samlEntityData.application[id]._rev;
451
- await putRawProvider(id, samlEntityData.application[id]).then(result => {
451
+ await putRawSaml2Provider(id, samlEntityData.application[id]).then(result => {
452
452
  if (result === null) {
453
453
  printMessage(`Import validation failed for ${id}`, 'error');
454
454
  }
@@ -480,7 +480,7 @@ export async function importRawSaml2ProvidersFromFiles(directory) {
480
480
  for (const id in samlEntityData.application) {
481
481
  // remove the "_rev" data before PUT
482
482
  delete samlEntityData.application[id]._rev;
483
- await putRawProvider(id, samlEntityData.application[id]).then(result => {
483
+ await putRawSaml2Provider(id, samlEntityData.application[id]).then(result => {
484
484
  if (result === null) {
485
485
  printMessage(`Import validation failed for ${id}`, 'error');
486
486
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Saml2Ops.js","names":["fs","path","Saml2","ExportImportUtils","createObjectTable","createProgressBar","createTable","debugMessage","printMessage","showSpinner","stopProgressBar","stopSpinner","updateProgressBar","roleMap","exportSaml2Provider","exportSaml2Providers","getSaml2ProviderStubs","getProviderByLocationAndId","getProviderMetadata","getProviderMetadataUrl","getSaml2ProviderStub","getRawProviders","getRawProvider","importSaml2Provider","importSaml2Providers","putRawProvider","getTypedFilename","saveJsonToFile","saveTextToFile","getRealmString","saveToFile","validateImport","getOneLineDescription","saml2ProviderObj","roles","key","value","Object","entries","push","description","entityId","entityLocation","length","join","getTableHeaderMd","markdown","getTableRowMd","row","listSaml2Providers","long","providerList","sort","a","b","_id","localeCompare","provider","table","location","map","role","toString","describeSaml2Provider","stub","id","rawProviderData","_rev","metadataUrl","error","message","exportSaml2MetadataToFile","file","fileName","metaData","brightCyan","exportSaml2ProviderToFile","fileData","err","exportSaml2ProvidersToFile","exportData","response","status","exportSaml2ProvidersToFiles","stubs","importSaml2ProviderFromFile","readFile","data","JSON","parse","meta","importFirstSaml2ProviderFromFile","keys","saml","remote","hosted","importSaml2ProvidersFromFile","importSaml2ProvidersFromFiles","names","readdirSync","jsonFiles","filter","name","toLowerCase","endsWith","totalStatus","total","successes","warnings","failures","readFileSync","myStatus","listRawSaml2Providers","result","exportRawSaml2ProviderToFile","rawData","stringify","exportRawSaml2ProvidersToFile","samlApplicationList","exportRawSaml2ProvidersToFiles","hasError","exportedAmount","item","samlApplicationData","importRawSaml2ProviderFromFile","indexOf","samlEntityData","application","importFirstRawSaml2ProviderFromFile","importRawSaml2ProvidersFromFile","amountOfEntities","then","importRawSaml2ProvidersFromFiles","directory","files","filesToImport","forEach","filePathAbsolute"],"sources":["ops/Saml2Ops.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { Saml2ProviderSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { Saml2, ExportImportUtils } from '@rockcarver/frodo-lib';\nimport {\n MultiOpStatusInterface,\n Saml2ExportInterface,\n} from '@rockcarver/frodo-lib/types/ops/OpsTypes';\nimport {\n createObjectTable,\n createProgressBar,\n createTable,\n debugMessage,\n printMessage,\n showSpinner,\n stopProgressBar,\n stopSpinner,\n updateProgressBar,\n} from '../utils/Console';\n\nconst {\n roleMap,\n exportSaml2Provider,\n exportSaml2Providers,\n getSaml2ProviderStubs,\n getProviderByLocationAndId,\n getProviderMetadata,\n getProviderMetadataUrl,\n getSaml2ProviderStub,\n getRawProviders,\n getRawProvider,\n importSaml2Provider,\n importSaml2Providers,\n putRawProvider,\n} = Saml2;\nconst {\n getTypedFilename,\n saveJsonToFile,\n saveTextToFile,\n getRealmString,\n saveToFile,\n validateImport,\n} = ExportImportUtils;\n\n/**\n * Get a one-line description of the saml2 provider object\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n saml2ProviderObj: Saml2ProviderSkeleton\n): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const description = `[${saml2ProviderObj.entityId['brightCyan']}]${\n ' (' + saml2ProviderObj.entityLocation\n }${roles.length ? ' ' + roles.join(', ') + ')' : ')'}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Entity Id | Location | Role(s) |\\n';\n markdown += '| --------- | -------- | ------- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the saml2 provider in markdown\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a table-row of the saml2 provider in markdown\n */\nexport function getTableRowMd(saml2ProviderObj: Saml2ProviderSkeleton): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const row = `| ${saml2ProviderObj.entityId} | ${\n saml2ProviderObj.entityLocation\n } | ${roles.length ? roles.join(', ') : ''} |`;\n return row;\n}\n\n/**\n * List entity providers\n * @param {boolean} long Long list format with details\n */\nexport async function listSaml2Providers(long = false) {\n const providerList = await getSaml2ProviderStubs();\n providerList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const provider of providerList) {\n printMessage(`${provider.entityId}`, 'data');\n }\n } else {\n const table = createTable([\n 'Entity Id'['brightCyan'],\n 'Location'['brightCyan'],\n 'Role(s)'['brightCyan'],\n ]);\n for (const provider of providerList) {\n table.push([\n provider.entityId,\n provider.location,\n provider.roles.map((role) => roleMap[role]).join(', '),\n ]);\n }\n printMessage(table.toString());\n }\n}\n\n/**\n * Describe an entity provider's configuration\n * @param {String} entityId Provider entity id\n */\nexport async function describeSaml2Provider(entityId) {\n try {\n const stub = await getSaml2ProviderStub(entityId);\n printMessage(stub);\n const { location } = stub;\n const id = stub._id;\n const roles = stub.roles.map((role: string) => roleMap[role]).join(', ');\n const rawProviderData = await getProviderByLocationAndId(location, id);\n delete rawProviderData._id;\n delete rawProviderData._rev;\n rawProviderData.location = location;\n rawProviderData.roles = roles;\n rawProviderData.metadataUrl = getProviderMetadataUrl(entityId);\n const table = createObjectTable(rawProviderData);\n printMessage(table.toString());\n } catch (error) {\n printMessage(error.message, 'error');\n }\n}\n\n/**\n * Export provider metadata to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n */\nexport async function exportSaml2MetadataToFile(entityId, file = null) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(entityId, 'metadata', 'xml');\n }\n createProgressBar(1, `Exporting metadata for: ${entityId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const metaData = await getProviderMetadata(entityId);\n saveTextToFile(metaData, fileName);\n stopProgressBar(\n `Exported ${entityId.brightCyan} metadata to ${fileName.brightCyan}.`\n );\n } catch (error) {\n stopProgressBar(`${error}`);\n printMessage(error, 'error');\n }\n}\n\n/**\n * Export a single entity provider to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n */\nexport async function exportSaml2ProviderToFile(entityId, file = null) {\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: start [entityId=${entityId}, file=${file}]`\n );\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(entityId, 'saml');\n }\n try {\n createProgressBar(1, `Exporting provider ${entityId}`);\n const fileData = await exportSaml2Provider(entityId);\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${entityId.brightCyan} to ${fileName.brightCyan}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(err, 'error');\n }\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: end [entityId=${entityId}, file=${fileName}]`\n );\n}\n\n/**\n * Export all entity providers to one file\n * @param {String} file Optional filename\n */\nexport async function exportSaml2ProvidersToFile(file = null) {\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: start [file=${file}]`);\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'saml');\n }\n try {\n const exportData = await exportSaml2Providers();\n saveJsonToFile(exportData, fileName);\n } catch (error) {\n printMessage(error.message, 'error');\n printMessage(\n `exportSaml2ProvidersToFile: ${error.response?.status}`,\n 'error'\n );\n }\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: end [file=${file}]`);\n}\n\n/**\n * Export all entity providers to individual files\n */\nexport async function exportSaml2ProvidersToFiles() {\n const stubs = await getSaml2ProviderStubs();\n if (stubs.length > 0) {\n createProgressBar(stubs.length, 'Exporting providers');\n for (const stub of stubs) {\n updateProgressBar(`Exporting provider ${stub.entityId}`);\n const fileName = getTypedFilename(stub.entityId, 'saml');\n const fileData = await exportSaml2Provider(stub.entityId);\n saveJsonToFile(fileData, fileName);\n }\n stopProgressBar(`${stubs.length} providers exported.`);\n } else {\n printMessage('No entity providers found.', 'info');\n }\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} entityId Provider entity id\n * @param {String} file Import file name\n */\nexport async function importSaml2ProviderFromFile(\n entityId: string,\n file: string\n) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n showSpinner(`Importing ${entityId}...`);\n try {\n await importSaml2Provider(entityId, fileData);\n stopSpinner(`Imported ${entityId}.`);\n } catch (error) {\n stopSpinner(`Error importing ${entityId}: ${error.message}`);\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} file Import file name\n */\nexport async function importFirstSaml2ProviderFromFile(file: string) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data) as Saml2ExportInterface;\n // pick the first provider and run with it\n const entityId =\n Object.keys(fileData.saml.remote)[0] ||\n Object.keys(fileData.saml.hosted)[0];\n if (validateImport(fileData.meta)) {\n showSpinner(`Importing ${entityId}...`);\n try {\n await importSaml2Provider(entityId, fileData);\n stopSpinner(`Imported ${entityId}.`);\n } catch (error) {\n stopSpinner(`Error importing ${entityId}: ${error.message}`);\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all SAML entity providers from file\n * @param {String} file Import file name\n */\nexport async function importSaml2ProvidersFromFile(file: string) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n await importSaml2Providers(fileData);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all SAML entity providers from all *.saml.json files in the current directory\n */\nexport async function importSaml2ProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.saml.json')\n );\n createProgressBar(jsonFiles.length, 'Importing providers...');\n const totalStatus: MultiOpStatusInterface = {\n total: 0,\n successes: 0,\n warnings: 0,\n failures: 0,\n };\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n const myStatus = await importSaml2Providers(fileData);\n totalStatus.total += myStatus.total;\n totalStatus.successes += myStatus.successes;\n totalStatus.warnings += myStatus.warnings;\n totalStatus.failures += myStatus.failures;\n updateProgressBar(\n `Imported ${myStatus.successes}/${myStatus.total} provider(s) from ${file}.`\n );\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressBar(\n `Imported ${totalStatus.successes} of ${totalStatus.total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n\n/**\n * List entity providers\n */\nexport async function listRawSaml2Providers() {\n const providerList = (await getRawProviders()).result;\n providerList.sort((a, b) => a._id.localeCompare(b._id));\n for (const provider of providerList) {\n printMessage(`${provider._id}`, 'data');\n }\n}\n\n/**\n * Exports a RAW SAML entity, which means the raw xml is included.\n * @param {string} entityId Reference to the entity for export\n * @param {string} file Optional filename for the exported file\n */\nexport async function exportRawSaml2ProviderToFile(entityId, file = null) {\n printMessage(`Exporting raw SAML entity provider ${entityId}`, 'info');\n let fileName = file;\n if (!file) {\n fileName = getTypedFilename(`${entityId}`, 'raw.saml');\n }\n createProgressBar(1, `Exporting raw entity provider: ${entityId}`);\n try {\n const rawData = await getRawProvider(entityId);\n updateProgressBar(`Writing file ${fileName}`);\n saveTextToFile(JSON.stringify(rawData, null, 2), fileName);\n stopProgressBar(`Exported raw entity provider ${entityId} to ${fileName}.`);\n } catch (error) {\n stopProgressBar(`Error exporting raw entity ${entityId}: ${error.message}`);\n printMessage(error.response?.data, 'error');\n }\n}\n\n/**\n * Export all entity providers raw to one file\n * @param {String} file Optional filename\n */\nexport async function exportRawSaml2ProvidersToFile(file = null) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(\n `all${getRealmString()}ProvidersRaw`,\n 'raw.saml'\n );\n }\n try {\n const samlApplicationList = (await getRawProviders()).result;\n\n saveToFile('application', samlApplicationList, '_id', fileName);\n printMessage(\n `All RAW saml entity providers exported to: ${fileName}`,\n 'info'\n );\n } catch (error) {\n printMessage(error.message, 'error');\n printMessage(\n `exportRawSaml2ProvidersToFile: ${error.response?.status}`,\n 'error'\n );\n }\n}\n\n/**\n * Export all entity providers to individual files\n */\nexport async function exportRawSaml2ProvidersToFiles() {\n const samlApplicationList = (await getRawProviders()).result;\n let hasError = false;\n createProgressBar(samlApplicationList.length, 'Exporting RAW providers');\n let exportedAmount = 0;\n for (const item of samlApplicationList) {\n updateProgressBar(`Exporting provider ${item.entityId}`);\n try {\n const samlApplicationData = await getRawProvider(item._id);\n const fileName = getTypedFilename(\n `${item._id}${getRealmString()}ProviderRaw`,\n 'raw.saml'\n );\n saveToFile('application', [samlApplicationData], '_id', fileName);\n exportedAmount++;\n } catch (error) {\n hasError = true;\n printMessage(`Unable to export: ${item._id}`, 'error');\n }\n }\n stopProgressBar(`${exportedAmount} providers exported.`);\n if (!hasError) {\n printMessage('All entities exported.', 'info');\n } else {\n printMessage('All other entities exported.', 'info');\n }\n}\n\n/**\n * Imports a raw SAML export file (containing one entity).\n * @param {string} file The import file\n */\nexport async function importRawSaml2ProviderFromFile(\n // entityId: string,\n file: string\n) {\n printMessage(`Importing SAML Entity ${file}...`, 'info');\n if (file.indexOf('.raw.saml.json') > -1) {\n const samlEntityData = JSON.parse(fs.readFileSync(file, 'utf8'));\n if (validateImport(samlEntityData.meta)) {\n for (const id in samlEntityData.application) {\n // remove the \"_rev\" data before PUT\n delete samlEntityData.application[id]._rev;\n try {\n await putRawProvider(id, samlEntityData.application[id]);\n } catch (error) {\n printMessage(`Unable to import: ${id}`, 'error');\n }\n printMessage(`Imported ${id}`, 'info');\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n }\n}\n\n/**\n * Import first raw SAML entity provider from file\n * @param {String} file Import file name\n */\nexport async function importFirstRawSaml2ProviderFromFile(file) {\n printMessage(`Importing SAML Entity ${file}...`, 'info');\n if (file.indexOf('.raw.saml.json') > -1) {\n const samlEntityData = JSON.parse(fs.readFileSync(file, 'utf8'));\n if (validateImport(samlEntityData.meta)) {\n for (const id in samlEntityData.application) {\n // remove the \"_rev\" data before PUT\n delete samlEntityData.application[id]._rev;\n try {\n await putRawProvider(id, samlEntityData.application[id]);\n } catch (error) {\n printMessage(`Unable to import: ${id}`, 'error');\n }\n printMessage(`Imported ${id}`, 'info');\n return;\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n }\n}\n\n/**\n * Imports the RAW provider info from a single file.\n * @param file Import file name\n */\nexport async function importRawSaml2ProvidersFromFile(file: string) {\n fs.readFile(file, 'utf8', async function (err, data) {\n if (err) throw err;\n const samlEntityData = JSON.parse(data);\n let amountOfEntities = 0;\n for (const id in samlEntityData.application) {\n if (id.length) {\n amountOfEntities++;\n }\n }\n if (validateImport(samlEntityData.meta)) {\n createProgressBar(amountOfEntities, 'Importing providers...');\n for (const id in samlEntityData.application) {\n // remove the \"_rev\" data before PUT\n delete samlEntityData.application[id]._rev;\n await putRawProvider(id, samlEntityData.application[id]).then(\n (result) => {\n if (result === null) {\n printMessage(`Import validation failed for ${id}`, 'error');\n }\n }\n );\n updateProgressBar(`Imported ${id}...`);\n }\n stopProgressBar(`Import done`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Whenever the SAML RAW file were exported using the exportRAW functionality this function\n * is used to read them back in. Only files with the .samlRaw.json extension will be imported.\n * @param {string} directory The directory from which to import the files\n */\nexport async function importRawSaml2ProvidersFromFiles(directory) {\n const files = fs.readdirSync(directory);\n const filesToImport = files.filter(\n (file) => file.indexOf('.samlRaw.json') > -1\n );\n\n if (filesToImport.length > 0) {\n createProgressBar(filesToImport.length, 'Importing providers...');\n filesToImport.forEach(async (file) => {\n const filePathAbsolute = path.join(directory, file);\n filesToImport.push(file);\n const samlEntityData = JSON.parse(\n fs.readFileSync(filePathAbsolute, 'utf8')\n );\n if (validateImport(samlEntityData.meta)) {\n for (const id in samlEntityData.application) {\n // remove the \"_rev\" data before PUT\n delete samlEntityData.application[id]._rev;\n await putRawProvider(id, samlEntityData.application[id]).then(\n (result) => {\n if (result === null) {\n printMessage(`Import validation failed for ${id}`, 'error');\n }\n }\n );\n updateProgressBar(`Imported ${id}...`);\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n stopProgressBar(`Import done`);\n } else {\n printMessage(\n 'Import failed, no files to import. (check extension to be .samlRaw.json)',\n 'warn'\n );\n }\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AAEvB,SAASC,KAAK,EAAEC,iBAAiB,QAAQ,uBAAuB;AAKhE,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,WAAW,EACXC,iBAAiB,QACZ,kBAAkB;AAEzB,MAAM;EACJC,OAAO;EACPC,mBAAmB;EACnBC,oBAAoB;EACpBC,qBAAqB;EACrBC,0BAA0B;EAC1BC,mBAAmB;EACnBC,sBAAsB;EACtBC,oBAAoB;EACpBC,eAAe;EACfC,cAAc;EACdC,mBAAmB;EACnBC,oBAAoB;EACpBC;AACF,CAAC,GAAGvB,KAAK;AACT,MAAM;EACJwB,gBAAgB;EAChBC,cAAc;EACdC,cAAc;EACdC,cAAc;EACdC,UAAU;EACVC;AACF,CAAC,GAAG5B,iBAAiB;;AAErB;AACA;AACA;AACA;AACA;AACA,OAAO,SA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E,gCAA+ByD,EAAG,EAAC,EAAE,OAAO,CAAC;YAC7D;UACF,CAAC,CACF;UACDrD,iBAAiB,CAAE,YAAWqD,EAAG,KAAI,CAAC;QACxC;MACF,CAAC,MAAM;QACLzD,YAAY,CAAC,6BAA6B,EAAE,OAAO,CAAC;MACtD;IACF,CAAC,CAAC;IACFE,eAAe,CAAE,aAAY,CAAC;EAChC,CAAC,MAAM;IACLF,YAAY,CACV,0EAA0E,EAC1E,MAAM,CACP;EACH;AACF"}
1
+ {"version":3,"file":"Saml2Ops.js","names":["fs","path","Saml2","ExportImportUtils","createObjectTable","createProgressBar","createTable","debugMessage","printMessage","showSpinner","stopProgressBar","stopSpinner","updateProgressBar","roleMap","exportSaml2Provider","exportSaml2Providers","getSaml2ProviderStubs","getProviderByLocationAndId","getProviderMetadata","getProviderMetadataUrl","getSaml2ProviderStub","getRawSaml2Providers","getRawSaml2Provider","importSaml2Provider","importSaml2Providers","putRawSaml2Provider","getTypedFilename","saveJsonToFile","saveTextToFile","getRealmString","saveToFile","validateImport","getOneLineDescription","saml2ProviderObj","roles","key","value","Object","entries","push","description","entityId","entityLocation","length","join","getTableHeaderMd","markdown","getTableRowMd","row","listSaml2Providers","long","providerList","sort","a","b","_id","localeCompare","provider","table","location","map","role","toString","describeSaml2Provider","stub","id","rawProviderData","_rev","metadataUrl","error","message","exportSaml2MetadataToFile","file","fileName","metaData","brightCyan","exportSaml2ProviderToFile","fileData","err","exportSaml2ProvidersToFile","exportData","response","status","exportSaml2ProvidersToFiles","stubs","importSaml2ProviderFromFile","readFile","data","JSON","parse","meta","importFirstSaml2ProviderFromFile","keys","saml","remote","hosted","importSaml2ProvidersFromFile","importSaml2ProvidersFromFiles","names","readdirSync","jsonFiles","filter","name","toLowerCase","endsWith","totalStatus","total","successes","warnings","failures","readFileSync","myStatus","listRawSaml2Providers","result","exportRawSaml2ProviderToFile","rawData","stringify","exportRawSaml2ProvidersToFile","samlApplicationList","exportRawSaml2ProvidersToFiles","hasError","exportedAmount","item","samlApplicationData","importRawSaml2ProviderFromFile","indexOf","samlEntityData","application","importFirstRawSaml2ProviderFromFile","importRawSaml2ProvidersFromFile","amountOfEntities","then","importRawSaml2ProvidersFromFiles","directory","files","filesToImport","forEach","filePathAbsolute"],"sources":["ops/Saml2Ops.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { Saml2ProviderSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { Saml2, ExportImportUtils } from '@rockcarver/frodo-lib';\nimport {\n MultiOpStatusInterface,\n Saml2ExportInterface,\n} from '@rockcarver/frodo-lib/types/ops/OpsTypes';\nimport {\n createObjectTable,\n createProgressBar,\n createTable,\n debugMessage,\n printMessage,\n showSpinner,\n stopProgressBar,\n stopSpinner,\n updateProgressBar,\n} from '../utils/Console';\n\nconst {\n roleMap,\n exportSaml2Provider,\n exportSaml2Providers,\n getSaml2ProviderStubs,\n getProviderByLocationAndId,\n getProviderMetadata,\n getProviderMetadataUrl,\n getSaml2ProviderStub,\n getRawSaml2Providers,\n getRawSaml2Provider,\n importSaml2Provider,\n importSaml2Providers,\n putRawSaml2Provider,\n} = Saml2;\nconst {\n getTypedFilename,\n saveJsonToFile,\n saveTextToFile,\n getRealmString,\n saveToFile,\n validateImport,\n} = ExportImportUtils;\n\n/**\n * Get a one-line description of the saml2 provider object\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n saml2ProviderObj: Saml2ProviderSkeleton\n): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const description = `[${saml2ProviderObj.entityId['brightCyan']}]${\n ' (' + saml2ProviderObj.entityLocation\n }${roles.length ? ' ' + roles.join(', ') + ')' : ')'}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Entity Id | Location | Role(s) |\\n';\n markdown += '| --------- | -------- | ------- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the saml2 provider in markdown\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a table-row of the saml2 provider in markdown\n */\nexport function getTableRowMd(saml2ProviderObj: Saml2ProviderSkeleton): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const row = `| ${saml2ProviderObj.entityId} | ${\n saml2ProviderObj.entityLocation\n } | ${roles.length ? roles.join(', ') : ''} |`;\n return row;\n}\n\n/**\n * List entity providers\n * @param {boolean} long Long list format with details\n */\nexport async function listSaml2Providers(long = false) {\n const providerList = await getSaml2ProviderStubs();\n providerList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const provider of providerList) {\n printMessage(`${provider.entityId}`, 'data');\n }\n } else {\n const table = createTable([\n 'Entity Id'['brightCyan'],\n 'Location'['brightCyan'],\n 'Role(s)'['brightCyan'],\n ]);\n for (const provider of providerList) {\n table.push([\n provider.entityId,\n provider.location,\n provider.roles.map((role) => roleMap[role]).join(', '),\n ]);\n }\n printMessage(table.toString());\n }\n}\n\n/**\n * Describe an entity provider's configuration\n * @param {String} entityId Provider entity id\n */\nexport async function describeSaml2Provider(entityId) {\n try {\n const stub = await getSaml2ProviderStub(entityId);\n printMessage(stub);\n const { location } = stub;\n const id = stub._id;\n const roles = stub.roles.map((role: string) => roleMap[role]).join(', ');\n const rawProviderData = await getProviderByLocationAndId(location, id);\n delete rawProviderData._id;\n delete rawProviderData._rev;\n rawProviderData.location = location;\n rawProviderData.roles = roles;\n rawProviderData.metadataUrl = getProviderMetadataUrl(entityId);\n const table = createObjectTable(rawProviderData);\n printMessage(table.toString());\n } catch (error) {\n printMessage(error.message, 'error');\n }\n}\n\n/**\n * Export provider metadata to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n */\nexport async function exportSaml2MetadataToFile(entityId, file = null) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(entityId, 'metadata', 'xml');\n }\n createProgressBar(1, `Exporting metadata for: ${entityId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const metaData = await getProviderMetadata(entityId);\n saveTextToFile(metaData, fileName);\n stopProgressBar(\n `Exported ${entityId.brightCyan} metadata to ${fileName.brightCyan}.`\n );\n } catch (error) {\n stopProgressBar(`${error}`);\n printMessage(error, 'error');\n }\n}\n\n/**\n * Export a single entity provider to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n */\nexport async function exportSaml2ProviderToFile(entityId, file = null) {\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: start [entityId=${entityId}, file=${file}]`\n );\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(entityId, 'saml');\n }\n try {\n createProgressBar(1, `Exporting provider ${entityId}`);\n const fileData = await exportSaml2Provider(entityId);\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${entityId.brightCyan} to ${fileName.brightCyan}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(err, 'error');\n }\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: end [entityId=${entityId}, file=${fileName}]`\n );\n}\n\n/**\n * Export all entity providers to one file\n * @param {String} file Optional filename\n */\nexport async function exportSaml2ProvidersToFile(file = null) {\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: start [file=${file}]`);\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'saml');\n }\n try {\n const exportData = await exportSaml2Providers();\n saveJsonToFile(exportData, fileName);\n } catch (error) {\n printMessage(error.message, 'error');\n printMessage(\n `exportSaml2ProvidersToFile: ${error.response?.status}`,\n 'error'\n );\n }\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: end [file=${file}]`);\n}\n\n/**\n * Export all entity providers to individual files\n */\nexport async function exportSaml2ProvidersToFiles() {\n const stubs = await getSaml2ProviderStubs();\n if (stubs.length > 0) {\n createProgressBar(stubs.length, 'Exporting providers');\n for (const stub of stubs) {\n updateProgressBar(`Exporting provider ${stub.entityId}`);\n const fileName = getTypedFilename(stub.entityId, 'saml');\n const fileData = await exportSaml2Provider(stub.entityId);\n saveJsonToFile(fileData, fileName);\n }\n stopProgressBar(`${stubs.length} providers exported.`);\n } else {\n printMessage('No entity providers found.', 'info');\n }\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} entityId Provider entity id\n * @param {String} file Import file name\n */\nexport async function importSaml2ProviderFromFile(\n entityId: string,\n file: string\n) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n showSpinner(`Importing ${entityId}...`);\n try {\n await importSaml2Provider(entityId, fileData);\n stopSpinner(`Imported ${entityId}.`);\n } catch (error) {\n stopSpinner(`Error importing ${entityId}: ${error.message}`);\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} file Import file name\n */\nexport async function importFirstSaml2ProviderFromFile(file: string) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data) as Saml2ExportInterface;\n // pick the first provider and run with it\n const entityId =\n Object.keys(fileData.saml.remote)[0] ||\n Object.keys(fileData.saml.hosted)[0];\n if (validateImport(fileData.meta)) {\n showSpinner(`Importing ${entityId}...`);\n try {\n await importSaml2Provider(entityId, fileData);\n stopSpinner(`Imported ${entityId}.`);\n } catch (error) {\n stopSpinner(`Error importing ${entityId}: ${error.message}`);\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all SAML entity providers from file\n * @param {String} file Import file name\n */\nexport async function importSaml2ProvidersFromFile(file: string) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n await importSaml2Providers(fileData);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all SAML entity providers from all *.saml.json files in the current directory\n */\nexport async function importSaml2ProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.saml.json')\n );\n createProgressBar(jsonFiles.length, 'Importing providers...');\n const totalStatus: MultiOpStatusInterface = {\n total: 0,\n successes: 0,\n warnings: 0,\n failures: 0,\n };\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n const myStatus = await importSaml2Providers(fileData);\n totalStatus.total += myStatus.total;\n totalStatus.successes += myStatus.successes;\n totalStatus.warnings += myStatus.warnings;\n totalStatus.failures += myStatus.failures;\n updateProgressBar(\n `Imported ${myStatus.successes}/${myStatus.total} provider(s) from ${file}.`\n );\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressBar(\n `Imported ${totalStatus.successes} of ${totalStatus.total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n\n/**\n * List entity providers\n */\nexport async function listRawSaml2Providers() {\n const providerList = (await getRawSaml2Providers()).result;\n providerList.sort((a, b) => a._id.localeCompare(b._id));\n for (const provider of providerList) {\n printMessage(`${provider._id}`, 'data');\n }\n}\n\n/**\n * Exports a RAW SAML entity, which means the raw xml is included.\n * @param {string} entityId Reference to the entity for export\n * @param {string} file Optional filename for the exported file\n */\nexport async function exportRawSaml2ProviderToFile(entityId, file = null) {\n printMessage(`Exporting raw SAML entity provider ${entityId}`, 'info');\n let fileName = file;\n if (!file) {\n fileName = getTypedFilename(`${entityId}`, 'raw.saml');\n }\n createProgressBar(1, `Exporting raw entity provider: ${entityId}`);\n try {\n const rawData = await getRawSaml2Provider(entityId);\n updateProgressBar(`Writing file ${fileName}`);\n saveTextToFile(JSON.stringify(rawData, null, 2), fileName);\n stopProgressBar(`Exported raw entity provider ${entityId} to ${fileName}.`);\n } catch (error) {\n stopProgressBar(`Error exporting raw entity ${entityId}: ${error.message}`);\n printMessage(error.response?.data, 'error');\n }\n}\n\n/**\n * Export all entity providers raw to one file\n * @param {String} file Optional filename\n */\nexport async function exportRawSaml2ProvidersToFile(file = null) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(\n `all${getRealmString()}ProvidersRaw`,\n 'raw.saml'\n );\n }\n try {\n const samlApplicationList = (await getRawSaml2Providers()).result;\n\n saveToFile('application', samlApplicationList, '_id', fileName);\n printMessage(\n `All RAW saml entity providers exported to: ${fileName}`,\n 'info'\n );\n } catch (error) {\n printMessage(error.message, 'error');\n printMessage(\n `exportRawSaml2ProvidersToFile: ${error.response?.status}`,\n 'error'\n );\n }\n}\n\n/**\n * Export all entity providers to individual files\n */\nexport async function exportRawSaml2ProvidersToFiles() {\n const samlApplicationList = (await getRawSaml2Providers()).result;\n let hasError = false;\n createProgressBar(samlApplicationList.length, 'Exporting RAW providers');\n let exportedAmount = 0;\n for (const item of samlApplicationList) {\n updateProgressBar(`Exporting provider ${item.entityId}`);\n try {\n const samlApplicationData = await getRawSaml2Provider(item._id);\n const fileName = getTypedFilename(\n `${item._id}${getRealmString()}ProviderRaw`,\n 'raw.saml'\n );\n saveToFile('application', [samlApplicationData], '_id', fileName);\n exportedAmount++;\n } catch (error) {\n hasError = true;\n printMessage(`Unable to export: ${item._id}`, 'error');\n }\n }\n stopProgressBar(`${exportedAmount} providers exported.`);\n if (!hasError) {\n printMessage('All entities exported.', 'info');\n } else {\n printMessage('All other entities exported.', 'info');\n }\n}\n\n/**\n * Imports a raw SAML export file (containing one entity).\n * @param {string} file The import file\n */\nexport async function importRawSaml2ProviderFromFile(\n // entityId: string,\n file: string\n) {\n printMessage(`Importing SAML Entity ${file}...`, 'info');\n if (file.indexOf('.raw.saml.json') > -1) {\n const samlEntityData = JSON.parse(fs.readFileSync(file, 'utf8'));\n if (validateImport(samlEntityData.meta)) {\n for (const id in samlEntityData.application) {\n // remove the \"_rev\" data before PUT\n delete samlEntityData.application[id]._rev;\n try {\n await putRawSaml2Provider(id, samlEntityData.application[id]);\n } catch (error) {\n printMessage(`Unable to import: ${id}`, 'error');\n }\n printMessage(`Imported ${id}`, 'info');\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n }\n}\n\n/**\n * Import first raw SAML entity provider from file\n * @param {String} file Import file name\n */\nexport async function importFirstRawSaml2ProviderFromFile(file) {\n printMessage(`Importing SAML Entity ${file}...`, 'info');\n if (file.indexOf('.raw.saml.json') > -1) {\n const samlEntityData = JSON.parse(fs.readFileSync(file, 'utf8'));\n if (validateImport(samlEntityData.meta)) {\n for (const id in samlEntityData.application) {\n // remove the \"_rev\" data before PUT\n delete samlEntityData.application[id]._rev;\n try {\n await putRawSaml2Provider(id, samlEntityData.application[id]);\n } catch (error) {\n printMessage(`Unable to import: ${id}`, 'error');\n }\n printMessage(`Imported ${id}`, 'info');\n return;\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n }\n}\n\n/**\n * Imports the RAW provider info from a single file.\n * @param file Import file name\n */\nexport async function importRawSaml2ProvidersFromFile(file: string) {\n fs.readFile(file, 'utf8', async function (err, data) {\n if (err) throw err;\n const samlEntityData = JSON.parse(data);\n let amountOfEntities = 0;\n for (const id in samlEntityData.application) {\n if (id.length) {\n amountOfEntities++;\n }\n }\n if (validateImport(samlEntityData.meta)) {\n createProgressBar(amountOfEntities, 'Importing providers...');\n for (const id in samlEntityData.application) {\n // remove the \"_rev\" data before PUT\n delete samlEntityData.application[id]._rev;\n await putRawSaml2Provider(id, samlEntityData.application[id]).then(\n (result) => {\n if (result === null) {\n printMessage(`Import validation failed for ${id}`, 'error');\n }\n }\n );\n updateProgressBar(`Imported ${id}...`);\n }\n stopProgressBar(`Import done`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Whenever the SAML RAW file were exported using the exportRAW functionality this function\n * is used to read them back in. Only files with the .samlRaw.json extension will be imported.\n * @param {string} directory The directory from which to import the files\n */\nexport async function importRawSaml2ProvidersFromFiles(directory) {\n const files = fs.readdirSync(directory);\n const filesToImport = files.filter(\n (file) => file.indexOf('.samlRaw.json') > -1\n );\n\n if (filesToImport.length > 0) {\n createProgressBar(filesToImport.length, 'Importing providers...');\n filesToImport.forEach(async (file) => {\n const filePathAbsolute = path.join(directory, file);\n filesToImport.push(file);\n const samlEntityData = JSON.parse(\n fs.readFileSync(filePathAbsolute, 'utf8')\n );\n if (validateImport(samlEntityData.meta)) {\n for (const id in samlEntityData.application) {\n // remove the \"_rev\" data before PUT\n delete samlEntityData.application[id]._rev;\n await putRawSaml2Provider(id, samlEntityData.application[id]).then(\n (result) => {\n if (result === null) {\n printMessage(`Import validation failed for ${id}`, 'error');\n }\n }\n );\n updateProgressBar(`Imported ${id}...`);\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n stopProgressBar(`Import done`);\n } else {\n printMessage(\n 'Import failed, no files to import. (check extension to be .samlRaw.json)',\n 'warn'\n );\n }\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AAEvB,SAASC,KAAK,EAAEC,iBAAiB,QAAQ,uBAAuB;AAKhE,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,WAAW,EACXC,iBAAiB,QACZ,kBAAkB;AAEzB,MAAM;EACJC,OAAO;EACPC,mBAAmB;EACnBC,oBAAoB;EACpBC,qBAAqB;EACrBC,0BAA0B;EAC1BC,mBAAmB;EACnBC,sBAAsB;EACtBC,oBAAoB;EACpBC,oBAAoB;EACpBC,mBAAmB;EACnBC,mBAAmB;EACnBC,oBAAoB;EACpBC;AACF,CAAC,GAAGvB,KAAK;AACT,MAAM;EACJwB,gBAAgB;EAChBC,cAAc;EACdC,cAAc;EACdC,cAAc;EACdC,UAAU;EACVC;AACF,CAAC,GA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AC/DlB,MAAM,IAAK;YACV,IAAIA,MAAM,KAAK,IAAI,EAAE;cACnBzG,YAAY,CAAE,gCAA+ByD,EAAG,EAAC,EAAE,OAAO,CAAC;YAC7D;UACF,CAAC,CACF;UACDrD,iBAAiB,CAAE,YAAWqD,EAAG,KAAI,CAAC;QACxC;MACF,CAAC,MAAM;QACLzD,YAAY,CAAC,6BAA6B,EAAE,OAAO,CAAC;MACtD;IACF,CAAC,CAAC;IACFE,eAAe,CAAE,aAAY,CAAC;EAChC,CAAC,MAAM;IACLF,YAAY,CACV,0EAA0E,EAC1E,MAAM,CACP;EACH;AACF"}
@@ -1,4 +1,15 @@
1
- import { ExportImportUtils } from '@rockcarver/frodo-lib';
1
+ import fs from 'fs';
2
+ import { Script, ExportImportUtils, state } from '@rockcarver/frodo-lib';
3
+ import { createProgressBar, createTable, debugMessage, failSpinner, printMessage, showSpinner, spinSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
4
+ import wordwrap from './utils/Wordwrap';
5
+ import { getTypedFilename, saveJsonToFile, titleCase } from '../utils/ExportImportUtils';
6
+ const {
7
+ getScripts,
8
+ exportScripts,
9
+ exportScript,
10
+ exportScriptByName,
11
+ importScripts
12
+ } = Script;
2
13
 
3
14
  /**
4
15
  * Get a one-line description of the script object
@@ -34,4 +45,169 @@ export function getTableRowMd(scriptObj) {
34
45
  const description = `| ${scriptObj.name} | ${langMap[scriptObj.language]} | ${ExportImportUtils.titleCase(scriptObj.context.split('_').join(' '))} | \`${scriptObj._id}\` |`;
35
46
  return description;
36
47
  }
48
+
49
+ /**
50
+ * List scripts
51
+ * @param {boolean} long detail list
52
+ * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise
53
+ */
54
+ export async function listScripts(long = false) {
55
+ let outcome = true;
56
+ debugMessage(`Cli.ScriptOps.listScripts: start`);
57
+ try {
58
+ const scripts = await getScripts();
59
+ scripts.sort((a, b) => a.name.localeCompare(b.name));
60
+ if (long) {
61
+ const table = createTable(['Name', 'UUID', 'Language', 'Context', 'Description']);
62
+ const langMap = {
63
+ JAVASCRIPT: 'JS',
64
+ GROOVY: 'Groovy'
65
+ };
66
+ scripts.forEach(script => {
67
+ table.push([wordwrap(script.name, 25, ' '), script._id, langMap[script.language], wordwrap(titleCase(script.context.split('_').join(' ')), 25), wordwrap(script.description, 30)]);
68
+ });
69
+ printMessage(table.toString(), 'data');
70
+ } else {
71
+ scripts.forEach(script => {
72
+ printMessage(`${script.name}`, 'data');
73
+ });
74
+ }
75
+ } catch (error) {
76
+ outcome = false;
77
+ printMessage(`Error listing scripts: ${error.message}`, 'error');
78
+ debugMessage(error);
79
+ }
80
+ debugMessage(`Cli.ScriptOps.listScripts: end [${outcome}]`);
81
+ return outcome;
82
+ }
83
+
84
+ /**
85
+ * Export script by id to file
86
+ * @param {string} scriptId script uuid
87
+ * @param {string} file file name
88
+ * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise
89
+ */
90
+ export async function exportScriptToFile(scriptId, file) {
91
+ debugMessage(`Cli.ScriptOps.exportScriptToFile: start`);
92
+ try {
93
+ showSpinner(`Exporting script '${scriptId}'...`);
94
+ let fileName = getTypedFilename(scriptId, 'script');
95
+ if (file) {
96
+ fileName = file;
97
+ }
98
+ spinSpinner(`Exporting script '${scriptId}' to '${fileName}'...`);
99
+ const exportData = await exportScript(scriptId);
100
+ saveJsonToFile(exportData, fileName);
101
+ succeedSpinner(`Exported script '${scriptId}' to '${fileName}'.`);
102
+ debugMessage(`Cli.ScriptOps.exportScriptToFile: end [true]`);
103
+ return true;
104
+ } catch (error) {
105
+ failSpinner(`Error exporting script '${scriptId}': ${error.message}`);
106
+ debugMessage(error);
107
+ }
108
+ debugMessage(`Cli.ScriptOps.exportScriptToFile: end [false]`);
109
+ return false;
110
+ }
111
+
112
+ /**
113
+ * Export script by name to file
114
+ * @param {string} name script name
115
+ * @param {string} file file name
116
+ * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise
117
+ */
118
+ export async function exportScriptByNameToFile(name, file) {
119
+ debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: start`);
120
+ try {
121
+ showSpinner(`Exporting script '${name}'...`);
122
+ let fileName = getTypedFilename(name, 'script');
123
+ if (file) {
124
+ fileName = file;
125
+ }
126
+ spinSpinner(`Exporting script '${name}' to '${fileName}'...`);
127
+ const exportData = await exportScriptByName(name);
128
+ saveJsonToFile(exportData, fileName);
129
+ succeedSpinner(`Exported script '${name}' to '${fileName}'.`);
130
+ debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: end [true]`);
131
+ return true;
132
+ } catch (error) {
133
+ failSpinner(`Error exporting script '${name}': ${error.message}`);
134
+ debugMessage(error);
135
+ }
136
+ debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: end [false]`);
137
+ return false;
138
+ }
139
+
140
+ /**
141
+ * Export all scripts to single file
142
+ * @param {string} file file name
143
+ * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise
144
+ */
145
+ export async function exportScriptsToFile(file) {
146
+ debugMessage(`Cli.ScriptOps.exportScriptsToFile: start`);
147
+ try {
148
+ let fileName = getTypedFilename(`all${titleCase(state.getRealm())}Scripts`, 'script');
149
+ if (file) {
150
+ fileName = file;
151
+ }
152
+ const exportData = await exportScripts();
153
+ saveJsonToFile(exportData, fileName);
154
+ debugMessage(`Cli.ScriptOps.exportScriptsToFile: end [true]`);
155
+ return true;
156
+ } catch (error) {
157
+ printMessage(`Error exporting scripts: ${error.message}`, 'error');
158
+ debugMessage(error);
159
+ }
160
+ debugMessage(`Cli.ScriptOps.exportScriptsToFile: end [false]`);
161
+ return false;
162
+ }
163
+
164
+ /**
165
+ * Export all scripts to individual files
166
+ * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise
167
+ */
168
+ export async function exportScriptsToFiles() {
169
+ let outcome = true;
170
+ debugMessage(`Cli.ScriptOps.exportScriptsToFiles: start`);
171
+ const scriptList = await getScripts();
172
+ createProgressBar(scriptList.length, 'Exporting scripts to individual files...');
173
+ for (const script of scriptList) {
174
+ try {
175
+ updateProgressBar(`Reading script ${script.name}`);
176
+ const fileName = getTypedFilename(script.name, 'script');
177
+ const exportData = await exportScriptByName(script.name);
178
+ saveJsonToFile(exportData, fileName);
179
+ } catch (error) {
180
+ outcome = false;
181
+ printMessage(`Error exporting script '${script.name}': ${error.message}`, 'error');
182
+ debugMessage(error);
183
+ }
184
+ }
185
+ stopProgressBar(`Exported ${scriptList.length} scripts to individual files.`);
186
+ debugMessage(`Cli.ScriptOps.exportScriptsToFiles: end [${outcome}]`);
187
+ return outcome;
188
+ }
189
+
190
+ /**
191
+ * Import script(s) from file
192
+ * @param {string} name Optional name of script. If supplied, only the script of that name is imported
193
+ * @param {string} file file name
194
+ * @param {boolean} reUuid true to generate a new uuid for each script on import, false otherwise
195
+ * @returns {Promise<boolean>} true if no errors occurred during import, false otherwise
196
+ */
197
+ export async function importScriptsFromFile(name, file, reUuid = false) {
198
+ let outcome = false;
199
+ debugMessage(`Cli.ScriptOps.importScriptsFromFile: start`);
200
+ fs.readFile(file, 'utf8', async (err, data) => {
201
+ try {
202
+ if (err) throw err;
203
+ const importData = JSON.parse(data);
204
+ outcome = await importScripts(name, importData, reUuid);
205
+ } catch (error) {
206
+ printMessage(`Error exporting script '${name}': ${error.message}`, 'error');
207
+ debugMessage(error);
208
+ }
209
+ });
210
+ debugMessage(`Cli.ScriptOps.importScriptsFromFile: end [${outcome}]`);
211
+ return outcome;
212
+ }
37
213
  //# sourceMappingURL=ScriptOps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScriptOps.js","names":["ExportImportUtils","getOneLineDescription","scriptObj","description","_id","context","name","getTableHeaderMd","markdown","getTableRowMd","langMap","JAVASCRIPT","GROOVY","language","titleCase","split","join"],"sources":["ops/ScriptOps.ts"],"sourcesContent":["import { ScriptSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { ExportImportUtils } from '@rockcarver/frodo-lib';\n\n/**\n * Get a one-line description of the script object\n * @param {ScriptSkeleton} scriptObj script object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(scriptObj: ScriptSkeleton): string {\n const description = `[${scriptObj._id['brightCyan']}] ${scriptObj.context} - ${scriptObj.name}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name | Language | Type | Id |\\n';\n markdown += '| ---- | -------- | ---- | ---|';\n return markdown;\n}\n\n/**\n * Get a one-line description of the script object in markdown\n * @param {ScriptSkeleton} scriptObj script object to describe\n * @returns {string} markdown table row\n */\nexport function getTableRowMd(scriptObj: ScriptSkeleton): string {\n const langMap = { JAVASCRIPT: 'JavaSscript', GROOVY: 'Groovy' };\n const description = `| ${scriptObj.name} | ${\n langMap[scriptObj.language]\n } | ${ExportImportUtils.titleCase(\n scriptObj.context.split('_').join(' ')\n )} | \\`${scriptObj._id}\\` |`;\n return description;\n}\n"],"mappings":"AACA,SAASA,iBAAiB,QAAQ,uBAAuB;;AAEzD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqB,CAACC,SAAyB,EAAU;EACvE,MAAMC,WAAW,GAAI,IAAGD,SAAS,CAACE,GAAG,CAAC,YAAY,CAAE,KAAIF,SAAS,CAACG,OAAQ,MAAKH,SAAS,CAACI,IAAK,EAAC;EAC/F,OAAOH,WAAW;AACpB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASI,gBAAgB,GAAW;EACzC,IAAIC,QAAQ,GAAG,EAAE;EACjBA,QAAQ,IAAI,mCAAmC;EAC/CA,QAAQ,IAAI,iCAAiC;EAC7C,OAAOA,QAAQ;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAa,CAACP,SAAyB,EAAU;EAC/D,MAAMQ,OAAO,GAAG;IAAEC,UAAU,EAAE,aAAa;IAAEC,MAAM,EAAE;EAAS,CAAC;EAC/D,MAAMT,WAAW,GAAI,KAAID,SAAS,CAACI,IAAK,MACtCI,OAAO,CAACR,SAAS,CAACW,QAAQ,CAC3B,MAAKb,iBAAiB,CAACc,SAAS,CAC/BZ,SAAS,CAACG,OAAO,CAACU,KAAK,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CACtC,QAAOd,SAAS,CAACE,GAAI,MAAK;EAC5B,OAAOD,WAAW;AACpB"}
1
+ {"version":3,"file":"ScriptOps.js","names":["fs","Script","ExportImportUtils","state","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","spinSpinner","stopProgressBar","succeedSpinner","updateProgressBar","wordwrap","getTypedFilename","saveJsonToFile","titleCase","getScripts","exportScripts","exportScript","exportScriptByName","importScripts","getOneLineDescription","scriptObj","description","_id","context","name","getTableHeaderMd","markdown","getTableRowMd","langMap","JAVASCRIPT","GROOVY","language","split","join","listScripts","long","outcome","scripts","sort","a","b","localeCompare","table","forEach","script","push","toString","error","message","exportScriptToFile","scriptId","file","fileName","exportData","exportScriptByNameToFile","exportScriptsToFile","getRealm","exportScriptsToFiles","scriptList","length","importScriptsFromFile","reUuid","readFile","err","data","importData","JSON","parse"],"sources":["ops/ScriptOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { ScriptSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { Script, ExportImportUtils, state } from '@rockcarver/frodo-lib';\nimport {\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n spinSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport wordwrap from './utils/Wordwrap';\nimport {\n getTypedFilename,\n saveJsonToFile,\n titleCase,\n} from '../utils/ExportImportUtils';\n\nconst {\n getScripts,\n exportScripts,\n exportScript,\n exportScriptByName,\n importScripts,\n} = Script;\n\n/**\n * Get a one-line description of the script object\n * @param {ScriptSkeleton} scriptObj script object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(scriptObj: ScriptSkeleton): string {\n const description = `[${scriptObj._id['brightCyan']}] ${scriptObj.context} - ${scriptObj.name}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name | Language | Type | Id |\\n';\n markdown += '| ---- | -------- | ---- | ---|';\n return markdown;\n}\n\n/**\n * Get a one-line description of the script object in markdown\n * @param {ScriptSkeleton} scriptObj script object to describe\n * @returns {string} markdown table row\n */\nexport function getTableRowMd(scriptObj: ScriptSkeleton): string {\n const langMap = { JAVASCRIPT: 'JavaSscript', GROOVY: 'Groovy' };\n const description = `| ${scriptObj.name} | ${\n langMap[scriptObj.language]\n } | ${ExportImportUtils.titleCase(\n scriptObj.context.split('_').join(' ')\n )} | \\`${scriptObj._id}\\` |`;\n return description;\n}\n\n/**\n * List scripts\n * @param {boolean} long detail list\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function listScripts(long = false): Promise<boolean> {\n let outcome = true;\n debugMessage(`Cli.ScriptOps.listScripts: start`);\n try {\n const scripts = await getScripts();\n scripts.sort((a, b) => a.name.localeCompare(b.name));\n if (long) {\n const table = createTable([\n 'Name',\n 'UUID',\n 'Language',\n 'Context',\n 'Description',\n ]);\n const langMap = { JAVASCRIPT: 'JS', GROOVY: 'Groovy' };\n scripts.forEach((script) => {\n table.push([\n wordwrap(script.name, 25, ' '),\n script._id,\n langMap[script.language],\n wordwrap(titleCase(script.context.split('_').join(' ')), 25),\n wordwrap(script.description, 30),\n ]);\n });\n printMessage(table.toString(), 'data');\n } else {\n scripts.forEach((script) => {\n printMessage(`${script.name}`, 'data');\n });\n }\n } catch (error) {\n outcome = false;\n printMessage(`Error listing scripts: ${error.message}`, 'error');\n debugMessage(error);\n }\n debugMessage(`Cli.ScriptOps.listScripts: end [${outcome}]`);\n return outcome;\n}\n\n/**\n * Export script by id to file\n * @param {string} scriptId script uuid\n * @param {string} file file name\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptToFile(\n scriptId: string,\n file: string\n): Promise<boolean> {\n debugMessage(`Cli.ScriptOps.exportScriptToFile: start`);\n try {\n showSpinner(`Exporting script '${scriptId}'...`);\n let fileName = getTypedFilename(scriptId, 'script');\n if (file) {\n fileName = file;\n }\n spinSpinner(`Exporting script '${scriptId}' to '${fileName}'...`);\n const exportData = await exportScript(scriptId);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported script '${scriptId}' to '${fileName}'.`);\n debugMessage(`Cli.ScriptOps.exportScriptToFile: end [true]`);\n return true;\n } catch (error) {\n failSpinner(`Error exporting script '${scriptId}': ${error.message}`);\n debugMessage(error);\n }\n debugMessage(`Cli.ScriptOps.exportScriptToFile: end [false]`);\n return false;\n}\n\n/**\n * Export script by name to file\n * @param {string} name script name\n * @param {string} file file name\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptByNameToFile(\n name: string,\n file: string\n): Promise<boolean> {\n debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: start`);\n try {\n showSpinner(`Exporting script '${name}'...`);\n let fileName = getTypedFilename(name, 'script');\n if (file) {\n fileName = file;\n }\n spinSpinner(`Exporting script '${name}' to '${fileName}'...`);\n const exportData = await exportScriptByName(name);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported script '${name}' to '${fileName}'.`);\n debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: end [true]`);\n return true;\n } catch (error) {\n failSpinner(`Error exporting script '${name}': ${error.message}`);\n debugMessage(error);\n }\n debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: end [false]`);\n return false;\n}\n\n/**\n * Export all scripts to single file\n * @param {string} file file name\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptsToFile(file: string): Promise<boolean> {\n debugMessage(`Cli.ScriptOps.exportScriptsToFile: start`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(state.getRealm())}Scripts`,\n 'script'\n );\n if (file) {\n fileName = file;\n }\n const exportData = await exportScripts();\n saveJsonToFile(exportData, fileName);\n debugMessage(`Cli.ScriptOps.exportScriptsToFile: end [true]`);\n return true;\n } catch (error) {\n printMessage(`Error exporting scripts: ${error.message}`, 'error');\n debugMessage(error);\n }\n debugMessage(`Cli.ScriptOps.exportScriptsToFile: end [false]`);\n return false;\n}\n\n/**\n * Export all scripts to individual files\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptsToFiles(): Promise<boolean> {\n let outcome = true;\n debugMessage(`Cli.ScriptOps.exportScriptsToFiles: start`);\n const scriptList = await getScripts();\n createProgressBar(\n scriptList.length,\n 'Exporting scripts to individual files...'\n );\n for (const script of scriptList) {\n try {\n updateProgressBar(`Reading script ${script.name}`);\n const fileName = getTypedFilename(script.name, 'script');\n const exportData = await exportScriptByName(script.name);\n saveJsonToFile(exportData, fileName);\n } catch (error) {\n outcome = false;\n printMessage(\n `Error exporting script '${script.name}': ${error.message}`,\n 'error'\n );\n debugMessage(error);\n }\n }\n stopProgressBar(`Exported ${scriptList.length} scripts to individual files.`);\n debugMessage(`Cli.ScriptOps.exportScriptsToFiles: end [${outcome}]`);\n return outcome;\n}\n\n/**\n * Import script(s) from file\n * @param {string} name Optional name of script. If supplied, only the script of that name is imported\n * @param {string} file file name\n * @param {boolean} reUuid true to generate a new uuid for each script on import, false otherwise\n * @returns {Promise<boolean>} true if no errors occurred during import, false otherwise\n */\nexport async function importScriptsFromFile(\n name: string,\n file: string,\n reUuid = false\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`Cli.ScriptOps.importScriptsFromFile: start`);\n fs.readFile(file, 'utf8', async (err, data) => {\n try {\n if (err) throw err;\n const importData = JSON.parse(data);\n outcome = await importScripts(name, importData, reUuid);\n } catch (error) {\n printMessage(\n `Error exporting script '${name}': ${error.message}`,\n 'error'\n );\n debugMessage(error);\n }\n });\n debugMessage(`Cli.ScriptOps.importScriptsFromFile: end [${outcome}]`);\n return outcome;\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAA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AAEC,IAAI,KAAK;IAC7C,IAAI;MACF,IAAID,GAAG,EAAE,MAAMA,GAAG;MAClB,MAAME,UAAU,GAAGC,IAAI,CAACC,KAAK,CAACH,IAAI,CAAC;MACnC5B,OAAO,GAAG,MAAMlB,aAAa,CAACM,IAAI,EAAEyC,UAAU,EAAEJ,MAAM,CAAC;IACzD,CAAC,CAAC,OAAOd,KAAK,EAAE;MACd3C,YAAY,CACT,2BAA0BoB,IAAK,MAAKuB,KAAK,CAACC,OAAQ,EAAC,EACpD,OAAO,CACR;MACD9C,YAAY,CAAC6C,KAAK,CAAC;IACrB;EACF,CAAC,CAAC;EACF7C,YAAY,CAAE,6CAA4CkC,OAAQ,GAAE,CAAC;EACrE,OAAOA,OAAO;AAChB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rockcarver/frodo-cli",
3
- "version": "0.19.3-1",
3
+ "version": "0.19.3-3",
4
4
  "type": "module",
5
5
  "description": "A command line interface to manage ForgeRock Identity Cloud tenants, ForgeOps deployments, and classic deployments.",
6
6
  "keywords": [
@@ -48,10 +48,18 @@
48
48
  "name": "Adam Crockett",
49
49
  "email": "adam.crockett@forgerock.com"
50
50
  },
51
+ {
52
+ "name": "Mees van Dongen",
53
+ "email": "meesvandongen@gmail.com"
54
+ },
51
55
  {
52
56
  "name": "Ali Falahi",
53
57
  "email": "ali@falahi.com"
54
58
  },
59
+ {
60
+ "name": "Marcel Maas",
61
+ "email": "maas.marcel@gmail.com"
62
+ },
55
63
  {
56
64
  "name": "Joshua Sayers",
57
65
  "email": "joshua.sayers@forgerock.com"
@@ -88,7 +96,7 @@
88
96
  ]
89
97
  },
90
98
  "dependencies": {
91
- "@rockcarver/frodo-lib": "0.17.3",
99
+ "@rockcarver/frodo-lib": "0.17.5-0",
92
100
  "cli-progress": "^3.11.2",
93
101
  "cli-table3": "^0.6.3",
94
102
  "colors": "^1.4.0",