@rockcarver/frodo-lib 0.13.2-0 → 0.14.1

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 (47) hide show
  1. package/CHANGELOG.md +33 -1
  2. package/cjs/api/ApiTypes.js.map +1 -1
  3. package/cjs/api/ThemeApi.js +132 -40
  4. package/cjs/api/ThemeApi.js.map +1 -1
  5. package/cjs/api/ThemeApi.test.js.map +1 -0
  6. package/cjs/index.js +5 -1
  7. package/cjs/index.js.map +1 -1
  8. package/cjs/ops/JourneyOps.js +260 -237
  9. package/cjs/ops/JourneyOps.js.map +1 -1
  10. package/cjs/ops/ThemeOps.js +103 -84
  11. package/cjs/ops/ThemeOps.js.map +1 -1
  12. package/cjs/ops/utils/Console.js +21 -5
  13. package/cjs/ops/utils/Console.js.map +1 -1
  14. package/cjs/storage/SessionStorage.js +6 -0
  15. package/cjs/storage/SessionStorage.js.map +1 -1
  16. package/cjs/test/mocks/ForgeRockApiMockEngine.js +2 -1
  17. package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
  18. package/cjs/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm-encore.json +77 -0
  19. package/cjs/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm-putThemes.json +665 -0
  20. package/cjs/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm.json +1 -1
  21. package/esm/api/ThemeApi.mjs +129 -41
  22. package/esm/api/ThemeApi.test.mjs +903 -0
  23. package/esm/index.mjs +2 -1
  24. package/esm/ops/JourneyOps.mjs +259 -236
  25. package/esm/ops/ThemeOps.mjs +44 -34
  26. package/esm/ops/utils/Console.mjs +18 -4
  27. package/esm/storage/SessionStorage.mjs +6 -0
  28. package/esm/test/mocks/ForgeRockApiMockEngine.mjs +2 -2
  29. package/esm/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm-encore.json +77 -0
  30. package/esm/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm-putThemes.json +665 -0
  31. package/esm/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm.json +1 -1
  32. package/package.json +1 -1
  33. package/types/api/ApiTypes.d.ts +5 -1
  34. package/types/api/ApiTypes.d.ts.map +1 -1
  35. package/types/api/ThemeApi.d.ts +28 -26
  36. package/types/api/ThemeApi.d.ts.map +1 -1
  37. package/types/index.d.ts +1 -0
  38. package/types/index.d.ts.map +1 -1
  39. package/types/ops/JourneyOps.d.ts.map +1 -1
  40. package/types/ops/ThemeOps.d.ts +5 -0
  41. package/types/ops/ThemeOps.d.ts.map +1 -1
  42. package/types/ops/utils/Console.d.ts +11 -4
  43. package/types/ops/utils/Console.d.ts.map +1 -1
  44. package/types/storage/SessionStorage.d.ts +6 -0
  45. package/types/storage/SessionStorage.d.ts.map +1 -1
  46. package/types/test/mocks/ForgeRockApiMockEngine.d.ts +1 -1
  47. package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
@@ -1,5 +1,5 @@
1
1
  import fs from 'fs';
2
- import { deleteTheme, deleteThemeByName, deleteThemes, getTheme, getThemeByName, getThemes, putTheme, putThemeByName, putThemes } from '../api/ThemeApi';
2
+ import { deleteTheme, deleteThemeByName, deleteThemes as _deleteThemes, getTheme, getThemeByName, getThemes, putTheme, putThemeByName, putThemes } from '../api/ThemeApi';
3
3
  import { createProgressIndicator, createTable, printMessage, stopProgressIndicator, updateProgressIndicator } from './utils/Console';
4
4
  import { getRealmString, getTypedFilename, saveToFile, validateImport } from './utils/ExportImportUtils';
