@rockcarver/frodo-lib 0.13.1 → 0.14.0

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 (52) hide show
  1. package/CHANGELOG.md +23 -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/LogOps.js +10 -4
  11. package/cjs/ops/LogOps.js.map +1 -1
  12. package/cjs/ops/ThemeOps.js +103 -84
  13. package/cjs/ops/ThemeOps.js.map +1 -1
  14. package/cjs/ops/utils/Console.js +21 -5
  15. package/cjs/ops/utils/Console.js.map +1 -1
  16. package/cjs/storage/SessionStorage.js +6 -0
  17. package/cjs/storage/SessionStorage.js.map +1 -1
  18. package/cjs/test/mocks/ForgeRockApiMockEngine.js +2 -1
  19. package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
  20. package/cjs/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm-encore.json +77 -0
  21. package/cjs/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm-putThemes.json +665 -0
  22. package/cjs/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm.json +1 -1
  23. package/esm/api/ThemeApi.mjs +129 -41
  24. package/esm/api/ThemeApi.test.mjs +903 -0
  25. package/esm/index.mjs +2 -1
  26. package/esm/ops/JourneyOps.mjs +259 -236
  27. package/esm/ops/LogOps.mjs +7 -3
  28. package/esm/ops/ThemeOps.mjs +44 -34
  29. package/esm/ops/utils/Console.mjs +18 -4
  30. package/esm/storage/SessionStorage.mjs +6 -0
  31. package/esm/test/mocks/ForgeRockApiMockEngine.mjs +2 -2
  32. package/esm/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm-encore.json +77 -0
  33. package/esm/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm-putThemes.json +665 -0
  34. package/esm/test/mocks/IdmConfigApi/getConfigEntity/ui/themerealm.json +1 -1
  35. package/package.json +1 -1
  36. package/types/api/ApiTypes.d.ts +5 -1
  37. package/types/api/ApiTypes.d.ts.map +1 -1
  38. package/types/api/ThemeApi.d.ts +28 -26
  39. package/types/api/ThemeApi.d.ts.map +1 -1
  40. package/types/index.d.ts +1 -0
  41. package/types/index.d.ts.map +1 -1
  42. package/types/ops/JourneyOps.d.ts.map +1 -1
  43. package/types/ops/LogOps.d.ts +2 -1
  44. package/types/ops/LogOps.d.ts.map +1 -1
  45. package/types/ops/ThemeOps.d.ts +5 -0
  46. package/types/ops/ThemeOps.d.ts.map +1 -1
  47. package/types/ops/utils/Console.d.ts +11 -4
  48. package/types/ops/utils/Console.d.ts.map +1 -1
  49. package/types/storage/SessionStorage.d.ts +6 -0
  50. package/types/storage/SessionStorage.d.ts.map +1 -1
  51. package/types/test/mocks/ForgeRockApiMockEngine.d.ts +1 -1
  52. package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.14.0] - 2022-10-11
11
+
12
+ ### Added
13
+
14
+ - rockcarver/frodo-cli#70: Added ability to create custom logging noise filters
15
+ - \#119, #121: Library modules can now produce verbose output Embedding code has to register a verboseHandler and enable verbose flag in session.
16
+ - \#120, #122: Library modules can now produce debug output. Embedding code has to register a debugHandler and enable debug flag in session.
17
+
18
+ ### Fixed
19
+
20
+ - \#116: Frodo now properly imports themes.
21
+
22
+ ## [0.13.2-0] - 2022-10-04
23
+
24
+ ### Added
25
+
26
+ - rockcarver/frodo-cli#70: Added ability to create custom logging noise filters
27
+
10
28
  ## [0.13.1] - 2022-10-04
11
29
 
12
30
  ### Fixed
@@ -589,7 +607,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
589
607
  - Fixed problem with adding connection profiles
590
608
  - Miscellaneous bug fixes
591
609
 
592
- [Unreleased]: https://github.com/rockcarver/frodo-lib/compare/v0.13.1...HEAD
610
+ [Unreleased]: https://github.com/rockcarver/frodo-lib/compare/v0.14.0...HEAD
611
+
612
+ [0.14.0]: https://github.com/rockcarver/frodo-lib/compare/v0.13.2-0...v0.14.0
613
+
614
+ [0.13.2-0]: https://github.com/rockcarver/frodo-lib/compare/v0.13.1...v0.13.2-0
593
615
 
594
616
  [0.13.1]: https://github.com/rockcarver/frodo-lib/compare/v0.13.0...v0.13.1
595
617
 
