@rockcarver/frodo-cli 2.0.0-21 → 2.0.0-23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/esm/cli/FrodoCommand.js +3 -1
- package/esm/cli/FrodoCommand.js.map +1 -1
- package/esm/cli/agent/agent-web.js +2 -2
- package/esm/cli/agent/agent-web.js.map +1 -1
- package/esm/cli/app/app-import.js +1 -1
- package/esm/cli/app/app-import.js.map +1 -1
- package/esm/cli/idm/idm-export.js +14 -8
- package/esm/cli/idm/idm-export.js.map +1 -1
- package/esm/cli/idm/idm-import.js +14 -8
- package/esm/cli/idm/idm-import.js.map +1 -1
- package/esm/cli/journey/journey-export.js +2 -3
- package/esm/cli/journey/journey-export.js.map +1 -1
- package/esm/cli/oauth/oauth-client-import.js +1 -1
- package/esm/cli/oauth/oauth-client-import.js.map +1 -1
- package/esm/cli/service/service-import.js +2 -3
- package/esm/cli/service/service-import.js.map +1 -1
- package/esm/ops/AdminFederationOps.js +29 -20
- package/esm/ops/AdminFederationOps.js.map +1 -1
- package/esm/ops/AgentOps.js +41 -34
- package/esm/ops/AgentOps.js.map +1 -1
- package/esm/ops/ApplicationOps.js +23 -17
- package/esm/ops/ApplicationOps.js.map +1 -1
- package/esm/ops/CirclesOfTrustOps.js +27 -20
- package/esm/ops/CirclesOfTrustOps.js.map +1 -1
- package/esm/ops/EmailTemplateOps.js +19 -14
- package/esm/ops/EmailTemplateOps.js.map +1 -1
- package/esm/ops/IdmOps.js +14 -22
- package/esm/ops/IdmOps.js.map +1 -1
- package/esm/ops/IdpOps.js +27 -19
- package/esm/ops/IdpOps.js.map +1 -1
- package/esm/ops/JourneyOps.js +18 -51
- package/esm/ops/JourneyOps.js.map +1 -1
- package/esm/ops/OAuth2ClientOps.js +23 -17
- package/esm/ops/OAuth2ClientOps.js.map +1 -1
- package/esm/ops/PolicyOps.js +27 -20
- package/esm/ops/PolicyOps.js.map +1 -1
- package/esm/ops/PolicySetOps.js +23 -17
- package/esm/ops/PolicySetOps.js.map +1 -1
- package/esm/ops/ResourceTypeOps.js +27 -20
- package/esm/ops/ResourceTypeOps.js.map +1 -1
- package/esm/ops/Saml2Ops.js +22 -14
- package/esm/ops/Saml2Ops.js.map +1 -1
- package/esm/ops/ScriptOps.js +22 -15
- package/esm/ops/ScriptOps.js.map +1 -1
- package/esm/ops/ServiceOps.js +21 -16
- package/esm/ops/ServiceOps.js.map +1 -1
- package/esm/ops/ThemeOps.js +21 -15
- package/esm/ops/ThemeOps.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JourneyOps.js","names":["frodo","state","fs","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","CirclesOfTrust","EmailTemplate","Idp","Node","Saml2","Script","Theme","cloneDeep","wordwrap","getTypedFilename","saveJsonToFile","getRealmString","utils","readJourneys","exportJourney","createMultiTreeExportTemplate","resolveDependencies","importJourneys","importJourney","getTreeDescendents","getNodeRef","onlineTreeExportResolver","getJourneyClassification","_getJourneyClassification","authn","journey","listJourneys","long","analyze","journeys","journeyStub","table","_journeyStub$uiConfig","push","_id","enabled","uiConfig","categories","JSON","parse","join","toString","exportPromises","useStringArrays","deps","journeyExports","Promise","all","journeyExport","_journeyExport$tree$u","tree","error","response","data","_error$response","exportJourneyToFile","journeyId","file","options","verbose","getDebug","getDirectory","dir","replace","existsSync","mkdirSync","recursive","fileData","exportJourneysToFile","fileName","trees","length","exportData","meta","exportJourneysToFiles","undefined","importJourneyFromFile","readFile","err","journeyData","installedJourneys","map","x","unresolvedJourneys","resolvedJourneys","Object","keys","then","catch","importError","importFirstJourneyFromFile","treeId","hasOwnProperty","call","importJourneysFromFile","name","message","type","importJourneysFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","allJourneysData","readFileSync","_error$response2","it","getJourneyClassificationMd","getOneLineDescription","treeObj","description","getOneLineDescriptionMd","describeTreeDescendents","descendents","depth","values","indent","Array","fill","descendent","describeTreeDescendentsMd","markdown","describeJourney","resolveTreeExport","_journeyData$meta","_journeyData$tree$uiC","_journeyData$themes","allNodes","nodes","innerNodes","nodeTypeMap","nodeData","_type","getAmVersion","originAmVersion","setAmVersion","stack","entries","nodeType","count","String","getNodeClassification","nodeObj","themes","themeData","scripts","scriptData","emailTemplates","templateData","socialIdentityProviders","socialIdpData","saml2Entities","entityProviderData","circlesOfTrust","cotData","describeJourneyMd","_journeyData$meta2","_journeyData$tree$uiC2","_journeyData$themes2","getNodeClassificationMd","getTableHeaderMd","getTableRowMd"],"sources":["../../src/ops/JourneyOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type NodeSkeleton } from '@rockcarver/frodo-lib/types/api/NodeApi';\nimport { type TreeSkeleton } from '@rockcarver/frodo-lib/types/api/TreeApi';\nimport {\n type JourneyClassificationType,\n type MultiTreeExportInterface,\n type SingleTreeExportInterface,\n type TreeDependencyMapInterface,\n type TreeExportOptions,\n type TreeExportResolverInterface,\n type TreeImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/JourneyOps';\nimport fs from 'fs';\n\nimport {\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport * as CirclesOfTrust from './CirclesOfTrustOps';\nimport * as EmailTemplate from './EmailTemplateOps';\nimport * as Idp from './IdpOps';\nimport * as Node from './NodeOps';\nimport * as Saml2 from './Saml2Ops';\nimport * as Script from './ScriptOps';\nimport * as Theme from './ThemeOps';\nimport { cloneDeep } from './utils/OpsUtils';\nimport wordwrap from './utils/Wordwrap';\n\nconst { getTypedFilename, saveJsonToFile, getRealmString } = frodo.utils;\nconst {\n readJourneys,\n exportJourney,\n createMultiTreeExportTemplate,\n resolveDependencies,\n importJourneys,\n importJourney,\n getTreeDescendents,\n getNodeRef,\n onlineTreeExportResolver,\n getJourneyClassification: _getJourneyClassification,\n} = frodo.authn.journey;\n\n/**\n * List all the journeys/trees\n * @param {boolean} long Long version, all the fields\n * @param {boolean} analyze Analyze journeys/trees for custom nodes (expensive)\n * @returns {Promise<TreeSkeleton[]>} a promise that resolves to an array journey objects\n */\nexport async function listJourneys(\n long = false,\n analyze = false\n): Promise<TreeSkeleton[]> {\n let journeys = [];\n try {\n journeys = await readJourneys();\n if (!long && !analyze) {\n for (const journeyStub of journeys) {\n printMessage(`${journeyStub['_id']}`, 'data');\n }\n } else {\n if (!analyze) {\n const table = createTable(['Name', 'Status', 'Tags']);\n for (const journeyStub of journeys) {\n table.push([\n `${journeyStub._id}`,\n journeyStub.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n journeyStub.uiConfig?.categories\n ? wordwrap(\n JSON.parse(journeyStub.uiConfig.categories).join(', '),\n 60\n )\n : '',\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n showSpinner('Retrieving details of all journeys...');\n const exportPromises = [];\n try {\n for (const journeyStub of journeys) {\n exportPromises.push(\n exportJourney(journeyStub['_id'], {\n useStringArrays: false,\n deps: false,\n })\n );\n }\n const journeyExports = await Promise.all(exportPromises);\n succeedSpinner('Retrieved details of all journeys.');\n const table = createTable([\n 'Name',\n 'Status',\n 'Classification',\n 'Tags',\n ]);\n for (const journeyExport of journeyExports) {\n table.push([\n `${journeyExport.tree._id}`,\n journeyExport.tree.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n getJourneyClassification(journeyExport).join(', '),\n journeyExport.tree.uiConfig?.categories\n ? wordwrap(\n JSON.parse(journeyExport.tree.uiConfig.categories).join(\n ', '\n ),\n 60\n )\n : '',\n ]);\n }\n printMessage(table.toString(), 'data');\n } catch (error) {\n failSpinner('Error retrieving details of all journeys.');\n printMessage(error.response.data, 'error');\n }\n }\n }\n } catch (error) {\n printMessage(error.response?.data, 'error');\n }\n return journeys;\n}\n\n/**\n * Export journey by id/name to file\n * @param {string} journeyId journey id/name\n * @param {string} file optional export file name\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneyToFile(\n journeyId: string,\n file: string,\n options: TreeExportOptions\n): Promise<void> {\n debugMessage(`exportJourneyToFile: start`);\n const verbose = state.getDebug();\n if (!file) {\n file = getTypedFilename(journeyId, 'journey');\n }\n if (state.getDirectory()) {\n const dir = state.getDirectory().replace(/\\/$/, '');\n debugMessage(`exportJourneyToFile: directory='${dir}'`);\n file = `${dir}/${file}`;\n // create directory if it doesn't exist\n if (!fs.existsSync(dir)) {\n debugMessage(`exportJourneyToFile: creating directory '${dir}'`);\n fs.mkdirSync(dir, { recursive: true });\n }\n }\n if (!verbose) showSpinner(`${journeyId}`);\n try {\n const fileData: SingleTreeExportInterface = await exportJourney(\n journeyId,\n options\n );\n if (verbose) showSpinner(`${journeyId}`);\n saveJsonToFile(fileData, file);\n succeedSpinner(\n `Exported ${journeyId['brightCyan']} to ${file['brightCyan']}.`\n );\n } catch (error) {\n if (verbose) showSpinner(`${journeyId}`);\n failSpinner(`Error exporting journey ${journeyId}: ${error}`);\n }\n}\n\n/**\n * Export all journeys to file\n * @param {string} file optional export file name\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneysToFile(\n file: string,\n options: TreeExportOptions = {\n deps: false,\n useStringArrays: false,\n }\n): Promise<void> {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Journeys`, 'journey');\n }\n if (state.getDirectory()) {\n const dir = state.getDirectory().replace(/\\/$/, '');\n debugMessage(`exportJourneysToFile: directory='${dir}'`);\n fileName = `${dir}/${fileName}`;\n // create directory if it doesn't exist\n if (!fs.existsSync(dir)) {\n debugMessage(`exportJourneysToFile: creating directory '${dir}'`);\n fs.mkdirSync(dir, { recursive: true });\n }\n }\n const trees = await readJourneys();\n const fileData: MultiTreeExportInterface = createMultiTreeExportTemplate();\n createProgressBar(trees.length, 'Exporting journeys...');\n for (const tree of trees) {\n updateProgressBar(`${tree._id}`);\n try {\n const exportData = await exportJourney(tree._id, options);\n delete exportData.meta;\n fileData.trees[tree._id] = exportData;\n } catch (error) {\n printMessage(`Error exporting journey ${tree._id}: ${error}`, 'error');\n }\n }\n saveJsonToFile(fileData, fileName);\n stopProgressBar(`Exported to ${fileName}`);\n}\n\n/**\n * Export all journeys to separate files\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneysToFiles(\n options: TreeExportOptions\n): Promise<void> {\n const dir = state.getDirectory()\n ? state.getDirectory().replace(/\\/$/, '')\n : undefined;\n debugMessage(`exportJourneysToFiles: directory='${dir}'`);\n // create directory if it doesn't exist\n if (dir && !fs.existsSync(dir)) {\n debugMessage(`exportJourneysToFiles: creating directory '${dir}'`);\n fs.mkdirSync(dir, { recursive: true });\n }\n const trees = await readJourneys();\n createProgressBar(trees.length, 'Exporting journeys...');\n for (const tree of trees) {\n updateProgressBar(`${tree._id}`);\n let fileName = getTypedFilename(`${tree._id}`, 'journey');\n if (dir) {\n fileName = `${dir}/${fileName}`;\n }\n try {\n const exportData: SingleTreeExportInterface = await exportJourney(\n tree._id,\n options\n );\n saveJsonToFile(exportData, fileName);\n } catch (error) {\n // do we need to report status here?\n }\n }\n stopProgressBar('Done');\n}\n\n/**\n * Import a journey from file\n * @param {string} journeyId journey id/name\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneyFromFile(\n journeyId: string,\n file: string,\n options: TreeImportOptions\n) {\n const verbose = state.getDebug();\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n let journeyData = JSON.parse(data);\n // check if this is a file with multiple trees and get journey by id\n if (journeyData.trees && journeyData.trees[journeyId]) {\n journeyData = journeyData.trees[journeyId];\n } else if (journeyData.trees) {\n journeyData = null;\n }\n\n // if a journeyId was specified, only import the matching journey\n if (journeyData && journeyId === journeyData.tree._id) {\n // attempt dependency resolution for single tree import\n const installedJourneys = (await readJourneys()).map((x) => x._id);\n const unresolvedJourneys = {};\n const resolvedJourneys = [];\n showSpinner('Resolving dependencies');\n await resolveDependencies(\n installedJourneys,\n { [journeyId]: journeyData },\n unresolvedJourneys,\n resolvedJourneys\n );\n if (Object.keys(unresolvedJourneys).length === 0) {\n succeedSpinner(`Resolved all dependencies.`);\n\n if (!verbose) showSpinner(`Importing ${journeyId}...`);\n importJourney(journeyData, options)\n .then(() => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n succeedSpinner(`Imported ${journeyId}.`);\n })\n .catch((importError) => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n failSpinner(`${importError}`);\n });\n } else {\n failSpinner(`Unresolved dependencies:`);\n for (const journey of Object.keys(unresolvedJourneys)) {\n printMessage(\n ` ${journey} requires ${unresolvedJourneys[journey]}`,\n 'error'\n );\n }\n }\n // end dependency resolution for single tree import\n } else {\n showSpinner(`Importing ${journeyId}...`);\n failSpinner(`${journeyId} not found!`);\n }\n });\n}\n\n/**\n * Import first journey from file\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importFirstJourneyFromFile(\n file: string,\n options: TreeImportOptions\n) {\n const verbose = state.getDebug();\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n let journeyData = cloneDeep(JSON.parse(data));\n let journeyId = null;\n // single tree\n if (journeyData.tree) {\n journeyId = cloneDeep(journeyData.tree._id);\n }\n // multiple trees, so get the first tree\n else if (journeyData.trees) {\n for (const treeId in journeyData.trees) {\n if (Object.hasOwnProperty.call(journeyData.trees, treeId)) {\n journeyId = treeId;\n journeyData = journeyData.trees[treeId];\n break;\n }\n }\n }\n\n // if a journeyId was specified, only import the matching journey\n if (journeyData && journeyId) {\n // attempt dependency resolution for single tree import\n const installedJourneys = (await readJourneys()).map((x) => x._id);\n const unresolvedJourneys = {};\n const resolvedJourneys = [];\n showSpinner('Resolving dependencies');\n await resolveDependencies(\n installedJourneys,\n { [journeyId]: journeyData },\n unresolvedJourneys,\n resolvedJourneys\n );\n if (Object.keys(unresolvedJourneys).length === 0) {\n succeedSpinner(`Resolved all dependencies.`);\n\n if (!verbose) showSpinner(`Importing ${journeyId}...`);\n importJourney(journeyData, options)\n .then(() => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n succeedSpinner(`Imported ${journeyId}.`);\n })\n .catch((importError) => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n failSpinner(`${importError}`);\n });\n } else {\n failSpinner(`Unresolved dependencies:`);\n for (const journey of Object.keys(unresolvedJourneys)) {\n printMessage(\n ` ${journey} requires ${unresolvedJourneys[journey]}`,\n 'error'\n );\n }\n }\n } else {\n showSpinner(`Importing...`);\n failSpinner(`No journeys found!`);\n }\n // end dependency resolution for single tree import\n });\n}\n\n/**\n * Import all journeys from file\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneysFromFile(\n file: string,\n options: TreeImportOptions\n) {\n fs.readFile(file, 'utf8', (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n importJourneys(fileData.trees, options);\n } catch (error) {\n if (error.name === 'UnresolvedDependenciesError') {\n for (const journey of Object.keys(error.unresolvedJourneys)) {\n printMessage({\n message: ` - ${journey} requires ${error.unresolvedJourneys[journey]}`,\n type: 'info',\n state,\n });\n }\n } else {\n printMessage(`${error.message}`, 'error');\n }\n }\n });\n}\n\n/**\n * Import all journeys from separate files\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneysFromFiles(options: TreeImportOptions) {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.journey.json')\n );\n const allJourneysData = { trees: {} };\n for (const file of jsonFiles) {\n const journeyData = JSON.parse(fs.readFileSync(file, 'utf8'));\n allJourneysData.trees[journeyData.tree._id] = journeyData;\n }\n try {\n await importJourneys(\n allJourneysData.trees as MultiTreeExportInterface,\n options\n );\n } catch (error) {\n printMessage(`${error.response?.data?.message || error.message}`, 'error');\n }\n}\n\n/**\n * Get journey classification\n * @param {SingleTreeExportInterface} journey journey export\n * @returns {string[]} Colored string array of classifications\n */\nexport function getJourneyClassification(\n journey: SingleTreeExportInterface\n): JourneyClassificationType[] {\n return _getJourneyClassification(journey).map((it) => {\n switch (it) {\n case 'standard':\n return it['brightGreen'];\n\n case 'cloud':\n return it['brightMagenta'];\n\n case 'custom':\n return it['brightRed'];\n\n case 'premium':\n return it['brightYellow'];\n }\n });\n}\n\n/**\n * Get journey classification in markdown\n * @param {SingleTreeExportInterface} journey journey export\n * @returns {string[]} Colored string array of classifications\n */\nexport function getJourneyClassificationMd(\n journey: SingleTreeExportInterface\n): string[] {\n return _getJourneyClassification(journey).map((it) => {\n switch (it) {\n case 'standard':\n return `:green_circle: \\`${it}\\``;\n\n case 'cloud':\n return `:purple_circle: \\`${it}\\``;\n\n case 'custom':\n return `:red_circle: \\`${it}\\``;\n\n case 'premium':\n return `:yellow_circle: \\`${it}\\``;\n }\n });\n}\n\n/**\n * Get a one-line description of the tree object\n * @param {TreeSkeleton} treeObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(treeObj: TreeSkeleton): string {\n const description = `[${treeObj._id['brightCyan']}]`;\n return description;\n}\n\n/**\n * Get a one-line description of the tree object in markdown\n * @param {TreeSkeleton} treeObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescriptionMd(treeObj: TreeSkeleton): string {\n const description = `${treeObj._id}`;\n return description;\n}\n\n/**\n * Helper function to render a nested list of dependent trees\n * @param {TreeDependencyMapInterface} descendents tree dependency map\n * @param {number} depth level of nesting\n */\nfunction describeTreeDescendents(\n descendents: TreeDependencyMapInterface,\n depth = 0\n) {\n if (depth || Object.values(descendents)[0].length) {\n // heading\n if (depth === 0) {\n printMessage(\n `\\nInner Tree Dependencies (${Object.values(descendents)[0].length}):`,\n 'data'\n );\n }\n const indent = Array(depth * 2)\n .fill(' ')\n .join('');\n const [tree] = Object.keys(descendents);\n printMessage(`${indent}- ${tree['brightCyan']}`, 'data');\n for (const descendent of descendents[tree]) {\n describeTreeDescendents(descendent, depth + 1);\n }\n }\n}\n\n/**\n * Helper function to render a nested list of dependent trees in markdown\n * @param {TreeDependencyMapInterface} descendents tree dependency map\n * @param {number} depth level of nesting\n */\nfunction describeTreeDescendentsMd(\n descendents: TreeDependencyMapInterface,\n depth = 0\n): string {\n let markdown = '';\n if (depth || Object.values(descendents)[0].length) {\n // heading\n if (depth === 0) {\n markdown += `## Inner Tree Dependencies (${\n Object.values(descendents)[0].length\n })\\n`;\n }\n const indent = Array(depth * 2)\n .fill(' ')\n .join('');\n const [tree] = Object.keys(descendents);\n markdown += `${indent}- ${tree}\\n`;\n for (const descendent of descendents[tree]) {\n markdown += describeTreeDescendentsMd(descendent, depth + 1);\n }\n return markdown;\n }\n return markdown;\n}\n\n/**\n * Describe a journey:\n * - Properties, tags, description, name, metadata\n * - Inner tree dependency tree\n * - Node type summary\n * - Nodes\n * - Themes\n * - Scripts\n * - Email templates\n * - Social identity providers\n * - SAML2 entity providers\n * - SAML2 circles of trust\n * @param {SingleTreeExportInterface} journeyData journey export object\n * @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function\n */\nexport async function describeJourney(\n journeyData: SingleTreeExportInterface,\n resolveTreeExport: TreeExportResolverInterface = onlineTreeExportResolver\n): Promise<void> {\n const allNodes = {\n ...journeyData.nodes,\n ...journeyData.innerNodes,\n };\n const nodeTypeMap = {};\n\n for (const nodeData of Object.values(allNodes)) {\n if (nodeTypeMap[nodeData._type._id]) {\n nodeTypeMap[nodeData._type._id] += 1;\n } else {\n nodeTypeMap[nodeData._type._id] = 1;\n }\n }\n\n // initialize AM version from file\n if (!state.getAmVersion() && journeyData.meta?.originAmVersion) {\n state.setAmVersion(journeyData.meta.originAmVersion);\n }\n\n // Journey Name\n printMessage(`${getOneLineDescription(journeyData.tree)}`, 'data');\n printMessage(Array(`[${journeyData.tree._id}]`['length']).fill('=').join(''));\n\n // Description\n if (journeyData.tree.description) {\n printMessage(`\\n${journeyData.tree.description}`, 'data');\n }\n\n // Status\n printMessage(\n `\\nStatus\\n${\n journeyData.tree.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen']\n }`\n );\n\n // Classification\n if (state.getAmVersion()) {\n printMessage(\n `\\nClassification\\n${getJourneyClassification(journeyData).join(', ')}`,\n 'data'\n );\n }\n\n // Categories/Tags\n if (\n journeyData.tree.uiConfig?.categories &&\n journeyData.tree.uiConfig.categories != '[]'\n ) {\n printMessage('\\nCategories/Tags', 'data');\n printMessage(\n `${JSON.parse(journeyData.tree.uiConfig.categories).join(', ')}`,\n 'data'\n );\n }\n\n // Dependency Tree\n try {\n const descendents = await getTreeDescendents(\n journeyData,\n resolveTreeExport\n );\n describeTreeDescendents(descendents);\n } catch (error) {\n printMessage(`Error resolving inner tree dependencies:`, 'error');\n printMessage(error.stack, 'error');\n }\n\n // Node Types\n if (Object.entries(nodeTypeMap).length) {\n printMessage(\n `\\nNode Types (${Object.entries(nodeTypeMap).length}):`,\n 'data'\n );\n for (const [nodeType, count] of Object.entries(nodeTypeMap)) {\n printMessage(\n `- ${String(count)} [${\n nodeType['brightCyan']\n }] (${Node.getNodeClassification(nodeType).join(', ')})`,\n 'data'\n );\n }\n }\n\n // Nodes\n if (Object.entries(allNodes).length) {\n printMessage(`\\nNodes (${Object.entries(allNodes).length}):`, 'data');\n for (const nodeObj of Object.values<NodeSkeleton>(allNodes)) {\n printMessage(\n `- ${Node.getOneLineDescription(\n nodeObj,\n getNodeRef(nodeObj, journeyData)\n )}`,\n 'data'\n );\n }\n }\n\n // Themes\n if (journeyData.themes?.length) {\n printMessage(`\\nThemes (${journeyData.themes.length}):`, 'data');\n for (const themeData of journeyData.themes) {\n printMessage(`- ${Theme.getOneLineDescription(themeData)}`, 'data');\n }\n }\n\n // Scripts\n if (Object.entries(journeyData.scripts).length) {\n printMessage(\n `\\nScripts (${Object.entries(journeyData.scripts).length}):`,\n 'data'\n );\n for (const scriptData of Object.values(journeyData.scripts)) {\n printMessage(`- ${Script.getOneLineDescription(scriptData)}`, 'data');\n }\n }\n\n // Email Templates\n if (Object.entries(journeyData.emailTemplates).length) {\n printMessage(\n `\\nEmail Templates (${\n Object.entries(journeyData.emailTemplates).length\n }):`,\n 'data'\n );\n for (const templateData of Object.values(journeyData.emailTemplates)) {\n printMessage(\n `- ${EmailTemplate.getOneLineDescription(templateData)}`,\n 'data'\n );\n }\n }\n\n // Social Identity Providers\n if (Object.entries(journeyData.socialIdentityProviders).length) {\n printMessage(\n `\\nSocial Identity Providers (${\n Object.entries(journeyData.socialIdentityProviders).length\n }):`,\n 'data'\n );\n for (const socialIdpData of Object.values(\n journeyData.socialIdentityProviders\n )) {\n printMessage(`- ${Idp.getOneLineDescription(socialIdpData)}`, 'data');\n }\n }\n\n // SAML2 Entity Providers\n if (Object.entries(journeyData.saml2Entities).length) {\n printMessage(\n `\\nSAML2 Entity Providers (${\n Object.entries(journeyData.saml2Entities).length\n }):`,\n 'data'\n );\n for (const entityProviderData of Object.values(journeyData.saml2Entities)) {\n printMessage(\n `- ${Saml2.getOneLineDescription(entityProviderData)}`,\n 'data'\n );\n }\n }\n\n // SAML2 Circles Of Trust\n if (Object.entries(journeyData.circlesOfTrust).length) {\n printMessage(\n `\\nSAML2 Circles Of Trust (${\n Object.entries(journeyData.circlesOfTrust).length\n }):`,\n 'data'\n );\n for (const cotData of Object.values(journeyData.circlesOfTrust)) {\n printMessage(\n `- ${CirclesOfTrust.getOneLineDescription(cotData)}`,\n 'data'\n );\n }\n }\n}\n\n/**\n * Describe a journey in markdown:\n * - Properties, tags, description, name, metadata\n * - Inner tree dependency tree\n * - Node type summary\n * - Nodes\n * - Themes\n * - Scripts\n * - Email templates\n * - Social identity providers\n * - SAML2 entity providers\n * - SAML2 circles of trust\n * @param {SingleTreeExportInterface} journeyData journey export object\n * @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function\n */\nexport async function describeJourneyMd(\n journeyData: SingleTreeExportInterface,\n resolveTreeExport: TreeExportResolverInterface = onlineTreeExportResolver\n) {\n const allNodes = {\n ...journeyData.nodes,\n ...journeyData.innerNodes,\n };\n const nodeTypeMap = {};\n\n for (const nodeData of Object.values(allNodes)) {\n if (nodeTypeMap[nodeData._type._id]) {\n nodeTypeMap[nodeData._type._id] += 1;\n } else {\n nodeTypeMap[nodeData._type._id] = 1;\n }\n }\n\n // initialize AM version from file\n if (!state.getAmVersion() && journeyData.meta?.originAmVersion) {\n state.setAmVersion(journeyData.meta.originAmVersion);\n }\n\n // Journey Name\n printMessage(\n `# ${getOneLineDescriptionMd(journeyData.tree)} - ${\n journeyData.tree.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n }, ${getJourneyClassificationMd(journeyData).join(', ')}`,\n 'data'\n );\n\n // Categories/Tags\n if (\n journeyData.tree.uiConfig?.categories &&\n journeyData.tree.uiConfig.categories != '[]'\n ) {\n printMessage(\n `\\`${JSON.parse(journeyData.tree.uiConfig.categories).join('`, `')}\\``,\n 'data'\n );\n }\n\n // Description\n if (journeyData.tree.description) {\n printMessage(`\\n${journeyData.tree.description}`, 'data');\n }\n\n // Journey image\n printMessage(`\\n[]()\\n`, 'data');\n\n // Dependency Tree\n const descendents = await getTreeDescendents(journeyData, resolveTreeExport);\n printMessage(describeTreeDescendentsMd(descendents), 'data');\n\n // Node Types\n if (Object.entries(nodeTypeMap).length) {\n printMessage(\n `## Node Types (${Object.entries(nodeTypeMap).length})`,\n 'data'\n );\n printMessage('| Count | Type | Classification |', 'data');\n printMessage('| -----:| ---- | -------------- |', 'data');\n for (const [nodeType, count] of Object.entries(nodeTypeMap)) {\n printMessage(\n `| ${String(count)} | ${nodeType} | ${Node.getNodeClassificationMd(\n nodeType\n ).join('<br>')} |`,\n 'data'\n );\n }\n }\n\n // Nodes\n if (Object.entries(allNodes).length) {\n printMessage(`## Nodes (${Object.entries(allNodes).length})`, 'data');\n printMessage(Node.getTableHeaderMd(), 'data');\n for (const nodeObj of Object.values<NodeSkeleton>(allNodes)) {\n printMessage(\n `${Node.getTableRowMd(nodeObj, getNodeRef(nodeObj, journeyData))}`,\n 'data'\n );\n }\n }\n\n // Themes\n if (journeyData.themes?.length) {\n printMessage(`## Themes (${journeyData.themes.length})`, 'data');\n printMessage(Theme.getTableHeaderMd(), 'data');\n for (const themeData of journeyData.themes) {\n printMessage(`${Theme.getTableRowMd(themeData)}`, 'data');\n }\n }\n\n // Scripts\n if (Object.entries(journeyData.scripts).length) {\n printMessage(\n `## Scripts (${Object.entries(journeyData.scripts).length})`,\n 'data'\n );\n printMessage(Script.getTableHeaderMd(), 'data');\n for (const scriptData of Object.values(journeyData.scripts)) {\n printMessage(`${Script.getTableRowMd(scriptData)}`, 'data');\n }\n }\n\n // Email Templates\n if (Object.entries(journeyData.emailTemplates).length) {\n printMessage(\n `## Email Templates (${\n Object.entries(journeyData.emailTemplates).length\n })`,\n 'data'\n );\n printMessage(EmailTemplate.getTableHeaderMd(), 'data');\n for (const templateData of Object.values(journeyData.emailTemplates)) {\n printMessage(`${EmailTemplate.getTableRowMd(templateData)}`, 'data');\n }\n }\n\n // Social Identity Providers\n if (Object.entries(journeyData.socialIdentityProviders).length) {\n printMessage(\n `## Social Identity Providers (${\n Object.entries(journeyData.socialIdentityProviders).length\n })`,\n 'data'\n );\n printMessage(Idp.getTableHeaderMd(), 'data');\n for (const socialIdpData of Object.values(\n journeyData.socialIdentityProviders\n )) {\n printMessage(`${Idp.getTableRowMd(socialIdpData)}`, 'data');\n }\n }\n\n // SAML2 Entity Providers\n if (Object.entries(journeyData.saml2Entities).length) {\n printMessage(\n `## SAML2 Entity Providers (${\n Object.entries(journeyData.saml2Entities).length\n })`,\n 'data'\n );\n printMessage(Saml2.getTableHeaderMd(), 'data');\n for (const entityProviderData of Object.values(journeyData.saml2Entities)) {\n printMessage(`${Saml2.getTableRowMd(entityProviderData)}`, 'data');\n }\n }\n\n // SAML2 Circles Of Trust\n if (Object.entries(journeyData.circlesOfTrust).length) {\n printMessage(\n `## SAML2 Circles Of Trust (${\n Object.entries(journeyData.circlesOfTrust).length\n })`,\n 'data'\n );\n printMessage(CirclesOfTrust.getTableHeaderMd(), 'data');\n for (const cotData of Object.values(journeyData.circlesOfTrust)) {\n printMessage(`${CirclesOfTrust.getTableRowMd(cotData)}`, 'data');\n }\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAYpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AACrD,OAAO,KAAKC,aAAa,MAAM,oBAAoB;AACnD,OAAO,KAAKC,GAAG,MAAM,UAAU;AAC/B,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,OAAO,KAAKC,KAAK,MAAM,YAAY;AACnC,OAAO,KAAKC,MAAM,MAAM,aAAa;AACrC,OAAO,KAAKC,KAAK,MAAM,YAAY;AACnC,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,OAAOC,QAAQ,MAAM,kBAAkB;AAEvC,MAAM;EAAEC,gBAAgB;EAAEC,cAAc;EAAEC;AAAe,CAAC,GAAGvB,KAAK,CAACwB,KAAK;AACxE,MAAM;EACJC,YAAY;EACZC,aAAa;EACbC,6BAA6B;EAC7BC,mBAAmB;EACnBC,cAAc;EACdC,aAAa;EACbC,kBAAkB;EAClBC,UAAU;EACVC,wBAAwB;EACxBC,wBAAwB,EAAEC;AAC5B,CAAC,GAAGnC,KAAK,CAACoC,KAAK,CAACC,OAAO;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAChCC,IAAI,GAAG,KAAK,EACZC,OAAO,GAAG,KAAK,EACU;EACzB,IAAIC,QAAQ,GAAG,EAAE;EACjB,IAAI;IACFA,QAAQ,GAAG,MAAMhB,YAAY,CAAC,CAAC;IAC/B,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MAAM,CAACtC,WAAW,CAAC0E,aAAa,CAAC,EAAE;MACzE9J,YAAY,CAAE,GAAES,KAAK,CAAC+J,aAAa,CAACT,kBAAkB,CAAE,EAAC,EAAE,MAAM,CAAC;IACpE;EACF;;EAEA;EACA,IAAIrE,MAAM,CAACsD,OAAO,CAAC5D,WAAW,CAAC4E,cAAc,CAAC,CAACpF,MAAM,EAAE;IACrD5E,YAAY,CACT,8BACC0F,MAAM,CAACsD,OAAO,CAAC5D,WAAW,CAAC4E,cAAc,CAAC,CAACpF,MAC5C,GAAE,EACH,MACF,CAAC;IACD5E,YAAY,CAACK,cAAc,CAACkK,gBAAgB,CAAC,CAAC,EAAE,MAAM,CAAC;IACvD,KAAK,MAAMN,OAAO,IAAIvE,MAAM,CAACgC,MAAM,CAACtC,WAAW,CAAC4E,cAAc,CAAC,EAAE;MAC/DhK,YAAY,CAAE,GAAEK,cAAc,CAACmK,aAAa,CAACP,OAAO,CAAE,EAAC,EAAE,MAAM,CAAC;IAClE;EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"JourneyOps.js","names":["frodo","state","fs","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","CirclesOfTrust","EmailTemplate","Idp","Node","Saml2","Script","Theme","cloneDeep","wordwrap","getTypedFilename","saveJsonToFile","getRealmString","getFilePath","getWorkingDirectory","utils","readJourneys","exportJourney","createMultiTreeExportTemplate","resolveDependencies","importJourneys","importJourney","getTreeDescendents","getNodeRef","onlineTreeExportResolver","getJourneyClassification","_getJourneyClassification","authn","journey","listJourneys","long","analyze","journeys","journeyStub","table","_journeyStub$uiConfig","push","_id","enabled","uiConfig","categories","JSON","parse","join","toString","exportPromises","useStringArrays","deps","journeyExports","Promise","all","journeyExport","_journeyExport$tree$u","tree","error","response","data","_error$response","exportJourneyToFile","journeyId","file","options","verbose","getDebug","filePath","fileData","exportJourneysToFile","trees","length","exportData","meta","exportJourneysToFiles","fileName","importJourneyFromFile","readFile","err","journeyData","installedJourneys","map","x","unresolvedJourneys","resolvedJourneys","Object","keys","then","catch","importError","importFirstJourneyFromFile","treeId","hasOwnProperty","call","importJourneysFromFile","name","message","type","importJourneysFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","allJourneysData","readFileSync","_error$response2","it","getJourneyClassificationMd","getOneLineDescription","treeObj","description","getOneLineDescriptionMd","describeTreeDescendents","descendents","depth","values","indent","Array","fill","descendent","describeTreeDescendentsMd","markdown","describeJourney","resolveTreeExport","_journeyData$meta","_journeyData$tree$uiC","_journeyData$themes","allNodes","nodes","innerNodes","nodeTypeMap","nodeData","_type","getAmVersion","originAmVersion","setAmVersion","stack","entries","nodeType","count","String","getNodeClassification","nodeObj","themes","themeData","scripts","scriptData","emailTemplates","templateData","socialIdentityProviders","socialIdpData","saml2Entities","entityProviderData","circlesOfTrust","cotData","describeJourneyMd","_journeyData$meta2","_journeyData$tree$uiC2","_journeyData$themes2","getNodeClassificationMd","getTableHeaderMd","getTableRowMd"],"sources":["../../src/ops/JourneyOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type NodeSkeleton } from '@rockcarver/frodo-lib/types/api/NodeApi';\nimport { type TreeSkeleton } from '@rockcarver/frodo-lib/types/api/TreeApi';\nimport {\n type JourneyClassificationType,\n type MultiTreeExportInterface,\n type SingleTreeExportInterface,\n type TreeDependencyMapInterface,\n type TreeExportOptions,\n type TreeExportResolverInterface,\n type TreeImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/JourneyOps';\nimport fs from 'fs';\n\nimport {\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport * as CirclesOfTrust from './CirclesOfTrustOps';\nimport * as EmailTemplate from './EmailTemplateOps';\nimport * as Idp from './IdpOps';\nimport * as Node from './NodeOps';\nimport * as Saml2 from './Saml2Ops';\nimport * as Script from './ScriptOps';\nimport * as Theme from './ThemeOps';\nimport { cloneDeep } from './utils/OpsUtils';\nimport wordwrap from './utils/Wordwrap';\n\nconst {\n getTypedFilename,\n saveJsonToFile,\n getRealmString,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n readJourneys,\n exportJourney,\n createMultiTreeExportTemplate,\n resolveDependencies,\n importJourneys,\n importJourney,\n getTreeDescendents,\n getNodeRef,\n onlineTreeExportResolver,\n getJourneyClassification: _getJourneyClassification,\n} = frodo.authn.journey;\n\n/**\n * List all the journeys/trees\n * @param {boolean} long Long version, all the fields\n * @param {boolean} analyze Analyze journeys/trees for custom nodes (expensive)\n * @returns {Promise<TreeSkeleton[]>} a promise that resolves to an array journey objects\n */\nexport async function listJourneys(\n long = false,\n analyze = false\n): Promise<TreeSkeleton[]> {\n let journeys = [];\n try {\n journeys = await readJourneys();\n if (!long && !analyze) {\n for (const journeyStub of journeys) {\n printMessage(`${journeyStub['_id']}`, 'data');\n }\n } else {\n if (!analyze) {\n const table = createTable(['Name', 'Status', 'Tags']);\n for (const journeyStub of journeys) {\n table.push([\n `${journeyStub._id}`,\n journeyStub.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n journeyStub.uiConfig?.categories\n ? wordwrap(\n JSON.parse(journeyStub.uiConfig.categories).join(', '),\n 60\n )\n : '',\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n showSpinner('Retrieving details of all journeys...');\n const exportPromises = [];\n try {\n for (const journeyStub of journeys) {\n exportPromises.push(\n exportJourney(journeyStub['_id'], {\n useStringArrays: false,\n deps: false,\n })\n );\n }\n const journeyExports = await Promise.all(exportPromises);\n succeedSpinner('Retrieved details of all journeys.');\n const table = createTable([\n 'Name',\n 'Status',\n 'Classification',\n 'Tags',\n ]);\n for (const journeyExport of journeyExports) {\n table.push([\n `${journeyExport.tree._id}`,\n journeyExport.tree.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n getJourneyClassification(journeyExport).join(', '),\n journeyExport.tree.uiConfig?.categories\n ? wordwrap(\n JSON.parse(journeyExport.tree.uiConfig.categories).join(\n ', '\n ),\n 60\n )\n : '',\n ]);\n }\n printMessage(table.toString(), 'data');\n } catch (error) {\n failSpinner('Error retrieving details of all journeys.');\n printMessage(error.response.data, 'error');\n }\n }\n }\n } catch (error) {\n printMessage(error.response?.data, 'error');\n }\n return journeys;\n}\n\n/**\n * Export journey by id/name to file\n * @param {string} journeyId journey id/name\n * @param {string} file optional export file name\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneyToFile(\n journeyId: string,\n file: string,\n options: TreeExportOptions\n): Promise<void> {\n debugMessage(`exportJourneyToFile: start`);\n const verbose = state.getDebug();\n if (!file) {\n file = getTypedFilename(journeyId, 'journey');\n }\n const filePath = getFilePath(file, true);\n if (!verbose) showSpinner(`${journeyId}`);\n try {\n const fileData: SingleTreeExportInterface = await exportJourney(\n journeyId,\n options\n );\n if (verbose) showSpinner(`${journeyId}`);\n saveJsonToFile(fileData, filePath);\n succeedSpinner(\n `Exported ${journeyId['brightCyan']} to ${filePath['brightCyan']}.`\n );\n } catch (error) {\n if (verbose) showSpinner(`${journeyId}`);\n failSpinner(`Error exporting journey ${journeyId}: ${error}`);\n }\n}\n\n/**\n * Export all journeys to file\n * @param {string} file optional export file name\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneysToFile(\n file: string,\n options: TreeExportOptions = {\n deps: false,\n useStringArrays: false,\n }\n): Promise<void> {\n if (!file) {\n file = getTypedFilename(`all${getRealmString()}Journeys`, 'journey');\n }\n const filePath = getFilePath(file, true);\n const trees = await readJourneys();\n const fileData: MultiTreeExportInterface = createMultiTreeExportTemplate();\n createProgressBar(trees.length, 'Exporting journeys...');\n for (const tree of trees) {\n updateProgressBar(`${tree._id}`);\n try {\n const exportData = await exportJourney(tree._id, options);\n delete exportData.meta;\n fileData.trees[tree._id] = exportData;\n } catch (error) {\n printMessage(`Error exporting journey ${tree._id}: ${error}`, 'error');\n }\n }\n saveJsonToFile(fileData, filePath);\n stopProgressBar(`Exported to ${filePath}`);\n}\n\n/**\n * Export all journeys to separate files\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneysToFiles(\n options: TreeExportOptions\n): Promise<void> {\n const trees = await readJourneys();\n createProgressBar(trees.length, 'Exporting journeys...');\n for (const tree of trees) {\n updateProgressBar(`${tree._id}`);\n const fileName = getTypedFilename(`${tree._id}`, 'journey');\n try {\n const exportData: SingleTreeExportInterface = await exportJourney(\n tree._id,\n options\n );\n saveJsonToFile(exportData, getFilePath(fileName, true));\n } catch (error) {\n // do we need to report status here?\n }\n }\n stopProgressBar('Done');\n}\n\n/**\n * Import a journey from file\n * @param {string} journeyId journey id/name\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneyFromFile(\n journeyId: string,\n file: string,\n options: TreeImportOptions\n) {\n const verbose = state.getDebug();\n fs.readFile(getFilePath(file), 'utf8', async (err, data) => {\n if (err) throw err;\n let journeyData = JSON.parse(data);\n // check if this is a file with multiple trees and get journey by id\n if (journeyData.trees && journeyData.trees[journeyId]) {\n journeyData = journeyData.trees[journeyId];\n } else if (journeyData.trees) {\n journeyData = null;\n }\n\n // if a journeyId was specified, only import the matching journey\n if (journeyData && journeyId === journeyData.tree._id) {\n // attempt dependency resolution for single tree import\n const installedJourneys = (await readJourneys()).map((x) => x._id);\n const unresolvedJourneys = {};\n const resolvedJourneys = [];\n showSpinner('Resolving dependencies');\n await resolveDependencies(\n installedJourneys,\n { [journeyId]: journeyData },\n unresolvedJourneys,\n resolvedJourneys\n );\n if (Object.keys(unresolvedJourneys).length === 0) {\n succeedSpinner(`Resolved all dependencies.`);\n\n if (!verbose) showSpinner(`Importing ${journeyId}...`);\n importJourney(journeyData, options)\n .then(() => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n succeedSpinner(`Imported ${journeyId}.`);\n })\n .catch((importError) => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n failSpinner(`${importError}`);\n });\n } else {\n failSpinner(`Unresolved dependencies:`);\n for (const journey of Object.keys(unresolvedJourneys)) {\n printMessage(\n ` ${journey} requires ${unresolvedJourneys[journey]}`,\n 'error'\n );\n }\n }\n // end dependency resolution for single tree import\n } else {\n showSpinner(`Importing ${journeyId}...`);\n failSpinner(`${journeyId} not found!`);\n }\n });\n}\n\n/**\n * Import first journey from file\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importFirstJourneyFromFile(\n file: string,\n options: TreeImportOptions\n) {\n const verbose = state.getDebug();\n fs.readFile(getFilePath(file), 'utf8', async (err, data) => {\n if (err) throw err;\n let journeyData = cloneDeep(JSON.parse(data));\n let journeyId = null;\n // single tree\n if (journeyData.tree) {\n journeyId = cloneDeep(journeyData.tree._id);\n }\n // multiple trees, so get the first tree\n else if (journeyData.trees) {\n for (const treeId in journeyData.trees) {\n if (Object.hasOwnProperty.call(journeyData.trees, treeId)) {\n journeyId = treeId;\n journeyData = journeyData.trees[treeId];\n break;\n }\n }\n }\n\n // if a journeyId was specified, only import the matching journey\n if (journeyData && journeyId) {\n // attempt dependency resolution for single tree import\n const installedJourneys = (await readJourneys()).map((x) => x._id);\n const unresolvedJourneys = {};\n const resolvedJourneys = [];\n showSpinner('Resolving dependencies');\n await resolveDependencies(\n installedJourneys,\n { [journeyId]: journeyData },\n unresolvedJourneys,\n resolvedJourneys\n );\n if (Object.keys(unresolvedJourneys).length === 0) {\n succeedSpinner(`Resolved all dependencies.`);\n\n if (!verbose) showSpinner(`Importing ${journeyId}...`);\n importJourney(journeyData, options)\n .then(() => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n succeedSpinner(`Imported ${journeyId}.`);\n })\n .catch((importError) => {\n if (verbose) showSpinner(`Importing ${journeyId}...`);\n failSpinner(`${importError}`);\n });\n } else {\n failSpinner(`Unresolved dependencies:`);\n for (const journey of Object.keys(unresolvedJourneys)) {\n printMessage(\n ` ${journey} requires ${unresolvedJourneys[journey]}`,\n 'error'\n );\n }\n }\n } else {\n showSpinner(`Importing...`);\n failSpinner(`No journeys found!`);\n }\n // end dependency resolution for single tree import\n });\n}\n\n/**\n * Import all journeys from file\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneysFromFile(\n file: string,\n options: TreeImportOptions\n) {\n fs.readFile(getFilePath(file), 'utf8', (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n importJourneys(fileData.trees, options);\n } catch (error) {\n if (error.name === 'UnresolvedDependenciesError') {\n for (const journey of Object.keys(error.unresolvedJourneys)) {\n printMessage({\n message: ` - ${journey} requires ${error.unresolvedJourneys[journey]}`,\n type: 'info',\n state,\n });\n }\n } else {\n printMessage(`${error.message}`, 'error');\n }\n }\n });\n}\n\n/**\n * Import all journeys from separate files\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneysFromFiles(options: TreeImportOptions) {\n const names = fs.readdirSync(getWorkingDirectory());\n const jsonFiles = names\n .filter((name) => name.toLowerCase().endsWith('.journey.json'))\n .map((name) => getFilePath(name));\n const allJourneysData = { trees: {} };\n for (const file of jsonFiles) {\n const journeyData = JSON.parse(fs.readFileSync(file, 'utf8'));\n allJourneysData.trees[journeyData.tree._id] = journeyData;\n }\n try {\n await importJourneys(\n allJourneysData.trees as MultiTreeExportInterface,\n options\n );\n } catch (error) {\n printMessage(`${error.response?.data?.message || error.message}`, 'error');\n }\n}\n\n/**\n * Get journey classification\n * @param {SingleTreeExportInterface} journey journey export\n * @returns {string[]} Colored string array of classifications\n */\nexport function getJourneyClassification(\n journey: SingleTreeExportInterface\n): JourneyClassificationType[] {\n return _getJourneyClassification(journey).map((it) => {\n switch (it) {\n case 'standard':\n return it['brightGreen'];\n\n case 'cloud':\n return it['brightMagenta'];\n\n case 'custom':\n return it['brightRed'];\n\n case 'premium':\n return it['brightYellow'];\n }\n });\n}\n\n/**\n * Get journey classification in markdown\n * @param {SingleTreeExportInterface} journey journey export\n * @returns {string[]} Colored string array of classifications\n */\nexport function getJourneyClassificationMd(\n journey: SingleTreeExportInterface\n): string[] {\n return _getJourneyClassification(journey).map((it) => {\n switch (it) {\n case 'standard':\n return `:green_circle: \\`${it}\\``;\n\n case 'cloud':\n return `:purple_circle: \\`${it}\\``;\n\n case 'custom':\n return `:red_circle: \\`${it}\\``;\n\n case 'premium':\n return `:yellow_circle: \\`${it}\\``;\n }\n });\n}\n\n/**\n * Get a one-line description of the tree object\n * @param {TreeSkeleton} treeObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(treeObj: TreeSkeleton): string {\n const description = `[${treeObj._id['brightCyan']}]`;\n return description;\n}\n\n/**\n * Get a one-line description of the tree object in markdown\n * @param {TreeSkeleton} treeObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescriptionMd(treeObj: TreeSkeleton): string {\n const description = `${treeObj._id}`;\n return description;\n}\n\n/**\n * Helper function to render a nested list of dependent trees\n * @param {TreeDependencyMapInterface} descendents tree dependency map\n * @param {number} depth level of nesting\n */\nfunction describeTreeDescendents(\n descendents: TreeDependencyMapInterface,\n depth = 0\n) {\n if (depth || Object.values(descendents)[0].length) {\n // heading\n if (depth === 0) {\n printMessage(\n `\\nInner Tree Dependencies (${Object.values(descendents)[0].length}):`,\n 'data'\n );\n }\n const indent = Array(depth * 2)\n .fill(' ')\n .join('');\n const [tree] = Object.keys(descendents);\n printMessage(`${indent}- ${tree['brightCyan']}`, 'data');\n for (const descendent of descendents[tree]) {\n describeTreeDescendents(descendent, depth + 1);\n }\n }\n}\n\n/**\n * Helper function to render a nested list of dependent trees in markdown\n * @param {TreeDependencyMapInterface} descendents tree dependency map\n * @param {number} depth level of nesting\n */\nfunction describeTreeDescendentsMd(\n descendents: TreeDependencyMapInterface,\n depth = 0\n): string {\n let markdown = '';\n if (depth || Object.values(descendents)[0].length) {\n // heading\n if (depth === 0) {\n markdown += `## Inner Tree Dependencies (${\n Object.values(descendents)[0].length\n })\\n`;\n }\n const indent = Array(depth * 2)\n .fill(' ')\n .join('');\n const [tree] = Object.keys(descendents);\n markdown += `${indent}- ${tree}\\n`;\n for (const descendent of descendents[tree]) {\n markdown += describeTreeDescendentsMd(descendent, depth + 1);\n }\n return markdown;\n }\n return markdown;\n}\n\n/**\n * Describe a journey:\n * - Properties, tags, description, name, metadata\n * - Inner tree dependency tree\n * - Node type summary\n * - Nodes\n * - Themes\n * - Scripts\n * - Email templates\n * - Social identity providers\n * - SAML2 entity providers\n * - SAML2 circles of trust\n * @param {SingleTreeExportInterface} journeyData journey export object\n * @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function\n */\nexport async function describeJourney(\n journeyData: SingleTreeExportInterface,\n resolveTreeExport: TreeExportResolverInterface = onlineTreeExportResolver\n): Promise<void> {\n const allNodes = {\n ...journeyData.nodes,\n ...journeyData.innerNodes,\n };\n const nodeTypeMap = {};\n\n for (const nodeData of Object.values(allNodes)) {\n if (nodeTypeMap[nodeData._type._id]) {\n nodeTypeMap[nodeData._type._id] += 1;\n } else {\n nodeTypeMap[nodeData._type._id] = 1;\n }\n }\n\n // initialize AM version from file\n if (!state.getAmVersion() && journeyData.meta?.originAmVersion) {\n state.setAmVersion(journeyData.meta.originAmVersion);\n }\n\n // Journey Name\n printMessage(`${getOneLineDescription(journeyData.tree)}`, 'data');\n printMessage(Array(`[${journeyData.tree._id}]`['length']).fill('=').join(''));\n\n // Description\n if (journeyData.tree.description) {\n printMessage(`\\n${journeyData.tree.description}`, 'data');\n }\n\n // Status\n printMessage(\n `\\nStatus\\n${\n journeyData.tree.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen']\n }`\n );\n\n // Classification\n if (state.getAmVersion()) {\n printMessage(\n `\\nClassification\\n${getJourneyClassification(journeyData).join(', ')}`,\n 'data'\n );\n }\n\n // Categories/Tags\n if (\n journeyData.tree.uiConfig?.categories &&\n journeyData.tree.uiConfig.categories != '[]'\n ) {\n printMessage('\\nCategories/Tags', 'data');\n printMessage(\n `${JSON.parse(journeyData.tree.uiConfig.categories).join(', ')}`,\n 'data'\n );\n }\n\n // Dependency Tree\n try {\n const descendents = await getTreeDescendents(\n journeyData,\n resolveTreeExport\n );\n describeTreeDescendents(descendents);\n } catch (error) {\n printMessage(`Error resolving inner tree dependencies:`, 'error');\n printMessage(error.stack, 'error');\n }\n\n // Node Types\n if (Object.entries(nodeTypeMap).length) {\n printMessage(\n `\\nNode Types (${Object.entries(nodeTypeMap).length}):`,\n 'data'\n );\n for (const [nodeType, count] of Object.entries(nodeTypeMap)) {\n printMessage(\n `- ${String(count)} [${\n nodeType['brightCyan']\n }] (${Node.getNodeClassification(nodeType).join(', ')})`,\n 'data'\n );\n }\n }\n\n // Nodes\n if (Object.entries(allNodes).length) {\n printMessage(`\\nNodes (${Object.entries(allNodes).length}):`, 'data');\n for (const nodeObj of Object.values<NodeSkeleton>(allNodes)) {\n printMessage(\n `- ${Node.getOneLineDescription(\n nodeObj,\n getNodeRef(nodeObj, journeyData)\n )}`,\n 'data'\n );\n }\n }\n\n // Themes\n if (journeyData.themes?.length) {\n printMessage(`\\nThemes (${journeyData.themes.length}):`, 'data');\n for (const themeData of journeyData.themes) {\n printMessage(`- ${Theme.getOneLineDescription(themeData)}`, 'data');\n }\n }\n\n // Scripts\n if (Object.entries(journeyData.scripts).length) {\n printMessage(\n `\\nScripts (${Object.entries(journeyData.scripts).length}):`,\n 'data'\n );\n for (const scriptData of Object.values(journeyData.scripts)) {\n printMessage(`- ${Script.getOneLineDescription(scriptData)}`, 'data');\n }\n }\n\n // Email Templates\n if (Object.entries(journeyData.emailTemplates).length) {\n printMessage(\n `\\nEmail Templates (${\n Object.entries(journeyData.emailTemplates).length\n }):`,\n 'data'\n );\n for (const templateData of Object.values(journeyData.emailTemplates)) {\n printMessage(\n `- ${EmailTemplate.getOneLineDescription(templateData)}`,\n 'data'\n );\n }\n }\n\n // Social Identity Providers\n if (Object.entries(journeyData.socialIdentityProviders).length) {\n printMessage(\n `\\nSocial Identity Providers (${\n Object.entries(journeyData.socialIdentityProviders).length\n }):`,\n 'data'\n );\n for (const socialIdpData of Object.values(\n journeyData.socialIdentityProviders\n )) {\n printMessage(`- ${Idp.getOneLineDescription(socialIdpData)}`, 'data');\n }\n }\n\n // SAML2 Entity Providers\n if (Object.entries(journeyData.saml2Entities).length) {\n printMessage(\n `\\nSAML2 Entity Providers (${\n Object.entries(journeyData.saml2Entities).length\n }):`,\n 'data'\n );\n for (const entityProviderData of Object.values(journeyData.saml2Entities)) {\n printMessage(\n `- ${Saml2.getOneLineDescription(entityProviderData)}`,\n 'data'\n );\n }\n }\n\n // SAML2 Circles Of Trust\n if (Object.entries(journeyData.circlesOfTrust).length) {\n printMessage(\n `\\nSAML2 Circles Of Trust (${\n Object.entries(journeyData.circlesOfTrust).length\n }):`,\n 'data'\n );\n for (const cotData of Object.values(journeyData.circlesOfTrust)) {\n printMessage(\n `- ${CirclesOfTrust.getOneLineDescription(cotData)}`,\n 'data'\n );\n }\n }\n}\n\n/**\n * Describe a journey in markdown:\n * - Properties, tags, description, name, metadata\n * - Inner tree dependency tree\n * - Node type summary\n * - Nodes\n * - Themes\n * - Scripts\n * - Email templates\n * - Social identity providers\n * - SAML2 entity providers\n * - SAML2 circles of trust\n * @param {SingleTreeExportInterface} journeyData journey export object\n * @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function\n */\nexport async function describeJourneyMd(\n journeyData: SingleTreeExportInterface,\n resolveTreeExport: TreeExportResolverInterface = onlineTreeExportResolver\n) {\n const allNodes = {\n ...journeyData.nodes,\n ...journeyData.innerNodes,\n };\n const nodeTypeMap = {};\n\n for (const nodeData of Object.values(allNodes)) {\n if (nodeTypeMap[nodeData._type._id]) {\n nodeTypeMap[nodeData._type._id] += 1;\n } else {\n nodeTypeMap[nodeData._type._id] = 1;\n }\n }\n\n // initialize AM version from file\n if (!state.getAmVersion() && journeyData.meta?.originAmVersion) {\n state.setAmVersion(journeyData.meta.originAmVersion);\n }\n\n // Journey Name\n printMessage(\n `# ${getOneLineDescriptionMd(journeyData.tree)} - ${\n journeyData.tree.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n }, ${getJourneyClassificationMd(journeyData).join(', ')}`,\n 'data'\n );\n\n // Categories/Tags\n if (\n journeyData.tree.uiConfig?.categories &&\n journeyData.tree.uiConfig.categories != '[]'\n ) {\n printMessage(\n `\\`${JSON.parse(journeyData.tree.uiConfig.categories).join('`, `')}\\``,\n 'data'\n );\n }\n\n // Description\n if (journeyData.tree.description) {\n printMessage(`\\n${journeyData.tree.description}`, 'data');\n }\n\n // Journey image\n printMessage(`\\n[]()\\n`, 'data');\n\n // Dependency Tree\n const descendents = await getTreeDescendents(journeyData, resolveTreeExport);\n printMessage(describeTreeDescendentsMd(descendents), 'data');\n\n // Node Types\n if (Object.entries(nodeTypeMap).length) {\n printMessage(\n `## Node Types (${Object.entries(nodeTypeMap).length})`,\n 'data'\n );\n printMessage('| Count | Type | Classification |', 'data');\n printMessage('| -----:| ---- | -------------- |', 'data');\n for (const [nodeType, count] of Object.entries(nodeTypeMap)) {\n printMessage(\n `| ${String(count)} | ${nodeType} | ${Node.getNodeClassificationMd(\n nodeType\n ).join('<br>')} |`,\n 'data'\n );\n }\n }\n\n // Nodes\n if (Object.entries(allNodes).length) {\n printMessage(`## Nodes (${Object.entries(allNodes).length})`, 'data');\n printMessage(Node.getTableHeaderMd(), 'data');\n for (const nodeObj of Object.values<NodeSkeleton>(allNodes)) {\n printMessage(\n `${Node.getTableRowMd(nodeObj, getNodeRef(nodeObj, journeyData))}`,\n 'data'\n );\n }\n }\n\n // Themes\n if (journeyData.themes?.length) {\n printMessage(`## Themes (${journeyData.themes.length})`, 'data');\n printMessage(Theme.getTableHeaderMd(), 'data');\n for (const themeData of journeyData.themes) {\n printMessage(`${Theme.getTableRowMd(themeData)}`, 'data');\n }\n }\n\n // Scripts\n if (Object.entries(journeyData.scripts).length) {\n printMessage(\n `## Scripts (${Object.entries(journeyData.scripts).length})`,\n 'data'\n );\n printMessage(Script.getTableHeaderMd(), 'data');\n for (const scriptData of Object.values(journeyData.scripts)) {\n printMessage(`${Script.getTableRowMd(scriptData)}`, 'data');\n }\n }\n\n // Email Templates\n if (Object.entries(journeyData.emailTemplates).length) {\n printMessage(\n `## Email Templates (${\n Object.entries(journeyData.emailTemplates).length\n })`,\n 'data'\n );\n printMessage(EmailTemplate.getTableHeaderMd(), 'data');\n for (const templateData of Object.values(journeyData.emailTemplates)) {\n printMessage(`${EmailTemplate.getTableRowMd(templateData)}`, 'data');\n }\n }\n\n // Social Identity Providers\n if (Object.entries(journeyData.socialIdentityProviders).length) {\n printMessage(\n `## Social Identity Providers (${\n Object.entries(journeyData.socialIdentityProviders).length\n })`,\n 'data'\n );\n printMessage(Idp.getTableHeaderMd(), 'data');\n for (const socialIdpData of Object.values(\n journeyData.socialIdentityProviders\n )) {\n printMessage(`${Idp.getTableRowMd(socialIdpData)}`, 'data');\n }\n }\n\n // SAML2 Entity Providers\n if (Object.entries(journeyData.saml2Entities).length) {\n printMessage(\n `## SAML2 Entity Providers (${\n Object.entries(journeyData.saml2Entities).length\n })`,\n 'data'\n );\n printMessage(Saml2.getTableHeaderMd(), 'data');\n for (const entityProviderData of Object.values(journeyData.saml2Entities)) {\n printMessage(`${Saml2.getTableRowMd(entityProviderData)}`, 'data');\n }\n }\n\n // SAML2 Circles Of Trust\n if (Object.entries(journeyData.circlesOfTrust).length) {\n printMessage(\n `## SAML2 Circles Of Trust (${\n Object.entries(journeyData.circlesOfTrust).length\n })`,\n 'data'\n );\n printMessage(CirclesOfTrust.getTableHeaderMd(), 'data');\n for (const cotData of Object.values(journeyData.circlesOfTrust)) {\n printMessage(`${CirclesOfTrust.getTableRowMd(cotData)}`, 'data');\n }\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAYpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,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BACCsF,MAAM,CAACsD,OAAO,CAAC5D,WAAW,CAAC4E,cAAc,CAAC,CAACpF,MAC5C,GAAE,EACH,MACF,CAAC;IACDxE,YAAY,CAACK,cAAc,CAAC8J,gBAAgB,CAAC,CAAC,EAAE,MAAM,CAAC;IACvD,KAAK,MAAMN,OAAO,IAAIvE,MAAM,CAACgC,MAAM,CAACtC,WAAW,CAAC4E,cAAc,CAAC,EAAE;MAC/D5J,YAAY,CAAE,GAAEK,cAAc,CAAC+J,aAAa,CAACP,OAAO,CAAE,EAAC,EAAE,MAAM,CAAC;IAClE;EACF;AACF"}
|
|
@@ -4,7 +4,9 @@ import { createProgressBar, createTable, debugMessage, failSpinner, printMessage
|
|
|
4
4
|
import { saveJsonToFile } from '../utils/ExportImportUtils';
|
|
5
5
|
const {
|
|
6
6
|
getTypedFilename,
|
|
7
|
-
titleCase
|
|
7
|
+
titleCase,
|
|
8
|
+
getFilePath,
|
|
9
|
+
getWorkingDirectory
|
|
8
10
|
} = frodo.utils;
|
|
9
11
|
const {
|
|
10
12
|
readOAuth2Clients,
|
|
@@ -76,9 +78,10 @@ export async function exportOAuth2ClientToFile(clientId, file, options = {
|
|
|
76
78
|
if (file) {
|
|
77
79
|
fileName = file;
|
|
78
80
|
}
|
|
81
|
+
const filePath = getFilePath(fileName, true);
|
|
79
82
|
const exportData = await exportOAuth2Client(clientId, options);
|
|
80
|
-
saveJsonToFile(exportData,
|
|
81
|
-
succeedSpinner(`Exported ${clientId} to ${
|
|
83
|
+
saveJsonToFile(exportData, filePath);
|
|
84
|
+
succeedSpinner(`Exported ${clientId} to ${filePath}.`);
|
|
82
85
|
outcome = true;
|
|
83
86
|
} catch (error) {
|
|
84
87
|
failSpinner(`Error exporting ${clientId}: ${error.message}`);
|
|
@@ -105,9 +108,10 @@ export async function exportOAuth2ClientsToFile(file, options = {
|
|
|
105
108
|
if (file) {
|
|
106
109
|
fileName = file;
|
|
107
110
|
}
|
|
111
|
+
const filePath = getFilePath(fileName, true);
|
|
108
112
|
const exportData = await exportOAuth2Clients(options);
|
|
109
|
-
saveJsonToFile(exportData,
|
|
110
|
-
succeedSpinner(`Exported all clients to ${
|
|
113
|
+
saveJsonToFile(exportData, filePath);
|
|
114
|
+
succeedSpinner(`Exported all clients to ${filePath}.`);
|
|
111
115
|
outcome = true;
|
|
112
116
|
} catch (error) {
|
|
113
117
|
failSpinner(`Error exporting all clients`);
|
|
@@ -135,7 +139,7 @@ export async function exportOAuth2ClientsToFiles(options = {
|
|
|
135
139
|
const file = getTypedFilename(client._id, 'oauth2.app');
|
|
136
140
|
try {
|
|
137
141
|
const exportData = await exportOAuth2Client(client._id, options);
|
|
138
|
-
saveJsonToFile(exportData, file);
|
|
142
|
+
saveJsonToFile(exportData, getFilePath(file, true));
|
|
139
143
|
updateProgressBar(`Exported ${client._id}.`);
|
|
140
144
|
} catch (error) {
|
|
141
145
|
errors.push(error);
|
|
@@ -165,7 +169,7 @@ export async function importOAuth2ClientFromFile(clientId, file, options = {
|
|
|
165
169
|
debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientFromFile: begin`);
|
|
166
170
|
showSpinner(`Importing ${clientId}...`);
|
|
167
171
|
try {
|
|
168
|
-
const data = fs.readFileSync(file, 'utf8');
|
|
172
|
+
const data = fs.readFileSync(getFilePath(file), 'utf8');
|
|
169
173
|
const fileData = JSON.parse(data);
|
|
170
174
|
await importOAuth2Client(clientId, fileData, options);
|
|
171
175
|
outcome = true;
|
|
@@ -189,15 +193,16 @@ export async function importFirstOAuth2ClientFromFile(file, options = {
|
|
|
189
193
|
}) {
|
|
190
194
|
let outcome = false;
|
|
191
195
|
debugMessage(`cli.OAuth2ClientOps.importFirstOAuth2ClientFromFile: begin`);
|
|
192
|
-
|
|
196
|
+
const filePath = getFilePath(file);
|
|
197
|
+
showSpinner(`Importing ${filePath}...`);
|
|
193
198
|
try {
|
|
194
|
-
const data = fs.readFileSync(
|
|
199
|
+
const data = fs.readFileSync(filePath, 'utf8');
|
|
195
200
|
const fileData = JSON.parse(data);
|
|
196
201
|
await importFirstOAuth2Client(fileData, options);
|
|
197
202
|
outcome = true;
|
|
198
|
-
succeedSpinner(`Imported ${
|
|
203
|
+
succeedSpinner(`Imported ${filePath}.`);
|
|
199
204
|
} catch (error) {
|
|
200
|
-
failSpinner(`Error importing ${
|
|
205
|
+
failSpinner(`Error importing ${filePath}.`);
|
|
201
206
|
printMessage(error, 'error');
|
|
202
207
|
}
|
|
203
208
|
debugMessage(`cli.OAuth2ClientOps.importFirstOAuth2ClientFromFile: end`);
|
|
@@ -215,15 +220,16 @@ export async function importOAuth2ClientsFromFile(file, options = {
|
|
|
215
220
|
}) {
|
|
216
221
|
let outcome = false;
|
|
217
222
|
debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFile: begin`);
|
|
218
|
-
|
|
223
|
+
const filePath = getFilePath(file);
|
|
224
|
+
showSpinner(`Importing ${filePath}...`);
|
|
219
225
|
try {
|
|
220
|
-
const data = fs.readFileSync(
|
|
226
|
+
const data = fs.readFileSync(filePath, 'utf8');
|
|
221
227
|
const clientData = JSON.parse(data);
|
|
222
228
|
await importOAuth2Clients(clientData, options);
|
|
223
229
|
outcome = true;
|
|
224
|
-
succeedSpinner(`Imported ${
|
|
230
|
+
succeedSpinner(`Imported ${filePath}.`);
|
|
225
231
|
} catch (error) {
|
|
226
|
-
failSpinner(`Error importing ${
|
|
232
|
+
failSpinner(`Error importing ${filePath}.`);
|
|
227
233
|
printMessage(error, 'error');
|
|
228
234
|
}
|
|
229
235
|
debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFile: end`);
|
|
@@ -241,8 +247,8 @@ export async function importOAuth2ClientsFromFiles(options = {
|
|
|
241
247
|
const errors = [];
|
|
242
248
|
try {
|
|
243
249
|
debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFiles: begin`);
|
|
244
|
-
const names = fs.readdirSync(
|
|
245
|
-
const files = names.filter(name => name.toLowerCase().endsWith('.oauth2.app.json'));
|
|
250
|
+
const names = fs.readdirSync(getWorkingDirectory());
|
|
251
|
+
const files = names.filter(name => name.toLowerCase().endsWith('.oauth2.app.json')).map(name => getFilePath(name));
|
|
246
252
|
createProgressBar(files.length, 'Importing clients...');
|
|
247
253
|
let total = 0;
|
|
248
254
|
for (const file of files) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuth2ClientOps.js","names":["frodo","state","fs","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","saveJsonToFile","getTypedFilename","titleCase","utils","readOAuth2Clients","exportOAuth2Client","exportOAuth2Clients","importOAuth2Client","importFirstOAuth2Client","importOAuth2Clients","oauth2oidc","client","listOAuth2Clients","long","clients","sort","a","b","_id","localeCompare","table","grantTypesMap","authorization_code","client_credentials","refresh_token","password","implicit","forEach","push","coreOAuth2ClientConfig","status","clientType","advancedOAuth2ClientConfig","grantTypes","map","type","join","scopes","redirectionUris","toString","error","exportOAuth2ClientToFile","clientId","file","options","useStringArrays","deps","outcome","fileName","exportData","message","exportOAuth2ClientsToFile","getRealmName","getRealm","exportOAuth2ClientsToFiles","errors","length","importOAuth2ClientFromFile","data","readFileSync","fileData","JSON","parse","importFirstOAuth2ClientFromFile","importOAuth2ClientsFromFile","clientData","importOAuth2ClientsFromFiles","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","application"],"sources":["../../src/ops/OAuth2ClientOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { ReadableStrings } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport type {\n OAuth2ClientExportInterface,\n OAuth2ClientExportOptions,\n OAuth2ClientImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/OAuth2ClientOps';\nimport fs from 'fs';\n\nimport {\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport { saveJsonToFile } from '../utils/ExportImportUtils';\n\nconst { getTypedFilename, titleCase } = frodo.utils;\nconst {\n readOAuth2Clients,\n exportOAuth2Client,\n exportOAuth2Clients,\n importOAuth2Client,\n importFirstOAuth2Client,\n importOAuth2Clients,\n} = frodo.oauth2oidc.client;\n\n/**\n * List OAuth2 clients\n */\nexport async function listOAuth2Clients(long = false) {\n try {\n const clients = await readOAuth2Clients();\n clients.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable([\n 'Client Id',\n 'Status',\n 'Client Type',\n 'Grant Types',\n 'Scopes',\n 'Redirect URIs',\n // 'Description',\n ]);\n const grantTypesMap = {\n authorization_code: 'Authz Code',\n client_credentials: 'Client Creds',\n refresh_token: 'Refresh Token',\n password: 'ROPC',\n 'urn:ietf:params:oauth:grant-type:uma-ticket': 'UMA',\n implicit: 'Implicit',\n 'urn:ietf:params:oauth:grant-type:device_code': 'Device Code',\n 'urn:ietf:params:oauth:grant-type:saml2-bearer': 'SAML2 Bearer',\n 'urn:openid:params:grant-type:ciba': 'CIBA',\n 'urn:ietf:params:oauth:grant-type:token-exchange': 'Token Exchange',\n 'urn:ietf:params:oauth:grant-type:jwt-bearer': 'JWT Bearer',\n };\n clients.forEach((client) => {\n table.push([\n client._id,\n client.coreOAuth2ClientConfig.status === 'Active'\n ? 'Active'['brightGreen']\n : (client.coreOAuth2ClientConfig.status as string)['brightRed'],\n client.coreOAuth2ClientConfig.clientType,\n (client.advancedOAuth2ClientConfig.grantTypes as ReadableStrings)\n .map((type) => grantTypesMap[type])\n .join('\\n'),\n (client.coreOAuth2ClientConfig.scopes as ReadableStrings).join('\\n'),\n (client.coreOAuth2ClientConfig.redirectionUris as string[]).join(\n '\\n'\n ),\n // wordwrap(client.description, 30),\n ]);\n });\n printMessage(table.toString(), 'data');\n } else {\n clients.forEach((client) => {\n printMessage(`${client._id}`, 'data');\n });\n }\n } catch (error) {\n printMessage(`Error listing oauth2 clients - ${error}`, 'error');\n }\n}\n\n/**\n * Export OAuth2 client to file\n * @param {string} clientId client id\n * @param {string} file file name\n * @param {OAuth2ClientExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportOAuth2ClientToFile(\n clientId: string,\n file: string,\n options: OAuth2ClientExportOptions = { useStringArrays: true, deps: true }\n) {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientToFile: begin`);\n showSpinner(`Exporting ${clientId}...`);\n try {\n let fileName = getTypedFilename(clientId, 'oauth2.app');\n if (file) {\n fileName = file;\n }\n const exportData = await exportOAuth2Client(clientId, options);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported ${clientId} to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${clientId}: ${error.message}`);\n }\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientToFile: end`);\n return outcome;\n}\n\n/**\n * Export all OAuth2 clients to file\n * @param {string} file file name\n * @param {OAuth2ClientExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportOAuth2ClientsToFile(\n file: string,\n options: OAuth2ClientExportOptions = { useStringArrays: true, deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientsToFile: begin`);\n showSpinner(`Exporting all clients...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(frodo.utils.getRealmName(state.getRealm()))}Applications`,\n 'oauth2.app'\n );\n if (file) {\n fileName = file;\n }\n const exportData = await exportOAuth2Clients(options);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported all clients to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting all clients`);\n printMessage(`${error.message}`, 'error');\n }\n debugMessage(\n `cli.OAuth2ClientOps.exportOAuth2ClientsToFile: end [${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Export all OAuth2 clients to separate files\n * @param {OAuth2ClientExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportOAuth2ClientsToFiles(\n options: OAuth2ClientExportOptions = { useStringArrays: true, deps: true }\n) {\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientsToFiles: begin`);\n const errors = [];\n try {\n const clients = await readOAuth2Clients();\n createProgressBar(clients.length, 'Exporting clients...');\n for (const client of clients) {\n const file = getTypedFilename(client._id, 'oauth2.app');\n try {\n const exportData: OAuth2ClientExportInterface =\n await exportOAuth2Client(client._id, options);\n saveJsonToFile(exportData, file);\n updateProgressBar(`Exported ${client._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${client._id}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting client(s) to file(s)`);\n }\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientsToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import first OAuth2 client from file\n * @param {string} clientId client id\n * @param {string} file file name\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importOAuth2ClientFromFile(\n clientId: string,\n file: string,\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientFromFile: begin`);\n showSpinner(`Importing ${clientId}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importOAuth2Client(clientId, fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${clientId}.`);\n } catch (error) {\n failSpinner(`Error importing ${clientId}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first OAuth2 client from file\n * @param {string} file file name\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstOAuth2ClientFromFile(\n file: string,\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.importFirstOAuth2ClientFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstOAuth2Client(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.OAuth2ClientOps.importFirstOAuth2ClientFromFile: end`);\n return outcome;\n}\n\n/**\n * Import OAuth2 clients from file\n * @param {string} file file name\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importOAuth2ClientsFromFile(\n file: string,\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const clientData = JSON.parse(data);\n await importOAuth2Clients(clientData, options);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFile: end`);\n return outcome;\n}\n\n/**\n * Import OAuth2 clients from files\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importOAuth2ClientsFromFiles(\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFiles: begin`);\n const names = fs.readdirSync('.');\n const files = names.filter((name) =>\n name.toLowerCase().endsWith('.oauth2.app.json')\n );\n createProgressBar(files.length, 'Importing clients...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: OAuth2ClientExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.application).length;\n total += count;\n await importOAuth2Clients(fileData, options);\n updateProgressBar(`Imported ${count} client(s) from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing client(s) from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} client(s) from ${files.length} file(s).`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing client(s) from file(s).`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFiles: 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,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SAASC,cAAc,QAAQ,4BAA4B;AAE3D,MAAM;EAAEC,gBAAgB;EAAEC;AAAU,CAAC,GAAGd,KAAK,CAACe,KAAK;AACnD,MAAM;EACJC,iBAAiB;EACjBC,kBAAkB;EAClBC,mBAAmB;EACnBC,kBAAkB;EAClBC,uBAAuB;EACvBC;AACF,CAAC,GAAGrB,KAAK,CAACsB,UAAU,CAACC,MAAM;;AAE3B;AACA;AACA;AACA,OAAO,eAAeC,iBAAiBA,CAACC,IAAI,GAAG,KAAK,EAAE;EACpD,IAAI;IACF,MAAMC,OAAO,GAAG,MAAMV,iBAAiB,CAAC,CAAC;IACzCU,OAAO,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IAClD,IAAIL,IAAI,EAAE;MACR,MAAMO,KAAK,GAAG5B,WAAW,CAAC,CACxB,WAAW,EACX,QAAQ,EACR,aAAa,EACb,aAAa,EACb,QAAQ,EACR;MACA;MAAA,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E,OAAO,CAAC;MAC9B;IACF;IACA3C,eAAe,CACZ,sBAAqB6E,KAAM,mBAAkBL,KAAK,CAACb,MAAO,WAC7D,CAAC;EACH,CAAC,CAAC,OAAOhB,KAAK,EAAE;IACde,MAAM,CAAC3B,IAAI,CAACY,KAAK,CAAC;IAClB3C,eAAe,CAAE,yCAAwC,CAAC;IAC1DF,YAAY,CAAC6C,KAAK,EAAE,OAAO,CAAC;EAC9B;EACA/C,YAAY,CAAE,uDAAsD,CAAC;EACrE,OAAO,CAAC,KAAK8D,MAAM,CAACC,MAAM;AAC5B"}
|
|
1
|
+
{"version":3,"file":"OAuth2ClientOps.js","names":["frodo","state","fs","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","saveJsonToFile","getTypedFilename","titleCase","getFilePath","getWorkingDirectory","utils","readOAuth2Clients","exportOAuth2Client","exportOAuth2Clients","importOAuth2Client","importFirstOAuth2Client","importOAuth2Clients","oauth2oidc","client","listOAuth2Clients","long","clients","sort","a","b","_id","localeCompare","table","grantTypesMap","authorization_code","client_credentials","refresh_token","password","implicit","forEach","push","coreOAuth2ClientConfig","status","clientType","advancedOAuth2ClientConfig","grantTypes","map","type","join","scopes","redirectionUris","toString","error","exportOAuth2ClientToFile","clientId","file","options","useStringArrays","deps","outcome","fileName","filePath","exportData","message","exportOAuth2ClientsToFile","getRealmName","getRealm","exportOAuth2ClientsToFiles","errors","length","importOAuth2ClientFromFile","data","readFileSync","fileData","JSON","parse","importFirstOAuth2ClientFromFile","importOAuth2ClientsFromFile","clientData","importOAuth2ClientsFromFiles","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","application"],"sources":["../../src/ops/OAuth2ClientOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { ReadableStrings } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport type {\n OAuth2ClientExportInterface,\n OAuth2ClientExportOptions,\n OAuth2ClientImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/OAuth2ClientOps';\nimport fs from 'fs';\n\nimport {\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport { saveJsonToFile } from '../utils/ExportImportUtils';\n\nconst { getTypedFilename, titleCase, getFilePath, getWorkingDirectory } =\n frodo.utils;\nconst {\n readOAuth2Clients,\n exportOAuth2Client,\n exportOAuth2Clients,\n importOAuth2Client,\n importFirstOAuth2Client,\n importOAuth2Clients,\n} = frodo.oauth2oidc.client;\n\n/**\n * List OAuth2 clients\n */\nexport async function listOAuth2Clients(long = false) {\n try {\n const clients = await readOAuth2Clients();\n clients.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable([\n 'Client Id',\n 'Status',\n 'Client Type',\n 'Grant Types',\n 'Scopes',\n 'Redirect URIs',\n // 'Description',\n ]);\n const grantTypesMap = {\n authorization_code: 'Authz Code',\n client_credentials: 'Client Creds',\n refresh_token: 'Refresh Token',\n password: 'ROPC',\n 'urn:ietf:params:oauth:grant-type:uma-ticket': 'UMA',\n implicit: 'Implicit',\n 'urn:ietf:params:oauth:grant-type:device_code': 'Device Code',\n 'urn:ietf:params:oauth:grant-type:saml2-bearer': 'SAML2 Bearer',\n 'urn:openid:params:grant-type:ciba': 'CIBA',\n 'urn:ietf:params:oauth:grant-type:token-exchange': 'Token Exchange',\n 'urn:ietf:params:oauth:grant-type:jwt-bearer': 'JWT Bearer',\n };\n clients.forEach((client) => {\n table.push([\n client._id,\n client.coreOAuth2ClientConfig.status === 'Active'\n ? 'Active'['brightGreen']\n : (client.coreOAuth2ClientConfig.status as string)['brightRed'],\n client.coreOAuth2ClientConfig.clientType,\n (client.advancedOAuth2ClientConfig.grantTypes as ReadableStrings)\n .map((type) => grantTypesMap[type])\n .join('\\n'),\n (client.coreOAuth2ClientConfig.scopes as ReadableStrings).join('\\n'),\n (client.coreOAuth2ClientConfig.redirectionUris as string[]).join(\n '\\n'\n ),\n // wordwrap(client.description, 30),\n ]);\n });\n printMessage(table.toString(), 'data');\n } else {\n clients.forEach((client) => {\n printMessage(`${client._id}`, 'data');\n });\n }\n } catch (error) {\n printMessage(`Error listing oauth2 clients - ${error}`, 'error');\n }\n}\n\n/**\n * Export OAuth2 client to file\n * @param {string} clientId client id\n * @param {string} file file name\n * @param {OAuth2ClientExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportOAuth2ClientToFile(\n clientId: string,\n file: string,\n options: OAuth2ClientExportOptions = { useStringArrays: true, deps: true }\n) {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientToFile: begin`);\n showSpinner(`Exporting ${clientId}...`);\n try {\n let fileName = getTypedFilename(clientId, 'oauth2.app');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportOAuth2Client(clientId, options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${clientId} to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${clientId}: ${error.message}`);\n }\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientToFile: end`);\n return outcome;\n}\n\n/**\n * Export all OAuth2 clients to file\n * @param {string} file file name\n * @param {OAuth2ClientExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportOAuth2ClientsToFile(\n file: string,\n options: OAuth2ClientExportOptions = { useStringArrays: true, deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientsToFile: begin`);\n showSpinner(`Exporting all clients...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(frodo.utils.getRealmName(state.getRealm()))}Applications`,\n 'oauth2.app'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportOAuth2Clients(options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all clients to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting all clients`);\n printMessage(`${error.message}`, 'error');\n }\n debugMessage(\n `cli.OAuth2ClientOps.exportOAuth2ClientsToFile: end [${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Export all OAuth2 clients to separate files\n * @param {OAuth2ClientExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportOAuth2ClientsToFiles(\n options: OAuth2ClientExportOptions = { useStringArrays: true, deps: true }\n) {\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientsToFiles: begin`);\n const errors = [];\n try {\n const clients = await readOAuth2Clients();\n createProgressBar(clients.length, 'Exporting clients...');\n for (const client of clients) {\n const file = getTypedFilename(client._id, 'oauth2.app');\n try {\n const exportData: OAuth2ClientExportInterface =\n await exportOAuth2Client(client._id, options);\n saveJsonToFile(exportData, getFilePath(file, true));\n updateProgressBar(`Exported ${client._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${client._id}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting client(s) to file(s)`);\n }\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientsToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import first OAuth2 client from file\n * @param {string} clientId client id\n * @param {string} file file name\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importOAuth2ClientFromFile(\n clientId: string,\n file: string,\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientFromFile: begin`);\n showSpinner(`Importing ${clientId}...`);\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n await importOAuth2Client(clientId, fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${clientId}.`);\n } catch (error) {\n failSpinner(`Error importing ${clientId}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first OAuth2 client from file\n * @param {string} file file name\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstOAuth2ClientFromFile(\n file: string,\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.importFirstOAuth2ClientFromFile: begin`);\n const filePath = getFilePath(file);\n showSpinner(`Importing ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstOAuth2Client(fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing ${filePath}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importFirstOAuth2ClientFromFile: end`);\n return outcome;\n}\n\n/**\n * Import OAuth2 clients from file\n * @param {string} file file name\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importOAuth2ClientsFromFile(\n file: string,\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFile: begin`);\n const filePath = getFilePath(file);\n showSpinner(`Importing ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const clientData = JSON.parse(data);\n await importOAuth2Clients(clientData, options);\n outcome = true;\n succeedSpinner(`Imported ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing ${filePath}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFile: end`);\n return outcome;\n}\n\n/**\n * Import OAuth2 clients from files\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importOAuth2ClientsFromFiles(\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFiles: begin`);\n const names = fs.readdirSync(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.oauth2.app.json'))\n .map((name) => getFilePath(name));\n createProgressBar(files.length, 'Importing clients...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: OAuth2ClientExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.application).length;\n total += count;\n await importOAuth2Clients(fileData, options);\n updateProgressBar(`Imported ${count} client(s) from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing client(s) from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} client(s) from ${files.length} file(s).`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing client(s) from file(s).`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFiles: 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,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SAASC,cAAc,QAAQ,4BAA4B;AAE3D,MAAM;EAAEC,gBAAgB;EAAEC,SAAS;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GACrEhB,KAAK,CAACiB,KAAK;AACb,MAAM;EACJC,iBAAiB;EACjBC,kBAAkB;EAClBC,mBAAmB;EACnBC,kBAAkB;EAClBC,uBAAuB;EACvBC;AACF,CAAC,GAAGvB,KAAK,CAACwB,UAAU,CAACC,MAAM;;AAE3B;AACA;AACA;AACA,OAAO,eA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ectTable, createProgressBar, createTable, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
|
|
4
4
|
import { getTypedFilename, saveJsonToFile, titleCase } from '../utils/ExportImportUtils';
|
|
5
5
|
const {
|
|
6
|
-
getRealmName
|
|
6
|
+
getRealmName,
|
|
7
|
+
getFilePath,
|
|
8
|
+
getWorkingDirectory
|
|
7
9
|
} = frodo.utils;
|
|
8
10
|
const {
|
|
9
11
|
readPolicies,
|
|
@@ -244,9 +246,10 @@ export async function exportPolicyToFile(policyId, file, options = {
|
|
|
244
246
|
if (file) {
|
|
245
247
|
fileName = file;
|
|
246
248
|
}
|
|
249
|
+
const filePath = getFilePath(fileName, true);
|
|
247
250
|
const exportData = await exportPolicy(policyId, options);
|
|
248
|
-
saveJsonToFile(exportData,
|
|
249
|
-
succeedSpinner(`Exported ${policyId} to ${
|
|
251
|
+
saveJsonToFile(exportData, filePath);
|
|
252
|
+
succeedSpinner(`Exported ${policyId} to ${filePath}.`);
|
|
250
253
|
outcome = true;
|
|
251
254
|
} catch (error) {
|
|
252
255
|
failSpinner(`Error exporting ${policyId}: ${error.message}`);
|
|
@@ -274,9 +277,10 @@ export async function exportPoliciesToFile(file, options = {
|
|
|
274
277
|
if (file) {
|
|
275
278
|
fileName = file;
|
|
276
279
|
}
|
|
280
|
+
const filePath = getFilePath(fileName, true);
|
|
277
281
|
const exportData = await exportPolicies(options);
|
|
278
|
-
saveJsonToFile(exportData,
|
|
279
|
-
succeedSpinner(`Exported all policy sets to ${
|
|
282
|
+
saveJsonToFile(exportData, filePath);
|
|
283
|
+
succeedSpinner(`Exported all policy sets to ${filePath}.`);
|
|
280
284
|
outcome = true;
|
|
281
285
|
} catch (error) {
|
|
282
286
|
failSpinner(`Error exporting policy sets: ${error.message}`);
|
|
@@ -305,9 +309,10 @@ export async function exportPoliciesByPolicySetToFile(policySetId, file, options
|
|
|
305
309
|
if (file) {
|
|
306
310
|
fileName = file;
|
|
307
311
|
}
|
|
312
|
+
const filePath = getFilePath(fileName, true);
|
|
308
313
|
const exportData = await exportPoliciesByPolicySet(policySetId, options);
|
|
309
|
-
saveJsonToFile(exportData,
|
|
310
|
-
succeedSpinner(`Exported all policy sets to ${
|
|
314
|
+
saveJsonToFile(exportData, filePath);
|
|
315
|
+
succeedSpinner(`Exported all policy sets to ${filePath}.`);
|
|
311
316
|
outcome = true;
|
|
312
317
|
} catch (error) {
|
|
313
318
|
failSpinner(`Error exporting policy sets: ${error.message}`);
|
|
@@ -335,7 +340,7 @@ export async function exportPoliciesToFiles(options = {
|
|
|
335
340
|
const file = getTypedFilename(policy._id, 'policy.authz');
|
|
336
341
|
try {
|
|
337
342
|
const exportData = await exportPolicy(policy._id, options);
|
|
338
|
-
saveJsonToFile(exportData, file);
|
|
343
|
+
saveJsonToFile(exportData, getFilePath(file, true));
|
|
339
344
|
updateProgressBar(`Exported ${policy._id}.`);
|
|
340
345
|
} catch (error) {
|
|
341
346
|
errors.push(error);
|
|
@@ -370,7 +375,7 @@ export async function exportPoliciesByPolicySetToFiles(policySetId, options = {
|
|
|
370
375
|
const file = getTypedFilename(policy._id, 'policy.authz');
|
|
371
376
|
try {
|
|
372
377
|
const exportData = await exportPolicy(policy._id, options);
|
|
373
|
-
saveJsonToFile(exportData, file);
|
|
378
|
+
saveJsonToFile(exportData, getFilePath(file, true));
|
|
374
379
|
updateProgressBar(`Exported ${policy._id}.`);
|
|
375
380
|
} catch (error) {
|
|
376
381
|
errors.push(error);
|
|
@@ -401,7 +406,7 @@ export async function importPolicyFromFile(policyId, file, options = {
|
|
|
401
406
|
debugMessage(`cli.PolicyOps.importPolicyFromFile: begin`);
|
|
402
407
|
showSpinner(`Importing ${policyId}...`);
|
|
403
408
|
try {
|
|
404
|
-
const data = fs.readFileSync(file, 'utf8');
|
|
409
|
+
const data = fs.readFileSync(getFilePath(file), 'utf8');
|
|
405
410
|
const fileData = JSON.parse(data);
|
|
406
411
|
await importPolicy(policyId, fileData, options);
|
|
407
412
|
outcome = true;
|
|
@@ -426,15 +431,16 @@ export async function importFirstPolicyFromFile(file, options = {
|
|
|
426
431
|
}) {
|
|
427
432
|
let outcome = false;
|
|
428
433
|
debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: begin`);
|
|
429
|
-
|
|
434
|
+
const filePath = getFilePath(file);
|
|
435
|
+
showSpinner(`Importing first policy from ${filePath}...`);
|
|
430
436
|
try {
|
|
431
|
-
const data = fs.readFileSync(
|
|
437
|
+
const data = fs.readFileSync(filePath, 'utf8');
|
|
432
438
|
const fileData = JSON.parse(data);
|
|
433
439
|
const policy = await importFirstPolicy(fileData, options);
|
|
434
440
|
outcome = true;
|
|
435
|
-
succeedSpinner(`Imported first policy with id '${policy._id}' from ${
|
|
441
|
+
succeedSpinner(`Imported first policy with id '${policy._id}' from ${filePath}.`);
|
|
436
442
|
} catch (error) {
|
|
437
|
-
failSpinner(`Error importing first policy from ${
|
|
443
|
+
failSpinner(`Error importing first policy from ${filePath}.`);
|
|
438
444
|
printMessage(error, 'error');
|
|
439
445
|
}
|
|
440
446
|
debugMessage(`cli.PolicySetOps.importFirstPolicyFromFile: end`);
|
|
@@ -453,15 +459,16 @@ export async function importPoliciesFromFile(file, options = {
|
|
|
453
459
|
}) {
|
|
454
460
|
let outcome = false;
|
|
455
461
|
debugMessage(`cli.PolicyOps.importPoliciesFromFile: begin`);
|
|
456
|
-
|
|
462
|
+
const filePath = getFilePath(file);
|
|
463
|
+
showSpinner(`Importing ${filePath}...`);
|
|
457
464
|
try {
|
|
458
|
-
const data = fs.readFileSync(
|
|
465
|
+
const data = fs.readFileSync(filePath, 'utf8');
|
|
459
466
|
const fileData = JSON.parse(data);
|
|
460
467
|
await importPolicies(fileData, options);
|
|
461
468
|
outcome = true;
|
|
462
|
-
succeedSpinner(`Imported ${
|
|
469
|
+
succeedSpinner(`Imported ${filePath}${options.policySetName ? ' into policy set ' + options.policySetName : '.'}`);
|
|
463
470
|
} catch (error) {
|
|
464
|
-
failSpinner(`Error importing ${
|
|
471
|
+
failSpinner(`Error importing ${filePath}${options.policySetName ? ' into policy set ' + options.policySetName : '.'}`);
|
|
465
472
|
printMessage(error, 'error');
|
|
466
473
|
}
|
|
467
474
|
debugMessage(`cli.PolicyOps.importPoliciesFromFile: end`);
|
|
@@ -480,8 +487,8 @@ export async function importPoliciesFromFiles(options = {
|
|
|
480
487
|
const errors = [];
|
|
481
488
|
try {
|
|
482
489
|
debugMessage(`cli.PolicyOps.importPoliciesFromFiles: begin`);
|
|
483
|
-
const names = fs.readdirSync(
|
|
484
|
-
const files = names.filter(name => name.toLowerCase().endsWith('.policy.authz.json'));
|
|
490
|
+
const names = fs.readdirSync(getWorkingDirectory());
|
|
491
|
+
const files = names.filter(name => name.toLowerCase().endsWith('.policy.authz.json')).map(name => getFilePath(name));
|
|
485
492
|
createProgressBar(files.length, 'Importing policies...');
|
|
486
493
|
let total = 0;
|
|
487
494
|
for (const file of files) {
|