@rockcarver/frodo-lib 0.12.0 → 0.12.2-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 (223) hide show
  1. package/CHANGELOG.md +22 -2
  2. package/cjs/api/AuthenticateApi.js +44 -14
  3. package/cjs/api/AuthenticateApi.js.map +1 -1
  4. package/cjs/api/BaseApi.js +171 -90
  5. package/cjs/api/BaseApi.js.map +1 -1
  6. package/cjs/api/CirclesOfTrustApi.js +87 -31
  7. package/cjs/api/CirclesOfTrustApi.js.map +1 -1
  8. package/cjs/api/EmailTemplateApi.js +48 -9
  9. package/cjs/api/EmailTemplateApi.js.map +1 -1
  10. package/cjs/api/IdmConfigApi.js +91 -25
  11. package/cjs/api/IdmConfigApi.js.map +1 -1
  12. package/cjs/api/LogApi.js +84 -29
  13. package/cjs/api/LogApi.js.map +1 -1
  14. package/cjs/api/ManagedObjectApi.js +66 -19
  15. package/cjs/api/ManagedObjectApi.js.map +1 -1
  16. package/cjs/api/NodeApi.js +190 -0
  17. package/cjs/api/NodeApi.js.map +1 -0
  18. package/cjs/api/NodeApi.test.js.map +1 -0
  19. package/cjs/api/OAuth2ClientApi.js +73 -27
  20. package/cjs/api/OAuth2ClientApi.js.map +1 -1
  21. package/cjs/api/OAuth2OIDCApi.js +82 -31
  22. package/cjs/api/OAuth2OIDCApi.js.map +1 -1
  23. package/cjs/api/OAuth2ProviderApi.js +39 -14
  24. package/cjs/api/OAuth2ProviderApi.js.map +1 -1
  25. package/cjs/api/RealmApi.js +100 -36
  26. package/cjs/api/RealmApi.js.map +1 -1
  27. package/cjs/api/Saml2Api.js +162 -74
  28. package/cjs/api/Saml2Api.js.map +1 -1
  29. package/cjs/api/ScriptApi.js +84 -29
  30. package/cjs/api/ScriptApi.js.map +1 -1
  31. package/cjs/api/SecretsApi.js +188 -69
  32. package/cjs/api/SecretsApi.js.map +1 -1
  33. package/cjs/api/ServerInfoApi.js +48 -14
  34. package/cjs/api/ServerInfoApi.js.map +1 -1
  35. package/cjs/api/SocialIdentityProvidersApi.js +103 -37
  36. package/cjs/api/SocialIdentityProvidersApi.js.map +1 -1
  37. package/cjs/api/StartupApi.js +74 -26
  38. package/cjs/api/StartupApi.js.map +1 -1
  39. package/cjs/api/StartupApi.test.js.map +1 -0
  40. package/cjs/api/ThemeApi.js +188 -96
  41. package/cjs/api/ThemeApi.js.map +1 -1
  42. package/cjs/api/TreeApi.js +96 -113
  43. package/cjs/api/TreeApi.js.map +1 -1
  44. package/cjs/api/TreeApi.test.js.map +1 -0
  45. package/cjs/api/VariablesApi.js +106 -39
  46. package/cjs/api/VariablesApi.js.map +1 -1
  47. package/cjs/api/utils/ApiUtils.js +41 -21
  48. package/cjs/api/utils/ApiUtils.js.map +1 -1
  49. package/cjs/api/utils/ApiUtils.test.js.map +1 -1
  50. package/cjs/api/utils/Base64.js +35 -10
  51. package/cjs/api/utils/Base64.js.map +1 -1
  52. package/cjs/index.js +126 -41
  53. package/cjs/index.js.map +1 -1
  54. package/cjs/index.test.js.map +1 -1
  55. package/cjs/ops/AdminOps.js +649 -480
  56. package/cjs/ops/AdminOps.js.map +1 -1
  57. package/cjs/ops/AuthenticateOps.js +302 -211
  58. package/cjs/ops/AuthenticateOps.js.map +1 -1
  59. package/cjs/ops/AuthenticateOps.test.js.map +1 -1
  60. package/cjs/ops/CirclesOfTrustOps.js +356 -219
  61. package/cjs/ops/CirclesOfTrustOps.js.map +1 -1
  62. package/cjs/ops/ConnectionProfileOps.js +200 -122
  63. package/cjs/ops/ConnectionProfileOps.js.map +1 -1
  64. package/cjs/ops/ConnectionProfileOps.test.js.map +1 -1
  65. package/cjs/ops/EmailTemplateOps.js +301 -192
  66. package/cjs/ops/EmailTemplateOps.js.map +1 -1
  67. package/cjs/ops/IdmOps.js +190 -121
  68. package/cjs/ops/IdmOps.js.map +1 -1
  69. package/cjs/ops/IdpOps.js +327 -196
  70. package/cjs/ops/IdpOps.js.map +1 -1
  71. package/cjs/ops/JourneyOps.js +1402 -1131
  72. package/cjs/ops/JourneyOps.js.map +1 -1
  73. package/cjs/ops/LogOps.js +125 -75
  74. package/cjs/ops/LogOps.js.map +1 -1
  75. package/cjs/ops/ManagedObjectOps.js +43 -16
  76. package/cjs/ops/ManagedObjectOps.js.map +1 -1
  77. package/cjs/ops/OAuth2ClientOps.js +155 -87
  78. package/cjs/ops/OAuth2ClientOps.js.map +1 -1
  79. package/cjs/ops/OrganizationOps.js +89 -56
  80. package/cjs/ops/OrganizationOps.js.map +1 -1
  81. package/cjs/ops/RealmOps.js +131 -83
  82. package/cjs/ops/RealmOps.js.map +1 -1
  83. package/cjs/ops/SamlOps.js +497 -331
  84. package/cjs/ops/SamlOps.js.map +1 -1
  85. package/cjs/ops/ScriptOps.js +215 -133
  86. package/cjs/ops/ScriptOps.js.map +1 -1
  87. package/cjs/ops/SecretsOps.js +269 -156
  88. package/cjs/ops/SecretsOps.js.map +1 -1
  89. package/cjs/ops/StartupOps.js +100 -75
  90. package/cjs/ops/StartupOps.js.map +1 -1
  91. package/cjs/ops/ThemeOps.js +373 -221
  92. package/cjs/ops/ThemeOps.js.map +1 -1
  93. package/cjs/ops/VariablesOps.js +168 -90
  94. package/cjs/ops/VariablesOps.js.map +1 -1
  95. package/cjs/ops/utils/Console.js +68 -33
  96. package/cjs/ops/utils/Console.js.map +1 -1
  97. package/cjs/ops/utils/DataProtection.js +100 -64
  98. package/cjs/ops/utils/DataProtection.js.map +1 -1
  99. package/cjs/ops/utils/DataProtection.test.js.map +1 -1
  100. package/cjs/ops/utils/ExportImportUtils.js +86 -47
  101. package/cjs/ops/utils/ExportImportUtils.js.map +1 -1
  102. package/cjs/ops/utils/ExportImportUtils.test.js.map +1 -1
  103. package/cjs/ops/utils/OpsUtils.js +47 -20
  104. package/cjs/ops/utils/OpsUtils.js.map +1 -1
  105. package/cjs/ops/utils/Wordwrap.js +10 -2
  106. package/cjs/ops/utils/Wordwrap.js.map +1 -1
  107. package/cjs/storage/SessionStorage.js +20 -8
  108. package/cjs/storage/SessionStorage.js.map +1 -1
  109. package/cjs/storage/StaticStorage.js +26 -10
  110. package/cjs/storage/StaticStorage.js.map +1 -1
  111. package/esm/api/BaseApi.mjs +35 -7
  112. package/esm/api/NodeApi.mjs +114 -0
  113. package/esm/api/NodeApi.test.mjs +105 -0
  114. package/esm/api/StartupApi.mjs +18 -8
  115. package/esm/api/StartupApi.test.mjs +56 -0
  116. package/esm/api/TreeApi.mjs +27 -99
  117. package/esm/api/TreeApi.test.mjs +175 -0
  118. package/esm/index.mjs +7 -5
  119. package/esm/ops/IdpOps.mjs +1 -1
  120. package/esm/ops/JourneyOps.mjs +165 -154
  121. package/esm/ops/StartupOps.mjs +59 -62
  122. package/esm/ops/utils/Console.mjs +3 -2
  123. package/package.json +7 -4
  124. package/types/api/AuthenticateApi.d.ts +2 -0
  125. package/types/api/AuthenticateApi.d.ts.map +1 -0
  126. package/types/api/BaseApi.d.ts +50 -0
  127. package/types/api/BaseApi.d.ts.map +1 -0
  128. package/types/api/CirclesOfTrustApi.d.ts +24 -0
  129. package/types/api/CirclesOfTrustApi.d.ts.map +1 -0
  130. package/types/api/EmailTemplateApi.d.ts +22 -0
  131. package/types/api/EmailTemplateApi.d.ts.map +1 -0
  132. package/types/api/IdmConfigApi.d.ts +39 -0
  133. package/types/api/IdmConfigApi.d.ts.map +1 -0
  134. package/types/api/LogApi.d.ts +4 -0
  135. package/types/api/LogApi.d.ts.map +1 -0
  136. package/types/api/ManagedObjectApi.d.ts +21 -0
  137. package/types/api/ManagedObjectApi.d.ts.map +1 -0
  138. package/types/api/NodeApi.d.ts +38 -0
  139. package/types/api/NodeApi.d.ts.map +1 -0
  140. package/types/api/OAuth2ClientApi.d.ts +18 -0
  141. package/types/api/OAuth2ClientApi.d.ts.map +1 -0
  142. package/types/api/OAuth2OIDCApi.d.ts +22 -0
  143. package/types/api/OAuth2OIDCApi.d.ts.map +1 -0
  144. package/types/api/OAuth2ProviderApi.d.ts +5 -0
  145. package/types/api/OAuth2ProviderApi.d.ts.map +1 -0
  146. package/types/api/RealmApi.d.ts +30 -0
  147. package/types/api/RealmApi.d.ts.map +1 -0
  148. package/types/api/Saml2Api.d.ts +52 -0
  149. package/types/api/Saml2Api.d.ts.map +1 -0
  150. package/types/api/ScriptApi.d.ts +24 -0
  151. package/types/api/ScriptApi.d.ts.map +1 -0
  152. package/types/api/SecretsApi.d.ts +10 -0
  153. package/types/api/SecretsApi.d.ts.map +1 -0
  154. package/types/api/ServerInfoApi.d.ts +10 -0
  155. package/types/api/ServerInfoApi.d.ts.map +1 -0
  156. package/types/api/SocialIdentityProvidersApi.d.ts +31 -0
  157. package/types/api/SocialIdentityProvidersApi.d.ts.map +1 -0
  158. package/types/api/StartupApi.d.ts +14 -0
  159. package/types/api/StartupApi.d.ts.map +1 -0
  160. package/types/api/ThemeApi.d.ts +54 -0
  161. package/types/api/ThemeApi.d.ts.map +1 -0
  162. package/types/api/TreeApi.d.ts +24 -0
  163. package/types/api/TreeApi.d.ts.map +1 -0
  164. package/types/api/VariablesApi.d.ts +32 -0
  165. package/types/api/VariablesApi.d.ts.map +1 -0
  166. package/types/api/utils/ApiUtils.d.ts +29 -0
  167. package/types/api/utils/ApiUtils.d.ts.map +1 -0
  168. package/types/api/utils/Base64.d.ts +30 -0
  169. package/types/api/utils/Base64.d.ts.map +1 -0
  170. package/types/index.d.ts +26 -0
  171. package/types/index.d.ts.map +1 -0
  172. package/types/ops/AdminOps.d.ts +11 -0
  173. package/types/ops/AdminOps.d.ts.map +1 -0
  174. package/types/ops/AuthenticateOps.d.ts +6 -0
  175. package/types/ops/AuthenticateOps.d.ts.map +1 -0
  176. package/types/ops/CirclesOfTrustOps.d.ts +40 -0
  177. package/types/ops/CirclesOfTrustOps.d.ts.map +1 -0
  178. package/types/ops/ConnectionProfileOps.d.ts +47 -0
  179. package/types/ops/ConnectionProfileOps.d.ts.map +1 -0
  180. package/types/ops/EmailTemplateOps.d.ts +40 -0
  181. package/types/ops/EmailTemplateOps.d.ts.map +1 -0
  182. package/types/ops/IdmOps.d.ts +27 -0
  183. package/types/ops/IdmOps.d.ts.map +1 -0
  184. package/types/ops/IdpOps.d.ts +45 -0
  185. package/types/ops/IdpOps.d.ts.map +1 -0
  186. package/types/ops/JourneyOps.d.ts +145 -0
  187. package/types/ops/JourneyOps.d.ts.map +1 -0
  188. package/types/ops/LogOps.d.ts +5 -0
  189. package/types/ops/LogOps.d.ts.map +1 -0
  190. package/types/ops/ManagedObjectOps.d.ts +14 -0
  191. package/types/ops/ManagedObjectOps.d.ts.map +1 -0
  192. package/types/ops/OAuth2ClientOps.d.ts +24 -0
  193. package/types/ops/OAuth2ClientOps.d.ts.map +1 -0
  194. package/types/ops/OrganizationOps.d.ts +11 -0
  195. package/types/ops/OrganizationOps.d.ts.map +1 -0
  196. package/types/ops/RealmOps.d.ts +22 -0
  197. package/types/ops/RealmOps.d.ts.map +1 -0
  198. package/types/ops/SamlOps.d.ts +51 -0
  199. package/types/ops/SamlOps.d.ts.map +1 -0
  200. package/types/ops/ScriptOps.d.ts +30 -0
  201. package/types/ops/ScriptOps.d.ts.map +1 -0
  202. package/types/ops/SecretsOps.d.ts +63 -0
  203. package/types/ops/SecretsOps.d.ts.map +1 -0
  204. package/types/ops/StartupOps.d.ts +25 -0
  205. package/types/ops/StartupOps.d.ts.map +1 -0
  206. package/types/ops/ThemeOps.d.ts +66 -0
  207. package/types/ops/ThemeOps.d.ts.map +1 -0
  208. package/types/ops/VariablesOps.d.ts +39 -0
  209. package/types/ops/VariablesOps.d.ts.map +1 -0
  210. package/types/ops/utils/Console.d.ts +63 -0
  211. package/types/ops/utils/Console.d.ts.map +1 -0
  212. package/types/ops/utils/DataProtection.d.ts +6 -0
  213. package/types/ops/utils/DataProtection.d.ts.map +1 -0
  214. package/types/ops/utils/ExportImportUtils.d.ts +22 -0
  215. package/types/ops/utils/ExportImportUtils.d.ts.map +1 -0
  216. package/types/ops/utils/OpsUtils.d.ts +27 -0
  217. package/types/ops/utils/OpsUtils.d.ts.map +1 -0
  218. package/types/ops/utils/Wordwrap.d.ts +1 -0
  219. package/types/ops/utils/Wordwrap.d.ts.map +1 -0
  220. package/types/storage/SessionStorage.d.ts +47 -0
  221. package/types/storage/SessionStorage.d.ts.map +1 -0
  222. package/types/storage/StaticStorage.d.ts +14 -0
  223. package/types/storage/StaticStorage.d.ts.map +1 -0