@@ -1 +1 @@
1
- {"version":3,"file":"ApiTypes.js","names":["ScriptLanguage","ScriptContext","Saml2ProiderLocation"],"sources":["api/ApiTypes.ts"],"sourcesContent":["interface ObjectSkeletonInterface {\n _id: string;\n _rev?: number;\n [k: string]: string | number | ObjectSkeletonInterface;\n}\n\nexport interface UiConfigInterface {\n categories: string;\n}\n\nexport interface NodeRefSkeletonInterface {\n connections: Record<string, string>;\n displayName: string;\n nodeType: string;\n x: number;\n y: number;\n}\n\nexport interface InnerNodeRefSkeletonInterface {\n _id: string;\n displayName: string;\n nodeType: string;\n}\n\nexport type TreeSkeleton = ObjectSkeletonInterface & {\n entryNodeId: string;\n nodes: Record<string, NodeRefSkeletonInterface>;\n identityResource?: string;\n uiConfig?: UiConfigInterface;\n enabled?: boolean;\n};\n\nexport type AmServiceType = ObjectSkeletonInterface & {\n name: string;\n};\n\nexport type NodeSkeleton = ObjectSkeletonInterface & {\n _type: AmServiceType;\n nodes?: InnerNodeRefSkeletonInterface[];\n tree?: string;\n identityResource?: string;\n};\n\nexport type SocialIdpSkeleton = ObjectSkeletonInterface & {\n _type: AmServiceType;\n enabled: boolean;\n};\n\nexport type EmailTemplateSkeleton = ObjectSkeletonInterface & {\n defaultLocale?: string;\n displayName?: string;\n enabled?: boolean;\n from: string;\n subject: Record<string, string>;\n};\n\nexport type ThemeSkeleton = ObjectSkeletonInterface & {\n name: string;\n isDefault: boolean;\n linkedTrees: string[];\n};\n\nexport enum ScriptLanguage {\n GROOVY = 'GROOVY',\n JAVASCRIPT = 'JAVASCRIPT',\n}\n\nexport enum ScriptContext {\n OAUTH2_ACCESS_TOKEN_MODIFICATION = 'OAUTH2_ACCESS_TOKEN_MODIFICATION',\n AUTHENTICATION_CLIENT_SIDE = 'AUTHENTICATION_CLIENT_SIDE',\n AUTHENTICATION_TREE_DECISION_NODE = 'AUTHENTICATION_TREE_DECISION_NODE',\n AUTHENTICATION_SERVER_SIDE = 'AUTHENTICATION_SERVER_SIDE',\n SOCIAL_IDP_PROFILE_TRANSFORMATION = 'SOCIAL_IDP_PROFILE_TRANSFORMATION',\n OAUTH2_VALIDATE_SCOPE = 'OAUTH2_VALIDATE_SCOPE',\n CONFIG_PROVIDER_NODE = 'CONFIG_PROVIDER_NODE',\n OAUTH2_AUTHORIZE_ENDPOINT_DATA_PROVIDER = 'OAUTH2_AUTHORIZE_ENDPOINT_DATA_PROVIDER',\n OAUTH2_EVALUATE_SCOPE = 'OAUTH2_EVALUATE_SCOPE',\n POLICY_CONDITION = 'POLICY_CONDITION',\n OIDC_CLAIMS = 'OIDC_CLAIMS',\n SAML2_IDP_ADAPTER = 'SAML2_IDP_ADAPTER',\n SAML2_IDP_ATTRIBUTE_MAPPER = 'SAML2_IDP_ATTRIBUTE_MAPPER',\n OAUTH2_MAY_ACT = 'OAUTH2_MAY_ACT',\n}\n\nexport type ScriptSkeleton = ObjectSkeletonInterface & {\n name: string;\n description: string;\n isDefault: boolean;\n script: string;\n language: ScriptLanguage;\n context: ScriptContext;\n createdBy: string;\n creationDate: number;\n lastModifiedBy: string;\n lastModifiedDate: number;\n};\n\nexport enum Saml2ProiderLocation {\n HOSTED = 'hosted',\n REMOTE = 'remote',\n}\n\nexport type Saml2ProviderSkeleton = ObjectSkeletonInterface & {\n entityId: string;\n entityLocation: Saml2ProiderLocation;\n serviceProvider: unknown;\n identityProvider: unknown;\n attributeQueryProvider: unknown;\n xacmlPolicyEnforcementPoint: unknown;\n};\n\nexport type CircleOfTrustSkeleton = ObjectSkeletonInterface & {\n _type: AmServiceType;\n status: string;\n trustedProviders: string[];\n};\n"],"mappings":";;;;;;IA8DYA,c;;;WAAAA,c;EAAAA,c;EAAAA,c;GAAAA,c,8BAAAA,c;;IAKAC,a;;;WAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;GAAAA,a,6BAAAA,a;;IA8BAC,oB;;;WAAAA,oB;EAAAA,oB;EAAAA,oB;GAAAA,oB,oCAAAA,oB"}
1
+ {"version":3,"file":"ApiTypes.js","names":["ScriptLanguage","ScriptContext","Saml2ProiderLocation"],"sources":["api/ApiTypes.ts"],"sourcesContent":["interface ObjectSkeletonInterface {\n _id: string;\n _rev?: number;\n [k: string]: string | number | boolean | string[] | ObjectSkeletonInterface;\n}\n\nexport interface UiConfigInterface {\n categories: string;\n}\n\nexport interface NodeRefSkeletonInterface {\n connections: Record<string, string>;\n displayName: string;\n nodeType: string;\n x: number;\n y: number;\n}\n\nexport interface InnerNodeRefSkeletonInterface {\n _id: string;\n displayName: string;\n nodeType: string;\n}\n\nexport type TreeSkeleton = ObjectSkeletonInterface & {\n entryNodeId: string;\n nodes: Record<string, NodeRefSkeletonInterface>;\n identityResource?: string;\n uiConfig?: UiConfigInterface;\n enabled?: boolean;\n};\n\nexport type AmServiceType = ObjectSkeletonInterface & {\n name: string;\n};\n\nexport type NodeSkeleton = ObjectSkeletonInterface & {\n _type: AmServiceType;\n nodes?: InnerNodeRefSkeletonInterface[];\n tree?: string;\n identityResource?: string;\n};\n\nexport type SocialIdpSkeleton = ObjectSkeletonInterface & {\n _type: AmServiceType;\n enabled: boolean;\n};\n\nexport type EmailTemplateSkeleton = ObjectSkeletonInterface & {\n defaultLocale?: string;\n displayName?: string;\n enabled?: boolean;\n from: string;\n subject: Record<string, string>;\n};\n\nexport type ThemeSkeleton = ObjectSkeletonInterface & {\n name: string;\n isDefault: boolean;\n linkedTrees: string[];\n};\n\nexport type UiThemeRealmObject = ObjectSkeletonInterface & {\n name: string;\n realm: Map<string, ThemeSkeleton[]>;\n};\n\nexport enum ScriptLanguage {\n GROOVY = 'GROOVY',\n JAVASCRIPT = 'JAVASCRIPT',\n}\n\nexport enum ScriptContext {\n OAUTH2_ACCESS_TOKEN_MODIFICATION = 'OAUTH2_ACCESS_TOKEN_MODIFICATION',\n AUTHENTICATION_CLIENT_SIDE = 'AUTHENTICATION_CLIENT_SIDE',\n AUTHENTICATION_TREE_DECISION_NODE = 'AUTHENTICATION_TREE_DECISION_NODE',\n AUTHENTICATION_SERVER_SIDE = 'AUTHENTICATION_SERVER_SIDE',\n SOCIAL_IDP_PROFILE_TRANSFORMATION = 'SOCIAL_IDP_PROFILE_TRANSFORMATION',\n OAUTH2_VALIDATE_SCOPE = 'OAUTH2_VALIDATE_SCOPE',\n CONFIG_PROVIDER_NODE = 'CONFIG_PROVIDER_NODE',\n OAUTH2_AUTHORIZE_ENDPOINT_DATA_PROVIDER = 'OAUTH2_AUTHORIZE_ENDPOINT_DATA_PROVIDER',\n OAUTH2_EVALUATE_SCOPE = 'OAUTH2_EVALUATE_SCOPE',\n POLICY_CONDITION = 'POLICY_CONDITION',\n OIDC_CLAIMS = 'OIDC_CLAIMS',\n SAML2_IDP_ADAPTER = 'SAML2_IDP_ADAPTER',\n SAML2_IDP_ATTRIBUTE_MAPPER = 'SAML2_IDP_ATTRIBUTE_MAPPER',\n OAUTH2_MAY_ACT = 'OAUTH2_MAY_ACT',\n}\n\nexport type ScriptSkeleton = ObjectSkeletonInterface & {\n name: string;\n description: string;\n isDefault: boolean;\n script: string;\n language: ScriptLanguage;\n context: ScriptContext;\n createdBy: string;\n creationDate: number;\n lastModifiedBy: string;\n lastModifiedDate: number;\n};\n\nexport enum Saml2ProiderLocation {\n HOSTED = 'hosted',\n REMOTE = 'remote',\n}\n\nexport type Saml2ProviderSkeleton = ObjectSkeletonInterface & {\n entityId: string;\n entityLocation: Saml2ProiderLocation;\n serviceProvider: unknown;\n identityProvider: unknown;\n attributeQueryProvider: unknown;\n xacmlPolicyEnforcementPoint: unknown;\n};\n\nexport type CircleOfTrustSkeleton = ObjectSkeletonInterface & {\n _type: AmServiceType;\n status: string;\n trustedProviders: string[];\n};\n"],"mappings":";;;;;;IAmEYA,c;;;WAAAA,c;EAAAA,c;EAAAA,c;GAAAA,c,8BAAAA,c;;IAKAC,a;;;WAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;GAAAA,a,6BAAAA,a;;IA8BAC,oB;;;WAAAA,oB;EAAAA,oB;EAAAA,oB;GAAAA,oB,oCAAAA,oB"}
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.THEMEREALM_ID = void 0;
6
7
  exports.deleteTheme = deleteTheme;
