@rockcarver/frodo-cli 2.0.0-28 → 2.0.0-29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/esm/app.js +4 -0
  3. package/esm/app.js.map +1 -1
  4. package/esm/cli/FrodoCommand.js +10 -4
  5. package/esm/cli/FrodoCommand.js.map +1 -1
  6. package/esm/cli/admin/admin-get-access-token.js +1 -1
  7. package/esm/cli/admin/admin-get-access-token.js.map +1 -1
  8. package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +1 -1
  9. package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +1 -1
  10. package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +1 -1
  11. package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js.map +1 -1
  12. package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +1 -1
  13. package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js.map +1 -1
  14. package/esm/cli/admin/admin-list-static-user-mappings.js +1 -1
  15. package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
  16. package/esm/cli/authz/authz-policy-delete.js +2 -2
  17. package/esm/cli/authz/authz-policy-delete.js.map +1 -1
  18. package/esm/cli/authz/authz-set-delete.js +2 -2
  19. package/esm/cli/authz/authz-set-delete.js.map +1 -1
  20. package/esm/cli/authz/authz-type-delete.js +3 -3
  21. package/esm/cli/authz/authz-type-delete.js.map +1 -1
  22. package/esm/cli/esv/esv-variable-delete.js +2 -2
  23. package/esm/cli/esv/esv-variable-delete.js.map +1 -1
  24. package/esm/cli/journey/journey-describe.js +1 -0
  25. package/esm/cli/journey/journey-describe.js.map +1 -1
  26. package/esm/cli/journey/journey-export.js +11 -1
  27. package/esm/cli/journey/journey-export.js.map +1 -1
  28. package/esm/ops/CirclesOfTrustOps.js +1 -1
  29. package/esm/ops/CirclesOfTrustOps.js.map +1 -1
  30. package/esm/ops/OAuth2ClientOps.js.map +1 -1
  31. package/esm/ops/PolicyOps.js +5 -15
  32. package/esm/ops/PolicyOps.js.map +1 -1
  33. package/esm/ops/PolicySetOps.js +11 -10
  34. package/esm/ops/PolicySetOps.js.map +1 -1
  35. package/esm/ops/RealmOps.js +3 -3
  36. package/esm/ops/RealmOps.js.map +1 -1
  37. package/esm/ops/ResourceTypeOps.js +11 -25
  38. package/esm/ops/ResourceTypeOps.js.map +1 -1
  39. package/esm/ops/Saml2Ops.js +2 -2
  40. package/esm/ops/Saml2Ops.js.map +1 -1
  41. package/esm/ops/SecretsOps.js +4 -4
  42. package/esm/ops/SecretsOps.js.map +1 -1
  43. package/esm/ops/VariablesOps.js +6 -4
  44. package/esm/ops/VariablesOps.js.map +1 -1
  45. package/global-jest-setup.js +4 -0
  46. package/package.json +4 -3
@@ -18,7 +18,8 @@ const {
18
18
  exportPolicySets,
19
19
  importPolicySet,
20
20
  importFirstPolicySet,
21
- importPolicySets
21
+ importPolicySets,
22
+ deletePolicySet
22
23
  } = frodo.authz.policySet;
23
24
 
24
25
  /**
@@ -65,7 +66,7 @@ export async function describePolicySet(policySetId, json = false) {
65
66
  * @param {string} policySetId policy set id/name
66
67
  * @returns {Promise<boolean>} true if successful, false otherwise
67
68
  */
