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