@@ -1,27 +1,42 @@
1
- import fs from 'fs';
2
- import { deleteTheme, deleteThemeByName, deleteThemes, getTheme, getThemeByName, getThemes, putTheme, putThemeByName, putThemes } from '../api/ThemeApi';
3
- import { createProgressIndicator, createTable, printMessage, stopProgressIndicator, updateProgressIndicator } from './utils/Console';
4
- import { getRealmString, getTypedFilename, saveToFile, validateImport } from './utils/ExportImportUtils';
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.deleteThemeByNameCmd = deleteThemeByNameCmd;
7
+ exports.deleteThemeCmd = deleteThemeCmd;
8
+ exports.deleteThemesCmd = deleteThemesCmd;
9
+ exports.exportThemeById = exportThemeById;
10
+ exports.exportThemeByName = exportThemeByName;
11
+ exports.exportThemesToFile = exportThemesToFile;
12
+ exports.exportThemesToFiles = exportThemesToFiles;
13
+ exports.importFirstThemeFromFile = importFirstThemeFromFile;
14
+ exports.importThemeById = importThemeById;
15
+ exports.importThemeByName = importThemeByName;
16
+ exports.importThemesFromFile = importThemesFromFile;
17
+ exports.importThemesFromFiles = importThemesFromFiles;
18
+ exports.listThemes = listThemes;
19
+
20
+ var _fs = _interopRequireDefault(require("fs"));
21
+
22
+ var _ThemeApi = require("../api/ThemeApi");
23
+
24
+ var _Console = require("./utils/Console");
25
+
26
+ var _ExportImportUtils = require("./utils/ExportImportUtils");
27
+
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+
30
+ 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); } }
31
+
32
+ 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); }); }; }
33
+
5
34
  /**
6
35
  * List all the themes
7
36
  * @param {boolean} long Long version, more fields
8
37
  */