7
8
  exports.deleteThemeByName = deleteThemeByName;
8
9
  exports.deleteThemes = deleteThemes;
@@ -17,6 +18,8 @@ var _IdmConfigApi = require("./IdmConfigApi");
17
18
 
18
19
  var _ApiUtils = require("./utils/ApiUtils");
19
20
 
21
+ var _Console = require("../ops/utils/Console");
22
+
20
23
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
21
24
 
22
25
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -24,16 +27,22 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
24
27
  var THEMEREALM_ID = 'ui/themerealm';
25
28
  /**
26
29
  * Get realm themes
27
- * @param {Object} themes object containing themes
28
- * @returns {Object} array of theme pertaining to the current realm
30
+ * @param {UiThemeRealmObject} themes object containing themes
31
+ * @returns {ThemeSkeleton[]} array of theme pertaining to the current realm
29
32
  */
30
33
 
34
+ exports.THEMEREALM_ID = THEMEREALM_ID;
35
+
31
36
  function getRealmThemes(themes) {
32
- return themes.realm[(0, _ApiUtils.getCurrentRealmName)()] ? themes.realm[(0, _ApiUtils.getCurrentRealmName)()] : [];
37
+ if (themes.realm && themes.realm[(0, _ApiUtils.getCurrentRealmName)()]) {
38
+ return themes.realm[(0, _ApiUtils.getCurrentRealmName)()];
39
+ }
40
+
41
+ return [];
33
42
  }
34
43
  /**
35
44
  * Get all themes
36
- * @returns {Promise} a promise that resolves to an array of themes
45
+ * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes
37
46
  */
38
47
 
39
48
 
@@ -42,8 +51,8 @@ function getThemes() {
42
51
  }
43
52
  /**
44
53
  * Get theme by id
45
- * @param {String} themeId theme id
46
- * @returns {Promise} a promise that resolves to an array of themes
54
+ * @param {string} themeId theme id
55
+ * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
47
56
  */
48
57
 
49
58
 
@@ -60,15 +69,25 @@ function getTheme(_x) {
60
69
  }
61
70
  /**
62
71
  * Get theme by name
63
- * @param {String} themeName theme name
64
- * @returns {Promise} a promise that resolves to an array of themes
72
+ * @param {string} themeName theme name
73
+ * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
65
74
  */
66
75
 
67
76
 
68
77
  function _getTheme() {
69
78
  _getTheme = _asyncToGenerator(function* (themeId) {
70
79
  var themes = yield (0, _IdmConfigApi.getConfigEntity)(THEMEREALM_ID);
71
- return getRealmThemes(themes).filter(theme => theme._id === themeId);
80
+ var found = getRealmThemes(themes).filter(theme => theme._id === themeId);
81
+
82
+ if (found.length === 1) {
83
+ return found[0];
84
+ }
85
+
86
+ if (found.length > 1) {
87
+ throw new Error("Multiple themes with id \"".concat(themeId, "\" found!"));
88
+ }
89
+
90
+ throw new Error("Theme with id \"".concat(themeId, "\" not found!"));
72
91
  });
73
92
  return _getTheme.apply(this, arguments);
74
93
  }
@@ -78,16 +97,26 @@ function getThemeByName(_x2) {
78
97
  }
79
98
  /**
80
99
  * Put theme by id
81
- * @param {String} themeId theme id
82
- * @param {Object} themeData theme object
83
- * @returns {Promise} a promise that resolves to a themes object
100
+ * @param {string} themeId theme id
101
+ * @param {ThemeSkeleton} themeData theme object
102
+ * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
84
103
  */
