@rockcarver/frodo-cli 2.0.0-21 → 2.0.0-23

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 (50) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/esm/cli/FrodoCommand.js +3 -1
  3. package/esm/cli/FrodoCommand.js.map +1 -1
  4. package/esm/cli/agent/agent-web.js +2 -2
  5. package/esm/cli/agent/agent-web.js.map +1 -1
  6. package/esm/cli/app/app-import.js +1 -1
  7. package/esm/cli/app/app-import.js.map +1 -1
  8. package/esm/cli/idm/idm-export.js +14 -8
  9. package/esm/cli/idm/idm-export.js.map +1 -1
  10. package/esm/cli/idm/idm-import.js +14 -8
  11. package/esm/cli/idm/idm-import.js.map +1 -1
  12. package/esm/cli/journey/journey-export.js +2 -3
  13. package/esm/cli/journey/journey-export.js.map +1 -1
  14. package/esm/cli/oauth/oauth-client-import.js +1 -1
  15. package/esm/cli/oauth/oauth-client-import.js.map +1 -1
  16. package/esm/cli/service/service-import.js +2 -3
  17. package/esm/cli/service/service-import.js.map +1 -1
  18. package/esm/ops/AdminFederationOps.js +29 -20
  19. package/esm/ops/AdminFederationOps.js.map +1 -1
  20. package/esm/ops/AgentOps.js +41 -34
  21. package/esm/ops/AgentOps.js.map +1 -1
  22. package/esm/ops/ApplicationOps.js +23 -17
  23. package/esm/ops/ApplicationOps.js.map +1 -1
  24. package/esm/ops/CirclesOfTrustOps.js +27 -20
  25. package/esm/ops/CirclesOfTrustOps.js.map +1 -1
  26. package/esm/ops/EmailTemplateOps.js +19 -14
  27. package/esm/ops/EmailTemplateOps.js.map +1 -1
  28. package/esm/ops/IdmOps.js +14 -22
  29. package/esm/ops/IdmOps.js.map +1 -1
  30. package/esm/ops/IdpOps.js +27 -19
  31. package/esm/ops/IdpOps.js.map +1 -1
  32. package/esm/ops/JourneyOps.js +18 -51
  33. package/esm/ops/JourneyOps.js.map +1 -1
  34. package/esm/ops/OAuth2ClientOps.js +23 -17
  35. package/esm/ops/OAuth2ClientOps.js.map +1 -1
  36. package/esm/ops/PolicyOps.js +27 -20
  37. package/esm/ops/PolicyOps.js.map +1 -1
  38. package/esm/ops/PolicySetOps.js +23 -17
  39. package/esm/ops/PolicySetOps.js.map +1 -1
  40. package/esm/ops/ResourceTypeOps.js +27 -20
  41. package/esm/ops/ResourceTypeOps.js.map +1 -1
  42. package/esm/ops/Saml2Ops.js +22 -14
  43. package/esm/ops/Saml2Ops.js.map +1 -1
  44. package/esm/ops/ScriptOps.js +22 -15
  45. package/esm/ops/ScriptOps.js.map +1 -1
  46. package/esm/ops/ServiceOps.js +21 -16
  47. package/esm/ops/ServiceOps.js.map +1 -1
  48. package/esm/ops/ThemeOps.js +21 -15
  49. package/esm/ops/ThemeOps.js.map +1 -1
  50. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"PolicyOps.js","names":["frodo","state","fs","createObjectTable","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","getRealmName","utils","readPolicies","readPoliciesByPolicySet","readPolicy","exportPolicy","exportPolicies","exportPoliciesByPolicySet","importPolicy","importFirstPolicy","importPolicies","authz","policy","listPolicies","long","outcome","policies","sort","a","b","_id","localeCompare","table","push","description","active","toString","err","message","listPoliciesByPolicySet","policySetId","describePolicy","policyId","json","policySet","deletePolicy","errors","error","length","errorMessages","map","join","deletePolicies","deletePoliciesByPolicySet","exportPolicyToFile","file","options","deps","prereqs","useStringArrays","fileName","exportData","exportPoliciesToFile","getRealm","exportPoliciesByPolicySetToFile","exportPoliciesToFiles","exportPoliciesByPolicySetToFiles","importPolicyFromFile","data","readFileSync","fileData","JSON","parse","importFirstPolicyFromFile","importPoliciesFromFile","policySetName","importPoliciesFromFiles","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","policyset"],"sources":["../../src/ops/PolicyOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type PolicySkeleton } from '@rockcarver/frodo-lib/types/api/PoliciesApi';\nimport type {\n PolicyExportInterface,\n PolicyExportOptions,\n PolicyImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/PolicyOps';\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 } = frodo.utils;\nconst {\n readPolicies,\n readPoliciesByPolicySet,\n readPolicy,\n exportPolicy,\n exportPolicies,\n exportPoliciesByPolicySet,\n importPolicy,\n importFirstPolicy,\n importPolicies,\n} = frodo.authz.policy;\n\n/**\n * List policies\n * @param {boolean} long list with details\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listPolicies(long = false): Promise<boolean> {\n let outcome = false;\n try {\n const policies = await readPolicies();\n policies.sort((a, b) => a._id.localeCompare(b._id));\n for (const policy of policies) {\n if (!long) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n if (long) {\n const table = createTable(['Id', 'Description', 'Status']);\n for (const policy of policies) {\n table.push([\n `${policy._id}`,\n `${policy.description}`,\n policy.active ? 'active'['brightGreen'] : 'inactive'['brightRed'],\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const policy of policies) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicies ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * List policies by policy set\n * @param {string} policySetId policy set id/name\n * @param {boolean} long list with details\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listPoliciesByPolicySet(\n policySetId: string,\n long = false\n): Promise<boolean> {\n let outcome = false;\n try {\n const policies = await readPoliciesByPolicySet(policySetId);\n policies.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Id', 'Description', 'Status']);\n for (const policy of policies) {\n table.push([\n `${policy._id}`,\n `${policy.description}`,\n policy.active ? 'active'['brightGreen'] : 'inactive'['brightRed'],\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const policy of policies) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicies ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Describe policy\n * @param {string} policyId policy id/name\n * @param {Object} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describePolicy(\n policyId: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n const policySet = await readPolicy(policyId);\n outcome = true;\n if (json) {\n printMessage(policySet, 'data');\n } else {\n const table = createObjectTable(policySet);\n printMessage(table.toString(), 'data');\n }\n return outcome;\n}\n\n/**\n * Delete policy\n * @param {string} policyId policy id/name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicy(policyId: string): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePolicy: begin`);\n showSpinner(`Deleting ${policyId}...`);\n let outcome = false;\n const errors = [];\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await deletePolicy(policyId);\n } catch (error) {\n printMessage(`Error deleting policy ${policyId}: ${error}`, 'error');\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n failSpinner(`Error deleting ${policyId}: ${errorMessages}`);\n } else {\n succeedSpinner(`Deleted ${policyId}.`);\n outcome = true;\n }\n debugMessage(`cli.PolicyOps.deletePolicy: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Delete all policies\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicies(): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePolicies: begin`);\n let outcome = false;\n const errors = [];\n let policies: PolicySkeleton[] = [];\n try {\n showSpinner(`Retrieving all policies...`);\n try {\n policies = await readPolicies();\n succeedSpinner(`Found ${policies.length} policies.`);\n } catch (error) {\n error.message = `Error retrieving all policies: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (policies.length)\n createProgressBar(\n policies.length,\n `Deleting ${policies.length} policies...`\n );\n for (const policy of policies) {\n const policyId = policy._id;\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await deletePolicy(policyId);\n updateProgressBar(`Deleted ${policyId}`);\n } catch (error) {\n error.message = `Error deleting policy ${policyId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting policies: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (policies.length)\n stopProgressBar(`Error deleting all policies: ${errorMessages}`);\n } else {\n if (policies.length)\n stopProgressBar(`Deleted ${policies.length} policies.`);\n outcome = true;\n }\n }\n debugMessage(`cli.PolicyOps.deletePolicies: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Delete all policies in policy set\n * @param {string} policySetId policy set id/name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePoliciesByPolicySet(\n policySetId: string\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePoliciesByPolicySet: begin`);\n let outcome = false;\n const errors = [];\n let policies: PolicySkeleton[] = [];\n try {\n showSpinner(`Retrieving all policies from policy set ${policySetId}...`);\n try {\n policies = await readPoliciesByPolicySet(policySetId);\n succeedSpinner(\n `Found ${policies.length} policies in policy set ${policySetId}.`\n );\n } catch (error) {\n error.message = `Error retrieving all policies from policy set ${policySetId}: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (policies.length)\n createProgressBar(\n policies.length,\n `Deleting ${policies.length} policies from policy set ${policySetId}...`\n );\n for (const policy of policies) {\n const policyId = policy._id;\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await deletePolicy(policyId);\n updateProgressBar(`Deleted ${policyId}`);\n } catch (error) {\n error.message = `Error deleting policy ${policyId} from policy set ${policySetId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting policies from policy set ${policySetId}: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (policies.length)\n stopProgressBar(\n `Error deleting all policies from policy set ${policySetId}: ${errorMessages}`\n );\n } else {\n if (policies.length)\n stopProgressBar(`Deleted ${policies.length} policies.`);\n outcome = true;\n }\n }\n debugMessage(\n `cli.PolicyOps.deletePoliciesByPolicySet: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Export policy to file\n * @param {string} policyId policy id/name\n * @param {string} file file name\n * @param {ApplicationExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPolicyToFile(\n policyId: string,\n file: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPolicyToFile: begin`);\n showSpinner(`Exporting ${policyId}...`);\n try {\n let fileName = getTypedFilename(policyId, 'policy.authz');\n if (file) {\n fileName = file;\n }\n const exportData = await exportPolicy(policyId, options);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported ${policyId} to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${policyId}: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPolicyToFile: end`);\n return outcome;\n}\n\n/**\n * Export policies to file\n * @param {string} file file name\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesToFile(\n file: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: begin`);\n showSpinner(`Exporting all policy sets...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}Policies`,\n 'policy.authz'\n );\n if (file) {\n fileName = file;\n }\n const exportData = await exportPolicies(options);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported all policy sets to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting policy sets: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: end`);\n return outcome;\n}\n\n/**\n * Export policies to file\n * @param {string} policySetId policy set id/name\n * @param {string} file file name\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesByPolicySetToFile(\n policySetId: string,\n file: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: begin`);\n showSpinner(`Exporting all policy sets...`);\n try {\n let fileName = getTypedFilename(\n `all${\n titleCase(getRealmName(state.getRealm())) + titleCase(policySetId)\n }Policies`,\n 'policy.authz'\n );\n if (file) {\n fileName = file;\n }\n const exportData = await exportPoliciesByPolicySet(policySetId, options);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported all policy sets to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting policy sets: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: end`);\n return outcome;\n}\n\n/**\n * Export all policies to separate files\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesToFiles(\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: begin`);\n const errors = [];\n try {\n const policies: PolicySkeleton[] = await readPolicies();\n createProgressBar(policies.length, 'Exporting policy sets...');\n for (const policy of policies) {\n const file = getTypedFilename(policy._id, 'policy.authz');\n try {\n const exportData: PolicyExportInterface = await exportPolicy(\n policy._id,\n options\n );\n saveJsonToFile(exportData, file);\n updateProgressBar(`Exported ${policy._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${policy._id}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting policy sets to files`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Export all policies to separate files\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesByPolicySetToFiles(\n policySetId: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: begin`);\n const errors = [];\n try {\n const policies: PolicySkeleton[] =\n await readPoliciesByPolicySet(policySetId);\n createProgressBar(\n policies.length,\n `Exporting policies in policy set ${policySetId}...`\n );\n for (const policy of policies) {\n const file = getTypedFilename(policy._id, 'policy.authz');\n try {\n const exportData: PolicyExportInterface = await exportPolicy(\n policy._id,\n options\n );\n saveJsonToFile(exportData, file);\n updateProgressBar(`Exported ${policy._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${policy._id}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting policy sets to files`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import policy from file\n * @param {string} policyId policy id/name\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPolicyFromFile(\n policyId: string,\n file: string,\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.importPolicyFromFile: begin`);\n showSpinner(`Importing ${policyId}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importPolicy(policyId, fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${policyId}.`);\n } catch (error) {\n failSpinner(`Error importing ${policyId}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPolicyFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first policy from file\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstPolicyFromFile(\n file: string,\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: begin`);\n showSpinner(`Importing first policy from ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const policy = await importFirstPolicy(fileData, options);\n outcome = true;\n succeedSpinner(\n `Imported first policy with id '${policy._id}' from ${file}.`\n );\n } catch (error) {\n failSpinner(`Error importing first policy from ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policies from file\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPoliciesFromFile(\n file: string,\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.importPoliciesFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importPolicies(fileData, options);\n outcome = true;\n succeedSpinner(\n `Imported ${file}${\n options.policySetName\n ? ' into policy set ' + options.policySetName\n : '.'\n }`\n );\n } catch (error) {\n failSpinner(\n `Error importing ${file}${\n options.policySetName\n ? ' into policy set ' + options.policySetName\n : '.'\n }`\n );\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPoliciesFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policies from files\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPoliciesFromFiles(\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.PolicyOps.importPoliciesFromFiles: begin`);\n const names = fs.readdirSync('.');\n const files = names.filter((name) =>\n name.toLowerCase().endsWith('.policy.authz.json')\n );\n createProgressBar(files.length, 'Importing policies...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: PolicyExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.policyset).length;\n total += count;\n await importPolicies(fileData, options);\n updateProgressBar(`Imported ${count} policies from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing policies from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} policies from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing policies from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPoliciesFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAOpD,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;AAAa,CAAC,GAAGhB,KAAK,CAACiB,KAAK;AACpC,MAAM;EACJC,YAAY;EACZC,uBAAuB;EACvBC,UAAU;EACVC,YAAY;EACZC,cAAc;EACdC,yBAAyB;EACzBC,YAAY;EACZC,iBAAiB;EACjBC;AACF,CAAC,GAAG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CAAC;EAC9B;EACA/C,YAAY,CAAE,4CAA2C,CAAC;EAC1D,OAAO,CAAC,KAAK8C,MAAM,CAACE,MAAM;AAC5B"}
