@rockcarver/frodo-cli 0.23.1-4 → 0.23.1-6

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/esm/app.js +2 -0
  3. package/esm/app.js.map +1 -1
  4. package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js +13 -6
  5. package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js.map +1 -1
  6. package/esm/cli/authz/authz-policy-delete.js +43 -0
  7. package/esm/cli/authz/authz-policy-delete.js.map +1 -0
  8. package/esm/cli/authz/authz-policy-describe.js +30 -0
  9. package/esm/cli/authz/authz-policy-describe.js.map +1 -0
  10. package/esm/cli/authz/authz-policy-export.js +70 -0
  11. package/esm/cli/authz/authz-policy-export.js.map +1 -0
  12. package/esm/cli/authz/authz-policy-import.js +26 -0
  13. package/esm/cli/authz/authz-policy-import.js.map +1 -0
  14. package/esm/cli/authz/authz-policy-list.js +37 -0
  15. package/esm/cli/authz/authz-policy-list.js.map +1 -0
  16. package/esm/cli/authz/authz-policy.js +10 -0
  17. package/esm/cli/authz/authz-policy.js.map +1 -0
  18. package/esm/cli/authz/authz-set-delete.js +37 -0
  19. package/esm/cli/authz/authz-set-delete.js.map +1 -0
  20. package/esm/cli/authz/authz-set-describe.js +30 -0
  21. package/esm/cli/authz/authz-set-describe.js.map +1 -0
  22. package/esm/cli/authz/authz-set-export.js +52 -0
  23. package/esm/cli/authz/authz-set-export.js.map +1 -0
  24. package/esm/cli/authz/authz-set-import.js +57 -0
  25. package/esm/cli/authz/authz-set-import.js.map +1 -0
  26. package/esm/cli/authz/authz-set-list.js +25 -0
  27. package/esm/cli/authz/authz-set-list.js.map +1 -0
  28. package/esm/cli/authz/authz-set.js +10 -0
  29. package/esm/cli/authz/authz-set.js.map +1 -0
  30. package/esm/cli/authz/authz-type-delete.js +38 -0
  31. package/esm/cli/authz/authz-type-delete.js.map +1 -0
  32. package/esm/cli/authz/authz-type-describe.js +30 -0
  33. package/esm/cli/authz/authz-type-describe.js.map +1 -0
  34. package/esm/cli/authz/authz-type-export.js +22 -0
  35. package/esm/cli/authz/authz-type-export.js.map +1 -0
  36. package/esm/cli/authz/authz-type-import.js +22 -0
  37. package/esm/cli/authz/authz-type-import.js.map +1 -0
  38. package/esm/cli/authz/authz-type-list.js +32 -0
  39. package/esm/cli/authz/authz-type-list.js.map +1 -0
  40. package/esm/cli/authz/authz-type.js +10 -0
  41. package/esm/cli/authz/authz-type.js.map +1 -0
  42. package/esm/cli/authz/authz.js +12 -0
  43. package/esm/cli/authz/authz.js.map +1 -0
  44. package/esm/cli/email/email-template-import.js +4 -4
  45. package/esm/cli/email/email-template-import.js.map +1 -1
  46. package/esm/cli/idm/idm-import.js +8 -3
  47. package/esm/cli/idm/idm-import.js.map +1 -1
  48. package/esm/ops/EmailTemplateOps.js +79 -38
  49. package/esm/ops/EmailTemplateOps.js.map +1 -1
  50. package/esm/ops/IdmOps.js +25 -2
  51. package/esm/ops/IdmOps.js.map +1 -1
  52. package/esm/ops/PolicyOps.js +392 -0
  53. package/esm/ops/PolicyOps.js.map +1 -0
  54. package/esm/ops/PolicySetOps.js +373 -0
  55. package/esm/ops/PolicySetOps.js.map +1 -0
  56. package/esm/ops/ResourceTypeOps.js +323 -0
  57. package/esm/ops/ResourceTypeOps.js.map +1 -0
  58. package/esm/utils/Console.js +2 -0
  59. package/esm/utils/Console.js.map +1 -1
  60. package/package.json +2 -2
@@ -1,8 +1,9 @@
1
1
  import fs from 'fs';
2
2
  import { EmailTemplate, ExportImportUtils } from '@rockcarver/frodo-lib';