85
104
 
86
105
 
87
106
  function _getThemeByName() {
88
107
  _getThemeByName = _asyncToGenerator(function* (themeName) {
89
108
  var themes = yield (0, _IdmConfigApi.getConfigEntity)(THEMEREALM_ID);
90
- return getRealmThemes(themes).filter(theme => theme.name === themeName);
109
+ var found = getRealmThemes(themes).filter(theme => theme.name === themeName);
110
+
111
+ if (found.length === 1) {
112
+ return found[0];
113
+ }
114
+
115
+ if (found.length > 1) {
116
+ throw new Error("Multiple themes with the name \"".concat(themeName, "\" found!"));
117
+ }
118
+
119
+ throw new Error("Theme \"".concat(themeName, "\" not found!"));
91
120
  });
92
121
  return _getThemeByName.apply(this, arguments);
93
122
  }
@@ -98,8 +127,8 @@ function putTheme(_x3, _x4) {
98
127
  /**
99
128
  * Put theme by name
100
129
  * @param {String} themeName theme name
101
- * @param {Object} themeData theme object
102
- * @returns {Promise} a promise that resolves to a themes object
130
+ * @param {ThemeSkeleton} themeData theme object
131
+ * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
103
132
  */
104
133
 
105
134
 
@@ -125,7 +154,17 @@ function _putTheme() {
125
154
  }
126
155
 
127
156
  themes.realm[(0, _ApiUtils.getCurrentRealmName)()] = realmThemes;
128
- return (0, _IdmConfigApi.putConfigEntity)(THEMEREALM_ID, themes);
157
+ var found = getRealmThemes(yield (0, _IdmConfigApi.putConfigEntity)(THEMEREALM_ID, themes)).filter(theme => theme._id === themeId);
158
+
159
+ if (found.length === 1) {
160
+ return found[0];
161
+ }
162
+
163
+ if (found.length > 1) {
164
+ throw new Error("Multiple themes with id \"".concat(themeId, "\" found!"));
165
+ }
166
+
167
+ throw new Error("Theme with id \"".concat(themeId, "\" not saved!"));
129
168
  });
130
169
  return _putTheme.apply(this, arguments);
131
170
  }
@@ -135,8 +174,8 @@ function putThemeByName(_x5, _x6) {
135
174
  }
136
175
  /**
137
176
  * Put all themes
138
- * @param {Object} allThemesData themes object containing all themes for all realms
139
- * @returns {Promise} a promise that resolves to a themes object
177
+ * @param {Map<string, ThemeSkeleton>} allThemesData themes object containing all themes for all realms
178
+ * @returns {Promise<Map<string, ThemeSkeleton>>} a promise that resolves to a themes object
140
179
  */
141
180
 
142
181
 
@@ -162,7 +201,17 @@ function _putThemeByName() {
162
201
  }
163
202
 
164
203
  themes['realm'][(0, _ApiUtils.getCurrentRealmName)()] = realmThemes;
165
- return (0, _IdmConfigApi.putConfigEntity)(THEMEREALM_ID, themes);
204
+ var found = getRealmThemes(yield (0, _IdmConfigApi.putConfigEntity)(THEMEREALM_ID, themes)).filter(theme => theme.name === themeName);
205
+
206
+ if (found.length === 1) {
207
+ return found[0];
208
+ }
209
+
210
+ if (found.length > 1) {
211
+ throw new Error("Multiple themes \"".concat(themeName, "\" found!"));
212
+ }
213
+
214
+ throw new Error("Theme \"".concat(themeName, "\" not saved!"));
166
215
  });
167
216
  return _putThemeByName.apply(this, arguments);
168
217
  }
@@ -172,25 +221,26 @@ function putThemes(_x7) {
172
221
  }
173
222
  /**
174
223
  * Delete theme by id
175
- * @param {String} themeId theme id
176
- * @returns {Promise} a promise that resolves to a themes object
224
+ * @param {string} themeId theme id
225
+ * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object
177
226
  */
178
227
 
179
228
 
