@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
|
@@ -1,7 +1,6 @@
|
|
|
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
|
-
import { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
|
|
5
4
|
const {
|
|
6
5
|
readAdminFederationProviders,
|
|
7
6
|
exportAdminFederationProvider,
|
|
@@ -11,6 +10,8 @@ const {
|
|
|
11
10
|
importFirstAdminFederationProvider
|
|
12
11
|
} = frodo.cloud.adminFed;
|
|
13
12
|
const {
|
|
13
|
+
getTypedFilename,
|
|
14
|
+
saveJsonToFile,
|
|
14
15
|
getFilePath,
|
|
15
16
|
getWorkingDirectory
|
|
16
17
|
} = frodo.utils;
|
|
@@ -39,9 +40,10 @@ export async function listAdminFederationProviders() {
|
|
|
39
40
|
* Export provider by id
|
|
40
41
|
* @param {string} providerId provider id/name
|
|
41
42
|
* @param {string} file optional export file name
|
|
43
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
42
44
|
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
43
45
|
*/
|
|
44
|
-
export async function exportAdminFederationProviderToFile(providerId, file = '') {
|
|
46
|
+
export async function exportAdminFederationProviderToFile(providerId, file = '', includeMeta = true) {
|
|
45
47
|
let outcome = false;
|
|
46
48
|
let fileName = file;
|
|
47
49
|
if (!fileName) {
|
|
@@ -52,7 +54,7 @@ export async function exportAdminFederationProviderToFile(providerId, file = '')
|
|
|
52
54
|
try {
|
|
53
55
|
updateProgressIndicator(indicatorId, `Writing file ${filePath}`);
|
|
54
56
|
const fileData = await exportAdminFederationProvider(providerId);
|
|
55
|
-
saveJsonToFile(fileData, filePath);
|
|
57
|
+
saveJsonToFile(fileData, filePath, includeMeta);
|
|
56
58
|
stopProgressIndicator(indicatorId, `Exported ${providerId['brightCyan']} to ${filePath['brightCyan']}.`);
|
|
57
59
|
outcome = true;
|
|
58
60
|
} catch (err) {
|
|
@@ -65,9 +67,10 @@ export async function exportAdminFederationProviderToFile(providerId, file = '')
|
|
|
65
67
|
/**
|
|
66
68
|
* Export all providers
|
|
67
69
|
* @param {string} file optional export file name
|
|
70
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
68
71
|
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
69
72
|
*/
|
|
70
|
-
export async function exportAdminFederationProvidersToFile(file = '') {
|
|
73
|
+
export async function exportAdminFederationProvidersToFile(file = '', includeMeta = true) {
|
|
71
74
|
let outcome = false;
|
|
72
75
|
const spinnerId = createProgressIndicator('indeterminate', 0, `Exporting all providers...`);
|
|
73
76
|
try {
|
|
@@ -77,7 +80,7 @@ export async function exportAdminFederationProvidersToFile(file = '') {
|
|
|
77
80
|
}
|
|
78
81
|
const filePath = getFilePath(fileName, true);
|
|
79
82
|
const fileData = await exportAdminFederationProviders();
|
|
80
|
-
saveJsonToFile(fileData, filePath);
|
|
83
|
+
saveJsonToFile(fileData, filePath, includeMeta);
|
|
81
84
|
stopProgressIndicator(spinnerId, `Exported all providers to ${filePath}`, 'success');
|
|
82
85
|
outcome = true;
|
|
83
86
|
} catch (error) {
|
|
@@ -90,9 +93,10 @@ export async function exportAdminFederationProvidersToFile(file = '') {
|
|
|
90
93
|
|
|
91
94
|
/**
|
|
92
95
|
* Export all providers to individual files
|
|
96
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
93
97
|
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
94
98
|
*/
|
|
95
|
-
export async function exportAdminFederationProvidersToFiles() {
|
|
99
|
+
export async function exportAdminFederationProvidersToFiles(includeMeta = true) {
|
|
96
100
|
let outcome = false;
|
|
97
101
|
let indicatorId;
|
|
98
102
|
try {
|
|
@@ -102,7 +106,7 @@ export async function exportAdminFederationProvidersToFiles() {
|
|
|
102
106
|
updateProgressIndicator(indicatorId, `Writing provider ${idpData._id}`);
|
|
103
107
|
const fileName = getTypedFilename(idpData._id, 'admin.federation');
|
|
104
108
|
const fileData = await exportAdminFederationProvider(idpData._id);
|
|
105
|
-
saveJsonToFile(fileData, getFilePath(fileName, true));
|
|
109
|
+
saveJsonToFile(fileData, getFilePath(fileName, true), includeMeta);
|
|
106
110
|
}
|
|
107
111
|
stopProgressIndicator(indicatorId, `${allIdpsData.length} providers exported.`);
|
|
108
112
|
outcome = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdminFederationOps.js","names":["frodo","fs","createProgressIndicator","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","getTypedFilename","saveJsonToFile","readAdminFederationProviders","exportAdminFederationProvider","exportAdminFederationProviders","importAdminFederationProvider","importAdminFederationProviders","importFirstAdminFederationProvider","cloud","adminFed","getFilePath","getWorkingDirectory","utils","listAdminFederationProviders","outcome","providers","sort","a","b","_id","localeCompare","forEach","socialIdentityProvider","err","message","exportAdminFederationProviderToFile","providerId","file","fileName","filePath","indicatorId","fileData","exportAdminFederationProvidersToFile","spinnerId","error","_error$response","response","data","exportAdminFederationProvidersToFiles","allIdpsData","length","idpData","_error$response2","importAdminFederationProviderFromFile","readFileSync","JSON","parse","_error$response3","importFirstAdminFederationProviderFromFile","_error$response4","importAdminFederationProvidersFromFile","_error$response5","importAdminFederationProvidersFromFiles","errors","names","readdirSync","files","filter","name","toLowerCase","endsWith","map","total","count","Object","keys","idp","push"],"sources":["../../src/ops/AdminFederationOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\n\nimport {\n createProgressIndicator,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\n\nconst {\n readAdminFederationProviders,\n exportAdminFederationProvider,\n exportAdminFederationProviders,\n importAdminFederationProvider,\n importAdminFederationProviders,\n importFirstAdminFederationProvider,\n} = frodo.cloud.adminFed;\n\nconst { getFilePath, getWorkingDirectory } = frodo.utils;\n\n/**\n * List providers\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listAdminFederationProviders(): Promise<boolean> {\n let outcome = false;\n try {\n const providers = await readAdminFederationProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n outcome = true;\n } catch (err) {\n printMessage(`listAdminFederationProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProviderToFile(\n providerId: string,\n file = ''\n): Promise<boolean> {\n let outcome = false;\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'admin.federation');\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 exportAdminFederationProvider(providerId);\n saveJsonToFile(fileData, filePath);\n stopProgressIndicator(\n indicatorId,\n `Exported ${providerId['brightCyan']} to ${filePath['brightCyan']}.`\n );\n outcome = true;\n } catch (err) {\n stopProgressIndicator(indicatorId, `${err}`);\n printMessage(`${err}`, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFile(\n file = ''\n): Promise<boolean> {\n let outcome = false;\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Exporting all providers...`\n );\n try {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allProviders`, 'admin.federation');\n }\n const filePath = getFilePath(fileName, true);\n const fileData = await exportAdminFederationProviders();\n saveJsonToFile(fileData, filePath);\n stopProgressIndicator(\n spinnerId,\n `Exported all providers to ${filePath}`,\n 'success'\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(spinnerId, `Error exporting all providers.`, 'fail');\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers to individual files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFiles(): Promise<boolean> {\n let outcome = false;\n let indicatorId: string;\n try {\n const allIdpsData = await readAdminFederationProviders();\n indicatorId = createProgressIndicator(\n 'determinate',\n allIdpsData.length,\n 'Exporting providers'\n );\n for (const idpData of allIdpsData) {\n updateProgressIndicator(indicatorId, `Writing provider ${idpData._id}`);\n const fileName = getTypedFilename(idpData._id, 'admin.federation');\n const fileData = await exportAdminFederationProvider(idpData._id);\n saveJsonToFile(fileData, getFilePath(fileName, true));\n }\n stopProgressIndicator(\n indicatorId,\n `${allIdpsData.length} providers exported.`\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error exporting all providers.`,\n 'fail'\n );\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\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 successful, false otherwise\n */\nexport async function importAdminFederationProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n const spinnerId = 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 importAdminFederationProvider(providerId, fileData);\n stopProgressIndicator(\n spinnerId,\n `Successfully imported provider ${providerId} from ${filePath}.`,\n 'success'\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(\n spinnerId,\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 successful, false otherwise\n */\nexport async function importFirstAdminFederationProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: begin`\n );\n const filePath = getFilePath(file);\n const spinnerId = 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 importFirstAdminFederationProvider(fileData);\n stopProgressIndicator(\n spinnerId,\n `Successfully imported first provider from ${filePath}.`,\n 'success'\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(\n spinnerId,\n `Error importing first provider from ${filePath}.`,\n 'fail'\n );\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: end`\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 successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: begin`\n );\n const filePath = getFilePath(file);\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing providers from ${filePath}...`\n );\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importAdminFederationProviders(fileData);\n stopProgressIndicator(\n spinnerId,\n `Imported providers from ${filePath}.`,\n 'success'\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(spinnerId, `Error importing ${filePath}.`, 'fail');\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: end`\n );\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFiles(): Promise<boolean> {\n const errors = [];\n let indicatorId: string;\n try {\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: begin`\n );\n const names = fs.readdirSync(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.admin.federation.json'))\n .map((name) => getFilePath(name));\n indicatorId = createProgressIndicator(\n 'determinate',\n files.length,\n 'Importing providers...'\n );\n let total = 0;\n for (const file of files) {\n try {\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 importAdminFederationProviders(fileData);\n updateProgressIndicator(\n indicatorId,\n `Imported ${count} provider(s) from ${file}`\n );\n } catch (error) {\n errors.push(error);\n updateProgressIndicator(\n indicatorId,\n `Error importing provider(s) from ${file}`\n );\n printMessage(error, 'error');\n }\n }\n stopProgressIndicator(\n indicatorId,\n `Finished importing ${total} provider(s) from ${files.length} file(s).`\n );\n } catch (error) {\n errors.push(error);\n stopProgressIndicator(\n indicatorId,\n `Error importing provider(s) from file(s).`\n );\n printMessage(error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: end`\n );\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,uBAAuB,EACvBC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,QAClB,kBAAkB;AACzB,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAE7E,MAAM;EACJC,4BAA4B;EAC5BC,6BAA6B;EAC7BC,8BAA8B;EAC9BC,6BAA6B;EAC7BC,8BAA8B;EAC9BC;AACF,CAAC,GAAGd,KAAK,CAACe,KAAK,CAACC,QAAQ;AAExB,MAAM;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GAAGlB,KAAK,CAACmB,KAAK;;AAExD;AACA;AACA;AACA;AACA,OAAO,eAAeC,4BAA4BA,CAAA,EAAqB;EACrE,IAAIC,OAAO,GAAG,KAAK;EACnB,IAAI;IACF,MAAMC,SAAS,GAAG,MAAMb,4BAA4B,CAAC,CAAC;IACtDa,SAAS,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IACpDJ,SAAS,CAACM,OAAO,CAAEC,sBAAsB,IAAK;MAC5CzB,YAAY,CAAE,GAAEyB,sBAAsB,CAACH,GAAI,EAAC,EAAE,MAAM,CAAC;IACvD,CAAC,CAAC;IACFL,OAAO,GAAG,IAAI;EAChB,CAAC,CAAC,OAAOS,GAAG,EAAE;IACZ1B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IAAI,IAAKhD,WAAW,CAACgD,IAAI,CAAC,CAAC;IACnC5B,WAAW,GAAGnC,uBAAuB,CACnC,aAAa,EACb6D,KAAK,CAAChB,MAAM,EACZ,wBACF,CAAC;IACD,IAAIsB,KAAK,GAAG,CAAC;IACb,KAAK,MAAMnC,IAAI,IAAI6B,KAAK,EAAE;MACxB,IAAI;QACF,MAAMnB,IAAI,GAAG3C,EAAE,CAACkD,YAAY,CAACjB,IAAI,EAAE,MAAM,CAAC;QAC1C,MAAMI,QAAQ,GAAGc,IAAI,CAACC,KAAK,CAACT,IAAI,CAAC;QACjC,MAAM0B,KAAK,GAAGC,MAAM,CAACC,IAAI,CAAClC,QAAQ,CAACmC,GAAG,CAAC,CAAC1B,MAAM;QAC9CsB,KAAK,IAAIC,KAAK;QACd,MAAMzD,8BAA8B,CAACyB,QAAQ,CAAC;QAC9ChC,uBAAuB,CACrB+B,WAAW,EACV,YAAWiC,KAAM,qBAAoBpC,IAAK,EAC7C,CAAC;MACH,CAAC,CAAC,OAAOO,KAAK,EAAE;QACdmB,MAAM,CAACc,IAAI,CAACjC,KAAK,CAAC;QAClBnC,uBAAuB,CACrB+B,WAAW,EACV,oCAAmCH,IAAK,EAC3C,CAAC;QACD9B,YAAY,CAACqC,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACApC,qBAAqB,CACnBgC,WAAW,EACV,sBAAqBgC,KAAM,qBAAoBN,KAAK,CAAChB,MAAO,WAC/D,CAAC;EACH,CAAC,CAAC,OAAON,KAAK,EAAE;IACdmB,MAAM,CAACc,IAAI,CAACjC,KAAK,CAAC;IAClBpC,qBAAqB,CACnBgC,WAAW,EACV,2CACH,CAAC;IACDjC,YAAY,CAACqC,KAAK,EAAE,OAAO,CAAC;EAC9B;EACAtC,YAAY,CACT,qEACH,CAAC;EACD,OAAO,CAAC,KAAKyD,MAAM,CAACb,MAAM;AAC5B"}
|
|
1
|
+
{"version":3,"file":"AdminFederationOps.js","names":["frodo","fs","createProgressIndicator","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","readAdminFederationProviders","exportAdminFederationProvider","exportAdminFederationProviders","importAdminFederationProvider","importAdminFederationProviders","importFirstAdminFederationProvider","cloud","adminFed","getTypedFilename","saveJsonToFile","getFilePath","getWorkingDirectory","utils","listAdminFederationProviders","outcome","providers","sort","a","b","_id","localeCompare","forEach","socialIdentityProvider","err","message","exportAdminFederationProviderToFile","providerId","file","includeMeta","fileName","filePath","indicatorId","fileData","exportAdminFederationProvidersToFile","spinnerId","error","_error$response","response","data","exportAdminFederationProvidersToFiles","allIdpsData","length","idpData","_error$response2","importAdminFederationProviderFromFile","readFileSync","JSON","parse","_error$response3","importFirstAdminFederationProviderFromFile","_error$response4","importAdminFederationProvidersFromFile","_error$response5","importAdminFederationProvidersFromFiles","errors","names","readdirSync","files","filter","name","toLowerCase","endsWith","map","total","count","Object","keys","idp","push"],"sources":["../../src/ops/AdminFederationOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\n\nimport {\n createProgressIndicator,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from '../utils/Console';\n\nconst {\n readAdminFederationProviders,\n exportAdminFederationProvider,\n exportAdminFederationProviders,\n importAdminFederationProvider,\n importAdminFederationProviders,\n importFirstAdminFederationProvider,\n} = frodo.cloud.adminFed;\n\nconst { getTypedFilename, saveJsonToFile, getFilePath, getWorkingDirectory } =\n frodo.utils;\n\n/**\n * List providers\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listAdminFederationProviders(): Promise<boolean> {\n let outcome = false;\n try {\n const providers = await readAdminFederationProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n outcome = true;\n } catch (err) {\n printMessage(`listAdminFederationProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\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 * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProviderToFile(\n providerId: string,\n file = '',\n includeMeta = true\n): Promise<boolean> {\n let outcome = false;\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'admin.federation');\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 exportAdminFederationProvider(providerId);\n saveJsonToFile(fileData, filePath, includeMeta);\n stopProgressIndicator(\n indicatorId,\n `Exported ${providerId['brightCyan']} to ${filePath['brightCyan']}.`\n );\n outcome = true;\n } catch (err) {\n stopProgressIndicator(indicatorId, `${err}`);\n printMessage(`${err}`, 'error');\n }\n return outcome;\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 * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFile(\n file = '',\n includeMeta = true\n): Promise<boolean> {\n let outcome = false;\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Exporting all providers...`\n );\n try {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allProviders`, 'admin.federation');\n }\n const filePath = getFilePath(fileName, true);\n const fileData = await exportAdminFederationProviders();\n saveJsonToFile(fileData, filePath, includeMeta);\n stopProgressIndicator(\n spinnerId,\n `Exported all providers to ${filePath}`,\n 'success'\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(spinnerId, `Error exporting all providers.`, 'fail');\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers to individual files\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFiles(\n includeMeta = true\n): Promise<boolean> {\n let outcome = false;\n let indicatorId: string;\n try {\n const allIdpsData = await readAdminFederationProviders();\n indicatorId = createProgressIndicator(\n 'determinate',\n allIdpsData.length,\n 'Exporting providers'\n );\n for (const idpData of allIdpsData) {\n updateProgressIndicator(indicatorId, `Writing provider ${idpData._id}`);\n const fileName = getTypedFilename(idpData._id, 'admin.federation');\n const fileData = await exportAdminFederationProvider(idpData._id);\n saveJsonToFile(fileData, getFilePath(fileName, true), includeMeta);\n }\n stopProgressIndicator(\n indicatorId,\n `${allIdpsData.length} providers exported.`\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error exporting all providers.`,\n 'fail'\n );\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\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 successful, false otherwise\n */\nexport async function importAdminFederationProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n const spinnerId = 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 importAdminFederationProvider(providerId, fileData);\n stopProgressIndicator(\n spinnerId,\n `Successfully imported provider ${providerId} from ${filePath}.`,\n 'success'\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(\n spinnerId,\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 successful, false otherwise\n */\nexport async function importFirstAdminFederationProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: begin`\n );\n const filePath = getFilePath(file);\n const spinnerId = 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 importFirstAdminFederationProvider(fileData);\n stopProgressIndicator(\n spinnerId,\n `Successfully imported first provider from ${filePath}.`,\n 'success'\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(\n spinnerId,\n `Error importing first provider from ${filePath}.`,\n 'fail'\n );\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: end`\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 successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: begin`\n );\n const filePath = getFilePath(file);\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing providers from ${filePath}...`\n );\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importAdminFederationProviders(fileData);\n stopProgressIndicator(\n spinnerId,\n `Imported providers from ${filePath}.`,\n 'success'\n );\n outcome = true;\n } catch (error) {\n stopProgressIndicator(spinnerId, `Error importing ${filePath}.`, 'fail');\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: end`\n );\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFiles(): Promise<boolean> {\n const errors = [];\n let indicatorId: string;\n try {\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: begin`\n );\n const names = fs.readdirSync(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.admin.federation.json'))\n .map((name) => getFilePath(name));\n indicatorId = createProgressIndicator(\n 'determinate',\n files.length,\n 'Importing providers...'\n );\n let total = 0;\n for (const file of files) {\n try {\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 importAdminFederationProviders(fileData);\n updateProgressIndicator(\n indicatorId,\n `Imported ${count} provider(s) from ${file}`\n );\n } catch (error) {\n errors.push(error);\n updateProgressIndicator(\n indicatorId,\n `Error importing provider(s) from ${file}`\n );\n printMessage(error, 'error');\n }\n }\n stopProgressIndicator(\n indicatorId,\n `Finished importing ${total} provider(s) from ${files.length} file(s).`\n );\n } catch (error) {\n errors.push(error);\n stopProgressIndicator(\n indicatorId,\n `Error importing provider(s) from file(s).`\n );\n printMessage(error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: end`\n );\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,uBAAuB,EACvBC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,QAClB,kBAAkB;AAEzB,MAAM;EACJC,4BAA4B;EAC5BC,6BAA6B;EAC7BC,8BAA8B;EAC9BC,6BAA6B;EAC7BC,8BAA8B;EAC9BC;AACF,CAAC,GAAGZ,KAAK,CAACa,KAAK,CAACC,QAAQ;AAExB,MAAM;EAAEC,gBAAgB;EAAEC,cAAc;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GAC1ElB,KAAK,CAACmB,KAAK;;AAEb;AACA;AACA;AACA;AACA,OAAO,eAAeC,4BAA4BA,CAAA,EAAqB;EACrE,IAAIC,OAAO,GAAG,KAAK;EACnB,IAAI;IACF,MAAMC,SAAS,GAAG,MAAMf,4BAA4B,CAAC,CAAC;IACtDe,SAAS,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IACpDJ,SAAS,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C,CAAC,OAAON,KAAK,EAAE;IACdmB,MAAM,CAACc,IAAI,CAACjC,KAAK,CAAC;IAClBrC,qBAAqB,CACnBiC,WAAW,EACV,2CACH,CAAC;IACDlC,YAAY,CAACsC,KAAK,EAAE,OAAO,CAAC;EAC9B;EACAvC,YAAY,CACT,qEACH,CAAC;EACD,OAAO,CAAC,KAAK0D,MAAM,CAACb,MAAM;AAC5B"}
|
package/esm/ops/AgentOps.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { createProgressIndicator, createTable, debugMessage, printMessage, stopProgressIndicator } from '../utils/Console';
|
|
4
|
-
import { getTypedFilename, saveJsonToFile, titleCase } from '../utils/ExportImportUtils';
|
|
5
4
|
const {
|
|
6
5
|
getRealmName,
|
|
6
|
+
getTypedFilename,
|
|
7
|
+
saveJsonToFile,
|
|
8
|
+
titleCase,
|
|
7
9
|
getFilePath,
|
|
8
10
|
getWorkingDirectory
|
|
9
11
|
} = frodo.utils;
|
|
@@ -143,115 +145,124 @@ export async function listWebAgents(long = false) {
|
|
|
143
145
|
/**
|
|
144
146
|
* Export all agents to file
|
|
145
147
|
* @param {string} file file name
|
|
148
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
146
149
|
*/
|
|
147
|
-
export async function exportAgentsToFile(file) {
|
|
150
|
+
export async function exportAgentsToFile(file, includeMeta = true) {
|
|
148
151
|
const exportData = await exportAgents();
|
|
149
152
|
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}Agents`, 'agent');
|
|
150
153
|
if (file) {
|
|
151
154
|
fileName = file;
|
|
152
155
|
}
|
|
153
|
-
saveJsonToFile(exportData, getFilePath(fileName, true));
|
|
156
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
154
157
|
}
|
|
155
158
|
|
|
156
159
|
/**
|
|
157
160
|
* Export all identity gateway agents to file
|
|
158
161
|
* @param {string} file file name
|
|
162
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
159
163
|
*/
|
|
160
|
-
export async function exportIdentityGatewayAgentsToFile(file) {
|
|
164
|
+
export async function exportIdentityGatewayAgentsToFile(file, includeMeta = true) {
|
|
161
165
|
const exportData = await exportIdentityGatewayAgents();
|
|
162
166
|
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}Agents`, agentTypeToFileIdMap['IdentityGatewayAgent']);
|
|
163
167
|
if (file) {
|
|
164
168
|
fileName = file;
|
|
165
169
|
}
|
|
166
|
-
saveJsonToFile(exportData, getFilePath(fileName, true));
|
|
170
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
167
171
|
}
|
|
168
172
|
|
|
169
173
|
/**
|
|
170
174
|
* Export all java agents to file
|
|
171
175
|
* @param {string} file file name
|
|
176
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
172
177
|
*/
|
|
173
|
-
export async function exportJavaAgentsToFile(file) {
|
|
178
|
+
export async function exportJavaAgentsToFile(file, includeMeta = true) {
|
|
174
179
|
const exportData = await exportJavaAgents();
|
|
175
180
|
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}Agents`, agentTypeToFileIdMap['J2EEAgent']);
|
|
176
181
|
if (file) {
|
|
177
182
|
fileName = file;
|
|
178
183
|
}
|
|
179
|
-
saveJsonToFile(exportData, getFilePath(fileName, true));
|
|
184
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
180
185
|
}
|
|
181
186
|
|
|
182
187
|
/**
|
|
183
188
|
* Export all web agents to file
|
|
184
189
|
* @param {string} file file name
|
|
190
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
185
191
|
*/
|
|
186
|
-
export async function exportWebAgentsToFile(file) {
|
|
192
|
+
export async function exportWebAgentsToFile(file, includeMeta = true) {
|
|
187
193
|
const exportData = await exportWebAgents();
|
|
188
194
|
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}Agents`, agentTypeToFileIdMap['WebAgent']);
|
|
189
195
|
if (file) {
|
|
190
196
|
fileName = file;
|
|
191
197
|
}
|
|
192
|
-
saveJsonToFile(exportData, getFilePath(fileName, true));
|
|
198
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
193
199
|
}
|
|
194
200
|
|
|
195
201
|
/**
|
|
196
202
|
* Export agent to file
|
|
197
203
|
* @param {string} agentId agent id
|
|
198
204
|
* @param {string} file file name
|
|
205
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
199
206
|
*/
|
|
200
|
-
export async function exportAgentToFile(agentId, file) {
|
|
207
|
+
export async function exportAgentToFile(agentId, file, includeMeta = true) {
|
|
201
208
|
const exportData = await exportAgent(agentId);
|
|
202
209
|
let fileName = getTypedFilename(agentId, agentTypeToFileIdMap[exportData.agents[agentId]._type._id]);
|
|
203
210
|
if (file) {
|
|
204
211
|
fileName = file;
|
|
205
212
|
}
|
|
206
|
-
saveJsonToFile(exportData, getFilePath(fileName, true));
|
|
213
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
207
214
|
}
|
|
208
215
|
|
|
209
216
|
/**
|
|
210
217
|
* Export identity gateway agent to file
|
|
211
218
|
* @param {string} agentId agent id
|
|
212
219
|
* @param {string} file file name
|
|
220
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
213
221
|
*/
|
|
214
|
-
export async function exportIdentityGatewayAgentToFile(agentId, file) {
|
|
222
|
+
export async function exportIdentityGatewayAgentToFile(agentId, file, includeMeta = true) {
|
|
215
223
|
const exportData = await exportIdentityGatewayAgent(agentId);
|
|
216
224
|
let fileName = getTypedFilename(agentId, agentTypeToFileIdMap[exportData.agents[agentId]._type._id]);
|
|
217
225
|
if (file) {
|
|
218
226
|
fileName = file;
|
|
219
227
|
}
|
|
220
|
-
saveJsonToFile(exportData, getFilePath(fileName, true));
|
|
228
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
221
229
|
}
|
|
222
230
|
|
|
223
231
|
/**
|
|
224
232
|
* Export java agent to file
|
|
225
233
|
* @param {string} agentId agent id
|
|
226
234
|
* @param {string} file file name
|
|
235
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
227
236
|
*/
|
|
228
|
-
export async function exportJavaAgentToFile(agentId, file) {
|
|
237
|
+
export async function exportJavaAgentToFile(agentId, file, includeMeta = true) {
|
|
229
238
|
const exportData = await exportJavaAgent(agentId);
|
|
230
239
|
let fileName = getTypedFilename(agentId, agentTypeToFileIdMap[exportData.agents[agentId]._type._id]);
|
|
231
240
|
if (file) {
|
|
232
241
|
fileName = file;
|
|
233
242
|
}
|
|
234
|
-
saveJsonToFile(exportData, getFilePath(fileName, true));
|
|
243
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
235
244
|
}
|
|
236
245
|
|
|
237
246
|
/**
|
|
238
247
|
* Export web agent to file
|
|
239
248
|
* @param {string} agentId agent id
|
|
240
249
|
* @param {string} file file name
|
|
250
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
241
251
|
*/
|
|
242
|
-
export async function exportWebAgentToFile(agentId, file) {
|
|
252
|
+
export async function exportWebAgentToFile(agentId, file, includeMeta = true) {
|
|
243
253
|
const exportData = await exportWebAgent(agentId);
|
|
244
254
|
let fileName = getTypedFilename(agentId, agentTypeToFileIdMap[exportData.agents[agentId]._type._id]);
|
|
245
255
|
if (file) {
|
|
246
256
|
fileName = file;
|
|
247
257
|
}
|
|
248
|
-
saveJsonToFile(exportData, getFilePath(fileName, true));
|
|
258
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
249
259
|
}
|
|
250
260
|
|
|
251
261
|
/**
|
|
252
262
|
* Export all agents to separate files
|
|
263
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
253
264
|
*/
|
|
254
|
-
export async function exportAgentsToFiles() {
|
|
265
|
+
export async function exportAgentsToFiles(includeMeta = true) {
|
|
255
266
|
const agents = await readAgents();
|
|
256
267
|
debugMessage(`exportAgentsToFiles: ${agents.length} agents`);
|
|
257
268
|
for (const agent of agents) {
|
|
@@ -260,47 +271,50 @@ export async function exportAgentsToFiles() {
|
|
|
260
271
|
const exportData = createAgentExportTemplate();
|
|
261
272
|
exportData.agents[agent._id] = agent;
|
|
262
273
|
debugMessage(`exportAgentsToFiles: exporting ${agent._id} to ${filePath}`);
|
|
263
|
-
saveJsonToFile(exportData, filePath);
|
|
274
|
+
saveJsonToFile(exportData, filePath, includeMeta);
|
|
264
275
|
}
|
|
265
276
|
debugMessage(`exportAgentsToFiles: done.`);
|
|
266
277
|
}
|
|
267
278
|
|
|
268
279
|
/**
|
|
269
280
|
* Export all identity gateway agents to separate files
|
|
281
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
270
282
|
*/
|
|
271
|
-
export async function exportIdentityGatewayAgentsToFiles() {
|
|
283
|
+
export async function exportIdentityGatewayAgentsToFiles(includeMeta = true) {
|
|
272
284
|
const agents = await readIdentityGatewayAgents();
|
|
273
285
|
for (const agent of agents) {
|
|
274
286
|
const fileName = getTypedFilename(agent._id, agentTypeToFileIdMap[agent._type._id]);
|
|
275
287
|
const exportData = createAgentExportTemplate();
|
|
276
288
|
exportData.agents[agent._id] = agent;
|
|
277
|
-
saveJsonToFile(exportData, getFilePath(fileName, true));
|
|
289
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
278
290
|
}
|
|
279
291
|
}
|
|
280
292
|
|
|
281
293
|
/**
|
|
282
294
|
* Export all java agents to separate files
|
|
295
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
283
296
|
*/
|
|
284
|
-
export async function exportJavaAgentsToFiles() {
|
|
297
|
+
export async function exportJavaAgentsToFiles(includeMeta = true) {
|
|
285
298
|
const agents = await readJavaAgents();
|
|
286
299
|
for (const agent of agents) {
|
|
287
300
|
const fileName = getTypedFilename(agent._id, agentTypeToFileIdMap[agent._type._id]);
|
|
288
301
|
const exportData = createAgentExportTemplate();
|
|
289
302
|
exportData.agents[agent._id] = agent;
|
|
290
|
-
saveJsonToFile(exportData, getFilePath(fileName, true));
|
|
303
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
291
304
|
}
|
|
292
305
|
}
|
|
293
306
|
|
|
294
307
|
/**
|
|
295
308
|
* Export all web agents to separate files
|
|
309
|
+
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
296
310
|
*/
|
|
297
|
-
export async function exportWebAgentsToFiles() {
|
|
311
|
+
export async function exportWebAgentsToFiles(includeMeta = true) {
|
|
298
312
|
const agents = await readWebAgents();
|
|
299
313
|
for (const agent of agents) {
|
|
300
314
|
const fileName = getTypedFilename(agent._id, agentTypeToFileIdMap[agent._type._id]);
|
|
301
315
|
const exportData = createAgentExportTemplate();
|
|
302
316
|
exportData.agents[agent._id] = agent;
|
|
303
|
-
saveJsonToFile(exportData, getFilePath(fileName, true));
|
|
317
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
304
318
|
}
|
|
305
319
|
}
|
|
306
320
|
|