@rockcarver/frodo-cli 2.0.0-19 → 2.0.0-20

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.
@@ -1,6 +1,6 @@
1
1
  import { frodo, state } from '@rockcarver/frodo-lib';
2
2
  import fs from 'fs';
3
- import { createObjectTable, createProgressBar, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
3
+ import { createObjectTable, createProgressBar, createTable, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
4
4
  import { getTypedFilename, saveJsonToFile, titleCase } from '../utils/ExportImportUtils';
5
5
  const {
6
6
  getRealmName
@@ -32,6 +32,17 @@ export async function listPolicies(long = false) {
32
32
  printMessage(`${policy._id}`, 'data');
33
33
  }
34
34
  }
35
+ if (long) {
36
+ const table = createTable(['Id', 'Description', 'Status']);
37
+ for (const policy of policies) {
38
+ table.push([`${policy._id}`, `${policy.description}`, policy.active ? 'active'['brightGreen'] : 'inactive'['brightRed']]);
39
+ }
40
+ printMessage(table.toString(), 'data');
41
+ } else {
42
+ for (const policy of policies) {
43
+ printMessage(`${policy._id}`, 'data');
44
+ }
45
+ }
35
46
  outcome = true;
36
47
  } catch (err) {
37
48
  printMessage(`listPolicies ERROR: ${err.message}`, 'error');
@@ -51,8 +62,14 @@ export async function listPoliciesByPolicySet(policySetId, long = false) {
51
62
  try {
52
63
  const policies = await readPoliciesByPolicySet(policySetId);
53
64
  policies.sort((a, b) => a._id.localeCompare(b._id));
54
- for (const policy of policies) {
55
- if (!long) {
65
+ if (long) {
66
+ const table = createTable(['Id', 'Description', 'Status']);
67
+ for (const policy of policies) {
68
+ table.push([`${policy._id}`, `${policy.description}`, policy.active ? 'active'['brightGreen'] : 'inactive'['brightRed']]);
69
+ }
70
+ printMessage(table.toString(), 'data');
71
+ } else {
72
+ for (const policy of policies) {
56
73
  printMessage(`${policy._id}`, 'data');
57
74
  }
58
75
  }
@@ -409,15 +426,15 @@ export async function importFirstPolicyFromFile(file, options = {
409
426
  }) {
410
427
  let outcome = false;
411
428
  debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: begin`);
412
- showSpinner(`Importing ${file}...`);
429
+ showSpinner(`Importing first policy from ${file}...`);
413
430
  try {
414
431
  const data = fs.readFileSync(file, 'utf8');
415
432
  const fileData = JSON.parse(data);
416
- await importFirstPolicy(fileData, options);
433
+ const policy = await importFirstPolicy(fileData, options);
417
434
  outcome = true;
418
- succeedSpinner(`Imported ${file}.`);
435
+ succeedSpinner(`Imported first policy with id '${policy._id}' from ${file}.`);
419
436
  } catch (error) {
420
- failSpinner(`Error importing ${file}.`);
437
+ failSpinner(`Error importing first policy from ${file}.`);
421
438
  printMessage(error, 'error');
422
439
  }
423
440
  debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: end`);
@@ -1 +1 @@
1
- {"version":3,"file":"PolicyOps.js","names":["frodo","state","fs","createObjectTable","createProgressBar","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","err","message","listPoliciesByPolicySet","policySetId","describePolicy","policyId","json","policySet","table","toString","deletePolicy","errors","error","length","errorMessages","map","join","deletePolicies","push","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 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 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 for (const policy of policies) {\n if (!long) {\n printMessage(`${policy._id}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listPolicies ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Describe policy\n * @param {string} policyId policy id/name\n * @param {Object} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describePolicy(\n policyId: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n const policySet = await 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 ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstPolicy(fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: end`);\n return outcome;\n}\n\n/**\n * Import policies from file\n * @param {string} file file name\n * @param {PolicyImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importPoliciesFromFile(\n file: string,\n options: PolicyImportOptions = { deps: true, 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,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,GAAGf,KAAK,CAACgB,KAAK;AACpC,MAAM;EACJC,YAAY;EACZC,uBAAuB;EACvBC,UAAU;EACVC,YAAY;EACZC,cAAc;EACdC,yBAAyB;EACzBC,YAAY;EACZC,iBAAiB;EACjBC;AACF,CAAC,GAAGzB,KAAK,CAAC0B,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,MAAMC,QAAQ,GAAG,MAAMd,YAAY,CAAC,CAAC;IACrCc,QAAQ,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IACnD,KAAK,MAAMR,MAAM,IAAII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AAC,CAAC,CAACC,QAAQ,CAAC,oBAAoB,CAClD,CAAC;IACDlF,iBAAiB,CAAC8E,KAAK,CAAChC,MAAM,EAAE,uBAAuB,CAAC;IACxD,IAAIqC,KAAK,GAAG,CAAC;IACb,KAAK,MAAM7B,IAAI,IAAIwB,KAAK,EAAE;MACxB,IAAI;QACF,MAAMX,IAAI,GAAGrE,EAAE,CAACsE,YAAY,CAACd,IAAI,EAAE,MAAM,CAAC;QAC1C,MAAMe,QAA+B,GAAGC,IAAI,CAACC,KAAK,CAACJ,IAAI,CAAC;QACxD,MAAMiB,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACjB,QAAQ,CAACkB,SAAS,CAAC,CAACzC,MAAM;QACpDqC,KAAK,IAAIC,KAAK;QACd,MAAM/D,cAAc,CAACgD,QAAQ,EAAEd,OAAO,CAAC;QACvChD,iBAAiB,CAAE,YAAW6E,KAAM,kBAAiB9B,IAAK,EAAC,CAAC;MAC9D,CAAC,CAAC,OAAOT,KAAK,EAAE;QACdD,MAAM,CAACO,IAAI,CAACN,KAAK,CAAC;QAClBtC,iBAAiB,CAAE,iCAAgC+C,IAAK,EAAC,CAAC;QAC1DnD,YAAY,CAAC0C,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACAxC,eAAe,CACZ,sBAAqB8E,KAAM,kBAAiBL,KAAK,CAAChC,MAAO,SAC5D,CAAC;EACH,CAAC,CAAC,OAAOD,KAAK,EAAE;IACdD,MAAM,CAACO,IAAI,CAACN,KAAK,CAAC;IAClBxC,eAAe,CAAE,sCAAqC,CAAC;IACvDF,YAAY,CAAC0C,KAAK,EAAE,OAAO,CAAC;EAC9B;EACA5C,YAAY,CAAE,4CAA2C,CAAC;EAC1D,OAAO,CAAC,KAAK2C,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","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,GAAG1B,KAAK,CAAC2B,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,MAAMC,QAAQ,GAAG,MAAMd,YAAY,CAAC,CAAC;IACrCc,QAAQ,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IACnD,KAAK,MAAMR,MAAM,IAAII,QAAQ,EAAE;MAC7B,IAAI,CAACF,IAAI,EAAE;QACTtB,YAAY,CAAE,GAAEoB,MAAM,CAACQ,GAAI,EAAC,EAAE,MAAM,CAAC;MACvC;IACF;IACA,IAAIN,IAAI,EAAE;MACR,MAAMQ,KAAK,GAAGjC,WAAW,CAAC,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;MAC1D,KAAK,MAAMuB,MA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S,CAAC,CAACxC,MAAM;QACpDoC,KAAK,IAAIC,KAAK;QACd,MAAMjE,cAAc,CAACkD,QAAQ,EAAEd,OAAO,CAAC;QACvClD,iBAAiB,CAAE,YAAW+E,KAAM,kBAAiB9B,IAAK,EAAC,CAAC;MAC9D,CAAC,CAAC,OAAOR,KAAK,EAAE;QACdD,MAAM,CAACb,IAAI,CAACc,KAAK,CAAC;QAClBzC,iBAAiB,CAAE,iCAAgCiD,IAAK,EAAC,CAAC;QAC1DrD,YAAY,CAAC6C,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACA3C,eAAe,CACZ,sBAAqBgF,KAAM,kBAAiBL,KAAK,CAAC/B,MAAO,SAC5D,CAAC;EACH,CAAC,CAAC,OAAOD,KAAK,EAAE;IACdD,MAAM,CAACb,IAAI,CAACc,KAAK,CAAC;IAClB3C,eAAe,CAAE,sCAAqC,CAAC;IACvDF,YAAY,CAAC6C,KAAK,EAAE,OAAO,CAAC;EAC9B;EACA/C,YAAY,CAAE,4CAA2C,CAAC;EAC1D,OAAO,CAAC,KAAK8C,MAAM,CAACE,MAAM;AAC5B"}
@@ -295,15 +295,15 @@ export async function importFirstPolicySetFromFile(file, options = {
295
295
  }) {
296
296
  let outcome = false;
297
297
  debugMessage(`cli.PolicySetOps.importFirstPolicySetFromFile: begin`);
298
- showSpinner(`Importing ${file}...`);
298
+ showSpinner(`Importing first policy set from ${file}...`);
299
299
  try {
300
300
  const data = fs.readFileSync(file, 'utf8');
301
301
  const fileData = JSON.parse(data);
302
- await importFirstPolicySet(fileData, options);
302
+ const policySet = await importFirstPolicySet(fileData, options);
303
303
  outcome = true;
304
- succeedSpinner(`Imported ${file}.`);
304
+ succeedSpinner(`Imported first policy set with name '${policySet.name}' from ${file}.`);
305
305
  } catch (error) {
306
- failSpinner(`Error importing ${file}.`);
306
+ failSpinner(`Error importing first policy set from ${file}.`);
307
307
  printMessage(error, 'error');
308
308
  }
309
309
  debugMessage(`cli.PolicySetOps.importFirstPolicySetFromFile: end`);
@@ -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 ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstPolicySet(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.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,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;AAAa,CAAC,GAAGf,KAAK,CAACgB,KAAK;AACpC,MAAM;EAAEC,uBAAuB;EAAEC;AAAa,CAAC,GAAGlB,KAAK,CAACmB,KAAK,CAACC,MAAM;AACpE,MAAM;EACJC,cAAc;EACdC,aAAa;EACbC,eAAe;EACfC,gBAAgB;EAChBC,eAAe;EACfC,oBAAoB;EACpBC;AACF,CAAC,GAAG3B,KAAK,CAACmB,KAAK,CAACS,SAAS;;AAEzB;AACA;AACA;AACA;AACA,OAAO,eAAeC,cAAcA,CAAA,EAAqB;EACvD,IAAIC,OAAO,GAAG,KAAK;EACnB,IAAI;IACF,MAAMC,UAAU,GAAG,MAAMV,cAAc,CAAC,CAAC;IACzCU,UAAU,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,IAAI,CAACC,aAAa,CAACF,CAAC,CAACC,IAAI,CAAC,CAAC;IACvD,KAAK,MAAMP,SAAS,IAAIG,UAAU,EAAE;MAClCxB,YAAY,CAAE,GAAEqB,SAAS,CAACO,IAAK,EAAC,EAAE,MAAM,CAAC;IAC3C;IACAL,OAAO,GAAG,IAAI;EAChB,CAAC,CAAC,OAAOO,GAAG,EAAE;IACZ9B,YAAY,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B,KAAK,EAAE;MACxB,IAAI;QACF,MAAMV,IAAI,GAAGjE,EAAE,CAACkE,YAAY,CAACZ,IAAI,EAAE,MAAM,CAAC;QAC1C,MAAMa,QAAkC,GAAGC,IAAI,CAACC,KAAK,CAACJ,IAAI,CAAC;QAC3D,MAAMe,KAAK,GAAGC,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","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,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAi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,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"}
@@ -32,7 +32,7 @@ export async function listServices(long = false, globalConfig = false) {
32
32
  if (long) {
33
33
  const table = createTable(['Service Id', 'Service Name']);
34
34
  for (const service of services) {
35
- table.push([service._id, service.name]);
35
+ table.push([service._id, globalConfig ? service['_type'].name : service.name]);
36
36
  }
37
37
  printMessage(table.toString(), 'data');
38
38
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceOps.js","names":["frodo","state","fs","createTable","debugMessage","failSpinner","printMessage","showSpinner","succeedSpinner","getRealmName","utils","getTypedFilename","titleCase","saveJsonToFile","getWorkingDirectory","getListOfServices","exportServices","exportService","getFullServices","createServiceExportTemplate","importService","importServices","deleteFullService","deleteFullServices","service","listServices","long","globalConfig","services","sort","a","b","_id","localeCompare","table","push","name","toString","error","stack","exportServicesToFile","file","exportData","fileName","getRealm","exportServiceToFile","serviceId","exportServicesToFiles","_type","importServiceFromFile","clean","verbose","getVerbose","readFile","err","data","importData","JSON","parse","importError","_importError$response","_importError$response2","message","response","detail","importFirstServiceFromFile","Object","keys","length","_importError$response3","_importError$response4","importServicesFromFile","status","importServicesFromFiles","names","readdirSync","agentFiles","filter","toLowerCase","endsWith","deleteService","_error$response","deleteServices"],"sources":["../../src/ops/ServiceOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type ServiceExportInterface } from '@rockcarver/frodo-lib/types/ops/ServiceOps';\nimport fs from 'fs';\n\nimport {\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n succeedSpinner,\n} from '../utils/Console';\n\nconst { getRealmName } = frodo.utils;\nconst { getTypedFilename, titleCase, saveJsonToFile, getWorkingDirectory } =\n frodo.utils;\nconst {\n getListOfServices,\n exportServices,\n exportService,\n getFullServices,\n createServiceExportTemplate,\n importService,\n importServices,\n deleteFullService,\n deleteFullServices,\n} = frodo.service;\n\n/**\n * List services\n */\nexport async function listServices(long = false, globalConfig = false) {\n try {\n const services = await getListOfServices(globalConfig);\n services.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Service Id', 'Service Name']);\n for (const service of services) {\n table.push([service._id, service.name]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const service of services) {\n printMessage(`${service._id}`, 'data');\n }\n }\n } catch (error) {\n printMessage(`Error listing agents - ${error}`, 'error');\n printMessage(error.stack, 'error');\n }\n}\n\n/**\n * Export all services to file\n * @param {string} file file name\n */\nexport async function exportServicesToFile(file, globalConfig = false) {\n const exportData = await exportServices(globalConfig);\n let fileName = getTypedFilename(\n `all${\n globalConfig ? 'Global' : titleCase(getRealmName(state.getRealm()))\n }Services`,\n `service`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, fileName);\n}\n\n/**\n * Export service to file\n * @param {string} serviceId service id\n * @param {string} file file name\n */\nexport async function exportServiceToFile(\n serviceId: string,\n file: string,\n globalConfig = false\n) {\n const exportData = await exportService(serviceId, globalConfig);\n let fileName = getTypedFilename(serviceId, `service`);\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, fileName);\n}\n\n/**\n * Export all services to separate files\n */\nexport async function exportServicesToFiles(globalConfig = false) {\n debugMessage(`cli.ServiceOps.exportServicesToFiles: start`);\n const services = await getFullServices(globalConfig);\n for (const service of services) {\n const fileName = getTypedFilename(service._type._id, `service`);\n const exportData = createServiceExportTemplate();\n exportData.service[service._type._id] = service;\n debugMessage(\n `cli.ServiceOps.exportServicesToFiles: exporting ${service._type._id} to ${fileName}`\n );\n saveJsonToFile(exportData, fileName);\n }\n debugMessage(`cli.ServiceOps.exportServicesToFiles: end.`);\n}\n\n/**\n * Import a service from file\n * @param {string} serviceId service id/name\n * @param {string} file import file name\n * @param {boolean} clean remove existing service\n */\nexport async function importServiceFromFile(\n serviceId: string,\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: start [serviceId=${serviceId}, file=${file}]`\n );\n const verbose = state.getVerbose();\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && importData.service[serviceId]) {\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, clean, globalConfig);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${serviceId} not found!`);\n }\n });\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: end [serviceId=${serviceId}, file=${file}]`\n );\n}\n\n/**\n * Import first service from file\n * @param {string} file import file name\n * @param {boolean} clean remove existing service\n */\nexport async function importFirstServiceFromFile(\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: start [file=${file}]`\n );\n const verbose = state.getVerbose();\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && Object.keys(importData.service).length) {\n const serviceId = Object.keys(importData.service)[0];\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, clean, globalConfig);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing service...`);\n failSpinner(`No service found in ${file}!`);\n }\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: end [file=${file}]`\n );\n });\n}\n\n/**\n * Import services from file\n * @param {String} file file name\n * @param {boolean} clean remove existing service\n */\nexport async function importServicesFromFile(\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(`cli.ServiceOps.importServiceFromFile: start [file=${file}]`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n debugMessage(`cli.ServiceOps.importServiceFromFile: importing ${file}`);\n const importData = JSON.parse(data) as ServiceExportInterface;\n try {\n await importServices(importData, clean, globalConfig);\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n printMessage(error.response.status, 'error');\n }\n debugMessage(`cli.ServiceOps.importServiceFromFile: end [file=${file}]`);\n });\n}\n\n/**\n * Import all services from separate files\n * @param {boolean} clean remove existing service\n */\nexport async function importServicesFromFiles(\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(`cli.ServiceOps.importServicesFromFiles: start`);\n const names = fs.readdirSync(getWorkingDirectory());\n const agentFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.service.json')\n );\n for (const file of agentFiles) {\n await importServicesFromFile(file, clean, globalConfig);\n }\n debugMessage(`cli.ServiceOps.importServicesFromFiles: end`);\n}\n\n/**\n * Delete a service by id/name\n * @param {string} serviceId Reference to the service to delete\n */\nexport async function deleteService(serviceId: string, globalConfig = false) {\n try {\n await deleteFullService(serviceId, globalConfig);\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(`Delete service '${serviceId}': ${message}`, 'error');\n }\n}\n\n/**\n * Delete all services\n */\nexport async function deleteServices(globalConfig = false) {\n await deleteFullServices(globalConfig);\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAEpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,cAAc,QACT,kBAAkB;AAEzB,MAAM;EAAEC;AAAa,CAAC,GAAGT,KAAK,CAACU,KAAK;AACpC,MAAM;EAAEC,gBAAgB;EAAEC,SAAS;EAAEC,cAAc;EAAEC;AAAoB,CAAC,GACxEd,KAAK,CAACU,KAAK;AACb,MAAM;EACJK,iBAAiB;EACjBC,cAAc;EACdC,aAAa;EACbC,eAAe;EACfC,2BAA2B;EAC3BC,aAAa;EACbC,cAAc;EACdC,iBAAiB;EACjBC;AACF,CAAC,GAAGvB,KAAK,CAACwB,OAAO;;AAEjB;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAACC,IAAI,GAAG,KAAK,EAAEC,YAAY,GAAG,KAAK,EAAE;EACrE,IAAI;IACF,MAAMC,QAAQ,GAAG,MAAMb,iBAAiB,CAACY,YAAY,CAAC;IACtDC,QAAQ,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IACnD,IAAIN,IAAI,EAAE;MACR,MAAMQ,KAAK,GAAG/B,WAAW,CAAC,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;MACzD,KAAK,MAA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ACnCA,IAAI,CAAC0C,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,eAAe,CAC7C,CAAC;EACD,KAAK,MAAMtC,IAAI,IAAImC,UAAU,EAAE;IAC7B,MAAML,sBAAsB,CAAC9B,IAAI,EAAES,KAAK,EAAEvB,YAAY,CAAC;EACzD;EACAvB,YAAY,CAAE,6CAA4C,CAAC;AAC7D;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAe4E,aAAaA,CAAClC,SAAiB,EAAEnB,YAAY,GAAG,KAAK,EAAE;EAC3E,IAAI;IACF,MAAML,iBAAiB,CAACwB,SAAS,EAAEnB,YAAY,CAAC;EAClD,CAAC,CAAC,OAAOW,KAAK,EAAE;IAAA,IAAA2C,eAAA;IACd,MAAMnB,OAAO,IAAAmB,eAAA,GAAG3C,KAAK,CAACyB,QAAQ,cAAAkB,eAAA,gBAAAA,eAAA,GAAdA,eAAA,CAAgB1B,IAAI,cAAA0B,eAAA,uBAApBA,eAAA,CAAsBnB,OAAO;IAC7CxD,YAAY,CAAE,mBAAkBwC,SAAU,MAAKgB,OAAQ,EAAC,EAAE,OAAO,CAAC;EACpE;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeoB,cAAcA,CAACvD,YAAY,GAAG,KAAK,EAAE;EACzD,MAAMJ,kBAAkB,CAACI,YAAY,CAAC;AACxC"}
1
+ {"version":3,"file":"ServiceOps.js","names":["frodo","state","fs","createTable","debugMessage","failSpinner","printMessage","showSpinner","succeedSpinner","getRealmName","utils","getTypedFilename","titleCase","saveJsonToFile","getWorkingDirectory","getListOfServices","exportServices","exportService","getFullServices","createServiceExportTemplate","importService","importServices","deleteFullService","deleteFullServices","service","listServices","long","globalConfig","services","sort","a","b","_id","localeCompare","table","push","name","toString","error","stack","exportServicesToFile","file","exportData","fileName","getRealm","exportServiceToFile","serviceId","exportServicesToFiles","_type","importServiceFromFile","clean","verbose","getVerbose","readFile","err","data","importData","JSON","parse","importError","_importError$response","_importError$response2","message","response","detail","importFirstServiceFromFile","Object","keys","length","_importError$response3","_importError$response4","importServicesFromFile","status","importServicesFromFiles","names","readdirSync","agentFiles","filter","toLowerCase","endsWith","deleteService","_error$response","deleteServices"],"sources":["../../src/ops/ServiceOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type ServiceExportInterface } from '@rockcarver/frodo-lib/types/ops/ServiceOps';\nimport fs from 'fs';\n\nimport {\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n succeedSpinner,\n} from '../utils/Console';\n\nconst { getRealmName } = frodo.utils;\nconst { getTypedFilename, titleCase, saveJsonToFile, getWorkingDirectory } =\n frodo.utils;\nconst {\n getListOfServices,\n exportServices,\n exportService,\n getFullServices,\n createServiceExportTemplate,\n importService,\n importServices,\n deleteFullService,\n deleteFullServices,\n} = frodo.service;\n\n/**\n * List services\n */\nexport async function listServices(long = false, globalConfig = false) {\n try {\n const services = await getListOfServices(globalConfig);\n services.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Service Id', 'Service Name']);\n for (const service of services) {\n table.push([\n service._id,\n globalConfig ? service['_type'].name : service.name,\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const service of services) {\n printMessage(`${service._id}`, 'data');\n }\n }\n } catch (error) {\n printMessage(`Error listing agents - ${error}`, 'error');\n printMessage(error.stack, 'error');\n }\n}\n\n/**\n * Export all services to file\n * @param {string} file file name\n */\nexport async function exportServicesToFile(file, globalConfig = false) {\n const exportData = await exportServices(globalConfig);\n let fileName = getTypedFilename(\n `all${\n globalConfig ? 'Global' : titleCase(getRealmName(state.getRealm()))\n }Services`,\n `service`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, fileName);\n}\n\n/**\n * Export service to file\n * @param {string} serviceId service id\n * @param {string} file file name\n */\nexport async function exportServiceToFile(\n serviceId: string,\n file: string,\n globalConfig = false\n) {\n const exportData = await exportService(serviceId, globalConfig);\n let fileName = getTypedFilename(serviceId, `service`);\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, fileName);\n}\n\n/**\n * Export all services to separate files\n */\nexport async function exportServicesToFiles(globalConfig = false) {\n debugMessage(`cli.ServiceOps.exportServicesToFiles: start`);\n const services = await getFullServices(globalConfig);\n for (const service of services) {\n const fileName = getTypedFilename(service._type._id, `service`);\n const exportData = createServiceExportTemplate();\n exportData.service[service._type._id] = service;\n debugMessage(\n `cli.ServiceOps.exportServicesToFiles: exporting ${service._type._id} to ${fileName}`\n );\n saveJsonToFile(exportData, fileName);\n }\n debugMessage(`cli.ServiceOps.exportServicesToFiles: end.`);\n}\n\n/**\n * Import a service from file\n * @param {string} serviceId service id/name\n * @param {string} file import file name\n * @param {boolean} clean remove existing service\n */\nexport async function importServiceFromFile(\n serviceId: string,\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: start [serviceId=${serviceId}, file=${file}]`\n );\n const verbose = state.getVerbose();\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && importData.service[serviceId]) {\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, clean, globalConfig);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${serviceId} not found!`);\n }\n });\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: end [serviceId=${serviceId}, file=${file}]`\n );\n}\n\n/**\n * Import first service from file\n * @param {string} file import file name\n * @param {boolean} clean remove existing service\n */\nexport async function importFirstServiceFromFile(\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: start [file=${file}]`\n );\n const verbose = state.getVerbose();\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && Object.keys(importData.service).length) {\n const serviceId = Object.keys(importData.service)[0];\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, clean, globalConfig);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing service...`);\n failSpinner(`No service found in ${file}!`);\n }\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: end [file=${file}]`\n );\n });\n}\n\n/**\n * Import services from file\n * @param {String} file file name\n * @param {boolean} clean remove existing service\n */\nexport async function importServicesFromFile(\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(`cli.ServiceOps.importServiceFromFile: start [file=${file}]`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n debugMessage(`cli.ServiceOps.importServiceFromFile: importing ${file}`);\n const importData = JSON.parse(data) as ServiceExportInterface;\n try {\n await importServices(importData, clean, globalConfig);\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n printMessage(error.response.status, 'error');\n }\n debugMessage(`cli.ServiceOps.importServiceFromFile: end [file=${file}]`);\n });\n}\n\n/**\n * Import all services from separate files\n * @param {boolean} clean remove existing service\n */\nexport async function importServicesFromFiles(\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(`cli.ServiceOps.importServicesFromFiles: start`);\n const names = fs.readdirSync(getWorkingDirectory());\n const agentFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.service.json')\n );\n for (const file of agentFiles) {\n await importServicesFromFile(file, clean, globalConfig);\n }\n debugMessage(`cli.ServiceOps.importServicesFromFiles: end`);\n}\n\n/**\n * Delete a service by id/name\n * @param {string} serviceId Reference to the service to delete\n */\nexport async function deleteService(serviceId: string, globalConfig = false) {\n try {\n await deleteFullService(serviceId, globalConfig);\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(`Delete service '${serviceId}': ${message}`, 'error');\n }\n}\n\n/**\n * Delete all services\n */\nexport async function deleteServices(globalConfig = false) {\n await deleteFullServices(globalConfig);\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAEpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,cAAc,QACT,kBAAkB;AAEzB,MAAM;EAAEC;AAAa,CAAC,GAAGT,KAAK,CAACU,KAAK;AACpC,MAAM;EAAEC,gBAAgB;EAAEC,SAAS;EAAEC,cAAc;EAAEC;AAAoB,CAAC,GACxEd,KAAK,CAACU,KAAK;AACb,MAAM;EACJK,iBAAiB;EACjBC,cAAc;EACdC,aAAa;EACbC,eAAe;EACfC,2BAA2B;EAC3BC,aAAa;EACbC,cAAc;EACdC,iBAAiB;EACjBC;AACF,CAAC,GAAGvB,KAAK,CAACwB,OAAO;;AAEjB;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAACC,IAAI,GAAG,KAAK,EAAEC,YAAY,GAAG,KAAK,EAAE;EACrE,IAAI;IACF,MAAMC,QAAQ,GAAG,MAAMb,iBAAiB,CAACY,YAAY,CAAC;IACtDC,QAAQ,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IACnD,IAAIN,IAAI,EAAE;MACR,MAAMQ,KAAK,GAAG/B,WAAW,CAAC,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;MACzD,KAAK,MAAMqB,OAAO,IAAII,QAAQ,EAAE;QAC9BM,KAAK,CAACC,IAAI,CAAC,CACTX,OAAO,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0C,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,eAAe,CAC7C,CAAC;EACD,KAAK,MAAMtC,IAAI,IAAImC,UAAU,EAAE;IAC7B,MAAML,sBAAsB,CAAC9B,IAAI,EAAES,KAAK,EAAEvB,YAAY,CAAC;EACzD;EACAvB,YAAY,CAAE,6CAA4C,CAAC;AAC7D;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAe4E,aAAaA,CAAClC,SAAiB,EAAEnB,YAAY,GAAG,KAAK,EAAE;EAC3E,IAAI;IACF,MAAML,iBAAiB,CAACwB,SAAS,EAAEnB,YAAY,CAAC;EAClD,CAAC,CAAC,OAAOW,KAAK,EAAE;IAAA,IAAA2C,eAAA;IACd,MAAMnB,OAAO,IAAAmB,eAAA,GAAG3C,KAAK,CAACyB,QAAQ,cAAAkB,eAAA,gBAAAA,eAAA,GAAdA,eAAA,CAAgB1B,IAAI,cAAA0B,eAAA,uBAApBA,eAAA,CAAsBnB,OAAO;IAC7CxD,YAAY,CAAE,mBAAkBwC,SAAU,MAAKgB,OAAQ,EAAC,EAAE,OAAO,CAAC;EACpE;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeoB,cAAcA,CAACvD,YAAY,GAAG,KAAK,EAAE;EACzD,MAAMJ,kBAAkB,CAACI,YAAY,CAAC;AACxC"}
@@ -1,5 +1,6 @@
1
1
  import { frodo } from '@rockcarver/frodo-lib';
2
2
  import fs from 'fs';
3
+ import { v4 as uuidv4 } from 'uuid';
3
4
  import { createProgressIndicator, createTable, printMessage, stopProgressIndicator, updateProgressIndicator } from '../utils/Console';
4
5
  import { getTypedFilename, saveToFile } from '../utils/ExportImportUtils';
5
6
  const {
@@ -82,6 +83,7 @@ export async function exportThemeByName(name, file) {
82
83
  createProgressIndicator('determinate', 1, `Exporting ${name}`);
83
84
  try {
84
85
  const themeData = await readThemeByName(name);
86
+ if (!themeData._id) themeData._id = uuidv4();
85
87
  updateProgressIndicator(`Writing file ${fileName}`);
86
88
  saveToFile('theme', [themeData], '_id', fileName);
87
89
  stopProgressIndicator(`Successfully exported theme ${name}.`);
@@ -125,6 +127,7 @@ export async function exportThemesToFile(file) {
125
127
  const allThemesData = await readThemes();
126
128
  createProgressIndicator('determinate', allThemesData.length, 'Exporting themes');
127
129
  for (const themeData of allThemesData) {
130
+ if (!themeData._id) themeData._id = uuidv4();
128
131
  updateProgressIndicator(`Exporting theme ${themeData.name}`);
129
132
  }
130
133
  saveToFile('theme', allThemesData, '_id', fileName);
@@ -138,6 +141,7 @@ export async function exportThemesToFiles() {
138
141
  const allThemesData = await readThemes();
139
142
  createProgressIndicator('determinate', allThemesData.length, 'Exporting themes');
140
143
  for (const themeData of allThemesData) {
144
+ if (!themeData._id) themeData._id = uuidv4();
141
145
  updateProgressIndicator(`Writing theme ${themeData.name}`);
142
146
  const fileName = getTypedFilename(themeData.name, 'theme');
143
147
  saveToFile('theme', themeData, '_id', fileName);