180
229
  function _putThemes() {
181
- _putThemes = _asyncToGenerator(function* (allThemesData) {
182
- var data = allThemesData;
230
+ _putThemes = _asyncToGenerator(function* (themeMap) {
231
+ (0, _Console.debug)("ThemeApi.putThemes: start");
183
232
  var themes = yield (0, _IdmConfigApi.getConfigEntity)(THEMEREALM_ID);
184
- var allThemeIDs = Object.keys(data);
233
+ var allThemeIDs = Object.keys(themeMap);
185
234
  var existingThemeIDs = [];
186
235
  var defaultThemeId = null; // update existing themes
187
236
 
188
237
  var realmThemes = getRealmThemes(themes).map(theme => {
189
- if (data[theme._id]) {
238
+ if (themeMap[theme._id]) {
239
+ (0, _Console.debug)("Update theme: ".concat(theme._id, " - ").concat(theme.name));
190
240
  existingThemeIDs.push(theme._id); // remember the id of the last default theme
191
241
 
192
- if (data[theme._id].isDefault) defaultThemeId = theme._id;
193
- return data[theme._id];
242
+ if (themeMap[theme._id].isDefault) defaultThemeId = theme._id;
243
+ return themeMap[theme._id];
194
244
  }
195
245
 
196
246
  return theme;
@@ -198,9 +248,10 @@ function _putThemes() {
198
248
  var newThemeIDs = allThemeIDs.filter(id => !existingThemeIDs.includes(id)); // add new themes
199
249
 
200
250
  newThemeIDs.forEach(themeId => {
201
- // remember the id of the last default theme
202
- if (data[themeId].isDefault) defaultThemeId = themeId;
203
- realmThemes.push(data[themeId]);
251
+ (0, _Console.debug)("Add theme: ".concat(themeMap[themeId]._id, " - ").concat(themeMap[themeId].name)); // remember the id of the last default theme
252
+
253
+ if (themeMap[themeId].isDefault) defaultThemeId = themeId;
254
+ realmThemes.push(themeMap[themeId]);
204
255
  }); // if we imported a default theme, flag all the other themes as not default
205
256
 
206
257
  if (defaultThemeId) {
@@ -212,7 +263,10 @@ function _putThemes() {
212
263
  }
213
264
 
214
265
  themes.realm[(0, _ApiUtils.getCurrentRealmName)()] = realmThemes;
215
- return (0, _IdmConfigApi.putConfigEntity)(THEMEREALM_ID, themes);
266
+ var updatedThemes = new Map(getRealmThemes(yield (0, _IdmConfigApi.putConfigEntity)(THEMEREALM_ID, themes)).map(theme => [theme._id, theme]));
267
+ (0, _Console.debug)(updatedThemes);
268
+ (0, _Console.debug)("ThemeApi.putThemes: finished");
269
+ return updatedThemes;
216
270
  });
217
271
  return _putThemes.apply(this, arguments);
218
272
  }
@@ -222,8 +276,8 @@ function deleteTheme(_x8) {
222
276
  }
223
277
  /**
224
278
  * Delete theme by name
225
- * @param {String} themeName theme name
226
- * @returns {Promise} a promise that resolves to a themes object
279
+ * @param {string} themeName theme name
280
+ * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object
227
281
  */
228
282
 
229
283
 
@@ -231,10 +285,24 @@ function _deleteTheme() {
231
285
  _deleteTheme = _asyncToGenerator(function* (themeId) {
232
286
  var themes = yield (0, _IdmConfigApi.getConfigEntity)(THEMEREALM_ID);
233
287
  var realmThemes = getRealmThemes(themes);
234
- var finalThemes = realmThemes.filter(theme => theme._id !== themeId);
288
+ var deletedThemes = [];
289
+ var finalThemes = realmThemes.filter(theme => {
290
+ if (theme._id !== themeId) {
291
+ return true;
292
+ }
293
+
294
+ deletedThemes.push(theme);
295
+ return false;
296
+ });
235
297
  if (realmThemes.length === finalThemes.length) throw new Error("".concat(themeId, " not found"));
236
298
  themes.realm[(0, _ApiUtils.getCurrentRealmName)()] = realmThemes;
237
- return (0, _IdmConfigApi.putConfigEntity)(THEMEREALM_ID, themes);
299
+ var undeletedThemes = getRealmThemes(yield (0, _IdmConfigApi.putConfigEntity)(THEMEREALM_ID, themes)).filter(theme => deletedThemes.includes(theme));
300
+
301
+ if (deletedThemes.length > 0 && undeletedThemes.length === 0) {
302
+ return deletedThemes[0];
303
+ }
304
+
305
+ throw new Error("Theme(s) with id(s) \"".concat(undeletedThemes.map(theme => theme._id), "\" not deleted!"));
238
306
  });
239
307
  return _deleteTheme.apply(this, arguments);
240
308
  }
@@ -244,7 +312,7 @@ function deleteThemeByName(_x9) {
244
312
  }
245
313
  /**
246
314
  * Delete all themes
247
- * @returns {Promise} a promise that resolves to an array of themes
315
+ * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes
248
316
  */
249
317
 
250
318
 
@@ -252,10 +320,25 @@ function _deleteThemeByName() {
252
320
  _deleteThemeByName = _asyncToGenerator(function* (themeName) {
253
321
  var themes = yield (0, _IdmConfigApi.getConfigEntity)(THEMEREALM_ID);
254
322
  var realmThemes = getRealmThemes(themes);
255
- var finalThemes = realmThemes.filter(theme => theme.name !== themeName);
323
+ var deletedThemes = [];
324
+ var finalThemes = realmThemes.filter(theme => {
325
+ if (theme.name !== themeName) {
326
+ return true;
327
+ }
328
+
329
+ deletedThemes.push(theme);
330
+ return false;
331
+ });
256
332
  if (realmThemes.length === finalThemes.length) throw new Error("".concat(themeName, " not found"));
257
- themes.realm[(0, _ApiUtils.getCurrentRealmName)()] = finalThemes;
258
- return (0, _IdmConfigApi.putConfigEntity)(THEMEREALM_ID, themes);
333
+ themes.realm[(0, _ApiUtils.getCurrentRealmName)()] = finalThemes; // return putConfigEntity(THEMEREALM_ID, themes);
334
+
335
+ var undeletedThemes = getRealmThemes(yield (0, _IdmConfigApi.putConfigEntity)(THEMEREALM_ID, themes)).filter(theme => deletedThemes.includes(theme));
336
+
337
+ if (deletedThemes.length > 0 && undeletedThemes.length === 0) {
338
+ return deletedThemes[0];
339
+ }
340
+
341
+ throw new Error("Theme(s) with id(s) \"".concat(undeletedThemes.map(theme => theme._id), "\" not deleted!"));
259
342
  });
260
343
  return _deleteThemeByName.apply(this, arguments);
261
344
  }
@@ -267,8 +350,17 @@ function deleteThemes() {
267
350
  function _deleteThemes() {
268
351
  _deleteThemes = _asyncToGenerator(function* () {
269
352
  var themes = yield (0, _IdmConfigApi.getConfigEntity)(THEMEREALM_ID);
353
+ var realmThemes = themes.realm[(0, _ApiUtils.getCurrentRealmName)()];
354
+ if (!realmThemes) throw new Error("No theme configuration found for realm \"".concat((0, _ApiUtils.getCurrentRealmName)(), "\""));
355
+ var deletedThemes = [];
356
+
357
+ for (var theme of realmThemes) {
358
+ deletedThemes.push(theme);
359
+ }
360
+
270
361
  themes.realm[(0, _ApiUtils.getCurrentRealmName)()] = [];
271
- return (0, _IdmConfigApi.putConfigEntity)(THEMEREALM_ID, themes);
362
+ yield (0, _IdmConfigApi.putConfigEntity)(THEMEREALM_ID, themes);
363
+ return deletedThemes;
272
364
  });
273
365
  return _deleteThemes.apply(this, arguments);
274
366
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeApi.js","names":["THEMEREALM_ID","getRealmThemes","themes","realm","getCurrentRealmName","getThemes","getConfigEntity","getTheme","themeId","filter","theme","_id","getThemeByName","themeName","name","putTheme","themeData","data","isNew","realmThemes","map","isDefault","push","putConfigEntity","putThemeByName","putThemes","allThemesData","allThemeIDs","Object","keys","existingThemeIDs","defaultThemeId","newThemeIDs","id","includes","forEach","deleteTheme","finalThemes","length","Error","deleteThemeByName","deleteThemes"],"sources":["api/ThemeApi.ts"],"sourcesContent":["import { getConfigEntity, putConfigEntity } from './IdmConfigApi';\nimport { getCurrentRealmName } from './utils/ApiUtils';\n\nconst THEMEREALM_ID = 'ui/themerealm';\n\n/**\n * Get realm themes\n * @param {Object} themes object containing themes\n * @returns {Object} array of theme pertaining to the current realm\n */\nfunction getRealmThemes(themes) {\n return themes.realm[getCurrentRealmName()]\n ? themes.realm[getCurrentRealmName()]\n : [];\n}\n\n/**\n * Get all themes\n * @returns {Promise} a promise that resolves to an array of themes\n */\nexport async function getThemes() {\n const themes = await getConfigEntity(THEMEREALM_ID);\n return getRealmThemes(themes);\n}\n\n/**\n * Get theme by id\n * @param {String} themeId theme id\n * @returns {Promise} a promise that resolves to an array of themes\n */\nexport async function getTheme(themeId) {\n const themes = await getConfigEntity(THEMEREALM_ID);\n return getRealmThemes(themes).filter((theme) => theme._id === themeId);\n}\n\n/**\n * Get theme by name\n * @param {String} themeName theme name\n * @returns {Promise} a promise that resolves to an array of themes\n */\nexport async function getThemeByName(themeName) {\n const themes = await getConfigEntity(THEMEREALM_ID);\n return getRealmThemes(themes).filter((theme) => theme.name === themeName);\n}\n\n/**\n * Put theme by id\n * @param {String} themeId theme id\n * @param {Object} themeData theme object\n * @returns {Promise} a promise that resolves to a themes object\n */\nexport async function putTheme(themeId, themeData) {\n const data = themeData;\n data._id = themeId;\n const themes = await getConfigEntity(THEMEREALM_ID);\n let isNew = true;\n const realmThemes = getRealmThemes(themes).map((theme) => {\n if (theme._id === themeId) {\n isNew = false;\n return data;\n }\n // eslint-disable-next-line no-param-reassign\n if (data.isDefault) theme.isDefault = false;\n return theme;\n });\n if (isNew) {\n realmThemes.push(data);\n }\n themes.realm[getCurrentRealmName()] = realmThemes;\n return putConfigEntity(THEMEREALM_ID, themes);\n}\n\n/**\n * Put theme by name\n * @param {String} themeName theme name\n * @param {Object} themeData theme object\n * @returns {Promise} a promise that resolves to a themes object\n */\nexport async function putThemeByName(themeName, themeData) {\n const data = themeData;\n data.name = themeName;\n const themes = await getConfigEntity(THEMEREALM_ID);\n let isNew = true;\n const realmThemes = getRealmThemes(themes).map((theme) => {\n if (theme.name === themeName) {\n isNew = false;\n return data;\n }\n // eslint-disable-next-line no-param-reassign\n if (data.isDefault) theme.isDefault = false;\n return theme;\n });\n if (isNew) {\n realmThemes.push(data);\n }\n themes['realm'][getCurrentRealmName()] = realmThemes;\n return putConfigEntity(THEMEREALM_ID, themes);\n}\n\n/**\n * Put all themes\n * @param {Object} allThemesData themes object containing all themes for all realms\n * @returns {Promise} a promise that resolves to a themes object\n */\nexport async function putThemes(allThemesData) {\n const data = allThemesData;\n const themes = await getConfigEntity(THEMEREALM_ID);\n const allThemeIDs = Object.keys(data);\n const existingThemeIDs = [];\n let defaultThemeId = null;\n // update existing themes\n let realmThemes = getRealmThemes(themes).map((theme) => {\n if (data[theme._id]) {\n existingThemeIDs.push(theme._id);\n // remember the id of the last default theme\n if (data[theme._id].isDefault) defaultThemeId = theme._id;\n return data[theme._id];\n }\n return theme;\n });\n const newThemeIDs = allThemeIDs.filter(\n (id) => !existingThemeIDs.includes(id)\n );\n // add new themes\n newThemeIDs.forEach((themeId) => {\n // remember the id of the last default theme\n if (data[themeId].isDefault) defaultThemeId = themeId;\n realmThemes.push(data[themeId]);\n });\n // if we imported a default theme, flag all the other themes as not default\n if (defaultThemeId) {\n realmThemes = realmThemes.map((theme) => {\n // eslint-disable-next-line no-param-reassign\n theme.isDefault = theme._id === defaultThemeId;\n return theme;\n });\n }\n themes.realm[getCurrentRealmName()] = realmThemes;\n return putConfigEntity(THEMEREALM_ID, themes);\n}\n\n/**\n * Delete theme by id\n * @param {String} themeId theme id\n * @returns {Promise} a promise that resolves to a themes object\n */\nexport async function deleteTheme(themeId) {\n const themes = await getConfigEntity(THEMEREALM_ID);\n const realmThemes = getRealmThemes(themes);\n const finalThemes = realmThemes.filter((theme) => theme._id !== themeId);\n if (realmThemes.length === finalThemes.length)\n throw new Error(`${themeId} not found`);\n themes.realm[getCurrentRealmName()] = realmThemes;\n return putConfigEntity(THEMEREALM_ID, themes);\n}\n\n/**\n * Delete theme by name\n * @param {String} themeName theme name\n * @returns {Promise} a promise that resolves to a themes object\n */\nexport async function deleteThemeByName(themeName) {\n const themes = await getConfigEntity(THEMEREALM_ID);\n const realmThemes = getRealmThemes(themes);\n const finalThemes = realmThemes.filter((theme) => theme.name !== themeName);\n if (realmThemes.length === finalThemes.length)\n throw new Error(`${themeName} not found`);\n themes.realm[getCurrentRealmName()] = finalThemes;\n return putConfigEntity(THEMEREALM_ID, themes);\n}\n\n/**\n * Delete all themes\n * @returns {Promise} a promise that resolves to an array of themes\n */\nexport async function deleteThemes() {\n const themes = await getConfigEntity(THEMEREALM_ID);\n themes.realm[getCurrentRealmName()] = [];\n return putConfigEntity(THEMEREALM_ID, themes);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAEA,IAAMA,aAAa,GAAG,eAAtB;AAEA;AACA;AACA;AACA;AACA;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AO,IAAAd,6BAAA,EAAgBvB,aAAhB,EAA+BE,MAA/B,CAAP;EACD,C;;;;SAMqBuC,Y;;;;;oCAAf,aAA8B;IACnC,IAAMvC,MAAM,SAAS,IAAAI,6BAAA,EAAgBN,aAAhB,CAArB;IACAE,MAAM,CAACC,KAAP,CAAa,IAAAC,6BAAA,GAAb,IAAsC,EAAtC;IACA,OAAO,IAAAmB,6BAAA,EAAgBvB,aAAhB,EAA+BE,MAA/B,CAAP;EACD,C"}
1
+ {"version":3,"file":"ThemeApi.js","names":["THEMEREALM_ID","getRealmThemes","themes","realm","getCurrentRealmName","getThemes","getConfigEntity","getTheme","themeId","found","filter","theme","_id","length","Error","getThemeByName","themeName","name","putTheme","themeData","data","isNew","realmThemes","map","isDefault","push","putConfigEntity","putThemeByName","putThemes","themeMap","debug","allThemeIDs","Object","keys","existingThemeIDs","defaultThemeId","newThemeIDs","id","includes","forEach","updatedThemes","Map","deleteTheme","deletedThemes","finalThemes","undeletedThemes","deleteThemeByName","deleteThemes"],"sources":["api/ThemeApi.ts"],"sourcesContent":["import { ThemeSkeleton, UiThemeRealmObject } from './ApiTypes';\nimport { getConfigEntity, putConfigEntity } from './IdmConfigApi';\nimport { getCurrentRealmName } from './utils/ApiUtils';\nimport { debug } from '../ops/utils/Console';\n\nexport const THEMEREALM_ID = 'ui/themerealm';\n\n/**\n * Get realm themes\n * @param {UiThemeRealmObject} themes object containing themes\n * @returns {ThemeSkeleton[]} array of theme pertaining to the current realm\n */\nfunction getRealmThemes(themes: UiThemeRealmObject): ThemeSkeleton[] {\n if (themes.realm && themes.realm[getCurrentRealmName()]) {\n return themes.realm[getCurrentRealmName()];\n }\n return [];\n}\n\n/**\n * Get all themes\n * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes\n */\nexport async function getThemes(): Promise<ThemeSkeleton[]> {\n const themes = await getConfigEntity(THEMEREALM_ID);\n return getRealmThemes(themes);\n}\n\n/**\n * Get theme by id\n * @param {string} themeId theme id\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function getTheme(themeId: string): Promise<ThemeSkeleton> {\n const themes = await getConfigEntity(THEMEREALM_ID);\n const found = getRealmThemes(themes).filter((theme) => theme._id === themeId);\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(`Multiple themes with id \"${themeId}\" found!`);\n }\n throw new Error(`Theme with id \"${themeId}\" not found!`);\n}\n\n/**\n * Get theme by name\n * @param {string} themeName theme name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function getThemeByName(\n themeName: string\n): Promise<ThemeSkeleton> {\n const themes = await getConfigEntity(THEMEREALM_ID);\n const found = getRealmThemes(themes).filter(\n (theme) => theme.name === themeName\n );\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(`Multiple themes with the name \"${themeName}\" found!`);\n }\n throw new Error(`Theme \"${themeName}\" not found!`);\n}\n\n/**\n * Put theme by id\n * @param {string} themeId theme id\n * @param {ThemeSkeleton} themeData theme object\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function putTheme(\n themeId: string,\n themeData: ThemeSkeleton\n): Promise<ThemeSkeleton> {\n const data = themeData;\n data._id = themeId;\n const themes = await getConfigEntity(THEMEREALM_ID);\n let isNew = true;\n const realmThemes = getRealmThemes(themes).map((theme) => {\n if (theme._id === themeId) {\n isNew = false;\n return data;\n }\n // eslint-disable-next-line no-param-reassign\n if (data.isDefault) theme.isDefault = false;\n return theme;\n });\n if (isNew) {\n realmThemes.push(data);\n }\n themes.realm[getCurrentRealmName()] = realmThemes;\n const found = getRealmThemes(\n await putConfigEntity(THEMEREALM_ID, themes)\n ).filter((theme) => theme._id === themeId);\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(`Multiple themes with id \"${themeId}\" found!`);\n }\n throw new Error(`Theme with id \"${themeId}\" not saved!`);\n}\n\n/**\n * Put theme by name\n * @param {String} themeName theme name\n * @param {ThemeSkeleton} themeData theme object\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function putThemeByName(\n themeName: string,\n themeData: ThemeSkeleton\n): Promise<ThemeSkeleton> {\n const data = themeData;\n data.name = themeName;\n const themes = await getConfigEntity(THEMEREALM_ID);\n let isNew = true;\n const realmThemes = getRealmThemes(themes).map((theme) => {\n if (theme.name === themeName) {\n isNew = false;\n return data;\n }\n // eslint-disable-next-line no-param-reassign\n if (data.isDefault) theme.isDefault = false;\n return theme;\n });\n if (isNew) {\n realmThemes.push(data);\n }\n themes['realm'][getCurrentRealmName()] = realmThemes;\n const found = getRealmThemes(\n await putConfigEntity(THEMEREALM_ID, themes)\n ).filter((theme) => theme.name === themeName);\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(`Multiple themes \"${themeName}\" found!`);\n }\n throw new Error(`Theme \"${themeName}\" not saved!`);\n}\n\n/**\n * Put all themes\n * @param {Map<string, ThemeSkeleton>} allThemesData themes object containing all themes for all realms\n * @returns {Promise<Map<string, ThemeSkeleton>>} a promise that resolves to a themes object\n */\nexport async function putThemes(\n themeMap: Map<string, ThemeSkeleton>\n): Promise<Map<string, ThemeSkeleton>> {\n debug(`ThemeApi.putThemes: start`);\n const themes = await getConfigEntity(THEMEREALM_ID);\n const allThemeIDs = Object.keys(themeMap);\n const existingThemeIDs = [];\n let defaultThemeId = null;\n // update existing themes\n let realmThemes = getRealmThemes(themes).map((theme) => {\n if (themeMap[theme._id]) {\n debug(`Update theme: ${theme._id} - ${theme.name}`);\n existingThemeIDs.push(theme._id);\n // remember the id of the last default theme\n if (themeMap[theme._id].isDefault) defaultThemeId = theme._id;\n return themeMap[theme._id];\n }\n return theme;\n });\n const newThemeIDs = allThemeIDs.filter(\n (id) => !existingThemeIDs.includes(id)\n );\n // add new themes\n newThemeIDs.forEach((themeId) => {\n debug(`Add theme: ${themeMap[themeId]._id} - ${themeMap[themeId].name}`);\n // remember the id of the last default theme\n if (themeMap[themeId].isDefault) defaultThemeId = themeId;\n realmThemes.push(themeMap[themeId]);\n });\n // if we imported a default theme, flag all the other themes as not default\n if (defaultThemeId) {\n realmThemes = realmThemes.map((theme) => {\n // eslint-disable-next-line no-param-reassign\n theme.isDefault = theme._id === defaultThemeId;\n return theme;\n });\n }\n themes.realm[getCurrentRealmName()] = realmThemes;\n const updatedThemes = new Map(\n getRealmThemes(await putConfigEntity(THEMEREALM_ID, themes)).map(\n (theme) => [theme._id, theme]\n )\n );\n debug(updatedThemes);\n debug(`ThemeApi.putThemes: finished`);\n return updatedThemes;\n}\n\n/**\n * Delete theme by id\n * @param {string} themeId theme id\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object\n */\nexport async function deleteTheme(themeId: string): Promise<ThemeSkeleton> {\n const themes = await getConfigEntity(THEMEREALM_ID);\n const realmThemes = getRealmThemes(themes);\n const deletedThemes: ThemeSkeleton[] = [];\n const finalThemes = realmThemes.filter((theme) => {\n if (theme._id !== themeId) {\n return true;\n }\n deletedThemes.push(theme);\n return false;\n });\n if (realmThemes.length === finalThemes.length)\n throw new Error(`${themeId} not found`);\n themes.realm[getCurrentRealmName()] = realmThemes;\n const undeletedThemes = getRealmThemes(\n await putConfigEntity(THEMEREALM_ID, themes)\n ).filter((theme) => deletedThemes.includes(theme));\n if (deletedThemes.length > 0 && undeletedThemes.length === 0) {\n return deletedThemes[0];\n }\n throw new Error(\n `Theme(s) with id(s) \"${undeletedThemes.map(\n (theme) => theme._id\n )}\" not deleted!`\n );\n}\n\n/**\n * Delete theme by name\n * @param {string} themeName theme name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object\n */\nexport async function deleteThemeByName(\n themeName: string\n): Promise<ThemeSkeleton> {\n const themes = await getConfigEntity(THEMEREALM_ID);\n const realmThemes = getRealmThemes(themes);\n const deletedThemes: ThemeSkeleton[] = [];\n const finalThemes = realmThemes.filter((theme) => {\n if (theme.name !== themeName) {\n return true;\n }\n deletedThemes.push(theme);\n return false;\n });\n if (realmThemes.length === finalThemes.length)\n throw new Error(`${themeName} not found`);\n themes.realm[getCurrentRealmName()] = finalThemes;\n // return putConfigEntity(THEMEREALM_ID, themes);\n const undeletedThemes = getRealmThemes(\n await putConfigEntity(THEMEREALM_ID, themes)\n ).filter((theme) => deletedThemes.includes(theme));\n if (deletedThemes.length > 0 && undeletedThemes.length === 0) {\n return deletedThemes[0];\n }\n throw new Error(\n `Theme(s) with id(s) \"${undeletedThemes.map(\n (theme) => theme._id\n )}\" not deleted!`\n );\n}\n\n/**\n * Delete all themes\n * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes\n */\nexport async function deleteThemes(): Promise<ThemeSkeleton[]> {\n const themes = await getConfigEntity(THEMEREALM_ID);\n const realmThemes = themes.realm[getCurrentRealmName()];\n if (!realmThemes)\n throw new Error(\n `No theme configuration found for realm \"${getCurrentRealmName()}\"`\n );\n const deletedThemes: ThemeSkeleton[] = [];\n for (const theme of realmThemes) {\n deletedThemes.push(theme);\n }\n themes.realm[getCurrentRealmName()] = [];\n await putConfigEntity(THEMEREALM_ID, themes);\n return deletedThemes;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;;;;;AAEO,IAAMA,aAAa,GAAG,eAAtB;AAEP;AACA;AACA;AACA;AACA;;;;AACA,SAASC,cAAT,CAAwBC,MAAxB,EAAqE;EACnE,IAAIA,MAAM,CAACC,KAAP,IAAgBD,MAAM,CAACC,KAAP,CAAa,IAAAC,6BAAA,GAAb,CAApB,EAAyD;IACvD,OAAOF,MAAM,CAACC,KAAP,CAAa,IAAAC,6BAAA,GAAb,CAAP;EACD;;EACD,OAAO,EAAP;AACD;AAED;AACA;AACA;AACA;;;SACsBC,S;;;AAKtB;AACA;AACA;AACA;AACA;;;;iCATO,aAAqD;IAC1D,IAAMH,MAAM,SAAS,IAAAI,6BAAA,EAAgBN,aAAhB,CAArB;IACA,OAAOC,cAAc,CAACC,MAAD,CAArB;EACD,C;;;;SAOqBK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