@rockcarver/frodo-lib 0.16.2-9 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (355) hide show
  1. package/CHANGELOG.md +222 -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 +266 -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 +242 -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
@@ -1,350 +1,241 @@
1
- import fs from 'fs';
2
- import { deleteTheme, deleteThemeByName, deleteThemes as _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
+ import { getConfigEntity, putConfigEntity } from '../api/IdmConfigApi';
2
+ import { getCurrentRealmName } from '../api/utils/ApiUtils';
3
+ import { debugMessage } from '../ops/utils/Console';
4
+ export const THEMEREALM_ID = 'ui/themerealm';
5
+
5
6
  /**
6
- * List all the themes
7
- * @param {boolean} long Long version, more fields
7
+ * Get realm themes
8
+ * @param {UiThemeRealmObject} themes object containing themes
9
+ * @returns {ThemeSkeleton[]} array of theme pertaining to the current realm
8
10
  */
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');
11
+ function getRealmThemes(themes) {
12
+ if (themes.realm && themes.realm[getCurrentRealmName()]) {
13
+ return themes.realm[getCurrentRealmName()];
24
14
  }
15
+ return [];
25
16
  }
17
+
26
18
  /**
27
- * Export theme by name to file
28
- * @param {String} name theme name
29
- * @param {String} file optional export file name
19
+ * Get all themes
20
+ * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes
30
21
  */
31
-
32
- export async function exportThemeByName(name, file) {
33
- let fileName = getTypedFilename(name, 'theme');
34
-
35
- if (file) {
36
- fileName = file;
37
- }
38
-
39
- createProgressIndicator(1, `Exporting ${name}`);
40
-
41
- try {
42
- const themeData = await getThemeByName(name);
43
- updateProgressIndicator(`Writing file ${fileName}`);
44
- saveToFile('theme', [themeData], '_id', fileName);
45
- stopProgressIndicator(`Successfully exported theme ${name}.`);
46
- } catch (error) {
47
- stopProgressIndicator(`${error.message}`);
48
- printMessage(`${error.message}`, 'error');
49
- }
22
+ export async function getThemes() {
23
+ const themes = await getConfigEntity(THEMEREALM_ID);
24
+ return getRealmThemes(themes);
50
25
  }
26
+
51
27
  /**
52
- * Export theme by uuid to file
53
- * @param {String} id theme uuid
54
- * @param {String} file optional export file name
28
+ * Get theme by id
29
+ * @param {string} themeId theme id
30
+ * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
55
31
  */
56
-
57
- export async function exportThemeById(id, file) {
58
- let fileName = getTypedFilename(id, 'theme');
59
-
60
- if (file) {
61
- fileName = file;
32
+ export async function getTheme(themeId) {
33
+ const themes = await getConfigEntity(THEMEREALM_ID);
34
+ const found = getRealmThemes(themes).filter(theme => theme._id === themeId);
35
+ if (found.length === 1) {
36
+ return found[0];
62
37
  }
63
-
64
- createProgressIndicator(1, `Exporting ${id}`);
65
-
66
- try {
67
- const themeData = await getTheme(id);
68
- updateProgressIndicator(`Writing file ${fileName}`);
69
- saveToFile('theme', [themeData], '_id', fileName);
70
- stopProgressIndicator(`Successfully exported theme ${id}.`);
71
- } catch (error) {
72
- stopProgressIndicator(`${error.message}`);
73
- printMessage(`${error.message}`, 'error');
38
+ if (found.length > 1) {
39
+ throw new Error(`Multiple themes with id "${themeId}" found!`);
74
40
  }
41
+ throw new Error(`Theme with id "${themeId}" not found!`);
75
42
  }
43
+
76
44
  /**
77
- * Export all themes to file
78
- * @param {String} file optional export file name
45
+ * Get theme by name
46
+ * @param {string} themeName theme name
47
+ * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
79
48
  */
80
-
81
- export async function exportThemesToFile(file) {
82
- let fileName = getTypedFilename(`all${getRealmString()}Themes`, 'theme');
83
-
84
- if (file) {
85
- fileName = file;
49
+ export async function getThemeByName(themeName) {
50
+ const themes = await getConfigEntity(THEMEREALM_ID);
51
+ const found = getRealmThemes(themes).filter(theme => theme.name === themeName);
52
+ if (found.length === 1) {
53
+ return found[0];
86
54
  }
87
-
88
- const allThemesData = await getThemes();
89
- createProgressIndicator(allThemesData.length, 'Exporting themes');
90
-
91
- for (const themeData of allThemesData) {
92
- updateProgressIndicator(`Exporting theme ${themeData.name}`);
55
+ if (found.length > 1) {
56
+ throw new Error(`Multiple themes with the name "${themeName}" found!`);
93
57
  }
94
-
95
- saveToFile('theme', allThemesData, '_id', fileName);
96
- stopProgressIndicator(`${allThemesData.length} themes exported to ${fileName}.`);
58
+ throw new Error(`Theme "${themeName}" not found!`);
97
59
  }
98
- /**
99
- * Export all themes to separate files
100
- */
101
-
102
- export async function exportThemesToFiles() {
103
- const allThemesData = await getThemes();
104
- createProgressIndicator(allThemesData.length, 'Exporting themes');
105
60
 
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
- }
111
-
112
- stopProgressIndicator(`${allThemesData.length} themes exported.`);
113
- }
114
61
  /**
115
- * Import theme by name from file
116
- * @param {String} name theme name
117
- * @param {String} file import file name
62
+ * Put theme by id
63
+ * @param {string} themeId theme id
64
+ * @param {ThemeSkeleton} themeData theme object
65
+ * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
118
66
  */
119
-
120
- export async function importThemeByName(name, file) {
121
- fs.readFile(file, 'utf8', async (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
-
135
- try {
136
- await putThemeByName(name, themeData.theme[id]);
137
- stopProgressIndicator(`Successfully imported theme ${name}.`);
138
- } catch (error) {
139
- stopProgressIndicator(`Error importing theme ${themeData.theme[id].name}: ${error.message}`);
140
- printMessage(`Error importing theme ${themeData.theme[id].name}: ${error.message}`, 'error');
141
- }
142
-
143
- break;
144
- }
145
- }
146
- }
147
-
148
- if (!found) {
149
- stopProgressIndicator(`Theme ${name} not found!`);
150
- }
151
- } else {
152
- printMessage('Import validation failed...', 'error');
67
+ export async function putTheme(themeId, themeData) {
68
+ const data = themeData;
69
+ data._id = themeId;
70
+ const themes = await getConfigEntity(THEMEREALM_ID);
71
+ let isNew = true;
72
+ const realmThemes = getRealmThemes(themes).map(theme => {
73
+ if (theme._id === themeId) {
74
+ isNew = false;
75
+ return data;
153
76
  }
77
+ // eslint-disable-next-line no-param-reassign
78
+ if (data.isDefault) theme.isDefault = false;
79
+ return theme;
154
80
  });
81
+ if (isNew) {
82
+ realmThemes.push(data);
83
+ }
84
+ themes.realm[getCurrentRealmName()] = realmThemes;
85
+ const found = getRealmThemes(await putConfigEntity(THEMEREALM_ID, themes)).filter(theme => theme._id === themeId);
86
+ if (found.length === 1) {
87
+ return found[0];
88
+ }
89
+ if (found.length > 1) {
90
+ throw new Error(`Multiple themes with id "${themeId}" found!`);
91
+ }
92
+ throw new Error(`Theme with id "${themeId}" not saved!`);
155
93
  }
156
- /**
157
- * Import theme by uuid from file
158
- * @param {String} id theme uuid
159
- * @param {String} file import file name
160
- */
161
-
162
- export async function importThemeById(id, file) {
163
- fs.readFile(file, 'utf8', async (err, data) => {
164
- if (err) throw err;
165
- const themeData = JSON.parse(data);
166
-
167
- if (validateImport(themeData.meta)) {
168
- createProgressIndicator(1, 'Importing theme...');
169
- let found = false;
170
-
171
- for (const themeId in themeData.theme) {
172
- if ({}.hasOwnProperty.call(themeData.theme, themeId)) {
173
- if (themeId === id) {
174
- found = true;
175
- updateProgressIndicator(`Importing ${themeData.theme[themeId]._id}`);
176
-
177
- try {
178
- await putTheme(themeId, themeData.theme[themeId]);
179
- stopProgressIndicator(`Successfully imported theme ${id}.`);
180
- } catch (error) {
181
- stopProgressIndicator(`Error importing theme ${themeData.theme[themeId]._id}: ${error.message}`);
182
- printMessage(`Error importing theme ${themeData.theme[themeId]._id}: ${error.message}`, 'error');
183
- }
184
-
185
- break;
186
- }
187
- }
188
- }
189
94
 
190
- if (!found) {
191
- stopProgressIndicator(`Theme ${id} not found!`);
192
- }
193
- } else {
194
- printMessage('Import validation failed...', 'error');
195
- }
196
- });
197
- }
198
95
  /**
199
- * Import all themes from single file
200
- * @param {String} file import file name
96
+ * Put theme by name
97
+ * @param {String} themeName theme name
98
+ * @param {ThemeSkeleton} themeData theme object
99
+ * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object
201
100
  */
202
-
203
- export async function importThemesFromFile(file) {
204
- fs.readFile(file, 'utf8', (err, data) => {
205
- if (err) throw err;
206
- const fileData = JSON.parse(data);
207
-
208
- if (validateImport(fileData.meta)) {
209
- createProgressIndicator(Object.keys(fileData.theme).length, 'Importing themes...');
210
-
211
- for (const id in fileData.theme) {
212
- if ({}.hasOwnProperty.call(fileData.theme, id)) {
213
- updateProgressIndicator(`Importing ${fileData.theme[id].name}`);
214
- }
215
- }
216
-
217
- putThemes(fileData.theme).then(result => {
218
- if (result == null) {
219
- stopProgressIndicator(`Error importing ${Object.keys(fileData.theme).length} themes!`);
220
- printMessage(`Error importing ${Object.keys(fileData.theme).length} themes from ${file}`, 'error');
221
- } else {
222
- stopProgressIndicator(`Successfully imported ${Object.keys(fileData.theme).length} themes.`);
223
- }
224
- });
225
- } else {
226
- printMessage('Import validation failed...', 'error');
101
+ export async function putThemeByName(themeName, themeData) {
102
+ const data = themeData;
103
+ data.name = themeName;
104
+ const themes = await getConfigEntity(THEMEREALM_ID);
105
+ let isNew = true;
106
+ const realmThemes = getRealmThemes(themes).map(theme => {
107
+ if (theme.name === themeName) {
108
+ isNew = false;
109
+ return data;
227
110
  }
111
+ // eslint-disable-next-line no-param-reassign
112
+ if (data.isDefault) theme.isDefault = false;
113
+ return theme;
228
114
  });
229
- }
230
- /**
231
- * Import themes from separate files
232
- */
233
-
234
- export async function importThemesFromFiles() {
235
- const names = fs.readdirSync('.');
236
- const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.theme.json'));
237
- createProgressIndicator(jsonFiles.length, 'Importing themes...');
238
- let fileData = null;
239
- let count = 0;
240
- let total = 0;
241
- let files = 0;
242
-
243
- for (const file of jsonFiles) {
244
- const data = fs.readFileSync(file, 'utf8');
245
- fileData = JSON.parse(data);
246
-
247
- if (validateImport(fileData.meta)) {
248
- count = Object.keys(fileData.theme).length; // eslint-disable-next-line no-await-in-loop
249
-
250
- const result = await putThemes(fileData.theme);
251
-
252
- if (result == null) {
253
- printMessage(`Error importing ${count} themes from ${file}`, 'error');
254
- } else {
255
- files += 1;
256
- total += count;
257
- updateProgressIndicator(`Imported ${count} theme(s) from ${file}`);
258
- }
259
- } else {
260
- printMessage(`Validation of ${file} failed!`, 'error');
261
- }
115
+ if (isNew) {
116
+ realmThemes.push(data);
262
117
  }
263
-
264
- stopProgressIndicator(`Finished importing ${total} theme(s) from ${files} file(s).`);
118
+ themes['realm'][getCurrentRealmName()] = realmThemes;
119
+ const found = getRealmThemes(await putConfigEntity(THEMEREALM_ID, themes)).filter(theme => theme.name === themeName);
120
+ if (found.length === 1) {
121
+ return found[0];
122
+ }
123
+ if (found.length > 1) {
124
+ throw new Error(`Multiple themes "${themeName}" found!`);
125
+ }
126
+ throw new Error(`Theme "${themeName}" not saved!`);
265
127
  }
128
+
266
129
  /**
267
- * Import first theme from file
268
- * @param {String} file import file name
130
+ * Put all themes
131
+ * @param {Map<string, ThemeSkeleton>} allThemesData themes object containing all themes for all realms
132
+ * @returns {Promise<Map<string, ThemeSkeleton>>} a promise that resolves to a themes object
269
133
  */
270
-
271
- export async function importFirstThemeFromFile(file) {
272
- fs.readFile(file, 'utf8', (err, data) => {
273
- if (err) throw err;
274
- const themeData = JSON.parse(data);
275
-
276
- if (validateImport(themeData.meta)) {
277
- createProgressIndicator(1, 'Importing theme...');
278
-
279
- for (const id in themeData.theme) {
280
- if ({}.hasOwnProperty.call(themeData.theme, id)) {
281
- updateProgressIndicator(`Importing ${themeData.theme[id].name}`);
282
- putTheme(id, themeData.theme[id]).then(result => {
283
- if (result == null) {
284
- stopProgressIndicator(`Error importing theme ${themeData.theme[id].name}`);
285
- printMessage(`Error importing theme ${themeData.theme[id].name}`, 'error');
286
- } else {
287
- stopProgressIndicator(`Successfully imported theme ${themeData.theme[id].name}`);
288
- }
289
- });
290
- break;
291
- }
292
- }
293
- } else {
294
- printMessage('Import validation failed...', 'error');
134
+ export async function putThemes(themeMap) {
135
+ debugMessage(`ThemeApi.putThemes: start`);
136
+ const themes = await getConfigEntity(THEMEREALM_ID);
137
+ const allThemeIDs = Object.keys(themeMap);
138
+ const existingThemeIDs = [];
139
+ let defaultThemeId = null;
140
+ // update existing themes
141
+ let realmThemes = getRealmThemes(themes).map(theme => {
142
+ if (themeMap[theme._id]) {
143
+ debugMessage(`Update theme: ${theme._id} - ${theme.name}`);
144
+ existingThemeIDs.push(theme._id);
145
+ // remember the id of the last default theme
146
+ if (themeMap[theme._id].isDefault) defaultThemeId = theme._id;
147
+ return themeMap[theme._id];
295
148
  }
149
+ return theme;
150
+ });
151
+ const newThemeIDs = allThemeIDs.filter(id => !existingThemeIDs.includes(id));
152
+ // add new themes
153
+ newThemeIDs.forEach(themeId => {
154
+ debugMessage(`Add theme: ${themeMap[themeId]._id} - ${themeMap[themeId].name}`);
155
+ // remember the id of the last default theme
156
+ if (themeMap[themeId].isDefault) defaultThemeId = themeId;
157
+ realmThemes.push(themeMap[themeId]);
296
158
  });
159
+ // if we imported a default theme, flag all the other themes as not default
160
+ if (defaultThemeId) {
161
+ realmThemes = realmThemes.map(theme => {
162
+ // eslint-disable-next-line no-param-reassign
163
+ theme.isDefault = theme._id === defaultThemeId;
164
+ return theme;
165
+ });
166
+ }
167
+ themes.realm[getCurrentRealmName()] = realmThemes;
168
+ const updatedThemes = new Map(getRealmThemes(await putConfigEntity(THEMEREALM_ID, themes)).map(theme => [theme._id, theme]));
169
+ debugMessage(updatedThemes);
170
+ debugMessage(`ThemeApi.putThemes: finished`);
171
+ return updatedThemes;
297
172
  }
173
+
298
174
  /**
299
175
  * Delete theme by id
300
- * @param {String} id theme id
176
+ * @param {string} themeId theme id
177
+ * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object
301
178
  */
302
-
303
- export async function deleteThemeCmd(id) {
304
- createProgressIndicator(undefined, `Deleting ${id}...`, 'indeterminate');
305
-
306
- try {
307
- await deleteTheme(id);
308
- stopProgressIndicator(`Deleted ${id}.`, 'success');
309
- } catch (error) {
310
- stopProgressIndicator(`Error: ${error.message}`, 'fail');
179
+ export async function deleteTheme(themeId) {
180
+ const themes = await getConfigEntity(THEMEREALM_ID);
181
+ const realmThemes = getRealmThemes(themes);
182
+ const deletedThemes = [];
183
+ const finalThemes = realmThemes.filter(theme => {
184
+ if (theme._id !== themeId) {
185
+ return true;
186
+ }
187
+ deletedThemes.push(theme);
188
+ return false;
189
+ });
190
+ if (realmThemes.length === finalThemes.length) throw new Error(`${themeId} not found`);
191
+ themes.realm[getCurrentRealmName()] = realmThemes;
192
+ const undeletedThemes = getRealmThemes(await putConfigEntity(THEMEREALM_ID, themes)).filter(theme => deletedThemes.includes(theme));
193
+ if (deletedThemes.length > 0 && undeletedThemes.length === 0) {
194
+ return deletedThemes[0];
311
195
  }
196
+ throw new Error(`Theme(s) with id(s) "${undeletedThemes.map(theme => theme._id)}" not deleted!`);
312
197
  }
198
+
313
199
  /**
314
200
  * Delete theme by name
315
- * @param {String} name theme name
201
+ * @param {string} themeName theme name
202
+ * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object
316
203
  */
317
-
318
- export async function deleteThemeByNameCmd(name) {
319
- createProgressIndicator(undefined, `Deleting ${name}...`, 'indeterminate');
320
-
321
- try {
322
- await deleteThemeByName(name);
323
- stopProgressIndicator(`Deleted ${name}.`, 'success');
324
- } catch (error) {
325
- stopProgressIndicator(`Error: ${error.message}`, 'fail');
204
+ export async function deleteThemeByName(themeName) {
205
+ const themes = await getConfigEntity(THEMEREALM_ID);
206
+ const realmThemes = getRealmThemes(themes);
207
+ const deletedThemes = [];
208
+ const finalThemes = realmThemes.filter(theme => {
209
+ if (theme.name !== themeName) {
210
+ return true;
211
+ }
212
+ deletedThemes.push(theme);
213
+ return false;
214
+ });
215
+ if (realmThemes.length === finalThemes.length) throw new Error(`${themeName} not found`);
216
+ themes.realm[getCurrentRealmName()] = finalThemes;
217
+ // return putConfigEntity(THEMEREALM_ID, themes);
218
+ const undeletedThemes = getRealmThemes(await putConfigEntity(THEMEREALM_ID, themes)).filter(theme => deletedThemes.includes(theme));
219
+ if (deletedThemes.length > 0 && undeletedThemes.length === 0) {
220
+ return deletedThemes[0];
326
221
  }
222
+ throw new Error(`Theme(s) with id(s) "${undeletedThemes.map(theme => theme._id)}" not deleted!`);
327
223
  }
224
+
328
225
  /**
329
226
  * Delete all themes
227
+ * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes
330
228
  */
331
-
332
229
  export async function deleteThemes() {
333
- createProgressIndicator(undefined, `Deleting all realm themes...`, 'indeterminate');
334
-
335
- try {
336
- await _deleteThemes();
337
- stopProgressIndicator(`Deleted all realm themes.`, 'success');
338
- } catch (error) {
339
- stopProgressIndicator(`Error: ${error.message}`, 'fail');
230
+ const themes = await getConfigEntity(THEMEREALM_ID);
231
+ const realmThemes = themes.realm[getCurrentRealmName()];
232
+ if (!realmThemes) throw new Error(`No theme configuration found for realm "${getCurrentRealmName()}"`);
233
+ const deletedThemes = [];
234
+ for (const theme of realmThemes) {
235
+ deletedThemes.push(theme);
340
236
  }
341
- }
342
- /**
343
- * Delete all themes
344
- * @deprecated since version 0.14.0
345
- */
346
-
347
- export async function deleteThemesCmd() {
348
- return deleteThemes();
237
+ themes.realm[getCurrentRealmName()] = [];
238
+ await putConfigEntity(THEMEREALM_ID, themes);
239
+ return deletedThemes;
349
240
  }
350
241
  //# sourceMappingURL=ThemeOps.js.map