@rockcarver/frodo-cli 0.23.1-7 → 0.23.1-8

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,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.23.1-8] - 2023-05-21
11
+
10
12
  ## [0.23.1-7] - 2023-05-18
11
13
 
12
14
  ## [0.23.1-6] - 2023-05-17
@@ -1106,7 +1108,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1106
1108
  - Fixed problem with adding connection profiles
1107
1109
  - Miscellaneous bug fixes
1108
1110
 
1109
- [Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.23.1-7...HEAD
1111
+ [Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.23.1-8...HEAD
1112
+
1113
+ [0.23.1-8]: https://github.com/rockcarver/frodo-cli/compare/v0.23.1-7...v0.23.1-8
1110
1114
 
1111
1115
  [0.23.1-7]: https://github.com/rockcarver/frodo-cli/compare/v0.23.1-6...v0.23.1-7
1112
1116
 
@@ -1,7 +1,8 @@
1
1
  import { FrodoCommand } from '../FrodoCommand';
2
2
  import { Option } from 'commander';
3
3
  import { Authenticate } from '@rockcarver/frodo-lib';
4
- import { importPolicyFromFile } from '../../ops/PolicyOps';
4
+ import { importFirstPolicyFromFile, importPoliciesFromFile, importPoliciesFromFiles, importPolicyFromFile } from '../../ops/PolicyOps';
5
+ import { verboseMessage } from '../../utils/Console';
5
6
  const {
6
7
  getTokens
7
8
  } = Authenticate;
@@ -10,6 +11,44 @@ program.description('Import authorization policies.').addOption(new Option('-i,
10
11
  // implement command logic inside action handler
11
12
  async (host, realm, user, password, options, command) => {
12
13
  command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
14
+ // import
15
+ if (options.policyId && (await getTokens())) {
16
+ verboseMessage('Importing authorization policy from file...');
17
+ const outcome = importPolicyFromFile(options.policyId, options.file, {
18
+ deps: options.deps
19
+ });
20
+ if (!outcome) process.exitCode = 1;
21
+ }
22
+ // -a/--all
23
+ else if (options.all && (await getTokens())) {
24
+ verboseMessage('Importing all authorization policies from file...');
25
+ const outcome = await importPoliciesFromFile(options.file, {
26
+ deps: options.deps
27
+ });
28
+ if (!outcome) process.exitCode = 1;
29
+ }
30
+ // -A/--all-separate
31
+ else if (options.allSeparate && (await getTokens())) {
32
+ verboseMessage('Importing all authorization policies from separate files...');
33
+ const outcome = await importPoliciesFromFiles({
34
+ deps: options.deps
35
+ });
36
+ if (!outcome) process.exitCode = 1;
37
+ }
38
+ // import first policy set from file
39
+ else if (options.file && (await getTokens())) {
40
+ verboseMessage(`Importing first authorization policy from file "${options.file}"...`);
41
+ const outcome = await importFirstPolicyFromFile(options.file, {
42
+ deps: options.deps
43
+ });
44
+ if (!outcome) process.exitCode = 1;
45
+ }
46
+ // unrecognized combination of options or no options
47
+ else {
48
+ verboseMessage('Unrecognized combination of options or no options...');
49
+ program.help();
50
+ process.exitCode = 1;
51
+ }
13
52
  if (await getTokens()) {
14
53
  const outcome = importPolicyFromFile(options.policyId, options.file, {
15
54
  deps: options.deps
@@ -1 +1 @@
1
- {"version":3,"file":"authz-policy-import.js","names":["FrodoCommand","Option","Authenticate","importPolicyFromFile","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","outcome","policyId","file","deps","process","exitCode","parse"],"sources":["cli/authz/authz-policy-import.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { importPolicyFromFile } from '../../ops/PolicyOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo authz policy import');\n\nprogram\n .description('Import authorization policies.')\n .addOption(\n new Option(\n '-i, --policy-id <policy-id>',\n 'Policy id. If specified, only one policy is imported and the options -a and -A are ignored.'\n )\n )\n .addOption(new Option('-f, --file <file>', 'Name of the file to import.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Import all policies from single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all policies from separate files (*.policy.authz.json) in the current directory. Ignored with -i or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n const outcome = importPolicyFromFile(options.policyId, options.file, {\n deps: options.deps,\n });\n if (!outcome) process.exitCode = 1;\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,QAAQ,uBAAuB;AACpD,SAASC,oBAAoB,QAAQ,qBAAqB;AAE1D,MAAM;EAAEC;AAAU,CAAC,GAAGF,YAAY;AAElC,MAAMG,OAAO,GAAG,IAAIL,YAAY,CAAC,2BAA2B,CAAC;AAE7DK,OAAO,CACJC,WAAW,CAAC,gCAAgC,CAAC,CAC7CC,SAAS,CACR,IAAIN,MAAM,CACR,6BAA6B,EAC7B,6FAA6F,CAC9F,CACF,CACAM,SAAS,CAAC,IAAIN,MAAM,CAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC,CACzEM,SAAS,CACR,IAAIN,MAAM,CACR,WAAW,EACX,wDAAwD,CACzD,CACF,CACAM,SAAS,CACR,IAAIN,MAAM,CACR,oBAAoB,EACpB,gHAAgH,CACjH,CACF,CACAO,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,MAAMV,SAAS,EAAE,EAAE;IACrB,MAAMY,OAAO,GAAGb,oBAAoB,CAACU,OAAO,CAACI,QAAQ,EAAEJ,OAAO,CAACK,IAAI,EAAE;MACnEC,IAAI,EAAEN,OAAO,CAACM;IAChB,CAAC,CAAC;IACF,IAAI,CAACH,OAAO,EAAEI,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC,CAAC,MAAM;IACLD,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHhB,OAAO,CAACiB,KAAK,EAAE"}
1
+ {"version":3,"file":"authz-policy-import.js","names":["FrodoCommand","Option","Authenticate","importFirstPolicyFromFile","importPoliciesFromFile","importPoliciesFromFiles","importPolicyFromFile","verboseMessage","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","policyId","outcome","file","deps","process","exitCode","all","allSeparate","help","parse"],"sources":["cli/authz/authz-policy-import.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport {\n importFirstPolicyFromFile,\n importPoliciesFromFile,\n importPoliciesFromFiles,\n importPolicyFromFile,\n} from '../../ops/PolicyOps';\nimport { verboseMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo authz policy import');\n\nprogram\n .description('Import authorization policies.')\n .addOption(\n new Option(\n '-i, --policy-id <policy-id>',\n 'Policy id. If specified, only one policy is imported and the options -a and -A are ignored.'\n )\n )\n .addOption(new Option('-f, --file <file>', 'Name of the file to import.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Import all policies from single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all policies from separate files (*.policy.authz.json) in the current directory. Ignored with -i or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // import\n if (options.policyId && (await getTokens())) {\n verboseMessage('Importing authorization policy from file...');\n const outcome = importPolicyFromFile(options.policyId, options.file, {\n deps: options.deps,\n });\n if (!outcome) process.exitCode = 1;\n }\n // -a/--all\n else if (options.all && (await getTokens())) {\n verboseMessage('Importing all authorization policies from file...');\n const outcome = await importPoliciesFromFile(options.file, {\n deps: options.deps,\n });\n if (!outcome) process.exitCode = 1;\n }\n // -A/--all-separate\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage(\n 'Importing all authorization policies from separate files...'\n );\n const outcome = await importPoliciesFromFiles({\n deps: options.deps,\n });\n if (!outcome) process.exitCode = 1;\n }\n // import first policy set from file\n else if (options.file && (await getTokens())) {\n verboseMessage(\n `Importing first authorization policy from file \"${options.file}\"...`\n );\n const outcome = await importFirstPolicyFromFile(options.file, {\n deps: options.deps,\n });\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n verboseMessage('Unrecognized combination of options or no options...');\n program.help();\n process.exitCode = 1;\n }\n if (await getTokens()) {\n const outcome = importPolicyFromFile(options.policyId, options.file, {\n deps: options.deps,\n });\n if (!outcome) process.exitCode = 1;\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,QAAQ,uBAAuB;AACpD,SACEC,yBAAyB,EACzBC,sBAAsB,EACtBC,uBAAuB,EACvBC,oBAAoB,QACf,qBAAqB;AAC5B,SAASC,cAAc,QAAQ,qBAAqB;AAEpD,MAAM;EAAEC;AAAU,CAAC,GAAGN,YAAY;AAElC,MAAMO,OAAO,GAAG,IAAIT,YAAY,CAAC,2BAA2B,CAAC;AAE7DS,OAAO,CACJC,WAAW,CAAC,gCAAgC,CAAC,CAC7CC,SAAS,CACR,IAAIV,MAAM,CACR,6BAA6B,EAC7B,6FAA6F,CAC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EAAEN,OAAO,CAACM;IAChB,CAAC,CAAC;IACF,IAAI,CAACF,OAAO,EAAEG,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK,IAAIR,OAAO,CAACK,IAAI,KAAK,MAAMd,SAAS,EAAE,CAAC,EAAE;IAC5CD,cAAc,CACX,mDAAkDU,OAAO,CAACK,IAAK,MAAK,CACtE;IACD,MAAMD,OAAO,GAAG,MAAMlB,yBAAyB,CAACc,OAAO,CAACK,IAAI,EAAE;MAC5DC,IAAI,EAAEN,OAAO,CAACM;IAChB,CAAC,CAAC;IACF,IAAI,CAACF,OAAO,EAAEG,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK;IACHlB,cAAc,CAAC,sDAAsD,CAAC;IACtEE,OAAO,CAACmB,IAAI,EAAE;IACdJ,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;EACA,IAAI,MAAMjB,SAAS,EAAE,EAAE;IACrB,MAAMa,OAAO,GAAGf,oBAAoB,CAACW,OAAO,CAACG,QAAQ,EAAEH,OAAO,CAACK,IAAI,EAAE;MACnEC,IAAI,EAAEN,OAAO,CAACM;IAChB,CAAC,CAAC;IACF,IAAI,CAACF,OAAO,EAAEG,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC,CAAC,MAAM;IACLD,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHhB,OAAO,CAACoB,KAAK,EAAE"}
@@ -11,7 +11,7 @@ program.description('Import authorization policy sets.').addOption(new Option('-
11
11
  // implement command logic inside action handler
12
12
  async (host, realm, user, password, options, command) => {
13
13
  command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
14
- // export
14
+ // import
15
15
  if (options.setId && (await getTokens())) {
16
16
  verboseMessage('Importing authorization policy set from file...');
17
17
  const outcome = importPolicySetFromFile(options.setId, options.file, {
@@ -1 +1 @@
1
- {"version":3,"file":"authz-set-import.js","names":["FrodoCommand","Option","Authenticate","importFirstPolicySetFromFile","importPolicySetFromFile","importPolicySetsFromFile","importPolicySetsFromFiles","verboseMessage","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","setId","outcome","file","deps","process","exitCode","all","allSeparate","help","parse"],"sources":["cli/authz/authz-set-import.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport {\n importFirstPolicySetFromFile,\n importPolicySetFromFile,\n importPolicySetsFromFile,\n importPolicySetsFromFiles,\n} from '../../ops/PolicySetOps';\nimport { verboseMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo authz set import');\n\nprogram\n .description('Import authorization policy sets.')\n .addOption(\n new Option(\n '-i, --set-id <set-id>',\n 'Policy set id/name. If specified, only one policy set is imported and the options -a and -A are ignored.'\n )\n )\n .addOption(new Option('-f, --file <file>', 'Name of the file to import.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Import all policy sets from single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all policy sets from separate files (*.policyset.authz.json) in the current directory. Ignored with -i or -a.'\n )\n )\n .addOption(\n new Option(\n '--no-deps',\n 'Do not include any dependencies (policies, scripts, resource types).'\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\n if (options.setId && (await getTokens())) {\n verboseMessage('Importing authorization policy set from file...');\n const outcome = importPolicySetFromFile(options.setId, options.file, {\n deps: options.deps,\n });\n if (!outcome) process.exitCode = 1;\n }\n // -a/--all\n else if (options.all && (await getTokens())) {\n verboseMessage('Importing all authorization policy sets from file...');\n const outcome = await importPolicySetsFromFile(options.file, {\n deps: options.deps,\n });\n if (!outcome) process.exitCode = 1;\n }\n // -A/--all-separate\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage(\n 'Importing all authorization policy sets from separate files...'\n );\n const outcome = await importPolicySetsFromFiles({\n deps: options.deps,\n });\n if (!outcome) process.exitCode = 1;\n }\n // import first policy set from file\n else if (options.file && (await getTokens())) {\n verboseMessage(\n `Importing first authorization policy set from file \"${options.file}\"...`\n );\n const outcome = await importFirstPolicySetFromFile(options.file, {\n deps: options.deps,\n });\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n verboseMessage('Unrecognized combination of options or no options...');\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,SACEC,4BAA4B,EAC5BC,uBAAuB,EACvBC,wBAAwB,EACxBC,yBAAyB,QACpB,wBAAwB;AAC/B,SAASC,cAAc,QAAQ,qBAAqB;AAEpD,MAAM;EAAEC;AAAU,CAAC,GAAGN,YAAY;AAElC,MAAMO,OAAO,GAAG,IAAIT,YAAY,CAAC,wBAAwB,CAAC;AAE1DS,OAAO,CACJC,WAAW,CAAC,mCAAmC,CAAC,CAChDC,SAAS,CACR,IAAIV,MAAM,CACR,uBAAuB,EACvB,0GAA0G,CAC3G,CACF,CACAU,SAAS,CAAC,IAAIV,MAAM,CAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC,CACzEU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,2DAA2D,CAC5D,CACF,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,oBAAoB,EACpB,sHAAsH,CACvH,CACF,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,sEAAsE,CACvE,CACF,CACAW,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC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CAAC;IACF,IAAI,CAACF,OAAO,EAAEG,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK;IACHlB,cAAc,CAAC,sDAAsD,CAAC;IACtEE,OAAO,CAACmB,IAAI,EAAE;IACdJ,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHhB,OAAO,CAACoB,KAAK,EAAE"}
1
+ {"version":3,"file":"authz-set-import.js","names":["FrodoCommand","Option","Authenticate","importFirstPolicySetFromFile","importPolicySetFromFile","importPolicySetsFromFile","importPolicySetsFromFiles","verboseMessage","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","setId","outcome","file","deps","process","exitCode","all","allSeparate","help","parse"],"sources":["cli/authz/authz-set-import.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport {\n importFirstPolicySetFromFile,\n importPolicySetFromFile,\n importPolicySetsFromFile,\n importPolicySetsFromFiles,\n} from '../../ops/PolicySetOps';\nimport { verboseMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo authz set import');\n\nprogram\n .description('Import authorization policy sets.')\n .addOption(\n new Option(\n '-i, --set-id <set-id>',\n 'Policy set id/name. If specified, only one policy set is imported and the options -a and -A are ignored.'\n )\n )\n .addOption(new Option('-f, --file <file>', 'Name of the file to import.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Import all policy sets from single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all policy sets from separate files (*.policyset.authz.json) in the current directory. Ignored with -i or -a.'\n )\n )\n .addOption(\n new Option(\n '--no-deps',\n 'Do not include any dependencies (policies, scripts, resource types).'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // import\n if (options.setId && (await getTokens())) {\n verboseMessage('Importing authorization policy set from file...');\n const outcome = importPolicySetFromFile(options.setId, options.file, {\n deps: options.deps,\n });\n if (!outcome) process.exitCode = 1;\n }\n // -a/--all\n else if (options.all && (await getTokens())) {\n verboseMessage('Importing all authorization policy sets from file...');\n const outcome = await importPolicySetsFromFile(options.file, {\n deps: options.deps,\n });\n if (!outcome) process.exitCode = 1;\n }\n // -A/--all-separate\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage(\n 'Importing all authorization policy sets from separate files...'\n );\n const outcome = await importPolicySetsFromFiles({\n deps: options.deps,\n });\n if (!outcome) process.exitCode = 1;\n }\n // import first policy set from file\n else if (options.file && (await getTokens())) {\n verboseMessage(\n `Importing first authorization policy set from file \"${options.file}\"...`\n );\n const outcome = await importFirstPolicySetFromFile(options.file, {\n deps: options.deps,\n });\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n verboseMessage('Unrecognized combination of options or no options...');\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,SACEC,4BAA4B,EAC5BC,uBAAuB,EACvBC,wBAAwB,EACxBC,yBAAyB,QACpB,wBAAwB;AAC/B,SAASC,cAAc,QAAQ,qBAAqB;AAEpD,MAAM;EAAEC;AAAU,CAAC,GAAGN,YAAY;AAElC,MAAMO,OAAO,GAAG,IAAIT,YAAY,CAAC,wBAAwB,CAAC;AAE1DS,OAAO,CACJC,WAAW,CAAC,mCAAmC,CAAC,CAChDC,SAAS,CACR,IAAIV,MAAM,CACR,uBAAuB,EACvB,0GAA0G,CAC3G,CACF,CACAU,SAAS,CAAC,IAAIV,MAAM,CAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC,CACzEU,SAAS,CACR,IAAIV,MAAM,CACR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OAAO,EAAEG,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK,IAAIR,OAAO,CAACK,IAAI,KAAK,MAAMd,SAAS,EAAE,CAAC,EAAE;IAC5CD,cAAc,CACX,uDAAsDU,OAAO,CAACK,IAAK,MAAK,CAC1E;IACD,MAAMD,OAAO,GAAG,MAAMlB,4BAA4B,CAACc,OAAO,CAACK,IAAI,EAAE;MAC/DC,IAAI,EAAEN,OAAO,CAACM;IAChB,CAAC,CAAC;IACF,IAAI,CAACF,OAAO,EAAEG,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK;IACHlB,cAAc,CAAC,sDAAsD,CAAC;IACtEE,OAAO,CAACmB,IAAI,EAAE;IACdJ,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHhB,OAAO,CAACoB,KAAK,EAAE"}
@@ -1,28 +1,33 @@
1
1
  import { FrodoCommand } from '../FrodoCommand';
2
2
  import { Option } from 'commander';
3
- import { Authenticate, Variables } from '@rockcarver/frodo-lib';
3
+ import { Authenticate } from '@rockcarver/frodo-lib';
4
4
  import { printMessage, verboseMessage } from '../../utils/Console.js';
5
+ import { deleteResourceType, deleteResourceTypeByName, deleteResourceTypes } from '../../ops/ResourceTypeOps';
5
6
  const {
6
7
  getTokens
7
8
  } = Authenticate;
8
- const {
9
- deleteVariableCmd,
10
- deleteVariablesCmd
11
- } = Variables;
12
- const program = new FrodoCommand('frodo cmd sub2 delete');
13
- program.description('Delete variables.').addOption(new Option('-i, --variable-id <variable-id>', 'Variable id. If specified, -a is ignored.')).addOption(new Option('-a, --all', 'Delete all variable in a realm. Ignored with -i.')).addOption(new Option('--no-deep', 'No deep delete. This leaves orphaned configuration artifacts behind.')).action(
9
+ const program = new FrodoCommand('frodo authz type delete');
10
+ program.description('Delete authorization resource types.').addOption(new Option('-i, --type-id <type-id>', 'Variable id. If specified, -a is ignored.')).addOption(new Option('-n, --type-name <type-name>', 'Resource type name. If specified, -a is ignored.')).addOption(new Option('-a, --all', 'Delete all resource types in a realm. Ignored with -i and -n.')).action(
14
11
  // implement command logic inside action handler
15
12
  async (host, realm, user, password, options, command) => {
16
13
  command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
17
- // delete by id
18
- if (options.variableId && (await getTokens())) {
19
- verboseMessage('Deleting variable...');
20
- deleteVariableCmd(options.variableId);
14
+ // delete by uuid
15
+ if (options.typeId && (await getTokens())) {
16
+ verboseMessage('Deleting authorization resource type...');
17
+ const outcome = deleteResourceType(options.typeId);
18
+ if (!outcome) process.exitCode = 1;
19
+ }
20
+ // delete by name
21
+ else if (options.typeName && (await getTokens())) {
22
+ verboseMessage('Deleting authorization resource type...');
23
+ const outcome = deleteResourceTypeByName(options.typeName);
24
+ if (!outcome) process.exitCode = 1;
21
25
  }
22
26
  // --all -a
23
27
  else if (options.all && (await getTokens())) {
24
- verboseMessage('Deleting all variables...');
25
- deleteVariablesCmd();
28
+ verboseMessage('Deleting all authorization resource types...');
29
+ const outcome = deleteResourceTypes();
30
+ if (!outcome) process.exitCode = 1;
26
31
  }
27
32
  // unrecognized combination of options or no options
28
33
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"authz-type-delete.js","names":["FrodoCommand","Option","Authenticate","Variables","printMessage","verboseMessage","getTokens","deleteVariableCmd","deleteVariablesCmd","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","variableId","all","help","process","exitCode","parse"],"sources":["cli/authz/authz-type-delete.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate, Variables } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\n\nconst { getTokens } = Authenticate;\nconst { deleteVariableCmd, deleteVariablesCmd } = Variables;\n\nconst program = new FrodoCommand('frodo cmd sub2 delete');\n\nprogram\n .description('Delete variables.')\n .addOption(\n new Option(\n '-i, --variable-id <variable-id>',\n 'Variable id. If specified, -a is ignored.'\n )\n )\n .addOption(\n new Option('-a, --all', 'Delete all variable in a realm. Ignored with -i.')\n )\n .addOption(\n new Option(\n '--no-deep',\n 'No deep delete. This leaves orphaned configuration artifacts behind.'\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 // delete by id\n if (options.variableId && (await getTokens())) {\n verboseMessage('Deleting variable...');\n deleteVariableCmd(options.variableId);\n }\n // --all -a\n else if (options.all && (await getTokens())) {\n verboseMessage('Deleting all variables...');\n deleteVariablesCmd();\n }\n // unrecognized combination of options or no options\n else {\n printMessage('Unrecognized combination of options or no options...');\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,SAAS,QAAQ,uBAAuB;AAC/D,SAASC,YAAY,EAAEC,cAAc,QAAQ,wBAAwB;AAErE,MAAM;EAAEC;AAAU,CAAC,GAAGJ,YAAY;AAClC,MAAM;EAAEK,iBAAiB;EAAEC;AAAmB,CAAC,GAAGL,SAAS;AAE3D,MAAMM,OAAO,GAAG,IAAIT,YAAY,CAAC,uBAAuB,CAAC;AAEzDS,OAAO,CACJC,WAAW,CAAC,mBAAmB,CAAC,CAChCC,SAAS,CACR,IAAIV,MAAM,CACR,iCAAiC,EACjC,2CAA2C,CAC5C,CACF,CACAU,SAAS,CACR,IAAIV,MAAM,CAAC,WAAW,EAAE,kDAAkD,CAAC,CAC5E,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,sEAAsE,CACvE,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;EACA,IAAID,OAAO,CAACG,UAAU,KAAK,MAAMd,SAAS,EAAE,CAAC,EAAE;IAC7CD,cAAc,CAAC,sBAAsB,CAAC;IACtCE,iBAAiB,CAACU,OAAO,CAACG,UAAU,CAAC;EACvC;EACA;EAAA,KACK,IAAIH,OAAO,CAACI,GAAG,KAAK,MAAMf,SAAS,EAAE,CAAC,EAAE;IAC3CD,cAAc,CAAC,2BAA2B,CAAC;IAC3CG,kBAAkB,EAAE;EACtB;EACA;EAAA,KACK;IACHJ,YAAY,CAAC,sDAAsD,CAAC;IACpEK,OAAO,CAACa,IAAI,EAAE;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHf,OAAO,CAACgB,KAAK,EAAE"}
1
+ {"version":3,"file":"authz-type-delete.js","names":["FrodoCommand","Option","Authenticate","printMessage","verboseMessage","deleteResourceType","deleteResourceTypeByName","deleteResourceTypes","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","typeId","outcome","process","exitCode","typeName","all","help","parse"],"sources":["cli/authz/authz-type-delete.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport {\n deleteResourceType,\n deleteResourceTypeByName,\n deleteResourceTypes,\n} from '../../ops/ResourceTypeOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo authz type delete');\n\nprogram\n .description('Delete authorization resource types.')\n .addOption(\n new Option(\n '-i, --type-id <type-id>',\n 'Variable id. If specified, -a is ignored.'\n )\n )\n .addOption(\n new Option(\n '-n, --type-name <type-name>',\n 'Resource type name. If specified, -a is ignored.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Delete all resource types in a realm. Ignored with -i and -n.'\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 // delete by uuid\n if (options.typeId && (await getTokens())) {\n verboseMessage('Deleting authorization resource type...');\n const outcome = deleteResourceType(options.typeId);\n if (!outcome) process.exitCode = 1;\n }\n // delete by name\n else if (options.typeName && (await getTokens())) {\n verboseMessage('Deleting authorization resource type...');\n const outcome = deleteResourceTypeByName(options.typeName);\n if (!outcome) process.exitCode = 1;\n }\n // --all -a\n else if (options.all && (await getTokens())) {\n verboseMessage('Deleting all authorization resource types...');\n const outcome = deleteResourceTypes();\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n printMessage('Unrecognized combination of options or no options...');\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,wBAAwB;AACrE,SACEC,kBAAkB,EAClBC,wBAAwB,EACxBC,mBAAmB,QACd,2BAA2B;AAElC,MAAM;EAAEC;AAAU,CAAC,GAAGN,YAAY;AAElC,MAAMO,OAAO,GAAG,IAAIT,YAAY,CAAC,yBAAyB,CAAC;AAE3DS,OAAO,CACJC,WAAW,CAAC,sCAAsC,CAAC,CACnDC,SAAS,CACR,IAAIV,MAAM,CACR,yBAAyB,EACzB,2CAA2C,CAC5C,CACF,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,6BAA6B,EAC7B,kDAAkD,CACnD,CACF,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,+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;EACA,IAAID,OAAO,CAACG,MAAM,KAAK,MAAMZ,SAAS,EAAE,CAAC,EAAE;IACzCJ,cAAc,CAAC,yCAAyC,CAAC;IACzD,MAAMiB,OAAO,GAAGhB,kBAAkB,CAACY,OAAO,CAACG,MAAM,CAAC;IAClD,IAAI,CAACC,OAAO,EAAEC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK,IAAIN,OAAO,CAACO,QAAQ,KAAK,MAAMhB,SAAS,EAAE,CAAC,EAAE;IAChDJ,cAAc,CAAC,yCAAyC,CAAC;IACzD,MAAMiB,OAAO,GAAGf,wBAAwB,CAACW,OAAO,CAACO,QAAQ,CAAC;IAC1D,IAAI,CAACH,OAAO,EAAEC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK,IAAIN,OAAO,CAACQ,GAAG,KAAK,MAAMjB,SAAS,EAAE,CAAC,EAAE;IAC3CJ,cAAc,CAAC,8CAA8C,CAAC;IAC9D,MAAMiB,OAAO,GAAGd,mBAAmB,EAAE;IACrC,IAAI,CAACc,OAAO,EAAEC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK;IACHpB,YAAY,CAAC,sDAAsD,CAAC;IACpEM,OAAO,CAACiB,IAAI,EAAE;IACdJ,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHd,OAAO,CAACkB,KAAK,EAAE"}
@@ -2,19 +2,23 @@ import { FrodoCommand } from '../FrodoCommand';
2
2
  import { Option } from 'commander';
3
3
  import { Authenticate } from '@rockcarver/frodo-lib';
4
4
  import { verboseMessage } from '../../utils/Console.js';
5
- import { describeResourceType } from '../../ops/ResourceTypeOps';
5
+ import { describeResourceType, describeResourceTypeByName } from '../../ops/ResourceTypeOps';
6
6
  const {
7
7
  getTokens
8
8
  } = Authenticate;
9
9
  const program = new FrodoCommand('frodo authz type describe');
10
- program.description('Describe authorization resource types.').addOption(new Option('-i, --type-id <type-id>', 'Resource type id.').makeOptionMandatory()).addOption(new Option('--json', 'Output in JSON format.')).action(
10
+ program.description('Describe authorization resource types.').addOption(new Option('-i, --type-id <type-uuid>', 'Resource type uuid.')).addOption(new Option('-n, --type-name <type-name>', 'Resource type name.')).addOption(new Option('--json', 'Output in JSON format.')).action(
11
11
  // implement command logic inside action handler
12
12
  async (host, realm, user, password, options, command) => {
13
13
  command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
14
14
  if (options.typeId && (await getTokens())) {
15
- verboseMessage(`Describing authorization resource type ${options.typeId}...`);
15
+ verboseMessage(`Describing authorization resource type by uuid...`);
16
16
  const outcome = await describeResourceType(options.typeId, options.json);
17
17
  if (!outcome) process.exitCode = 1;
18
+ } else if (options.typeName && (await getTokens())) {
19
+ verboseMessage(`Describing authorization resource type by name...`);
20
+ const outcome = await describeResourceTypeByName(options.typeName, options.json);
21
+ if (!outcome) process.exitCode = 1;
18
22
  }
19
23
  // unrecognized combination of options or no options
20
24
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"authz-type-describe.js","names":["FrodoCommand","Option","Authenticate","verboseMessage","describeResourceType","getTokens","program","description","addOption","makeOptionMandatory","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","typeId","outcome","json","process","exitCode","help","parse"],"sources":["cli/authz/authz-type-describe.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console.js';\nimport { describeResourceType } from '../../ops/ResourceTypeOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo authz type describe');\n\nprogram\n .description('Describe authorization resource types.')\n .addOption(\n new Option(\n '-i, --type-id <type-id>',\n 'Resource type id.'\n ).makeOptionMandatory()\n )\n .addOption(new Option('--json', 'Output in JSON format.'))\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 (options.typeId && (await getTokens())) {\n verboseMessage(\n `Describing authorization resource type ${options.typeId}...`\n );\n const outcome = await describeResourceType(\n options.typeId,\n options.json\n );\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n verboseMessage('Unrecognized combination of options or no options...');\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,cAAc,QAAQ,wBAAwB;AACvD,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE,MAAM;EAAEC;AAAU,CAAC,GAAGH,YAAY;AAElC,MAAMI,OAAO,GAAG,IAAIN,YAAY,CAAC,2BAA2B,CAAC;AAE7DM,OAAO,CACJC,WAAW,CAAC,wCAAwC,CAAC,CACrDC,SAAS,CACR,IAAIP,MAAM,CACR,yBAAyB,EACzB,mBAAmB,CACpB,CAACQ,mBAAmB,EAAE,CACxB,CACAD,SAAS,CAAC,IAAIP,MAAM,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC,CACzDS,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,IAAID,OAAO,CAACG,MAAM,KAAK,MAAMb,SAAS,EAAE,CAAC,EAAE;IACzCF,cAAc,CACX,0CAAyCY,OAAO,CAACG,MAAO,KAAI,CAC9D;IACD,MAAMC,OAAO,GAAG,MAAMf,oBAAoB,CACxCW,OAAO,CAACG,MAAM,EACdH,OAAO,CAACK,IAAI,CACb;IACD,IAAI,CAACD,OAAO,EAAEE,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK;IACHnB,cAAc,CAAC,sDAAsD,CAAC;IACtEG,OAAO,CAACiB,IAAI,EAAE;IACdF,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHhB,OAAO,CAACkB,KAAK,EAAE"}
1
+ {"version":3,"file":"authz-type-describe.js","names":["FrodoCommand","Option","Authenticate","verboseMessage","describeResourceType","describeResourceTypeByName","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","typeId","outcome","json","process","exitCode","typeName","help","parse"],"sources":["cli/authz/authz-type-describe.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console.js';\nimport {\n describeResourceType,\n describeResourceTypeByName,\n} from '../../ops/ResourceTypeOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo authz type describe');\n\nprogram\n .description('Describe authorization resource types.')\n .addOption(new Option('-i, --type-id <type-uuid>', 'Resource type uuid.'))\n .addOption(new Option('-n, --type-name <type-name>', 'Resource type name.'))\n .addOption(new Option('--json', 'Output in JSON format.'))\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 (options.typeId && (await getTokens())) {\n verboseMessage(`Describing authorization resource type by uuid...`);\n const outcome = await describeResourceType(\n options.typeId,\n options.json\n );\n if (!outcome) process.exitCode = 1;\n } else if (options.typeName && (await getTokens())) {\n verboseMessage(`Describing authorization resource type by name...`);\n const outcome = await describeResourceTypeByName(\n options.typeName,\n options.json\n );\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n verboseMessage('Unrecognized combination of options or no options...');\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,cAAc,QAAQ,wBAAwB;AACvD,SACEC,oBAAoB,EACpBC,0BAA0B,QACrB,2BAA2B;AAElC,MAAM;EAAEC;AAAU,CAAC,GAAGJ,YAAY;AAElC,MAAMK,OAAO,GAAG,IAAIP,YAAY,CAAC,2BAA2B,CAAC;AAE7DO,OAAO,CACJC,WAAW,CAAC,wCAAwC,CAAC,CACrDC,SAAS,CAAC,IAAIR,MAAM,CAAC,2BAA2B,EAAE,qBAAqB,CAAC,CAAC,CACzEQ,SAAS,CAAC,IAAIR,MAAM,CAAC,6BAA6B,EAAE,qBAAqB,CAAC,CAAC,CAC3EQ,SAAS,CAAC,IAAIR,MAAM,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC,CACzDS,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,IAAID,OAAO,CAACG,MAAM,KAAK,MAAMZ,SAAS,EAAE,CAAC,EAAE;IACzCH,cAAc,CAAE,mDAAkD,CAAC;IACnE,MAAMgB,OAAO,GAAG,MAAMf,oBAAoB,CACxCW,OAAO,CAACG,MAAM,EACdH,OAAO,CAACK,IAAI,CACb;IACD,IAAI,CAACD,OAAO,EAAEE,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC,CAAC,MAAM,IAAIP,OAAO,CAACQ,QAAQ,KAAK,MAAMjB,SAAS,EAAE,CAAC,EAAE;IAClDH,cAAc,CAAE,mDAAkD,CAAC;IACnE,MAAMgB,OAAO,GAAG,MAAMd,0BAA0B,CAC9CU,OAAO,CAACQ,QAAQ,EAChBR,OAAO,CAACK,IAAI,CACb;IACD,IAAI,CAACD,OAAO,EAAEE,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK;IACHnB,cAAc,CAAC,sDAAsD,CAAC;IACtEI,OAAO,CAACiB,IAAI,EAAE;IACdH,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHf,OAAO,CAACkB,KAAK,EAAE"}
@@ -1,17 +1,44 @@
1
1
  import { FrodoCommand } from '../FrodoCommand';
2
2
  import { Option } from 'commander';
3
3
  import { Authenticate } from '@rockcarver/frodo-lib';
4
+ import { verboseMessage } from '../../utils/Console';
5
+ import { exportResourceTypeByNameToFile, exportResourceTypeToFile, exportResourceTypesToFile, exportResourceTypesToFiles } from '../../ops/ResourceTypeOps';
4
6
  const {
5
7
  getTokens
6
8
  } = Authenticate;
7
- const program = new FrodoCommand('frodo esv variable export');
8
- program.description('Export variables.').addOption(new Option('-i, --variable-id <variable-id>', 'Variable id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the export file.')).addOption(new Option('-a, --all', 'Export all variables to a single file. Ignored with -i.')).addOption(new Option('-A, --all-separate', 'Export all variables to separate files (*.variable.json) in the current directory. Ignored with -i or -a.')).action(
9
+ const program = new FrodoCommand('frodo authz type export');
10
+ program.description('Export authorization resource types.').addOption(new Option('-i, --type-id <type-uuid>', 'Resource type uuid. If specified, -a and -A are ignored.')).addOption(new Option('-n, --type-name <type-name>', 'Resource type name. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the export file.')).addOption(new Option('-a, --all', 'Export all resource types to a single file. Ignored with -i.')).addOption(new Option('-A, --all-separate', 'Export all resource types to separate files (*.resourcetype.authz.json) in the current directory. Ignored with -i, -n, or -a.')).action(
9
11
  // implement command logic inside action handler
10
12
  async (host, realm, user, password, options, command) => {
11
13
  command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
12
- if (await getTokens()) {
13
- // code goes here
14
- } else {
14
+ // export by uuid
15
+ if (options.typeId && (await getTokens())) {
16
+ verboseMessage('Exporting authorization resource type to file...');
17
+ const outcome = exportResourceTypeToFile(options.typeId, options.file);
18
+ if (!outcome) process.exitCode = 1;
19
+ }
20
+ // export by name
21
+ else if (options.typeName && (await getTokens())) {
22
+ verboseMessage('Exporting authorization resource type to file...');
23
+ const outcome = exportResourceTypeByNameToFile(options.typeName, options.file);
24
+ if (!outcome) process.exitCode = 1;
25
+ }
26
+ // -a/--all
27
+ else if (options.all && (await getTokens())) {
28
+ verboseMessage('Exporting all authorization resource types to file...');
29
+ const outcome = await exportResourceTypesToFile(options.file);
30
+ if (!outcome) process.exitCode = 1;
31
+ }
32
+ // -A/--all-separate
33
+ else if (options.allSeparate && (await getTokens())) {
34
+ verboseMessage('Exporting all authorization resource types to separate files...');
35
+ const outcome = await exportResourceTypesToFiles();
36
+ if (!outcome) process.exitCode = 1;
37
+ }
38
+ // unrecognized combination of options or no options
39
+ else {
40
+ verboseMessage('Unrecognized combination of options or no options...');
41
+ program.help();
15
42
  process.exitCode = 1;
16
43
  }
17
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"authz-type-export.js","names":["FrodoCommand","Option","Authenticate","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","process","exitCode","parse"],"sources":["cli/authz/authz-type-export.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo esv variable export');\n\nprogram\n .description('Export variables.')\n .addOption(\n new Option(\n '-i, --variable-id <variable-id>',\n 'Variable id. 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 variables to a single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all variables to separate files (*.variable.json) in the current directory. Ignored with -i or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n // code goes here\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,QAAQ,uBAAuB;AAEpD,MAAM;EAAEC;AAAU,CAAC,GAAGD,YAAY;AAElC,MAAME,OAAO,GAAG,IAAIJ,YAAY,CAAC,2BAA2B,CAAC;AAE7DI,OAAO,CACJC,WAAW,CAAC,mBAAmB,CAAC,CAChCC,SAAS,CACR,IAAIL,MAAM,CACR,iCAAiC,EACjC,mDAAmD,CACpD,CACF,CACAK,SAAS,CAAC,IAAIL,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC,CAAC,CACtEK,SAAS,CACR,IAAIL,MAAM,CACR,WAAW,EACX,yDAAyD,CAC1D,CACF,CACAK,SAAS,CACR,IAAIL,MAAM,CACR,oBAAoB,EACpB,2GAA2G,CAC5G,CACF,CACAM,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,MAAMV,SAAS,EAAE,EAAE;IACrB;EAAA,CACD,MAAM;IACLY,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHZ,OAAO,CAACa,KAAK,EAAE"}
1
+ {"version":3,"file":"authz-type-export.js","names":["FrodoCommand","Option","Authenticate","verboseMessage","exportResourceTypeByNameToFile","exportResourceTypeToFile","exportResourceTypesToFile","exportResourceTypesToFiles","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","typeId","outcome","file","process","exitCode","typeName","all","allSeparate","help","parse"],"sources":["cli/authz/authz-type-export.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console';\nimport {\n exportResourceTypeByNameToFile,\n exportResourceTypeToFile,\n exportResourceTypesToFile,\n exportResourceTypesToFiles,\n} from '../../ops/ResourceTypeOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo authz type export');\n\nprogram\n .description('Export authorization resource types.')\n .addOption(\n new Option(\n '-i, --type-id <type-uuid>',\n 'Resource type uuid. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-n, --type-name <type-name>',\n 'Resource type name. 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 resource types to a single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all resource types to separate files (*.resourcetype.authz.json) in the current directory. Ignored with -i, -n, or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // export by uuid\n if (options.typeId && (await getTokens())) {\n verboseMessage('Exporting authorization resource type to file...');\n const outcome = exportResourceTypeToFile(options.typeId, options.file);\n if (!outcome) process.exitCode = 1;\n }\n // export by name\n else if (options.typeName && (await getTokens())) {\n verboseMessage('Exporting authorization resource type to file...');\n const outcome = exportResourceTypeByNameToFile(\n options.typeName,\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // -a/--all\n else if (options.all && (await getTokens())) {\n verboseMessage('Exporting all authorization resource types to file...');\n const outcome = await exportResourceTypesToFile(options.file);\n if (!outcome) process.exitCode = 1;\n }\n // -A/--all-separate\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage(\n 'Exporting all authorization resource types to separate files...'\n );\n const outcome = await exportResourceTypesToFiles();\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n verboseMessage('Unrecognized combination of options or no options...');\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,cAAc,QAAQ,qBAAqB;AACpD,SACEC,8BAA8B,EAC9BC,wBAAwB,EACxBC,yBAAyB,EACzBC,0BAA0B,QACrB,2BAA2B;AAElC,MAAM;EAAEC;AAAU,CAAC,GAAGN,YAAY;AAElC,MAAMO,OAAO,GAAG,IAAIT,YAAY,CAAC,yBAAyB,CAAC;AAE3DS,OAAO,CACJC,WAAW,CAAC,sCAAsC,CAAC,CACnDC,SAAS,CACR,IAAIV,MAAM,CACR,2BAA2B,EAC3B,0DAA0D,CAC3D,CACF,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,6BAA6B,EAC7B,0DAA0D,CAC3D,CACF,CACAU,SAAS,CAAC,IAAIV,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC,CAAC,CACtEU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,8DAA8D,CAC/D,CACF,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,oBAAoB,EACpB,+HAA+H,CAChI,CACF,CACAW,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK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AO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHf,OAAO,CAACoB,KAAK,EAAE"}
@@ -1,17 +1,50 @@
1
1
  import { FrodoCommand } from '../FrodoCommand';
2
2
  import { Option } from 'commander';
3
3
  import { Authenticate } from '@rockcarver/frodo-lib';
4
+ import { verboseMessage } from '../../utils/Console';
5
+ import { importFirstResourceTypeFromFile, importResourceTypeByNameFromFile, importResourceTypeFromFile, importResourceTypesFromFile, importResourceTypesFromFiles } from '../../ops/ResourceTypeOps';
4
6
  const {
5
7
  getTokens
6
8
  } = Authenticate;
7
- const program = new FrodoCommand('frodo esv variable import');
8
- program.description('Import variables.').addOption(new Option('-i, --variable-id <variable-id>', 'Variable id. If specified, only one variable is imported and the options -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the file to import.')).addOption(new Option('-a, --all', 'Import all variables from single file. Ignored with -i.')).addOption(new Option('-A, --all-separate', 'Import all variables from separate files (*.variable.json) in the current directory. Ignored with -i or -a.')).action(
9
+ const program = new FrodoCommand('frodo authz type import');
10
+ program.description('Import authorization resource types.').addOption(new Option('-i, --type-id <type-uuid>', 'Resource type uuid. If specified, -a and -A are ignored.')).addOption(new Option('-n, --type-name <type-name>', 'Resource type name. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the file to import.')).addOption(new Option('-a, --all', 'Import all resource types from single file. Ignored with -i.')).addOption(new Option('-A, --all-separate', 'Import all resource types from separate files (*.resourcetype.authz.json) in the current directory. Ignored with -i, -n, or -a.')).action(
9
11
  // implement command logic inside action handler
10
12
  async (host, realm, user, password, options, command) => {
11
13
  command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
12
- if (await getTokens()) {
13
- // code goes here
14
- } else {
14
+ // import by uuid
15
+ if (options.typeId && (await getTokens())) {
16
+ verboseMessage('Importing authorization resource type by uuid from file...');
17
+ const outcome = importResourceTypeFromFile(options.typeId, options.file);
18
+ if (!outcome) process.exitCode = 1;
19
+ }
20
+ // import by name
21
+ else if (options.typeName && (await getTokens())) {
22
+ verboseMessage('Importing authorization resource type by name from file...');
23
+ const outcome = importResourceTypeByNameFromFile(options.typeName, options.file);
24
+ if (!outcome) process.exitCode = 1;
25
+ }
26
+ // -a/--all
27
+ else if (options.all && (await getTokens())) {
28
+ verboseMessage('Importing all authorization resource types from file...');
29
+ const outcome = await importResourceTypesFromFile(options.file);
30
+ if (!outcome) process.exitCode = 1;
31
+ }
32
+ // -A/--all-separate
33
+ else if (options.allSeparate && (await getTokens())) {
34
+ verboseMessage('Importing all authorization resource types from separate files...');
35
+ const outcome = await importResourceTypesFromFiles();
36
+ if (!outcome) process.exitCode = 1;
37
+ }
38
+ // import first
39
+ else if (options.file && (await getTokens())) {
40
+ verboseMessage(`Importing first authorization resource type from file "${options.file}"...`);
41
+ const outcome = await importFirstResourceTypeFromFile(options.file);
42
+ if (!outcome) process.exitCode = 1;
43
+ }
44
+ // unrecognized combination of options or no options
45
+ else {
46
+ verboseMessage('Unrecognized combination of options or no options...');
47
+ program.help();
15
48
  process.exitCode = 1;
16
49
  }
17
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"authz-type-import.js","names":["FrodoCommand","Option","Authenticate","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","process","exitCode","parse"],"sources":["cli/authz/authz-type-import.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo esv variable import');\n\nprogram\n .description('Import variables.')\n .addOption(\n new Option(\n '-i, --variable-id <variable-id>',\n 'Variable id. If specified, only one variable is imported and the options -a and -A are ignored.'\n )\n )\n .addOption(new Option('-f, --file <file>', 'Name of the file to import.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Import all variables from single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all variables from separate files (*.variable.json) in the current directory. Ignored with -i or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n // code goes here\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,QAAQ,uBAAuB;AAEpD,MAAM;EAAEC;AAAU,CAAC,GAAGD,YAAY;AAElC,MAAME,OAAO,GAAG,IAAIJ,YAAY,CAAC,2BAA2B,CAAC;AAE7DI,OAAO,CACJC,WAAW,CAAC,mBAAmB,CAAC,CAChCC,SAAS,CACR,IAAIL,MAAM,CACR,iCAAiC,EACjC,iGAAiG,CAClG,CACF,CACAK,SAAS,CAAC,IAAIL,MAAM,CAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC,CACzEK,SAAS,CACR,IAAIL,MAAM,CACR,WAAW,EACX,yDAAyD,CAC1D,CACF,CACAK,SAAS,CACR,IAAIL,MAAM,CACR,oBAAoB,EACpB,6GAA6G,CAC9G,CACF,CACAM,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,MAAMV,SAAS,EAAE,EAAE;IACrB;EAAA,CACD,MAAM;IACLY,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHZ,OAAO,CAACa,KAAK,EAAE"}
1
+ {"version":3,"file":"authz-type-import.js","names":["FrodoCommand","Option","Authenticate","verboseMessage","importFirstResourceTypeFromFile","importResourceTypeByNameFromFile","importResourceTypeFromFile","importResourceTypesFromFile","importResourceTypesFromFiles","getTokens","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","typeId","outcome","file","process","exitCode","typeName","all","allSeparate","help","parse"],"sources":["cli/authz/authz-type-import.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console';\nimport {\n importFirstResourceTypeFromFile,\n importResourceTypeByNameFromFile,\n importResourceTypeFromFile,\n importResourceTypesFromFile,\n importResourceTypesFromFiles,\n} from '../../ops/ResourceTypeOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo authz type import');\n\nprogram\n .description('Import authorization resource types.')\n .addOption(\n new Option(\n '-i, --type-id <type-uuid>',\n 'Resource type uuid. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-n, --type-name <type-name>',\n 'Resource type name. If specified, -a and -A are ignored.'\n )\n )\n .addOption(new Option('-f, --file <file>', 'Name of the file to import.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Import all resource types from single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all resource types from separate files (*.resourcetype.authz.json) in the current directory. Ignored with -i, -n, or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // import by uuid\n if (options.typeId && (await getTokens())) {\n verboseMessage(\n 'Importing authorization resource type by uuid from file...'\n );\n const outcome = importResourceTypeFromFile(\n options.typeId,\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // import by name\n else if (options.typeName && (await getTokens())) {\n verboseMessage(\n 'Importing authorization resource type by name from file...'\n );\n const outcome = importResourceTypeByNameFromFile(\n options.typeName,\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // -a/--all\n else if (options.all && (await getTokens())) {\n verboseMessage(\n 'Importing all authorization resource types from file...'\n );\n const outcome = await importResourceTypesFromFile(options.file);\n if (!outcome) process.exitCode = 1;\n }\n // -A/--all-separate\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage(\n 'Importing all authorization resource types from separate files...'\n );\n const outcome = await importResourceTypesFromFiles();\n if (!outcome) process.exitCode = 1;\n }\n // import first\n else if (options.file && (await getTokens())) {\n verboseMessage(\n `Importing first authorization resource type from file \"${options.file}\"...`\n );\n const outcome = await importFirstResourceTypeFromFile(options.file);\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n verboseMessage('Unrecognized combination of options or no options...');\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,cAAc,QAAQ,qBAAqB;AACpD,SACEC,+BAA+B,EAC/BC,gCAAgC,EAChCC,0BAA0B,EAC1BC,2BAA2B,EAC3BC,4BAA4B,QACvB,2BAA2B;AAElC,MAAM;EAAEC;AAAU,CAAC,GAAGP,YAAY;AAElC,MAAMQ,OAAO,GAAG,IAAIV,YAAY,CAAC,yBAAyB,CAAC;AAE3DU,OAAO,CACJC,WAAW,CAAC,sCAAsC,CAAC,CACnDC,SAAS,CACR,IAAIX,MAAM,CACR,2BAA2B,EAC3B,0DAA0D,CAC3D,CACF,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,6BAA6B,EAC7B,0DAA0D,CAC3D,CACF,CACAW,SAAS,CAAC,IAAIX,MAAM,CAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC,CACzEW,SAAS,CACR,IAAIX,MAAM,CACR,WAAW,EACX,8DAA8D,CAC/D,CACF,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,oBAAoB,EACpB,iIAAiI,CAClI,CACF,CACAY,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C;EACpC;EACA;EAAA,KACK,IAAIP,OAAO,CAACK,IAAI,KAAK,MAAMd,SAAS,EAAE,CAAC,EAAE;IAC5CN,cAAc,CACX,0DAAyDe,OAAO,CAACK,IAAK,MAAK,CAC7E;IACD,MAAMD,OAAO,GAAG,MAAMlB,+BAA+B,CAACc,OAAO,CAACK,IAAI,CAAC;IACnE,IAAI,CAACD,OAAO,EAAEE,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK;IACHtB,cAAc,CAAC,sDAAsD,CAAC;IACtEO,OAAO,CAACmB,IAAI,EAAE;IACdL,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHf,OAAO,CAACoB,KAAK,EAAE"}
@@ -1,25 +1,19 @@
1
1
  import { FrodoCommand } from '../FrodoCommand';
2
- import { Authenticate, Variables } from '@rockcarver/frodo-lib';
2
+ import { Option } from 'commander';
3
+ import { Authenticate } from '@rockcarver/frodo-lib';
3
4
  import { verboseMessage } from '../../utils/Console.js';
4
5
  import { listResourceTypes } from '../../ops/ResourceTypeOps';
5
6
  const {
6
7
  getTokens
7
8
  } = Authenticate;
8
- const {
9
- listVariables
10
- } = Variables;
11
9
  const program = new FrodoCommand('frodo authz type list');
12
- program.description('List authorization resource types.')
13
- // .addOption(
14
- // new Option('-l, --long', 'Long with all fields.').default(false, 'false')
15
- // )
16
- .action(
10
+ program.description('List authorization resource types.').addOption(new Option('-l, --long', 'Long with more fields.').default(false, 'false')).action(
17
11
  // implement command logic inside action handler
18
12
  async (host, realm, user, password, options, command) => {
19
13
  command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
20
14
  if (await getTokens()) {
21
15
  verboseMessage('Listing resource types...');
22
- const outcome = listResourceTypes();
16
+ const outcome = listResourceTypes(options.long);
23
17
  if (!outcome) process.exitCode = 1;
24
18
  } else {
25
19
  process.exitCode = 1;
@@ -1 +1 @@
1
- {"version":3,"file":"authz-type-list.js","names":["FrodoCommand","Authenticate","Variables","verboseMessage","listResourceTypes","getTokens","listVariables","program","description","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","outcome","process","exitCode","parse"],"sources":["cli/authz/authz-type-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate, Variables } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console.js';\nimport { listResourceTypes } from '../../ops/ResourceTypeOps';\n\nconst { getTokens } = Authenticate;\nconst { listVariables } = Variables;\n\nconst program = new FrodoCommand('frodo authz type list');\n\nprogram\n .description('List authorization resource types.')\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 resource types...');\n const outcome = listResourceTypes();\n if (!outcome) process.exitCode = 1;\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;AAE9C,SAASC,YAAY,EAAEC,SAAS,QAAQ,uBAAuB;AAC/D,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,iBAAiB,QAAQ,2BAA2B;AAE7D,MAAM;EAAEC;AAAU,CAAC,GAAGJ,YAAY;AAClC,MAAM;EAAEK;AAAc,CAAC,GAAGJ,SAAS;AAEnC,MAAMK,OAAO,GAAG,IAAIP,YAAY,CAAC,uBAAuB,CAAC;AAEzDO,OAAO,CACJC,WAAW,CAAC,oCAAoC;AACjD;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,MAAMV,SAAS,EAAE,EAAE;IACrBF,cAAc,CAAC,2BAA2B,CAAC;IAC3C,MAAMc,OAAO,GAAGb,iBAAiB,EAAE;IACnC,IAAI,CAACa,OAAO,EAAEC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC,CAAC,MAAM;IACLD,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHZ,OAAO,CAACa,KAAK,EAAE"}
1
+ {"version":3,"file":"authz-type-list.js","names":["FrodoCommand","Option","Authenticate","verboseMessage","listResourceTypes","getTokens","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","outcome","long","process","exitCode","parse"],"sources":["cli/authz/authz-type-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console.js';\nimport { listResourceTypes } from '../../ops/ResourceTypeOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo authz type list');\n\nprogram\n .description('List authorization resource types.')\n .addOption(\n new Option('-l, --long', 'Long with more fields.').default(false, 'false')\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n verboseMessage('Listing resource types...');\n const outcome = listResourceTypes(options.long);\n if (!outcome) process.exitCode = 1;\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,QAAQ,uBAAuB;AACpD,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,iBAAiB,QAAQ,2BAA2B;AAE7D,MAAM;EAAEC;AAAU,CAAC,GAAGH,YAAY;AAElC,MAAMI,OAAO,GAAG,IAAIN,YAAY,CAAC,uBAAuB,CAAC;AAEzDM,OAAO,CACJC,WAAW,CAAC,oCAAoC,CAAC,CACjDC,SAAS,CACR,IAAIP,MAAM,CAAC,YAAY,EAAE,wBAAwB,CAAC,CAACQ,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAC3E,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,CAAC,2BAA2B,CAAC;IAC3C,MAAMe,OAAO,GAAGd,iBAAiB,CAACW,OAAO,CAACI,IAAI,CAAC;IAC/C,IAAI,CAACD,OAAO,EAAEE,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC,CAAC,MAAM;IACLD,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEHf,OAAO,CAACgB,KAAK,EAAE"}
@@ -10,7 +10,9 @@ const {
10
10
  exportPolicy,
11
11
  exportPolicies,
12
12
  exportPoliciesByPolicySet,
13
- importPolicy
13
+ importPolicy,
14
+ importFirstPolicy,
15
+ importPolicies
14
16
  } = Policy;
15
17
  const {
16
18
  getRealmName
@@ -364,8 +366,8 @@ export async function exportPoliciesByPolicySetToFiles(policySetId, options = {
364
366
  }
365
367
 
366
368
  /**
367
- * Import policy set from file
368
- * @param {string} policyId policy set name
369
+ * Import policy from file
370
+ * @param {string} policyId policy id/name
369
371
  * @param {string} file file name
370
372
  * @param {PolicyImportOptions} options import options
371
373
  * @returns {Promise<boolean>} true if successful, false otherwise
@@ -389,4 +391,95 @@ export async function importPolicyFromFile(policyId, file, options = {
389
391
  debugMessage(`cli.PolicyOps.importPolicyFromFile: end`);
390
392
  return outcome;
391
393
  }
394
+
395
+ /**
396
+ * Import first policy from file
397
+ * @param {string} file file name
398
+ * @param {PolicyImportOptions} options import options
399
+ * @returns {Promise<boolean>} true if successful, false otherwise
400
+ */
401
+ export async function importFirstPolicyFromFile(file, options = {
402
+ deps: true
403
+ }) {
404
+ let outcome = false;
405
+ debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: begin`);
406
+ showSpinner(`Importing ${file}...`);
407
+ try {
408
+ const data = fs.readFileSync(file, 'utf8');
409
+ const fileData = JSON.parse(data);
410
+ await importFirstPolicy(fileData, options);
411
+ outcome = true;
412
+ succeedSpinner(`Imported ${file}.`);
413
+ } catch (error) {
414
+ failSpinner(`Error importing ${file}.`);
415
+ printMessage(error, 'error');
416
+ }
417
+ debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: end`);
418
+ return outcome;
419
+ }
420
+
421
+ /**
422
+ * Import policies from file
423
+ * @param {string} file file name
424
+ * @param {PolicyImportOptions} options import options
425
+ * @returns {Promise<boolean>} true if successful, false otherwise
426
+ */
427
+ export async function importPoliciesFromFile(file, options = {
428
+ deps: true
429
+ }) {
430
+ let outcome = false;
431
+ debugMessage(`cli.PolicyOps.importPoliciesFromFile: begin`);
432
+ showSpinner(`Importing ${file}...`);
433
+ try {
434
+ const data = fs.readFileSync(file, 'utf8');
435
+ const fileData = JSON.parse(data);
436
+ await importPolicies(fileData, options);
437
+ outcome = true;
438
+ succeedSpinner(`Imported ${file}.`);
439
+ } catch (error) {
440
+ failSpinner(`Error importing ${file}.`);
441
+ printMessage(error, 'error');
442
+ }
443
+ debugMessage(`cli.PolicyOps.importPoliciesFromFile: end`);
444
+ return outcome;
445
+ }
446
+
447
+ /**
448
+ * Import policies from files
449
+ * @param {PolicyImportOptions} options import options
450
+ * @returns {Promise<boolean>} true if successful, false otherwise
451
+ */
452
+ export async function importPoliciesFromFiles(options = {
453
+ deps: true
454
+ }) {
455
+ const errors = [];
456
+ try {
457
+ debugMessage(`cli.PolicyOps.importPoliciesFromFiles: begin`);
458
+ const names = fs.readdirSync('.');
459
+ const files = names.filter(name => name.toLowerCase().endsWith('.policy.authz.json'));
460
+ createProgressBar(files.length, 'Importing policies...');
461
+ let total = 0;
462
+ for (const file of files) {
463
+ try {
464
+ const data = fs.readFileSync(file, 'utf8');
465
+ const fileData = JSON.parse(data);
466
+ const count = Object.keys(fileData.policyset).length;
467
+ total += count;
468
+ await importPolicies(fileData, options);
469
+ updateProgressBar(`Imported ${count} policies from ${file}`);
470
+ } catch (error) {
471
+ errors.push(error);
472
+ updateProgressBar(`Error importing policies from ${file}`);
473
+ printMessage(error, 'error');
474
+ }
475
+ }
476
+ stopProgressBar(`Finished importing ${total} policies from ${files.length} files.`);
477
+ } catch (error) {
478
+ errors.push(error);
479
+ stopProgressBar(`Error importing policies from files.`);
480
+ printMessage(error, 'error');
481
+ }
482
+ debugMessage(`cli.PolicyOps.importPoliciesFromFiles: end`);
483
+ return 0 === errors.length;
484
+ }
392
485
  //# sourceMappingURL=PolicyOps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PolicyOps.js","names":["fs","Policy","Utils","state","createObjectTable","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","deletePolicy","_deletePolicy","getPolicy","getPolicies","getPoliciesByPolicySet","exportPolicy","exportPolicies","exportPoliciesByPolicySet","importPolicy","getRealmName","listPolicies","long","outcome","policies","sort","a","b","_id","localeCompare","policy","err","message","listPoliciesByPolicySet","policySetId","describePolicy","policyId","json","policySet","table","toString","errors","error","length","errorMessages","map","join","deletePolicies","push","deletePoliciesByPolicySet","exportPolicyToFile","file","options","useStringArrays","deps","fileName","exportData","exportPoliciesToFile","getRealm","exportPoliciesByPolicySetToFile","exportPoliciesToFiles","exportPoliciesByPolicySetToFiles","importPolicyFromFile","data","readFileSync","fileData","JSON","parse"],"sources":["ops/PolicyOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { PolicySkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { Policy, Utils, state } from '@rockcarver/frodo-lib';\nimport {\n createObjectTable,\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getTypedFilename,\n saveJsonToFile,\n titleCase,\n} from '../utils/ExportImportUtils';\nimport {\n PolicyExportOptions,\n PolicyImportOptions,\n PolicyExportInterface,\n} from '@rockcarver/frodo-lib/types/ops/PolicyOps';\n\nconst {\n deletePolicy: _deletePolicy,\n getPolicy,\n getPolicies,\n getPoliciesByPolicySet,\n exportPolicy,\n exportPolicies,\n exportPoliciesByPolicySet,\n importPolicy,\n} = Policy;\nconst { getRealmName } = Utils;\n\n/**\n * List policies\n * @param {boolean} long list with details\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listPolicies(long = false): Promise<boolean> {\n let outcome = false;\n try {\n const policies = await getPolicies();\n policies.sort((a, b) => a._id.localeCompare(b._id));\n for (const policy of policies) {\n if (!long) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicies ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * List policies by policy set\n * @param {string} policySetId policy set id/name\n * @param {boolean} long list with details\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listPoliciesByPolicySet(\n policySetId: string,\n long = false\n): Promise<boolean> {\n let outcome = false;\n try {\n const policies = await getPoliciesByPolicySet(policySetId);\n policies.sort((a, b) => a._id.localeCompare(b._id));\n for (const policy of policies) {\n if (!long) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicies ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Describe policy\n * @param {string} policyId policy id/name\n * @param {Object} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describePolicy(\n policyId: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n const policySet = await getPolicy(policyId);\n outcome = true;\n if (json) {\n printMessage(policySet, 'data');\n } else {\n const table = createObjectTable(policySet);\n printMessage(table.toString(), 'data');\n }\n return outcome;\n}\n\n/**\n * Delete policy\n * @param {string} policyId policy id/name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicy(policyId: string): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePolicy: begin`);\n showSpinner(`Deleting ${policyId}...`);\n let outcome = false;\n const errors = [];\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await _deletePolicy(policyId);\n } catch (error) {\n printMessage(`Error deleting policy ${policyId}: ${error}`, 'error');\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n failSpinner(`Error deleting ${policyId}: ${errorMessages}`);\n } else {\n succeedSpinner(`Deleted ${policyId}.`);\n outcome = true;\n }\n debugMessage(`cli.PolicyOps.deletePolicy: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Delete all policies\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicies(): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePolicies: begin`);\n let outcome = false;\n const errors = [];\n let policies: PolicySkeleton[] = [];\n try {\n showSpinner(`Retrieving all policies...`);\n try {\n policies = await getPolicies();\n succeedSpinner(`Found ${policies.length} policies.`);\n } catch (error) {\n error.message = `Error retrieving all policies: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (policies.length)\n createProgressBar(\n policies.length,\n `Deleting ${policies.length} policies...`\n );\n for (const policy of policies) {\n const policyId = policy._id;\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await _deletePolicy(policyId);\n updateProgressBar(`Deleted ${policyId}`);\n } catch (error) {\n error.message = `Error deleting policy ${policyId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting policies: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (policies.length)\n stopProgressBar(`Error deleting all policies: ${errorMessages}`);\n } else {\n if (policies.length)\n stopProgressBar(`Deleted ${policies.length} policies.`);\n outcome = true;\n }\n }\n debugMessage(`cli.PolicyOps.deletePolicies: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Delete all policies in policy set\n * @param {string} policySetId policy set id/name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePoliciesByPolicySet(\n policySetId: string\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePoliciesByPolicySet: begin`);\n let outcome = false;\n const errors = [];\n let policies: PolicySkeleton[] = [];\n try {\n showSpinner(`Retrieving all policies from policy set ${policySetId}...`);\n try {\n policies = await getPoliciesByPolicySet(policySetId);\n succeedSpinner(\n `Found ${policies.length} policies in policy set ${policySetId}.`\n );\n } catch (error) {\n error.message = `Error retrieving all policies from policy set ${policySetId}: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (policies.length)\n createProgressBar(\n policies.length,\n `Deleting ${policies.length} policies from policy set ${policySetId}...`\n );\n for (const policy of policies) {\n const policyId = policy._id;\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await _deletePolicy(policyId);\n updateProgressBar(`Deleted ${policyId}`);\n } catch (error) {\n error.message = `Error deleting policy ${policyId} from policy set ${policySetId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting policies from policy set ${policySetId}: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (policies.length)\n stopProgressBar(\n `Error deleting all policies from policy set ${policySetId}: ${errorMessages}`\n );\n } else {\n if (policies.length)\n stopProgressBar(`Deleted ${policies.length} policies.`);\n outcome = true;\n }\n }\n debugMessage(\n `cli.PolicyOps.deletePoliciesByPolicySet: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Export policy to file\n * @param {string} policyId policy id/name\n * @param {string} file file name\n * @param {ApplicationExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPolicyToFile(\n policyId: string,\n file: string,\n options: PolicyExportOptions = { useStringArrays: true, deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPolicyToFile: begin`);\n showSpinner(`Exporting ${policyId}...`);\n try {\n let fileName = getTypedFilename(policyId, 'policy.authz');\n if (file) {\n fileName = file;\n }\n const exportData = await exportPolicy(policyId, options);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported ${policyId} to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${policyId}: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPolicyToFile: end`);\n return outcome;\n}\n\n/**\n * Export policies to file\n * @param {string} file file name\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesToFile(\n file: string,\n options: PolicyExportOptions = { useStringArrays: true, deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: begin`);\n showSpinner(`Exporting all policy sets...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}Policies`,\n 'policy.authz'\n );\n if (file) {\n fileName = file;\n }\n const exportData = await exportPolicies(options);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported all policy sets to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting policy sets: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: end`);\n return outcome;\n}\n\n/**\n * Export policies to file\n * @param {string} policySetId policy set id/name\n * @param {string} file file name\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesByPolicySetToFile(\n policySetId: string,\n file: string,\n options: PolicyExportOptions = { useStringArrays: true, deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: begin`);\n showSpinner(`Exporting all policy sets...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}Policies`,\n 'policy.authz'\n );\n if (file) {\n fileName = file;\n }\n const exportData = await exportPoliciesByPolicySet(policySetId, options);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported all policy sets to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting policy sets: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: end`);\n return outcome;\n}\n\n/**\n * Export all policies to separate files\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesToFiles(\n options: PolicyExportOptions = { useStringArrays: true, deps: true }\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: begin`);\n const errors = [];\n try {\n const policies: PolicySkeleton[] = await getPolicies();\n createProgressBar(policies.length, 'Exporting policy sets...');\n for (const policy of policies) {\n const file = getTypedFilename(policy._id, 'policy.authz');\n try {\n const exportData: PolicyExportInterface = await exportPolicy(\n policy._id,\n options\n );\n saveJsonToFile(exportData, file);\n updateProgressBar(`Exported ${policy._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${policy._id}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting policy sets to files`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Export all policies to separate files\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesByPolicySetToFiles(\n policySetId: string,\n options: PolicyExportOptions = { useStringArrays: true, deps: true }\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: begin`);\n const errors = [];\n try {\n const policies: PolicySkeleton[] = await getPoliciesByPolicySet(\n policySetId\n );\n createProgressBar(\n policies.length,\n `Exporting policies in policy set ${policySetId}...`\n );\n for (const policy of policies) {\n const file = getTypedFilename(policy._id, 'policy.authz');\n try {\n const exportData: PolicyExportInterface = await exportPolicy(\n policy._id,\n options\n );\n saveJsonToFile(exportData, file);\n updateProgressBar(`Exported ${policy._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${policy._id}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting policy sets to files`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import policy set from file\n * @param {string} policyId policy set name\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPolicyFromFile(\n policyId: string,\n file: string,\n options: PolicyImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.importPolicyFromFile: begin`);\n showSpinner(`Importing ${policyId}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importPolicy(policyId, fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${policyId}.`);\n } catch (error) {\n failSpinner(`Error importing ${policyId}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPolicyFromFile: end`);\n return outcome;\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAEnB,SAASC,MAAM,EAAEC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAC5D,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,gBAAgB,EAChB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,MAAM;AAC5B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAemB,oBAAoB,CACxC1B,QAAgB,EAChBe,IAAY,EACZC,OAA4B,GAAG;EAAEE,IAAI,EAAE;AAAK,CAAC,EAC3B;EAClB,IAAI/B,OAAO,GAAG,KAAK;EACnBtB,YAAY,CAAE,2CAA0C,CAAC;EACzDG,WAAW,CAAE,aAAYgC,QAAS,KAAI,CAAC;EACvC,IAAI;IACF,MAAM2B,IAAI,GAAGpE,EAAE,CAACqE,YAAY,CAACb,IAAI,EAAE,MAAM,CAAC;IAC1C,MAAMc,QAAQ,GAAGC,IAAI,CAACC,KAAK,CAACJ,IAAI,CAAC;IACjC,MAAM5C,YAAY,CAACiB,QAAQ,EAAE6B,QAAQ,EAAEb,OAAO,CAAC;IAC/C7B,OAAO,GAAG,IAAI;IACdjB,cAAc,CAAE,YAAW8B,QAAS,GAAE,CAAC;EACzC,CAAC,CAAC,OAAOM,KAAK,EAAE;IACdxC,WAAW,CAAE,mBAAkBkC,QAAS,GAAE,CAAC;IAC3CjC,YAAY,CAACuC,KAAK,EAAE,OAAO,CAAC;EAC9B;EACAzC,YAAY,CAAE,yCAAwC,CAAC;EACvD,OAAOsB,OAAO;AAChB"}
1
+ {"version":3,"file":"PolicyOps.js","names":["fs","Policy","Utils","state","createObjectTable","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","deletePolicy","_deletePolicy","getPolicy","getPolicies","getPoliciesByPolicySet","exportPolicy","exportPolicies","exportPoliciesByPolicySet","importPolicy","importFirstPolicy","importPolicies","getRealmName","listPolicies","long","outcome","policies","sort","a","b","_id","localeCompare","policy","err","message","listPoliciesByPolicySet","policySetId","describePolicy","policyId","json","policySet","table","toString","errors","error","length","errorMessages","map","join","deletePolicies","push","deletePoliciesByPolicySet","exportPolicyToFile","file","options","useStringArrays","deps","fileName","exportData","exportPoliciesToFile","getRealm","exportPoliciesByPolicySetToFile","exportPoliciesToFiles","exportPoliciesByPolicySetToFiles","importPolicyFromFile","data","readFileSync","fileData","JSON","parse","importFirstPolicyFromFile","importPoliciesFromFile","importPoliciesFromFiles","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","policyset"],"sources":["ops/PolicyOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { PolicySkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { Policy, Utils, state } from '@rockcarver/frodo-lib';\nimport {\n createObjectTable,\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getTypedFilename,\n saveJsonToFile,\n titleCase,\n} from '../utils/ExportImportUtils';\nimport {\n PolicyExportOptions,\n PolicyImportOptions,\n PolicyExportInterface,\n} from '@rockcarver/frodo-lib/types/ops/PolicyOps';\n\nconst {\n deletePolicy: _deletePolicy,\n getPolicy,\n getPolicies,\n getPoliciesByPolicySet,\n exportPolicy,\n exportPolicies,\n exportPoliciesByPolicySet,\n importPolicy,\n importFirstPolicy,\n importPolicies,\n} = Policy;\nconst { getRealmName } = Utils;\n\n/**\n * List policies\n * @param {boolean} long list with details\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listPolicies(long = false): Promise<boolean> {\n let outcome = false;\n try {\n const policies = await getPolicies();\n policies.sort((a, b) => a._id.localeCompare(b._id));\n for (const policy of policies) {\n if (!long) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicies ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * List policies by policy set\n * @param {string} policySetId policy set id/name\n * @param {boolean} long list with details\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listPoliciesByPolicySet(\n policySetId: string,\n long = false\n): Promise<boolean> {\n let outcome = false;\n try {\n const policies = await getPoliciesByPolicySet(policySetId);\n policies.sort((a, b) => a._id.localeCompare(b._id));\n for (const policy of policies) {\n if (!long) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicies ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Describe policy\n * @param {string} policyId policy id/name\n * @param {Object} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describePolicy(\n policyId: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n const policySet = await getPolicy(policyId);\n outcome = true;\n if (json) {\n printMessage(policySet, 'data');\n } else {\n const table = createObjectTable(policySet);\n printMessage(table.toString(), 'data');\n }\n return outcome;\n}\n\n/**\n * Delete policy\n * @param {string} policyId policy id/name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicy(policyId: string): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePolicy: begin`);\n showSpinner(`Deleting ${policyId}...`);\n let outcome = false;\n const errors = [];\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await _deletePolicy(policyId);\n } catch (error) {\n printMessage(`Error deleting policy ${policyId}: ${error}`, 'error');\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n failSpinner(`Error deleting ${policyId}: ${errorMessages}`);\n } else {\n succeedSpinner(`Deleted ${policyId}.`);\n outcome = true;\n }\n debugMessage(`cli.PolicyOps.deletePolicy: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Delete all policies\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicies(): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePolicies: begin`);\n let outcome = false;\n const errors = [];\n let policies: PolicySkeleton[] = [];\n try {\n showSpinner(`Retrieving all policies...`);\n try {\n policies = await getPolicies();\n succeedSpinner(`Found ${policies.length} policies.`);\n } catch (error) {\n error.message = `Error retrieving all policies: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (policies.length)\n createProgressBar(\n policies.length,\n `Deleting ${policies.length} policies...`\n );\n for (const policy of policies) {\n const policyId = policy._id;\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await _deletePolicy(policyId);\n updateProgressBar(`Deleted ${policyId}`);\n } catch (error) {\n error.message = `Error deleting policy ${policyId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting policies: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (policies.length)\n stopProgressBar(`Error deleting all policies: ${errorMessages}`);\n } else {\n if (policies.length)\n stopProgressBar(`Deleted ${policies.length} policies.`);\n outcome = true;\n }\n }\n debugMessage(`cli.PolicyOps.deletePolicies: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Delete all policies in policy set\n * @param {string} policySetId policy set id/name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePoliciesByPolicySet(\n policySetId: string\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePoliciesByPolicySet: begin`);\n let outcome = false;\n const errors = [];\n let policies: PolicySkeleton[] = [];\n try {\n showSpinner(`Retrieving all policies from policy set ${policySetId}...`);\n try {\n policies = await getPoliciesByPolicySet(policySetId);\n succeedSpinner(\n `Found ${policies.length} policies in policy set ${policySetId}.`\n );\n } catch (error) {\n error.message = `Error retrieving all policies from policy set ${policySetId}: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (policies.length)\n createProgressBar(\n policies.length,\n `Deleting ${policies.length} policies from policy set ${policySetId}...`\n );\n for (const policy of policies) {\n const policyId = policy._id;\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await _deletePolicy(policyId);\n updateProgressBar(`Deleted ${policyId}`);\n } catch (error) {\n error.message = `Error deleting policy ${policyId} from policy set ${policySetId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting policies from policy set ${policySetId}: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (policies.length)\n stopProgressBar(\n `Error deleting all policies from policy set ${policySetId}: ${errorMessages}`\n );\n } else {\n if (policies.length)\n stopProgressBar(`Deleted ${policies.length} policies.`);\n outcome = true;\n }\n }\n debugMessage(\n `cli.PolicyOps.deletePoliciesByPolicySet: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Export policy to file\n * @param {string} policyId policy id/name\n * @param {string} file file name\n * @param {ApplicationExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPolicyToFile(\n policyId: string,\n file: string,\n options: PolicyExportOptions = { useStringArrays: true, deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPolicyToFile: begin`);\n showSpinner(`Exporting ${policyId}...`);\n try {\n let fileName = getTypedFilename(policyId, 'policy.authz');\n if (file) {\n fileName = file;\n }\n const exportData = await exportPolicy(policyId, options);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported ${policyId} to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${policyId}: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPolicyToFile: end`);\n return outcome;\n}\n\n/**\n * Export policies to file\n * @param {string} file file name\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesToFile(\n file: string,\n options: PolicyExportOptions = { useStringArrays: true, deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: begin`);\n showSpinner(`Exporting all policy sets...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}Policies`,\n 'policy.authz'\n );\n if (file) {\n fileName = file;\n }\n const exportData = await exportPolicies(options);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported all policy sets to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting policy sets: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: end`);\n return outcome;\n}\n\n/**\n * Export policies to file\n * @param {string} policySetId policy set id/name\n * @param {string} file file name\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesByPolicySetToFile(\n policySetId: string,\n file: string,\n options: PolicyExportOptions = { useStringArrays: true, deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: begin`);\n showSpinner(`Exporting all policy sets...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}Policies`,\n 'policy.authz'\n );\n if (file) {\n fileName = file;\n }\n const exportData = await exportPoliciesByPolicySet(policySetId, options);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported all policy sets to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting policy sets: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: end`);\n return outcome;\n}\n\n/**\n * Export all policies to separate files\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesToFiles(\n options: PolicyExportOptions = { useStringArrays: true, deps: true }\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: begin`);\n const errors = [];\n try {\n const policies: PolicySkeleton[] = await getPolicies();\n createProgressBar(policies.length, 'Exporting policy sets...');\n for (const policy of policies) {\n const file = getTypedFilename(policy._id, 'policy.authz');\n try {\n const exportData: PolicyExportInterface = await exportPolicy(\n policy._id,\n options\n );\n saveJsonToFile(exportData, file);\n updateProgressBar(`Exported ${policy._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${policy._id}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting policy sets to files`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Export all policies to separate files\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesByPolicySetToFiles(\n policySetId: string,\n options: PolicyExportOptions = { useStringArrays: true, deps: true }\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: begin`);\n const errors = [];\n try {\n const policies: PolicySkeleton[] = await getPoliciesByPolicySet(\n policySetId\n );\n createProgressBar(\n policies.length,\n `Exporting policies in policy set ${policySetId}...`\n );\n for (const policy of policies) {\n const file = getTypedFilename(policy._id, 'policy.authz');\n try {\n const exportData: PolicyExportInterface = await exportPolicy(\n policy._id,\n options\n );\n saveJsonToFile(exportData, file);\n updateProgressBar(`Exported ${policy._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${policy._id}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting policy sets to files`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import policy from file\n * @param {string} policyId policy id/name\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPolicyFromFile(\n policyId: string,\n file: string,\n options: PolicyImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.importPolicyFromFile: begin`);\n showSpinner(`Importing ${policyId}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importPolicy(policyId, fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${policyId}.`);\n } catch (error) {\n failSpinner(`Error importing ${policyId}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPolicyFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first policy from file\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstPolicyFromFile(\n file: string,\n options: PolicyImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstPolicy(fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policies from file\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPoliciesFromFile(\n file: string,\n options: PolicyImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.importPoliciesFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importPolicies(fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPoliciesFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policies from files\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPoliciesFromFiles(\n options: PolicyImportOptions = { deps: true }\n): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.PolicyOps.importPoliciesFromFiles: begin`);\n const names = fs.readdirSync('.');\n const files = names.filter((name) =>\n name.toLowerCase().endsWith('.policy.authz.json')\n );\n createProgressBar(files.length, 'Importing policies...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: PolicyExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.policyset).length;\n total += count;\n await importPolicies(fileData, options);\n updateProgressBar(`Imported ${count} policies from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing policies from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} policies from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing policies from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPoliciesFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAEnB,SAASC,MAAM,EAAEC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAC5D,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,gBAAgB,EAChBC,cAAc,EACdC,SAAS,QACJ,4BAA4B;AAOnC,MAAM;EACJC,YAAY,EAAEC,aAAa;EAC3BC,SAAS;EACTC,WAAW;EACXC,sBAAsB;EACtBC,YAAY;EACZC,cAAc;EACdC,yBAAyB;EACzBC,YAAY;EACZC,iBAAiB;EACjBC;AACF,CAAC,GAAGzB,MAAM;AACV,MAAM;EAAE0B;AAAa,CAAC,GAAGzB,KAAK;;AAE9B;AACA;AACA;AACA;AACA;AACA,OAAO,eAAe0B,YAAY,CAACC,IAAI,GAAG,KAAK,EAAoB;EACjE,IAAIC,OAAO,GAAG,KAAK;EACnB,IAAI;IACF,MAAMC,QAAQ,GAAG,MAAMZ,WAAW,EAAE;IACpCY,QAAQ,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IACnD,KAAK,MAAME,MAAM,IAAIN,QAAQ,EAAE;MAC7B,IAAI,CAACF,I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C,QAAQ,EAAEb,OAAO,CAAC;QACvC/C,iBAAiB,CAAE,YAAW0E,KAAM,kBAAiB5B,IAAK,EAAC,CAAC;MAC9D,CAAC,CAAC,OAAOT,KAAK,EAAE;QACdD,MAAM,CAACO,IAAI,CAACN,KAAK,CAAC;QAClBrC,iBAAiB,CAAE,iCAAgC8C,IAAK,EAAC,CAAC;QAC1DlD,YAAY,CAACyC,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACAvC,eAAe,CACZ,sBAAqB2E,KAAM,kBAAiBL,KAAK,CAAC9B,MAAO,SAAQ,CACnE;EACH,CAAC,CAAC,OAAOD,KAAK,EAAE;IACdD,MAAM,CAACO,IAAI,CAACN,KAAK,CAAC;IAClBvC,eAAe,CAAE,sCAAqC,CAAC;IACvDF,YAAY,CAACyC,KAAK,EAAE,OAAO,CAAC;EAC9B;EACA3C,YAAY,CAAE,4CAA2C,CAAC;EAC1D,OAAO,CAAC,KAAK0C,MAAM,CAACE,MAAM;AAC5B"}
@@ -1,14 +1,18 @@
1
1
  import fs from 'fs';
2
2
  import { ResourceType, Utils, state } from '@rockcarver/frodo-lib';
3
- import { createObjectTable, createProgressBar, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
3
+ import { createObjectTable, createProgressBar, createTable, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
4
4
  import { getTypedFilename, saveJsonToFile, titleCase } from '../utils/ExportImportUtils';
5
5
  const {
6
6
  deleteResourceType: _deleteResourceType,
7
+ deleteResourceTypeByName: _deleteResourceTypeByName,
7
8
  getResourceTypes,
9
+ getResourceType,
8
10
  getResourceTypeByName,
9
11
  exportResourceType,
12
+ exportResourceTypeByName,
10
13
  exportResourceTypes,
11
14
  importResourceType,
15
+ importResourceTypeByName,
12
16
  importFirstResourceType,
13
17
  importResourceTypes
14
18
  } = ResourceType;
@@ -18,15 +22,24 @@ const {
18
22
 
19
23
  /**
20
24
  * List resource types
25
+ * @param {boolean} long more fields
21
26
  * @returns {Promise<boolean>} true if successful, false otherwise
22
27
  */
23
- export async function listResourceTypes() {
28
+ export async function listResourceTypes(long = false) {
24
29
  let outcome = false;
25
30
  try {
26
31
  const resourceTypes = await getResourceTypes();
27
32
  resourceTypes.sort((a, b) => a.name.localeCompare(b.name));
28
- for (const resourceType of resourceTypes) {
29
- printMessage(`${resourceType.name}`, 'data');
33
+ if (long) {
34
+ const table = createTable(['Name', 'Description', 'Uuid']);
35
+ for (const resourceType of resourceTypes) {
36
+ table.push([`${resourceType.name}`, `${resourceType.description}`, `${resourceType.uuid}`]);
37
+ }
38
+ printMessage(table.toString(), 'data');
39
+ } else {
40
+ for (const resourceType of resourceTypes) {
41
+ printMessage(`${resourceType.name}`, 'data');
42
+ }
30
43
  }
31
44
  outcome = true;
32
45
  } catch (err) {
@@ -37,12 +50,41 @@ export async function listResourceTypes() {
37
50
  }
38
51
 
39
52
  /**
40
- * Describe resource type
53
+ * Describe resource type by uuid
54
+ * @param {string} resourceTypeUuid resource type uuid
55
+ * @param {boolean} json JSON output
56
+ * @returns {Promise<boolean>} true if successful, false otherwise
57
+ */
58
+ export async function describeResourceType(resourceTypeUuid, json = false) {
59
+ let outcome = false;
60
+ try {
61
+ const resourceType = await getResourceType(resourceTypeUuid);
62
+ if (json) {
63
+ printMessage(resourceType, 'data');
64
+ } else {
65
+ const table = createObjectTable(resourceType);
66
+ printMessage(table.toString(), 'data');
67
+ }
68
+ outcome = true;
69
+ } catch (error) {
70
+ var _error$response;
71
+ if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 404) {
72
+ printMessage(`Resource Type with uuid ${resourceTypeUuid} does not exist in realm ${state.getRealm()}`, 'error');
73
+ } else {
74
+ var _error$response2, _error$response2$data;
75
+ printMessage(((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.message) || error.message, 'error');
76
+ }
77
+ }
78
+ return outcome;
79
+ }
80
+
81
+ /**
82
+ * Describe resource type by name
41
83
  * @param {string} resourceTypeName resource type name
42
84
  * @param {boolean} json JSON output
43
85
  * @returns {Promise<boolean>} true if successful, false otherwise
44
86
  */
45
- export async function describeResourceType(resourceTypeName, json = false) {
87
+ export async function describeResourceTypeByName(resourceTypeName, json = false) {
46
88
  let outcome = false;
47
89
  try {
48
90
  const resourceType = await getResourceTypeByName(resourceTypeName);
@@ -54,38 +96,77 @@ export async function describeResourceType(resourceTypeName, json = false) {
54
96
  }
55
97
  outcome = true;
56
98
  } catch (error) {
57
- printMessage(error.message, 'error');
99
+ var _error$response3;
100
+ if (((_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.status) === 404) {
101
+ printMessage(`Resource Type with name ${resourceTypeName} does not exist in realm ${state.getRealm()}`, 'error');
102
+ } else {
103
+ var _error$response4, _error$response4$data;
104
+ printMessage(((_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : (_error$response4$data = _error$response4.data) === null || _error$response4$data === void 0 ? void 0 : _error$response4$data.message) || error.message, 'error');
105
+ }
58
106
  }
59
107
  return outcome;
60
108
  }
61
109
 
62
110
  /**
63
- * Delete resource type
64
- * @param {string} resourceTypeId resource type id
111
+ * Delete resource type by uuid
112
+ * @param {string} resourceTypeUuid resource type uuid
65
113
  * @returns {Promise<boolean>} true if successful, false otherwise
66
114
  */
67
- export async function deleteResourceType(resourceTypeId) {
115
+ export async function deleteResourceType(resourceTypeUuid) {
68
116
  debugMessage(`cli.ResourceTypeOps.deleteResourceType: begin`);
69
- showSpinner(`Deleting ${resourceTypeId}...`);
117
+ showSpinner(`Deleting ${resourceTypeUuid}...`);
70
118
  let outcome = false;
71
119
  const errors = [];
72
120
  try {
73
- debugMessage(`Deleting resource type ${resourceTypeId}`);
74
- await _deleteResourceType(resourceTypeId);
121
+ debugMessage(`Deleting resource type ${resourceTypeUuid}`);
122
+ await _deleteResourceType(resourceTypeUuid);
75
123
  } catch (error) {
76
- printMessage(`Error deleting resource type ${resourceTypeId}: ${error}`, 'error');
124
+ errors.push(error);
77
125
  }
78
126
  if (errors.length) {
79
- const errorMessages = errors.map(error => error.message).join('\n');
80
- failSpinner(`Error deleting ${resourceTypeId}: ${errorMessages}`);
127
+ const errorMessages = errors.map(error => {
128
+ var _error$response5, _error$response5$data;
129
+ return ((_error$response5 = error.response) === null || _error$response5 === void 0 ? void 0 : (_error$response5$data = _error$response5.data) === null || _error$response5$data === void 0 ? void 0 : _error$response5$data.message) || error.message;
130
+ }).join('\n');
131
+ failSpinner(`Error deleting ${resourceTypeUuid}: ${errorMessages}`);
81
132
  } else {
82
- succeedSpinner(`Deleted ${resourceTypeId}.`);
133
+ succeedSpinner(`Deleted ${resourceTypeUuid}.`);
83
134
  outcome = true;
84
135
  }
85
136
  debugMessage(`cli.ResourceTypeOps.deleteResourceType: end [outcome=${outcome}]`);
86
137
  return outcome;
87
138
  }
88
139
 
140
+ /**
141
+ * Delete resource type by name
142
+ * @param {string} resourceTypeName resource type name
143
+ * @returns {Promise<boolean>} true if successful, false otherwise
144
+ */
145
+ export async function deleteResourceTypeByName(resourceTypeName) {
146
+ debugMessage(`cli.ResourceTypeOps.deleteResourceTypeByName: begin`);
147
+ showSpinner(`Deleting ${resourceTypeName}...`);
148
+ let outcome = false;
149
+ const errors = [];
150
+ try {
151
+ debugMessage(`Deleting resource type ${resourceTypeName}`);
152
+ await _deleteResourceTypeByName(resourceTypeName);
153
+ } catch (error) {
154
+ errors.push(error);
155
+ }
156
+ if (errors.length) {
157
+ const errorMessages = errors.map(error => {
158
+ var _error$response6, _error$response6$data;
159
+ return ((_error$response6 = error.response) === null || _error$response6 === void 0 ? void 0 : (_error$response6$data = _error$response6.data) === null || _error$response6$data === void 0 ? void 0 : _error$response6$data.message) || error.message;
160
+ }).join('\n');
161
+ failSpinner(`Error deleting ${resourceTypeName}: ${errorMessages}`);
162
+ } else {
163
+ succeedSpinner(`Deleted ${resourceTypeName}.`);
164
+ outcome = true;
165
+ }
166
+ debugMessage(`cli.ResourceTypeOps.deleteResourceTypeByName: end [outcome=${outcome}]`);
167
+ return outcome;
168
+ }
169
+
89
170
  /**
90
171
  * Delete all resource types
91
172
  * @returns {Promise<boolean>} true if successful, false otherwise
@@ -136,30 +217,56 @@ export async function deleteResourceTypes() {
136
217
 
137
218
  /**
138
219
  * Export resource type to file
139
- * @param {string} resourceTypeId resource type id
220
+ * @param {string} resourceTypeUuid resource type uuid
140
221
  * @param {string} file file name
141
222
  * @returns {Promise<boolean>} true if successful, false otherwise
142
223
  */
143
- export async function exportResourceTypeToFile(resourceTypeId, file) {
224
+ export async function exportResourceTypeToFile(resourceTypeUuid, file) {
144
225
  let outcome = false;
145
226
  debugMessage(`cli.ResourceTypeOps.exportResourceTypeToFile: begin`);
146
- showSpinner(`Exporting ${resourceTypeId}...`);
227
+ showSpinner(`Exporting ${resourceTypeUuid}...`);
147
228
  try {
148
- let fileName = getTypedFilename(resourceTypeId, 'resourcetype.authz');
229
+ let fileName = getTypedFilename(resourceTypeUuid, 'resourcetype.authz');
149
230
  if (file) {
150
231
  fileName = file;
151
232
  }
152
- const exportData = await exportResourceType(resourceTypeId);
233
+ const exportData = await exportResourceType(resourceTypeUuid);
153
234
  saveJsonToFile(exportData, fileName);
154
- succeedSpinner(`Exported ${resourceTypeId} to ${fileName}.`);
235
+ succeedSpinner(`Exported ${resourceTypeUuid} to ${fileName}.`);
155
236
  outcome = true;
156
237
  } catch (error) {
157
- failSpinner(`Error exporting ${resourceTypeId}: ${error.message}`);
238
+ failSpinner(`Error exporting ${resourceTypeUuid}: ${error.message}`);
158
239
  }
159
240
  debugMessage(`cli.ResourceTypeOps.exportResourceTypeToFile: end`);
160
241
  return outcome;
161
242
  }
162
243
 
244
+ /**
245
+ * Export resource type by name to file
246
+ * @param {string} resourceTypeName resource type name
247
+ * @param {string} file file name
248
+ * @returns {Promise<boolean>} true if successful, false otherwise
249
+ */
250
+ export async function exportResourceTypeByNameToFile(resourceTypeName, file) {
251
+ let outcome = false;
252
+ debugMessage(`cli.ResourceTypeOps.exportResourceTypeByNameToFile: begin`);
253
+ showSpinner(`Exporting ${resourceTypeName}...`);
254
+ try {
255
+ let fileName = getTypedFilename(resourceTypeName, 'resourcetype.authz');
256
+ if (file) {
257
+ fileName = file;
258
+ }
259
+ const exportData = await exportResourceTypeByName(resourceTypeName);
260
+ saveJsonToFile(exportData, fileName);
261
+ succeedSpinner(`Exported ${resourceTypeName} to ${fileName}.`);
262
+ outcome = true;
263
+ } catch (error) {
264
+ failSpinner(`Error exporting ${resourceTypeName}: ${error.message}`);
265
+ }
266
+ debugMessage(`cli.ResourceTypeOps.exportResourceTypeByNameToFile: end`);
267
+ return outcome;
268
+ }
269
+
163
270
  /**
164
271
  * Export resource types to file
165
272
  * @param {string} file file name
@@ -232,13 +339,37 @@ export async function importResourceTypeFromFile(resourceTypeId, file) {
232
339
  outcome = true;
233
340
  succeedSpinner(`Imported ${resourceTypeId}.`);
234
341
  } catch (error) {
235
- failSpinner(`Error importing ${resourceTypeId}.`);
342
+ failSpinner(`Error importing ${resourceTypeId}: ${error.message}`);
236
343
  printMessage(error, 'error');
237
344
  }
238
345
  debugMessage(`cli.ResourceTypeOps.importResourceTypeFromFile: end`);
239
346
  return outcome;
240
347
  }
241
348
 
349
+ /**
350
+ * Import resource type by name from file
351
+ * @param {string} resourceTypeName resource type name
352
+ * @param {string} file file name
353
+ * @returns {Promise<boolean>} true if successful, false otherwise
354
+ */
355
+ export async function importResourceTypeByNameFromFile(resourceTypeName, file) {
356
+ let outcome = false;
357
+ debugMessage(`cli.ResourceTypeOps.importResourceTypeByNameFromFile: begin`);
358
+ showSpinner(`Importing ${resourceTypeName}...`);
359
+ try {
360
+ const data = fs.readFileSync(file, 'utf8');
361
+ const fileData = JSON.parse(data);
362
+ await importResourceTypeByName(resourceTypeName, fileData);
363
+ outcome = true;
364
+ succeedSpinner(`Imported ${resourceTypeName}.`);
365
+ } catch (error) {
366
+ failSpinner(`Error importing ${resourceTypeName}: ${error.message}`);
367
+ printMessage(error, 'error');
368
+ }
369
+ debugMessage(`cli.ResourceTypeOps.importResourceTypeByNameFromFile: end`);
370
+ return outcome;
371
+ }
372
+
242
373
  /**
243
374
  * Import first resource type from file
244
375
  * @param {string} file file name
@@ -1 +1 @@
1
- {"version":3,"file":"ResourceTypeOps.js","names":["fs","ResourceType","Utils","state","createObjectTable","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","deleteResourceType","_deleteResourceType","getResourceTypes","getResourceTypeByName","exportResourceType","exportResourceTypes","importResourceType","importFirstResourceType","importResourceTypes","getRealmName","listResourceTypes","outcome","resourceTypes","sort","a","b","name","localeCompare","resourceType","err","message","describeResourceType","resourceTypeName","json","table","toString","error","resourceTypeId","errors","length","errorMessages","map","join","deleteResourceTypes","uuid","push","exportResourceTypeToFile","file","fileName","exportData","exportResourceTypesToFile","getRealm","exportResourceTypesToFiles","importResourceTypeFromFile","data","readFileSync","fileData","JSON","parse","importFirstResourceTypeFromFile","importResourceTypesFromFile","importResourceTypesFromFiles","names","readdirSync","files","filter","toLowerCase","endsWith","total","count","Object","keys","resourcetype"],"sources":["ops/ResourceTypeOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { ResourceTypeSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { ResourceType, Utils, state } from '@rockcarver/frodo-lib';\nimport {\n createObjectTable,\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getTypedFilename,\n saveJsonToFile,\n titleCase,\n} from '../utils/ExportImportUtils';\nimport { ResourceTypeExportInterface } from '@rockcarver/frodo-lib/types/ops/ResourceTypeOps';\n\nconst {\n deleteResourceType: _deleteResourceType,\n getResourceTypes,\n getResourceTypeByName,\n exportResourceType,\n exportResourceTypes,\n importResourceType,\n importFirstResourceType,\n importResourceTypes,\n} = ResourceType;\nconst { getRealmName } = Utils;\n\n/**\n * List resource types\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listResourceTypes(): Promise<boolean> {\n let outcome = false;\n try {\n const resourceTypes = await getResourceTypes();\n resourceTypes.sort((a, b) => a.name.localeCompare(b.name));\n for (const resourceType of resourceTypes) {\n printMessage(`${resourceType.name}`, 'data');\n }\n outcome = true;\n } catch (err) {\n printMessage(`listResourceTypes ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Describe resource type\n * @param {string} resourceTypeName resource type name\n * @param {boolean} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describeResourceType(\n resourceTypeName: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n try {\n const resourceType = await getResourceTypeByName(resourceTypeName);\n if (json) {\n printMessage(resourceType, 'data');\n } else {\n const table = createObjectTable(resourceType);\n printMessage(table.toString(), 'data');\n }\n outcome = true;\n } catch (error) {\n printMessage(error.message, 'error');\n }\n return outcome;\n}\n\n/**\n * Delete resource type\n * @param {string} resourceTypeId resource type id\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteResourceType(\n resourceTypeId: string\n): Promise<boolean | ResourceTypeSkeleton> {\n debugMessage(`cli.ResourceTypeOps.deleteResourceType: begin`);\n showSpinner(`Deleting ${resourceTypeId}...`);\n let outcome = false;\n const errors = [];\n try {\n debugMessage(`Deleting resource type ${resourceTypeId}`);\n await _deleteResourceType(resourceTypeId);\n } catch (error) {\n printMessage(\n `Error deleting resource type ${resourceTypeId}: ${error}`,\n 'error'\n );\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n failSpinner(`Error deleting ${resourceTypeId}: ${errorMessages}`);\n } else {\n succeedSpinner(`Deleted ${resourceTypeId}.`);\n outcome = true;\n }\n debugMessage(\n `cli.ResourceTypeOps.deleteResourceType: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Delete all resource types\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteResourceTypes(): Promise<\n boolean | ResourceTypeSkeleton\n> {\n debugMessage(`cli.ResourceTypeOps.deleteResourceTypes: begin`);\n let outcome = false;\n const errors = [];\n let resourceTypes: ResourceTypeSkeleton[] = [];\n try {\n showSpinner(`Retrieving all resource types...`);\n try {\n resourceTypes = await getResourceTypes();\n succeedSpinner(`Found ${resourceTypes.length} resource types.`);\n } catch (error) {\n error.message = `Error retrieving all resource types: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (resourceTypes.length)\n createProgressBar(\n resourceTypes.length,\n `Deleting ${resourceTypes.length} resource types...`\n );\n for (const resourceType of resourceTypes) {\n const resourceTypeId = resourceType.uuid;\n try {\n debugMessage(`Deleting resource type ${resourceTypeId}`);\n await _deleteResourceType(resourceTypeId);\n updateProgressBar(`Deleted ${resourceTypeId}`);\n } catch (error) {\n error.message = `Error deleting resource type ${resourceTypeId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting resource types: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (resourceTypes.length)\n stopProgressBar(`Error deleting all resource types: ${errorMessages}`);\n } else {\n if (resourceTypes.length)\n stopProgressBar(`Deleted ${resourceTypes.length} resource types.`);\n outcome = true;\n }\n }\n debugMessage(\n `cli.ResourceTypeOps.deleteResourceTypes: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Export resource type to file\n * @param {string} resourceTypeId resource type id\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypeToFile(\n resourceTypeId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.exportResourceTypeToFile: begin`);\n showSpinner(`Exporting ${resourceTypeId}...`);\n try {\n let fileName = getTypedFilename(resourceTypeId, 'resourcetype.authz');\n if (file) {\n fileName = file;\n }\n const exportData = await exportResourceType(resourceTypeId);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported ${resourceTypeId} to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${resourceTypeId}: ${error.message}`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypeToFile: end`);\n return outcome;\n}\n\n/**\n * Export resource types to file\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypesToFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFile: begin`);\n showSpinner(`Exporting all resource types...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}ResourceTypes`,\n 'resourcetype.authz'\n );\n if (file) {\n fileName = file;\n }\n const exportData = await exportResourceTypes();\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported all resource types to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting resource types: ${error.message}`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFile: end`);\n return outcome;\n}\n\n/**\n * Export all resource types to separate files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypesToFiles(): Promise<boolean> {\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFiles: begin`);\n const errors = [];\n try {\n const resourceTypes: ResourceTypeSkeleton[] = await getResourceTypes();\n createProgressBar(resourceTypes.length, 'Exporting resource types...');\n for (const resourceType of resourceTypes) {\n const file = getTypedFilename(resourceType.name, 'resourcetype.authz');\n try {\n const exportData: ResourceTypeExportInterface =\n await exportResourceType(resourceType.uuid);\n saveJsonToFile(exportData, file);\n updateProgressBar(`Exported ${resourceType.name}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${resourceType.name}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting resource types to files`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import resource type from file\n * @param {string} resourceTypeId resource type id\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypeFromFile(\n resourceTypeId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importResourceTypeFromFile: begin`);\n showSpinner(`Importing ${resourceTypeId}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importResourceType(resourceTypeId, fileData);\n outcome = true;\n succeedSpinner(`Imported ${resourceTypeId}.`);\n } catch (error) {\n failSpinner(`Error importing ${resourceTypeId}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypeFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first resource type from file\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstResourceTypeFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importFirstResourceTypeFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstResourceType(fileData);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importFirstResourceTypeFromFile: end`);\n return outcome;\n}\n\n/**\n * Import resource types from file\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypesFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importResourceTypes(fileData);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFile: end`);\n return outcome;\n}\n\n/**\n * Import resource types from files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypesFromFiles(): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFiles: begin`);\n const names = fs.readdirSync('.');\n const files = names.filter((name) =>\n name.toLowerCase().endsWith('.resourcetype.authz.json')\n );\n createProgressBar(files.length, 'Importing resource types...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: ResourceTypeExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.resourcetype).length;\n total += count;\n await importResourceTypes(fileData);\n updateProgressBar(`Imported ${count} resource types from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing resource types from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} resource types from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing resource types from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAEnB,SAASC,YAAY,EAAEC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAClE,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,gBAAgB,EAChBC,cAAc,EACdC,SAAS,QACJ,4BAA4B;AAGnC,MAAM;EACJC,kBAAkB,EAAEC,mBAAmB;EACvCC,gBAAgB;EAChB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iBAAiB,CAACiE,KAAK,CAACzB,MAAM,EAAE,6BAA6B,CAAC;IAC9D,IAAI6B,KAAK,GAAG,CAAC;IACb,KAAK,MAAMrB,IAAI,IAAIiB,KAAK,EAAE;MACxB,IAAI;QACF,MAAMV,IAAI,GAAG5D,EAAE,CAAC6D,YAAY,CAACR,IAAI,EAAE,MAAM,CAAC;QAC1C,MAAMS,QAAqC,GAAGC,IAAI,CAACC,KAAK,CAACJ,IAAI,CAAC;QAC9D,MAAMe,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACf,QAAQ,CAACgB,YAAY,CAAC,CAACjC,MAAM;QACvD6B,KAAK,IAAIC,KAAK;QACd,MAAMnD,mBAAmB,CAACsC,QAAQ,CAAC;QACnClD,iBAAiB,CAAE,YAAW+D,KAAM,wBAAuBtB,IAAK,EAAC,CAAC;MACpE,CAAC,CAAC,OAAOX,KAAK,EAAE;QACdE,MAAM,CAACO,IAAI,CAACT,KAAK,CAAC;QAClB9B,iBAAiB,CAAE,uCAAsCyC,IAAK,EAAC,CAAC;QAChE7C,YAAY,CAACkC,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACAhC,eAAe,CACZ,sBAAqBgE,KAAM,wBAAuBJ,KAAK,CAACzB,MAAO,SAAQ,CACzE;EACH,CAAC,CAAC,OAAOH,KAAK,EAAE;IACdE,MAAM,CAACO,IAAI,CAACT,KAAK,CAAC;IAClBhC,eAAe,CAAE,4CAA2C,CAAC;IAC7DF,YAAY,CAACkC,KAAK,EAAE,OAAO,CAAC;EAC9B;EACApC,YAAY,CAAE,uDAAsD,CAAC;EACrE,OAAO,CAAC,KAAKsC,MAAM,CAACC,MAAM;AAC5B"}
1
+ {"version":3,"file":"ResourceTypeOps.js","names":["fs","ResourceType","Utils","state","createObjectTable","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","deleteResourceType","_deleteResourceType","deleteResourceTypeByName","_deleteResourceTypeByName","getResourceTypes","getResourceType","getResourceTypeByName","exportResourceType","exportResourceTypeByName","exportResourceTypes","importResourceType","importResourceTypeByName","importFirstResourceType","importResourceTypes","getRealmName","listResourceTypes","long","outcome","resourceTypes","sort","a","b","name","localeCompare","table","resourceType","push","description","uuid","toString","err","message","describeResourceType","resourceTypeUuid","json","error","response","status","getRealm","data","describeResourceTypeByName","resourceTypeName","errors","length","errorMessages","map","join","deleteResourceTypes","resourceTypeId","exportResourceTypeToFile","file","fileName","exportData","exportResourceTypeByNameToFile","exportResourceTypesToFile","exportResourceTypesToFiles","importResourceTypeFromFile","readFileSync","fileData","JSON","parse","importResourceTypeByNameFromFile","importFirstResourceTypeFromFile","importResourceTypesFromFile","importResourceTypesFromFiles","names","readdirSync","files","filter","toLowerCase","endsWith","total","count","Object","keys","resourcetype"],"sources":["ops/ResourceTypeOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { ResourceTypeSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { ResourceType, Utils, state } from '@rockcarver/frodo-lib';\nimport {\n createObjectTable,\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getTypedFilename,\n saveJsonToFile,\n titleCase,\n} from '../utils/ExportImportUtils';\nimport { ResourceTypeExportInterface } from '@rockcarver/frodo-lib/types/ops/ResourceTypeOps';\n\nconst {\n deleteResourceType: _deleteResourceType,\n deleteResourceTypeByName: _deleteResourceTypeByName,\n getResourceTypes,\n getResourceType,\n getResourceTypeByName,\n exportResourceType,\n exportResourceTypeByName,\n exportResourceTypes,\n importResourceType,\n importResourceTypeByName,\n importFirstResourceType,\n importResourceTypes,\n} = ResourceType;\nconst { getRealmName } = Utils;\n\n/**\n * List resource types\n * @param {boolean} long more fields\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listResourceTypes(long = false): Promise<boolean> {\n let outcome = false;\n try {\n const resourceTypes = await getResourceTypes();\n resourceTypes.sort((a, b) => a.name.localeCompare(b.name));\n if (long) {\n const table = createTable(['Name', 'Description', 'Uuid']);\n for (const resourceType of resourceTypes) {\n table.push([\n `${resourceType.name}`,\n `${resourceType.description}`,\n `${resourceType.uuid}`,\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const resourceType of resourceTypes) {\n printMessage(`${resourceType.name}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listResourceTypes ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Describe resource type by uuid\n * @param {string} resourceTypeUuid resource type uuid\n * @param {boolean} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describeResourceType(\n resourceTypeUuid: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n try {\n const resourceType = await getResourceType(resourceTypeUuid);\n if (json) {\n printMessage(resourceType, 'data');\n } else {\n const table = createObjectTable(resourceType);\n printMessage(table.toString(), 'data');\n }\n outcome = true;\n } catch (error) {\n if (error.response?.status === 404) {\n printMessage(\n `Resource Type with uuid ${resourceTypeUuid} does not exist in realm ${state.getRealm()}`,\n 'error'\n );\n } else {\n printMessage(error.response?.data?.message || error.message, 'error');\n }\n }\n return outcome;\n}\n\n/**\n * Describe resource type by name\n * @param {string} resourceTypeName resource type name\n * @param {boolean} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describeResourceTypeByName(\n resourceTypeName: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n try {\n const resourceType = await getResourceTypeByName(resourceTypeName);\n if (json) {\n printMessage(resourceType, 'data');\n } else {\n const table = createObjectTable(resourceType);\n printMessage(table.toString(), 'data');\n }\n outcome = true;\n } catch (error) {\n if (error.response?.status === 404) {\n printMessage(\n `Resource Type with name ${resourceTypeName} does not exist in realm ${state.getRealm()}`,\n 'error'\n );\n } else {\n printMessage(error.response?.data?.message || error.message, 'error');\n }\n }\n return outcome;\n}\n\n/**\n * Delete resource type by uuid\n * @param {string} resourceTypeUuid resource type uuid\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteResourceType(\n resourceTypeUuid: string\n): Promise<boolean | ResourceTypeSkeleton> {\n debugMessage(`cli.ResourceTypeOps.deleteResourceType: begin`);\n showSpinner(`Deleting ${resourceTypeUuid}...`);\n let outcome = false;\n const errors = [];\n try {\n debugMessage(`Deleting resource type ${resourceTypeUuid}`);\n await _deleteResourceType(resourceTypeUuid);\n } catch (error) {\n errors.push(error);\n }\n if (errors.length) {\n const errorMessages = errors\n .map((error) => error.response?.data?.message || error.message)\n .join('\\n');\n failSpinner(`Error deleting ${resourceTypeUuid}: ${errorMessages}`);\n } else {\n succeedSpinner(`Deleted ${resourceTypeUuid}.`);\n outcome = true;\n }\n debugMessage(\n `cli.ResourceTypeOps.deleteResourceType: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Delete resource type by name\n * @param {string} resourceTypeName resource type name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteResourceTypeByName(\n resourceTypeName: string\n): Promise<boolean | ResourceTypeSkeleton> {\n debugMessage(`cli.ResourceTypeOps.deleteResourceTypeByName: begin`);\n showSpinner(`Deleting ${resourceTypeName}...`);\n let outcome = false;\n const errors = [];\n try {\n debugMessage(`Deleting resource type ${resourceTypeName}`);\n await _deleteResourceTypeByName(resourceTypeName);\n } catch (error) {\n errors.push(error);\n }\n if (errors.length) {\n const errorMessages = errors\n .map((error) => error.response?.data?.message || error.message)\n .join('\\n');\n failSpinner(`Error deleting ${resourceTypeName}: ${errorMessages}`);\n } else {\n succeedSpinner(`Deleted ${resourceTypeName}.`);\n outcome = true;\n }\n debugMessage(\n `cli.ResourceTypeOps.deleteResourceTypeByName: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Delete all resource types\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteResourceTypes(): Promise<\n boolean | ResourceTypeSkeleton\n> {\n debugMessage(`cli.ResourceTypeOps.deleteResourceTypes: begin`);\n let outcome = false;\n const errors = [];\n let resourceTypes: ResourceTypeSkeleton[] = [];\n try {\n showSpinner(`Retrieving all resource types...`);\n try {\n resourceTypes = await getResourceTypes();\n succeedSpinner(`Found ${resourceTypes.length} resource types.`);\n } catch (error) {\n error.message = `Error retrieving all resource types: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (resourceTypes.length)\n createProgressBar(\n resourceTypes.length,\n `Deleting ${resourceTypes.length} resource types...`\n );\n for (const resourceType of resourceTypes) {\n const resourceTypeId = resourceType.uuid;\n try {\n debugMessage(`Deleting resource type ${resourceTypeId}`);\n await _deleteResourceType(resourceTypeId);\n updateProgressBar(`Deleted ${resourceTypeId}`);\n } catch (error) {\n error.message = `Error deleting resource type ${resourceTypeId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting resource types: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (resourceTypes.length)\n stopProgressBar(`Error deleting all resource types: ${errorMessages}`);\n } else {\n if (resourceTypes.length)\n stopProgressBar(`Deleted ${resourceTypes.length} resource types.`);\n outcome = true;\n }\n }\n debugMessage(\n `cli.ResourceTypeOps.deleteResourceTypes: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Export resource type to file\n * @param {string} resourceTypeUuid resource type uuid\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypeToFile(\n resourceTypeUuid: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.exportResourceTypeToFile: begin`);\n showSpinner(`Exporting ${resourceTypeUuid}...`);\n try {\n let fileName = getTypedFilename(resourceTypeUuid, 'resourcetype.authz');\n if (file) {\n fileName = file;\n }\n const exportData = await exportResourceType(resourceTypeUuid);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported ${resourceTypeUuid} to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${resourceTypeUuid}: ${error.message}`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypeToFile: end`);\n return outcome;\n}\n\n/**\n * Export resource type by name to file\n * @param {string} resourceTypeName resource type name\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypeByNameToFile(\n resourceTypeName: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.exportResourceTypeByNameToFile: begin`);\n showSpinner(`Exporting ${resourceTypeName}...`);\n try {\n let fileName = getTypedFilename(resourceTypeName, 'resourcetype.authz');\n if (file) {\n fileName = file;\n }\n const exportData = await exportResourceTypeByName(resourceTypeName);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported ${resourceTypeName} to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${resourceTypeName}: ${error.message}`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypeByNameToFile: end`);\n return outcome;\n}\n\n/**\n * Export resource types to file\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypesToFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFile: begin`);\n showSpinner(`Exporting all resource types...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}ResourceTypes`,\n 'resourcetype.authz'\n );\n if (file) {\n fileName = file;\n }\n const exportData = await exportResourceTypes();\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported all resource types to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting resource types: ${error.message}`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFile: end`);\n return outcome;\n}\n\n/**\n * Export all resource types to separate files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypesToFiles(): Promise<boolean> {\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFiles: begin`);\n const errors = [];\n try {\n const resourceTypes: ResourceTypeSkeleton[] = await getResourceTypes();\n createProgressBar(resourceTypes.length, 'Exporting resource types...');\n for (const resourceType of resourceTypes) {\n const file = getTypedFilename(resourceType.name, 'resourcetype.authz');\n try {\n const exportData: ResourceTypeExportInterface =\n await exportResourceType(resourceType.uuid);\n saveJsonToFile(exportData, file);\n updateProgressBar(`Exported ${resourceType.name}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${resourceType.name}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting resource types to files`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import resource type from file\n * @param {string} resourceTypeId resource type id\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypeFromFile(\n resourceTypeId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importResourceTypeFromFile: begin`);\n showSpinner(`Importing ${resourceTypeId}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importResourceType(resourceTypeId, fileData);\n outcome = true;\n succeedSpinner(`Imported ${resourceTypeId}.`);\n } catch (error) {\n failSpinner(`Error importing ${resourceTypeId}: ${error.message}`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypeFromFile: end`);\n return outcome;\n}\n\n/**\n * Import resource type by name from file\n * @param {string} resourceTypeName resource type name\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypeByNameFromFile(\n resourceTypeName: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importResourceTypeByNameFromFile: begin`);\n showSpinner(`Importing ${resourceTypeName}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importResourceTypeByName(resourceTypeName, fileData);\n outcome = true;\n succeedSpinner(`Imported ${resourceTypeName}.`);\n } catch (error) {\n failSpinner(`Error importing ${resourceTypeName}: ${error.message}`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypeByNameFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first resource type from file\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstResourceTypeFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importFirstResourceTypeFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstResourceType(fileData);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importFirstResourceTypeFromFile: end`);\n return outcome;\n}\n\n/**\n * Import resource types from file\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypesFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importResourceTypes(fileData);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFile: end`);\n return outcome;\n}\n\n/**\n * Import resource types from files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypesFromFiles(): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFiles: begin`);\n const names = fs.readdirSync('.');\n const files = names.filter((name) =>\n name.toLowerCase().endsWith('.resourcetype.authz.json')\n );\n createProgressBar(files.length, 'Importing resource types...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: ResourceTypeExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.resourcetype).length;\n total += count;\n await importResourceTypes(fileData);\n updateProgressBar(`Imported ${count} resource types from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing resource types from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} resource types from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing resource types from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAEnB,SAASC,YAAY,EAAEC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAClE,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,gBAAgB,EAChBC,cAAc,EACdC,SAAS,QACJ,4BAA4B;AAGnC,MAAM;EACJC,kBAAkB,EAAEC,mBAAmB;EACvCC,wBAAwB,EAAEC,yBAAyB;EACnDC,gBAAgB;EAChBC,eAAe;EACfC,qBAAqB;EACrBC,kBAAkB;EAClBC,wBAAwB;EACxBC,mBAAmB;EACnBC,kBAAkB;EAClBC,wBAAwB;EACxBC,uBAAuB;EACvBC;AACF,CAAC,GAAG7B,YAAY;AAChB,MAAM;EAAE8B;AAAa,CAAC,GAAG7B,KAAK;;AAE9B;AACA;AACA;AACA;AACA;AACA,OAAO,eAAe8B,iBAAiB,CAACC,IA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CAAC;EACrE,OAAO,CAAC,KAAKoD,MAAM,CAACC,MAAM;AAC5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rockcarver/frodo-cli",
3
- "version": "0.23.1-7",
3
+ "version": "0.23.1-8",
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": [
@@ -99,7 +99,7 @@
99
99
  ]
100
100
  },
101
101
  "dependencies": {
102
- "@rockcarver/frodo-lib": "0.18.9-6",
102
+ "@rockcarver/frodo-lib": "0.18.9-7",
103
103
  "chokidar": "^3.5.3",
104
104
  "cli-progress": "^3.11.2",
105
105
  "cli-table3": "^0.6.3",