@rockcarver/frodo-cli 2.0.0-37 → 2.0.0-39
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/_template/something-else-export.js +1 -1
- package/esm/cli/_template/something-else-export.js.map +1 -1
- package/esm/cli/_template/something-export.js +1 -1
- package/esm/cli/_template/something-export.js.map +1 -1
- package/esm/cli/_template/something-other-export.js +1 -1
- package/esm/cli/_template/something-other-export.js.map +1 -1
- package/esm/cli/admin/admin-federation-export.js +4 -4
- package/esm/cli/admin/admin-federation-export.js.map +1 -1
- package/esm/cli/agent/agent-export.js +4 -4
- package/esm/cli/agent/agent-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-export.js +4 -4
- package/esm/cli/agent/agent-gateway-export.js.map +1 -1
- package/esm/cli/agent/agent-java-export.js +4 -4
- package/esm/cli/agent/agent-java-export.js.map +1 -1
- package/esm/cli/agent/agent-web-export.js +4 -4
- package/esm/cli/agent/agent-web-export.js.map +1 -1
- package/esm/cli/app/app-export.js +4 -4
- package/esm/cli/app/app-export.js.map +1 -1
- package/esm/cli/authn/authn-export.js +2 -2
- package/esm/cli/authn/authn-export.js.map +1 -1
- package/esm/cli/authz/authz-policy-export.js +6 -6
- package/esm/cli/authz/authz-policy-export.js.map +1 -1
- package/esm/cli/authz/authz-set-export.js +4 -4
- package/esm/cli/authz/authz-set-export.js.map +1 -1
- package/esm/cli/authz/authz-type-export.js +5 -5
- package/esm/cli/authz/authz-type-export.js.map +1 -1
- package/esm/cli/config/config-export.js +3 -3
- package/esm/cli/config/config-export.js.map +1 -1
- package/esm/cli/email/email-template-export.js +4 -4
- package/esm/cli/email/email-template-export.js.map +1 -1
- package/esm/cli/esv/esv-secret-export.js +4 -4
- package/esm/cli/esv/esv-secret-export.js.map +1 -1
- package/esm/cli/esv/esv-secret-list.js +2 -2
- package/esm/cli/esv/esv-secret-list.js.map +1 -1
- package/esm/cli/esv/esv-variable-export.js +4 -4
- package/esm/cli/esv/esv-variable-export.js.map +1 -1
- package/esm/cli/esv/esv-variable-list.js +2 -2
- package/esm/cli/esv/esv-variable-list.js.map +1 -1
- package/esm/cli/idp/idp-export.js +4 -4
- package/esm/cli/idp/idp-export.js.map +1 -1
- package/esm/cli/journey/journey-describe.js +3 -1
- package/esm/cli/journey/journey-describe.js.map +1 -1
- package/esm/cli/journey/journey-export.js +4 -4
- package/esm/cli/journey/journey-export.js.map +1 -1
- package/esm/cli/oauth/oauth-client-export.js +4 -4
- package/esm/cli/oauth/oauth-client-export.js.map +1 -1
- package/esm/cli/saml/saml-cot-export.js +4 -4
- package/esm/cli/saml/saml-cot-export.js.map +1 -1
- package/esm/cli/saml/saml-export.js +4 -4
- package/esm/cli/saml/saml-export.js.map +1 -1
- package/esm/cli/script/script-export.js +4 -4
- package/esm/cli/script/script-export.js.map +1 -1
- package/esm/cli/script/script-list.js +2 -2
- package/esm/cli/script/script-list.js.map +1 -1
- package/esm/cli/service/service-export.js +4 -4
- package/esm/cli/service/service-export.js.map +1 -1
- package/esm/cli/theme/theme-export.js +5 -5
- package/esm/cli/theme/theme-export.js.map +1 -1
- package/esm/ops/AdminFederationOps.js +11 -7
- package/esm/ops/AdminFederationOps.js.map +1 -1
- package/esm/ops/AgentOps.js +39 -25
- package/esm/ops/AgentOps.js.map +1 -1
- package/esm/ops/ApplicationOps.js +11 -8
- package/esm/ops/ApplicationOps.js.map +1 -1
- package/esm/ops/AuthenticationSettingsOps.js +4 -3
- package/esm/ops/AuthenticationSettingsOps.js.map +1 -1
- package/esm/ops/CirclesOfTrustOps.js +12 -7
- package/esm/ops/CirclesOfTrustOps.js.map +1 -1
- package/esm/ops/ConfigOps.js +9 -7
- package/esm/ops/ConfigOps.js.map +1 -1
- package/esm/ops/EmailTemplateOps.js +11 -7
- package/esm/ops/EmailTemplateOps.js.map +1 -1
- package/esm/ops/IdmOps.js +3 -2
- package/esm/ops/IdmOps.js.map +1 -1
- package/esm/ops/IdpOps.js +14 -7
- package/esm/ops/IdpOps.js.map +1 -1
- package/esm/ops/JourneyOps.js +15 -6
- package/esm/ops/JourneyOps.js.map +1 -1
- package/esm/ops/OAuth2ClientOps.js +10 -7
- package/esm/ops/OAuth2ClientOps.js.map +1 -1
- package/esm/ops/PolicyOps.js +18 -11
- package/esm/ops/PolicyOps.js.map +1 -1
- package/esm/ops/PolicySetOps.js +12 -7
- package/esm/ops/PolicySetOps.js.map +1 -1
- package/esm/ops/ResourceTypeOps.js +15 -9
- package/esm/ops/ResourceTypeOps.js.map +1 -1
- package/esm/ops/Saml2Ops.js +10 -7
- package/esm/ops/Saml2Ops.js.map +1 -1
- package/esm/ops/ScriptOps.js +73 -36
- package/esm/ops/ScriptOps.js.map +1 -1
- package/esm/ops/SecretsOps.js +76 -48
- package/esm/ops/SecretsOps.js.map +1 -1
- package/esm/ops/ServiceOps.js +10 -9
- package/esm/ops/ServiceOps.js.map +1 -1
- package/esm/ops/ThemeOps.js +15 -9
- package/esm/ops/ThemeOps.js.map +1 -1
- package/esm/ops/VariablesOps.js +49 -23
- package/esm/ops/VariablesOps.js.map +1 -1
- package/esm/utils/Config.js +147 -1
- package/esm/utils/Config.js.map +1 -1
- package/package.json +2 -2
- package/esm/utils/ExportImportUtils.js +0 -48
- package/esm/utils/ExportImportUtils.js.map +0 -1
package/esm/ops/IdmOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdmOps.js","names":["frodo","state","fs","fse","path","propertiesReader","replaceall","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","readFiles","stringify","utils","json","unSubstituteEnvParams","areScriptHooksValid","getFilePath","testConnectorServers","readConfigEntities","readConfigEntity","exportConfigEntities","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","err","exportAllRawConfigEntities","exportedConfigurations","value","Object","entries","outputFile","exportAllConfigEntities","entitiesFile","envFile","entriesToExport","readFile","data","entriesData","JSON","parse","envParams","undefined","entityPromises","includes","push","results","Promise","item","configEntityString","each","key","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","reason","importAllConfigEntities","entriesToImport","envReader","unsubstituted","countManagedObjects","type","response"],"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 { stringify } = frodo.utils.json;\nconst { unSubstituteEnvParams, areScriptHooksValid, getFilePath } = frodo.utils;\nconst {\n testConnectorServers,\n readConfigEntities,\n readConfigEntity,\n exportConfigEntities,\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(getFilePath(fileName, true), stringify(configEntity), (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 */\nexport async function exportAllRawConfigEntities() {\n const exportedConfigurations = await exportConfigEntities();\n for (const [id, value] of Object.entries(exportedConfigurations.config)) {\n if (value != null) {\n fse.outputFile(\n getFilePath(`${id}.json`, true),\n stringify(value),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\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 = stringify(item);\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,gBA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B,KAAK,CAACmE,MAAO,EAAC,EAAE,OAAO,CAAC;IAC5C;IACA/F,qBAAqB,CAClB,oBAAmB6F,MAAM,CAACnE,MAAO,iBAAgB,EAClD,OACF,CAAC;IACD;EACF;EAEA1B,qBAAqB,CAAE,YAAW6D,OAAO,CAACnC,MAAO,iBAAgB,EAAE,SAAS,CAAC;AAC/E;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAe0E,mBAAmBA,CAACC,IAAY,EAAE;EACtD,IAAI;IACF,MAAMP,MAAM,GAAG,MAAM9E,mBAAmB,CAACqF,IAAI,CAAC;IAC9CtG,YAAY,CAAE,GAAEsG,IAAK,KAAIP,MAAM,CAACpE,MAAO,EAAC,EAAE,MAAM,CAAC;EACnD,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd7B,YAAY,CAAC6B,KAAK,CAAC0E,QAAQ,CAAClD,IAAI,EAAE,OAAO,CAAC;IAC1CrD,YAAY,CAAE,2CAA0C6B,KAAM,EAAC,EAAE,OAAO,CAAC;EAC3E;AACF"}
|
|
1
|
+
{"version":3,"file":"IdmOps.js","names":["frodo","state","fs","fse","path","propertiesReader","replaceall","createProgressIndicator","printMessage","stopProgressIndicator","stringify","utils","json","unSubstituteEnvParams","areScriptHooksValid","getFilePath","getTypedFilename","readFiles","testConnectorServers","readConfigEntities","readConfigEntity","exportConfigEntities","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","err","exportAllRawConfigEntities","exportedConfigurations","value","Object","entries","outputFile","exportAllConfigEntities","entitiesFile","envFile","entriesToExport","readFile","data","entriesData","JSON","parse","envParams","undefined","entityPromises","includes","push","results","Promise","item","configEntityString","each","key","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","reason","importAllConfigEntities","entriesToImport","envReader","unsubstituted","countManagedObjects","type","response"],"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';\n\nconst { stringify } = frodo.utils.json;\n\nconst {\n unSubstituteEnvParams,\n areScriptHooksValid,\n getFilePath,\n getTypedFilename,\n readFiles,\n} = frodo.utils;\nconst {\n testConnectorServers,\n readConfigEntities,\n readConfigEntity,\n exportConfigEntities,\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(getFilePath(fileName, true), stringify(configEntity), (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 */\nexport async function exportAllRawConfigEntities() {\n const exportedConfigurations = await exportConfigEntities();\n for (const [id, value] of Object.entries(exportedConfigurations.config)) {\n if (value != null) {\n fse.outputFile(\n getFilePath(`${id}.json`, true),\n stringify(value),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\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 = stringify(item);\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;AAEzB,MAAM;EAAEC;AAAU,CAAC,GAAGV,KAAK,CAACW,KAAK,CAACC,IAAI;AAEtC,MAAM;EACJC,qBAAqB;EACrBC,mBAAmB;EACnBC,WAAW;EACXC,gBAAgB;EAChBC;AACF,CAAC,GAAGjB,KAAK,CAACW,KAAK;AACf,MAAM;EACJO,oBAAoB;EACpBC,kBAAkB;EAClBC,gBAAgB;EAChBC,oBAAoB;E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mBA,CAACC,IAAY,EAAE;EACtD,IAAI;IACF,MAAMP,MAAM,GAAG,MAAM9E,mBAAmB,CAACqF,IAAI,CAAC;IAC9CtG,YAAY,CAAE,GAAEsG,IAAK,KAAIP,MAAM,CAACpE,MAAO,EAAC,EAAE,MAAM,CAAC;EACnD,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd7B,YAAY,CAAC6B,KAAK,CAAC0E,QAAQ,CAAClD,IAAI,EAAE,OAAO,CAAC;IAC1CrD,YAAY,CAAE,2CAA0C6B,KAAM,EAAC,EAAE,OAAO,CAAC;EAC3E;AACF"}
|
package/esm/ops/IdpOps.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { frodo } from '@rockcarver/frodo-lib';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { createProgressIndicator, debugMessage, printMessage, stopProgressIndicator, updateProgressIndicator } from '../utils/Console';
|
|
4
|
-
|
|
4
|
+
const {
|
|
5
|
+
getRealmString,
|
|
6
|
+
getTypedFilename,
|
|
7
|
+
saveJsonToFile
|
|
8
|
+
} = frodo.utils;
|
|
5
9
|
const {
|
|
6
10
|
readSocialIdentityProviders,
|
|
7
11
|
exportSocialIdentityProvider,
|
|
@@ -66,8 +70,9 @@ export async function listSocialProviders() {
|
|
|
66
70
|
* Export provider by id
|
|
67
71
|
* @param {string} providerId provider id/name
|
|
68
72
|
* @param {string} file optional export file name
|
|
73
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
69
74
|
*/
|
|
70
|
-
export async function exportSocialIdentityProviderToFile(providerId, file = '') {
|
|
75
|
+
export async function exportSocialIdentityProviderToFile(providerId, file = '', includeMeta = true) {
|
|
71
76
|
debugMessage(`cli.IdpOps.exportSocialIdentityProviderToFile: start`);
|
|
72
77
|
let fileName = file;
|
|
73
78
|
if (!fileName) {
|
|
@@ -78,7 +83,7 @@ export async function exportSocialIdentityProviderToFile(providerId, file = '')
|
|
|
78
83
|
try {
|
|
79
84
|
updateProgressIndicator(indicatorId, `Writing file ${filePath}`);
|
|
80
85
|
const fileData = await exportSocialIdentityProvider(providerId);
|
|
81
|
-
saveJsonToFile(fileData, filePath);
|
|
86
|
+
saveJsonToFile(fileData, filePath, includeMeta);
|
|
82
87
|
stopProgressIndicator(indicatorId, `Exported ${providerId['brightCyan']} to ${filePath['brightCyan']}.`);
|
|
83
88
|
} catch (err) {
|
|
84
89
|
stopProgressIndicator(indicatorId, `${err}`);
|
|
@@ -90,20 +95,22 @@ export async function exportSocialIdentityProviderToFile(providerId, file = '')
|
|
|
90
95
|
/**
|
|
91
96
|
* Export all providers
|
|
92
97
|
* @param {string} file optional export file name
|
|
98
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
93
99
|
*/
|
|
94
|
-
export async function exportSocialIdentityProvidersToFile(file = '') {
|
|
100
|
+
export async function exportSocialIdentityProvidersToFile(file = '', includeMeta = true) {
|
|
95
101
|
let fileName = file;
|
|
96
102
|
if (!fileName) {
|
|
97
103
|
fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');
|
|
98
104
|
}
|
|
99
105
|
const fileData = await exportSocialIdentityProviders();
|
|
100
|
-
saveJsonToFile(fileData, getFilePath(fileName, true));
|
|
106
|
+
saveJsonToFile(fileData, getFilePath(fileName, true), includeMeta);
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
/**
|
|
104
110
|
* Export all providers to individual files
|
|
111
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
105
112
|
*/
|
|
106
|
-
export async function exportSocialIdentityProvidersToFiles() {
|
|
113
|
+
export async function exportSocialIdentityProvidersToFiles(includeMeta = true) {
|
|
107
114
|
debugMessage(`cli.IdpOps.exportSocialIdentityProvidersToFiles: start`);
|
|
108
115
|
let indicatorId;
|
|
109
116
|
try {
|
|
@@ -113,7 +120,7 @@ export async function exportSocialIdentityProvidersToFiles() {
|
|
|
113
120
|
try {
|
|
114
121
|
const fileName = getTypedFilename(idpData._id, 'idp');
|
|
115
122
|
const fileData = await exportSocialIdentityProvider(idpData._id);
|
|
116
|
-
saveJsonToFile(fileData, getFilePath(fileName, true));
|
|
123
|
+
saveJsonToFile(fileData, getFilePath(fileName, true), includeMeta);
|
|
117
124
|
updateProgressIndicator(indicatorId, `Exported provider ${idpData._id}`);
|
|
118
125
|
} catch (error) {
|
|
119
126
|
printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');
|
package/esm/ops/IdpOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdpOps.js","names":["frodo","fs","createProgressIndicator","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","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","indicatorId","fileData","exportSocialIdentityProvidersToFile","exportSocialIdentityProvidersToFiles","allIdpsData","length","idpData","error","importSocialIdentityProviderFromFile","outcome","data","readFileSync","JSON","parse","_error$response","response","importFirstSocialIdentityProviderFromFile","_error$response2","importSocialIdentityProvidersFromFile","_error$response3","importSocialIdentityProvidersFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","map","total","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 createProgressIndicator,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\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 const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting ${providerId}`\n );\n try {\n updateProgressIndicator(indicatorId, `Writing file ${filePath}`);\n const fileData = await exportSocialIdentityProvider(providerId);\n saveJsonToFile(fileData, filePath);\n stopProgressIndicator(\n indicatorId,\n `Exported ${providerId['brightCyan']} to ${filePath['brightCyan']}.`\n );\n } catch (err) {\n stopProgressIndicator(indicatorId, `${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 let indicatorId: string;\n try {\n const allIdpsData = await readSocialIdentityProviders();\n indicatorId = createProgressIndicator(\n 'determinate',\n allIdpsData.length,\n 'Exporting providers'\n );\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 updateProgressIndicator(\n indicatorId,\n `Exported provider ${idpData._id}`\n );\n } catch (error) {\n printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');\n }\n }\n stopProgressIndicator(\n indicatorId,\n `${allIdpsData.length} providers exported.`\n );\n } catch (error) {\n stopProgressIndicator(indicatorId, `${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 const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing provider ${providerId} from ${filePath}...`\n );\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importSocialIdentityProvider(providerId, fileData);\n outcome = true;\n stopProgressIndicator(\n indicatorId,\n `Successfully imported provider ${providerId} from ${filePath}.`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing provider ${providerId} from ${filePath}.`,\n 'fail'\n );\n printMessage(error.response?.data || error, 'error');\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 const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing first provider from ${filePath}...`\n );\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstSocialIdentityProvider(fileData);\n outcome = true;\n stopProgressIndicator(\n indicatorId,\n `Successfully imported first provider from ${filePath}.`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing first provider from ${filePath}.`,\n 'fail'\n );\n printMessage(error.response?.data || error, 'error');\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 const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing providers from ${filePath}...`\n );\n const data = fs.readFileSync(filePath, 'utf8');\n try {\n const fileData = JSON.parse(data);\n await importSocialIdentityProviders(fileData);\n outcome = true;\n stopProgressIndicator(\n indicatorId,\n `Successfully imported providers from ${filePath}.`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing providers from ${filePath}.`,\n 'fail'\n );\n printMessage(error.response?.data || error, 'error');\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 const indicatorId = createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing providers...'\n );\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 updateProgressIndicator(\n indicatorId,\n `Imported ${count} provider(s) from ${file}`\n );\n }\n stopProgressIndicator(\n indicatorId,\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,uBAAuB,EACvBC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,QAClB,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,GAAGf,KAAK,CAACgB,UAAU,CAACC,QAAQ;AAE7B,MAAM;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GAAGnB,KAAK,CAACoB,KAAK;;AAExD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAACC,YAA+B,EAAU;EAC7E,MAAMC,WAAW,GAAI,IAAGD,YAAY,CAACE,GAAG,CAAC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WAAW,CAAClD,mBAAmB,CAAC,CAAC,CAAC;EACnD,MAAMmD,SAAS,GAAGF,KAAK,CACpBG,MAAM,CAAExC,IAAI,IAAKA,IAAI,CAACyC,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAC1DC,GAAG,CAAE3C,IAAI,IAAKb,WAAW,CAACa,IAAI,CAAC,CAAC;EAEnC,MAAMgB,WAAW,GAAG7C,uBAAuB,CACzC,aAAa,EACboE,SAAS,CAAClB,MAAM,EAChB,wBACF,CAAC;EACD,IAAIuB,KAAK,GAAG,CAAC;EACb,KAAK,MAAM/B,IAAI,IAAI0B,SAAS,EAAE;IAC5B,MAAMb,IAAI,GAAGxD,EAAE,CAACyD,YAAY,CAACd,IAAI,EAAE,MAAM,CAAC;IAC1C,MAAMI,QAAQ,GAAGW,IAAI,CAACC,KAAK,CAACH,IAAI,CAAC;IACjC,MAAMmB,KAAK,GAAGC,MAAM,CAACC,IAAI,CAAC9B,QAAQ,CAAC+B,GAAG,CAAC,CAAC3B,MAAM;IAC9CuB,KAAK,IAAIC,KAAK;IACd,MAAM7D,6BAA6B,CAACiC,QAAQ,CAAC;IAC7C1C,uBAAuB,CACrByC,WAAW,EACV,YAAW6B,KAAM,qBAAoBhC,IAAK,EAC7C,CAAC;EACH;EACAvC,qBAAqB,CACnB0C,WAAW,EACV,sBAAqB4B,KAAM,qBAAoBL,SAAS,CAAClB,MAAO,WACnE,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"IdpOps.js","names":["frodo","fs","createProgressIndicator","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","getRealmString","getTypedFilename","saveJsonToFile","utils","readSocialIdentityProviders","exportSocialIdentityProvider","exportSocialIdentityProviders","importFirstSocialIdentityProvider","importSocialIdentityProvider","importSocialIdentityProviders","oauth2oidc","external","getFilePath","getWorkingDirectory","getOneLineDescription","socialIdpObj","description","_id","_type","getTableHeaderMd","markdown","getTableRowMd","row","enabled","name","listSocialProviders","providers","sort","a","b","localeCompare","forEach","socialIdentityProvider","err","message","exportSocialIdentityProviderToFile","providerId","file","includeMeta","fileName","filePath","indicatorId","fileData","exportSocialIdentityProvidersToFile","exportSocialIdentityProvidersToFiles","allIdpsData","length","idpData","error","importSocialIdentityProviderFromFile","outcome","data","readFileSync","JSON","parse","_error$response","response","importFirstSocialIdentityProviderFromFile","_error$response2","importSocialIdentityProvidersFromFile","_error$response3","importSocialIdentityProvidersFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","map","total","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 createProgressIndicator,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from '../utils/Console';\n\nconst { getRealmString, getTypedFilename, saveJsonToFile } = frodo.utils;\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 * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSocialIdentityProviderToFile(\n providerId: string,\n file = '',\n includeMeta = true\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 const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting ${providerId}`\n );\n try {\n updateProgressIndicator(indicatorId, `Writing file ${filePath}`);\n const fileData = await exportSocialIdentityProvider(providerId);\n saveJsonToFile(fileData, filePath, includeMeta);\n stopProgressIndicator(\n indicatorId,\n `Exported ${providerId['brightCyan']} to ${filePath['brightCyan']}.`\n );\n } catch (err) {\n stopProgressIndicator(indicatorId, `${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 * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSocialIdentityProvidersToFile(\n file = '',\n includeMeta = true\n) {\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), includeMeta);\n}\n\n/**\n * Export all providers to individual files\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSocialIdentityProvidersToFiles(includeMeta = true) {\n debugMessage(`cli.IdpOps.exportSocialIdentityProvidersToFiles: start`);\n let indicatorId: string;\n try {\n const allIdpsData = await readSocialIdentityProviders();\n indicatorId = createProgressIndicator(\n 'determinate',\n allIdpsData.length,\n 'Exporting providers'\n );\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), includeMeta);\n updateProgressIndicator(\n indicatorId,\n `Exported provider ${idpData._id}`\n );\n } catch (error) {\n printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');\n }\n }\n stopProgressIndicator(\n indicatorId,\n `${allIdpsData.length} providers exported.`\n );\n } catch (error) {\n stopProgressIndicator(indicatorId, `${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 const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing provider ${providerId} from ${filePath}...`\n );\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importSocialIdentityProvider(providerId, fileData);\n outcome = true;\n stopProgressIndicator(\n indicatorId,\n `Successfully imported provider ${providerId} from ${filePath}.`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing provider ${providerId} from ${filePath}.`,\n 'fail'\n );\n printMessage(error.response?.data || error, 'error');\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 const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing first provider from ${filePath}...`\n );\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstSocialIdentityProvider(fileData);\n outcome = true;\n stopProgressIndicator(\n indicatorId,\n `Successfully imported first provider from ${filePath}.`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing first provider from ${filePath}.`,\n 'fail'\n );\n printMessage(error.response?.data || error, 'error');\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 const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing providers from ${filePath}...`\n );\n const data = fs.readFileSync(filePath, 'utf8');\n try {\n const fileData = JSON.parse(data);\n await importSocialIdentityProviders(fileData);\n outcome = true;\n stopProgressIndicator(\n indicatorId,\n `Successfully imported providers from ${filePath}.`,\n 'success'\n );\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing providers from ${filePath}.`,\n 'fail'\n );\n printMessage(error.response?.data || error, 'error');\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 const indicatorId = createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing providers...'\n );\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 updateProgressIndicator(\n indicatorId,\n `Imported ${count} provider(s) from ${file}`\n );\n }\n stopProgressIndicator(\n indicatorId,\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,uBAAuB,EACvBC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,QAClB,kBAAkB;AAEzB,MAAM;EAAEC,cAAc;EAAEC,gBAAgB;EAAEC;AAAe,CAAC,GAAGT,KAAK,CAACU,KAAK;AACxE,MAAM;EACJC,2BAA2B;EAC3BC,4BAA4B;EAC5BC,6BAA6B;EAC7BC,iCAAiC;EACjCC,4BAA4B;EAC5BC;AACF,CAAC,GAAGhB,KAAK,CAACiB,UAAU,CAACC,QAAQ;AAE7B,MAAM;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GAAGpB,KAAK,CAACU,KAAK;;AAExD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASW,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,MAAK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F,CAAC;EACD,IAAIuB,KAAK,GAAG,CAAC;EACb,KAAK,MAAMhC,IAAI,IAAI2B,SAAS,EAAE;IAC5B,MAAMb,IAAI,GAAGzD,EAAE,CAAC0D,YAAY,CAACf,IAAI,EAAE,MAAM,CAAC;IAC1C,MAAMK,QAAQ,GAAGW,IAAI,CAACC,KAAK,CAACH,IAAI,CAAC;IACjC,MAAMmB,KAAK,GAAGC,MAAM,CAACC,IAAI,CAAC9B,QAAQ,CAAC+B,GAAG,CAAC,CAAC3B,MAAM;IAC9CuB,KAAK,IAAIC,KAAK;IACd,MAAM7D,6BAA6B,CAACiC,QAAQ,CAAC;IAC7C3C,uBAAuB,CACrB0C,WAAW,EACV,YAAW6B,KAAM,qBAAoBjC,IAAK,EAC7C,CAAC;EACH;EACAvC,qBAAqB,CACnB2C,WAAW,EACV,sBAAqB4B,KAAM,qBAAoBL,SAAS,CAAClB,MAAO,WACnE,CAAC;AACH"}
|
package/esm/ops/JourneyOps.js
CHANGED
|
@@ -89,9 +89,13 @@ export async function listJourneys(long = false, analyze = false) {
|
|
|
89
89
|
* Export journey by id/name to file
|
|
90
90
|
* @param {string} journeyId journey id/name
|
|
91
91
|
* @param {string} file optional export file name
|
|
92
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
92
93
|
* @param {TreeExportOptions} options export options
|
|
93
94
|
*/
|
|
94
|
-
export async function exportJourneyToFile(journeyId, file, options
|
|
95
|
+
export async function exportJourneyToFile(journeyId, file, includeMeta = true, options = {
|
|
96
|
+
deps: false,
|
|
97
|
+
useStringArrays: false
|
|
98
|
+
}) {
|
|
95
99
|
debugMessage(`exportJourneyToFile: start`);
|
|
96
100
|
const verbose = state.getVerbose();
|
|
97
101
|
if (!file) {
|
|
@@ -103,7 +107,7 @@ export async function exportJourneyToFile(journeyId, file, options) {
|
|
|
103
107
|
try {
|
|
104
108
|
const fileData = await exportJourney(journeyId, options);
|
|
105
109
|
if (verbose) spinnerId = createProgressIndicator('indeterminate', 0, `${journeyId}`);
|
|
106
|
-
saveJsonToFile(fileData, filePath);
|
|
110
|
+
saveJsonToFile(fileData, filePath, includeMeta);
|
|
107
111
|
stopProgressIndicator(spinnerId, `Exported ${journeyId['brightCyan']} to ${filePath['brightCyan']}.`, 'success');
|
|
108
112
|
} catch (error) {
|
|
109
113
|
if (verbose) spinnerId = createProgressIndicator('indeterminate', 0, `${journeyId}`);
|
|
@@ -114,9 +118,10 @@ export async function exportJourneyToFile(journeyId, file, options) {
|
|
|
114
118
|
/**
|
|
115
119
|
* Export all journeys to file
|
|
116
120
|
* @param {string} file optional export file name
|
|
121
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
117
122
|
* @param {TreeExportOptions} options export options
|
|
118
123
|
*/
|
|
119
|
-
export async function exportJourneysToFile(file, options = {
|
|
124
|
+
export async function exportJourneysToFile(file, includeMeta = true, options = {
|
|
120
125
|
deps: false,
|
|
121
126
|
useStringArrays: false
|
|
122
127
|
}) {
|
|
@@ -125,14 +130,18 @@ export async function exportJourneysToFile(file, options = {
|
|
|
125
130
|
}
|
|
126
131
|
const filePath = getFilePath(file, true);
|
|
127
132
|
const fileData = await exportJourneys(options);
|
|
128
|
-
saveJsonToFile(fileData, filePath);
|
|
133
|
+
saveJsonToFile(fileData, filePath, includeMeta);
|
|
129
134
|
}
|
|
130
135
|
|
|
131
136
|
/**
|
|
132
137
|
* Export all journeys to separate files
|
|
138
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
133
139
|
* @param {TreeExportOptions} options export options
|
|
134
140
|
*/
|
|
135
|
-
export async function exportJourneysToFiles(options
|
|
141
|
+
export async function exportJourneysToFiles(includeMeta = true, options = {
|
|
142
|
+
deps: false,
|
|
143
|
+
useStringArrays: false
|
|
144
|
+
}) {
|
|
136
145
|
const journeysExport = await exportJourneys(options);
|
|
137
146
|
const trees = Object.entries(journeysExport.trees);
|
|
138
147
|
for (const [treeId, treeValue] of trees) {
|
|
@@ -141,7 +150,7 @@ export async function exportJourneysToFiles(options) {
|
|
|
141
150
|
treeValue['meta'] = journeysExport.meta;
|
|
142
151
|
try {
|
|
143
152
|
updateProgressIndicator(indicatorId, `Saving ${treeId} to ${file}`);
|
|
144
|
-
saveJsonToFile(treeValue, file);
|
|
153
|
+
saveJsonToFile(treeValue, file, includeMeta);
|
|
145
154
|
stopProgressIndicator(indicatorId, `${treeId} saved to ${file}`);
|
|
146
155
|
} catch (error) {
|
|
147
156
|
stopProgressIndicator(indicatorId, `Error saving ${treeId} to ${file}`);
|