9
-
10
- export async function listThemes(long = false) {
11
- const themeList = await getThemes();
12
- themeList.sort((a, b) => a.name.localeCompare(b.name));
13
-
14
- if (!long) {
15
- themeList.forEach(theme => {
16
- printMessage(`${theme.isDefault ? theme.name.brightCyan : theme.name}`, 'data');
17
- });
18
- } else {
19
- const table = createTable(['Name'['brightCyan'], 'Id'['brightCyan'], 'Default'['brightCyan']]);
20
- themeList.forEach(theme => {
21
- table.push([`${theme.name}`, `${theme._id}`, `${theme.isDefault ? 'Yes'['brightGreen'] : ''}`]);
22
- });
23
- printMessage(table.toString(), 'data');
24
- }
38
+ function listThemes() {
39
+ return _listThemes.apply(this, arguments);
25
40
  }
26
41
  /**
27
42
  * Export theme by name to file
@@ -29,24 +44,30 @@ export async function listThemes(long = false) {
29
44
  * @param {String} file optional export file name
30
45
  */
31
46
 
32
- export async function exportThemeByName(name, file) {
33
- let fileName = getTypedFilename(name, 'theme');
34
47
 
35
- if (file) {
36
- fileName = file;
37
- }
48
+ function _listThemes() {
49
+ _listThemes = _asyncToGenerator(function* () {
50
+ var long = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
51
+ var themeList = yield (0, _ThemeApi.getThemes)();
52
+ themeList.sort((a, b) => a.name.localeCompare(b.name));
38
53
 
39
- createProgressIndicator(1, `Exporting ${name}`);
40
- const themeData = await getThemeByName(name);
54
+ if (!long) {
55
+ themeList.forEach(theme => {
56
+ (0, _Console.printMessage)("".concat(theme.isDefault ? theme.name.brightCyan : theme.name), 'data');
57
+ });
58
+ } else {
59
+ var table = (0, _Console.createTable)(['Name'['brightCyan'], 'Id'['brightCyan'], 'Default'['brightCyan']]);
60
+ themeList.forEach(theme => {
61
+ table.push(["".concat(theme.name), "".concat(theme._id), "".concat(theme.isDefault ? 'Yes'['brightGreen'] : '')]);
62
+ });
63
+ (0, _Console.printMessage)(table.toString(), 'data');
64
+ }
65
+ });
66
+ return _listThemes.apply(this, arguments);
67
+ }
41
68
 
42
- if (themeData.length === 0) {
43
- stopProgressIndicator(`Theme ${name} not found!`);
44
- printMessage(`Theme ${name} not found!`, 'error');
45
- } else {
46
- updateProgressIndicator(`Writing file ${fileName}`);
47
- saveToFile('theme', themeData, '_id', fileName);
48
- stopProgressIndicator(`Successfully exported theme ${name}.`);
49
- }
69
+ function exportThemeByName(_x, _x2) {
70
+ return _exportThemeByName.apply(this, arguments);
50
71
  }
51
72
  /**
52
73
  * Export theme by uuid to file
@@ -54,62 +75,93 @@ export async function exportThemeByName(name, file) {
54
75
  * @param {String} file optional export file name
55
76
  */
56
77
 
57
- export async function exportThemeById(id, file) {
58
- let fileName = getTypedFilename(id, 'theme');
59
78
 
60
- if (file) {
61
- fileName = file;
62
- }
79
+ function _exportThemeByName() {
80
+ _exportThemeByName = _asyncToGenerator(function* (name, file) {
81
+ var fileName = (0, _ExportImportUtils.getTypedFilename)(name, 'theme');
82
+
83
+ if (file) {
84
+ fileName = file;
85
+ }
63
86
 
64
- createProgressIndicator(1, `Exporting ${id}`);
65
- const themeData = await getTheme(id);
87
+ (0, _Console.createProgressIndicator)(1, "Exporting ".concat(name));
88
+ var themeData = yield (0, _ThemeApi.getThemeByName)(name);
66
89
 
67
- if (themeData.length === 0) {
68
- stopProgressIndicator(`Theme ${id} not found!`);
69
- printMessage(`Theme ${id} not found!`, 'error');
70
- } else {
71
- updateProgressIndicator(`Writing file ${fileName}`);
72
- saveToFile('theme', themeData, '_id', fileName);
73
- stopProgressIndicator(`Successfully exported theme ${id}.`);
74
- }
90
+ if (themeData.length === 0) {
91
+ (0, _Console.stopProgressIndicator)("Theme ".concat(name, " not found!"));
92
+ (0, _Console.printMessage)("Theme ".concat(name, " not found!"), 'error');
93
+ } else {
94
+ (0, _Console.updateProgressIndicator)("Writing file ".concat(fileName));
95
+ (0, _ExportImportUtils.saveToFile)('theme', themeData, '_id', fileName);
96
+ (0, _Console.stopProgressIndicator)("Successfully exported theme ".concat(name, "."));
97
+ }
98
+ });
99
+ return _exportThemeByName.apply(this, arguments);
100
+ }
101
+
102
+ function exportThemeById(_x3, _x4) {
103
+ return _exportThemeById.apply(this, arguments);
75
104
  }
76
105
  /**
77
106
  * Export all themes to file
78
107
  * @param {String} file optional export file name
79
108
  */
80
109
 
81
- export async function exportThemesToFile(file) {
82
- let fileName = getTypedFilename(`all${getRealmString()}Themes`, 'theme');
83
110
 
84
- if (file) {
85
- fileName = file;
86
- }
111
+ function _exportThemeById() {
112
+ _exportThemeById = _asyncToGenerator(function* (id, file) {
113
+ var fileName = (0, _ExportImportUtils.getTypedFilename)(id, 'theme');
87
114
 
88
- const allThemesData = await getThemes();
89
- createProgressIndicator(allThemesData.length, 'Exporting themes');
115
+ if (file) {
116
+ fileName = file;
117
+ }
90
118
 
91
- for (const themeData of allThemesData) {
92
- updateProgressIndicator(`Exporting theme ${themeData.name}`);
93
- }
119
+ (0, _Console.createProgressIndicator)(1, "Exporting ".concat(id));
120
+ var themeData = yield (0, _ThemeApi.getTheme)(id);
94
121
 
95
- saveToFile('theme', allThemesData, '_id', fileName);
96
- stopProgressIndicator(`${allThemesData.length} themes exported to ${fileName}.`);
122
+ if (themeData.length === 0) {
123
+ (0, _Console.stopProgressIndicator)("Theme ".concat(id, " not found!"));
124
+ (0, _Console.printMessage)("Theme ".concat(id, " not found!"), 'error');
125
+ } else {
126
+ (0, _Console.updateProgressIndicator)("Writing file ".concat(fileName));
127
+ (0, _ExportImportUtils.saveToFile)('theme', themeData, '_id', fileName);
128
+ (0, _Console.stopProgressIndicator)("Successfully exported theme ".concat(id, "."));
129
+ }
130
+ });
131
+ return _exportThemeById.apply(this, arguments);
132
+ }
133
+
134
+ function exportThemesToFile(_x5) {
135
+ return _exportThemesToFile.apply(this, arguments);
97
136
  }
98
137
  /**
99
138
  * Export all themes to separate files
100
139
  */
101
140
 
102
- export async function exportThemesToFiles() {
103
- const allThemesData = await getThemes();
104
- createProgressIndicator(allThemesData.length, 'Exporting themes');
105
141
 
106
- for (const themeData of allThemesData) {
107
- updateProgressIndicator(`Writing theme ${themeData.name}`);
108
- const fileName = getTypedFilename(themeData.name, 'theme');
109
- saveToFile('theme', themeData, '_id', fileName);
110
- }
142
+ function _exportThemesToFile() {
143
+ _exportThemesToFile = _asyncToGenerator(function* (file) {
144
+ var fileName = (0, _ExportImportUtils.getTypedFilename)("all".concat((0, _ExportImportUtils.getRealmString)(), "Themes"), 'theme');
145
+
146
+ if (file) {
147
+ fileName = file;
148
+ }
149
+
150
+ var allThemesData = yield (0, _ThemeApi.getThemes)();
151
+ (0, _Console.createProgressIndicator)(allThemesData.length, 'Exporting themes');
111
152
 
112
- stopProgressIndicator(`${allThemesData.length} themes exported.`);
153
+ for (var themeData of allThemesData) {
154
+ (0, _Console.updateProgressIndicator)("Exporting theme ".concat(themeData.name));
155
+ }
156
+
157
+ (0, _ExportImportUtils.saveToFile)('theme', allThemesData, '_id', fileName);
158
+ (0, _Console.stopProgressIndicator)("".concat(allThemesData.length, " themes exported to ").concat(fileName, "."));
159
+ });
160
+ return _exportThemesToFile.apply(this, arguments);
161
+ }
162
+
163
+ function exportThemesToFiles() {
164
+ return _exportThemesToFiles.apply(this, arguments);
113
165
  }
114
166
  /**
115
167
  * Import theme by name from file
@@ -117,40 +169,25 @@ export async function exportThemesToFiles() {
117
169
  * @param {String} file import file name
118
170
  */
119
171
 
120
- export async function importThemeByName(name, file) {
121
- fs.readFile(file, 'utf8', (err, data) => {
122
- if (err) throw err;
123
- const themeData = JSON.parse(data);
124
-
125
- if (validateImport(themeData.meta)) {
126
- createProgressIndicator(1, 'Importing theme...');
127
- let found = false;
128
-
129
- for (const id in themeData.theme) {
130
- if ({}.hasOwnProperty.call(themeData.theme, id)) {
131
- if (themeData.theme[id].name === name) {
132
- found = true;
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
- });
142
- break;
143
- }
144
- }
145
- }
146
172
 
147
- if (!found) {
148
- stopProgressIndicator(`Theme ${name} not found!`);
149
- }
150
- } else {
151
- printMessage('Import validation failed...', 'error');
173
+ function _exportThemesToFiles() {
174
+ _exportThemesToFiles = _asyncToGenerator(function* () {
175
+ var allThemesData = yield (0, _ThemeApi.getThemes)();
176
+ (0, _Console.createProgressIndicator)(allThemesData.length, 'Exporting themes');
177
+
178
+ for (var themeData of allThemesData) {
179
+ (0, _Console.updateProgressIndicator)("Writing theme ".concat(themeData.name));
180
+ var fileName = (0, _ExportImportUtils.getTypedFilename)(themeData.name, 'theme');
181
+ (0, _ExportImportUtils.saveToFile)('theme', themeData, '_id', fileName);
152
182
  }
183
+
184
+ (0, _Console.stopProgressIndicator)("".concat(allThemesData.length, " themes exported."));
153
185
  });
186
+ return _exportThemesToFiles.apply(this, arguments);
187
+ }
188
+
189
+ function importThemeByName(_x6, _x7) {
190
+ return _importThemeByName.apply(this, arguments);
154
191
  }
155
192
  /**
156
193
  * Import theme by uuid from file
@@ -158,183 +195,298 @@ export async function importThemeByName(name, file) {
158
195
  * @param {String} file import file name
159
196
  */
160
197
 
161
- export async function importThemeById(id, file) {
162
- fs.readFile(file, 'utf8', (err, data) => {
163
- if (err) throw err;
164
- const themeData = JSON.parse(data);
165
-
166
- if (validateImport(themeData.meta)) {
167
- createProgressIndicator(1, 'Importing theme...');
168
- let found = false;
169
-
170
- for (const themeId in themeData.theme) {
171
- if ({}.hasOwnProperty.call(themeData.theme, themeId)) {
172
- if (themeId === id) {
173
- found = true;
174
- 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
- });
183
- break;
198
+
199
+ function _importThemeByName() {
200
+ _importThemeByName = _asyncToGenerator(function* (name, file) {
201
+ _fs.default.readFile(file, 'utf8', (err, data) => {
202
+ if (err) throw err;
203
+ var themeData = JSON.parse(data);
204
+
205
+ if ((0, _ExportImportUtils.validateImport)(themeData.meta)) {
206
+ (0, _Console.createProgressIndicator)(1, 'Importing theme...');
207
+ var found = false;
208
+
209
+ var _loop = function _loop(id) {
210
+ if ({}.hasOwnProperty.call(themeData.theme, id)) {
211
+ if (themeData.theme[id].name === name) {
212
+ found = true;
213
+ (0, _Console.updateProgressIndicator)("Importing ".concat(themeData.theme[id].name));
214
+ (0, _ThemeApi.putThemeByName)(name, themeData.theme[id]).then(result => {
215
+ if (result == null) {
216
+ (0, _Console.stopProgressIndicator)("Error importing theme ".concat(themeData.theme[id].name));
217
+ (0, _Console.printMessage)("Error importing theme ".concat(themeData.theme[id].name), 'error');
218
+ } else {
219
+ (0, _Console.stopProgressIndicator)("Successfully imported theme ".concat(name, "."));
220
+ }
221
+ });
222
+ return "break";
223
+ }
184
224
  }
225
+ };
226
+
227
+ for (var id in themeData.theme) {
228
+ var _ret = _loop(id);
229
+
230
+ if (_ret === "break") break;
185
231
  }
186
- }
187
232
 
188
- if (!found) {
189
- stopProgressIndicator(`Theme ${id} not found!`);
233
+ if (!found) {
234
+ (0, _Console.stopProgressIndicator)("Theme ".concat(name, " not found!"));
235
+ }
236
+ } else {
237
+ (0, _Console.printMessage)('Import validation failed...', 'error');
190
238
  }
191
- } else {
192
- printMessage('Import validation failed...', 'error');
193
- }
239
+ });
194
240
  });
241
+ return _importThemeByName.apply(this, arguments);
242
+ }
243
+
244
+ function importThemeById(_x8, _x9) {
245
+ return _importThemeById.apply(this, arguments);
195
246
  }
196
247
  /**
197
248
  * Import all themes from single file
198
249
  * @param {String} file import file name
199
250
  */
200
251
 
201
- export async function importThemesFromFile(file) {
202
- fs.readFile(file, 'utf8', (err, data) => {
203
- if (err) throw err;
204
- const fileData = JSON.parse(data);
205
252
 
206
- if (validateImport(fileData.meta)) {
207
- createProgressIndicator(Object.keys(fileData.theme).length, 'Importing themes...');
253
+ function _importThemeById() {
254
+ _importThemeById = _asyncToGenerator(function* (id, file) {
255
+ _fs.default.readFile(file, 'utf8', (err, data) => {
256
+ if (err) throw err;
257
+ var themeData = JSON.parse(data);
258
+
259
+ if ((0, _ExportImportUtils.validateImport)(themeData.meta)) {
260
+ (0, _Console.createProgressIndicator)(1, 'Importing theme...');
261
+ var found = false;
262
+
263
+ var _loop2 = function _loop2(themeId) {
264
+ if ({}.hasOwnProperty.call(themeData.theme, themeId)) {
265
+ if (themeId === id) {
266
+ found = true;
267
+ (0, _Console.updateProgressIndicator)("Importing ".concat(themeData.theme[themeId]._id));
268
+ (0, _ThemeApi.putTheme)(themeId, themeData.theme[themeId]).then(result => {
269
+ if (result == null) {
270
+ (0, _Console.stopProgressIndicator)("Error importing theme ".concat(themeData.theme[themeId]._id));
271
+ (0, _Console.printMessage)("Error importing theme ".concat(themeData.theme[themeId]._id), 'error');
272
+ } else {
273
+ (0, _Console.stopProgressIndicator)("Successfully imported theme ".concat(id, "."));
274
+ }
275
+ });
276
+ return "break";
277
+ }
278
+ }
279
+ };
280
+
281
+ for (var themeId in themeData.theme) {
282
+ var _ret2 = _loop2(themeId);
208
283
 
209
- for (const id in fileData.theme) {
210
- if ({}.hasOwnProperty.call(fileData.theme, id)) {
211
- updateProgressIndicator(`Importing ${fileData.theme[id].name}`);
284
+ if (_ret2 === "break") break;
212
285
  }
213
- }
214
286
 
215
- putThemes(fileData.theme).then(result => {
216
- if (result == null) {
217
- stopProgressIndicator(`Error importing ${Object.keys(fileData.theme).length} themes!`);
218
- printMessage(`Error importing ${Object.keys(fileData.theme).length} themes from ${file}`, 'error');
219
- } else {
220
- stopProgressIndicator(`Successfully imported ${Object.keys(fileData.theme).length} themes.`);
287
+ if (!found) {
288
+ (0, _Console.stopProgressIndicator)("Theme ".concat(id, " not found!"));
221
289
  }
222
- });
223
- } else {
224
- printMessage('Import validation failed...', 'error');
225
- }
290
+ } else {
291
+ (0, _Console.printMessage)('Import validation failed...', 'error');
292
+ }
293
+ });
226
294
  });
295
+ return _importThemeById.apply(this, arguments);
296
+ }
297
+
298
+ function importThemesFromFile(_x10) {
299
+ return _importThemesFromFile.apply(this, arguments);
227
300
  }
228
301
  /**
229
302
  * Import themes from separate files
230
303
  */
231
304
 
232
- export async function importThemesFromFiles() {
233
- const names = fs.readdirSync('.');
234
- const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.theme.json'));
235
- createProgressIndicator(jsonFiles.length, 'Importing themes...');
236
- let fileData = null;
237
- let count = 0;
238
- let total = 0;
239
- let files = 0;
240
305
 
241
- for (const file of jsonFiles) {
242
- const data = fs.readFileSync(file, 'utf8');
243
- fileData = JSON.parse(data);
306
+ function _importThemesFromFile() {
307
+ _importThemesFromFile = _asyncToGenerator(function* (file) {
308
+ _fs.default.readFile(file, 'utf8', (err, data) => {
309
+ if (err) throw err;
310
+ var fileData = JSON.parse(data);
244
311
 
245
- if (validateImport(fileData.meta)) {
246
- count = Object.keys(fileData.theme).length; // eslint-disable-next-line no-await-in-loop
312
+ if ((0, _ExportImportUtils.validateImport)(fileData.meta)) {
313
+ (0, _Console.createProgressIndicator)(Object.keys(fileData.theme).length, 'Importing themes...');
247
314
 
248
- const result = await putThemes(fileData.theme);
315
+ for (var id in fileData.theme) {
316
+ if ({}.hasOwnProperty.call(fileData.theme, id)) {
317
+ (0, _Console.updateProgressIndicator)("Importing ".concat(fileData.theme[id].name));
318
+ }
319
+ }
249
320
 
250
- if (result == null) {
251
- printMessage(`Error importing ${count} themes from ${file}`, 'error');
321
+ (0, _ThemeApi.putThemes)(fileData.theme).then(result => {
322
+ if (result == null) {
323
+ (0, _Console.stopProgressIndicator)("Error importing ".concat(Object.keys(fileData.theme).length, " themes!"));
324
+ (0, _Console.printMessage)("Error importing ".concat(Object.keys(fileData.theme).length, " themes from ").concat(file), 'error');
325
+ } else {
326
+ (0, _Console.stopProgressIndicator)("Successfully imported ".concat(Object.keys(fileData.theme).length, " themes."));
327
+ }
328
+ });
252
329
  } else {
253
- files += 1;
254
- total += count;
255
- updateProgressIndicator(`Imported ${count} theme(s) from ${file}`);
330
+ (0, _Console.printMessage)('Import validation failed...', 'error');
256
331
  }
257
- } else {
258
- printMessage(`Validation of ${file} failed!`, 'error');
259
- }
260
- }
332
+ });
333
+ });
334
+ return _importThemesFromFile.apply(this, arguments);
335
+ }
261
336
 
262
- stopProgressIndicator(`Finished importing ${total} theme(s) from ${files} file(s).`);
337
+ function importThemesFromFiles() {
338
+ return _importThemesFromFiles.apply(this, arguments);
263
339
  }
264
340
  /**
265
341
  * Import first theme from file
266
342
  * @param {String} file import file name
267
343
  */
268
344
 
269
- export async function importFirstThemeFromFile(file) {
270
- fs.readFile(file, 'utf8', (err, data) => {
271
- if (err) throw err;
272
- const themeData = JSON.parse(data);
273
-
274
- if (validateImport(themeData.meta)) {
275
- createProgressIndicator(1, 'Importing theme...');
276
-
277
- for (const id in themeData.theme) {
278
- if ({}.hasOwnProperty.call(themeData.theme, id)) {
279
- updateProgressIndicator(`Importing ${themeData.theme[id].name}`);
280
- putTheme(id, themeData.theme[id]).then(result => {
281
- if (result == null) {
282
- stopProgressIndicator(`Error importing theme ${themeData.theme[id].name}`);
283
- printMessage(`Error importing theme ${themeData.theme[id].name}`, 'error');
284
- } else {
285
- stopProgressIndicator(`Successfully imported theme ${themeData.theme[id].name}`);
286
- }
287
- });
288
- break;
345
+
346
+ function _importThemesFromFiles() {
347
+ _importThemesFromFiles = _asyncToGenerator(function* () {
348
+ var names = _fs.default.readdirSync('.');
349
+
350
+ var jsonFiles = names.filter(name => name.toLowerCase().endsWith('.theme.json'));
351
+ (0, _Console.createProgressIndicator)(jsonFiles.length, 'Importing themes...');
352
+ var fileData = null;
353
+ var count = 0;
354
+ var total = 0;
355
+ var files = 0;
356
+
357
+ for (var file of jsonFiles) {
358
+ var data = _fs.default.readFileSync(file, 'utf8');
359
+
360
+ fileData = JSON.parse(data);
361
+
362
+ if ((0, _ExportImportUtils.validateImport)(fileData.meta)) {
363
+ count = Object.keys(fileData.theme).length; // eslint-disable-next-line no-await-in-loop
364
+
365
+ var result = yield (0, _ThemeApi.putThemes)(fileData.theme);
366
+
367
+ if (result == null) {
368
+ (0, _Console.printMessage)("Error importing ".concat(count, " themes from ").concat(file), 'error');
369
+ } else {
370
+ files += 1;
371
+ total += count;
372
+ (0, _Console.updateProgressIndicator)("Imported ".concat(count, " theme(s) from ").concat(file));
289
373
  }
374
+ } else {
375
+ (0, _Console.printMessage)("Validation of ".concat(file, " failed!"), 'error');
290
376
  }
291
- } else {
292
- printMessage('Import validation failed...', 'error');
293
377
  }
378
+
379
+ (0, _Console.stopProgressIndicator)("Finished importing ".concat(total, " theme(s) from ").concat(files, " file(s)."));
294
380
  });
381
+ return _importThemesFromFiles.apply(this, arguments);
382
+ }
383
+
384
+ function importFirstThemeFromFile(_x11) {
385
+ return _importFirstThemeFromFile.apply(this, arguments);
295
386
  }
296
387
  /**
297
388
  * Delete theme by id
298
389
  * @param {String} id theme id
299
390
  */
300
391
 
301
- export async function deleteThemeCmd(id) {
302
- createProgressIndicator(undefined, `Deleting ${id}...`, 'indeterminate');
303
392
 
304
- try {
305
- await deleteTheme(id);
306
- stopProgressIndicator(`Deleted ${id}.`, 'success');
307
- } catch (error) {
308
- stopProgressIndicator(`Error: ${error.message}`, 'fail');
309
- }
393
+ function _importFirstThemeFromFile() {
394
+ _importFirstThemeFromFile = _asyncToGenerator(function* (file) {
395
+ _fs.default.readFile(file, 'utf8', (err, data) => {
396
+ if (err) throw err;
397
+ var themeData = JSON.parse(data);
398
+
399
+ if ((0, _ExportImportUtils.validateImport)(themeData.meta)) {
400
+ (0, _Console.createProgressIndicator)(1, 'Importing theme...');
401
+
402
+ var _loop3 = function _loop3(id) {
403
+ if ({}.hasOwnProperty.call(themeData.theme, id)) {
404
+ (0, _Console.updateProgressIndicator)("Importing ".concat(themeData.theme[id].name));
405
+ (0, _ThemeApi.putTheme)(id, themeData.theme[id]).then(result => {
406
+ if (result == null) {
407
+ (0, _Console.stopProgressIndicator)("Error importing theme ".concat(themeData.theme[id].name));
408
+ (0, _Console.printMessage)("Error importing theme ".concat(themeData.theme[id].name), 'error');
409
+ } else {
410
+ (0, _Console.stopProgressIndicator)("Successfully imported theme ".concat(themeData.theme[id].name));
411
+ }
412
+ });
413
+ return "break";
414
+ }
415
+ };
416
+
417
+ for (var id in themeData.theme) {
418
+ var _ret3 = _loop3(id);
419
+
420
+ if (_ret3 === "break") break;
421
+ }
422
+ } else {
423
+ (0, _Console.printMessage)('Import validation failed...', 'error');
424
+ }
425
+ });
426
+ });
427
+ return _importFirstThemeFromFile.apply(this, arguments);
428
+ }
429
+
430
+ function deleteThemeCmd(_x12) {
431
+ return _deleteThemeCmd.apply(this, arguments);
310
432
  }
311
433
  /**
312
434
  * Delete theme by name
313
435
  * @param {String} name theme name
314
436
  */
315
437
 
316
- export async function deleteThemeByNameCmd(name) {
317
- createProgressIndicator(undefined, `Deleting ${name}...`, 'indeterminate');
318
438
 
319
- try {
320
- await deleteThemeByName(name);
321
- stopProgressIndicator(`Deleted ${name}.`, 'success');
322
- } catch (error) {
323
- stopProgressIndicator(`Error: ${error.message}`, 'fail');
324
- }
439
+ function _deleteThemeCmd() {
440
+ _deleteThemeCmd = _asyncToGenerator(function* (id) {
441
+ (0, _Console.createProgressIndicator)(undefined, "Deleting ".concat(id, "..."), 'indeterminate');
442
+
443
+ try {
444
+ yield (0, _ThemeApi.deleteTheme)(id);
445
+ (0, _Console.stopProgressIndicator)("Deleted ".concat(id, "."), 'success');
446
+ } catch (error) {
447
+ (0, _Console.stopProgressIndicator)("Error: ".concat(error.message), 'fail');
448
+ }
449
+ });
450
+ return _deleteThemeCmd.apply(this, arguments);
451
+ }
452
+
453
+ function deleteThemeByNameCmd(_x13) {
454
+ return _deleteThemeByNameCmd.apply(this, arguments);
325
455
  }
326
456
  /**
327
457
  * Delete all themes
328
458
  */
329
459
 
330
- export async function deleteThemesCmd() {
331
- createProgressIndicator(undefined, `Deleting all realm themes...`, 'indeterminate');
332
460
 
333
- try {
334
- await deleteThemes();
335
- stopProgressIndicator(`Deleted all realm themes.`, 'success');
336
- } catch (error) {
337
- stopProgressIndicator(`Error: ${error.message}`, 'fail');
338
- }
461
+ function _deleteThemeByNameCmd() {
462
+ _deleteThemeByNameCmd = _asyncToGenerator(function* (name) {
463
+ (0, _Console.createProgressIndicator)(undefined, "Deleting ".concat(name, "..."), 'indeterminate');
464
+
465
+ try {
466
+ yield (0, _ThemeApi.deleteThemeByName)(name);
467
+ (0, _Console.stopProgressIndicator)("Deleted ".concat(name, "."), 'success');
468
+ } catch (error) {
469
+ (0, _Console.stopProgressIndicator)("Error: ".concat(error.message), 'fail');
470
+ }
471
+ });
472
+ return _deleteThemeByNameCmd.apply(this, arguments);
473
+ }
474
+
475
+ function deleteThemesCmd() {
476
+ return _deleteThemesCmd.apply(this, arguments);
477
+ }
478
+
479
+ function _deleteThemesCmd() {
480
+ _deleteThemesCmd = _asyncToGenerator(function* () {
481
+ (0, _Console.createProgressIndicator)(undefined, "Deleting all realm themes...", 'indeterminate');
482
+
483
+ try {
484
+ yield (0, _ThemeApi.deleteThemes)();
485
+ (0, _Console.stopProgressIndicator)("Deleted all realm themes.", 'success');
486
+ } catch (error) {
487
+ (0, _Console.stopProgressIndicator)("Error: ".concat(error.message), 'fail');
488
+ }
489
+ });
490
+ return _deleteThemesCmd.apply(this, arguments);
339
491
  }
340
492
  //# sourceMappingURL=ThemeOps.js.map