1
+ {"version":3,"file":"PolicyOps.js","names":["frodo","state","fs","createObjectTable","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","getRealmName","getFilePath","getWorkingDirectory","utils","readPolicies","readPoliciesByPolicySet","readPolicy","exportPolicy","exportPolicies","exportPoliciesByPolicySet","importPolicy","importFirstPolicy","importPolicies","authz","policy","listPolicies","long","outcome","policies","sort","a","b","_id","localeCompare","table","push","description","active","toString","err","message","listPoliciesByPolicySet","policySetId","describePolicy","policyId","json","policySet","deletePolicy","errors","error","length","errorMessages","map","join","deletePolicies","deletePoliciesByPolicySet","exportPolicyToFile","file","options","deps","prereqs","useStringArrays","fileName","filePath","exportData","exportPoliciesToFile","getRealm","exportPoliciesByPolicySetToFile","exportPoliciesToFiles","exportPoliciesByPolicySetToFiles","importPolicyFromFile","data","readFileSync","fileData","JSON","parse","importFirstPolicyFromFile","importPoliciesFromFile","policySetName","importPoliciesFromFiles","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","policyset"],"sources":["../../src/ops/PolicyOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type PolicySkeleton } from '@rockcarver/frodo-lib/types/api/PoliciesApi';\nimport type {\n PolicyExportInterface,\n PolicyExportOptions,\n PolicyImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/PolicyOps';\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 readPolicies,\n readPoliciesByPolicySet,\n readPolicy,\n exportPolicy,\n exportPolicies,\n exportPoliciesByPolicySet,\n importPolicy,\n importFirstPolicy,\n importPolicies,\n} = frodo.authz.policy;\n\n/**\n * List policies\n * @param {boolean} long list with details\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listPolicies(long = false): Promise<boolean> {\n let outcome = false;\n try {\n const policies = await readPolicies();\n policies.sort((a, b) => a._id.localeCompare(b._id));\n for (const policy of policies) {\n if (!long) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n if (long) {\n const table = createTable(['Id', 'Description', 'Status']);\n for (const policy of policies) {\n table.push([\n `${policy._id}`,\n `${policy.description}`,\n policy.active ? 'active'['brightGreen'] : 'inactive'['brightRed'],\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const policy of policies) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicies ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * List policies by policy set\n * @param {string} policySetId policy set id/name\n * @param {boolean} long list with details\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listPoliciesByPolicySet(\n policySetId: string,\n long = false\n): Promise<boolean> {\n let outcome = false;\n try {\n const policies = await readPoliciesByPolicySet(policySetId);\n policies.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Id', 'Description', 'Status']);\n for (const policy of policies) {\n table.push([\n `${policy._id}`,\n `${policy.description}`,\n policy.active ? 'active'['brightGreen'] : 'inactive'['brightRed'],\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const policy of policies) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicies ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Describe policy\n * @param {string} policyId policy id/name\n * @param {Object} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describePolicy(\n policyId: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n const policySet = await readPolicy(policyId);\n outcome = true;\n if (json) {\n printMessage(policySet, 'data');\n } else {\n const table = createObjectTable(policySet);\n printMessage(table.toString(), 'data');\n }\n return outcome;\n}\n\n/**\n * Delete policy\n * @param {string} policyId policy id/name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicy(policyId: string): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePolicy: begin`);\n showSpinner(`Deleting ${policyId}...`);\n let outcome = false;\n const errors = [];\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await deletePolicy(policyId);\n } catch (error) {\n printMessage(`Error deleting policy ${policyId}: ${error}`, 'error');\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n failSpinner(`Error deleting ${policyId}: ${errorMessages}`);\n } else {\n succeedSpinner(`Deleted ${policyId}.`);\n outcome = true;\n }\n debugMessage(`cli.PolicyOps.deletePolicy: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Delete all policies\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePolicies(): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePolicies: begin`);\n let outcome = false;\n const errors = [];\n let policies: PolicySkeleton[] = [];\n try {\n showSpinner(`Retrieving all policies...`);\n try {\n policies = await readPolicies();\n succeedSpinner(`Found ${policies.length} policies.`);\n } catch (error) {\n error.message = `Error retrieving all policies: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (policies.length)\n createProgressBar(\n policies.length,\n `Deleting ${policies.length} policies...`\n );\n for (const policy of policies) {\n const policyId = policy._id;\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await deletePolicy(policyId);\n updateProgressBar(`Deleted ${policyId}`);\n } catch (error) {\n error.message = `Error deleting policy ${policyId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting policies: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (policies.length)\n stopProgressBar(`Error deleting all policies: ${errorMessages}`);\n } else {\n if (policies.length)\n stopProgressBar(`Deleted ${policies.length} policies.`);\n outcome = true;\n }\n }\n debugMessage(`cli.PolicyOps.deletePolicies: end [outcome=${outcome}]`);\n return outcome;\n}\n\n/**\n * Delete all policies in policy set\n * @param {string} policySetId policy set id/name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deletePoliciesByPolicySet(\n policySetId: string\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.deletePoliciesByPolicySet: begin`);\n let outcome = false;\n const errors = [];\n let policies: PolicySkeleton[] = [];\n try {\n showSpinner(`Retrieving all policies from policy set ${policySetId}...`);\n try {\n policies = await readPoliciesByPolicySet(policySetId);\n succeedSpinner(\n `Found ${policies.length} policies in policy set ${policySetId}.`\n );\n } catch (error) {\n error.message = `Error retrieving all policies from policy set ${policySetId}: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (policies.length)\n createProgressBar(\n policies.length,\n `Deleting ${policies.length} policies from policy set ${policySetId}...`\n );\n for (const policy of policies) {\n const policyId = policy._id;\n try {\n debugMessage(`Deleting policy ${policyId}`);\n await deletePolicy(policyId);\n updateProgressBar(`Deleted ${policyId}`);\n } catch (error) {\n error.message = `Error deleting policy ${policyId} from policy set ${policySetId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting policies from policy set ${policySetId}: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (policies.length)\n stopProgressBar(\n `Error deleting all policies from policy set ${policySetId}: ${errorMessages}`\n );\n } else {\n if (policies.length)\n stopProgressBar(`Deleted ${policies.length} policies.`);\n outcome = true;\n }\n }\n debugMessage(\n `cli.PolicyOps.deletePoliciesByPolicySet: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Export policy to file\n * @param {string} policyId policy id/name\n * @param {string} file file name\n * @param {ApplicationExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPolicyToFile(\n policyId: string,\n file: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPolicyToFile: begin`);\n showSpinner(`Exporting ${policyId}...`);\n try {\n let fileName = getTypedFilename(policyId, 'policy.authz');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportPolicy(policyId, options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${policyId} to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${policyId}: ${error.message}`);\n }\n debugMessage(`cli.PolicyOps.exportPolicyToFile: end`);\n return outcome;\n}\n\n/**\n * Export policies to file\n * @param {string} file file name\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesToFile(\n file: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: begin`);\n showSpinner(`Exporting all policy sets...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}Policies`,\n 'policy.authz'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportPolicies(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.PolicyOps.exportPoliciesToFile: end`);\n return outcome;\n}\n\n/**\n * Export policies to file\n * @param {string} policySetId policy set id/name\n * @param {string} file file name\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesByPolicySetToFile(\n policySetId: string,\n file: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.exportPoliciesToFile: begin`);\n showSpinner(`Exporting all policy sets...`);\n try {\n let fileName = getTypedFilename(\n `all${\n titleCase(getRealmName(state.getRealm())) + titleCase(policySetId)\n }Policies`,\n 'policy.authz'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportPoliciesByPolicySet(policySetId, 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.PolicyOps.exportPoliciesToFile: end`);\n return outcome;\n}\n\n/**\n * Export all policies to separate files\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesToFiles(\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: begin`);\n const errors = [];\n try {\n const policies: PolicySkeleton[] = await readPolicies();\n createProgressBar(policies.length, 'Exporting policy sets...');\n for (const policy of policies) {\n const file = getTypedFilename(policy._id, 'policy.authz');\n try {\n const exportData: PolicyExportInterface = await exportPolicy(\n policy._id,\n options\n );\n saveJsonToFile(exportData, getFilePath(file, true));\n updateProgressBar(`Exported ${policy._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${policy._id}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting policy sets to files`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Export all policies to separate files\n * @param {PolicyExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportPoliciesByPolicySetToFiles(\n policySetId: string,\n options: PolicyExportOptions = {\n deps: true,\n prereqs: false,\n useStringArrays: true,\n }\n): Promise<boolean> {\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: begin`);\n const errors = [];\n try {\n const policies: PolicySkeleton[] =\n await readPoliciesByPolicySet(policySetId);\n createProgressBar(\n policies.length,\n `Exporting policies in policy set ${policySetId}...`\n );\n for (const policy of policies) {\n const file = getTypedFilename(policy._id, 'policy.authz');\n try {\n const exportData: PolicyExportInterface = await exportPolicy(\n policy._id,\n options\n );\n saveJsonToFile(exportData, getFilePath(file, true));\n updateProgressBar(`Exported ${policy._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${policy._id}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting policy sets to files`);\n }\n debugMessage(`cli.PolicyOps.exportPoliciesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import policy from file\n * @param {string} policyId policy id/name\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPolicyFromFile(\n policyId: string,\n file: string,\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.importPolicyFromFile: begin`);\n showSpinner(`Importing ${policyId}...`);\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n await importPolicy(policyId, fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${policyId}.`);\n } catch (error) {\n failSpinner(`Error importing ${policyId}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPolicyFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first policy from file\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstPolicyFromFile(\n file: string,\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: begin`);\n const filePath = getFilePath(file);\n showSpinner(`Importing first policy from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n const policy = await importFirstPolicy(fileData, options);\n outcome = true;\n succeedSpinner(\n `Imported first policy with id '${policy._id}' from ${filePath}.`\n );\n } catch (error) {\n failSpinner(`Error importing first policy from ${filePath}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policies from file\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPoliciesFromFile(\n file: string,\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.PolicyOps.importPoliciesFromFile: 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 importPolicies(fileData, options);\n outcome = true;\n succeedSpinner(\n `Imported ${filePath}${\n options.policySetName\n ? ' into policy set ' + options.policySetName\n : '.'\n }`\n );\n } catch (error) {\n failSpinner(\n `Error importing ${filePath}${\n options.policySetName\n ? ' into policy set ' + options.policySetName\n : '.'\n }`\n );\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPoliciesFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policies from files\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPoliciesFromFiles(\n options: PolicyImportOptions = { deps: true, prereqs: false }\n): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.PolicyOps.importPoliciesFromFiles: begin`);\n const names = fs.readdirSync(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.policy.authz.json'))\n .map((name) => getFilePath(name));\n createProgressBar(files.length, 'Importing policies...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: PolicyExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.policyset).length;\n total += count;\n await importPolicies(fileData, options);\n updateProgressBar(`Imported ${count} policies from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing policies from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} policies from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing policies from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicyOps.importPoliciesFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAOpD,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,YAAY;EACZC,uBAAuB;EACvBC,UAAU;EACVC,YAAY;EACZC,cAAc;EACdC,yBAAyB;EACzBC,YAAY;EACZC,iBAAiB;EACjBC;AACF,CAAC,GAAG5B,KAAK,CAAC6B,KAAK,CAACC,MAAM;;AAEtB;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAACC,IAAI,GAAG,KAAK,EAAoB;EACjE,IAAIC,OAAO,GAAG,KAAK;EACnB,IAAI;IACF,M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3C,iBAAiB,CAAE,iCAAgCmD,IAAK,EAAC,CAAC;QAC1DvD,YAAY,CAAC+C,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACA7C,eAAe,CACZ,sBAAqBmF,KAAM,kBAAiBL,KAAK,CAAChC,MAAO,SAC5D,CAAC;EACH,CAAC,CAAC,OAAOD,KAAK,EAAE;IACdD,MAAM,CAACb,IAAI,CAACc,KAAK,CAAC;IAClB7C,eAAe,CAAE,sCAAqC,CAAC;IACvDF,YAAY,CAAC+C,KAAK,EAAE,OAAO,CAAC;EAC9B;EACAjD,YAAY,CAAE,4CAA2C,CAAC;EAC1D,OAAO,CAAC,KAAKgD,MAAM,CAACE,MAAM;AAC5B"}
@@ -3,7 +3,9 @@ import fs from 'fs';
3
3
  import { createObjectTable, createProgressBar, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
4
4
  import { getTypedFilename, saveJsonToFile, titleCase } from '../utils/ExportImportUtils';
5
5
  const {
6
- getRealmName
6
+ getRealmName,
7
+ getFilePath,
8
+ getWorkingDirectory
7
9
  } = frodo.utils;
8
10
  const {
9
11
  readPoliciesByPolicySet,
@@ -179,9 +181,10 @@ export async function exportPolicySetToFile(policySetId, file, options = {
179
181
  if (file) {
180
182
  fileName = file;
181
183
  }
184
+ const filePath = getFilePath(fileName, true);
182
185
  const exportData = await exportPolicySet(policySetId, options);
183
- saveJsonToFile(exportData, fileName);
184
- succeedSpinner(`Exported ${policySetId} to ${fileName}.`);
186
+ saveJsonToFile(exportData, filePath);
187
+ succeedSpinner(`Exported ${policySetId} to ${filePath}.`);
185
188
  outcome = true;
186
189
  } catch (error) {
187
190
  failSpinner(`Error exporting ${policySetId}: ${error.message}`);
@@ -209,9 +212,10 @@ export async function exportPolicySetsToFile(file, options = {
209
212
  if (file) {
210
213
  fileName = file;
211
214
  }
215
+ const filePath = getFilePath(fileName, true);
212
216
  const exportData = await exportPolicySets(options);
213
- saveJsonToFile(exportData, fileName);
214
- succeedSpinner(`Exported all policy sets to ${fileName}.`);
217
+ saveJsonToFile(exportData, filePath);
218
+ succeedSpinner(`Exported all policy sets to ${filePath}.`);
215
219
  outcome = true;
216
220
  } catch (error) {
217
221
  failSpinner(`Error exporting policy sets: ${error.message}`);
@@ -239,7 +243,7 @@ export async function exportPolicySetsToFiles(options = {
239
243
  const file = getTypedFilename(policySet.name, 'policyset.authz');
240
244
  try {
241
245
  const exportData = await exportPolicySet(policySet.name, options);
242
- saveJsonToFile(exportData, file);
246
+ saveJsonToFile(exportData, getFilePath(file, true));
243
247
  updateProgressBar(`Exported ${policySet.name}.`);
244
248
  } catch (error) {
245
249
  errors.push(error);
@@ -270,7 +274,7 @@ export async function importPolicySetFromFile(policySetId, file, options = {
270
274
  debugMessage(`cli.PolicySetOps.importPolicySetFromFile: begin`);
271
275
  showSpinner(`Importing ${policySetId}...`);
272
276
  try {
273
- const data = fs.readFileSync(file, 'utf8');
277
+ const data = fs.readFileSync(getFilePath(file), 'utf8');
274
278
  const fileData = JSON.parse(data);
275
279
  await importPolicySet(policySetId, fileData, options);
276
280
  outcome = true;
@@ -295,15 +299,16 @@ export async function importFirstPolicySetFromFile(file, options = {
295
299
  }) {
296
300
  let outcome = false;
297
301
  debugMessage(`cli.PolicySetOps.importFirstPolicySetFromFile: begin`);
298
- showSpinner(`Importing first policy set from ${file}...`);
302
+ const filePath = getFilePath(file);
303
+ showSpinner(`Importing first policy set from ${filePath}...`);
299
304
  try {
300
- const data = fs.readFileSync(file, 'utf8');
305
+ const data = fs.readFileSync(filePath, 'utf8');
301
306
  const fileData = JSON.parse(data);
302
307
  const policySet = await importFirstPolicySet(fileData, options);
303
308
  outcome = true;
304
- succeedSpinner(`Imported first policy set with name '${policySet.name}' from ${file}.`);
309
+ succeedSpinner(`Imported first policy set with name '${policySet.name}' from ${filePath}.`);
305
310
  } catch (error) {
306
- failSpinner(`Error importing first policy set from ${file}.`);
311
+ failSpinner(`Error importing first policy set from ${filePath}.`);
307
312
  printMessage(error, 'error');
308
313
  }
309
314
  debugMessage(`cli.PolicySetOps.importFirstPolicySetFromFile: end`);
@@ -322,15 +327,16 @@ export async function importPolicySetsFromFile(file, options = {
322
327
  }) {
323
328
  let outcome = false;
324
329
  debugMessage(`cli.PolicySetOps.importPolicySetsFromFile: begin`);
325
- showSpinner(`Importing ${file}...`);
330
+ const filePath = getFilePath(file);
331
+ showSpinner(`Importing ${filePath}...`);
326
332
  try {
327
- const data = fs.readFileSync(file, 'utf8');
333
+ const data = fs.readFileSync(filePath, 'utf8');
328
334
  const fileData = JSON.parse(data);
329
335
  await importPolicySets(fileData, options);
330
336
  outcome = true;
331
- succeedSpinner(`Imported ${file}.`);
337
+ succeedSpinner(`Imported ${filePath}.`);
332
338
  } catch (error) {
333
- failSpinner(`Error importing ${file}.`);
339
+ failSpinner(`Error importing ${filePath}.`);
334
340
  printMessage(error, 'error');
335
341
  }
336
342
  debugMessage(`cli.PolicySetOps.importPolicySetsFromFile: end`);
@@ -349,8 +355,8 @@ export async function importPolicySetsFromFiles(options = {
349
355
  const errors = [];
350
356
  try {
351
357
  debugMessage(`cli.PolicySetOps.importPolicySetsFromFiles: begin`);
352
- const names = fs.readdirSync('.');
353
- const files = names.filter(name => name.toLowerCase().endsWith('.policyset.authz.json'));
358
+ const names = fs.readdirSync(getWorkingDirectory());
359
+ const files = names.filter(name => name.toLowerCase().endsWith('.policyset.authz.json')).map(name => getFilePath(name));
354
360
  createProgressBar(files.length, 'Importing policy sets...');
355
361
  let total = 0;
356
362
  for (const file of files) {
@@ -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","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","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 } = 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 exportData = await exportPolicySet(policySetId, options);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported ${policySetId} to ${fileName}.`);\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 exportData = await exportPolicySets(options);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported all policy sets to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting policy sets: ${error.message}`);\n }\n debugMessage(`cli.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, file);\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(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 showSpinner(`Importing first policy set from ${file}...`);\n try {\n const data = fs.readFileSync(file, '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 ${file}.`\n );\n } catch (error) {\n failSpinner(`Error importing first policy set from ${file}.`);\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 showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importPolicySets(fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.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('.');\n const files = names.filter((name) =>\n name.toLowerCase().endsWith('.policyset.authz.json')\n );\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,E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AAGC,MAAM,CAACC,IAAI,CAACf,QAAQ,CAACgB,SAAS,CAAC,CAACnC,MAAM;QACpD+B,KAAK,IAAIC,KAAK;QACd,MAAMvD,gBAAgB,CAAC0C,QAAQ,EAAEZ,OAAO,CAAC;QACzC9C,iBAAiB,CAAE,YAAWuE,KAAM,qBAAoB1B,IAAK,EAAC,CAAC;MACjE,CAAC,CAAC,OAAOR,KAAK,EAAE;QACdH,MAAM,CAACI,IAAI,CAACD,KAAK,CAAC;QAClBrC,iBAAiB,CAAE,oCAAmC6C,IAAK,EAAC,CAAC;QAC7DjD,YAAY,CAACyC,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACAvC,eAAe,CACZ,sBAAqBwE,KAAM,qBAAoBJ,KAAK,CAAC3B,MAAO,SAC/D,CAAC;EACH,CAAC,CAAC,OAAOF,KAAK,EAAE;IACdH,MAAM,CAACI,IAAI,CAACD,KAAK,CAAC;IAClBvC,eAAe,CAAE,yCAAwC,CAAC;IAC1DF,YAAY,CAACyC,KAAK,EAAE,OAAO,CAAC;EAC9B;EACA3C,YAAY,CAAE,iDAAgD,CAAC;EAC/D,OAAO,CAAC,KAAKwC,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","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,EAC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ACtE7B,GAAG,CAAEjB,IAAI,IAAKrB,WAAW,CAACqB,IAAI,CAAC,CAAC;IACnCjC,iBAAiB,CAAC4E,KAAK,CAAC5B,MAAM,EAAE,0BAA0B,CAAC;IAC3D,IAAIgC,KAAK,GAAG,CAAC;IACb,KAAK,MAAM1B,IAAI,IAAIsB,KAAK,EAAE;MACxB,IAAI;QACF,MAAMV,IAAI,GAAGpE,EAAE,CAACqE,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,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"}
@@ -3,7 +3,9 @@ import fs from 'fs';
3
3
  import { createObjectTable, createProgressBar, createTable, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
4
4
  import { getTypedFilename, saveJsonToFile, titleCase } from '../utils/ExportImportUtils';
5
5
  const {
6
- getRealmName
6
+ getRealmName,
7
+ getFilePath,
8
+ getWorkingDirectory
7
9
  } = frodo.utils;
8
10
  const {
9
11
  readResourceTypes,
@@ -228,9 +230,10 @@ export async function exportResourceTypeToFile(resourceTypeUuid, file) {
228
230
  if (file) {
229
231
  fileName = file;
230
232
  }
233
+ const filePath = getFilePath(fileName, true);
231
234
  const exportData = await exportResourceType(resourceTypeUuid);
232
- saveJsonToFile(exportData, fileName);
233
- succeedSpinner(`Exported ${resourceTypeUuid} to ${fileName}.`);
235
+ saveJsonToFile(exportData, filePath);
236
+ succeedSpinner(`Exported ${resourceTypeUuid} to ${filePath}.`);
234
237
  outcome = true;
235
238
  } catch (error) {
236
239
  failSpinner(`Error exporting ${resourceTypeUuid}: ${error.message}`);
@@ -254,9 +257,10 @@ export async function exportResourceTypeByNameToFile(resourceTypeName, file) {
254
257
  if (file) {
255
258
  fileName = file;
256
259
  }
260
+ const filePath = getFilePath(fileName, true);
257
261
  const exportData = await exportResourceTypeByName(resourceTypeName);
258
- saveJsonToFile(exportData, fileName);
259
- succeedSpinner(`Exported ${resourceTypeName} to ${fileName}.`);
262
+ saveJsonToFile(exportData, filePath);
263
+ succeedSpinner(`Exported ${resourceTypeName} to ${filePath}.`);
260
264
  outcome = true;
261
265
  } catch (error) {
262
266
  failSpinner(`Error exporting ${resourceTypeName}: ${error.message}`);
@@ -279,9 +283,10 @@ export async function exportResourceTypesToFile(file) {
279
283
  if (file) {
280
284
  fileName = file;
281
285
  }
286
+ const filePath = getFilePath(fileName, true);
282
287
  const exportData = await exportResourceTypes();
283
- saveJsonToFile(exportData, fileName);
284
- succeedSpinner(`Exported all resource types to ${fileName}.`);
288
+ saveJsonToFile(exportData, filePath);
289
+ succeedSpinner(`Exported all resource types to ${filePath}.`);
285
290
  outcome = true;
286
291
  } catch (error) {
287
292
  failSpinner(`Error exporting resource types: ${error.message}`);
@@ -304,7 +309,7 @@ export async function exportResourceTypesToFiles() {
304
309
  const file = getTypedFilename(resourceType.name, 'resourcetype.authz');
305
310
  try {
306
311
  const exportData = await exportResourceType(resourceType.uuid);
307
- saveJsonToFile(exportData, file);
312
+ saveJsonToFile(exportData, getFilePath(file, true));
308
313
  updateProgressBar(`Exported ${resourceType.name}.`);
309
314
  } catch (error) {
310
315
  errors.push(error);
@@ -331,7 +336,7 @@ export async function importResourceTypeFromFile(resourceTypeId, file) {
331
336
  debugMessage(`cli.ResourceTypeOps.importResourceTypeFromFile: begin`);
332
337
  showSpinner(`Importing ${resourceTypeId}...`);
333
338
  try {
334
- const data = fs.readFileSync(file, 'utf8');
339
+ const data = fs.readFileSync(getFilePath(file), 'utf8');
335
340
  const fileData = JSON.parse(data);
336
341
  await importResourceType(resourceTypeId, fileData);
337
342
  outcome = true;
@@ -355,7 +360,7 @@ export async function importResourceTypeByNameFromFile(resourceTypeName, file) {
355
360
  debugMessage(`cli.ResourceTypeOps.importResourceTypeByNameFromFile: begin`);
356
361
  showSpinner(`Importing ${resourceTypeName}...`);
357
362
  try {
358
- const data = fs.readFileSync(file, 'utf8');
363
+ const data = fs.readFileSync(getFilePath(file), 'utf8');
359
364
  const fileData = JSON.parse(data);
360
365
  await importResourceTypeByName(resourceTypeName, fileData);
361
366
  outcome = true;
@@ -376,15 +381,16 @@ export async function importResourceTypeByNameFromFile(resourceTypeName, file) {
376
381
  export async function importFirstResourceTypeFromFile(file) {
377
382
  let outcome = false;
378
383
  debugMessage(`cli.ResourceTypeOps.importFirstResourceTypeFromFile: begin`);
379
- showSpinner(`Importing ${file}...`);
384
+ const filePath = getFilePath(file);
385
+ showSpinner(`Importing ${filePath}...`);
380
386
  try {
381
- const data = fs.readFileSync(file, 'utf8');
387
+ const data = fs.readFileSync(filePath, 'utf8');
382
388
  const fileData = JSON.parse(data);
383
389
  await importFirstResourceType(fileData);
384
390
  outcome = true;
385
- succeedSpinner(`Imported ${file}.`);
391
+ succeedSpinner(`Imported ${filePath}.`);
386
392
  } catch (error) {
387
- failSpinner(`Error importing ${file}.`);
393
+ failSpinner(`Error importing ${filePath}.`);
388
394
  printMessage(error, 'error');
389
395
  }
390
396
  debugMessage(`cli.ResourceTypeOps.importFirstResourceTypeFromFile: end`);
@@ -399,15 +405,16 @@ export async function importFirstResourceTypeFromFile(file) {
399
405
  export async function importResourceTypesFromFile(file) {
400
406
  let outcome = false;
401
407
  debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFile: begin`);
402
- showSpinner(`Importing ${file}...`);
408
+ const filePath = getFilePath(file);
409
+ showSpinner(`Importing ${filePath}...`);
403
410
  try {
404
- const data = fs.readFileSync(file, 'utf8');
411
+ const data = fs.readFileSync(filePath, 'utf8');
405
412
  const fileData = JSON.parse(data);
406
413
  await importResourceTypes(fileData);
407
414
  outcome = true;
408
- succeedSpinner(`Imported ${file}.`);
415
+ succeedSpinner(`Imported ${filePath}.`);
409
416
  } catch (error) {
410
- failSpinner(`Error importing ${file}.`);
417
+ failSpinner(`Error importing ${filePath}.`);
411
418
  printMessage(error, 'error');
412
419
  }
413
420
  debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFile: end`);
@@ -422,8 +429,8 @@ export async function importResourceTypesFromFiles() {
422
429
  const errors = [];
423
430
  try {
424
431
  debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFiles: begin`);
425
- const names = fs.readdirSync('.');
426
- const files = names.filter(name => name.toLowerCase().endsWith('.resourcetype.authz.json'));
432
+ const names = fs.readdirSync(getWorkingDirectory());
433
+ const files = names.filter(name => name.toLowerCase().endsWith('.resourcetype.authz.json')).map(name => getFilePath(name));
427
434
  createProgressBar(files.length, 'Importing resource types...');
428
435
  let total = 0;
429
436
  for (const file of files) {