5
5
  /**
@@ -13,7 +13,7 @@ export async function listThemes(long = false) {
13
13
 
14
14
  if (!long) {
15
15
  themeList.forEach(theme => {
16
- printMessage(`${theme.isDefault ? theme.name.brightCyan : theme.name}`, 'data');
16
+ printMessage(`${theme.isDefault ? theme.name['brightCyan'] : theme.name}`, 'data');
17
17
  });
18
18
  } else {
19
19
  const table = createTable(['Name'['brightCyan'], 'Id'['brightCyan'], 'Default'['brightCyan']]);
@@ -37,15 +37,15 @@ export async function exportThemeByName(name, file) {
37
37
  }
38
38
 
39
39
  createProgressIndicator(1, `Exporting ${name}`);
40
- const themeData = await getThemeByName(name);
41
40
 
42
- if (themeData.length === 0) {
43
- stopProgressIndicator(`Theme ${name} not found!`);
44
- printMessage(`Theme ${name} not found!`, 'error');
45
- } else {
41
+ try {
42
+ const themeData = await getThemeByName(name);
46
43
  updateProgressIndicator(`Writing file ${fileName}`);
47
- saveToFile('theme', themeData, '_id', fileName);
44
+ saveToFile('theme', [themeData], '_id', fileName);
48
45
  stopProgressIndicator(`Successfully exported theme ${name}.`);
46
+ } catch (error) {
47
+ stopProgressIndicator(`${error.message}`);
48
+ printMessage(`${error.message}`, 'error');
49
49
  }
50
50
  }
51
51
  /**
@@ -62,15 +62,15 @@ export async function exportThemeById(id, file) {
62
62
  }
63
63
 
64
64
  createProgressIndicator(1, `Exporting ${id}`);
65
- const themeData = await getTheme(id);
66
65
 
67
- if (themeData.length === 0) {
68
- stopProgressIndicator(`Theme ${id} not found!`);
69
- printMessage(`Theme ${id} not found!`, 'error');
70
- } else {
66
+ try {
67
+ const themeData = await getTheme(id);
71
68
  updateProgressIndicator(`Writing file ${fileName}`);
72
- saveToFile('theme', themeData, '_id', fileName);
69
+ saveToFile('theme', [themeData], '_id', fileName);
73
70
  stopProgressIndicator(`Successfully exported theme ${id}.`);
71
+ } catch (error) {
72
+ stopProgressIndicator(`${error.message}`);
73
+ printMessage(`${error.message}`, 'error');
74
74
  }
75
75
  }
76
76
  /**
@@ -118,7 +118,7 @@ export async function exportThemesToFiles() {
118
118
  */
119
119
 