68
- export async function deletePolicySet(policySetId) {
69
+ export async function deletePolicySetById(policySetId) {
69
70
  debugMessage(`cli.PolicySetOps.deletePolicySet: begin`);
70
71
  showSpinner(`Deleting ${policySetId}...`);
71
72
  let outcome = false;
@@ -81,18 +82,18 @@ export async function deletePolicySet(policySetId) {
81
82
  errors.push(error);
82
83
  }
83
84
  }
84
- try {
85
- debugMessage(`Deleting policy set ${policySetId}`);
86
- await deletePolicySet(policySetId);
87
- } catch (error) {
88
- printMessage(`Error deleting policy set ${policySetId}: ${error}`, 'error');
89
- }
90
85
  if (errors.length) {
91
86
  const errorMessages = errors.map(error => error.message).join('\n');
92
87
  failSpinner(`Error deleting ${policySetId}: ${errorMessages}`);
93
88
  } else {
94
- succeedSpinner(`Deleted ${policySetId}.`);
95
- outcome = true;
89
+ try {
90
+ debugMessage(`Deleting policy set ${policySetId}`);
91
+ await deletePolicySet(policySetId);
92
+ succeedSpinner(`Deleted ${policySetId}.`);
93
+ outcome = true;
94
+ } catch (error) {
95
+ printMessage(`Error deleting policy set ${policySetId}: ${error}`, 'error');
96
+ }
96
97
  }
97
98
  debugMessage(`cli.PolicySetOps.deletePolicySet: end [outcome=${outcome}]`);
98
99
  return outcome;
@@ -1 +1 @@
1
- {"version":3,"file":"PolicySetOps.js","names":["frodo","state","fs","createObjectTable","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","getRealmName","getFilePath","getWorkingDirectory","utils","readPoliciesByPolicySet","deletePolicy","authz","policy","readPolicySets","readPolicySet","exportPolicySet","exportPolicySets","importPolicySet","importFirstPolicySet","importPolicySets","policySet","listPolicySets","outcome","policySets","sort","a","b","name","localeCompare","err","message","describePolicySet","policySetId","json","table","toString","deletePolicySet","errors","policies","_id","error","push","length","errorMessages","map","join","deletePolicySets","exportPolicySetToFile","file","options","deps","prereqs","useStringArrays","fileName","filePath","exportData","exportPolicySetsToFile","getRealm","exportPolicySetsToFiles","importPolicySetFromFile","data","readFileSync","fileData","JSON","parse","importFirstPolicySetFromFile","importPolicySetsFromFile","importPolicySetsFromFiles","names","readdirSync","files","filter","toLowerCase","endsWith","total","count","Object","keys","policyset"],"sources":["../../src/ops/PolicySetOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type PolicySkeleton } from '@rockcarver/frodo-lib/types/api/PoliciesApi';\nimport { type PolicySetSkeleton } from '@rockcarver/frodo-lib/types/api/PolicySetApi';\nimport {\n type PolicySetExportInterface,\n type PolicySetExportOptions,\n type PolicySetImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/PolicySetOps';\nimport fs from 'fs';\n\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';\n\nconst { getRealmName, getFilePath, getWorkingDirectory } = frodo.utils;\nconst { readPoliciesByPolicySet, deletePolicy } = frodo.authz.policy;\nconst {\n readPolicySets,\n readPolicySet,\n exportPolicySet,\n exportPolicySets,\n importPolicySet,\n importFirstPolicySet,\n importPolicySets,\n} = frodo.authz.policySet;\n\n/**\n * List policy sets\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listPolicySets(): Promise<boolean> {\n let outcome = false;\n try {\n const policySets = await readPolicySets();\n policySets.sort((a, b) => a.name.localeCompare(b.name));\n for (const policySet of policySets) {\n printMessage(`${policySet.name}`, 'data');\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicySets ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Describe policy set\n * @param {string} policySetId policy set id/name\n * @param {Object} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describePolicySet(\n policySetId: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n const policySet = await readPolicySet(policySetId);\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 set\n * @param {string} policySetId policy set id/name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicySet(policySetId: string): Promise<boolean> {\n debugMessage(`cli.PolicySetOps.deletePolicySet: begin`);\n showSpinner(`Deleting ${policySetId}...`);\n let outcome = false;\n const errors = [];\n const policies: PolicySkeleton[] = await readPoliciesByPolicySet(policySetId);\n for (const policy of policies) {\n try {\n debugMessage(`Deleting policy ${policy._id}`);\n await deletePolicy(policy._id);\n } catch (error) {\n error.message = `Error deleting policy ${policy._id} in policy set ${policySetId}: ${error}`;\n printMessage(error.message, 'error');\n errors.push(error);\n }\n }\n try {\n debugMessage(`Deleting policy set ${policySetId}`);\n await deletePolicySet(policySetId);\n } catch (error) {\n printMessage(`Error deleting policy set ${policySetId}: ${error}`, 'error');\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n failSpinner(`Error deleting ${policySetId}: ${errorMessages}`);\n } else {\n succeedSpinner(`Deleted ${policySetId}.`);\n outcome = true;\n }\n debugMessage(`cli.PolicySetOps.deletePolicySet: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Delete all policy sets\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicySets(): Promise<boolean> {\n debugMessage(`cli.PolicySetOps.deletePolicySets: begin`);\n let outcome = false;\n const errors = [];\n let policySets: PolicySetSkeleton[] = [];\n try {\n showSpinner(`Retrieving all policy sets...`);\n try {\n policySets = await readPolicySets();\n succeedSpinner(`Found ${policySets.length} policy sets.`);\n } catch (error) {\n error.message = `Error retrieving all policy sets: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (policySets.length)\n createProgressBar(\n policySets.length,\n `Deleting ${policySets.length} policy sets...`\n );\n for (const policySet of policySets) {\n const policySetId = policySet.name;\n try {\n const policies: PolicySkeleton[] =\n await readPoliciesByPolicySet(policySetId);\n for (const policy of policies) {\n try {\n debugMessage(`Deleting policy ${policy._id}`);\n await deletePolicy(policy._id);\n } catch (error) {\n error.message = `Error deleting policy ${policy._id} in policy set ${policySetId}: ${error}`;\n printMessage(error.message, 'error');\n errors.push(error);\n }\n }\n } catch (error) {\n errors.push(error);\n }\n try {\n debugMessage(`Deleting policy set ${policySetId}`);\n await deletePolicySet(policySetId);\n updateProgressBar(`Deleted ${policySetId}`);\n } catch (error) {\n error.message = `Error deleting policy set ${policySetId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting policy sets: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (policySets.length)\n stopProgressBar(`Error deleting all policy sets: ${errorMessages}`);\n } else {\n if (policySets.length)\n stopProgressBar(`Deleted ${policySets.length} policy sets.`);\n outcome = true;\n }\n }\n debugMessage(`cli.PolicySetOps.deletePolicySets: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Export policy set to file\n * @param {string} policySetId policy set id/name\n * @param {string} file file name\n * @param {PolicySetExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPolicySetToFile(\n policySetId: string,\n file: string,\n options: PolicySetExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.exportPolicySetToFile: begin`);\n showSpinner(`Exporting ${policySetId}...`);\n try {\n let fileName = getTypedFilename(policySetId, 'policyset.authz');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportPolicySet(policySetId, options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${policySetId} to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${policySetId}: ${error.message}`);\n }\n debugMessage(`cli.PolicySetOps.exportPolicySetToFile: end`);\n return outcome;\n}\n\n/**\n * Export policy sets to file\n * @param {string} file file name\n * @param {PolicySetExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPolicySetsToFile(\n file: string,\n options: PolicySetExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.exportPolicySetsToFile: begin`);\n showSpinner(`Exporting all policy sets...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}PolicySets`,\n 'policyset.authz'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportPolicySets(options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all policy sets to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting policy sets: ${error.message}`);\n }\n debugMessage(`cli.PolicySetOps.exportPolicySetsToFile: end`);\n return outcome;\n}\n\n/**\n * Export all policy sets to separate files\n * @param {PolicySetExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPolicySetsToFiles(\n options: PolicySetExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n debugMessage(`cli.PolicySetOps.exportPolicySetsToFiles: begin`);\n const errors = [];\n try {\n const policySets: PolicySetSkeleton[] = await readPolicySets();\n createProgressBar(policySets.length, 'Exporting policy sets...');\n for (const policySet of policySets) {\n const file = getTypedFilename(policySet.name, 'policyset.authz');\n try {\n const exportData: PolicySetExportInterface = await exportPolicySet(\n policySet.name,\n options\n );\n saveJsonToFile(exportData, getFilePath(file, true));\n updateProgressBar(`Exported ${policySet.name}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${policySet.name}.`);\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.PolicySetOps.exportPolicySetsToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import policy set from file\n * @param {string} policySetId policy set id/name\n * @param {string} file file name\n * @param {PolicySetImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPolicySetFromFile(\n policySetId: string,\n file: string,\n options: PolicySetImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.importPolicySetFromFile: begin`);\n showSpinner(`Importing ${policySetId}...`);\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n await importPolicySet(policySetId, fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${policySetId}.`);\n } catch (error) {\n failSpinner(`Error importing ${policySetId}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.importPolicySetFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first policy set from file\n * @param {string} file file name\n * @param {PolicySetImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstPolicySetFromFile(\n file: string,\n options: PolicySetImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.importFirstPolicySetFromFile: begin`);\n const filePath = getFilePath(file);\n showSpinner(`Importing first policy set from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n const policySet = await importFirstPolicySet(fileData, options);\n outcome = true;\n succeedSpinner(\n `Imported first policy set with name '${policySet.name}' from ${filePath}.`\n );\n } catch (error) {\n failSpinner(`Error importing first policy set from ${filePath}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.importFirstPolicySetFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policy sets from file\n * @param {string} file file name\n * @param {PolicySetImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPolicySetsFromFile(\n file: string,\n options: PolicySetImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.importPolicySetsFromFile: begin`);\n const filePath = getFilePath(file);\n showSpinner(`Importing ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importPolicySets(fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing ${filePath}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.importPolicySetsFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policy sets from files\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPolicySetsFromFiles(\n options: PolicySetImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.PolicySetOps.importPolicySetsFromFiles: begin`);\n const names = fs.readdirSync(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.policyset.authz.json'))\n .map((name) => getFilePath(name));\n createProgressBar(files.length, 'Importing policy sets...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: PolicySetExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.policyset).length;\n total += count;\n await importPolicySets(fileData, options);\n updateProgressBar(`Imported ${count} policy sets from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing policy sets from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} policy sets from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing policy sets from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.importPolicySetsFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAQpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,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;AAEnC,MAAM;EAAEC,YAAY;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GAAGjB,KAAK,CAACkB,KAAK;AACtE,MAAM;EAAEC,uBAAuB;EAAEC;AAAa,CAAC,GAAGpB,KAAK,CAACqB,KAAK,CAACC,MAAM;AACpE,MAAM;EACJC,cAAc;EACdC,aAAa;EACbC,eAAe;EACfC,gBAAgB;EA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ACf,QAAQ,CAACgB,SAAS,CAAC,CAACpC,MAAM;QACpDgC,KAAK,IAAIC,KAAK;QACd,MAAMxD,gBAAgB,CAAC2C,QAAQ,EAAEb,OAAO,CAAC;QACzChD,iBAAiB,CAAE,YAAW0E,KAAM,qBAAoB3B,IAAK,EAAC,CAAC;MACjE,CAAC,CAAC,OAAOR,KAAK,EAAE;QACdH,MAAM,CAACI,IAAI,CAACD,KAAK,CAAC;QAClBvC,iBAAiB,CAAE,oCAAmC+C,IAAK,EAAC,CAAC;QAC7DnD,YAAY,CAAC2C,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACAzC,eAAe,CACZ,sBAAqB2E,KAAM,qBAAoBJ,KAAK,CAAC5B,MAAO,SAC/D,CAAC;EACH,CAAC,CAAC,OAAOF,KAAK,EAAE;IACdH,MAAM,CAACI,IAAI,CAACD,KAAK,CAAC;IAClBzC,eAAe,CAAE,yCAAwC,CAAC;IAC1DF,YAAY,CAAC2C,KAAK,EAAE,OAAO,CAAC;EAC9B;EACA7C,YAAY,CAAE,iDAAgD,CAAC;EAC/D,OAAO,CAAC,KAAK0C,MAAM,CAACK,MAAM;AAC5B"}
1
+ {"version":3,"file":"PolicySetOps.js","names":["frodo","state","fs","createObjectTable","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","getRealmName","getFilePath","getWorkingDirectory","utils","readPoliciesByPolicySet","deletePolicy","authz","policy","readPolicySets","readPolicySet","exportPolicySet","exportPolicySets","importPolicySet","importFirstPolicySet","importPolicySets","deletePolicySet","policySet","listPolicySets","outcome","policySets","sort","a","b","name","localeCompare","err","message","describePolicySet","policySetId","json","table","toString","deletePolicySetById","errors","policies","_id","error","push","length","errorMessages","map","join","deletePolicySets","exportPolicySetToFile","file","options","deps","prereqs","useStringArrays","fileName","filePath","exportData","exportPolicySetsToFile","getRealm","exportPolicySetsToFiles","importPolicySetFromFile","data","readFileSync","fileData","JSON","parse","importFirstPolicySetFromFile","importPolicySetsFromFile","importPolicySetsFromFiles","names","readdirSync","files","filter","toLowerCase","endsWith","total","count","Object","keys","policyset"],"sources":["../../src/ops/PolicySetOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type PolicySkeleton } from '@rockcarver/frodo-lib/types/api/PoliciesApi';\nimport { type PolicySetSkeleton } from '@rockcarver/frodo-lib/types/api/PolicySetApi';\nimport {\n type PolicySetExportInterface,\n type PolicySetExportOptions,\n type PolicySetImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/PolicySetOps';\nimport fs from 'fs';\n\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';\n\nconst { getRealmName, getFilePath, getWorkingDirectory } = frodo.utils;\nconst { readPoliciesByPolicySet, deletePolicy } = frodo.authz.policy;\nconst {\n readPolicySets,\n readPolicySet,\n exportPolicySet,\n exportPolicySets,\n importPolicySet,\n importFirstPolicySet,\n importPolicySets,\n deletePolicySet,\n} = frodo.authz.policySet;\n\n/**\n * List policy sets\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listPolicySets(): Promise<boolean> {\n let outcome = false;\n try {\n const policySets = await readPolicySets();\n policySets.sort((a, b) => a.name.localeCompare(b.name));\n for (const policySet of policySets) {\n printMessage(`${policySet.name}`, 'data');\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicySets ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Describe policy set\n * @param {string} policySetId policy set id/name\n * @param {Object} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describePolicySet(\n policySetId: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n const policySet = await readPolicySet(policySetId);\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 set\n * @param {string} policySetId policy set id/name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicySetById(\n policySetId: string\n): Promise<boolean> {\n debugMessage(`cli.PolicySetOps.deletePolicySet: begin`);\n showSpinner(`Deleting ${policySetId}...`);\n let outcome = false;\n const errors = [];\n const policies: PolicySkeleton[] = await readPoliciesByPolicySet(policySetId);\n for (const policy of policies) {\n try {\n debugMessage(`Deleting policy ${policy._id}`);\n await deletePolicy(policy._id);\n } catch (error) {\n error.message = `Error deleting policy ${policy._id} in policy set ${policySetId}: ${error}`;\n printMessage(error.message, 'error');\n errors.push(error);\n }\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n failSpinner(`Error deleting ${policySetId}: ${errorMessages}`);\n } else {\n try {\n debugMessage(`Deleting policy set ${policySetId}`);\n await deletePolicySet(policySetId);\n succeedSpinner(`Deleted ${policySetId}.`);\n outcome = true;\n } catch (error) {\n printMessage(\n `Error deleting policy set ${policySetId}: ${error}`,\n 'error'\n );\n }\n }\n debugMessage(`cli.PolicySetOps.deletePolicySet: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Delete all policy sets\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicySets(): Promise<boolean> {\n debugMessage(`cli.PolicySetOps.deletePolicySets: begin`);\n let outcome = false;\n const errors = [];\n let policySets: PolicySetSkeleton[] = [];\n try {\n showSpinner(`Retrieving all policy sets...`);\n try {\n policySets = await readPolicySets();\n succeedSpinner(`Found ${policySets.length} policy sets.`);\n } catch (error) {\n error.message = `Error retrieving all policy sets: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (policySets.length)\n createProgressBar(\n policySets.length,\n `Deleting ${policySets.length} policy sets...`\n );\n for (const policySet of policySets) {\n const policySetId = policySet.name;\n try {\n const policies: PolicySkeleton[] =\n await readPoliciesByPolicySet(policySetId);\n for (const policy of policies) {\n try {\n debugMessage(`Deleting policy ${policy._id}`);\n await deletePolicy(policy._id);\n } catch (error) {\n error.message = `Error deleting policy ${policy._id} in policy set ${policySetId}: ${error}`;\n printMessage(error.message, 'error');\n errors.push(error);\n }\n }\n } catch (error) {\n errors.push(error);\n }\n try {\n debugMessage(`Deleting policy set ${policySetId}`);\n await deletePolicySet(policySetId);\n updateProgressBar(`Deleted ${policySetId}`);\n } catch (error) {\n error.message = `Error deleting policy set ${policySetId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting policy sets: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (policySets.length)\n stopProgressBar(`Error deleting all policy sets: ${errorMessages}`);\n } else {\n if (policySets.length)\n stopProgressBar(`Deleted ${policySets.length} policy sets.`);\n outcome = true;\n }\n }\n debugMessage(`cli.PolicySetOps.deletePolicySets: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Export policy set to file\n * @param {string} policySetId policy set id/name\n * @param {string} file file name\n * @param {PolicySetExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPolicySetToFile(\n policySetId: string,\n file: string,\n options: PolicySetExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.exportPolicySetToFile: begin`);\n showSpinner(`Exporting ${policySetId}...`);\n try {\n let fileName = getTypedFilename(policySetId, 'policyset.authz');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportPolicySet(policySetId, options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${policySetId} to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${policySetId}: ${error.message}`);\n }\n debugMessage(`cli.PolicySetOps.exportPolicySetToFile: end`);\n return outcome;\n}\n\n/**\n * Export policy sets to file\n * @param {string} file file name\n * @param {PolicySetExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPolicySetsToFile(\n file: string,\n options: PolicySetExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.exportPolicySetsToFile: begin`);\n showSpinner(`Exporting all policy sets...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}PolicySets`,\n 'policyset.authz'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportPolicySets(options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all policy sets to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting policy sets: ${error.message}`);\n }\n debugMessage(`cli.PolicySetOps.exportPolicySetsToFile: end`);\n return outcome;\n}\n\n/**\n * Export all policy sets to separate files\n * @param {PolicySetExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPolicySetsToFiles(\n options: PolicySetExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n debugMessage(`cli.PolicySetOps.exportPolicySetsToFiles: begin`);\n const errors = [];\n try {\n const policySets: PolicySetSkeleton[] = await readPolicySets();\n createProgressBar(policySets.length, 'Exporting policy sets...');\n for (const policySet of policySets) {\n const file = getTypedFilename(policySet.name, 'policyset.authz');\n try {\n const exportData: PolicySetExportInterface = await exportPolicySet(\n policySet.name,\n options\n );\n saveJsonToFile(exportData, getFilePath(file, true));\n updateProgressBar(`Exported ${policySet.name}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${policySet.name}.`);\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.PolicySetOps.exportPolicySetsToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import policy set from file\n * @param {string} policySetId policy set id/name\n * @param {string} file file name\n * @param {PolicySetImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPolicySetFromFile(\n policySetId: string,\n file: string,\n options: PolicySetImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.importPolicySetFromFile: begin`);\n showSpinner(`Importing ${policySetId}...`);\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n await importPolicySet(policySetId, fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${policySetId}.`);\n } catch (error) {\n failSpinner(`Error importing ${policySetId}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.importPolicySetFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first policy set from file\n * @param {string} file file name\n * @param {PolicySetImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstPolicySetFromFile(\n file: string,\n options: PolicySetImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.importFirstPolicySetFromFile: begin`);\n const filePath = getFilePath(file);\n showSpinner(`Importing first policy set from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n const policySet = await importFirstPolicySet(fileData, options);\n outcome = true;\n succeedSpinner(\n `Imported first policy set with name '${policySet.name}' from ${filePath}.`\n );\n } catch (error) {\n failSpinner(`Error importing first policy set from ${filePath}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.importFirstPolicySetFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policy sets from file\n * @param {string} file file name\n * @param {PolicySetImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPolicySetsFromFile(\n file: string,\n options: PolicySetImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.importPolicySetsFromFile: begin`);\n const filePath = getFilePath(file);\n showSpinner(`Importing ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importPolicySets(fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing ${filePath}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.importPolicySetsFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policy sets from files\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPolicySetsFromFiles(\n options: PolicySetImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.PolicySetOps.importPolicySetsFromFiles: begin`);\n const names = fs.readdirSync(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.policyset.authz.json'))\n .map((name) => getFilePath(name));\n createProgressBar(files.length, 'Importing policy sets...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: PolicySetExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.policyset).length;\n total += count;\n await importPolicySets(fileData, options);\n updateProgressBar(`Imported ${count} policy sets from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing policy sets from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} policy sets from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing policy sets from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.importPolicySetsFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAQpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,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,CAAC,CAAC,CACtE7B,GAAG,CAAEjB,IAAI,IAAKtB,WAAW,CAACsB,IAAI,CAAC,CAAC;IACnClC,iBAAiB,CAAC6E,KAAK,CAAC5B,MAAM,EAAE,0BAA0B,CAAC;IAC3D,IAAIgC,KAAK,GAAG,CAAC;IACb,KAAK,MAAM1B,IAAI,IAAIsB,KAAK,EAAE;MACxB,IAAI;QACF,MAAMV,IAAI,GAAGrE,EAAE,CAACsE,YAAY,CAACb,IAAI,EAAE,MAAM,CAAC;QAC1C,MAAMc,QAAkC,GAAGC,IAAI,CAACC,KAAK,CAACJ,IAAI,CAAC;QAC3D,MAAMe,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACf,QAAQ,CAACgB,SAAS,CAAC,CAACpC,MAAM;QACpDgC,KAAK,IAAIC,KAAK;QACd,MAAMzD,gBAAgB,CAAC4C,QAAQ,EAAEb,OAAO,CAAC;QACzCjD,iBAAiB,CAAE,YAAW2E,KAAM,qBAAoB3B,IAAK,EAAC,CAAC;MACjE,CAAC,CAAC,OAAOR,KAAK,EAAE;QACdH,MAAM,CAACI,IAAI,CAACD,KAAK,CAAC;QAClBxC,iBAAiB,CAAE,oCAAmCgD,IAAK,EAAC,CAAC;QAC7DpD,YAAY,CAAC4C,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACA1C,eAAe,CACZ,sBAAqB4E,KAAM,qBAAoBJ,KAAK,CAAC5B,MAAO,SAC/D,CAAC;EACH,CAAC,CAAC,OAAOF,KAAK,EAAE;IACdH,MAAM,CAACI,IAAI,CAACD,KAAK,CAAC;IAClB1C,eAAe,CAAE,yCAAwC,CAAC;IAC1DF,YAAY,CAAC4C,KAAK,EAAE,OAAO,CAAC;EAC9B;EACA9C,YAAY,CAAE,iDAAgD,CAAC;EAC/D,OAAO,CAAC,KAAK2C,MAAM,CAACK,MAAM;AAC5B"}
@@ -18,10 +18,10 @@ export async function listRealms(long = false) {
18
18
  realms.forEach(realmConfig => {
19
19
  table.push([realmConfig.name, realmConfig.active ? 'active'['brightGreen'] : 'inactive'['brightRed'], realmConfig.aliases.join('\n'), realmConfig.parentPath]);
20
20
  });
21
- printMessage(table.toString());
21
+ printMessage(table.toString(), 'data');
22
22
  } else {
23
23
  realms.forEach(realmConfig => {
24
- printMessage(realmConfig.name, 'info');
24
+ printMessage(realmConfig.name, 'data');
25
25
  });
26
26
  }
27
27
  } catch (error) {
@@ -45,7 +45,7 @@ export async function describeRealm(realm) {
45
45
  table.push(['Custom Domains'['brightCyan'], realmConfig.aliases.join('\n')]);
46
46
  table.push(['Parent'['brightCyan'], realmConfig.parentPath]);
47
47
  table.push(['Id'['brightCyan'], realmConfig._id]);
48
- printMessage(table.toString());
48
+ printMessage(table.toString(), 'data');
49
49
  } catch (error) {
50
50
  printMessage(`Realm ${realm} not found!`, 'error');
51
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RealmOps.js","names":["frodo","createKeyValueTable","createTable","printMessage","readRealms","readRealmByName","updateRealm","realm","listRealms","long","realms","table","forEach","realmConfig","push","name","active","aliases","join","parentPath","toString","error","_error$response","rmessage","response","data","describeRealm","_id","addCustomDomain","domain","exists","alias","toLowerCase","message","removeCustomDomain","filter","length"],"sources":["../../src/ops/RealmOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\n\nimport {\n createKeyValueTable,\n createTable,\n printMessage,\n} from '../utils/Console';\n\nconst { readRealms, readRealmByName, updateRealm } = frodo.realm;\n\n/**\n * List realms\n * @param {boolean} long Long list format with details\n */\nexport async function listRealms(long = false) {\n try {\n const realms = await readRealms();\n if (long) {\n const table = createTable([\n 'Name'['brightCyan'],\n 'Status'['brightCyan'],\n 'Custom Domains'['brightCyan'],\n 'Parent'['brightCyan'],\n ]);\n realms.forEach((realmConfig) => {\n table.push([\n realmConfig.name,\n realmConfig.active\n ? 'active'['brightGreen']\n : 'inactive'['brightRed'],\n realmConfig.aliases.join('\\n'),\n realmConfig.parentPath,\n ]);\n });\n printMessage(table.toString());\n } else {\n realms.forEach((realmConfig) => {\n printMessage(realmConfig.name, 'info');\n });\n }\n } catch (error) {\n printMessage(error, 'error');\n printMessage(`Error listing realms: ${error.rmessage}`, 'error');\n printMessage(error.response?.data, 'error');\n }\n}\n\n/**\n * Describe realm\n * @param {String} realm realm name\n */\nexport async function describeRealm(realm: string) {\n try {\n const realmConfig = await readRealmByName(realm);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], realmConfig.name]);\n table.push([\n 'Status'['brightCyan'],\n realmConfig.active ? 'active'['brightGreen'] : 'inactive'['brightRed'],\n ]);\n table.push([\n 'Custom Domains'['brightCyan'],\n realmConfig.aliases.join('\\n'),\n ]);\n table.push(['Parent'['brightCyan'], realmConfig.parentPath]);\n table.push(['Id'['brightCyan'], realmConfig._id]);\n printMessage(table.toString());\n } catch (error) {\n printMessage(`Realm ${realm} not found!`, 'error');\n }\n}\n\n/**\n * Add custom DNS domain name (realm DNS alias)\n * @param {String} realm realm name\n * @param {String} domain domain name\n */\nexport async function addCustomDomain(realm: string, domain: string) {\n try {\n let realmConfig = await readRealmByName(realm);\n let exists = false;\n realmConfig.aliases.forEach((alias) => {\n if (domain.toLowerCase() === alias.toLowerCase()) {\n exists = true;\n }\n });\n if (!exists) {\n try {\n realmConfig.aliases.push(domain.toLowerCase());\n realmConfig = await updateRealm(realmConfig._id, realmConfig);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], realmConfig.name]);\n table.push([\n 'Status'['brightCyan'],\n realmConfig.active\n ? 'active'['brightGreen']\n : 'inactive'['brightRed'],\n ]);\n table.push([\n 'Custom Domains'['brightCyan'],\n realmConfig.aliases.join('\\n'),\n ]);\n table.push(['Parent'['brightCyan'], realmConfig.parentPath]);\n table.push(['Id'['brightCyan'], realmConfig._id]);\n printMessage(table.toString());\n } catch (error) {\n printMessage(`Error adding custom domain: ${error.message}`, 'error');\n }\n }\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n }\n}\n\n/**\n * Remove custom DNS domain name (realm DNS alias)\n * @param {String} realm realm name\n * @param {String} domain domain name\n */\nexport async function removeCustomDomain(realm: string, domain: string) {\n try {\n let realmConfig = await readRealmByName(realm);\n const aliases = realmConfig.aliases.filter(\n (alias) => domain.toLowerCase() !== alias.toLowerCase()\n );\n if (aliases.length < realmConfig.aliases.length) {\n try {\n realmConfig.aliases = aliases;\n realmConfig = await updateRealm(realmConfig._id, realmConfig);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], realmConfig.name]);\n table.push([\n 'Status'['brightCyan'],\n realmConfig.active\n ? 'active'['brightGreen']\n : 'inactive'['brightRed'],\n ]);\n table.push([\n 'Custom Domains'['brightCyan'],\n realmConfig.aliases.join('\\n'),\n ]);\n table.push(['Parent'['brightCyan'], realmConfig.parentPath]);\n table.push(['Id'['brightCyan'], realmConfig._id]);\n printMessage(table.toString());\n } catch (error) {\n printMessage(`Error removing custom domain: ${error.message}`, 'error');\n }\n }\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAE7C,SACEC,mBAAmB,EACnBC,WAAW,EACXC,YAAY,QACP,kBAAkB;AAEzB,MAAM;EAAEC,UAAU;EAAEC,eAAe;EAAEC;AAAY,CAAC,GAAGN,KAAK,CAACO,KAAK;;AAEhE;AACA;AACA;AACA;AACA,OAAO,eAAeC,UAAUA,CAACC,IAAI,GAAG,KAAK,EAAE;EAC7C,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMN,UAAU,CAAC,CAAC;IACjC,IAAIK,IAAI,EAAE;MACR,MAAME,KAAK,GAAGT,WAAW,CAAC,CACxB,MAAM,CAAC,YAAY,CAAC,EACpB,QAAQ,CAAC,YAAY,CAAC,EACtB,gBAAgB,CAAC,YAAY,CAAC,EAC9B,QAAQ,CAAC,YAAY,CAAC,CACvB,CAAC;MACFQ,MAAM,CAACE,OAAO,CAAEC,WAAW,IAAK;QAC9BF,KAAK,CAACG,IAAI,CAAC,CACTD,WAAW,CA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GV,mBAAmB,CAAC,CAAC;QACnCU,KAAK,CAACG,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,EAAED,WAAW,CAACE,IAAI,CAAC,CAAC;QACpDJ,KAAK,CAACG,IAAI,CAAC,CACT,QAAQ,CAAC,YAAY,CAAC,EACtBD,WAAW,CAACG,MAAM,GACd,QAAQ,CAAC,aAAa,CAAC,GACvB,UAAU,CAAC,WAAW,CAAC,CAC5B,CAAC;QACFL,KAAK,CAACG,IAAI,CAAC,CACT,gBAAgB,CAAC,YAAY,CAAC,EAC9BD,WAAW,CAACI,OAAO,CAACC,IAAI,CAAC,IAAI,CAAC,CAC/B,CAAC;QACFP,KAAK,CAACG,IAAI,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAED,WAAW,CAACM,UAAU,CAAC,CAAC;QAC5DR,KAAK,CAACG,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,EAAED,WAAW,CAACc,GAAG,CAAC,CAAC;QACjDxB,YAAY,CAACQ,KAAK,CAACS,QAAQ,CAAC,CAAC,CAAC;MAChC,CAAC,CAAC,OAAOC,KAAK,EAAE;QACdlB,YAAY,CAAE,iCAAgCkB,KAAK,CAACY,OAAQ,EAAC,EAAE,OAAO,CAAC;MACzE;IACF;EACF,CAAC,CAAC,OAAOZ,KAAK,EAAE;IACdlB,YAAY,CAAE,GAAEkB,KAAK,CAACY,OAAQ,EAAC,EAAE,OAAO,CAAC;EAC3C;AACF"}
1
+ {"version":3,"file":"RealmOps.js","names":["frodo","createKeyValueTable","createTable","printMessage","readRealms","readRealmByName","updateRealm","realm","listRealms","long","realms","table","forEach","realmConfig","push","name","active","aliases","join","parentPath","toString","error","_error$response","rmessage","response","data","describeRealm","_id","addCustomDomain","domain","exists","alias","toLowerCase","message","removeCustomDomain","filter","length"],"sources":["../../src/ops/RealmOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\n\nimport {\n createKeyValueTable,\n createTable,\n printMessage,\n} from '../utils/Console';\n\nconst { readRealms, readRealmByName, updateRealm } = frodo.realm;\n\n/**\n * List realms\n * @param {boolean} long Long list format with details\n */\nexport async function listRealms(long = false) {\n try {\n const realms = await readRealms();\n if (long) {\n const table = createTable([\n 'Name'['brightCyan'],\n 'Status'['brightCyan'],\n 'Custom Domains'['brightCyan'],\n 'Parent'['brightCyan'],\n ]);\n realms.forEach((realmConfig) => {\n table.push([\n realmConfig.name,\n realmConfig.active\n ? 'active'['brightGreen']\n : 'inactive'['brightRed'],\n realmConfig.aliases.join('\\n'),\n realmConfig.parentPath,\n ]);\n });\n printMessage(table.toString(), 'data');\n } else {\n realms.forEach((realmConfig) => {\n printMessage(realmConfig.name, 'data');\n });\n }\n } catch (error) {\n printMessage(error, 'error');\n printMessage(`Error listing realms: ${error.rmessage}`, 'error');\n printMessage(error.response?.data, 'error');\n }\n}\n\n/**\n * Describe realm\n * @param {String} realm realm name\n */\nexport async function describeRealm(realm: string) {\n try {\n const realmConfig = await readRealmByName(realm);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], realmConfig.name]);\n table.push([\n 'Status'['brightCyan'],\n realmConfig.active ? 'active'['brightGreen'] : 'inactive'['brightRed'],\n ]);\n table.push([\n 'Custom Domains'['brightCyan'],\n realmConfig.aliases.join('\\n'),\n ]);\n table.push(['Parent'['brightCyan'], realmConfig.parentPath]);\n table.push(['Id'['brightCyan'], realmConfig._id]);\n printMessage(table.toString(), 'data');\n } catch (error) {\n printMessage(`Realm ${realm} not found!`, 'error');\n }\n}\n\n/**\n * Add custom DNS domain name (realm DNS alias)\n * @param {String} realm realm name\n * @param {String} domain domain name\n */\nexport async function addCustomDomain(realm: string, domain: string) {\n try {\n let realmConfig = await readRealmByName(realm);\n let exists = false;\n realmConfig.aliases.forEach((alias) => {\n if (domain.toLowerCase() === alias.toLowerCase()) {\n exists = true;\n }\n });\n if (!exists) {\n try {\n realmConfig.aliases.push(domain.toLowerCase());\n realmConfig = await updateRealm(realmConfig._id, realmConfig);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], realmConfig.name]);\n table.push([\n 'Status'['brightCyan'],\n realmConfig.active\n ? 'active'['brightGreen']\n : 'inactive'['brightRed'],\n ]);\n table.push([\n 'Custom Domains'['brightCyan'],\n realmConfig.aliases.join('\\n'),\n ]);\n table.push(['Parent'['brightCyan'], realmConfig.parentPath]);\n table.push(['Id'['brightCyan'], realmConfig._id]);\n printMessage(table.toString());\n } catch (error) {\n printMessage(`Error adding custom domain: ${error.message}`, 'error');\n }\n }\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n }\n}\n\n/**\n * Remove custom DNS domain name (realm DNS alias)\n * @param {String} realm realm name\n * @param {String} domain domain name\n */\nexport async function removeCustomDomain(realm: string, domain: string) {\n try {\n let realmConfig = await readRealmByName(realm);\n const aliases = realmConfig.aliases.filter(\n (alias) => domain.toLowerCase() !== alias.toLowerCase()\n );\n if (aliases.length < realmConfig.aliases.length) {\n try {\n realmConfig.aliases = aliases;\n realmConfig = await updateRealm(realmConfig._id, realmConfig);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], realmConfig.name]);\n table.push([\n 'Status'['brightCyan'],\n realmConfig.active\n ? 'active'['brightGreen']\n : 'inactive'['brightRed'],\n ]);\n table.push([\n 'Custom Domains'['brightCyan'],\n realmConfig.aliases.join('\\n'),\n ]);\n table.push(['Parent'['brightCyan'], realmConfig.parentPath]);\n table.push(['Id'['brightCyan'], realmConfig._id]);\n printMessage(table.toString());\n } catch (error) {\n printMessage(`Error removing custom domain: ${error.message}`, 'error');\n }\n }\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAE7C,SACEC,mBAAmB,EACnBC,WAAW,EACXC,YAAY,QACP,kBAAkB;AAEzB,MAAM;EAAEC,UAAU;EAAEC,eAAe;EAAEC;AAAY,CAAC,GAAGN,KAAK,CAACO,KAAK;;AAEhE;AACA;AACA;AACA;AACA,OAA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OAAOZ,KAAK,EAAE;IACdlB,YAAY,CAAE,GAAEkB,KAAK,CAACY,OAAQ,EAAC,EAAE,OAAO,CAAC;EAC3C;AACF"}
@@ -17,7 +17,9 @@ const {
17
17
  importResourceType,
18
18
  importResourceTypeByName,
19
19
  importFirstResourceType,
20
- importResourceTypes
20
+ importResourceTypes,
21
+ deleteResourceType,
22
+ deleteResourceTypeByName
21
23
  } = frodo.authz.resourceType;
22
24
 
23
25
  /**
@@ -112,26 +114,18 @@ export async function describeResourceTypeByName(resourceTypeName, json = false)
112
114
  * @param {string} resourceTypeUuid resource type uuid
113
115
  * @returns {Promise<boolean>} true if successful, false otherwise
114
116
  */
115
- export async function deleteResourceType(resourceTypeUuid) {
117
+ export async function deleteResourceTypeById(resourceTypeUuid) {
116
118
  debugMessage(`cli.ResourceTypeOps.deleteResourceType: begin`);
117
119
  showSpinner(`Deleting ${resourceTypeUuid}...`);
118
120
  let outcome = false;
119
- const errors = [];
120
121
  try {
121
122
  debugMessage(`Deleting resource type ${resourceTypeUuid}`);
122
123
  await deleteResourceType(resourceTypeUuid);
123
- } catch (error) {
124
- errors.push(error);
125
- }
126
- if (errors.length) {
127
- const errorMessages = errors.map(error => {
128
- var _error$response5;
129
- return ((_error$response5 = error.response) === null || _error$response5 === void 0 || (_error$response5 = _error$response5.data) === null || _error$response5 === void 0 ? void 0 : _error$response5.message) || error.message;
130
- }).join('\n');
131
- failSpinner(`Error deleting ${resourceTypeUuid}: ${errorMessages}`);
132
- } else {
133
124
  succeedSpinner(`Deleted ${resourceTypeUuid}.`);
134
125
  outcome = true;
126
+ } catch (error) {
127
+ var _error$response5;
128
+ failSpinner(`Error deleting ${resourceTypeUuid}: ${((_error$response5 = error.response) === null || _error$response5 === void 0 || (_error$response5 = _error$response5.data) === null || _error$response5 === void 0 ? void 0 : _error$response5.message) || error.message}`);
135
129
  }
136
130
  debugMessage(`cli.ResourceTypeOps.deleteResourceType: end [outcome=${outcome}]`);
137
131
  return outcome;
@@ -142,26 +136,18 @@ export async function deleteResourceType(resourceTypeUuid) {
142
136
  * @param {string} resourceTypeName resource type name
143
137
  * @returns {Promise<boolean>} true if successful, false otherwise
144
138
  */
145
- export async function deleteResourceTypeByName(resourceTypeName) {
139
+ export async function deleteResourceTypeUsingName(resourceTypeName) {
146
140
  debugMessage(`cli.ResourceTypeOps.deleteResourceTypeByName: begin`);
147
141
  showSpinner(`Deleting ${resourceTypeName}...`);
148
142
  let outcome = false;
149
- const errors = [];
150
143
  try {
151
144
  debugMessage(`Deleting resource type ${resourceTypeName}`);
152
145
  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;
159
- return ((_error$response6 = error.response) === null || _error$response6 === void 0 || (_error$response6 = _error$response6.data) === null || _error$response6 === void 0 ? void 0 : _error$response6.message) || error.message;
160
- }).join('\n');
161
- failSpinner(`Error deleting ${resourceTypeName}: ${errorMessages}`);
162
- } else {
163
146
  succeedSpinner(`Deleted ${resourceTypeName}.`);
164
147
  outcome = true;
148
+ } catch (error) {
149
+ var _error$response6;
150
+ failSpinner(`Error deleting ${resourceTypeName}: ${((_error$response6 = error.response) === null || _error$response6 === void 0 || (_error$response6 = _error$response6.data) === null || _error$response6 === void 0 ? void 0 : _error$response6.message) || error.message}`);
165
151
  }
166
152
  debugMessage(`cli.ResourceTypeOps.deleteResourceTypeByName: end [outcome=${outcome}]`);
167
153
  return outcome;
@@ -1 +1 @@
1
- {"version":3,"file":"ResourceTypeOps.js","names":["frodo","state","fs","createObjectTable","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","getRealmName","getFilePath","getWorkingDirectory","utils","readResourceTypes","readResourceType","readResourceTypeByName","exportResourceType","exportResourceTypeByName","exportResourceTypes","importResourceType","importResourceTypeByName","importFirstResourceType","importResourceTypes","authz","resourceType","listResourceTypes","long","outcome","resourceTypes","sort","a","b","name","localeCompare","table","push","description","uuid","toString","err","message","describeResourceType","resourceTypeUuid","json","error","_error$response","response","status","getRealm","_error$response2","data","describeResourceTypeByName","resourceTypeName","_error$response3","_error$response4","deleteResourceType","errors","length","errorMessages","map","_error$response5","join","deleteResourceTypeByName","_error$response6","deleteResourceTypes","resourceTypeId","exportResourceTypeToFile","file","fileName","filePath","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":["../../src/ops/ResourceTypeOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type ResourceTypeSkeleton } from '@rockcarver/frodo-lib/types/api/ResourceTypesApi';\nimport { type ResourceTypeExportInterface } from '@rockcarver/frodo-lib/types/ops/ResourceTypeOps';\nimport fs from 'fs';\n\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';\n\nconst { getRealmName, getFilePath, getWorkingDirectory } = frodo.utils;\nconst {\n readResourceTypes,\n readResourceType,\n readResourceTypeByName,\n exportResourceType,\n exportResourceTypeByName,\n exportResourceTypes,\n importResourceType,\n importResourceTypeByName,\n importFirstResourceType,\n importResourceTypes,\n} = frodo.authz.resourceType;\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 readResourceTypes();\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 readResourceType(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 readResourceTypeByName(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 readResourceTypes();\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 filePath = getFilePath(fileName, true);\n const exportData = await exportResourceType(resourceTypeUuid);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${resourceTypeUuid} to ${filePath}.`);\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 filePath = getFilePath(fileName, true);\n const exportData = await exportResourceTypeByName(resourceTypeName);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${resourceTypeName} to ${filePath}.`);\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 filePath = getFilePath(fileName, true);\n const exportData = await exportResourceTypes();\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all resource types to ${filePath}.`);\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 readResourceTypes();\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, getFilePath(file, true));\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(getFilePath(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(getFilePath(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 const filePath = getFilePath(file);\n showSpinner(`Importing ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstResourceType(fileData);\n outcome = true;\n succeedSpinner(`Imported ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing ${filePath}.`);\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 const filePath = getFilePath(file);\n showSpinner(`Importing ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importResourceTypes(fileData);\n outcome = true;\n succeedSpinner(`Imported ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing ${filePath}.`);\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(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.resourcetype.authz.json'))\n .map((name) => getFilePath(name));\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,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAGpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,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;AAEnC,MAAM;EAAEC,YAAY;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GAAGlB,KAAK,CAACmB,KAAK;AACtE,MAAM;EACJC,iBAAiB;EACjBC,gBAAgB;EAChBC,sBAAsB;EACtBC,kBAAkB;EAClBC,wBAAwB;EACxBC,mBAAmB;EACnBC,kBAAkB;EAClBC,wBAAwB;EACxBC,uBAAuB;EACvBC;AACF,CAAC,GAAG7B,KAAK,CAAC8B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Table","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","getRealmName","getFilePath","getWorkingDirectory","utils","readResourceTypes","readResourceType","readResourceTypeByName","exportResourceType","exportResourceTypeByName","exportResourceTypes","importResourceType","importResourceTypeByName","importFirstResourceType","importResourceTypes","deleteResourceType","deleteResourceTypeByName","authz","resourceType","listResourceTypes","long","outcome","resourceTypes","sort","a","b","name","localeCompare","table","push","description","uuid","toString","err","message","describeResourceType","resourceTypeUuid","json","error","_error$response","response","status","getRealm","_error$response2","data","describeResourceTypeByName","resourceTypeName","_error$response3","_error$response4","deleteResourceTypeById","_error$response5","deleteResourceTypeUsingName","_error$response6","deleteResourceTypes","errors","length","resourceTypeId","errorMessages","map","join","exportResourceTypeToFile","file","fileName","filePath","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":["../../src/ops/ResourceTypeOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type ResourceTypeSkeleton } from '@rockcarver/frodo-lib/types/api/ResourceTypesApi';\nimport { type ResourceTypeExportInterface } from '@rockcarver/frodo-lib/types/ops/ResourceTypeOps';\nimport fs from 'fs';\n\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';\n\nconst { getRealmName, getFilePath, getWorkingDirectory } = frodo.utils;\nconst {\n readResourceTypes,\n readResourceType,\n readResourceTypeByName,\n exportResourceType,\n exportResourceTypeByName,\n exportResourceTypes,\n importResourceType,\n importResourceTypeByName,\n importFirstResourceType,\n importResourceTypes,\n deleteResourceType,\n deleteResourceTypeByName,\n} = frodo.authz.resourceType;\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 readResourceTypes();\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 readResourceType(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 readResourceTypeByName(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 deleteResourceTypeById(\n resourceTypeUuid: string\n): Promise<boolean | ResourceTypeSkeleton> {\n debugMessage(`cli.ResourceTypeOps.deleteResourceType: begin`);\n showSpinner(`Deleting ${resourceTypeUuid}...`);\n let outcome = false;\n try {\n debugMessage(`Deleting resource type ${resourceTypeUuid}`);\n await deleteResourceType(resourceTypeUuid);\n succeedSpinner(`Deleted ${resourceTypeUuid}.`);\n outcome = true;\n } catch (error) {\n failSpinner(\n `Error deleting ${resourceTypeUuid}: ${\n error.response?.data?.message || error.message\n }`\n );\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 deleteResourceTypeUsingName(\n resourceTypeName: string\n): Promise<boolean | ResourceTypeSkeleton> {\n debugMessage(`cli.ResourceTypeOps.deleteResourceTypeByName: begin`);\n showSpinner(`Deleting ${resourceTypeName}...`);\n let outcome = false;\n try {\n debugMessage(`Deleting resource type ${resourceTypeName}`);\n await deleteResourceTypeByName(resourceTypeName);\n succeedSpinner(`Deleted ${resourceTypeName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(\n `Error deleting ${resourceTypeName}: ${\n error.response?.data?.message || error.message\n }`\n );\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 readResourceTypes();\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 filePath = getFilePath(fileName, true);\n const exportData = await exportResourceType(resourceTypeUuid);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${resourceTypeUuid} to ${filePath}.`);\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 filePath = getFilePath(fileName, true);\n const exportData = await exportResourceTypeByName(resourceTypeName);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${resourceTypeName} to ${filePath}.`);\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 filePath = getFilePath(fileName, true);\n const exportData = await exportResourceTypes();\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all resource types to ${filePath}.`);\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 readResourceTypes();\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, getFilePath(file, true));\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(getFilePath(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(getFilePath(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 const filePath = getFilePath(file);\n showSpinner(`Importing ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstResourceType(fileData);\n outcome = true;\n succeedSpinner(`Imported ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing ${filePath}.`);\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 const filePath = getFilePath(file);\n showSpinner(`Importing ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importResourceTypes(fileData);\n outcome = true;\n succeedSpinner(`Imported ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing ${filePath}.`);\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(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.resourcetype.authz.json'))\n .map((name) => getFilePath(name));\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,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAGpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,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;AAEnC,MAAM;EAAEC,YAAY;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GAAGlB,KAAK,CAACmB,KAAK;AACtE,MAAM;EACJC,iBAAiB;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AAY,CAACR,IAAI,EAAE,MAAM,CAAC;QAC1C,MAAMS,QAAqC,GAAGC,IAAI,CAACC,KAAK,CAAC5B,IAAI,CAAC;QAC9D,MAAMwC,KAAK,GAAGC,MAAM,CAACC,IAAI,CAAChB,QAAQ,CAACiB,YAAY,CAAC,CAAChC,MAAM;QACvD4B,KAAK,IAAIC,KAAK;QACd,MAAMtE,mBAAmB,CAACwD,QAAQ,CAAC;QACnCzE,iBAAiB,CAAE,YAAWuF,KAAM,wBAAuBvB,IAAK,EAAC,CAAC;MACpE,CAAC,CAAC,OAAOvB,KAAK,EAAE;QACdgB,MAAM,CAACzB,IAAI,CAACS,KAAK,CAAC;QAClBzC,iBAAiB,CAAE,uCAAsCgE,IAAK,EAAC,CAAC;QAChEpE,YAAY,CAAC6C,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACA3C,eAAe,CACZ,sBAAqBwF,KAAM,wBAAuBJ,KAAK,CAACxB,MAAO,SAClE,CAAC;EACH,CAAC,CAAC,OAAOjB,KAAK,EAAE;IACdgB,MAAM,CAACzB,IAAI,CAACS,KAAK,CAAC;IAClB3C,eAAe,CAAE,4CAA2C,CAAC;IAC7DF,YAAY,CAAC6C,KAAK,EAAE,OAAO,CAAC;EAC9B;EACA/C,YAAY,CAAE,uDAAsD,CAAC;EACrE,OAAO,CAAC,KAAK+D,MAAM,CAACC,MAAM;AAC5B"}
@@ -90,7 +90,7 @@ export async function listSaml2Providers(long = false) {
90
90
  for (const provider of providerList) {
91
91
  table.push([provider.entityId, provider.location, provider.roles.map(role => roleMap[role]).join(', ')]);
92
92
  }
93
- printMessage(table.toString());
93
+ printMessage(table.toString(), 'data');
94
94
  }
95
95
  }
96
96
 
@@ -112,7 +112,7 @@ export async function describeSaml2Provider(entityId) {
112
112
  rawProviderData.roles = roles;
113
113
  rawProviderData.metadataUrl = getSaml2ProviderMetadataUrl(entityId);
114
114
  const table = createObjectTable(rawProviderData);
115
- printMessage(table.toString());
115
+ printMessage(table.toString(), 'data');
116
116
  } catch (error) {
117
117
  printMessage(error.message, 'error');
118
118
  }