@rockcarver/frodo-cli 0.23.1-6 → 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 +9 -1
- package/esm/cli/authz/authz-policy-import.js +40 -1
- package/esm/cli/authz/authz-policy-import.js.map +1 -1
- package/esm/cli/authz/authz-set-import.js +1 -1
- package/esm/cli/authz/authz-set-import.js.map +1 -1
- package/esm/cli/authz/authz-type-delete.js +18 -13
- package/esm/cli/authz/authz-type-delete.js.map +1 -1
- package/esm/cli/authz/authz-type-describe.js +7 -3
- package/esm/cli/authz/authz-type-describe.js.map +1 -1
- package/esm/cli/authz/authz-type-export.js +32 -5
- package/esm/cli/authz/authz-type-export.js.map +1 -1
- package/esm/cli/authz/authz-type-import.js +38 -5
- package/esm/cli/authz/authz-type-import.js.map +1 -1
- package/esm/cli/authz/authz-type-list.js +4 -10
- package/esm/cli/authz/authz-type-list.js.map +1 -1
- package/esm/ops/EmailTemplateOps.js +24 -3
- package/esm/ops/EmailTemplateOps.js.map +1 -1
- package/esm/ops/PolicyOps.js +96 -3
- package/esm/ops/PolicyOps.js.map +1 -1
- package/esm/ops/ResourceTypeOps.js +156 -25
- package/esm/ops/ResourceTypeOps.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.23.1-8] - 2023-05-21
|
|
11
|
+
|
|
12
|
+
## [0.23.1-7] - 2023-05-18
|
|
13
|
+
|
|
10
14
|
## [0.23.1-6] - 2023-05-17
|
|
11
15
|
|
|
12
16
|
## [0.23.1-5] - 2023-05-17
|
|
@@ -1104,7 +1108,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1104
1108
|
- Fixed problem with adding connection profiles
|
|
1105
1109
|
- Miscellaneous bug fixes
|
|
1106
1110
|
|
|
1107
|
-
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.23.1-
|
|
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
|
|
1114
|
+
|
|
1115
|
+
[0.23.1-7]: https://github.com/rockcarver/frodo-cli/compare/v0.23.1-6...v0.23.1-7
|
|
1108
1116
|
|
|
1109
1117
|
[0.23.1-6]: https://github.com/rockcarver/frodo-cli/compare/v0.23.1-5...v0.23.1-6
|
|
1110
1118
|
|
|
@@ -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","
|
|
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,CAC9F,CACF,CACAU,SAAS,CAAC,IAAIV,MAAM,CAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC,CACzEU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,wDAAwD,CACzD,CACF,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,oBAAoB,EACpB,gHAAgH,CACjH,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,QAAQ,KAAK,MAAMZ,SAAS,EAAE,CAAC,EAAE;IAC3CD,cAAc,CAAC,6CAA6C,CAAC;IAC7D,MAAMc,OAAO,GAAGf,oBAAoB,CAACW,OAAO,CAAC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AE;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
|
-
//
|
|
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 //
|
|
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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CAAC,EAAE;IACnDD,cAAc,CACZ,gEAAgE,CACjE;IACD,MAAMc,OAAO,GAAG,MAAMf,yBAAyB,CAAC;MAC9CiB,IAAI,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,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
|
|
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
|
-
|
|
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
|
|
18
|
-
if (options.
|
|
19
|
-
verboseMessage('Deleting
|
|
20
|
-
|
|
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
|
|
25
|
-
|
|
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","
|
|
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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AAEC,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-
|
|
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
|
|
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","
|
|
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
|
|
8
|
-
program.description('Export
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
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,IAA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,CAAC;IACtEM,OAAO,CAACmB,IAAI,EAAE;IACdL,OAAO,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
|
|
8
|
-
program.description('Import
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
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,IAAI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AAI,CAACc,OAAO,EAAEE,OAAO,CAACC,QAAQ,GAAG,CAAC;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 {
|
|
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","
|
|
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"}
|
|
@@ -4,6 +4,7 @@ import { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
|
|
|
4
4
|
import { createProgressIndicator, updateProgressIndicator, stopProgressIndicator, printMessage, createTable, showSpinner, succeedSpinner, failSpinner, debugMessage } from '../utils/Console';
|
|
5
5
|
import wordwrap from './utils/Wordwrap';
|
|
6
6
|
import path from 'path';
|
|
7
|
+
import { cloneDeep } from './utils/OpsUtils';
|
|
7
8
|
const EMAIL_TEMPLATE_FILE_TYPE = 'template.email';
|
|
8
9
|
const {
|
|
9
10
|
EMAIL_TEMPLATE_TYPE,
|
|
@@ -186,7 +187,7 @@ export async function importEmailTemplateFromFile(templateId, file, raw = false)
|
|
|
186
187
|
createProgressIndicator('determinate', 1, `Importing ${templateId}`);
|
|
187
188
|
if (fileData.emailTemplate[templateId] || raw && fileData._id === templateId) {
|
|
188
189
|
try {
|
|
189
|
-
const emailTemplateData = raw ? fileData : fileData.emailTemplate[templateId];
|
|
190
|
+
const emailTemplateData = raw ? s2sConvert(fileData) : fileData.emailTemplate[templateId];
|
|
190
191
|
await putEmailTemplate(templateId, emailTemplateData);
|
|
191
192
|
updateProgressIndicator(`Importing ${templateId}`);
|
|
192
193
|
stopProgressIndicator(`Imported ${templateId}`);
|
|
@@ -247,6 +248,24 @@ function getEmailTemplateIdFromFile(file) {
|
|
|
247
248
|
return templateId;
|
|
248
249
|
}
|
|
249
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Convert template for s2s purposes (software-to-saas migration)
|
|
253
|
+
* @param {EmailTemplateSkeleton} templateData template object
|
|
254
|
+
* @returns {EmailTemplateSkeleton} converted template object
|
|
255
|
+
*/
|
|
256
|
+
function s2sConvert(templateData) {
|
|
257
|
+
if (templateData.message && !templateData.html) {
|
|
258
|
+
const convertedData = cloneDeep(templateData);
|
|
259
|
+
convertedData.html = cloneDeep(templateData.message);
|
|
260
|
+
debugMessage(`cli.EmailTemplateOps.s2sConvert: templateData:`);
|
|
261
|
+
debugMessage(templateData);
|
|
262
|
+
debugMessage(`cli.EmailTemplateOps.s2sConvert: convertedData:`);
|
|
263
|
+
debugMessage(convertedData);
|
|
264
|
+
return convertedData;
|
|
265
|
+
}
|
|
266
|
+
return templateData;
|
|
267
|
+
}
|
|
268
|
+
|
|
250
269
|
/**
|
|
251
270
|
* Import all email templates from separate files
|
|
252
271
|
* @param {boolean} raw import raw data file lacking frodo export envelop
|
|
@@ -266,7 +285,8 @@ export async function importEmailTemplatesFromFiles(raw = false) {
|
|
|
266
285
|
total++;
|
|
267
286
|
const templateId = getEmailTemplateIdFromFile(file);
|
|
268
287
|
try {
|
|
269
|
-
|
|
288
|
+
const templateData = s2sConvert(fileData);
|
|
289
|
+
await putEmailTemplate(templateId, templateData);
|
|
270
290
|
} catch (putEmailTemplateError) {
|
|
271
291
|
var _putEmailTemplateErro;
|
|
272
292
|
errors += 1;
|
|
@@ -311,7 +331,8 @@ export async function importFirstEmailTemplateFromFile(file, raw = false) {
|
|
|
311
331
|
if (raw) {
|
|
312
332
|
const templateId = getEmailTemplateIdFromFile(file);
|
|
313
333
|
try {
|
|
314
|
-
|
|
334
|
+
const templateData = s2sConvert(fileData);
|
|
335
|
+
await putEmailTemplate(templateId, templateData);
|
|
315
336
|
succeedSpinner(`Imported ${templateId}`);
|
|
316
337
|
} catch (putEmailTemplateError) {
|
|
317
338
|
var _putEmailTemplateErro2;
|