3
3
  import { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
4
- import { createProgressIndicator, updateProgressIndicator, stopProgressIndicator, printMessage, createTable } from '../utils/Console';
4
+ import { createProgressIndicator, updateProgressIndicator, stopProgressIndicator, printMessage, createTable, showSpinner, succeedSpinner, failSpinner, debugMessage } from '../utils/Console';
5
5
  import wordwrap from './utils/Wordwrap';
6
+ import path from 'path';
6
7
  const EMAIL_TEMPLATE_FILE_TYPE = 'template.email';
7
8
  const {
8
9
  EMAIL_TEMPLATE_TYPE,
@@ -171,20 +172,22 @@ export async function exportEmailTemplatesToFiles() {
171
172
 
172
173
  /**
173
174
  * Import email template by id from file
174
- * @param {String} templateId email template id
175
- * @param {String} file optional filename
175
+ * @param {string} templateId email template id
176
+ * @param {string} file optional filename
177
+ * @param {boolean} raw import raw data file lacking frodo export envelop
176
178
  */
177
- export async function importEmailTemplateFromFile(templateId, file) {
179
+ export async function importEmailTemplateFromFile(templateId, file, raw = false) {
178
180
  // eslint-disable-next-line no-param-reassign
179
181
  templateId = templateId.replaceAll(`${EMAIL_TEMPLATE_TYPE}/`, '');
180
182
  fs.readFile(file, 'utf8', async (err, data) => {
181
183
  if (err) throw err;
182
184
  const fileData = JSON.parse(data);
183
- if (validateImport(fileData.meta)) {
185
+ if (raw || validateImport(fileData.meta)) {
184
186
  createProgressIndicator('determinate', 1, `Importing ${templateId}`);
185
- if (fileData.emailTemplate[templateId]) {
187
+ if (fileData.emailTemplate[templateId] || raw && fileData._id === templateId) {
186
188
  try {
187
- await putEmailTemplate(templateId, fileData.emailTemplate[templateId]);
189
+ const emailTemplateData = raw ? fileData : fileData.emailTemplate[templateId];
190
+ await putEmailTemplate(templateId, emailTemplateData);
188
191
  updateProgressIndicator(`Importing ${templateId}`);
189
192
  stopProgressIndicator(`Imported ${templateId}`);
190
193
  } catch (putEmailTemplateError) {
@@ -192,8 +195,8 @@ export async function importEmailTemplateFromFile(templateId, file) {
192
195
  printMessage(putEmailTemplateError, 'error');
193
196
  }
194
197
  } else {
195
- stopProgressIndicator(`Email template ${templateId.brightCyan} not found in ${file.brightCyan}!`);
196
- printMessage(`Email template ${templateId.brightCyan} not found in ${file.brightCyan}!`, 'error');
198
+ stopProgressIndicator(`Email template ${templateId} not found in ${file}!`);
199
+ printMessage(`Email template ${templateId} not found in ${file}!`, 'error');
197
200
  }
198
201
  } else {
199
202
  printMessage('Import validation failed...', 'error');
@@ -203,7 +206,7 @@ export async function importEmailTemplateFromFile(templateId, file) {
203
206
 
204
207
  /**
205
208
  * Import all email templates from file
206
- * @param {String} file optional filename
209
+ * @param {string} file optional filename
207
210
  */
208
211
  export async function importEmailTemplatesFromFile(file) {
209
212
  fs.readFile(file, 'utf8', async (err, data) => {
@@ -231,31 +234,58 @@ export async function importEmailTemplatesFromFile(file) {
231
234
  });
232
235
  }
233
236
 
237
+ /**
238
+ * Helper function to get email template id from file name
239
+ * @param {string} file file name
240
+ * @returns {string} email template id/name
241
+ */
242
+ function getEmailTemplateIdFromFile(file) {
243
+ debugMessage(`cli.EmailTemplateOps.getEmailTemplateIdFromFile: file=${file}`);
244
+ const fileName = path.basename(file);
245
+ const templateId = fileName.substring(14, fileName.indexOf('.'));
246
+ debugMessage(`cli.EmailTemplateOps.getEmailTemplateIdFromFile: templateId=${templateId}`);
247
+ return templateId;
248
+ }
249
+
234
250
  /**
235
251
  * Import all email templates from separate files
252
+ * @param {boolean} raw import raw data file lacking frodo export envelop
236
253
  */
237
- export async function importEmailTemplatesFromFiles() {
254
+ export async function importEmailTemplatesFromFiles(raw = false) {
238
255
  const names = fs.readdirSync('.');
239
- const jsonFiles = names.filter(name => name.toLowerCase().endsWith(`${EMAIL_TEMPLATE_FILE_TYPE}.json`));
256
+ const jsonFiles = raw ? names.filter(name => name.startsWith(`${EMAIL_TEMPLATE_TYPE}-`) && name.endsWith(`.json`)) : names.filter(name => name.toLowerCase().endsWith(`${EMAIL_TEMPLATE_FILE_TYPE}.json`));
240
257
  createProgressIndicator('determinate', jsonFiles.length, 'Importing email templates...');
241
258
  let total = 0;
242
259
  let totalErrors = 0;
243
260
  for (const file of jsonFiles) {
244
261
  const data = fs.readFileSync(file, 'utf8');
245
262
  const fileData = JSON.parse(data);
246
- if (validateImport(fileData.meta)) {
247
- total += Object.keys(fileData.emailTemplate).length;
263
+ if (raw && file.startsWith('emailTemplate-') || validateImport(fileData.meta)) {
248
264
  let errors = 0;
249
- for (const id in fileData.emailTemplate) {
250
- if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {
251
- const templateId = id.replace(regexEmailTemplateType, '');
252
- try {
253
- // eslint-disable-next-line no-await-in-loop
254
- await putEmailTemplate(templateId, fileData.emailTemplate[templateId]);
255
- } catch (putEmailTemplateError) {
256
- errors += 1;
257
- printMessage(`\nError importing ${templateId}`, 'error');
258
- printMessage(putEmailTemplateError.response.data, 'error');
265
+ if (raw) {
266
+ total++;
267
+ const templateId = getEmailTemplateIdFromFile(file);
268
+ try {
269
+ await putEmailTemplate(templateId, fileData);
270
+ } catch (putEmailTemplateError) {
271
+ var _putEmailTemplateErro;
272
+ errors += 1;
273
+ printMessage(`\nError importing ${templateId}`, 'error');
274
+ printMessage(putEmailTemplateError, 'error');
275
+ printMessage((_putEmailTemplateErro = putEmailTemplateError.response) === null || _putEmailTemplateErro === void 0 ? void 0 : _putEmailTemplateErro.data, 'error');
276
+ }
277
+ } else {
278
+ total += Object.keys(fileData.emailTemplate).length;
279
+ for (const id in fileData.emailTemplate) {
280
+ if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {
281
+ const templateId = id.replace(regexEmailTemplateType, '');
282
+ try {
283
+ await putEmailTemplate(templateId, fileData.emailTemplate[templateId]);
284
+ } catch (putEmailTemplateError) {
285
+ errors += 1;
286
+ printMessage(`\nError importing ${templateId}`, 'error');
287
+ printMessage(putEmailTemplateError.response.data, 'error');
288
+ }
259
289
  }
260
290
  }
261
291
  }
@@ -272,24 +302,35 @@ export async function importEmailTemplatesFromFiles() {
272
302
  * Import first email template from file
273
303
  * @param {String} file optional filename
274
304
  */
275
- export async function importFirstEmailTemplateFromFile(file) {
305
+ export async function importFirstEmailTemplateFromFile(file, raw = false) {
276
306
  fs.readFile(file, 'utf8', async (err, data) => {
277
307
  if (err) throw err;
278
308
  const fileData = JSON.parse(data);
279
- if (validateImport(fileData.meta)) {
280
- createProgressIndicator('determinate', 1, `Importing first email template`);
281
- for (const id in fileData.emailTemplate) {
282
- if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {
283
- try {
284
- await putEmailTemplate(id.replace(regexEmailTemplateType, ''), fileData.emailTemplate[id]);
285
- updateProgressIndicator(`Imported ${id}`);
286
- stopProgressIndicator(`Imported ${id}`);
287
- } catch (putEmailTemplateError) {
288
- stopProgressIndicator(`Error importing email template ${id}`);
289
- printMessage(`\nError importing email template ${id}`, 'error');
290
- printMessage(putEmailTemplateError.response.data, 'error');
309
+ if (raw && file.startsWith('emailTemplate-') || validateImport(fileData.meta)) {
310
+ showSpinner(`Importing first email template`);
311
+ if (raw) {
312
+ const templateId = getEmailTemplateIdFromFile(file);
313
+ try {
314
+ await putEmailTemplate(templateId, fileData);
315
+ succeedSpinner(`Imported ${templateId}`);
316
+ } catch (putEmailTemplateError) {
317
+ var _putEmailTemplateErro2;
318
+ failSpinner(`Error importing ${templateId}`);
319
+ printMessage((_putEmailTemplateErro2 = putEmailTemplateError.response) === null || _putEmailTemplateErro2 === void 0 ? void 0 : _putEmailTemplateErro2.data, 'error');
320
+ }
321
+ } else {
322
+ for (const id in fileData.emailTemplate) {
323
+ if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {
324
+ try {
325
+ await putEmailTemplate(id.replace(regexEmailTemplateType, ''), fileData.emailTemplate[id]);
326
+ succeedSpinner(`Imported ${id}`);
327
+ } catch (putEmailTemplateError) {
328
+ var _putEmailTemplateErro3;
329
+ failSpinner(`Error importing ${id}`);
330
+ printMessage((_putEmailTemplateErro3 = putEmailTemplateError.response) === null || _putEmailTemplateErro3 === void 0 ? void 0 : _putEmailTemplateErro3.data, 'error');
331
+ }
332
+ break;
291
333
  }
292
- break;
293
334
  }
294
335
  }
295
336
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"EmailTemplateOps.js","names":["fs","EmailTemplate","ExportImportUtils","getTypedFilename","saveJsonToFile","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","printMessage","createTable","wordwrap","EMAIL_TEMPLATE_FILE_TYPE","EMAIL_TEMPLATE_TYPE","getEmailTemplate","getEmailTemplates","putEmailTemplate","validateImport","regexEmailTemplateType","RegExp","getFileDataTemplate","meta","emailTemplate","getOneLineDescription","templateObj","description","_id","split","displayName","defaultLocale","subject","Object","values","getTableHeaderMd","markdown","getTableRowMd","templateId","replace","locales","keys","length","filter","locale","join","row","name","listEmailTemplates","long","emailTemplates","result","error","message","sort","a","b","localeCompare","entries","table","push","enabled","from","toString","exportEmailTemplateToFile","file","fileName","templateData","fileData","err","exportEmailTemplatesToFile","response","templates","resultCount","template","exportEmailTemplatesToFiles","importEmailTemplateFromFile","replaceAll","readFile","data","JSON","parse","putEmailTemplateError","brightCyan","importEmailTemplatesFromFile","id","hasOwnProperty","call","importEmailTemplatesFromFiles","names","readdirSync","jsonFiles","toLowerCase","endsWith","total","totalErrors","readFileSync","errors","importFirstEmailTemplateFromFile"],"sources":["ops/EmailTemplateOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { EmailTemplateSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { EmailTemplate, ExportImportUtils } from '@rockcarver/frodo-lib';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\nimport {\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n printMessage,\n createTable,\n} from '../utils/Console';\nimport wordwrap from './utils/Wordwrap';\n\nconst EMAIL_TEMPLATE_FILE_TYPE = 'template.email';\nconst {\n EMAIL_TEMPLATE_TYPE,\n getEmailTemplate,\n getEmailTemplates,\n putEmailTemplate,\n} = EmailTemplate;\nconst { validateImport } = ExportImportUtils;\n\nconst regexEmailTemplateType = new RegExp(`${EMAIL_TEMPLATE_TYPE}/`, 'g');\n\n// use a function vs a template variable to avoid problems in loops\nfunction getFileDataTemplate() {\n return {\n meta: {},\n emailTemplate: {},\n };\n}\n\n/**\n * Get a one-line description of the email template\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n templateObj: EmailTemplateSkeleton\n): string {\n const description = `[${templateObj._id.split('/')[1]['brightCyan']}] ${\n templateObj.displayName ? templateObj.displayName : ''\n } - ${\n templateObj.defaultLocale\n ? templateObj.subject[templateObj.defaultLocale]\n : Object.values(templateObj.subject)[0]\n }`;\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 += '| Display Name | Locale(s) | Subject | Id |\\n';\n markdown += '| ------------ | --------- | ------- | ---|';\n return markdown;\n}\n\n/**\n * Get a table-row of the email template in markdown\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a table-row of the email template in markdown\n */\nexport function getTableRowMd(templateObj: EmailTemplateSkeleton): string {\n const templateId = templateObj._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const locales = `${templateObj.defaultLocale}${\n Object.keys(templateObj.subject).length > 1\n ? ` (${Object.keys(templateObj.subject)\n .filter((locale) => locale !== templateObj.defaultLocale)\n .join(',')})`\n : ''\n }`;\n const row = `| ${\n templateObj.name ? templateObj.name : templateId\n } | ${locales} | ${\n templateObj.subject[templateObj.defaultLocale]\n } | \\`${templateId}\\` |`;\n return row;\n}\n\n/**\n * List email templates\n * @param {boolean} long Long list format with details\n * @return {Promise<unknown[]>} a promise that resolves to an array of email template objects\n */\nexport async function listEmailTemplates(long = false): Promise<unknown[]> {\n let emailTemplates = [];\n try {\n emailTemplates = (await getEmailTemplates()).result;\n } catch (error) {\n printMessage(`Error retrieving email templates: ${error.message}`, 'error');\n }\n emailTemplates.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const [, emailTemplate] of emailTemplates.entries()) {\n printMessage(\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n 'data'\n );\n }\n } else {\n const table = createTable([\n 'Id'['brightCyan'],\n 'Name'['brightCyan'],\n 'Status'['brightCyan'],\n 'Locale(s)'['brightCyan'],\n 'From'['brightCyan'],\n 'Subject'['brightCyan'],\n ]);\n for (const emailTemplate of emailTemplates) {\n table.push([\n // Id\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n // Name\n `${emailTemplate.displayName ? emailTemplate.displayName : ''}`,\n // Status\n emailTemplate.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n // Locale(s)\n `${emailTemplate.defaultLocale}${\n Object.keys(emailTemplate.subject).length > 1\n ? ` (${Object.keys(emailTemplate.subject)\n .filter((locale) => locale !== emailTemplate.defaultLocale)\n .join(',')})`\n : ''\n }`,\n // From\n `${emailTemplate.from ? emailTemplate.from : ''}`,\n // Subject\n wordwrap(emailTemplate.subject[emailTemplate.defaultLocale], 40),\n ]);\n }\n printMessage(table.toString(), 'data');\n }\n return emailTemplates;\n}\n\n/**\n * Export single email template to a file\n * @param {string} templateId email template id to export\n * @param {string} file filename where to export the template data\n */\nexport async function exportEmailTemplateToFile(\n templateId: string,\n file: string\n) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n }\n createProgressIndicator('determinate', 1, `Exporting ${templateId}`);\n try {\n const templateData = await getEmailTemplate(templateId);\n updateProgressIndicator(`Writing file ${fileName}`);\n const fileData = getFileDataTemplate();\n fileData.emailTemplate[templateId] = templateData;\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `Exported ${templateId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to file\n * @param {String} file optional filename\n */\nexport async function exportEmailTemplatesToFile(file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allEmailTemplates`, EMAIL_TEMPLATE_FILE_TYPE);\n }\n try {\n const fileData = getFileDataTemplate();\n const response = await getEmailTemplates();\n const templates = response.result;\n createProgressIndicator(\n 'determinate',\n response.resultCount,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n }\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `${response.resultCount} templates exported to ${fileName}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to separate files\n */\nexport async function exportEmailTemplatesToFiles() {\n try {\n const response = await getEmailTemplates();\n const templates = response.result;\n createProgressIndicator(\n 'determinate',\n response.resultCount,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n const fileData = getFileDataTemplate();\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n saveJsonToFile(fileData, fileName);\n }\n stopProgressIndicator(`${response.resultCount} templates exported.`);\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Import email template by id from file\n * @param {String} templateId email template id\n * @param {String} file optional filename\n */\nexport async function importEmailTemplateFromFile(templateId, file) {\n // eslint-disable-next-line no-param-reassign\n templateId = templateId.replaceAll(`${EMAIL_TEMPLATE_TYPE}/`, '');\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator('determinate', 1, `Importing ${templateId}`);\n if (fileData.emailTemplate[templateId]) {\n try {\n await putEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n updateProgressIndicator(`Importing ${templateId}`);\n stopProgressIndicator(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n stopProgressIndicator(`${putEmailTemplateError}`);\n printMessage(putEmailTemplateError, 'error');\n }\n } else {\n stopProgressIndicator(\n `Email template ${templateId.brightCyan} not found in ${file.brightCyan}!`\n );\n printMessage(\n `Email template ${templateId.brightCyan} not found in ${file.brightCyan}!`,\n 'error'\n );\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all email templates from file\n * @param {String} file optional filename\n */\nexport async function importEmailTemplatesFromFile(file) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(\n 'determinate',\n Object.keys(fileData.emailTemplate).length,\n `Importing email templates`\n );\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n // eslint-disable-next-line no-await-in-loop\n await putEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n updateProgressIndicator(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError.response.data, 'error');\n }\n }\n }\n stopProgressIndicator(`Done.`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all email templates from separate files\n */\nexport async function importEmailTemplatesFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith(`${EMAIL_TEMPLATE_FILE_TYPE}.json`)\n );\n createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing email templates...'\n );\n let total = 0;\n let totalErrors = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n total += Object.keys(fileData.emailTemplate).length;\n let errors = 0;\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n // eslint-disable-next-line no-await-in-loop\n await putEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n } catch (putEmailTemplateError) {\n errors += 1;\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError.response.data, 'error');\n }\n }\n }\n totalErrors += errors;\n updateProgressIndicator(`Imported ${file}`);\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n `Imported ${total - totalErrors} of ${total} email template(s) from ${\n jsonFiles.length\n } file(s).`\n );\n}\n\n/**\n * Import first email template from file\n * @param {String} file optional filename\n */\nexport async function importFirstEmailTemplateFromFile(file) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(\n 'determinate',\n 1,\n `Importing first email template`\n );\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n try {\n await putEmailTemplate(\n id.replace(regexEmailTemplateType, ''),\n fileData.emailTemplate[id]\n );\n updateProgressIndicator(`Imported ${id}`);\n stopProgressIndicator(`Imported ${id}`);\n } catch (putEmailTemplateError) {\n stopProgressIndicator(`Error importing email template ${id}`);\n printMessage(`\\nError importing email template ${id}`, 'error');\n printMessage(putEmailTemplateError.response.data, 'error');\n }\n break;\n }\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAEnB,SAASC,aAAa,EAAEC,iBAAiB,QAAQ,uBAAuB;AACxE,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAC7E,SACEC,uBAAuB,EACvBC,uBAAuB,EACvBC,qBAAqB,EACrBC,YAAY,EACZC,WAAW,QACN,kBAAkB;AACzB,OAAOC,QAAQ,MAAM,kBAAkB;AAEvC,MAAMC,wBAAwB,GAAG,gBAAgB;AACjD,MAAM;EACJC,mBAAmB;EACnBC,gBAAgB;EAChBC,iBAAiB;EACjBC;AACF,CAAC,GAAGd,aAAa;AACjB,MAAM;EAA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E,EAAG,EAAC,EAAE,OAAO,CAAC;YAC/D1E,YAAY,CAACuE,qBAAqB,CAACX,QAAQ,CAACQ,IAAI,EAAE,OAAO,CAAC;UAC5D;UACA;QACF;MACF;IACF,CAAC,MAAM;MACLpE,YAAY,CAAC,6BAA6B,EAAE,OAAO,CAAC;IACtD;EACF,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"EmailTemplateOps.js","names":["fs","EmailTemplate","ExportImportUtils","getTypedFilename","saveJsonToFile","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","printMessage","createTable","showSpinner","succeedSpinner","failSpinner","debugMessage","wordwrap","path","EMAIL_TEMPLATE_FILE_TYPE","EMAIL_TEMPLATE_TYPE","getEmailTemplate","getEmailTemplates","putEmailTemplate","validateImport","regexEmailTemplateType","RegExp","getFileDataTemplate","meta","emailTemplate","getOneLineDescription","templateObj","description","_id","split","displayName","defaultLocale","subject","Object","values","getTableHeaderMd","markdown","getTableRowMd","templateId","replace","locales","keys","length","filter","locale","join","row","name","listEmailTemplates","long","emailTemplates","result","error","message","sort","a","b","localeCompare","entries","table","push","enabled","from","toString","exportEmailTemplateToFile","file","fileName","templateData","fileData","err","exportEmailTemplatesToFile","response","templates","resultCount","template","exportEmailTemplatesToFiles","importEmailTemplateFromFile","raw","replaceAll","readFile","data","JSON","parse","emailTemplateData","putEmailTemplateError","importEmailTemplatesFromFile","id","hasOwnProperty","call","getEmailTemplateIdFromFile","basename","substring","indexOf","importEmailTemplatesFromFiles","names","readdirSync","jsonFiles","startsWith","endsWith","toLowerCase","total","totalErrors","readFileSync","errors","importFirstEmailTemplateFromFile"],"sources":["ops/EmailTemplateOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { EmailTemplateSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { EmailTemplate, ExportImportUtils } from '@rockcarver/frodo-lib';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\nimport {\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n printMessage,\n createTable,\n showSpinner,\n succeedSpinner,\n failSpinner,\n debugMessage,\n} from '../utils/Console';\nimport wordwrap from './utils/Wordwrap';\nimport path from 'path';\n\nconst EMAIL_TEMPLATE_FILE_TYPE = 'template.email';\nconst {\n EMAIL_TEMPLATE_TYPE,\n getEmailTemplate,\n getEmailTemplates,\n putEmailTemplate,\n} = EmailTemplate;\nconst { validateImport } = ExportImportUtils;\n\nconst regexEmailTemplateType = new RegExp(`${EMAIL_TEMPLATE_TYPE}/`, 'g');\n\n// use a function vs a template variable to avoid problems in loops\nfunction getFileDataTemplate() {\n return {\n meta: {},\n emailTemplate: {},\n };\n}\n\n/**\n * Get a one-line description of the email template\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n templateObj: EmailTemplateSkeleton\n): string {\n const description = `[${templateObj._id.split('/')[1]['brightCyan']}] ${\n templateObj.displayName ? templateObj.displayName : ''\n } - ${\n templateObj.defaultLocale\n ? templateObj.subject[templateObj.defaultLocale]\n : Object.values(templateObj.subject)[0]\n }`;\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 += '| Display Name | Locale(s) | Subject | Id |\\n';\n markdown += '| ------------ | --------- | ------- | ---|';\n return markdown;\n}\n\n/**\n * Get a table-row of the email template in markdown\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a table-row of the email template in markdown\n */\nexport function getTableRowMd(templateObj: EmailTemplateSkeleton): string {\n const templateId = templateObj._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const locales = `${templateObj.defaultLocale}${\n Object.keys(templateObj.subject).length > 1\n ? ` (${Object.keys(templateObj.subject)\n .filter((locale) => locale !== templateObj.defaultLocale)\n .join(',')})`\n : ''\n }`;\n const row = `| ${\n templateObj.name ? templateObj.name : templateId\n } | ${locales} | ${\n templateObj.subject[templateObj.defaultLocale]\n } | \\`${templateId}\\` |`;\n return row;\n}\n\n/**\n * List email templates\n * @param {boolean} long Long list format with details\n * @return {Promise<unknown[]>} a promise that resolves to an array of email template objects\n */\nexport async function listEmailTemplates(long = false): Promise<unknown[]> {\n let emailTemplates = [];\n try {\n emailTemplates = (await getEmailTemplates()).result;\n } catch (error) {\n printMessage(`Error retrieving email templates: ${error.message}`, 'error');\n }\n emailTemplates.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const [, emailTemplate] of emailTemplates.entries()) {\n printMessage(\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n 'data'\n );\n }\n } else {\n const table = createTable([\n 'Id'['brightCyan'],\n 'Name'['brightCyan'],\n 'Status'['brightCyan'],\n 'Locale(s)'['brightCyan'],\n 'From'['brightCyan'],\n 'Subject'['brightCyan'],\n ]);\n for (const emailTemplate of emailTemplates) {\n table.push([\n // Id\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n // Name\n `${emailTemplate.displayName ? emailTemplate.displayName : ''}`,\n // Status\n emailTemplate.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n // Locale(s)\n `${emailTemplate.defaultLocale}${\n Object.keys(emailTemplate.subject).length > 1\n ? ` (${Object.keys(emailTemplate.subject)\n .filter((locale) => locale !== emailTemplate.defaultLocale)\n .join(',')})`\n : ''\n }`,\n // From\n `${emailTemplate.from ? emailTemplate.from : ''}`,\n // Subject\n wordwrap(emailTemplate.subject[emailTemplate.defaultLocale], 40),\n ]);\n }\n printMessage(table.toString(), 'data');\n }\n return emailTemplates;\n}\n\n/**\n * Export single email template to a file\n * @param {string} templateId email template id to export\n * @param {string} file filename where to export the template data\n */\nexport async function exportEmailTemplateToFile(\n templateId: string,\n file: string\n) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n }\n createProgressIndicator('determinate', 1, `Exporting ${templateId}`);\n try {\n const templateData = await getEmailTemplate(templateId);\n updateProgressIndicator(`Writing file ${fileName}`);\n const fileData = getFileDataTemplate();\n fileData.emailTemplate[templateId] = templateData;\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `Exported ${templateId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to file\n * @param {String} file optional filename\n */\nexport async function exportEmailTemplatesToFile(file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allEmailTemplates`, EMAIL_TEMPLATE_FILE_TYPE);\n }\n try {\n const fileData = getFileDataTemplate();\n const response = await getEmailTemplates();\n const templates = response.result;\n createProgressIndicator(\n 'determinate',\n response.resultCount,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n }\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `${response.resultCount} templates exported to ${fileName}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to separate files\n */\nexport async function exportEmailTemplatesToFiles() {\n try {\n const response = await getEmailTemplates();\n const templates = response.result;\n createProgressIndicator(\n 'determinate',\n response.resultCount,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n const fileData = getFileDataTemplate();\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n saveJsonToFile(fileData, fileName);\n }\n stopProgressIndicator(`${response.resultCount} templates exported.`);\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Import email template by id from file\n * @param {string} templateId email template id\n * @param {string} file optional filename\n * @param {boolean} raw import raw data file lacking frodo export envelop\n */\nexport async function importEmailTemplateFromFile(\n templateId: string,\n file: string,\n raw = false\n) {\n // eslint-disable-next-line no-param-reassign\n templateId = templateId.replaceAll(`${EMAIL_TEMPLATE_TYPE}/`, '');\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (raw || validateImport(fileData.meta)) {\n createProgressIndicator('determinate', 1, `Importing ${templateId}`);\n if (\n fileData.emailTemplate[templateId] ||\n (raw && fileData._id === templateId)\n ) {\n try {\n const emailTemplateData = raw\n ? fileData\n : fileData.emailTemplate[templateId];\n await putEmailTemplate(templateId, emailTemplateData);\n updateProgressIndicator(`Importing ${templateId}`);\n stopProgressIndicator(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n stopProgressIndicator(`${putEmailTemplateError}`);\n printMessage(putEmailTemplateError, 'error');\n }\n } else {\n stopProgressIndicator(\n `Email template ${templateId} not found in ${file}!`\n );\n printMessage(\n `Email template ${templateId} not found in ${file}!`,\n 'error'\n );\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all email templates from file\n * @param {string} file optional filename\n */\nexport async function importEmailTemplatesFromFile(file: string) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(\n 'determinate',\n Object.keys(fileData.emailTemplate).length,\n `Importing email templates`\n );\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n // eslint-disable-next-line no-await-in-loop\n await putEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n updateProgressIndicator(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError.response.data, 'error');\n }\n }\n }\n stopProgressIndicator(`Done.`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Helper function to get email template id from file name\n * @param {string} file file name\n * @returns {string} email template id/name\n */\nfunction getEmailTemplateIdFromFile(file: string) {\n debugMessage(`cli.EmailTemplateOps.getEmailTemplateIdFromFile: file=${file}`);\n const fileName = path.basename(file);\n const templateId = fileName.substring(14, fileName.indexOf('.'));\n debugMessage(\n `cli.EmailTemplateOps.getEmailTemplateIdFromFile: templateId=${templateId}`\n );\n return templateId;\n}\n\n/**\n * Import all email templates from separate files\n * @param {boolean} raw import raw data file lacking frodo export envelop\n */\nexport async function importEmailTemplatesFromFiles(raw = false) {\n const names = fs.readdirSync('.');\n const jsonFiles = raw\n ? names.filter(\n (name) =>\n name.startsWith(`${EMAIL_TEMPLATE_TYPE}-`) && name.endsWith(`.json`)\n )\n : names.filter((name) =>\n name.toLowerCase().endsWith(`${EMAIL_TEMPLATE_FILE_TYPE}.json`)\n );\n createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing email templates...'\n );\n let total = 0;\n let totalErrors = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (\n (raw && file.startsWith('emailTemplate-')) ||\n validateImport(fileData.meta)\n ) {\n let errors = 0;\n if (raw) {\n total++;\n const templateId = getEmailTemplateIdFromFile(file);\n try {\n await putEmailTemplate(templateId, fileData);\n } catch (putEmailTemplateError) {\n errors += 1;\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError, 'error');\n printMessage(putEmailTemplateError.response?.data, 'error');\n }\n } else {\n total += Object.keys(fileData.emailTemplate).length;\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n await putEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n } catch (putEmailTemplateError) {\n errors += 1;\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError.response.data, 'error');\n }\n }\n }\n }\n totalErrors += errors;\n updateProgressIndicator(`Imported ${file}`);\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n `Imported ${total - totalErrors} of ${total} email template(s) from ${\n jsonFiles.length\n } file(s).`\n );\n}\n\n/**\n * Import first email template from file\n * @param {String} file optional filename\n */\nexport async function importFirstEmailTemplateFromFile(\n file: string,\n raw = false\n) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (\n (raw && file.startsWith('emailTemplate-')) ||\n validateImport(fileData.meta)\n ) {\n showSpinner(`Importing first email template`);\n if (raw) {\n const templateId = getEmailTemplateIdFromFile(file);\n try {\n await putEmailTemplate(templateId, fileData);\n succeedSpinner(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n failSpinner(`Error importing ${templateId}`);\n printMessage(putEmailTemplateError.response?.data, 'error');\n }\n } else {\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n try {\n await putEmailTemplate(\n id.replace(regexEmailTemplateType, ''),\n fileData.emailTemplate[id]\n );\n succeedSpinner(`Imported ${id}`);\n } catch (putEmailTemplateError) {\n failSpinner(`Error importing ${id}`);\n printMessage(putEmailTemplateError.response?.data, 'error');\n }\n break;\n }\n }\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAEnB,SAASC,aAAa,EAAEC,iBAAiB,QAAQ,uBAAuB;AACxE,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAC7E,SACEC,uBAAuB,EACvBC,uBAAuB,EACvBC,qBAAqB,EACrBC,YAAY,EACZC,WAAW,EACXC,WAAW,EACXC,cAAc,EACdC,WAAW,EACXC,YAAY,QACP,kBAAkB;AACzB,OAAOC,QAAQ,MAAM,kBAAkB;AACvC,OAAOC,IAA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gCS,IAAI,EAAE,OAAO,CAAC;QAC7D;MACF,CAAC,MAAM;QACL,KAAK,MAAMM,EAAE,IAAIlB,QAAQ,CAAC5C,aAAa,EAAE;UACvC,IAAI,CAAC,CAAC,CAAC+D,cAAc,CAACC,IAAI,CAACpB,QAAQ,CAAC5C,aAAa,EAAE8D,EAAE,CAAC,EAAE;YACtD,IAAI;cACF,MAAMpE,gBAAgB,CACpBoE,EAAE,CAAC/C,OAAO,CAACnB,sBAAsB,EAAE,EAAE,CAAC,EACtCgD,QAAQ,CAAC5C,aAAa,CAAC8D,EAAE,CAAC,CAC3B;cACD7E,cAAc,CAAE,YAAW6E,EAAG,EAAC,CAAC;YAClC,CAAC,CAAC,OAAOF,qBAAqB,EAAE;cAAA;cAC9B1E,WAAW,CAAE,mBAAkB4E,EAAG,EAAC,CAAC;cACpChF,YAAY,2BAAC8E,qBAAqB,CAACb,QAAQ,2DAA9B,uBAAgCS,IAAI,EAAE,OAAO,CAAC;YAC7D;YACA;UACF;QACF;MACF;IACF,CAAC,MAAM;MACL1E,YAAY,CAAC,6BAA6B,EAAE,OAAO,CAAC;IACtD;EACF,CAAC,CAAC;AACJ"}
package/esm/ops/IdmOps.js CHANGED
@@ -175,11 +175,12 @@ export async function exportAllConfigEntities(directory, entitiesFile, envFile)
175
175
  }
176
176
 
177
177
  /**
178
- * Import an IDM configuration object.
178
+ * Import an IDM configuration object by id from file.
179
179
  * @param entityId the configuration object to import
180
180
  * @param file optional file to import
181
+ * @param validate validate script hooks
181
182
  */
182
- export async function importConfigEntity(entityId, file, validate) {
183
+ export async function importConfigEntityByIdFromFile(entityId, file, validate) {
183
184
  if (!file) {
184
185
  file = getTypedFilename(entityId, 'idm');
185
186
  }
@@ -198,6 +199,28 @@ export async function importConfigEntity(entityId, file, validate) {
198
199
  }
199
200
  }
200
201
 
202
+ /**
203
+ * Import IDM configuration object from file.
204
+ * @param file optional file to import
205
+ * @param validate validate script hooks
206
+ */
207
+ export async function importConfigEntityFromFile(file, validate) {
208
+ const importData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');
209
+ const jsObject = JSON.parse(importData);
210
+ const entityId = jsObject._id;
211
+ const isValid = validateScriptHooks(jsObject);
212
+ if (validate && !isValid) {
213
+ printMessage('Invalid IDM configuration object', 'error');
214
+ return;
215
+ }
216
+ try {
217
+ await putConfigEntity(entityId, importData);
218
+ } catch (putConfigEntityError) {
219
+ printMessage(putConfigEntityError, 'error');
220
+ printMessage(`Error: ${putConfigEntityError}`, 'error');
221
+ }
222
+ }
223
+
201
224
  /**
202
225
  * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>
203
226
  * @param baseDirectory export directory
@@ -1 +1 @@
1
- {"version":3,"file":"IdmOps.js","names":["fs","fse","path","propertiesReader","replaceall","Idm","Utils","ValidationUtils","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","readFiles","unSubstituteEnvParams","validateScriptHooks","getAllConfigEntities","getConfigEntity","putConfigEntity","queryAllManagedObjectsByType","testConnectorServers","warnAboutOfflineConnectorServers","all","offline","filter","status","ok","map","name","length","join","error","message","listAllConfigEntities","configurations","configEntity","_id","getAllConfigEntitiesError","exportConfigEntity","id","file","fileName","writeFile","JSON","stringify","err","exportAllRawConfigEntities","directory","existsSync","mkdirSync","undefined","entityPromises","push","catch","getConfigEntityError","response","data","includes","reason","results","Promise","item","outputFile","exportAllConfigEntities","entitiesFile","envFile","entriesToExport","readFile","entriesData","parse","idm","envParams","configEntityString","each","key","value","importConfigEntity","entityId","validate","entityData","readFileSync","resolve","process","cwd","jsObject","isValid","putConfigEntityError","importAllRawConfigEntities","baseDirectory","files","jsonFiles","toLowerCase","endsWith","content","substring","everyScriptValid","isScriptValid","allSettled","errors","result","importAllConfigEntities","entriesToImport","envReader","unsubstituted","countManagedObjects","type","count","resultCount","pagedResultsCookie","totalPagedResultsPolicy","totalPagedResults","remainingPagedResults"],"sources":["ops/IdmOps.ts"],"sourcesContent":["/* eslint-disable no-await-in-loop */\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\n\nimport { Idm, Utils, ValidationUtils } from '@rockcarver/frodo-lib';\nimport {\n createProgressIndicator,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename } from '../utils/ExportImportUtils';\n\nconst { readFiles, unSubstituteEnvParams } = Utils;\nconst { validateScriptHooks } = ValidationUtils;\nconst {\n getAllConfigEntities,\n getConfigEntity,\n putConfigEntity,\n queryAllManagedObjectsByType,\n testConnectorServers,\n} = Idm;\n\n/**\n * Warn about and list offline remote connector servers\n */\nexport async function warnAboutOfflineConnectorServers() {\n try {\n const all = await testConnectorServers();\n const offline = all\n .filter((status) => !status.ok)\n .map((status) => status.name);\n if (offline.length) {\n printMessage(\n `\\nThe following connector server(s) are offline and their connectors and configuration unavailable:\\n${offline.join(\n '\\n'\n )}`,\n 'warn'\n );\n }\n } catch (error) {\n printMessage(error, 'error');\n printMessage(\n `Error getting offline connector servers: ${error.message}`,\n 'error'\n );\n }\n}\n\n/**\n * List all IDM configuration objects\n */\nexport async function listAllConfigEntities() {\n try {\n const { configurations } = await getAllConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export an IDM configuration object.\n * @param {String} id the desired configuration object\n * @param {String} file optional export file\n */\nexport async function exportConfigEntity(id, file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`${id}`, 'idm');\n }\n const configEntity = await getConfigEntity(id);\n fs.writeFile(fileName, JSON.stringify(configEntity, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${id} export to file`, 'error');\n }\n return '';\n });\n}\n\n/**\n * Export all IDM configuration objects into separate JSON files in a directory specified by <directory>\n * @param {String} directory export directory\n */\nexport async function exportAllRawConfigEntities(directory) {\n try {\n const { configurations } = await getAllConfigEntities();\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n entityPromises.push(\n getConfigEntity(configEntity._id).catch((getConfigEntityError) => {\n if (\n !(\n getConfigEntityError.response?.status === 403 &&\n getConfigEntityError.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n ) &&\n !(\n // list of config entities, which do not exist by default or ever.\n (\n [\n 'script',\n 'notificationFactory',\n 'apiVersion',\n 'metrics',\n 'repo.init',\n 'endpoint/validateQueryFilter',\n 'endpoint/oauthproxy',\n 'external.rest',\n 'scheduler',\n 'org.apache.felix.fileinstall/openidm',\n 'cluster',\n 'endpoint/mappingDetails',\n 'fieldPolicy/teammember',\n ].includes(configEntity._id) &&\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.reason === 'Not Found'\n )\n ) &&\n // https://bugster.forgerock.org/jira/browse/OPENIDM-18270\n !(\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.message ===\n 'No configuration exists for id org.apache.felix.fileinstall/openidm'\n )\n ) {\n printMessage(getConfigEntityError.response?.data, 'error');\n printMessage(\n `Error getting config entity ${configEntity._id}: ${getConfigEntityError}`,\n 'error'\n );\n }\n })\n );\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n fse.outputFile(\n `${directory}/${item._id}.json`,\n JSON.stringify(item, null, 2),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator('Exported config objects.', 'success');\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export all IDM configuration objects\n * @param {String} directory export directory\n * @param {String} entitiesFile JSON file that specifies the config entities to export/import\n * @param {String} envFile File that defines environment specific variables for replacement during configuration export/import\n */\nexport async function exportAllConfigEntities(\n directory,\n entitiesFile,\n envFile\n) {\n let entriesToExport = [];\n // read list of entities to export\n fs.readFile(entitiesFile, 'utf8', async (err, data) => {\n if (err) throw err;\n const entriesData = JSON.parse(data);\n entriesToExport = entriesData.idm;\n // console.log(`entriesToExport ${entriesToExport}`);\n\n // read list of configs to parameterize for environment specific values\n const envParams = propertiesReader(envFile);\n\n try {\n const { configurations } = await getAllConfigEntities();\n // create export directory if not exist\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(getConfigEntity(configEntity._id));\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n let configEntityString = JSON.stringify(item, null, 2);\n envParams.each((key, value) => {\n configEntityString = replaceall(\n value,\n `\\${${key}}`,\n configEntityString\n );\n });\n fse.outputFile(\n `${directory}/${item._id}.json`,\n configEntityString,\n (error) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${error}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator(null, 'success');\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n });\n}\n\n/**\n * Import an IDM configuration object.\n * @param entityId the configuration object to import\n * @param file optional file to import\n */\nexport async function importConfigEntity(\n entityId: string,\n file?: string,\n validate?: boolean\n) {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const entityData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n\n const jsObject = JSON.parse(entityData);\n const isValid = validateScriptHooks(jsObject);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await putConfigEntity(entityId, entityData);\n } catch (putConfigEntityError) {\n printMessage(putConfigEntityError, 'error');\n printMessage(`Error: ${putConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>\n * @param baseDirectory export directory\n * @param validate validate script hooks\n */\nexport async function importAllRawConfigEntities(\n baseDirectory: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ path, content }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles.map((file) => {\n return putConfigEntity(file.entityId, file.content);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Import all IDM configuration objects\n * @param baseDirectory import directory\n * @param entitiesFile JSON file that specifies the config entities to export/import\n * @param envFile File that defines environment specific variables for replacement during configuration export/import\n * @param validate validate script hooks\n */\nexport async function importAllConfigEntities(\n baseDirectory: string,\n entitiesFile: string,\n envFile: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const entriesToImport = JSON.parse(fs.readFileSync(entitiesFile, 'utf8')).idm;\n\n const envReader = propertiesReader(envFile);\n\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content, path }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles\n .filter(({ entityId }) => {\n return entriesToImport.includes(entityId);\n })\n .map(({ entityId, content }) => {\n const unsubstituted = unSubstituteEnvParams(content, envReader);\n return putConfigEntity(entityId, unsubstituted);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Count number of managed objects of a given type\n * @param {String} type managed object type, e.g. alpha_user\n */\nexport async function countManagedObjects(type) {\n let count = 0;\n let result = {\n result: [],\n resultCount: 0,\n pagedResultsCookie: null,\n totalPagedResultsPolicy: 'NONE',\n totalPagedResults: -1,\n remainingPagedResults: -1,\n };\n try {\n do {\n result = await queryAllManagedObjectsByType(\n type,\n [],\n result.pagedResultsCookie\n );\n count += result.resultCount;\n } while (result.pagedResultsCookie);\n printMessage(`${type}: ${count}`);\n } catch (error) {\n printMessage(error.response.data, 'error');\n printMessage(`Error querying managed objects by type: ${error}`, 'error');\n }\n}\n"],"mappings":"AAAA;AACA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAC1B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,gBAAgB,MAAM,mBAAmB;AAChD,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,GAAG,EAAEC,KAAK,EAAEC,eAAe,QAAQ,uBAAuB;AACnE,SACEC,uBAAuB,EACvBC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,gBAAgB,QAAQ,4BAA4B;AAE7D,MAAM;EAAEC,SAAS;EAAEC;AAAsB,CAAC,GAAGP,KAAK;AAClD,MAAM;EAAEQ;AAAoB,CAAC,GAAGP,eAAe;AAC/C,MAAM;EACJQ,oBAAoB;EACpBC,eAAe;EACfC,eAAe;EACfC,4BAA4B;EAC5BC;AACF,CAAC,GAAGd,GAAG;;AAEP;AACA;AACA;AACA,OAAO,eAAee,gCAAgC,GAAG;EACvD,IAAI;IACF,MAAMC,GAAG,GAAG,MAAMF,oBAAoB,EAAE;IACxC,MAAMG,OAAO,GAAGD,GAAG,CAChBE,MAAM,CAAEC,MAAM,IAAK,CAACA,MAAM,CAACC,EAAE,CAAC,CAC9BC,GAAG,CAAEF,MAAM,IAAKA,MAAM,CAACG,IAAI,CAAC;IAC/B,IAAIL,OAAO,CAACM,MAAM,EAAE;MAClBnB,YAAY,CACT,wGAAuGa,OAAO,CAACO,IAAI,CAClH,IAAI,CACJ,EAAC,EACH,MAAM,CACP;IACH;EACF,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdrB,YAAY,CAACqB,KAAK,EAAE,OAAO,CAAC;IAC5BrB,YAAY,CACT,4CAA2CqB,KAAK,CAACC,OAAQ,EAAC,EAC3D,OAAO,CACR;EACH;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeC,qBAAqB,GAA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EAlB,qBAAqB,CAAE,YAAWgD,OAAO,CAAC9B,MAAO,iBAAgB,EAAE,SAAS,CAAC;AAC/E;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAe2E,mBAAmB,CAACC,IAAI,EAAE;EAC9C,IAAIC,KAAK,GAAG,CAAC;EACb,IAAIP,MAAM,GAAG;IACXA,MAAM,EAAE,EAAE;IACVQ,WAAW,EAAE,CAAC;IACdC,kBAAkB,EAAE,IAAI;IACxBC,uBAAuB,EAAE,MAAM;IAC/BC,iBAAiB,EAAE,CAAC,CAAC;IACrBC,qBAAqB,EAAE,CAAC;EAC1B,CAAC;EACD,IAAI;IACF,GAAG;MACDZ,MAAM,GAAG,MAAMhF,4BAA4B,CACzCsF,IAAI,EACJ,EAAE,EACFN,MAAM,CAACS,kBAAkB,CAC1B;MACDF,KAAK,IAAIP,MAAM,CAACQ,WAAW;IAC7B,CAAC,QAAQR,MAAM,CAACS,kBAAkB;IAClClG,YAAY,CAAE,GAAE+F,IAAK,KAAIC,KAAM,EAAC,CAAC;EACnC,CAAC,CAAC,OAAO3E,KAAK,EAAE;IACdrB,YAAY,CAACqB,KAAK,CAACwB,QAAQ,CAACC,IAAI,EAAE,OAAO,CAAC;IAC1C9C,YAAY,CAAE,2CAA0CqB,KAAM,EAAC,EAAE,OAAO,CAAC;EAC3E;AACF"}
1
+ {"version":3,"file":"IdmOps.js","names":["fs","fse","path","propertiesReader","replaceall","Idm","Utils","ValidationUtils","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","readFiles","unSubstituteEnvParams","validateScriptHooks","getAllConfigEntities","getConfigEntity","putConfigEntity","queryAllManagedObjectsByType","testConnectorServers","warnAboutOfflineConnectorServers","all","offline","filter","status","ok","map","name","length","join","error","message","listAllConfigEntities","configurations","configEntity","_id","getAllConfigEntitiesError","exportConfigEntity","id","file","fileName","writeFile","JSON","stringify","err","exportAllRawConfigEntities","directory","existsSync","mkdirSync","undefined","entityPromises","push","catch","getConfigEntityError","response","data","includes","reason","results","Promise","item","outputFile","exportAllConfigEntities","entitiesFile","envFile","entriesToExport","readFile","entriesData","parse","idm","envParams","configEntityString","each","key","value","importConfigEntityByIdFromFile","entityId","validate","entityData","readFileSync","resolve","process","cwd","jsObject","isValid","putConfigEntityError","importConfigEntityFromFile","importData","importAllRawConfigEntities","baseDirectory","files","jsonFiles","toLowerCase","endsWith","content","substring","everyScriptValid","isScriptValid","allSettled","errors","result","importAllConfigEntities","entriesToImport","envReader","unsubstituted","countManagedObjects","type","count","resultCount","pagedResultsCookie","totalPagedResultsPolicy","totalPagedResults","remainingPagedResults"],"sources":["ops/IdmOps.ts"],"sourcesContent":["/* eslint-disable no-await-in-loop */\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\n\nimport { Idm, Utils, ValidationUtils } from '@rockcarver/frodo-lib';\nimport {\n createProgressIndicator,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename } from '../utils/ExportImportUtils';\n\nconst { readFiles, unSubstituteEnvParams } = Utils;\nconst { validateScriptHooks } = ValidationUtils;\nconst {\n getAllConfigEntities,\n getConfigEntity,\n putConfigEntity,\n queryAllManagedObjectsByType,\n testConnectorServers,\n} = Idm;\n\n/**\n * Warn about and list offline remote connector servers\n */\nexport async function warnAboutOfflineConnectorServers() {\n try {\n const all = await testConnectorServers();\n const offline = all\n .filter((status) => !status.ok)\n .map((status) => status.name);\n if (offline.length) {\n printMessage(\n `\\nThe following connector server(s) are offline and their connectors and configuration unavailable:\\n${offline.join(\n '\\n'\n )}`,\n 'warn'\n );\n }\n } catch (error) {\n printMessage(error, 'error');\n printMessage(\n `Error getting offline connector servers: ${error.message}`,\n 'error'\n );\n }\n}\n\n/**\n * List all IDM configuration objects\n */\nexport async function listAllConfigEntities() {\n try {\n const { configurations } = await getAllConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export an IDM configuration object.\n * @param {String} id the desired configuration object\n * @param {String} file optional export file\n */\nexport async function exportConfigEntity(id, file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`${id}`, 'idm');\n }\n const configEntity = await getConfigEntity(id);\n fs.writeFile(fileName, JSON.stringify(configEntity, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${id} export to file`, 'error');\n }\n return '';\n });\n}\n\n/**\n * Export all IDM configuration objects into separate JSON files in a directory specified by <directory>\n * @param {String} directory export directory\n */\nexport async function exportAllRawConfigEntities(directory) {\n try {\n const { configurations } = await getAllConfigEntities();\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n entityPromises.push(\n getConfigEntity(configEntity._id).catch((getConfigEntityError) => {\n if (\n !(\n getConfigEntityError.response?.status === 403 &&\n getConfigEntityError.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n ) &&\n !(\n // list of config entities, which do not exist by default or ever.\n (\n [\n 'script',\n 'notificationFactory',\n 'apiVersion',\n 'metrics',\n 'repo.init',\n 'endpoint/validateQueryFilter',\n 'endpoint/oauthproxy',\n 'external.rest',\n 'scheduler',\n 'org.apache.felix.fileinstall/openidm',\n 'cluster',\n 'endpoint/mappingDetails',\n 'fieldPolicy/teammember',\n ].includes(configEntity._id) &&\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.reason === 'Not Found'\n )\n ) &&\n // https://bugster.forgerock.org/jira/browse/OPENIDM-18270\n !(\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.message ===\n 'No configuration exists for id org.apache.felix.fileinstall/openidm'\n )\n ) {\n printMessage(getConfigEntityError.response?.data, 'error');\n printMessage(\n `Error getting config entity ${configEntity._id}: ${getConfigEntityError}`,\n 'error'\n );\n }\n })\n );\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n fse.outputFile(\n `${directory}/${item._id}.json`,\n JSON.stringify(item, null, 2),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator('Exported config objects.', 'success');\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export all IDM configuration objects\n * @param {String} directory export directory\n * @param {String} entitiesFile JSON file that specifies the config entities to export/import\n * @param {String} envFile File that defines environment specific variables for replacement during configuration export/import\n */\nexport async function exportAllConfigEntities(\n directory,\n entitiesFile,\n envFile\n) {\n let entriesToExport = [];\n // read list of entities to export\n fs.readFile(entitiesFile, 'utf8', async (err, data) => {\n if (err) throw err;\n const entriesData = JSON.parse(data);\n entriesToExport = entriesData.idm;\n // console.log(`entriesToExport ${entriesToExport}`);\n\n // read list of configs to parameterize for environment specific values\n const envParams = propertiesReader(envFile);\n\n try {\n const { configurations } = await getAllConfigEntities();\n // create export directory if not exist\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(getConfigEntity(configEntity._id));\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n let configEntityString = JSON.stringify(item, null, 2);\n envParams.each((key, value) => {\n configEntityString = replaceall(\n value,\n `\\${${key}}`,\n configEntityString\n );\n });\n fse.outputFile(\n `${directory}/${item._id}.json`,\n configEntityString,\n (error) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${error}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator(null, 'success');\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n });\n}\n\n/**\n * Import an IDM configuration object by id from file.\n * @param entityId the configuration object to import\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityByIdFromFile(\n entityId: string,\n file?: string,\n validate?: boolean\n) {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const entityData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n\n const jsObject = JSON.parse(entityData);\n const isValid = validateScriptHooks(jsObject);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await putConfigEntity(entityId, entityData);\n } catch (putConfigEntityError) {\n printMessage(putConfigEntityError, 'error');\n printMessage(`Error: ${putConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import IDM configuration object from file.\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityFromFile(\n file: string,\n validate?: boolean\n) {\n const importData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n const jsObject = JSON.parse(importData);\n const entityId = jsObject._id;\n const isValid = validateScriptHooks(jsObject);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await putConfigEntity(entityId, importData);\n } catch (putConfigEntityError) {\n printMessage(putConfigEntityError, 'error');\n printMessage(`Error: ${putConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>\n * @param baseDirectory export directory\n * @param validate validate script hooks\n */\nexport async function importAllRawConfigEntities(\n baseDirectory: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ path, content }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles.map((file) => {\n return putConfigEntity(file.entityId, file.content);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Import all IDM configuration objects\n * @param baseDirectory import directory\n * @param entitiesFile JSON file that specifies the config entities to export/import\n * @param envFile File that defines environment specific variables for replacement during configuration export/import\n * @param validate validate script hooks\n */\nexport async function importAllConfigEntities(\n baseDirectory: string,\n entitiesFile: string,\n envFile: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const entriesToImport = JSON.parse(fs.readFileSync(entitiesFile, 'utf8')).idm;\n\n const envReader = propertiesReader(envFile);\n\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content, path }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles\n .filter(({ entityId }) => {\n return entriesToImport.includes(entityId);\n })\n .map(({ entityId, content }) => {\n const unsubstituted = unSubstituteEnvParams(content, envReader);\n return putConfigEntity(entityId, unsubstituted);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Count number of managed objects of a given type\n * @param {String} type managed object type, e.g. alpha_user\n */\nexport async function countManagedObjects(type) {\n let count = 0;\n let result = {\n result: [],\n resultCount: 0,\n pagedResultsCookie: null,\n totalPagedResultsPolicy: 'NONE',\n totalPagedResults: -1,\n remainingPagedResults: -1,\n };\n try {\n do {\n result = await queryAllManagedObjectsByType(\n type,\n [],\n result.pagedResultsCookie\n );\n count += result.resultCount;\n } while (result.pagedResultsCookie);\n printMessage(`${type}: ${count}`);\n } catch (error) {\n printMessage(error.response.data, 'error');\n printMessage(`Error querying managed objects by type: ${error}`, 'error');\n }\n}\n"],"mappings":"AAAA;AACA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAC1B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,gBAAgB,MAAM,mBAAmB;AAChD,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,GAAG,EAAEC,KAAK,EAAEC,eAAe,QAAQ,uBAAuB;AACnE,SACEC,uBAAuB,EACvBC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AACzB,SA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