@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
package/esm/ops/IdmOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdmOps.js","names":["frodo","fs","fse","path","propertiesReader","replaceall","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","readFiles","unSubstituteEnvParams","areScriptHooksValid","utils","testConnectorServers","readConfigEntities","readConfigEntity","updateConfigEntity","idm","config","queryManagedObjects","managed","warnAboutOfflineConnectorServers","all","offline","filter","status","ok","map","name","length","join","error","message","listAllConfigEntities","configurations","configEntity","_id","readConfigEntitiesError","exportConfigEntity","id","file","fileName","writeFile","JSON","stringify","err","exportAllRawConfigEntities","directory","existsSync","mkdirSync","undefined","entityPromises","push","catch","readConfigEntityError","_readConfigEntityErro","_readConfigEntityErro2","_readConfigEntityErro3","_readConfigEntityErro4","_readConfigEntityErro5","_readConfigEntityErro6","response","data","includes","reason","_readConfigEntityErro7","results","Promise","item","outputFile","exportAllConfigEntities","entitiesFile","envFile","entriesToExport","readFile","entriesData","parse","envParams","configEntityString","each","key","value","importConfigEntityByIdFromFile","entityId","validate","fileData","readFileSync","resolve","process","cwd","entityData","isValid","updateConfigEntityError","importConfigEntityFromFile","importAllRawConfigEntities","baseDirectory","files","jsonFiles","toLowerCase","endsWith","content","substring","everyScriptValid","jsObject","isScriptValid","allSettled","errors","result","importAllConfigEntities","entriesToImport","envReader","unsubstituted","countManagedObjects","type"],"sources":["../../src/ops/IdmOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\n\nimport {\n createProgressIndicator,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename, readFiles } from '../utils/ExportImportUtils';\n\nconst { unSubstituteEnvParams, areScriptHooksValid } = frodo.utils;\nconst {\n testConnectorServers,\n readConfigEntities,\n readConfigEntity,\n updateConfigEntity,\n} = frodo.idm.config;\nconst { queryManagedObjects } = frodo.idm.managed;\n\n/**\n * Warn about and list offline remote connector servers\n */\nexport async function warnAboutOfflineConnectorServers() {\n try {\n const all = await testConnectorServers();\n const offline = all\n .filter((status) => !status.ok)\n .map((status) => status.name);\n if (offline.length) {\n printMessage(\n `\\nThe following connector server(s) are offline and their connectors and configuration unavailable:\\n${offline.join(\n '\\n'\n )}`,\n 'warn'\n );\n }\n } catch (error) {\n printMessage(error, 'error');\n printMessage(\n `Error getting offline connector servers: ${error.message}`,\n 'error'\n );\n }\n}\n\n/**\n * List all IDM configuration objects\n */\nexport async function listAllConfigEntities() {\n try {\n const configurations = await readConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n } catch (readConfigEntitiesError) {\n printMessage(readConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${readConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export an IDM configuration object.\n * @param {String} id the desired configuration object\n * @param {String} file optional export file\n */\nexport async function exportConfigEntity(id, file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`${id}`, 'idm');\n }\n const configEntity = await readConfigEntity(id);\n fs.writeFile(fileName, JSON.stringify(configEntity, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${id} export to file`, 'error');\n }\n return '';\n });\n}\n\n/**\n * Export all IDM configuration objects into separate JSON files in a directory specified by <directory>\n * @param {String} directory export directory\n */\nexport async function exportAllRawConfigEntities(directory) {\n try {\n const configurations = await readConfigEntities();\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n entityPromises.push(\n readConfigEntity(configEntity._id).catch((readConfigEntityError) => {\n if (\n !(\n readConfigEntityError.response?.status === 403 &&\n readConfigEntityError.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n ) &&\n !(\n // list of config entities, which do not exist by default or ever.\n (\n [\n 'script',\n 'notificationFactory',\n 'apiVersion',\n 'metrics',\n 'repo.init',\n 'endpoint/validateQueryFilter',\n 'endpoint/oauthproxy',\n 'external.rest',\n 'scheduler',\n 'org.apache.felix.fileinstall/openidm',\n 'cluster',\n 'endpoint/mappingDetails',\n 'fieldPolicy/teammember',\n ].includes(configEntity._id) &&\n readConfigEntityError.response?.status === 404 &&\n readConfigEntityError.response?.data?.reason === 'Not Found'\n )\n ) &&\n // https://bugster.forgerock.org/jira/browse/OPENIDM-18270\n !(\n readConfigEntityError.response?.status === 404 &&\n readConfigEntityError.response?.data?.message ===\n 'No configuration exists for id org.apache.felix.fileinstall/openidm'\n )\n ) {\n printMessage(readConfigEntityError.response?.data, 'error');\n printMessage(\n `Error getting config entity ${configEntity._id}: ${readConfigEntityError}`,\n 'error'\n );\n }\n })\n );\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n fse.outputFile(\n `${directory}/${item._id}.json`,\n JSON.stringify(item, null, 2),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator('Exported config objects.', 'success');\n } catch (readConfigEntitiesError) {\n printMessage(readConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${readConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export all IDM configuration objects\n * @param {String} directory export directory\n * @param {String} entitiesFile JSON file that specifies the config entities to export/import\n * @param {String} envFile File that defines environment specific variables for replacement during configuration export/import\n */\nexport async function exportAllConfigEntities(\n directory,\n entitiesFile,\n envFile\n) {\n let entriesToExport = [];\n // read list of entities to export\n fs.readFile(entitiesFile, 'utf8', async (err, data) => {\n if (err) throw err;\n const entriesData = JSON.parse(data);\n entriesToExport = entriesData.idm;\n // console.log(`entriesToExport ${entriesToExport}`);\n\n // read list of configs to parameterize for environment specific values\n const envParams = propertiesReader(envFile);\n\n try {\n const configurations = await readConfigEntities();\n // create export directory if not exist\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(readConfigEntity(configEntity._id));\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n let configEntityString = JSON.stringify(item, null, 2);\n envParams.each((key, value) => {\n configEntityString = replaceall(\n value,\n `\\${${key}}`,\n configEntityString\n );\n });\n fse.outputFile(\n `${directory}/${item._id}.json`,\n configEntityString,\n (error) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${error}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator(null, 'success');\n } catch (readConfigEntitiesError) {\n printMessage(readConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${readConfigEntitiesError}`,\n 'error'\n );\n }\n });\n}\n\n/**\n * Import an IDM configuration object by id from file.\n * @param entityId the configuration object to import\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityByIdFromFile(\n entityId: string,\n file?: string,\n validate?: boolean\n) {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n\n const entityData = JSON.parse(fileData);\n const isValid = areScriptHooksValid(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await updateConfigEntity(entityId, entityData);\n } catch (updateConfigEntityError) {\n printMessage(updateConfigEntityError, 'error');\n printMessage(`Error: ${updateConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import IDM configuration object from file.\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityFromFile(\n file: string,\n validate?: boolean\n) {\n const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n const entityData = JSON.parse(fileData);\n const entityId = entityData._id;\n const isValid = areScriptHooksValid(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await updateConfigEntity(entityId, entityData);\n } catch (updateConfigEntityError) {\n printMessage(updateConfigEntityError, 'error');\n printMessage(`Error: ${updateConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>\n * @param baseDirectory export directory\n * @param validate validate script hooks\n */\nexport async function importAllRawConfigEntities(\n baseDirectory: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ path, content }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = areScriptHooksValid(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles.map((file) => {\n return updateConfigEntity(file.entityId, JSON.parse(file.content));\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Import all IDM configuration objects\n * @param baseDirectory import directory\n * @param entitiesFile JSON file that specifies the config entities to export/import\n * @param envFile File that defines environment specific variables for replacement during configuration export/import\n * @param validate validate script hooks\n */\nexport async function importAllConfigEntities(\n baseDirectory: string,\n entitiesFile: string,\n envFile: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const entriesToImport = JSON.parse(fs.readFileSync(entitiesFile, 'utf8')).idm;\n\n const envReader = propertiesReader(envFile);\n\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content, path }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = areScriptHooksValid(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles\n .filter(({ entityId }) => {\n return entriesToImport.includes(entityId);\n })\n .map(({ entityId, content }) => {\n const unsubstituted = unSubstituteEnvParams(content, envReader);\n return updateConfigEntity(entityId, JSON.parse(unsubstituted));\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Count number of managed objects of a given type\n * @param {String} type managed object type, e.g. alpha_user\n */\nexport async function countManagedObjects(type: string) {\n try {\n const result = await queryManagedObjects(type);\n printMessage(`${type}: ${result.length}`, 'data');\n } catch (error) {\n printMessage(error.response.data, 'error');\n printMessage(`Error querying managed objects by type: ${error}`, 'error');\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAC1B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,gBAAgB,MAAM,mBAAmB;AAChD,OAAOC,UAAU,MAAM,YAAY;AAEnC,SACEC,uBAAuB,EACvBC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,4BAA4B;AAExE,MAAM;EAAEC,qBAAqB;EAAEC;AAAoB,CAAC,GAAGZ,KAAK,CAACa,KAAK;AAClE,MAAM;EACJC,oBAAoB;EACpBC,kBAAkB;EAClBC,gBAAgB;EAChBC;AACF,CAAC,GAAGjB,KAAK,CAACkB,GAAG,CAACC,MAAM;AACpB,MAAM;EAAEC;AAAoB,CAAC,GAAGpB,KAAK,CAACkB,GAAG,CAACG,OAAO;;AAEjD;AACA;AACA;AACA,OAAO,eAAeC,gCAAgCA,CAAA,EAAG;EACvD,IAAI;IACF,MAAMC,GAAG,GAAG,MAAMT,oBAAoB,CAAC,CAAC;IACxC,MAAMU,OAAO,GAAGD,GAAG,CAChBE,MAAM,CAAEC,MAAM,IAAK,CAACA,MAAM,CAACC,EAAE,CAAC,CAC9BC,GAAG,CAAEF,MAAM,IAAKA,MAAM,CAACG,IAAI,CAAC;IAC/B,IAAIL,OAAO,CAACM,MAA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AK,UACjE,CAAC;EAED,IAAIiF,MAAM,CAAC7E,MAAM,GAAG,CAAC,EAAE;IACrBvB,YAAY,CAAE,oBAAmBoG,MAAM,CAAC7E,MAAO,kBAAiB,EAAE,OAAO,CAAC;IAC1E,KAAK,MAAME,KAAK,IAAI2E,MAAM,EAAE;MAC1BpG,YAAY,CAAE,KAAIyB,KAAK,CAACiC,MAAO,EAAC,EAAE,OAAO,CAAC;IAC5C;IACAzD,qBAAqB,CAClB,oBAAmBmG,MAAM,CAAC7E,MAAO,iBAAgB,EAClD,OACF,CAAC;IACD;EACF;EAEAtB,qBAAqB,CAAE,YAAW2D,OAAO,CAACrC,MAAO,iBAAgB,EAAE,SAAS,CAAC;AAC/E;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAemF,mBAAmBA,CAACC,IAAY,EAAE;EACtD,IAAI;IACF,MAAMN,MAAM,GAAG,MAAMxF,mBAAmB,CAAC8F,IAAI,CAAC;IAC9C3G,YAAY,CAAE,GAAE2G,IAAK,KAAIN,MAAM,CAAC9E,MAAO,EAAC,EAAE,MAAM,CAAC;EACnD,CAAC,CAAC,OAAOE,KAAK,EAAE;IACdzB,YAAY,CAACyB,KAAK,CAAC8B,QAAQ,CAACC,IAAI,EAAE,OAAO,CAAC;IAC1CxD,YAAY,CAAE,2CAA0CyB,KAAM,EAAC,EAAE,OAAO,CAAC;EAC3E;AACF"}
|
|
1
|
+
{"version":3,"file":"IdmOps.js","names":["frodo","state","fs","fse","path","propertiesReader","replaceall","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","readFiles","unSubstituteEnvParams","areScriptHooksValid","getFilePath","utils","testConnectorServers","readConfigEntities","readConfigEntity","updateConfigEntity","idm","config","queryManagedObjects","managed","warnAboutOfflineConnectorServers","all","offline","filter","status","ok","map","name","length","join","error","message","listAllConfigEntities","configurations","configEntity","_id","readConfigEntitiesError","exportConfigEntity","id","file","fileName","writeFile","JSON","stringify","err","exportAllRawConfigEntities","undefined","entityPromises","push","catch","readConfigEntityError","_readConfigEntityErro","_readConfigEntityErro2","_readConfigEntityErro3","_readConfigEntityErro4","_readConfigEntityErro5","_readConfigEntityErro6","response","data","includes","reason","_readConfigEntityErro7","results","Promise","item","outputFile","exportAllConfigEntities","entitiesFile","envFile","entriesToExport","readFile","entriesData","parse","envParams","configEntityString","each","key","value","importConfigEntityByIdFromFile","entityId","validate","fileData","readFileSync","resolve","process","cwd","entityData","isValid","updateConfigEntityError","importConfigEntityFromFile","importAllRawConfigEntities","baseDirectory","getDirectory","existsSync","files","jsonFiles","toLowerCase","endsWith","content","substring","everyScriptValid","jsObject","isScriptValid","allSettled","errors","result","importAllConfigEntities","entriesToImport","envReader","unsubstituted","countManagedObjects","type"],"sources":["../../src/ops/IdmOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\n\nimport {\n createProgressIndicator,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename, readFiles } from '../utils/ExportImportUtils';\n\nconst { unSubstituteEnvParams, areScriptHooksValid, getFilePath } = frodo.utils;\nconst {\n testConnectorServers,\n readConfigEntities,\n readConfigEntity,\n updateConfigEntity,\n} = frodo.idm.config;\nconst { queryManagedObjects } = frodo.idm.managed;\n\n/**\n * Warn about and list offline remote connector servers\n */\nexport async function warnAboutOfflineConnectorServers() {\n try {\n const all = await testConnectorServers();\n const offline = all\n .filter((status) => !status.ok)\n .map((status) => status.name);\n if (offline.length) {\n printMessage(\n `\\nThe following connector server(s) are offline and their connectors and configuration unavailable:\\n${offline.join(\n '\\n'\n )}`,\n 'warn'\n );\n }\n } catch (error) {\n printMessage(error, 'error');\n printMessage(\n `Error getting offline connector servers: ${error.message}`,\n 'error'\n );\n }\n}\n\n/**\n * List all IDM configuration objects\n */\nexport async function listAllConfigEntities() {\n try {\n const configurations = await readConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n } catch (readConfigEntitiesError) {\n printMessage(readConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${readConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export an IDM configuration object.\n * @param {String} id the desired configuration object\n * @param {String} file optional export file\n */\nexport async function exportConfigEntity(id, file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`${id}`, 'idm');\n }\n const configEntity = await readConfigEntity(id);\n fs.writeFile(\n getFilePath(fileName, true),\n JSON.stringify(configEntity, null, 2),\n (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${id} export to file`, 'error');\n }\n return '';\n }\n );\n}\n\n/**\n * Export all IDM configuration objects into separate JSON files in a directory specified by <directory>\n */\nexport async function exportAllRawConfigEntities() {\n try {\n const configurations = await readConfigEntities();\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n entityPromises.push(\n readConfigEntity(configEntity._id).catch((readConfigEntityError) => {\n if (\n !(\n readConfigEntityError.response?.status === 403 &&\n readConfigEntityError.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n ) &&\n !(\n // list of config entities, which do not exist by default or ever.\n (\n [\n 'script',\n 'notificationFactory',\n 'apiVersion',\n 'metrics',\n 'repo.init',\n 'endpoint/validateQueryFilter',\n 'endpoint/oauthproxy',\n 'external.rest',\n 'scheduler',\n 'org.apache.felix.fileinstall/openidm',\n 'cluster',\n 'endpoint/mappingDetails',\n 'fieldPolicy/teammember',\n ].includes(configEntity._id) &&\n readConfigEntityError.response?.status === 404 &&\n readConfigEntityError.response?.data?.reason === 'Not Found'\n )\n ) &&\n // https://bugster.forgerock.org/jira/browse/OPENIDM-18270\n !(\n readConfigEntityError.response?.status === 404 &&\n readConfigEntityError.response?.data?.message ===\n 'No configuration exists for id org.apache.felix.fileinstall/openidm'\n )\n ) {\n printMessage(readConfigEntityError.response?.data, 'error');\n printMessage(\n `Error getting config entity ${configEntity._id}: ${readConfigEntityError}`,\n 'error'\n );\n }\n })\n );\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n fse.outputFile(\n getFilePath(`${item._id}.json`, true),\n JSON.stringify(item, null, 2),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator('Exported config objects.', 'success');\n } catch (readConfigEntitiesError) {\n printMessage(readConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${readConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export all IDM configuration objects\n * @param {String} entitiesFile JSON file that specifies the config entities to export/import\n * @param {String} envFile File that defines environment specific variables for replacement during configuration export/import\n */\nexport async function exportAllConfigEntities(entitiesFile, envFile) {\n let entriesToExport = [];\n // read list of entities to export\n fs.readFile(entitiesFile, 'utf8', async (err, data) => {\n if (err) throw err;\n const entriesData = JSON.parse(data);\n entriesToExport = entriesData.idm;\n // console.log(`entriesToExport ${entriesToExport}`);\n\n // read list of configs to parameterize for environment specific values\n const envParams = propertiesReader(envFile);\n\n try {\n const configurations = await readConfigEntities();\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(readConfigEntity(configEntity._id));\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n let configEntityString = JSON.stringify(item, null, 2);\n envParams.each((key, value) => {\n configEntityString = replaceall(\n value,\n `\\${${key}}`,\n configEntityString\n );\n });\n fse.outputFile(\n getFilePath(`${item._id}.json`, true),\n configEntityString,\n (error) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${error}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator(null, 'success');\n } catch (readConfigEntitiesError) {\n printMessage(readConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${readConfigEntitiesError}`,\n 'error'\n );\n }\n });\n}\n\n/**\n * Import an IDM configuration object by id from file.\n * @param entityId the configuration object to import\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityByIdFromFile(\n entityId: string,\n file?: string,\n validate?: boolean\n) {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const fileData = fs.readFileSync(\n path.resolve(process.cwd(), getFilePath(file)),\n 'utf8'\n );\n\n const entityData = JSON.parse(fileData);\n const isValid = areScriptHooksValid(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await updateConfigEntity(entityId, entityData);\n } catch (updateConfigEntityError) {\n printMessage(updateConfigEntityError, 'error');\n printMessage(`Error: ${updateConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import IDM configuration object from file.\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityFromFile(\n file: string,\n validate?: boolean\n) {\n const fileData = fs.readFileSync(\n path.resolve(process.cwd(), getFilePath(file)),\n 'utf8'\n );\n const entityData = JSON.parse(fileData);\n const entityId = entityData._id;\n const isValid = areScriptHooksValid(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await updateConfigEntity(entityId, entityData);\n } catch (updateConfigEntityError) {\n printMessage(updateConfigEntityError, 'error');\n printMessage(`Error: ${updateConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>\n * @param validate validate script hooks\n */\nexport async function importAllRawConfigEntities(validate?: boolean) {\n const baseDirectory = state.getDirectory();\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ path, content }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = areScriptHooksValid(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles.map((file) => {\n return updateConfigEntity(file.entityId, JSON.parse(file.content));\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Import all IDM configuration objects\n * @param entitiesFile JSON file that specifies the config entities to export/import\n * @param envFile File that defines environment specific variables for replacement during configuration export/import\n * @param validate validate script hooks\n */\nexport async function importAllConfigEntities(\n entitiesFile: string,\n envFile: string,\n validate?: boolean\n) {\n const baseDirectory = state.getDirectory();\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const entriesToImport = JSON.parse(fs.readFileSync(entitiesFile, 'utf8')).idm;\n\n const envReader = propertiesReader(envFile);\n\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content, path }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = areScriptHooksValid(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles\n .filter(({ entityId }) => {\n return entriesToImport.includes(entityId);\n })\n .map(({ entityId, content }) => {\n const unsubstituted = unSubstituteEnvParams(content, envReader);\n return updateConfigEntity(entityId, JSON.parse(unsubstituted));\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Count number of managed objects of a given type\n * @param {String} type managed object type, e.g. alpha_user\n */\nexport async function countManagedObjects(type: string) {\n try {\n const result = await queryManagedObjects(type);\n printMessage(`${type}: ${result.length}`, 'data');\n } catch (error) {\n printMessage(error.response.data, 'error');\n printMessage(`Error querying managed objects by type: ${error}`, 'error');\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAC1B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,gBAAgB,MAAM,mBAAmB;AAChD,OAAOC,UAAU,MAAM,YAAY;AAEnC,SACEC,uBAAuB,EACvBC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,4BAA4B;AAExE,MAAM;EAAEC,qBAAqB;EAAEC,mBAAmB;EAAEC;AAAY,CAAC,GAAGd,KAAK,CAACe,KAAK;AAC/E,MAAM;EACJC,oBAAoB;EACpBC,kBAAkB;EAClBC,gBAAgB;EAChBC;AACF,CAAC,GAAGnB,KAAK,CAACoB,GAAG,CAACC,MAAM;AACpB,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,
|
|
11
11
|
importSocialIdentityProviders
|
|
12
12
|
} = frodo.oauth2oidc.external;
|
|
13
|
+
const {
|
|
14
|
+
getFilePath,
|
|
15
|
+
getWorkingDirectory
|
|
16
|
+
} = frodo.utils;
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
19
|
* Get a one-line description of the social idp object
|
|
@@ -69,12 +73,13 @@ export async function exportSocialIdentityProviderToFile(providerId, file = '')
|
|
|
69
73
|
if (!fileName) {
|
|
70
74
|
fileName = getTypedFilename(providerId, 'idp');
|
|
71
75
|
}
|
|
76
|
+
const filePath = getFilePath(fileName, true);
|
|
72
77
|
createProgressBar(1, `Exporting ${providerId}`);
|
|
73
78
|
try {
|
|
74
|
-
updateProgressBar(`Writing file ${
|
|
79
|
+
updateProgressBar(`Writing file ${filePath}`);
|
|
75
80
|
const fileData = await exportSocialIdentityProvider(providerId);
|
|
76
|
-
saveJsonToFile(fileData,
|
|
77
|
-
stopProgressBar(`Exported ${providerId['brightCyan']} to ${
|
|
81
|
+
saveJsonToFile(fileData, filePath);
|
|
82
|
+
stopProgressBar(`Exported ${providerId['brightCyan']} to ${filePath['brightCyan']}.`);
|
|
78
83
|
} catch (err) {
|
|
79
84
|
stopProgressBar(`${err}`);
|
|
80
85
|
printMessage(`${err}`, 'error');
|
|
@@ -92,7 +97,7 @@ export async function exportSocialIdentityProvidersToFile(file = '') {
|
|
|
92
97
|
fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');
|
|
93
98
|
}
|
|
94
99
|
const fileData = await exportSocialIdentityProviders();
|
|
95
|
-
saveJsonToFile(fileData, fileName);
|
|
100
|
+
saveJsonToFile(fileData, getFilePath(fileName, true));
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
/**
|
|
@@ -107,7 +112,7 @@ export async function exportSocialIdentityProvidersToFiles() {
|
|
|
107
112
|
try {
|
|
108
113
|
const fileName = getTypedFilename(idpData._id, 'idp');
|
|
109
114
|
const fileData = await exportSocialIdentityProvider(idpData._id);
|
|
110
|
-
saveJsonToFile(fileData, fileName);
|
|
115
|
+
saveJsonToFile(fileData, getFilePath(fileName, true));
|
|
111
116
|
updateProgressBar(`Exported provider ${idpData._id}`);
|
|
112
117
|
} catch (error) {
|
|
113
118
|
printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');
|
|
@@ -129,17 +134,18 @@ export async function exportSocialIdentityProvidersToFiles() {
|
|
|
129
134
|
*/
|
|
130
135
|
export async function importSocialIdentityProviderFromFile(providerId, file) {
|
|
131
136
|
let outcome = false;
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
const filePath = getFilePath(file);
|
|
138
|
+
showSpinner(`Importing provider ${providerId} from ${filePath}...`);
|
|
139
|
+
fs.readFile(filePath, 'utf8', async (err, data) => {
|
|
134
140
|
if (err) throw err;
|
|
135
141
|
try {
|
|
136
142
|
const fileData = JSON.parse(data);
|
|
137
143
|
await importSocialIdentityProvider(providerId, fileData);
|
|
138
144
|
outcome = true;
|
|
139
|
-
succeedSpinner(`Successfully imported provider ${providerId} from ${
|
|
145
|
+
succeedSpinner(`Successfully imported provider ${providerId} from ${filePath}.`);
|
|
140
146
|
} catch (error) {
|
|
141
147
|
var _error$response;
|
|
142
|
-
failSpinner(`Error importing provider ${providerId} from ${
|
|
148
|
+
failSpinner(`Error importing provider ${providerId} from ${filePath}.`);
|
|
143
149
|
printMessage(((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || error, 'error');
|
|
144
150
|
}
|
|
145
151
|
});
|
|
@@ -153,17 +159,18 @@ export async function importSocialIdentityProviderFromFile(providerId, file) {
|
|
|
153
159
|
*/
|
|
154
160
|
export async function importFirstSocialIdentityProviderFromFile(file) {
|
|
155
161
|
let outcome = false;
|
|
156
|
-
|
|
157
|
-
|
|
162
|
+
const filePath = getFilePath(file);
|
|
163
|
+
showSpinner(`Importing first provider from ${filePath}...`);
|
|
164
|
+
fs.readFile(filePath, 'utf8', async (err, data) => {
|
|
158
165
|
if (err) throw err;
|
|
159
166
|
try {
|
|
160
167
|
const fileData = JSON.parse(data);
|
|
161
168
|
await importFirstSocialIdentityProvider(fileData);
|
|
162
169
|
outcome = true;
|
|
163
|
-
succeedSpinner(`Successfully imported first provider from ${
|
|
170
|
+
succeedSpinner(`Successfully imported first provider from ${filePath}.`);
|
|
164
171
|
} catch (error) {
|
|
165
172
|
var _error$response2;
|
|
166
|
-
failSpinner(`Error importing first provider from ${
|
|
173
|
+
failSpinner(`Error importing first provider from ${filePath}.`);
|
|
167
174
|
printMessage(((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) || error, 'error');
|
|
168
175
|
}
|
|
169
176
|
});
|
|
@@ -177,17 +184,18 @@ export async function importFirstSocialIdentityProviderFromFile(file) {
|
|
|
177
184
|
*/
|
|
178
185
|
export async function importSocialIdentityProvidersFromFile(file) {
|
|
179
186
|
let outcome = false;
|
|
180
|
-
|
|
181
|
-
|
|
187
|
+
const filePath = getFilePath(file);
|
|
188
|
+
showSpinner(`Importing providers from ${filePath}...`);
|
|
189
|
+
fs.readFile(filePath, 'utf8', async (err, data) => {
|
|
182
190
|
if (err) throw err;
|
|
183
191
|
try {
|
|
184
192
|
const fileData = JSON.parse(data);
|
|
185
193
|
await importSocialIdentityProviders(fileData);
|
|
186
194
|
outcome = true;
|
|
187
|
-
succeedSpinner(`Successfully imported providers from ${
|
|
195
|
+
succeedSpinner(`Successfully imported providers from ${filePath}.`);
|
|
188
196
|
} catch (error) {
|
|
189
197
|
var _error$response3;
|
|
190
|
-
failSpinner(`Error importing providers from ${
|
|
198
|
+
failSpinner(`Error importing providers from ${filePath}.`);
|
|
191
199
|
printMessage(((_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || error, 'error');
|
|
192
200
|
}
|
|
193
201
|
});
|
|
@@ -198,8 +206,8 @@ export async function importSocialIdentityProvidersFromFile(file) {
|
|
|
198
206
|
* Import providers from *.idp.json files in current working directory
|
|
199
207
|
*/
|
|
200
208
|
export async function importSocialIdentityProvidersFromFiles() {
|
|
201
|
-
const names = fs.readdirSync(
|
|
202
|
-
const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.idp.json'));
|
|
209
|
+
const names = fs.readdirSync(getWorkingDirectory());
|
|
210
|
+
const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.idp.json')).map(name => getFilePath(name));
|
|
203
211
|
createProgressBar(jsonFiles.length, 'Importing providers...');
|
|
204
212
|
let total = 0;
|
|
205
213
|
for (const file of jsonFiles) {
|
package/esm/ops/IdpOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdpOps.js","names":["frodo","fs","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getRealmString","getTypedFilename","saveJsonToFile","readSocialIdentityProviders","exportSocialIdentityProvider","exportSocialIdentityProviders","importFirstSocialIdentityProvider","importSocialIdentityProvider","importSocialIdentityProviders","oauth2oidc","external","getOneLineDescription","socialIdpObj","description","_id","_type","getTableHeaderMd","markdown","getTableRowMd","row","enabled","name","listSocialProviders","providers","sort","a","b","localeCompare","forEach","socialIdentityProvider","err","message","exportSocialIdentityProviderToFile","providerId","file","fileName","fileData","exportSocialIdentityProvidersToFile","exportSocialIdentityProvidersToFiles","allIdpsData","length","idpData","error","importSocialIdentityProviderFromFile","outcome","readFile","data","JSON","parse","_error$response","response","importFirstSocialIdentityProviderFromFile","_error$response2","importSocialIdentityProvidersFromFile","_error$response3","importSocialIdentityProvidersFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","total","readFileSync","count","Object","keys","idp"],"sources":["../../src/ops/IdpOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { SocialIdpSkeleton } from '@rockcarver/frodo-lib/types/api/SocialIdentityProvidersApi';\nimport fs from 'fs';\n\nimport {\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n} from '../utils/ExportImportUtils';\n\nconst {\n readSocialIdentityProviders,\n exportSocialIdentityProvider,\n exportSocialIdentityProviders,\n importFirstSocialIdentityProvider,\n importSocialIdentityProvider,\n importSocialIdentityProviders,\n} = frodo.oauth2oidc.external;\n\n/**\n * Get a one-line description of the social idp object\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(socialIdpObj: SocialIdpSkeleton): string {\n const description = `[${socialIdpObj._id['brightCyan']}] ${socialIdpObj._type._id}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Type |\\n';\n markdown += '| ------- | ------ | ---- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the social idp in markdown\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a table-row of the social idp in markdown\n */\nexport function getTableRowMd(socialIdpObj: SocialIdpSkeleton): string {\n const row = `| ${socialIdpObj._id} | ${\n socialIdpObj.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n } | ${socialIdpObj._type.name} |`;\n return row;\n}\n\n/**\n * List providers\n */\nexport async function listSocialProviders() {\n try {\n const providers = await readSocialIdentityProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n } catch (err) {\n printMessage(`listSocialProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n */\nexport async function exportSocialIdentityProviderToFile(\n providerId: string,\n file = ''\n) {\n debugMessage(`cli.IdpOps.exportSocialIdentityProviderToFile: start`);\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'idp');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await exportSocialIdentityProvider(providerId);\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialIdentityProviderToFile: end`);\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n */\nexport async function exportSocialIdentityProvidersToFile(file = '') {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');\n }\n const fileData = await exportSocialIdentityProviders();\n saveJsonToFile(fileData, fileName);\n}\n\n/**\n * Export all providers to individual files\n */\nexport async function exportSocialIdentityProvidersToFiles() {\n debugMessage(`cli.IdpOps.exportSocialIdentityProvidersToFiles: start`);\n try {\n const allIdpsData = await readSocialIdentityProviders();\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n try {\n const fileName = getTypedFilename(idpData._id, 'idp');\n const fileData = await exportSocialIdentityProvider(idpData._id);\n saveJsonToFile(fileData, fileName);\n updateProgressBar(`Exported provider ${idpData._id}`);\n } catch (error) {\n printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');\n }\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n } catch (error) {\n stopProgressBar(`${error}`);\n printMessage(`${error}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialIdentityProvidersToFiles: end`);\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if provider was imported successfully, false otherwise\n */\nexport async function importSocialIdentityProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing provider ${providerId} from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importSocialIdentityProvider(providerId, fileData);\n outcome = true;\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise\n */\nexport async function importFirstSocialIdentityProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing first provider from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importFirstSocialIdentityProvider(fileData);\n outcome = true;\n succeedSpinner(`Successfully imported first provider from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing first provider from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise\n */\nexport async function importSocialIdentityProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing providers from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importSocialIdentityProviders(fileData);\n outcome = true;\n succeedSpinner(`Successfully imported providers from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing providers from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n */\nexport async function importSocialIdentityProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.idp.json')\n );\n\n createProgressBar(jsonFiles.length, 'Importing providers...');\n let total = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await importSocialIdentityProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAE7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,cAAc,EACdC,gBAAgB,EAChBC,cAAc,QACT,4BAA4B;AAEnC,MAAM;EACJC,2BAA2B;EAC3BC,4BAA4B;EAC5BC,6BAA6B;EAC7BC,iCAAiC;EACjCC,4BAA4B;EAC5BC;AACF,CAAC,GAAGlB,KAAK,CAACmB,UAAU,CAACC,QAAQ;;AAE7B;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAACC,YAA+B,EAAU;EAC7E,MAAMC,WAAW,GAAI,IAAGD,YAAY,CAACE,GAAG,CAAC,YAAY,CAAE,KAAIF,YAAY,CAACG,KAAK,CAACD,GAAI,EAAC;EACnF,OAAOD,WAAW;AACpB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,gBAAgBA,CAAA,EAAW;EACzC,IAAIC,QAAQ,GAAG,EAAE;EACjBA,QAAQ,IAAI,+BAA+B;EAC3CA,QAAQ,IAAI,6BAA6B;EACzC,OAAOA,QAAQ;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACN,YAA+B,EAAU;EACrE,MAAMO,GAAG,GAAI,KAAIP,YAAY,CAACE,GAAI,MAChCF,YAAY,CAACQ,OAAO,KAAK,KAAK,GAC1B,gBAAgB,GAChB,8BACL,MAAKR,YAAY,CAACG,KAAK,CAACM,IAAK,IAAG;EACjC,OAAOF,GAAG;AACZ;;AAEA;AACA;AACA;AACA,OAAO,eAAeG,mBAAmBA,CAAA,EAAG;EAC1C,IAAI;IAC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ACF,CAAC,CAAC;EACF,OAAOE,OAAO;AAChB;;AAEA;AACA;AACA;AACA,OAAO,eAAeW,sCAAsCA,CAAA,EAAG;EAC7D,MAAMC,KAAK,GAAGjE,EAAE,CAACkE,WAAW,CAAC,GAAG,CAAC;EACjC,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAEtC,IAAI,IAClCA,IAAI,CAACuC,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,WAAW,CACzC,CAAC;EAEDrE,iBAAiB,CAACkE,SAAS,CAAClB,MAAM,EAAE,wBAAwB,CAAC;EAC7D,IAAIsB,KAAK,GAAG,CAAC;EACb,KAAK,MAAM5B,IAAI,IAAIwB,SAAS,EAAE;IAC5B,MAAMZ,IAAI,GAAGvD,EAAE,CAACwE,YAAY,CAAC7B,IAAI,EAAE,MAAM,CAAC;IAC1C,MAAME,QAAQ,GAAGW,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC;IACjC,MAAMkB,KAAK,GAAGC,MAAM,CAACC,IAAI,CAAC9B,QAAQ,CAAC+B,GAAG,CAAC,CAAC3B,MAAM;IAC9CsB,KAAK,IAAIE,KAAK;IACd,MAAMxD,6BAA6B,CAAC4B,QAAQ,CAAC;IAC7CrC,iBAAiB,CAAE,YAAWiE,KAAM,qBAAoB9B,IAAK,EAAC,CAAC;EACjE;EACArC,eAAe,CACZ,sBAAqBiE,KAAM,qBAAoBJ,SAAS,CAAClB,MAAO,WACnE,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"IdpOps.js","names":["frodo","fs","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getRealmString","getTypedFilename","saveJsonToFile","readSocialIdentityProviders","exportSocialIdentityProvider","exportSocialIdentityProviders","importFirstSocialIdentityProvider","importSocialIdentityProvider","importSocialIdentityProviders","oauth2oidc","external","getFilePath","getWorkingDirectory","utils","getOneLineDescription","socialIdpObj","description","_id","_type","getTableHeaderMd","markdown","getTableRowMd","row","enabled","name","listSocialProviders","providers","sort","a","b","localeCompare","forEach","socialIdentityProvider","err","message","exportSocialIdentityProviderToFile","providerId","file","fileName","filePath","fileData","exportSocialIdentityProvidersToFile","exportSocialIdentityProvidersToFiles","allIdpsData","length","idpData","error","importSocialIdentityProviderFromFile","outcome","readFile","data","JSON","parse","_error$response","response","importFirstSocialIdentityProviderFromFile","_error$response2","importSocialIdentityProvidersFromFile","_error$response3","importSocialIdentityProvidersFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","map","total","readFileSync","count","Object","keys","idp"],"sources":["../../src/ops/IdpOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { SocialIdpSkeleton } from '@rockcarver/frodo-lib/types/api/SocialIdentityProvidersApi';\nimport fs from 'fs';\n\nimport {\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n} from '../utils/ExportImportUtils';\n\nconst {\n readSocialIdentityProviders,\n exportSocialIdentityProvider,\n exportSocialIdentityProviders,\n importFirstSocialIdentityProvider,\n importSocialIdentityProvider,\n importSocialIdentityProviders,\n} = frodo.oauth2oidc.external;\n\nconst { getFilePath, getWorkingDirectory } = frodo.utils;\n\n/**\n * Get a one-line description of the social idp object\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(socialIdpObj: SocialIdpSkeleton): string {\n const description = `[${socialIdpObj._id['brightCyan']}] ${socialIdpObj._type._id}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Type |\\n';\n markdown += '| ------- | ------ | ---- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the social idp in markdown\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a table-row of the social idp in markdown\n */\nexport function getTableRowMd(socialIdpObj: SocialIdpSkeleton): string {\n const row = `| ${socialIdpObj._id} | ${\n socialIdpObj.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n } | ${socialIdpObj._type.name} |`;\n return row;\n}\n\n/**\n * List providers\n */\nexport async function listSocialProviders() {\n try {\n const providers = await readSocialIdentityProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n } catch (err) {\n printMessage(`listSocialProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n */\nexport async function exportSocialIdentityProviderToFile(\n providerId: string,\n file = ''\n) {\n debugMessage(`cli.IdpOps.exportSocialIdentityProviderToFile: start`);\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'idp');\n }\n const filePath = getFilePath(fileName, true);\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${filePath}`);\n const fileData = await exportSocialIdentityProvider(providerId);\n saveJsonToFile(fileData, filePath);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${filePath['brightCyan']}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialIdentityProviderToFile: end`);\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n */\nexport async function exportSocialIdentityProvidersToFile(file = '') {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');\n }\n const fileData = await exportSocialIdentityProviders();\n saveJsonToFile(fileData, getFilePath(fileName, true));\n}\n\n/**\n * Export all providers to individual files\n */\nexport async function exportSocialIdentityProvidersToFiles() {\n debugMessage(`cli.IdpOps.exportSocialIdentityProvidersToFiles: start`);\n try {\n const allIdpsData = await readSocialIdentityProviders();\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n try {\n const fileName = getTypedFilename(idpData._id, 'idp');\n const fileData = await exportSocialIdentityProvider(idpData._id);\n saveJsonToFile(fileData, getFilePath(fileName, true));\n updateProgressBar(`Exported provider ${idpData._id}`);\n } catch (error) {\n printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');\n }\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n } catch (error) {\n stopProgressBar(`${error}`);\n printMessage(`${error}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialIdentityProvidersToFiles: end`);\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if provider was imported successfully, false otherwise\n */\nexport async function importSocialIdentityProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing provider ${providerId} from ${filePath}...`);\n fs.readFile(filePath, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importSocialIdentityProvider(providerId, fileData);\n outcome = true;\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${filePath}.`\n );\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise\n */\nexport async function importFirstSocialIdentityProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing first provider from ${filePath}...`);\n fs.readFile(filePath, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importFirstSocialIdentityProvider(fileData);\n outcome = true;\n succeedSpinner(`Successfully imported first provider from ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing first provider from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise\n */\nexport async function importSocialIdentityProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing providers from ${filePath}...`);\n fs.readFile(filePath, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importSocialIdentityProviders(fileData);\n outcome = true;\n succeedSpinner(`Successfully imported providers from ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing providers from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n */\nexport async function importSocialIdentityProvidersFromFiles() {\n const names = fs.readdirSync(getWorkingDirectory());\n const jsonFiles = names\n .filter((name) => name.toLowerCase().endsWith('.idp.json'))\n .map((name) => getFilePath(name));\n\n createProgressBar(jsonFiles.length, 'Importing providers...');\n let total = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await importSocialIdentityProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAE7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,cAAc,EACdC,gBAAgB,EAChBC,cAAc,QACT,4BAA4B;AAEnC,MAAM;EACJC,2BAA2B;EAC3BC,4BAA4B;EAC5BC,6BAA6B;EAC7BC,iCAAiC;EACjCC,4BAA4B;EA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AG;EAC7D,MAAMC,KAAK,GAAGrE,EAAE,CAACsE,WAAW,CAACjD,mBAAmB,CAAC,CAAC,CAAC;EACnD,MAAMkD,SAAS,GAAGF,KAAK,CACpBG,MAAM,CAAEvC,IAAI,IAAKA,IAAI,CAACwC,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAC1DC,GAAG,CAAE1C,IAAI,IAAKb,WAAW,CAACa,IAAI,CAAC,CAAC;EAEnChC,iBAAiB,CAACsE,SAAS,CAAClB,MAAM,EAAE,wBAAwB,CAAC;EAC7D,IAAIuB,KAAK,GAAG,CAAC;EACb,KAAK,MAAM9B,IAAI,IAAIyB,SAAS,EAAE;IAC5B,MAAMZ,IAAI,GAAG3D,EAAE,CAAC6E,YAAY,CAAC/B,IAAI,EAAE,MAAM,CAAC;IAC1C,MAAMG,QAAQ,GAAGW,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC;IACjC,MAAMmB,KAAK,GAAGC,MAAM,CAACC,IAAI,CAAC/B,QAAQ,CAACgC,GAAG,CAAC,CAAC5B,MAAM;IAC9CuB,KAAK,IAAIE,KAAK;IACd,MAAM7D,6BAA6B,CAACgC,QAAQ,CAAC;IAC7CzC,iBAAiB,CAAE,YAAWsE,KAAM,qBAAoBhC,IAAK,EAAC,CAAC;EACjE;EACAxC,eAAe,CACZ,sBAAqBsE,KAAM,qBAAoBL,SAAS,CAAClB,MAAO,WACnE,CAAC;AACH"}
|
package/esm/ops/JourneyOps.js
CHANGED
|
@@ -13,7 +13,9 @@ import wordwrap from './utils/Wordwrap';
|
|
|
13
13
|
const {
|
|
14
14
|
getTypedFilename,
|
|
15
15
|
saveJsonToFile,
|
|
16
|
-
getRealmString
|
|
16
|
+
getRealmString,
|
|
17
|
+
getFilePath,
|
|
18
|
+
getWorkingDirectory
|
|
17
19
|
} = frodo.utils;
|
|
18
20
|
const {
|
|
19
21
|
readJourneys,
|
|
@@ -93,24 +95,13 @@ export async function exportJourneyToFile(journeyId, file, options) {
|
|
|
93
95
|
if (!file) {
|
|
94
96
|
file = getTypedFilename(journeyId, 'journey');
|
|
95
97
|
}
|
|
96
|
-
|
|
97
|
-
const dir = state.getDirectory().replace(/\/$/, '');
|
|
98
|
-
debugMessage(`exportJourneyToFile: directory='${dir}'`);
|
|
99
|
-
file = `${dir}/${file}`;
|
|
100
|
-
// create directory if it doesn't exist
|
|
101
|
-
if (!fs.existsSync(dir)) {
|
|
102
|
-
debugMessage(`exportJourneyToFile: creating directory '${dir}'`);
|
|
103
|
-
fs.mkdirSync(dir, {
|
|
104
|
-
recursive: true
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
98
|
+
const filePath = getFilePath(file, true);
|
|
108
99
|
if (!verbose) showSpinner(`${journeyId}`);
|
|
109
100
|
try {
|
|
110
101
|
const fileData = await exportJourney(journeyId, options);
|
|
111
102
|
if (verbose) showSpinner(`${journeyId}`);
|
|
112
|
-
saveJsonToFile(fileData,
|
|
113
|
-
succeedSpinner(`Exported ${journeyId['brightCyan']} to ${
|
|
103
|
+
saveJsonToFile(fileData, filePath);
|
|
104
|
+
succeedSpinner(`Exported ${journeyId['brightCyan']} to ${filePath['brightCyan']}.`);
|
|
114
105
|
} catch (error) {
|
|
115
106
|
if (verbose) showSpinner(`${journeyId}`);
|
|
116
107
|
failSpinner(`Error exporting journey ${journeyId}: ${error}`);
|
|
@@ -126,22 +117,10 @@ export async function exportJourneysToFile(file, options = {
|
|
|
126
117
|
deps: false,
|
|
127
118
|
useStringArrays: false
|
|
128
119
|
}) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
fileName = getTypedFilename(`all${getRealmString()}Journeys`, 'journey');
|
|
132
|
-
}
|
|
133
|
-
if (state.getDirectory()) {
|
|
134
|
-
const dir = state.getDirectory().replace(/\/$/, '');
|
|
135
|
-
debugMessage(`exportJourneysToFile: directory='${dir}'`);
|
|
136
|
-
fileName = `${dir}/${fileName}`;
|
|
137
|
-
// create directory if it doesn't exist
|
|
138
|
-
if (!fs.existsSync(dir)) {
|
|
139
|
-
debugMessage(`exportJourneysToFile: creating directory '${dir}'`);
|
|
140
|
-
fs.mkdirSync(dir, {
|
|
141
|
-
recursive: true
|
|
142
|
-
});
|
|
143
|
-
}
|
|
120
|
+
if (!file) {
|
|
121
|
+
file = getTypedFilename(`all${getRealmString()}Journeys`, 'journey');
|
|
144
122
|
}
|
|
123
|
+
const filePath = getFilePath(file, true);
|
|
145
124
|
const trees = await readJourneys();
|
|
146
125
|
const fileData = createMultiTreeExportTemplate();
|
|
147
126
|
createProgressBar(trees.length, 'Exporting journeys...');
|
|
@@ -155,8 +134,8 @@ export async function exportJourneysToFile(file, options = {
|
|
|
155
134
|
printMessage(`Error exporting journey ${tree._id}: ${error}`, 'error');
|
|
156
135
|
}
|
|
157
136
|
}
|
|
158
|
-
saveJsonToFile(fileData,
|
|
159
|
-
stopProgressBar(`Exported to ${
|
|
137
|
+
saveJsonToFile(fileData, filePath);
|
|
138
|
+
stopProgressBar(`Exported to ${filePath}`);
|
|
160
139
|
}
|
|
161
140
|
|
|
162
141
|
/**
|
|
@@ -164,26 +143,14 @@ export async function exportJourneysToFile(file, options = {
|
|
|
164
143
|
* @param {TreeExportOptions} options export options
|
|
165
144
|
*/
|
|
166
145
|
export async function exportJourneysToFiles(options) {
|
|
167
|
-
const dir = state.getDirectory() ? state.getDirectory().replace(/\/$/, '') : undefined;
|
|
168
|
-
debugMessage(`exportJourneysToFiles: directory='${dir}'`);
|
|
169
|
-
// create directory if it doesn't exist
|
|
170
|
-
if (dir && !fs.existsSync(dir)) {
|
|
171
|
-
debugMessage(`exportJourneysToFiles: creating directory '${dir}'`);
|
|
172
|
-
fs.mkdirSync(dir, {
|
|
173
|
-
recursive: true
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
146
|
const trees = await readJourneys();
|
|
177
147
|
createProgressBar(trees.length, 'Exporting journeys...');
|
|
178
148
|
for (const tree of trees) {
|
|
179
149
|
updateProgressBar(`${tree._id}`);
|
|
180
|
-
|
|
181
|
-
if (dir) {
|
|
182
|
-
fileName = `${dir}/${fileName}`;
|
|
183
|
-
}
|
|
150
|
+
const fileName = getTypedFilename(`${tree._id}`, 'journey');
|
|
184
151
|
try {
|
|
185
152
|
const exportData = await exportJourney(tree._id, options);
|
|
186
|
-
saveJsonToFile(exportData, fileName);
|
|
153
|
+
saveJsonToFile(exportData, getFilePath(fileName, true));
|
|
187
154
|
} catch (error) {
|
|
188
155
|
// do we need to report status here?
|
|
189
156
|
}
|
|
@@ -199,7 +166,7 @@ export async function exportJourneysToFiles(options) {
|
|
|
199
166
|
*/
|
|
200
167
|
export async function importJourneyFromFile(journeyId, file, options) {
|
|
201
168
|
const verbose = state.getDebug();
|
|
202
|
-
fs.readFile(file, 'utf8', async (err, data) => {
|
|
169
|
+
fs.readFile(getFilePath(file), 'utf8', async (err, data) => {
|
|
203
170
|
if (err) throw err;
|
|
204
171
|
let journeyData = JSON.parse(data);
|
|
205
172
|
// check if this is a file with multiple trees and get journey by id
|
|
@@ -250,7 +217,7 @@ export async function importJourneyFromFile(journeyId, file, options) {
|
|
|
250
217
|
*/
|
|
251
218
|
export async function importFirstJourneyFromFile(file, options) {
|
|
252
219
|
const verbose = state.getDebug();
|
|
253
|
-
fs.readFile(file, 'utf8', async (err, data) => {
|
|
220
|
+
fs.readFile(getFilePath(file), 'utf8', async (err, data) => {
|
|
254
221
|
if (err) throw err;
|
|
255
222
|
let journeyData = cloneDeep(JSON.parse(data));
|
|
256
223
|
let journeyId = null;
|
|
@@ -309,7 +276,7 @@ export async function importFirstJourneyFromFile(file, options) {
|
|
|
309
276
|
* @param {TreeImportOptions} options import options
|
|
310
277
|
*/
|
|
311
278
|
export async function importJourneysFromFile(file, options) {
|
|
312
|
-
fs.readFile(file, 'utf8', (err, data) => {
|
|
279
|
+
fs.readFile(getFilePath(file), 'utf8', (err, data) => {
|
|
313
280
|
if (err) throw err;
|
|
314
281
|
try {
|
|
315
282
|
const fileData = JSON.parse(data);
|
|
@@ -335,8 +302,8 @@ export async function importJourneysFromFile(file, options) {
|
|
|
335
302
|
* @param {TreeImportOptions} options import options
|
|
336
303
|
*/
|
|
337
304
|
export async function importJourneysFromFiles(options) {
|
|
338
|
-
const names = fs.readdirSync(
|
|
339
|
-
const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.journey.json'));
|
|
305
|
+
const names = fs.readdirSync(getWorkingDirectory());
|
|
306
|
+
const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.journey.json')).map(name => getFilePath(name));
|
|
340
307
|
const allJourneysData = {
|
|
341
308
|
trees: {}
|
|
342
309
|
};
|