@rockcarver/frodo-cli 2.0.0-40 → 2.0.0-41

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/esm/ops/IdpOps.js CHANGED
@@ -138,16 +138,19 @@ export async function exportSocialIdentityProvidersToFiles(includeMeta = true) {
138
138
  * Import provider by id/name
139
139
  * @param {string} providerId provider id/name
140
140
  * @param {string} file import file name
141
+ * @param {SocialIdentityProviderImportOptions} options import options
141
142
  * @returns {Promise<boolean>} true if provider was imported successfully, false otherwise
142
143
  */
143
- export async function importSocialIdentityProviderFromFile(providerId, file) {
144
+ export async function importSocialIdentityProviderFromFile(providerId, file, options = {
145
+ deps: true
146
+ }) {
144
147
  let outcome = false;
145
148
  const filePath = getFilePath(file);
146
149
  const indicatorId = createProgressIndicator('indeterminate', 0, `Importing provider ${providerId} from ${filePath}...`);
147
150
  try {
148
151
  const data = fs.readFileSync(filePath, 'utf8');
149
152
  const fileData = JSON.parse(data);
150
- await importSocialIdentityProvider(providerId, fileData);
153
+ await importSocialIdentityProvider(providerId, fileData, options);
151
154
  outcome = true;
152
155
  stopProgressIndicator(indicatorId, `Successfully imported provider ${providerId} from ${filePath}.`, 'success');
153
156
  } catch (error) {
@@ -161,16 +164,19 @@ export async function importSocialIdentityProviderFromFile(providerId, file) {
161
164
  /**
162
165
  * Import first provider from file
163
166
  * @param {String} file import file name
167
+ * @param {SocialIdentityProviderImportOptions} options import options
164
168
  * @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise
165
169
  */
166
- export async function importFirstSocialIdentityProviderFromFile(file) {
170
+ export async function importFirstSocialIdentityProviderFromFile(file, options = {
171
+ deps: true
172
+ }) {
167
173
  let outcome = false;
168
174
  const filePath = getFilePath(file);
169
175
  const indicatorId = createProgressIndicator('indeterminate', 0, `Importing first provider from ${filePath}...`);
170
176
  try {
171
177
  const data = fs.readFileSync(filePath, 'utf8');
172
178
  const fileData = JSON.parse(data);
173
- await importFirstSocialIdentityProvider(fileData);
179
+ await importFirstSocialIdentityProvider(fileData, options);
174
180
  outcome = true;
175
181
  stopProgressIndicator(indicatorId, `Successfully imported first provider from ${filePath}.`, 'success');
176
182
  } catch (error) {
@@ -184,16 +190,19 @@ export async function importFirstSocialIdentityProviderFromFile(file) {
184
190
  /**
185
191
  * Import all providers from file
186
192
  * @param {string} file import file name
193
+ * @param {SocialIdentityProviderImportOptions} options import options
187
194
  * @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise
188
195
  */
189
- export async function importSocialIdentityProvidersFromFile(file) {
196
+ export async function importSocialIdentityProvidersFromFile(file, options = {
197
+ deps: true
198
+ }) {
190
199
  let outcome = false;
191
200
  const filePath = getFilePath(file);
192
201
  const indicatorId = createProgressIndicator('indeterminate', 0, `Importing providers from ${filePath}...`);
193
202
  const data = fs.readFileSync(filePath, 'utf8');
194
203
  try {
195
204
  const fileData = JSON.parse(data);
196
- await importSocialIdentityProviders(fileData);
205
+ await importSocialIdentityProviders(fileData, options);
197
206
  outcome = true;
198
207
  stopProgressIndicator(indicatorId, `Successfully imported providers from ${filePath}.`, 'success');
199
208
  } catch (error) {
@@ -206,8 +215,11 @@ export async function importSocialIdentityProvidersFromFile(file) {
206
215
 
207
216
  /**
208
217
  * Import providers from *.idp.json files in current working directory
218
+ * @param {SocialIdentityProviderImportOptions} options import options
209
219
  */
210
- export async function importSocialIdentityProvidersFromFiles() {
220
+ export async function importSocialIdentityProvidersFromFiles(options = {
221
+ deps: true
222
+ }) {
211
223
  const names = fs.readdirSync(getWorkingDirectory());
212
224
  const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.idp.json')).map(name => getFilePath(name));
213
225
  const indicatorId = createProgressIndicator('determinate', jsonFiles.length, 'Importing providers...');
@@ -217,7 +229,7 @@ export async function importSocialIdentityProvidersFromFiles() {
217
229
  const fileData = JSON.parse(data);
218
230
  const count = Object.keys(fileData.idp).length;
219
231
  total += count;
220
- await importSocialIdentityProviders(fileData);
232
+ await importSocialIdentityProviders(fileData, options);
221
233
  updateProgressIndicator(indicatorId, `Imported ${count} provider(s) from ${file}`);
222
234
  }
223
235
  stopProgressIndicator(indicatorId, `Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`);
@@ -1 +1 @@
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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C;EACtD;EACA,OAAOE,OAAO;AAChB;;AAEA;AACA;AACA;AACA,OAAO,eAAeW,sCAAsCA,CAAA,EAAG;EAC7D,MAAMC,KAAK,GAAGpE,EAAE,CAACqE,WAAW,CAAClD,mBAAmB,CAAC,CAAC,CAAC;EACnD,MAAMmD,SAAS,GAAGF,KAAK,CACpBG,MAAM,CAAEzC,IAAI,IAAKA,IAAI,CAAC0C,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAC1DC,GAAG,CAAE5C,IAAI,IAAKZ,WAAW,CAACY,IAAI,CAAC,CAAC;EAEnC,MAAMiB,WAAW,GAAG9C,uBAAuB,CACzC,aAAa,EACbqE,SAAS,CAAClB,MAAM,EAChB,wBACF,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"}
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","options","deps","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 { type SocialIdentityProviderImportOptions } from '@rockcarver/frodo-lib/types/ops/IdpOps';\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 * @param {SocialIdentityProviderImportOptions} options import options\n * @returns {Promise<boolean>} true if provider was imported successfully, false otherwise\n */\nexport async function importSocialIdentityProviderFromFile(\n providerId: string,\n file: string,\n options: SocialIdentityProviderImportOptions = { deps: true }\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, options);\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 * @param {SocialIdentityProviderImportOptions} options import options\n * @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise\n */\nexport async function importFirstSocialIdentityProviderFromFile(\n file: string,\n options: SocialIdentityProviderImportOptions = { deps: true }\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, options);\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 * @param {SocialIdentityProviderImportOptions} options import options\n * @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise\n */\nexport async function importSocialIdentityProvidersFromFile(\n file: string,\n options: SocialIdentityProviderImportOptions = { deps: true }\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, options);\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 * @param {SocialIdentityProviderImportOptions} options import options\n */\nexport async function importSocialIdentityProvidersFromFiles(\n options: SocialIdentityProviderImportOptions = { deps: true }\n) {\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, options);\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;AAG7C,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,GAA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nB2C,WAAW,EACV,sBAAqB8B,KAAM,qBAAoBL,SAAS,CAACpB,MAAO,WACnE,CAAC;AACH"}
@@ -288,7 +288,7 @@ export async function importJourneysFromFile(file, options) {
288
288
  const data = fs.readFileSync(getFilePath(file), 'utf8');
289
289
  try {
290
290
  const fileData = JSON.parse(data);
291
- await importJourneys(fileData.trees, options);
291
+ await importJourneys(fileData, options);
292
292
  } catch (error) {
293
293
  if (error.name === 'UnresolvedDependenciesError') {
294
294
  for (const journey of Object.keys(error.unresolvedJourneys)) {
@@ -322,7 +322,7 @@ export async function importJourneysFromFiles(options) {
322
322
  allJourneysData.trees[journeyData.tree._id] = journeyData;
323
323
  }
324
324
  try {
325
- await importJourneys(allJourneysData.trees, options);
325
+ await importJourneys(allJourneysData, options);
326
326
  } catch (error) {
327
327
  var _error$response2;
328
328
  printMessage(`${((_error$response2 = error.response) === null || _error$response2 === void 0 || (_error$response2 = _error$response2.data) === null || _error$response2 === void 0 ? void 0 : _error$response2.message) || error.message}`, 'error');
@@ -1 +1 @@
1
- {"version":3,"file":"JourneyOps.js","names":["frodo","state","fs","createProgressIndicator","createTable","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","CirclesOfTrust","EmailTemplate","Idp","Node","Saml2","Script","Theme","cloneDeep","wordwrap","getTypedFilename","saveJsonToFile","getRealmString","getFilePath","getWorkingDirectory","utils","readJourneys","exportJourney","exportJourneys","resolveDependencies","importJourneys","importJourney","getTreeDescendents","getNodeRef","onlineTreeExportResolver","getJourneyClassification","_getJourneyClassification","disableJourney","_disableJourney","enableJourney","_enableJourney","authn","journey","listJourneys","long","analyze","journeys","journeyStub","table","_journeyStub$uiConfig","push","_id","enabled","uiConfig","categories","JSON","parse","join","toString","spinnerId","exportPromises","useStringArrays","deps","journeyExports","Promise","all","journeyExport","_journeyExport$tree$u","tree","error","response","data","_error$response","exportJourneyToFile","journeyId","file","includeMeta","options","verbose","getVerbose","filePath","fileData","exportJourneysToFile","exportJourneysToFiles","journeysExport","trees","Object","entries","treeId","treeValue","indicatorId","meta","importJourneyFromFile","readFileSync","journeyData","installedJourneys","map","x","unresolvedJourneys","resolvedJourneys","indicatorId1","keys","length","indicatorId2","importError","indicatorId3","importFirstJourneyFromFile","hasOwnProperty","call","depSpinnerId","importSpinnerId","importJourneysFromFile","name","message","type","importJourneysFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","allJourneysData","_error$response2","it","getJourneyClassificationMd","getOneLineDescription","treeObj","description","getOneLineDescriptionMd","describeTreeDescendents","descendents","depth","values","indent","Array","fill","descendent","describeTreeDescendentsMd","markdown","describeJourney","resolveTreeExport","_journeyData$meta","_journeyData$tree$uiC","_journeyData$themes","allNodes","nodes","innerNodes","nodeTypeMap","nodeData","_type","getAmVersion","originAmVersion","setAmVersion","stack","nodeType","count","String","getNodeClassification","nodeObj","themes","themeData","scripts","scriptData","emailTemplates","templateData","socialIdentityProviders","socialIdpData","saml2Entities","entityProviderData","circlesOfTrust","cotData","describeJourneyMd","_journeyData$meta2","_journeyData$tree$uiC2","_journeyData$themes2","getNodeClassificationMd","getTableHeaderMd","getTableRowMd"],"sources":["../../src/ops/JourneyOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type NodeSkeleton } from '@rockcarver/frodo-lib/types/api/NodeApi';\nimport { type TreeSkeleton } from '@rockcarver/frodo-lib/types/api/TreeApi';\nimport {\n type JourneyClassificationType,\n type MultiTreeExportInterface,\n type SingleTreeExportInterface,\n type TreeDependencyMapInterface,\n type TreeExportOptions,\n type TreeExportResolverInterface,\n type TreeImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/JourneyOps';\nimport fs from 'fs';\n\nimport {\n createProgressIndicator,\n createTable,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from '../utils/Console';\nimport * as CirclesOfTrust from './CirclesOfTrustOps';\nimport * as EmailTemplate from './EmailTemplateOps';\nimport * as Idp from './IdpOps';\nimport * as Node from './NodeOps';\nimport * as Saml2 from './Saml2Ops';\nimport * as Script from './ScriptOps';\nimport * as Theme from './ThemeOps';\nimport { cloneDeep } from './utils/OpsUtils';\nimport wordwrap from './utils/Wordwrap';\n\nconst {\n getTypedFilename,\n saveJsonToFile,\n getRealmString,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n readJourneys,\n exportJourney,\n exportJourneys,\n resolveDependencies,\n importJourneys,\n importJourney,\n getTreeDescendents,\n getNodeRef,\n onlineTreeExportResolver,\n getJourneyClassification: _getJourneyClassification,\n disableJourney: _disableJourney,\n enableJourney: _enableJourney,\n} = frodo.authn.journey;\n\n/**\n * List all the journeys/trees\n * @param {boolean} long Long version, all the fields\n * @param {boolean} analyze Analyze journeys/trees for custom nodes (expensive)\n * @returns {Promise<TreeSkeleton[]>} a promise that resolves to an array journey objects\n */\nexport async function listJourneys(\n long = false,\n analyze = false\n): Promise<TreeSkeleton[]> {\n let journeys = [];\n try {\n journeys = await readJourneys();\n if (!long && !analyze) {\n for (const journeyStub of journeys) {\n printMessage(`${journeyStub['_id']}`, 'data');\n }\n } else {\n if (!analyze) {\n const table = createTable(['Name', 'Status', 'Tags']);\n for (const journeyStub of journeys) {\n table.push([\n `${journeyStub._id}`,\n journeyStub.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n journeyStub.uiConfig?.categories\n ? wordwrap(\n JSON.parse(journeyStub.uiConfig.categories).join(', '),\n 60\n )\n : '',\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Retrieving details of all journeys...`\n );\n const exportPromises = [];\n try {\n for (const journeyStub of journeys) {\n exportPromises.push(\n exportJourney(journeyStub['_id'], {\n useStringArrays: false,\n deps: false,\n })\n );\n }\n const journeyExports = await Promise.all(exportPromises);\n stopProgressIndicator(\n spinnerId,\n 'Retrieved details of all journeys.',\n 'success'\n );\n const table = createTable([\n 'Name',\n 'Status',\n 'Classification',\n 'Tags',\n ]);\n for (const journeyExport of journeyExports) {\n table.push([\n `${journeyExport.tree._id}`,\n journeyExport.tree.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n getJourneyClassification(journeyExport).join(', '),\n journeyExport.tree.uiConfig?.categories\n ? wordwrap(\n JSON.parse(journeyExport.tree.uiConfig.categories).join(\n ', '\n ),\n 60\n )\n : '',\n ]);\n }\n printMessage(table.toString(), 'data');\n } catch (error) {\n stopProgressIndicator(\n spinnerId,\n 'Error retrieving details of all journeys.',\n 'fail'\n );\n printMessage(error.response.data, 'error');\n }\n }\n }\n } catch (error) {\n printMessage(error.response?.data, 'error');\n }\n return journeys;\n}\n\n/**\n * Export journey by id/name to file\n * @param {string} journeyId journey id/name\n * @param {string} file optional export file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneyToFile(\n journeyId: string,\n file: string,\n includeMeta = true,\n options: TreeExportOptions = {\n deps: false,\n useStringArrays: false,\n }\n): Promise<void> {\n debugMessage(`exportJourneyToFile: start`);\n const verbose = state.getVerbose();\n if (!file) {\n file = getTypedFilename(journeyId, 'journey');\n }\n const filePath = getFilePath(file, true);\n let spinnerId: string;\n if (!verbose)\n spinnerId = createProgressIndicator('indeterminate', 0, `${journeyId}`);\n try {\n const fileData: SingleTreeExportInterface = await exportJourney(\n journeyId,\n options\n );\n if (verbose)\n spinnerId = createProgressIndicator('indeterminate', 0, `${journeyId}`);\n saveJsonToFile(fileData, filePath, includeMeta);\n stopProgressIndicator(\n spinnerId,\n `Exported ${journeyId['brightCyan']} to ${filePath['brightCyan']}.`,\n 'success'\n );\n } catch (error) {\n if (verbose)\n spinnerId = createProgressIndicator('indeterminate', 0, `${journeyId}`);\n stopProgressIndicator(\n spinnerId,\n `Error exporting journey ${journeyId}: ${error}`,\n 'fail'\n );\n }\n}\n\n/**\n * Export all journeys to file\n * @param {string} file optional export file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneysToFile(\n file: string,\n includeMeta = true,\n options: TreeExportOptions = {\n deps: false,\n useStringArrays: false,\n }\n): Promise<void> {\n if (!file) {\n file = getTypedFilename(`all${getRealmString()}Journeys`, 'journey');\n }\n const filePath = getFilePath(file, true);\n const fileData: MultiTreeExportInterface = await exportJourneys(options);\n saveJsonToFile(fileData, filePath, includeMeta);\n}\n\n/**\n * Export all journeys to separate files\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneysToFiles(\n includeMeta = true,\n options: TreeExportOptions = {\n deps: false,\n useStringArrays: false,\n }\n): Promise<void> {\n const journeysExport = await exportJourneys(options);\n const trees = Object.entries(journeysExport.trees);\n for (const [treeId, treeValue] of trees) {\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Saving ${treeId}...`\n );\n const file = getFilePath(getTypedFilename(`${treeId}`, 'journey'), true);\n treeValue['meta'] = journeysExport.meta;\n try {\n updateProgressIndicator(indicatorId, `Saving ${treeId} to ${file}`);\n saveJsonToFile(treeValue, file, includeMeta);\n stopProgressIndicator(indicatorId, `${treeId} saved to ${file}`);\n } catch (error) {\n stopProgressIndicator(indicatorId, `Error saving ${treeId} to ${file}`);\n }\n }\n}\n\n/**\n * Import a journey from file\n * @param {string} journeyId journey id/name\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneyFromFile(\n journeyId: string,\n file: string,\n options: TreeImportOptions\n) {\n const verbose = state.getVerbose();\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n let journeyData = JSON.parse(data);\n // check if this is a file with multiple trees and get journey by id\n if (journeyData.trees && journeyData.trees[journeyId]) {\n journeyData = journeyData.trees[journeyId];\n } else if (journeyData.trees) {\n journeyData = null;\n }\n\n // if a journeyId was specified, only import the matching journey\n if (journeyData && journeyId === journeyData.tree._id) {\n // attempt dependency resolution for single tree import\n const installedJourneys = (await readJourneys()).map((x) => x._id);\n const unresolvedJourneys = {};\n const resolvedJourneys = [];\n const indicatorId1 = createProgressIndicator(\n 'indeterminate',\n 0,\n 'Resolving dependencies'\n );\n await resolveDependencies(\n installedJourneys,\n { [journeyId]: journeyData },\n unresolvedJourneys,\n resolvedJourneys\n );\n if (Object.keys(unresolvedJourneys).length === 0) {\n stopProgressIndicator(\n indicatorId1,\n `Resolved all dependencies.`,\n 'success'\n );\n\n let indicatorId2: string;\n if (!verbose)\n indicatorId2 = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${journeyId}...`\n );\n try {\n await importJourney(journeyData, options);\n if (verbose)\n indicatorId2 = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${journeyId}...`\n );\n stopProgressIndicator(\n indicatorId2,\n `Imported ${journeyId}.`,\n 'success'\n );\n } catch (importError) {\n if (verbose)\n indicatorId2 = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${journeyId}...`\n );\n stopProgressIndicator(indicatorId2, `${importError}`, 'fail');\n }\n } else {\n stopProgressIndicator(indicatorId1, `Unresolved dependencies:`, 'fail');\n for (const journey of Object.keys(unresolvedJourneys)) {\n printMessage(\n ` ${journey} requires ${unresolvedJourneys[journey]}`,\n 'error'\n );\n }\n }\n // end dependency resolution for single tree import\n } else {\n const indicatorId3 = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${journeyId}...`\n );\n stopProgressIndicator(indicatorId3, `${journeyId} not found!`, 'fail');\n }\n } catch (error) {\n printMessage(`Error importing journey ${journeyId}: ${error}`, 'error');\n }\n}\n\n/**\n * Import first journey from file\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importFirstJourneyFromFile(\n file: string,\n options: TreeImportOptions\n) {\n const verbose = state.getVerbose();\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n let journeyData = cloneDeep(JSON.parse(data));\n let journeyId = null;\n // single tree\n if (journeyData.tree) {\n journeyId = cloneDeep(journeyData.tree._id);\n }\n // multiple trees, so get the first tree\n else if (journeyData.trees) {\n for (const treeId in journeyData.trees) {\n if (Object.hasOwnProperty.call(journeyData.trees, treeId)) {\n journeyId = treeId;\n journeyData = journeyData.trees[treeId];\n break;\n }\n }\n }\n\n // if a journeyId was specified, only import the matching journey\n if (journeyData && journeyId) {\n // attempt dependency resolution for single tree import\n const installedJourneys = (await readJourneys()).map((x) => x._id);\n const unresolvedJourneys = {};\n const resolvedJourneys = [];\n const depSpinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n 'Resolving dependencies'\n );\n await resolveDependencies(\n installedJourneys,\n { [journeyId]: journeyData },\n unresolvedJourneys,\n resolvedJourneys\n );\n if (Object.keys(unresolvedJourneys).length === 0) {\n stopProgressIndicator(\n depSpinnerId,\n `Resolved all dependencies.`,\n 'success'\n );\n\n let importSpinnerId: string;\n if (!verbose)\n importSpinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${journeyId}...`\n );\n try {\n await importJourney(journeyData, options);\n if (verbose)\n importSpinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${journeyId}...`\n );\n stopProgressIndicator(\n importSpinnerId,\n `Imported ${journeyId}.`,\n 'success'\n );\n } catch (importError) {\n if (verbose)\n importSpinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${journeyId}...`\n );\n stopProgressIndicator(importSpinnerId, `${importError}`, 'fail');\n }\n } else {\n stopProgressIndicator(depSpinnerId, `Unresolved dependencies:`, 'fail');\n for (const journey of Object.keys(unresolvedJourneys)) {\n printMessage(\n ` ${journey} requires ${unresolvedJourneys[journey]}`,\n 'error'\n );\n }\n }\n } else {\n const importSpinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing...`\n );\n stopProgressIndicator(importSpinnerId, `No journeys found!`, 'fail');\n }\n // end dependency resolution for single tree import\n } catch (error) {\n printMessage(`Error importing first journey: ${error}`, 'error');\n }\n}\n\n/**\n * Import all journeys from file\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneysFromFile(\n file: string,\n options: TreeImportOptions\n) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n try {\n const fileData = JSON.parse(data);\n await importJourneys(fileData.trees, options);\n } catch (error) {\n if (error.name === 'UnresolvedDependenciesError') {\n for (const journey of Object.keys(error.unresolvedJourneys)) {\n printMessage({\n message: ` - ${journey} requires ${error.unresolvedJourneys[journey]}`,\n type: 'info',\n state,\n });\n }\n } else {\n printMessage(`${error.message}`, 'error');\n }\n }\n } catch (error) {\n printMessage(`Error importing journeys: ${error}`, 'error');\n }\n}\n\n/**\n * Import all journeys from separate files\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneysFromFiles(options: TreeImportOptions) {\n const names = fs.readdirSync(getWorkingDirectory());\n const jsonFiles = names\n .filter((name) => name.toLowerCase().endsWith('.journey.json'))\n .map((name) => getFilePath(name));\n const allJourneysData = { trees: {} };\n for (const file of jsonFiles) {\n const journeyData = JSON.parse(fs.readFileSync(file, 'utf8'));\n allJourneysData.trees[journeyData.tree._id] = journeyData;\n }\n try {\n await importJourneys(\n allJourneysData.trees as MultiTreeExportInterface,\n options\n );\n } catch (error) {\n printMessage(`${error.response?.data?.message || error.message}`, 'error');\n }\n}\n\n/**\n * Get journey classification\n * @param {SingleTreeExportInterface} journey journey export\n * @returns {string[]} Colored string array of classifications\n */\nexport function getJourneyClassification(\n journey: SingleTreeExportInterface\n): JourneyClassificationType[] {\n return _getJourneyClassification(journey).map((it) => {\n switch (it) {\n case 'standard':\n return it['brightGreen'];\n\n case 'cloud':\n return it['brightMagenta'];\n\n case 'custom':\n return it['brightRed'];\n\n case 'premium':\n return it['brightYellow'];\n }\n });\n}\n\n/**\n * Get journey classification in markdown\n * @param {SingleTreeExportInterface} journey journey export\n * @returns {string[]} Colored string array of classifications\n */\nexport function getJourneyClassificationMd(\n journey: SingleTreeExportInterface\n): string[] {\n return _getJourneyClassification(journey).map((it) => {\n switch (it) {\n case 'standard':\n return `:green_circle: \\`${it}\\``;\n\n case 'cloud':\n return `:purple_circle: \\`${it}\\``;\n\n case 'custom':\n return `:red_circle: \\`${it}\\``;\n\n case 'premium':\n return `:yellow_circle: \\`${it}\\``;\n }\n });\n}\n\n/**\n * Get a one-line description of the tree object\n * @param {TreeSkeleton} treeObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(treeObj: TreeSkeleton): string {\n const description = `[${treeObj._id['brightCyan']}]`;\n return description;\n}\n\n/**\n * Get a one-line description of the tree object in markdown\n * @param {TreeSkeleton} treeObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescriptionMd(treeObj: TreeSkeleton): string {\n const description = `${treeObj._id}`;\n return description;\n}\n\n/**\n * Helper function to render a nested list of dependent trees\n * @param {TreeDependencyMapInterface} descendents tree dependency map\n * @param {number} depth level of nesting\n */\nfunction describeTreeDescendents(\n descendents: TreeDependencyMapInterface,\n depth = 0\n) {\n if (depth || Object.values(descendents)[0].length) {\n // heading\n if (depth === 0) {\n printMessage(\n `\\nInner Tree Dependencies (${Object.values(descendents)[0].length}):`,\n 'data'\n );\n }\n const indent = Array(depth * 2)\n .fill(' ')\n .join('');\n const [tree] = Object.keys(descendents);\n printMessage(`${indent}- ${tree['brightCyan']}`, 'data');\n for (const descendent of descendents[tree]) {\n describeTreeDescendents(descendent, depth + 1);\n }\n }\n}\n\n/**\n * Helper function to render a nested list of dependent trees in markdown\n * @param {TreeDependencyMapInterface} descendents tree dependency map\n * @param {number} depth level of nesting\n */\nfunction describeTreeDescendentsMd(\n descendents: TreeDependencyMapInterface,\n depth = 0\n): string {\n let markdown = '';\n if (depth || Object.values(descendents)[0].length) {\n // heading\n if (depth === 0) {\n markdown += `## Inner Tree Dependencies (${\n Object.values(descendents)[0].length\n })\\n`;\n }\n const indent = Array(depth * 2)\n .fill(' ')\n .join('');\n const [tree] = Object.keys(descendents);\n markdown += `${indent}- ${tree}\\n`;\n for (const descendent of descendents[tree]) {\n markdown += describeTreeDescendentsMd(descendent, depth + 1);\n }\n return markdown;\n }\n return markdown;\n}\n\n/**\n * Describe a journey:\n * - Properties, tags, description, name, metadata\n * - Inner tree dependency tree\n * - Node type summary\n * - Nodes\n * - Themes\n * - Scripts\n * - Email templates\n * - Social identity providers\n * - SAML2 entity providers\n * - SAML2 circles of trust\n * @param {SingleTreeExportInterface} journeyData journey export object\n * @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function\n */\nexport async function describeJourney(\n journeyData: SingleTreeExportInterface,\n resolveTreeExport: TreeExportResolverInterface = onlineTreeExportResolver\n): Promise<void> {\n const allNodes = {\n ...journeyData.nodes,\n ...journeyData.innerNodes,\n };\n const nodeTypeMap = {};\n\n for (const nodeData of Object.values(allNodes)) {\n if (nodeTypeMap[nodeData._type._id]) {\n nodeTypeMap[nodeData._type._id] += 1;\n } else {\n nodeTypeMap[nodeData._type._id] = 1;\n }\n }\n\n // initialize AM version from file\n if (!state.getAmVersion() && journeyData.meta?.originAmVersion) {\n state.setAmVersion(journeyData.meta.originAmVersion);\n }\n\n // Journey Name\n printMessage(`${getOneLineDescription(journeyData.tree)}`, 'data');\n printMessage(Array(`[${journeyData.tree._id}]`['length']).fill('=').join(''));\n\n // Description\n if (journeyData.tree.description) {\n printMessage(`\\n${journeyData.tree.description}`, 'data');\n }\n\n // Status\n printMessage(\n `\\nStatus\\n${\n journeyData.tree.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen']\n }`\n );\n\n // Classification\n if (state.getAmVersion()) {\n printMessage(\n `\\nClassification\\n${getJourneyClassification(journeyData).join(', ')}`,\n 'data'\n );\n }\n\n // Categories/Tags\n if (\n journeyData.tree.uiConfig?.categories &&\n journeyData.tree.uiConfig.categories != '[]'\n ) {\n printMessage('\\nCategories/Tags', 'data');\n printMessage(\n `${JSON.parse(journeyData.tree.uiConfig.categories).join(', ')}`,\n 'data'\n );\n }\n\n // Dependency Tree\n try {\n const descendents = await getTreeDescendents(\n journeyData,\n resolveTreeExport\n );\n describeTreeDescendents(descendents);\n } catch (error) {\n printMessage(`Error resolving inner tree dependencies:`, 'error');\n printMessage(error.stack, 'error');\n }\n\n // Node Types\n if (Object.entries(nodeTypeMap).length) {\n printMessage(\n `\\nNode Types (${Object.entries(nodeTypeMap).length}):`,\n 'data'\n );\n for (const [nodeType, count] of Object.entries(nodeTypeMap)) {\n printMessage(\n `- ${String(count)} [${\n nodeType['brightCyan']\n }] (${Node.getNodeClassification(nodeType).join(', ')})`,\n 'data'\n );\n }\n }\n\n // Nodes\n if (Object.entries(allNodes).length) {\n printMessage(`\\nNodes (${Object.entries(allNodes).length}):`, 'data');\n for (const nodeObj of Object.values<NodeSkeleton>(allNodes)) {\n printMessage(\n `- ${Node.getOneLineDescription(\n nodeObj,\n getNodeRef(nodeObj, journeyData)\n )}`,\n 'data'\n );\n }\n }\n\n // Themes\n if (journeyData.themes?.length) {\n printMessage(`\\nThemes (${journeyData.themes.length}):`, 'data');\n for (const themeData of journeyData.themes) {\n printMessage(`- ${Theme.getOneLineDescription(themeData)}`, 'data');\n }\n }\n\n // Scripts\n if (Object.entries(journeyData.scripts).length) {\n printMessage(\n `\\nScripts (${Object.entries(journeyData.scripts).length}):`,\n 'data'\n );\n for (const scriptData of Object.values(journeyData.scripts)) {\n printMessage(`- ${Script.getOneLineDescription(scriptData)}`, 'data');\n }\n }\n\n // Email Templates\n if (Object.entries(journeyData.emailTemplates).length) {\n printMessage(\n `\\nEmail Templates (${\n Object.entries(journeyData.emailTemplates).length\n }):`,\n 'data'\n );\n for (const templateData of Object.values(journeyData.emailTemplates)) {\n printMessage(\n `- ${EmailTemplate.getOneLineDescription(templateData)}`,\n 'data'\n );\n }\n }\n\n // Social Identity Providers\n if (Object.entries(journeyData.socialIdentityProviders).length) {\n printMessage(\n `\\nSocial Identity Providers (${\n Object.entries(journeyData.socialIdentityProviders).length\n }):`,\n 'data'\n );\n for (const socialIdpData of Object.values(\n journeyData.socialIdentityProviders\n )) {\n printMessage(`- ${Idp.getOneLineDescription(socialIdpData)}`, 'data');\n }\n }\n\n // SAML2 Entity Providers\n if (Object.entries(journeyData.saml2Entities).length) {\n printMessage(\n `\\nSAML2 Entity Providers (${\n Object.entries(journeyData.saml2Entities).length\n }):`,\n 'data'\n );\n for (const entityProviderData of Object.values(journeyData.saml2Entities)) {\n printMessage(\n `- ${Saml2.getOneLineDescription(entityProviderData)}`,\n 'data'\n );\n }\n }\n\n // SAML2 Circles Of Trust\n if (Object.entries(journeyData.circlesOfTrust).length) {\n printMessage(\n `\\nSAML2 Circles Of Trust (${\n Object.entries(journeyData.circlesOfTrust).length\n }):`,\n 'data'\n );\n for (const cotData of Object.values(journeyData.circlesOfTrust)) {\n printMessage(\n `- ${CirclesOfTrust.getOneLineDescription(cotData)}`,\n 'data'\n );\n }\n }\n}\n\n/**\n * Describe a journey in markdown:\n * - Properties, tags, description, name, metadata\n * - Inner tree dependency tree\n * - Node type summary\n * - Nodes\n * - Themes\n * - Scripts\n * - Email templates\n * - Social identity providers\n * - SAML2 entity providers\n * - SAML2 circles of trust\n * @param {SingleTreeExportInterface} journeyData journey export object\n * @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function\n */\nexport async function describeJourneyMd(\n journeyData: SingleTreeExportInterface,\n resolveTreeExport: TreeExportResolverInterface = onlineTreeExportResolver\n) {\n const allNodes = {\n ...journeyData.nodes,\n ...journeyData.innerNodes,\n };\n const nodeTypeMap = {};\n\n for (const nodeData of Object.values(allNodes)) {\n if (nodeTypeMap[nodeData._type._id]) {\n nodeTypeMap[nodeData._type._id] += 1;\n } else {\n nodeTypeMap[nodeData._type._id] = 1;\n }\n }\n\n // initialize AM version from file\n if (!state.getAmVersion() && journeyData.meta?.originAmVersion) {\n state.setAmVersion(journeyData.meta.originAmVersion);\n }\n\n // Journey Name\n printMessage(\n `# ${getOneLineDescriptionMd(journeyData.tree)} - ${\n journeyData.tree.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n }, ${getJourneyClassificationMd(journeyData).join(', ')}`,\n 'data'\n );\n\n // Categories/Tags\n if (\n journeyData.tree.uiConfig?.categories &&\n journeyData.tree.uiConfig.categories != '[]'\n ) {\n printMessage(\n `\\`${JSON.parse(journeyData.tree.uiConfig.categories).join('`, `')}\\``,\n 'data'\n );\n }\n\n // Description\n if (journeyData.tree.description) {\n printMessage(`\\n${journeyData.tree.description}`, 'data');\n }\n\n // Journey image\n printMessage(`\\n[![](./${journeyData.tree._id}.png)]()\\n`, 'data');\n\n // Dependency Tree\n const descendents = await getTreeDescendents(journeyData, resolveTreeExport);\n printMessage(describeTreeDescendentsMd(descendents), 'data');\n\n // Node Types\n if (Object.entries(nodeTypeMap).length) {\n printMessage(\n `## Node Types (${Object.entries(nodeTypeMap).length})`,\n 'data'\n );\n printMessage('| Count | Type | Classification |', 'data');\n printMessage('| -----:| ---- | -------------- |', 'data');\n for (const [nodeType, count] of Object.entries(nodeTypeMap)) {\n printMessage(\n `| ${String(count)} | ${nodeType} | ${Node.getNodeClassificationMd(\n nodeType\n ).join('<br>')} |`,\n 'data'\n );\n }\n }\n\n // Nodes\n if (Object.entries(allNodes).length) {\n printMessage(`## Nodes (${Object.entries(allNodes).length})`, 'data');\n printMessage(Node.getTableHeaderMd(), 'data');\n for (const nodeObj of Object.values<NodeSkeleton>(allNodes)) {\n printMessage(\n `${Node.getTableRowMd(nodeObj, getNodeRef(nodeObj, journeyData))}`,\n 'data'\n );\n }\n }\n\n // Themes\n if (journeyData.themes?.length) {\n printMessage(`## Themes (${journeyData.themes.length})`, 'data');\n printMessage(Theme.getTableHeaderMd(), 'data');\n for (const themeData of journeyData.themes) {\n printMessage(`${Theme.getTableRowMd(themeData)}`, 'data');\n }\n }\n\n // Scripts\n if (Object.entries(journeyData.scripts).length) {\n printMessage(\n `## Scripts (${Object.entries(journeyData.scripts).length})`,\n 'data'\n );\n printMessage(Script.getTableHeaderMd(), 'data');\n for (const scriptData of Object.values(journeyData.scripts)) {\n printMessage(`${Script.getTableRowMd(scriptData)}`, 'data');\n }\n }\n\n // Email Templates\n if (Object.entries(journeyData.emailTemplates).length) {\n printMessage(\n `## Email Templates (${\n Object.entries(journeyData.emailTemplates).length\n })`,\n 'data'\n );\n printMessage(EmailTemplate.getTableHeaderMd(), 'data');\n for (const templateData of Object.values(journeyData.emailTemplates)) {\n printMessage(`${EmailTemplate.getTableRowMd(templateData)}`, 'data');\n }\n }\n\n // Social Identity Providers\n if (Object.entries(journeyData.socialIdentityProviders).length) {\n printMessage(\n `## Social Identity Providers (${\n Object.entries(journeyData.socialIdentityProviders).length\n })`,\n 'data'\n );\n printMessage(Idp.getTableHeaderMd(), 'data');\n for (const socialIdpData of Object.values(\n journeyData.socialIdentityProviders\n )) {\n printMessage(`${Idp.getTableRowMd(socialIdpData)}`, 'data');\n }\n }\n\n // SAML2 Entity Providers\n if (Object.entries(journeyData.saml2Entities).length) {\n printMessage(\n `## SAML2 Entity Providers (${\n Object.entries(journeyData.saml2Entities).length\n })`,\n 'data'\n );\n printMessage(Saml2.getTableHeaderMd(), 'data');\n for (const entityProviderData of Object.values(journeyData.saml2Entities)) {\n printMessage(`${Saml2.getTableRowMd(entityProviderData)}`, 'data');\n }\n }\n\n // SAML2 Circles Of Trust\n if (Object.entries(journeyData.circlesOfTrust).length) {\n printMessage(\n `## SAML2 Circles Of Trust (${\n Object.entries(journeyData.circlesOfTrust).length\n })`,\n 'data'\n );\n printMessage(CirclesOfTrust.getTableHeaderMd(), 'data');\n for (const cotData of Object.values(journeyData.circlesOfTrust)) {\n printMessage(`${CirclesOfTrust.getTableRowMd(cotData)}`, 'data');\n }\n }\n}\n\nexport async function enableJourney(journeyId: string): Promise<boolean> {\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Enabling journey ${journeyId}...`\n );\n if (_enableJourney(journeyId)) {\n stopProgressIndicator(\n indicatorId,\n `Enabled journey ${journeyId}.`,\n 'success'\n );\n return true;\n } else {\n stopProgressIndicator(\n indicatorId,\n `Error enabling journey ${journeyId}`,\n 'fail'\n );\n return false;\n }\n}\n\nexport async function disableJourney(journeyId: string): Promise<boolean> {\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Disabling journey ${journeyId}...`\n );\n if (_disableJourney(journeyId)) {\n stopProgressIndicator(\n indicatorId,\n `Disabled journey ${journeyId}.`,\n 'success'\n );\n return true;\n } else {\n stopProgressIndicator(\n indicatorId,\n `Error disabling journey ${journeyId}`,\n 'fail'\n );\n return false;\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAYpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,uBAAuB,EACvBC,WAAW,EACXC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,QAClB,kBAAkB;AACzB,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AACrD,OAAO,KAAKC,aAAa,MAAM,oBAAoB;AACnD,OAAO,KAAKC,GAAG,MAAM,UAAU;AAC/B,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,OAAO,KAAKC,KAAK,MAAM,YAAY;AACnC,OAAO,KAAKC,MAAM,MAAM,aAAa;AACrC,OAAO,KAAKC,KAAK,MAAM,YAAY;AACnC,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,OAAOC,QAAQ,MAAM,kBAAkB;AAEvC,MAAM;EACJC,gBAAgB;EAChBC,cAAc;EACdC,cAAc;EACdC,WAAW;EACXC;AACF,CAAC,GAAGtB,KAAK,CAACuB,KAAK;AACf,MAAM;EACJC,YAAY;EACZC,aAAa;EACbC,cAAc;EACdC,mBAAmB;EACnBC,cAAc;EACdC,aAAa;EACbC,kBAAkB;EAClBC,UAAU;EACVC,wBAAwB;EACxBC,wBAAwB,EAAEC,yBAAyB;EACnDC,cAAc,EAAEC,eAAe;EAC/BC,aAAa,EAAEC;AACjB,CAAC,GAAGtC,KAAK,CAACuC,KAAK,CAACC,OAAO;;AAEvB;AACA;AACA;AACA;AACA;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AU,EAAC,EACtC,MACF,CAAC;IACD,OAAO,KAAK;EACd;AACF"}
1
+ {"version":3,"file":"JourneyOps.js","names":["frodo","state","fs","createProgressIndicator","createTable","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","CirclesOfTrust","EmailTemplate","Idp","Node","Saml2","Script","Theme","cloneDeep","wordwrap","getTypedFilename","saveJsonToFile","getRealmString","getFilePath","getWorkingDirectory","utils","readJourneys","exportJourney","exportJourneys","resolveDependencies","importJourneys","importJourney","getTreeDescendents","getNodeRef","onlineTreeExportResolver","getJourneyClassification","_getJourneyClassification","disableJourney","_disableJourney","enableJourney","_enableJourney","authn","journey","listJourneys","long","analyze","journeys","journeyStub","table","_journeyStub$uiConfig","push","_id","enabled","uiConfig","categories","JSON","parse","join","toString","spinnerId","exportPromises","useStringArrays","deps","journeyExports","Promise","all","journeyExport","_journeyExport$tree$u","tree","error","response","data","_error$response","exportJourneyToFile","journeyId","file","includeMeta","options","verbose","getVerbose","filePath","fileData","exportJourneysToFile","exportJourneysToFiles","journeysExport","trees","Object","entries","treeId","treeValue","indicatorId","meta","importJourneyFromFile","readFileSync","journeyData","installedJourneys","map","x","unresolvedJourneys","resolvedJourneys","indicatorId1","keys","length","indicatorId2","importError","indicatorId3","importFirstJourneyFromFile","hasOwnProperty","call","depSpinnerId","importSpinnerId","importJourneysFromFile","name","message","type","importJourneysFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","allJourneysData","_error$response2","it","getJourneyClassificationMd","getOneLineDescription","treeObj","description","getOneLineDescriptionMd","describeTreeDescendents","descendents","depth","values","indent","Array","fill","descendent","describeTreeDescendentsMd","markdown","describeJourney","resolveTreeExport","_journeyData$meta","_journeyData$tree$uiC","_journeyData$themes","allNodes","nodes","innerNodes","nodeTypeMap","nodeData","_type","getAmVersion","originAmVersion","setAmVersion","stack","nodeType","count","String","getNodeClassification","nodeObj","themes","themeData","scripts","scriptData","emailTemplates","templateData","socialIdentityProviders","socialIdpData","saml2Entities","entityProviderData","circlesOfTrust","cotData","describeJourneyMd","_journeyData$meta2","_journeyData$tree$uiC2","_journeyData$themes2","getNodeClassificationMd","getTableHeaderMd","getTableRowMd"],"sources":["../../src/ops/JourneyOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type NodeSkeleton } from '@rockcarver/frodo-lib/types/api/NodeApi';\nimport { type TreeSkeleton } from '@rockcarver/frodo-lib/types/api/TreeApi';\nimport {\n type JourneyClassificationType,\n type MultiTreeExportInterface,\n type SingleTreeExportInterface,\n type TreeDependencyMapInterface,\n type TreeExportOptions,\n type TreeExportResolverInterface,\n type TreeImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/JourneyOps';\nimport fs from 'fs';\n\nimport {\n createProgressIndicator,\n createTable,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from '../utils/Console';\nimport * as CirclesOfTrust from './CirclesOfTrustOps';\nimport * as EmailTemplate from './EmailTemplateOps';\nimport * as Idp from './IdpOps';\nimport * as Node from './NodeOps';\nimport * as Saml2 from './Saml2Ops';\nimport * as Script from './ScriptOps';\nimport * as Theme from './ThemeOps';\nimport { cloneDeep } from './utils/OpsUtils';\nimport wordwrap from './utils/Wordwrap';\n\nconst {\n getTypedFilename,\n saveJsonToFile,\n getRealmString,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n readJourneys,\n exportJourney,\n exportJourneys,\n resolveDependencies,\n importJourneys,\n importJourney,\n getTreeDescendents,\n getNodeRef,\n onlineTreeExportResolver,\n getJourneyClassification: _getJourneyClassification,\n disableJourney: _disableJourney,\n enableJourney: _enableJourney,\n} = frodo.authn.journey;\n\n/**\n * List all the journeys/trees\n * @param {boolean} long Long version, all the fields\n * @param {boolean} analyze Analyze journeys/trees for custom nodes (expensive)\n * @returns {Promise<TreeSkeleton[]>} a promise that resolves to an array journey objects\n */\nexport async function listJourneys(\n long = false,\n analyze = false\n): Promise<TreeSkeleton[]> {\n let journeys = [];\n try {\n journeys = await readJourneys();\n if (!long && !analyze) {\n for (const journeyStub of journeys) {\n printMessage(`${journeyStub['_id']}`, 'data');\n }\n } else {\n if (!analyze) {\n const table = createTable(['Name', 'Status', 'Tags']);\n for (const journeyStub of journeys) {\n table.push([\n `${journeyStub._id}`,\n journeyStub.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n journeyStub.uiConfig?.categories\n ? wordwrap(\n JSON.parse(journeyStub.uiConfig.categories).join(', '),\n 60\n )\n : '',\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n const spinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Retrieving details of all journeys...`\n );\n const exportPromises = [];\n try {\n for (const journeyStub of journeys) {\n exportPromises.push(\n exportJourney(journeyStub['_id'], {\n useStringArrays: false,\n deps: false,\n })\n );\n }\n const journeyExports = await Promise.all(exportPromises);\n stopProgressIndicator(\n spinnerId,\n 'Retrieved details of all journeys.',\n 'success'\n );\n const table = createTable([\n 'Name',\n 'Status',\n 'Classification',\n 'Tags',\n ]);\n for (const journeyExport of journeyExports) {\n table.push([\n `${journeyExport.tree._id}`,\n journeyExport.tree.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n getJourneyClassification(journeyExport).join(', '),\n journeyExport.tree.uiConfig?.categories\n ? wordwrap(\n JSON.parse(journeyExport.tree.uiConfig.categories).join(\n ', '\n ),\n 60\n )\n : '',\n ]);\n }\n printMessage(table.toString(), 'data');\n } catch (error) {\n stopProgressIndicator(\n spinnerId,\n 'Error retrieving details of all journeys.',\n 'fail'\n );\n printMessage(error.response.data, 'error');\n }\n }\n }\n } catch (error) {\n printMessage(error.response?.data, 'error');\n }\n return journeys;\n}\n\n/**\n * Export journey by id/name to file\n * @param {string} journeyId journey id/name\n * @param {string} file optional export file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneyToFile(\n journeyId: string,\n file: string,\n includeMeta = true,\n options: TreeExportOptions = {\n deps: false,\n useStringArrays: false,\n }\n): Promise<void> {\n debugMessage(`exportJourneyToFile: start`);\n const verbose = state.getVerbose();\n if (!file) {\n file = getTypedFilename(journeyId, 'journey');\n }\n const filePath = getFilePath(file, true);\n let spinnerId: string;\n if (!verbose)\n spinnerId = createProgressIndicator('indeterminate', 0, `${journeyId}`);\n try {\n const fileData: SingleTreeExportInterface = await exportJourney(\n journeyId,\n options\n );\n if (verbose)\n spinnerId = createProgressIndicator('indeterminate', 0, `${journeyId}`);\n saveJsonToFile(fileData, filePath, includeMeta);\n stopProgressIndicator(\n spinnerId,\n `Exported ${journeyId['brightCyan']} to ${filePath['brightCyan']}.`,\n 'success'\n );\n } catch (error) {\n if (verbose)\n spinnerId = createProgressIndicator('indeterminate', 0, `${journeyId}`);\n stopProgressIndicator(\n spinnerId,\n `Error exporting journey ${journeyId}: ${error}`,\n 'fail'\n );\n }\n}\n\n/**\n * Export all journeys to file\n * @param {string} file optional export file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneysToFile(\n file: string,\n includeMeta = true,\n options: TreeExportOptions = {\n deps: false,\n useStringArrays: false,\n }\n): Promise<void> {\n if (!file) {\n file = getTypedFilename(`all${getRealmString()}Journeys`, 'journey');\n }\n const filePath = getFilePath(file, true);\n const fileData: MultiTreeExportInterface = await exportJourneys(options);\n saveJsonToFile(fileData, filePath, includeMeta);\n}\n\n/**\n * Export all journeys to separate files\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {TreeExportOptions} options export options\n */\nexport async function exportJourneysToFiles(\n includeMeta = true,\n options: TreeExportOptions = {\n deps: false,\n useStringArrays: false,\n }\n): Promise<void> {\n const journeysExport = await exportJourneys(options);\n const trees = Object.entries(journeysExport.trees);\n for (const [treeId, treeValue] of trees) {\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Saving ${treeId}...`\n );\n const file = getFilePath(getTypedFilename(`${treeId}`, 'journey'), true);\n treeValue['meta'] = journeysExport.meta;\n try {\n updateProgressIndicator(indicatorId, `Saving ${treeId} to ${file}`);\n saveJsonToFile(treeValue, file, includeMeta);\n stopProgressIndicator(indicatorId, `${treeId} saved to ${file}`);\n } catch (error) {\n stopProgressIndicator(indicatorId, `Error saving ${treeId} to ${file}`);\n }\n }\n}\n\n/**\n * Import a journey from file\n * @param {string} journeyId journey id/name\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneyFromFile(\n journeyId: string,\n file: string,\n options: TreeImportOptions\n) {\n const verbose = state.getVerbose();\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n let journeyData = JSON.parse(data);\n // check if this is a file with multiple trees and get journey by id\n if (journeyData.trees && journeyData.trees[journeyId]) {\n journeyData = journeyData.trees[journeyId];\n } else if (journeyData.trees) {\n journeyData = null;\n }\n\n // if a journeyId was specified, only import the matching journey\n if (journeyData && journeyId === journeyData.tree._id) {\n // attempt dependency resolution for single tree import\n const installedJourneys = (await readJourneys()).map((x) => x._id);\n const unresolvedJourneys = {};\n const resolvedJourneys = [];\n const indicatorId1 = createProgressIndicator(\n 'indeterminate',\n 0,\n 'Resolving dependencies'\n );\n await resolveDependencies(\n installedJourneys,\n { [journeyId]: journeyData },\n unresolvedJourneys,\n resolvedJourneys\n );\n if (Object.keys(unresolvedJourneys).length === 0) {\n stopProgressIndicator(\n indicatorId1,\n `Resolved all dependencies.`,\n 'success'\n );\n\n let indicatorId2: string;\n if (!verbose)\n indicatorId2 = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${journeyId}...`\n );\n try {\n await importJourney(journeyData, options);\n if (verbose)\n indicatorId2 = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${journeyId}...`\n );\n stopProgressIndicator(\n indicatorId2,\n `Imported ${journeyId}.`,\n 'success'\n );\n } catch (importError) {\n if (verbose)\n indicatorId2 = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${journeyId}...`\n );\n stopProgressIndicator(indicatorId2, `${importError}`, 'fail');\n }\n } else {\n stopProgressIndicator(indicatorId1, `Unresolved dependencies:`, 'fail');\n for (const journey of Object.keys(unresolvedJourneys)) {\n printMessage(\n ` ${journey} requires ${unresolvedJourneys[journey]}`,\n 'error'\n );\n }\n }\n // end dependency resolution for single tree import\n } else {\n const indicatorId3 = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${journeyId}...`\n );\n stopProgressIndicator(indicatorId3, `${journeyId} not found!`, 'fail');\n }\n } catch (error) {\n printMessage(`Error importing journey ${journeyId}: ${error}`, 'error');\n }\n}\n\n/**\n * Import first journey from file\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importFirstJourneyFromFile(\n file: string,\n options: TreeImportOptions\n) {\n const verbose = state.getVerbose();\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n let journeyData = cloneDeep(JSON.parse(data));\n let journeyId = null;\n // single tree\n if (journeyData.tree) {\n journeyId = cloneDeep(journeyData.tree._id);\n }\n // multiple trees, so get the first tree\n else if (journeyData.trees) {\n for (const treeId in journeyData.trees) {\n if (Object.hasOwnProperty.call(journeyData.trees, treeId)) {\n journeyId = treeId;\n journeyData = journeyData.trees[treeId];\n break;\n }\n }\n }\n\n // if a journeyId was specified, only import the matching journey\n if (journeyData && journeyId) {\n // attempt dependency resolution for single tree import\n const installedJourneys = (await readJourneys()).map((x) => x._id);\n const unresolvedJourneys = {};\n const resolvedJourneys = [];\n const depSpinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n 'Resolving dependencies'\n );\n await resolveDependencies(\n installedJourneys,\n { [journeyId]: journeyData },\n unresolvedJourneys,\n resolvedJourneys\n );\n if (Object.keys(unresolvedJourneys).length === 0) {\n stopProgressIndicator(\n depSpinnerId,\n `Resolved all dependencies.`,\n 'success'\n );\n\n let importSpinnerId: string;\n if (!verbose)\n importSpinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${journeyId}...`\n );\n try {\n await importJourney(journeyData, options);\n if (verbose)\n importSpinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${journeyId}...`\n );\n stopProgressIndicator(\n importSpinnerId,\n `Imported ${journeyId}.`,\n 'success'\n );\n } catch (importError) {\n if (verbose)\n importSpinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${journeyId}...`\n );\n stopProgressIndicator(importSpinnerId, `${importError}`, 'fail');\n }\n } else {\n stopProgressIndicator(depSpinnerId, `Unresolved dependencies:`, 'fail');\n for (const journey of Object.keys(unresolvedJourneys)) {\n printMessage(\n ` ${journey} requires ${unresolvedJourneys[journey]}`,\n 'error'\n );\n }\n }\n } else {\n const importSpinnerId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing...`\n );\n stopProgressIndicator(importSpinnerId, `No journeys found!`, 'fail');\n }\n // end dependency resolution for single tree import\n } catch (error) {\n printMessage(`Error importing first journey: ${error}`, 'error');\n }\n}\n\n/**\n * Import all journeys from file\n * @param {string} file import file name\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneysFromFile(\n file: string,\n options: TreeImportOptions\n) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n try {\n const fileData = JSON.parse(data);\n await importJourneys(fileData, options);\n } catch (error) {\n if (error.name === 'UnresolvedDependenciesError') {\n for (const journey of Object.keys(error.unresolvedJourneys)) {\n printMessage({\n message: ` - ${journey} requires ${error.unresolvedJourneys[journey]}`,\n type: 'info',\n state,\n });\n }\n } else {\n printMessage(`${error.message}`, 'error');\n }\n }\n } catch (error) {\n printMessage(`Error importing journeys: ${error}`, 'error');\n }\n}\n\n/**\n * Import all journeys from separate files\n * @param {TreeImportOptions} options import options\n */\nexport async function importJourneysFromFiles(options: TreeImportOptions) {\n const names = fs.readdirSync(getWorkingDirectory());\n const jsonFiles = names\n .filter((name) => name.toLowerCase().endsWith('.journey.json'))\n .map((name) => getFilePath(name));\n const allJourneysData = { trees: {} };\n for (const file of jsonFiles) {\n const journeyData = JSON.parse(fs.readFileSync(file, 'utf8'));\n allJourneysData.trees[journeyData.tree._id] = journeyData;\n }\n try {\n await importJourneys(allJourneysData as MultiTreeExportInterface, options);\n } catch (error) {\n printMessage(`${error.response?.data?.message || error.message}`, 'error');\n }\n}\n\n/**\n * Get journey classification\n * @param {SingleTreeExportInterface} journey journey export\n * @returns {string[]} Colored string array of classifications\n */\nexport function getJourneyClassification(\n journey: SingleTreeExportInterface\n): JourneyClassificationType[] {\n return _getJourneyClassification(journey).map((it) => {\n switch (it) {\n case 'standard':\n return it['brightGreen'];\n\n case 'cloud':\n return it['brightMagenta'];\n\n case 'custom':\n return it['brightRed'];\n\n case 'premium':\n return it['brightYellow'];\n }\n });\n}\n\n/**\n * Get journey classification in markdown\n * @param {SingleTreeExportInterface} journey journey export\n * @returns {string[]} Colored string array of classifications\n */\nexport function getJourneyClassificationMd(\n journey: SingleTreeExportInterface\n): string[] {\n return _getJourneyClassification(journey).map((it) => {\n switch (it) {\n case 'standard':\n return `:green_circle: \\`${it}\\``;\n\n case 'cloud':\n return `:purple_circle: \\`${it}\\``;\n\n case 'custom':\n return `:red_circle: \\`${it}\\``;\n\n case 'premium':\n return `:yellow_circle: \\`${it}\\``;\n }\n });\n}\n\n/**\n * Get a one-line description of the tree object\n * @param {TreeSkeleton} treeObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(treeObj: TreeSkeleton): string {\n const description = `[${treeObj._id['brightCyan']}]`;\n return description;\n}\n\n/**\n * Get a one-line description of the tree object in markdown\n * @param {TreeSkeleton} treeObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescriptionMd(treeObj: TreeSkeleton): string {\n const description = `${treeObj._id}`;\n return description;\n}\n\n/**\n * Helper function to render a nested list of dependent trees\n * @param {TreeDependencyMapInterface} descendents tree dependency map\n * @param {number} depth level of nesting\n */\nfunction describeTreeDescendents(\n descendents: TreeDependencyMapInterface,\n depth = 0\n) {\n if (depth || Object.values(descendents)[0].length) {\n // heading\n if (depth === 0) {\n printMessage(\n `\\nInner Tree Dependencies (${Object.values(descendents)[0].length}):`,\n 'data'\n );\n }\n const indent = Array(depth * 2)\n .fill(' ')\n .join('');\n const [tree] = Object.keys(descendents);\n printMessage(`${indent}- ${tree['brightCyan']}`, 'data');\n for (const descendent of descendents[tree]) {\n describeTreeDescendents(descendent, depth + 1);\n }\n }\n}\n\n/**\n * Helper function to render a nested list of dependent trees in markdown\n * @param {TreeDependencyMapInterface} descendents tree dependency map\n * @param {number} depth level of nesting\n */\nfunction describeTreeDescendentsMd(\n descendents: TreeDependencyMapInterface,\n depth = 0\n): string {\n let markdown = '';\n if (depth || Object.values(descendents)[0].length) {\n // heading\n if (depth === 0) {\n markdown += `## Inner Tree Dependencies (${\n Object.values(descendents)[0].length\n })\\n`;\n }\n const indent = Array(depth * 2)\n .fill(' ')\n .join('');\n const [tree] = Object.keys(descendents);\n markdown += `${indent}- ${tree}\\n`;\n for (const descendent of descendents[tree]) {\n markdown += describeTreeDescendentsMd(descendent, depth + 1);\n }\n return markdown;\n }\n return markdown;\n}\n\n/**\n * Describe a journey:\n * - Properties, tags, description, name, metadata\n * - Inner tree dependency tree\n * - Node type summary\n * - Nodes\n * - Themes\n * - Scripts\n * - Email templates\n * - Social identity providers\n * - SAML2 entity providers\n * - SAML2 circles of trust\n * @param {SingleTreeExportInterface} journeyData journey export object\n * @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function\n */\nexport async function describeJourney(\n journeyData: SingleTreeExportInterface,\n resolveTreeExport: TreeExportResolverInterface = onlineTreeExportResolver\n): Promise<void> {\n const allNodes = {\n ...journeyData.nodes,\n ...journeyData.innerNodes,\n };\n const nodeTypeMap = {};\n\n for (const nodeData of Object.values(allNodes)) {\n if (nodeTypeMap[nodeData._type._id]) {\n nodeTypeMap[nodeData._type._id] += 1;\n } else {\n nodeTypeMap[nodeData._type._id] = 1;\n }\n }\n\n // initialize AM version from file\n if (!state.getAmVersion() && journeyData.meta?.originAmVersion) {\n state.setAmVersion(journeyData.meta.originAmVersion);\n }\n\n // Journey Name\n printMessage(`${getOneLineDescription(journeyData.tree)}`, 'data');\n printMessage(Array(`[${journeyData.tree._id}]`['length']).fill('=').join(''));\n\n // Description\n if (journeyData.tree.description) {\n printMessage(`\\n${journeyData.tree.description}`, 'data');\n }\n\n // Status\n printMessage(\n `\\nStatus\\n${\n journeyData.tree.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen']\n }`\n );\n\n // Classification\n if (state.getAmVersion()) {\n printMessage(\n `\\nClassification\\n${getJourneyClassification(journeyData).join(', ')}`,\n 'data'\n );\n }\n\n // Categories/Tags\n if (\n journeyData.tree.uiConfig?.categories &&\n journeyData.tree.uiConfig.categories != '[]'\n ) {\n printMessage('\\nCategories/Tags', 'data');\n printMessage(\n `${JSON.parse(journeyData.tree.uiConfig.categories).join(', ')}`,\n 'data'\n );\n }\n\n // Dependency Tree\n try {\n const descendents = await getTreeDescendents(\n journeyData,\n resolveTreeExport\n );\n describeTreeDescendents(descendents);\n } catch (error) {\n printMessage(`Error resolving inner tree dependencies:`, 'error');\n printMessage(error.stack, 'error');\n }\n\n // Node Types\n if (Object.entries(nodeTypeMap).length) {\n printMessage(\n `\\nNode Types (${Object.entries(nodeTypeMap).length}):`,\n 'data'\n );\n for (const [nodeType, count] of Object.entries(nodeTypeMap)) {\n printMessage(\n `- ${String(count)} [${\n nodeType['brightCyan']\n }] (${Node.getNodeClassification(nodeType).join(', ')})`,\n 'data'\n );\n }\n }\n\n // Nodes\n if (Object.entries(allNodes).length) {\n printMessage(`\\nNodes (${Object.entries(allNodes).length}):`, 'data');\n for (const nodeObj of Object.values<NodeSkeleton>(allNodes)) {\n printMessage(\n `- ${Node.getOneLineDescription(\n nodeObj,\n getNodeRef(nodeObj, journeyData)\n )}`,\n 'data'\n );\n }\n }\n\n // Themes\n if (journeyData.themes?.length) {\n printMessage(`\\nThemes (${journeyData.themes.length}):`, 'data');\n for (const themeData of journeyData.themes) {\n printMessage(`- ${Theme.getOneLineDescription(themeData)}`, 'data');\n }\n }\n\n // Scripts\n if (Object.entries(journeyData.scripts).length) {\n printMessage(\n `\\nScripts (${Object.entries(journeyData.scripts).length}):`,\n 'data'\n );\n for (const scriptData of Object.values(journeyData.scripts)) {\n printMessage(`- ${Script.getOneLineDescription(scriptData)}`, 'data');\n }\n }\n\n // Email Templates\n if (Object.entries(journeyData.emailTemplates).length) {\n printMessage(\n `\\nEmail Templates (${\n Object.entries(journeyData.emailTemplates).length\n }):`,\n 'data'\n );\n for (const templateData of Object.values(journeyData.emailTemplates)) {\n printMessage(\n `- ${EmailTemplate.getOneLineDescription(templateData)}`,\n 'data'\n );\n }\n }\n\n // Social Identity Providers\n if (Object.entries(journeyData.socialIdentityProviders).length) {\n printMessage(\n `\\nSocial Identity Providers (${\n Object.entries(journeyData.socialIdentityProviders).length\n }):`,\n 'data'\n );\n for (const socialIdpData of Object.values(\n journeyData.socialIdentityProviders\n )) {\n printMessage(`- ${Idp.getOneLineDescription(socialIdpData)}`, 'data');\n }\n }\n\n // SAML2 Entity Providers\n if (Object.entries(journeyData.saml2Entities).length) {\n printMessage(\n `\\nSAML2 Entity Providers (${\n Object.entries(journeyData.saml2Entities).length\n }):`,\n 'data'\n );\n for (const entityProviderData of Object.values(journeyData.saml2Entities)) {\n printMessage(\n `- ${Saml2.getOneLineDescription(entityProviderData)}`,\n 'data'\n );\n }\n }\n\n // SAML2 Circles Of Trust\n if (Object.entries(journeyData.circlesOfTrust).length) {\n printMessage(\n `\\nSAML2 Circles Of Trust (${\n Object.entries(journeyData.circlesOfTrust).length\n }):`,\n 'data'\n );\n for (const cotData of Object.values(journeyData.circlesOfTrust)) {\n printMessage(\n `- ${CirclesOfTrust.getOneLineDescription(cotData)}`,\n 'data'\n );\n }\n }\n}\n\n/**\n * Describe a journey in markdown:\n * - Properties, tags, description, name, metadata\n * - Inner tree dependency tree\n * - Node type summary\n * - Nodes\n * - Themes\n * - Scripts\n * - Email templates\n * - Social identity providers\n * - SAML2 entity providers\n * - SAML2 circles of trust\n * @param {SingleTreeExportInterface} journeyData journey export object\n * @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function\n */\nexport async function describeJourneyMd(\n journeyData: SingleTreeExportInterface,\n resolveTreeExport: TreeExportResolverInterface = onlineTreeExportResolver\n) {\n const allNodes = {\n ...journeyData.nodes,\n ...journeyData.innerNodes,\n };\n const nodeTypeMap = {};\n\n for (const nodeData of Object.values(allNodes)) {\n if (nodeTypeMap[nodeData._type._id]) {\n nodeTypeMap[nodeData._type._id] += 1;\n } else {\n nodeTypeMap[nodeData._type._id] = 1;\n }\n }\n\n // initialize AM version from file\n if (!state.getAmVersion() && journeyData.meta?.originAmVersion) {\n state.setAmVersion(journeyData.meta.originAmVersion);\n }\n\n // Journey Name\n printMessage(\n `# ${getOneLineDescriptionMd(journeyData.tree)} - ${\n journeyData.tree.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n }, ${getJourneyClassificationMd(journeyData).join(', ')}`,\n 'data'\n );\n\n // Categories/Tags\n if (\n journeyData.tree.uiConfig?.categories &&\n journeyData.tree.uiConfig.categories != '[]'\n ) {\n printMessage(\n `\\`${JSON.parse(journeyData.tree.uiConfig.categories).join('`, `')}\\``,\n 'data'\n );\n }\n\n // Description\n if (journeyData.tree.description) {\n printMessage(`\\n${journeyData.tree.description}`, 'data');\n }\n\n // Journey image\n printMessage(`\\n[![](./${journeyData.tree._id}.png)]()\\n`, 'data');\n\n // Dependency Tree\n const descendents = await getTreeDescendents(journeyData, resolveTreeExport);\n printMessage(describeTreeDescendentsMd(descendents), 'data');\n\n // Node Types\n if (Object.entries(nodeTypeMap).length) {\n printMessage(\n `## Node Types (${Object.entries(nodeTypeMap).length})`,\n 'data'\n );\n printMessage('| Count | Type | Classification |', 'data');\n printMessage('| -----:| ---- | -------------- |', 'data');\n for (const [nodeType, count] of Object.entries(nodeTypeMap)) {\n printMessage(\n `| ${String(count)} | ${nodeType} | ${Node.getNodeClassificationMd(\n nodeType\n ).join('<br>')} |`,\n 'data'\n );\n }\n }\n\n // Nodes\n if (Object.entries(allNodes).length) {\n printMessage(`## Nodes (${Object.entries(allNodes).length})`, 'data');\n printMessage(Node.getTableHeaderMd(), 'data');\n for (const nodeObj of Object.values<NodeSkeleton>(allNodes)) {\n printMessage(\n `${Node.getTableRowMd(nodeObj, getNodeRef(nodeObj, journeyData))}`,\n 'data'\n );\n }\n }\n\n // Themes\n if (journeyData.themes?.length) {\n printMessage(`## Themes (${journeyData.themes.length})`, 'data');\n printMessage(Theme.getTableHeaderMd(), 'data');\n for (const themeData of journeyData.themes) {\n printMessage(`${Theme.getTableRowMd(themeData)}`, 'data');\n }\n }\n\n // Scripts\n if (Object.entries(journeyData.scripts).length) {\n printMessage(\n `## Scripts (${Object.entries(journeyData.scripts).length})`,\n 'data'\n );\n printMessage(Script.getTableHeaderMd(), 'data');\n for (const scriptData of Object.values(journeyData.scripts)) {\n printMessage(`${Script.getTableRowMd(scriptData)}`, 'data');\n }\n }\n\n // Email Templates\n if (Object.entries(journeyData.emailTemplates).length) {\n printMessage(\n `## Email Templates (${\n Object.entries(journeyData.emailTemplates).length\n })`,\n 'data'\n );\n printMessage(EmailTemplate.getTableHeaderMd(), 'data');\n for (const templateData of Object.values(journeyData.emailTemplates)) {\n printMessage(`${EmailTemplate.getTableRowMd(templateData)}`, 'data');\n }\n }\n\n // Social Identity Providers\n if (Object.entries(journeyData.socialIdentityProviders).length) {\n printMessage(\n `## Social Identity Providers (${\n Object.entries(journeyData.socialIdentityProviders).length\n })`,\n 'data'\n );\n printMessage(Idp.getTableHeaderMd(), 'data');\n for (const socialIdpData of Object.values(\n journeyData.socialIdentityProviders\n )) {\n printMessage(`${Idp.getTableRowMd(socialIdpData)}`, 'data');\n }\n }\n\n // SAML2 Entity Providers\n if (Object.entries(journeyData.saml2Entities).length) {\n printMessage(\n `## SAML2 Entity Providers (${\n Object.entries(journeyData.saml2Entities).length\n })`,\n 'data'\n );\n printMessage(Saml2.getTableHeaderMd(), 'data');\n for (const entityProviderData of Object.values(journeyData.saml2Entities)) {\n printMessage(`${Saml2.getTableRowMd(entityProviderData)}`, 'data');\n }\n }\n\n // SAML2 Circles Of Trust\n if (Object.entries(journeyData.circlesOfTrust).length) {\n printMessage(\n `## SAML2 Circles Of Trust (${\n Object.entries(journeyData.circlesOfTrust).length\n })`,\n 'data'\n );\n printMessage(CirclesOfTrust.getTableHeaderMd(), 'data');\n for (const cotData of Object.values(journeyData.circlesOfTrust)) {\n printMessage(`${CirclesOfTrust.getTableRowMd(cotData)}`, 'data');\n }\n }\n}\n\nexport async function enableJourney(journeyId: string): Promise<boolean> {\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Enabling journey ${journeyId}...`\n );\n if (_enableJourney(journeyId)) {\n stopProgressIndicator(\n indicatorId,\n `Enabled journey ${journeyId}.`,\n 'success'\n );\n return true;\n } else {\n stopProgressIndicator(\n indicatorId,\n `Error enabling journey ${journeyId}`,\n 'fail'\n );\n return false;\n }\n}\n\nexport async function disableJourney(journeyId: string): Promise<boolean> {\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Disabling journey ${journeyId}...`\n );\n if (_disableJourney(journeyId)) {\n stopProgressIndicator(\n indicatorId,\n `Disabled journey ${journeyId}.`,\n 'success'\n );\n return true;\n } else {\n stopProgressIndicator(\n indicatorId,\n `Error disabling journey ${journeyId}`,\n 'fail'\n );\n return false;\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAYpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,uBAAuB,EACvBC,WAAW,EACXC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,QAClB,kBAAkB;AACzB,OAAO,KAAKC,cAAc,MAAM,qBAAqB;AACrD,OAAO,KAAKC,aAAa,MAAM,oBAAoB;AACnD,OAAO,KAAKC,GA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KAChC,CAAC;EACD,IAAIlC,cAAc,CAACkC,SAAS,CAAC,EAAE;IAC7BjE,qBAAqB,CACnBiF,WAAW,EACV,mBAAkBhB,SAAU,GAAE,EAC/B,SACF,CAAC;IACD,OAAO,IAAI;EACb,CAAC,MAAM;IACLjE,qBAAqB,CACnBiF,WAAW,EACV,0BAAyBhB,SAAU,EAAC,EACrC,MACF,CAAC;IACD,OAAO,KAAK;EACd;AACF;AAEA,OAAO,eAAerC,cAAcA,CAACqC,SAAiB,EAAoB;EACxE,MAAMgB,WAAW,GAAGrF,uBAAuB,CACzC,eAAe,EACf,CAAC,EACA,qBAAoBqE,SAAU,KACjC,CAAC;EACD,IAAIpC,eAAe,CAACoC,SAAS,CAAC,EAAE;IAC9BjE,qBAAqB,CACnBiF,WAAW,EACV,oBAAmBhB,SAAU,GAAE,EAChC,SACF,CAAC;IACD,OAAO,IAAI;EACb,CAAC,MAAM;IACLjE,qBAAqB,CACnBiF,WAAW,EACV,2BAA0BhB,SAAU,EAAC,EACtC,MACF,CAAC;IACD,OAAO,KAAK;EACd;AACF"}
@@ -216,14 +216,17 @@ export async function exportSaml2ProvidersToFiles(includeMeta = true) {
216
216
  * Import a SAML entity provider by entity id from file
217
217
  * @param {String} entityId Provider entity id
218
218
  * @param {String} file Import file name
219
+ * @param {Saml2ProviderImportOptions} options import options
219
220
  */
220
- export async function importSaml2ProviderFromFile(entityId, file) {
221
+ export async function importSaml2ProviderFromFile(entityId, file, options = {
222
+ deps: true
223
+ }) {
221
224
  try {
222
225
  const data = fs.readFileSync(getFilePath(file), 'utf8');
223
226
  const fileData = JSON.parse(data);
224
227
  const indicatorId = createProgressIndicator('indeterminate', 0, `Importing ${entityId}...`);
225
228
  try {
226
- await importSaml2Provider(entityId, fileData);
229
+ await importSaml2Provider(entityId, fileData, options);
227
230
  stopProgressIndicator(indicatorId, `Imported ${entityId}.`, 'success');
228
231
  } catch (error) {
229
232
  stopProgressIndicator(indicatorId, `Error importing ${entityId}: ${error.message}`, 'fail');
@@ -236,8 +239,11 @@ export async function importSaml2ProviderFromFile(entityId, file) {
236
239
  /**
237
240
  * Import a SAML entity provider by entity id from file
238
241
  * @param {String} file Import file name
242
+ * @param {Saml2ProviderImportOptions} options import options
239
243
  */
240
- export async function importFirstSaml2ProviderFromFile(file) {
244
+ export async function importFirstSaml2ProviderFromFile(file, options = {
245
+ deps: true
246
+ }) {
241
247
  try {
242
248
  const data = fs.readFileSync(getFilePath(file), 'utf8');
243
249
  const fileData = JSON.parse(data);
@@ -246,7 +252,7 @@ export async function importFirstSaml2ProviderFromFile(file) {
246
252
  const entityId = decodeBase64(entityId64);
247
253
  const indicatorId = createProgressIndicator('indeterminate', 0, `Importing ${entityId}...`);
248
254
  try {
249
- await importSaml2Provider(entityId, fileData);
255
+ await importSaml2Provider(entityId, fileData, options);
250
256
  stopProgressIndicator(indicatorId, `Imported ${entityId}.`, 'success');
251
257
  } catch (error) {
252
258
  stopProgressIndicator(indicatorId, `Error importing ${entityId}: ${error.message}`, 'fail');
@@ -259,13 +265,16 @@ export async function importFirstSaml2ProviderFromFile(file) {
259
265
  /**
260
266
  * Import all SAML entity providers from file
261
267
  * @param {String} file Import file name
268
+ * @param {Saml2ProviderImportOptions} options import options
262
269
  */
263
- export async function importSaml2ProvidersFromFile(file) {
270
+ export async function importSaml2ProvidersFromFile(file, options = {
271
+ deps: true
272
+ }) {
264
273
  try {
265
274
  const data = fs.readFileSync(getFilePath(file), 'utf8');
266
275
  const fileData = JSON.parse(data);
267
276
  if (validateImport(fileData.meta)) {
268
- await importSaml2Providers(fileData);
277
+ await importSaml2Providers(fileData, options);
269
278
  } else {
270
279
  printMessage('Import validation failed...', 'error');
271
280
  }
@@ -276,8 +285,11 @@ export async function importSaml2ProvidersFromFile(file) {
276
285
 
277
286
  /**
278
287
  * Import all SAML entity providers from all *.saml.json files in the current directory
288
+ * @param {Saml2ProviderImportOptions} options import options
279
289
  */
280
- export async function importSaml2ProvidersFromFiles() {
290
+ export async function importSaml2ProvidersFromFiles(options = {
291
+ deps: true
292
+ }) {
281
293
  const names = fs.readdirSync(getWorkingDirectory());
282
294
  const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.saml.json')).map(name => getFilePath(name));
283
295
  const indicatorId = createProgressIndicator('determinate', jsonFiles.length, 'Importing providers...');
@@ -287,7 +299,7 @@ export async function importSaml2ProvidersFromFiles() {
287
299
  const data = fs.readFileSync(file, 'utf8');
288
300
  const fileData = JSON.parse(data);
289
301
  if (validateImport(fileData.meta)) {
290
- const result = await importSaml2Providers(fileData);
302
+ const result = await importSaml2Providers(fileData, options);
291
303
  total += result.length;
292
304
  updateProgressIndicator(indicatorId, `Imported ${result.length} provider(s) from ${file}.`);
293
305
  } else {