120
120
  export async function importThemeByName(name, file) {
121
- fs.readFile(file, 'utf8', (err, data) => {
121
+ fs.readFile(file, 'utf8', async (err, data) => {
122
122
  if (err) throw err;
123
123
  const themeData = JSON.parse(data);
124
124
 
@@ -131,14 +131,15 @@ export async function importThemeByName(name, file) {
131
131
  if (themeData.theme[id].name === name) {
132
132
  found = true;
133
133
  updateProgressIndicator(`Importing ${themeData.theme[id].name}`);
134
- putThemeByName(name, themeData.theme[id]).then(result => {
135
- if (result == null) {
136
- stopProgressIndicator(`Error importing theme ${themeData.theme[id].name}`);
137
- printMessage(`Error importing theme ${themeData.theme[id].name}`, 'error');
138
- } else {
139
- stopProgressIndicator(`Successfully imported theme ${name}.`);
140
- }
141
- });
134
+
135
+ try {
136
+ await putThemeByName(name, themeData.theme[id]);
137
+ stopProgressIndicator(`Successfully imported theme ${name}.`);
138
+ } catch (error) {
139
+ stopProgressIndicator(`Error importing theme ${themeData.theme[id].name}: ${error.message}`);
140
+ printMessage(`Error importing theme ${themeData.theme[id].name}: ${error.message}`, 'error');
141
+ }
142
+
142
143
  break;
143
144
  }
144
145
  }
@@ -159,7 +160,7 @@ export async function importThemeByName(name, file) {
159
160
  */
160
161
 
161
162
  export async function importThemeById(id, file) {
162
- fs.readFile(file, 'utf8', (err, data) => {
163
+ fs.readFile(file, 'utf8', async (err, data) => {
163
164
  if (err) throw err;
164
165
  const themeData = JSON.parse(data);
165
166
 
@@ -172,14 +173,15 @@ export async function importThemeById(id, file) {
172
173
  if (themeId === id) {
173
174
  found = true;
174
175
  updateProgressIndicator(`Importing ${themeData.theme[themeId]._id}`);
175
- putTheme(themeId, themeData.theme[themeId]).then(result => {
176
- if (result == null) {
177
- stopProgressIndicator(`Error importing theme ${themeData.theme[themeId]._id}`);
178
- printMessage(`Error importing theme ${themeData.theme[themeId]._id}`, 'error');
179
- } else {
180
- stopProgressIndicator(`Successfully imported theme ${id}.`);
181
- }
182
- });
176
+
177
+ try {
178
+ await putTheme(themeId, themeData.theme[themeId]);
179
+ stopProgressIndicator(`Successfully imported theme ${id}.`);
180
+ } catch (error) {
181
+ stopProgressIndicator(`Error importing theme ${themeData.theme[themeId]._id}: ${error.message}`);
182
+ printMessage(`Error importing theme ${themeData.theme[themeId]._id}: ${error.message}`, 'error');
183
+ }
184
+
183
185
  break;
184
186
  }
185
187
  }
@@ -327,14 +329,22 @@ export async function deleteThemeByNameCmd(name) {
327
329
  * Delete all themes
328
330
  */
329
331
 
330
- export async function deleteThemesCmd() {
332
+ export async function deleteThemes() {
331
333
  createProgressIndicator(undefined, `Deleting all realm themes...`, 'indeterminate');
332
334
 
333
335
  try {
334
- await deleteThemes();
336
+ await _deleteThemes();
335
337
  stopProgressIndicator(`Deleted all realm themes.`, 'success');
336
338
  } catch (error) {
337
339
  stopProgressIndicator(`Error: ${error.message}`, 'fail');
338
340
  }
339
341
  }
342
+ /**
343
+ * Delete all themes
344
+ * @deprecated since version 0.14.0
345
+ */
346
+
347
+ export async function deleteThemesCmd() {
348
+ return deleteThemes();
349
+ }
340
350
  //# sourceMappingURL=ThemeOps.js.map
@@ -20,16 +20,30 @@ export function printMessage(message, type = 'text', newline = true) {
20
20
  handler(message, type, newline);
21
21
  }
22
22
  }
23
+ /**
24
+ * Handles verbose output. The caller decides and implements how
25
+ * the messages are handled, by implementing the handler function
26
+ * on its side. Implementing and registering a `handler` is optional.
27
+ *
28
+ * @param {string | unknown} message The verbose output message
29
+ */
30
+
31
+ export function verbose(message) {
32
+ const handler = storage.session.getVerboseHandler();
33
+
34
+ if (handler) {
35
+ handler(message);
36
+ }
37
+ }
23
38
  /**
24
39
  * Handles debug output. The caller decides and implements how
25
40
  * the messages are handled, by implementing the handler function
26
- * on its side. `handler` is optional, and if not included by the caller,
27
- * the data and messages will be lost.
41
+ * on its side. Implementing and registering a `handler` is optional.
28
42
  *
29
- * @param {string | unknown} message The string message to return
43
+ * @param {string | object} message The debug output message
30
44
  */
31
45
 
32
- export function debugMessage(message) {
46
+ export function debug(message) {
33
47
  const handler = storage.session.getDebugHandler();
34
48
 
35
49
  if (handler) {
@@ -52,8 +52,14 @@ export default {
52
52
  getPrintHandler: () => _sessionStorage['printHandler'],
53
53
  setErrorHandler: errorHandler => _sessionStorage['errorHandler'] = errorHandler,
54
54
  getErrorHandler: () => _sessionStorage['errorHandler'],
55
+ setVerboseHandler: verboseHandler => _sessionStorage['verboseHandler'] = verboseHandler,
56
+ getVerboseHandler: () => _sessionStorage['verboseHandler'],
57
+ setVerbose: verbose => _sessionStorage['verbose'] = verbose,
58
+ getVerbose: () => _sessionStorage['verbose'],
55
59
  setDebugHandler: debugHandler => _sessionStorage['debugHandler'] = debugHandler,
56
60
  getDebugHandler: () => _sessionStorage['debugHandler'],
61
+ setDebug: debug => _sessionStorage['debug'] = debug,
62
+ getDebug: () => _sessionStorage['debug'],
57
63
  setCreateProgressHandler: handler => _sessionStorage['createProgressHandler'] = handler,
58
64
  getCreateProgressHandler: () => _sessionStorage['createProgressHandler'],
59
65
  setUpdateProgressHandler: handler => _sessionStorage['updateProgressHandler'] = handler,
@@ -258,11 +258,11 @@ export function mockListAllConfigEntities(mock) {
258
258
  return [mockStatus, mockResponse];
259
259
  });
260
260
  }
261
- export function mockGetConfigEntity(mock) {
261
+ export function mockGetConfigEntity(mock, variation = null) {
262
262
  mock.onGet(/.*?\/openidm\/config\/.+/).reply(function (config) {
263
263
  const entityId = config.url ? config.url.substring(config.url.indexOf('/config/') + 8) : '';
264
264
  const mockStatus = 200;
265
- const mockResponse = JSON.parse(fs.readFileSync(path.resolve(__dirname, `./IdmConfigApi/getConfigEntity/${entityId}.json`), 'utf8'));
265
+ const mockResponse = JSON.parse(fs.readFileSync(path.resolve(__dirname, `./IdmConfigApi/getConfigEntity/${variation ? entityId + '-' + variation : entityId}.json`), 'utf8'));
266
266
  expect(mockResponse._id).toBe(entityId);
267
267
  return [mockStatus, mockResponse];
268
268
  });
@@ -0,0 +1,77 @@
1
+ {
2
+ "_id": "ui/themerealm",
3
+ "realm": {
4
+ "/": [
5
+ {
6
+ "accountCardBackgroundColor": "#ffffff",
7
+ "accountCardHeaderColor": "#23282e",
8
+ "accountCardInnerBorderColor": "#e7eef4",
9
+ "accountCardInputBackgroundColor": "#ffffff",
10
+ "accountCardInputBorderColor": "#c0c9d5",
11
+ "accountCardInputLabelColor": "#5e6d82",
12
+ "accountCardInputSelectColor": "#e4f4fd",
13
+ "accountCardInputTextColor": "#23282e",
14
+ "accountCardOuterBorderColor": "#e7eef4",
15
+ "accountCardShadow": 3,
16
+ "accountCardTabActiveColor": "#e4f4fd",
17
+ "accountCardTabActiveBorderColor": "#109cf1",
18
+ "accountCardTextColor": "#5e6d82",
19
+ "accountFooter": "<div class=\"d-flex justify-content-center py-4 w-100\"><span class=\"pr-1\">© 2022</span>\n<a href=\"#\" target=\"_blank\" class=\"text-body\">My Company, Inc</a><a href=\"#\" target=\"_blank\" style=\"color: #0000ee\" class=\"pl-3 text-body\">Privacy Policy</a><a href=\"#\" target=\"_blank\" style=\"color: #0000ee\" class=\"pl-3 text-body\">Terms & Conditions</a></div>",
20
+ "accountFooterEnabled": false,
21
+ "accountNavigationBackgroundColor": "#ffffff",
22
+ "accountNavigationTextColor": "#455469",
23
+ "accountNavigationToggleBorderColor": "#e7eef4",
24
+ "accountTableRowHoverColor": "#f6f8fa",
25
+ "backgroundColor": "#324054",
26
+ "backgroundImage": "",
27
+ "buttonRounded": 5,
28
+ "favicon": "https://cdn.forgerock.com/platform/themes/starter/logo-starter.svg",
29
+ "fontFamily": "Open Sans",
30
+ "journeyCardBackgroundColor": "#ffffff",
31
+ "journeyCardShadow": 3,
32
+ "journeyCardTextColor": "#5e6d82",
33
+ "journeyCardTitleColor": "#23282e",
34
+ "journeyFooter": "<div class=\"d-flex justify-content-center py-4 w-100\"><span class=\"pr-1\">© 2022</span>\n<a href=\"#\" target=\"_blank\" class=\"text-body\">My Company, Inc</a><a href=\"#\" target=\"_blank\" style=\"color: #0000ee\" class=\"pl-3 text-body\">Privacy Policy</a><a href=\"#\" target=\"_blank\" style=\"color: #0000ee\" class=\"pl-3 text-body\">Terms & Conditions</a></div>",
35
+ "journeyFooterEnabled": false,
36
+ "journeyHeader": "<div class=\"d-flex justify-content-center py-4 flex-grow-1\">Header Content</div>",
37
+ "journeyHeaderEnabled": false,
38
+ "journeyInputBackgroundColor": "#ffffff",
39
+ "journeyInputBorderColor": "#c0c9d5",
40
+ "journeyInputLabelColor": "#5e6d82",
41
+ "journeyInputSelectColor": "#e4f4fd",
42
+ "journeyInputTextColor": "#23282e",
43
+ "journeyTheaterMode": false,
44
+ "journeyJustifiedContent": "",
45
+ "journeyJustifiedContentEnabled": false,
46
+ "journeyLayout": "card",
47
+ "linkActiveColor": "#004067",
48
+ "linkColor": "#0070b3",
49
+ "linkedTrees": [],
50
+ "logo": "https://cdn.forgerock.com/platform/themes/starter/logo-starter.svg",
51
+ "logoAltText": "Logo",
52
+ "logoEnabled": true,
53
+ "logoHeight": "56",
54
+ "logoProfile": "https://cdn.forgerock.com/platform/themes/starter/logo-starter-full.svg",
55
+ "logoProfileAltText": "Logo",
56
+ "logoProfileCollapsed": "https://cdn.forgerock.com/platform/themes/starter/logo-starter.svg",
57
+ "logoProfileCollapsedAltText": "Logo",
58
+ "logoProfileHeight": "24",
59
+ "primaryColor": "#324054",
60
+ "primaryOffColor": "#242E3C",
61
+ "profileBackgroundColor": "#ffffff",
62
+ "profileMenuHighlightColor": "#f6f8fa",
63
+ "profileMenuTextHighlightColor": "#455469",
64
+ "profileMenuHoverColor": "#f6f8fa",
65
+ "profileMenuHoverTextColor": "#455469",
66
+ "textColor": "#ffffff",
67
+ "topBarBackgroundColor": "#ffffff",
68
+ "topBarBorderColor": "#e7eef4",
69
+ "topBarHeaderColor": "#23282e",
70
+ "topBarTextColor": "#69788b",
71
+ "_id": "d6636b33-111b-40f2-870d-f4dcb7281e43",
72
+ "isDefault": false,
73
+ "name": "Starter Theme"
74
+ }
75
+ ]
76
+ }
77
+ }