@rockcarver/frodo-lib 2.0.0-13 → 2.0.0-15

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 (403) hide show
  1. package/build.zip +0 -0
  2. package/cjs/api/AgentApi.js.map +1 -1
  3. package/cjs/api/AuthenticateApi.js.map +1 -1
  4. package/cjs/api/BaseApi.js +1 -1
  5. package/cjs/api/BaseApi.js.map +1 -1
  6. package/cjs/api/CirclesOfTrustApi.js.map +1 -1
  7. package/cjs/api/IdmConfigApi.js.map +1 -1
  8. package/cjs/api/IdmSystemApi.js.map +1 -1
  9. package/cjs/api/ManagedObjectApi.js.map +1 -1
  10. package/cjs/api/NodeApi.js.map +1 -1
  11. package/cjs/api/OAuth2ClientApi.js.map +1 -1
  12. package/cjs/api/OAuth2OIDCApi.js.map +1 -1
  13. package/cjs/api/OAuth2OIDCApi.test.js +2 -2
  14. package/cjs/api/OAuth2OIDCApi.test.js.map +1 -1
  15. package/cjs/api/OAuth2ProviderApi.js.map +1 -1
  16. package/cjs/api/PoliciesApi.js.map +1 -1
  17. package/cjs/api/PolicySetApi.js.map +1 -1
  18. package/cjs/api/RealmApi.js.map +1 -1
  19. package/cjs/api/ResourceTypesApi.js.map +1 -1
  20. package/cjs/api/Saml2Api.js.map +1 -1
  21. package/cjs/api/ScriptApi.js.map +1 -1
  22. package/cjs/api/ServerInfoApi.js.map +1 -1
  23. package/cjs/api/ServiceApi.js.map +1 -1
  24. package/cjs/api/SocialIdentityProvidersApi.js.map +1 -1
  25. package/cjs/api/TreeApi.js.map +1 -1
  26. package/cjs/api/cloud/AdminFederationProvidersApi.js.map +1 -1
  27. package/cjs/api/cloud/EnvInfoApi.js.map +1 -1
  28. package/cjs/api/cloud/FeatureApi.js.map +1 -1
  29. package/cjs/api/cloud/LogApi.js.map +1 -1
  30. package/cjs/api/cloud/SecretsApi.js.map +1 -1
  31. package/cjs/api/cloud/StartupApi.js.map +1 -1
  32. package/cjs/api/cloud/VariablesApi.js.map +1 -1
  33. package/cjs/api/utils/ApiUtils.js.map +1 -1
  34. package/cjs/api/utils/Base64.js +4 -4
  35. package/cjs/api/utils/Base64.js.map +1 -1
  36. package/cjs/index.js +12 -10
  37. package/cjs/index.js.map +1 -1
  38. package/cjs/lib/FrodoLib.js +181 -22
  39. package/cjs/lib/FrodoLib.js.map +1 -1
  40. package/cjs/lib/FrodoLib.test.js +9 -9
  41. package/cjs/lib/FrodoLib.test.js.map +1 -1
  42. package/cjs/ops/AdminOps.js.map +1 -1
  43. package/cjs/ops/AgentOps.js +35 -35
  44. package/cjs/ops/AgentOps.js.map +1 -1
  45. package/cjs/ops/AuthenticateOps.js +10 -12
  46. package/cjs/ops/AuthenticateOps.js.map +1 -1
  47. package/cjs/ops/CirclesOfTrustOps.js +14 -14
  48. package/cjs/ops/CirclesOfTrustOps.js.map +1 -1
  49. package/cjs/ops/ConnectionProfileOps.js +2 -2
  50. package/cjs/ops/ConnectionProfileOps.js.map +1 -1
  51. package/cjs/ops/ConnectionProfileOps.test.js +5 -5
  52. package/cjs/ops/ConnectionProfileOps.test.js.map +1 -1
  53. package/cjs/ops/EmailTemplateOps.js.map +1 -1
  54. package/cjs/ops/IdmOps.js.map +1 -1
  55. package/cjs/ops/IdpOps.js.map +1 -1
  56. package/cjs/ops/InfoOps.js +3 -4
  57. package/cjs/ops/InfoOps.js.map +1 -1
  58. package/cjs/ops/JoseOps.js +30 -0
  59. package/cjs/ops/JoseOps.js.map +1 -1
  60. package/cjs/ops/JourneyOps.js +41 -43
  61. package/cjs/ops/JourneyOps.js.map +1 -1
  62. package/cjs/ops/JourneyOps.test.js +3 -2
  63. package/cjs/ops/JourneyOps.test.js.map +1 -1
  64. package/cjs/ops/ManagedObjectOps.js.map +1 -1
  65. package/cjs/ops/NodeOps.js.map +1 -1
  66. package/cjs/ops/OAuth2ClientOps.js +19 -19
  67. package/cjs/ops/OAuth2ClientOps.js.map +1 -1
  68. package/cjs/ops/OAuth2OidcOps.js.map +1 -1
  69. package/cjs/ops/OAuth2ProviderOps.js.map +1 -1
  70. package/cjs/ops/OpsTypes.js.map +1 -1
  71. package/cjs/ops/OrganizationOps.js.map +1 -1
  72. package/cjs/ops/PolicyOps.js +29 -29
  73. package/cjs/ops/PolicyOps.js.map +1 -1
  74. package/cjs/ops/PolicySetOps.js +27 -27
  75. package/cjs/ops/PolicySetOps.js.map +1 -1
  76. package/cjs/ops/RealmOps.js.map +1 -1
  77. package/cjs/ops/ResourceTypeOps.js +23 -23
  78. package/cjs/ops/ResourceTypeOps.js.map +1 -1
  79. package/cjs/ops/Saml2Ops.js +11 -11
  80. package/cjs/ops/Saml2Ops.js.map +1 -1
  81. package/cjs/ops/Saml2Ops.test.js +3 -2
  82. package/cjs/ops/Saml2Ops.test.js.map +1 -1
  83. package/cjs/ops/ScriptOps.js +3 -3
  84. package/cjs/ops/ScriptOps.js.map +1 -1
  85. package/cjs/ops/ServiceOps.js.map +1 -1
  86. package/cjs/ops/ThemeOps.js.map +1 -1
  87. package/cjs/ops/cloud/AdminFederationOps.js.map +1 -1
  88. package/cjs/ops/cloud/FeatureOps.js.map +1 -1
  89. package/cjs/ops/cloud/LogOps.js.map +1 -1
  90. package/cjs/ops/cloud/SecretsOps.js.map +1 -1
  91. package/cjs/ops/cloud/ServiceAccountOps.js +1 -1
  92. package/cjs/ops/cloud/ServiceAccountOps.js.map +1 -1
  93. package/cjs/ops/cloud/StartupOps.js.map +1 -1
  94. package/cjs/ops/cloud/VariablesOps.js.map +1 -1
  95. package/cjs/ops/utils/Console.js.map +1 -1
  96. package/cjs/ops/utils/DataProtection.js +3 -3
  97. package/cjs/ops/utils/DataProtection.js.map +1 -1
  98. package/cjs/ops/utils/DataProtection.test.js +1 -1
  99. package/cjs/ops/utils/DataProtection.test.js.map +1 -1
  100. package/cjs/ops/utils/ExportImportUtils.js +2 -2
  101. package/cjs/ops/utils/ExportImportUtils.js.map +1 -1
  102. package/cjs/ops/utils/OpsUtils.js +105 -25
  103. package/cjs/ops/utils/OpsUtils.js.map +1 -1
  104. package/cjs/ops/utils/OpsUtils.test.js +6 -5
  105. package/cjs/ops/utils/OpsUtils.test.js.map +1 -1
  106. package/cjs/ops/utils/ScriptValidationUtils.js +33 -2
  107. package/cjs/ops/utils/ScriptValidationUtils.js.map +1 -1
  108. package/cjs/ops/utils/ScriptValidationUtils.test.js +1 -1
  109. package/cjs/ops/utils/ScriptValidationUtils.test.js.map +1 -1
  110. package/cjs/ops/utils/{Version.js → VersionUtils.js} +1 -1
  111. package/cjs/ops/utils/VersionUtils.js.map +1 -0
  112. package/cjs/ops/utils/{Version.test.js → VersionUtils.test.js} +3 -3
  113. package/cjs/ops/utils/VersionUtils.test.js.map +1 -0
  114. package/cjs/shared/Constants.js +34 -0
  115. package/cjs/shared/Constants.js.map +1 -0
  116. package/cjs/shared/State.js +477 -220
  117. package/cjs/shared/State.js.map +1 -1
  118. package/cjs/utils/SetupPollyForFrodoLib.js.map +1 -1
  119. package/esm/api/AgentApi.js.map +1 -1
  120. package/esm/api/AuthenticateApi.js.map +1 -1
  121. package/esm/api/BaseApi.js +2 -2
  122. package/esm/api/BaseApi.js.map +1 -1
  123. package/esm/api/CirclesOfTrustApi.js.map +1 -1
  124. package/esm/api/IdmConfigApi.js.map +1 -1
  125. package/esm/api/IdmSystemApi.js.map +1 -1
  126. package/esm/api/ManagedObjectApi.js.map +1 -1
  127. package/esm/api/NodeApi.js.map +1 -1
  128. package/esm/api/OAuth2ClientApi.js.map +1 -1
  129. package/esm/api/OAuth2OIDCApi.js.map +1 -1
  130. package/esm/api/OAuth2OIDCApi.test.js +2 -2
  131. package/esm/api/OAuth2OIDCApi.test.js.map +1 -1
  132. package/esm/api/OAuth2ProviderApi.js.map +1 -1
  133. package/esm/api/PoliciesApi.js.map +1 -1
  134. package/esm/api/PolicySetApi.js.map +1 -1
  135. package/esm/api/RealmApi.js.map +1 -1
  136. package/esm/api/ResourceTypesApi.js.map +1 -1
  137. package/esm/api/Saml2Api.js.map +1 -1
  138. package/esm/api/ScriptApi.js.map +1 -1
  139. package/esm/api/ServerInfoApi.js.map +1 -1
  140. package/esm/api/ServiceApi.js.map +1 -1
  141. package/esm/api/SocialIdentityProvidersApi.js.map +1 -1
  142. package/esm/api/TreeApi.js.map +1 -1
  143. package/esm/api/cloud/AdminFederationProvidersApi.js.map +1 -1
  144. package/esm/api/cloud/EnvInfoApi.js.map +1 -1
  145. package/esm/api/cloud/FeatureApi.js.map +1 -1
  146. package/esm/api/cloud/LogApi.js.map +1 -1
  147. package/esm/api/cloud/SecretsApi.js.map +1 -1
  148. package/esm/api/cloud/StartupApi.js.map +1 -1
  149. package/esm/api/cloud/VariablesApi.js.map +1 -1
  150. package/esm/api/utils/ApiUtils.js.map +1 -1
  151. package/esm/api/utils/Base64.js +4 -4
  152. package/esm/api/utils/Base64.js.map +1 -1
  153. package/esm/index.js +2 -1
  154. package/esm/index.js.map +1 -1
  155. package/esm/lib/FrodoLib.js +164 -19
  156. package/esm/lib/FrodoLib.js.map +1 -1
  157. package/esm/lib/FrodoLib.test.js +10 -10
  158. package/esm/lib/FrodoLib.test.js.map +1 -1
  159. package/esm/ops/AdminOps.js.map +1 -1
  160. package/esm/ops/AgentOps.js.map +1 -1
  161. package/esm/ops/AuthenticateOps.js +10 -10
  162. package/esm/ops/AuthenticateOps.js.map +1 -1
  163. package/esm/ops/CirclesOfTrustOps.js.map +1 -1
  164. package/esm/ops/ConnectionProfileOps.js +2 -2
  165. package/esm/ops/ConnectionProfileOps.js.map +1 -1
  166. package/esm/ops/ConnectionProfileOps.test.js +5 -5
  167. package/esm/ops/ConnectionProfileOps.test.js.map +1 -1
  168. package/esm/ops/EmailTemplateOps.js.map +1 -1
  169. package/esm/ops/IdmOps.js.map +1 -1
  170. package/esm/ops/IdpOps.js.map +1 -1
  171. package/esm/ops/InfoOps.js +2 -2
  172. package/esm/ops/InfoOps.js.map +1 -1
  173. package/esm/ops/JoseOps.js +20 -0
  174. package/esm/ops/JoseOps.js.map +1 -1
  175. package/esm/ops/JourneyOps.js +10 -11
  176. package/esm/ops/JourneyOps.js.map +1 -1
  177. package/esm/ops/JourneyOps.test.js +2 -2
  178. package/esm/ops/JourneyOps.test.js.map +1 -1
  179. package/esm/ops/ManagedObjectOps.js.map +1 -1
  180. package/esm/ops/NodeOps.js.map +1 -1
  181. package/esm/ops/OAuth2ClientOps.js.map +1 -1
  182. package/esm/ops/OAuth2OidcOps.js.map +1 -1
  183. package/esm/ops/OAuth2ProviderOps.js.map +1 -1
  184. package/esm/ops/OpsTypes.js.map +1 -1
  185. package/esm/ops/OrganizationOps.js.map +1 -1
  186. package/esm/ops/PolicyOps.js.map +1 -1
  187. package/esm/ops/PolicySetOps.js.map +1 -1
  188. package/esm/ops/RealmOps.js.map +1 -1
  189. package/esm/ops/ResourceTypeOps.js.map +1 -1
  190. package/esm/ops/Saml2Ops.js.map +1 -1
  191. package/esm/ops/Saml2Ops.test.js +2 -2
  192. package/esm/ops/Saml2Ops.test.js.map +1 -1
  193. package/esm/ops/ScriptOps.js.map +1 -1
  194. package/esm/ops/ServiceOps.js.map +1 -1
  195. package/esm/ops/ThemeOps.js.map +1 -1
  196. package/esm/ops/cloud/AdminFederationOps.js.map +1 -1
  197. package/esm/ops/cloud/FeatureOps.js.map +1 -1
  198. package/esm/ops/cloud/LogOps.js.map +1 -1
  199. package/esm/ops/cloud/SecretsOps.js.map +1 -1
  200. package/esm/ops/cloud/ServiceAccountOps.js +1 -1
  201. package/esm/ops/cloud/ServiceAccountOps.js.map +1 -1
  202. package/esm/ops/cloud/StartupOps.js.map +1 -1
  203. package/esm/ops/cloud/VariablesOps.js.map +1 -1
  204. package/esm/ops/utils/Console.js.map +1 -1
  205. package/esm/ops/utils/DataProtection.js +3 -3
  206. package/esm/ops/utils/DataProtection.js.map +1 -1
  207. package/esm/ops/utils/DataProtection.test.js +2 -2
  208. package/esm/ops/utils/DataProtection.test.js.map +1 -1
  209. package/esm/ops/utils/ExportImportUtils.js +2 -2
  210. package/esm/ops/utils/ExportImportUtils.js.map +1 -1
  211. package/esm/ops/utils/OpsUtils.js +96 -22
  212. package/esm/ops/utils/OpsUtils.js.map +1 -1
  213. package/esm/ops/utils/OpsUtils.test.js +5 -5
  214. package/esm/ops/utils/OpsUtils.test.js.map +1 -1
  215. package/esm/ops/utils/ScriptValidationUtils.js +28 -0
  216. package/esm/ops/utils/ScriptValidationUtils.js.map +1 -1
  217. package/esm/ops/utils/ScriptValidationUtils.test.js +2 -2
  218. package/esm/ops/utils/ScriptValidationUtils.test.js.map +1 -1
  219. package/esm/ops/utils/{Version.js → VersionUtils.js} +1 -1
  220. package/esm/ops/utils/VersionUtils.js.map +1 -0
  221. package/esm/ops/utils/{Version.test.js → VersionUtils.test.js} +2 -2
  222. package/esm/ops/utils/VersionUtils.test.js.map +1 -0
  223. package/esm/shared/Constants.js +27 -0
  224. package/esm/shared/Constants.js.map +1 -0
  225. package/esm/shared/State.js +481 -226
  226. package/esm/shared/State.js.map +1 -1
  227. package/esm/utils/SetupPollyForFrodoLib.js.map +1 -1
  228. package/package.json +5 -2
  229. package/types/api/AgentApi.d.ts +1 -1
  230. package/types/api/AgentApi.d.ts.map +1 -1
  231. package/types/api/AuthenticateApi.d.ts +1 -1
  232. package/types/api/AuthenticateApi.d.ts.map +1 -1
  233. package/types/api/BaseApi.d.ts +1 -1
  234. package/types/api/BaseApi.d.ts.map +1 -1
  235. package/types/api/CirclesOfTrustApi.d.ts +1 -1
  236. package/types/api/CirclesOfTrustApi.d.ts.map +1 -1
  237. package/types/api/IdmConfigApi.d.ts +1 -1
  238. package/types/api/IdmConfigApi.d.ts.map +1 -1
  239. package/types/api/IdmSystemApi.d.ts +1 -1
  240. package/types/api/IdmSystemApi.d.ts.map +1 -1
  241. package/types/api/ManagedObjectApi.d.ts +1 -1
  242. package/types/api/ManagedObjectApi.d.ts.map +1 -1
  243. package/types/api/NodeApi.d.ts +1 -1
  244. package/types/api/NodeApi.d.ts.map +1 -1
  245. package/types/api/OAuth2ClientApi.d.ts +1 -1
  246. package/types/api/OAuth2ClientApi.d.ts.map +1 -1
  247. package/types/api/OAuth2OIDCApi.d.ts +1 -1
  248. package/types/api/OAuth2OIDCApi.d.ts.map +1 -1
  249. package/types/api/OAuth2ProviderApi.d.ts +1 -1
  250. package/types/api/OAuth2ProviderApi.d.ts.map +1 -1
  251. package/types/api/PoliciesApi.d.ts +1 -1
  252. package/types/api/PoliciesApi.d.ts.map +1 -1
  253. package/types/api/PolicySetApi.d.ts +1 -1
  254. package/types/api/PolicySetApi.d.ts.map +1 -1
  255. package/types/api/RealmApi.d.ts +1 -1
  256. package/types/api/RealmApi.d.ts.map +1 -1
  257. package/types/api/ResourceTypesApi.d.ts +1 -1
  258. package/types/api/ResourceTypesApi.d.ts.map +1 -1
  259. package/types/api/Saml2Api.d.ts +1 -1
  260. package/types/api/Saml2Api.d.ts.map +1 -1
  261. package/types/api/ScriptApi.d.ts +1 -1
  262. package/types/api/ScriptApi.d.ts.map +1 -1
  263. package/types/api/ServerInfoApi.d.ts +1 -1
  264. package/types/api/ServerInfoApi.d.ts.map +1 -1
  265. package/types/api/ServiceApi.d.ts +1 -1
  266. package/types/api/ServiceApi.d.ts.map +1 -1
  267. package/types/api/SocialIdentityProvidersApi.d.ts +1 -1
  268. package/types/api/SocialIdentityProvidersApi.d.ts.map +1 -1
  269. package/types/api/TreeApi.d.ts +1 -1
  270. package/types/api/TreeApi.d.ts.map +1 -1
  271. package/types/api/cloud/AdminFederationProvidersApi.d.ts +1 -1
  272. package/types/api/cloud/AdminFederationProvidersApi.d.ts.map +1 -1
  273. package/types/api/cloud/EnvInfoApi.d.ts +1 -1
  274. package/types/api/cloud/EnvInfoApi.d.ts.map +1 -1
  275. package/types/api/cloud/FeatureApi.d.ts +1 -1
  276. package/types/api/cloud/FeatureApi.d.ts.map +1 -1
  277. package/types/api/cloud/LogApi.d.ts +1 -1
  278. package/types/api/cloud/LogApi.d.ts.map +1 -1
  279. package/types/api/cloud/SecretsApi.d.ts +1 -1
  280. package/types/api/cloud/SecretsApi.d.ts.map +1 -1
  281. package/types/api/cloud/StartupApi.d.ts +1 -1
  282. package/types/api/cloud/StartupApi.d.ts.map +1 -1
  283. package/types/api/cloud/VariablesApi.d.ts +1 -1
  284. package/types/api/cloud/VariablesApi.d.ts.map +1 -1
  285. package/types/api/utils/ApiUtils.d.ts +1 -1
  286. package/types/api/utils/ApiUtils.d.ts.map +1 -1
  287. package/types/api/utils/Base64.d.ts +6 -6
  288. package/types/api/utils/Base64.d.ts.map +1 -1
  289. package/types/index.d.ts +2 -1
  290. package/types/index.d.ts.map +1 -1
  291. package/types/lib/FrodoLib.d.ts +224 -370
  292. package/types/lib/FrodoLib.d.ts.map +1 -1
  293. package/types/ops/AdminOps.d.ts +3 -2
  294. package/types/ops/AdminOps.d.ts.map +1 -1
  295. package/types/ops/AgentOps.d.ts +3 -2
  296. package/types/ops/AgentOps.d.ts.map +1 -1
  297. package/types/ops/AuthenticateOps.d.ts +3 -2
  298. package/types/ops/AuthenticateOps.d.ts.map +1 -1
  299. package/types/ops/CirclesOfTrustOps.d.ts +3 -2
  300. package/types/ops/CirclesOfTrustOps.d.ts.map +1 -1
  301. package/types/ops/ConnectionProfileOps.d.ts +3 -2
  302. package/types/ops/ConnectionProfileOps.d.ts.map +1 -1
  303. package/types/ops/EmailTemplateOps.d.ts +3 -2
  304. package/types/ops/EmailTemplateOps.d.ts.map +1 -1
  305. package/types/ops/IdmOps.d.ts +3 -2
  306. package/types/ops/IdmOps.d.ts.map +1 -1
  307. package/types/ops/IdpOps.d.ts +3 -2
  308. package/types/ops/IdpOps.d.ts.map +1 -1
  309. package/types/ops/InfoOps.d.ts +3 -2
  310. package/types/ops/InfoOps.d.ts.map +1 -1
  311. package/types/ops/JoseOps.d.ts +17 -1
  312. package/types/ops/JoseOps.d.ts.map +1 -1
  313. package/types/ops/JourneyOps.d.ts +16 -10
  314. package/types/ops/JourneyOps.d.ts.map +1 -1
  315. package/types/ops/ManagedObjectOps.d.ts +3 -2
  316. package/types/ops/ManagedObjectOps.d.ts.map +1 -1
  317. package/types/ops/NodeOps.d.ts +3 -2
  318. package/types/ops/NodeOps.d.ts.map +1 -1
  319. package/types/ops/OAuth2ClientOps.d.ts +3 -2
  320. package/types/ops/OAuth2ClientOps.d.ts.map +1 -1
  321. package/types/ops/OAuth2OidcOps.d.ts +6 -5
  322. package/types/ops/OAuth2OidcOps.d.ts.map +1 -1
  323. package/types/ops/OAuth2ProviderOps.d.ts +3 -2
  324. package/types/ops/OAuth2ProviderOps.d.ts.map +1 -1
  325. package/types/ops/OpsTypes.d.ts +1 -1
  326. package/types/ops/OpsTypes.d.ts.map +1 -1
  327. package/types/ops/OrganizationOps.d.ts +3 -2
  328. package/types/ops/OrganizationOps.d.ts.map +1 -1
  329. package/types/ops/PolicyOps.d.ts +3 -2
  330. package/types/ops/PolicyOps.d.ts.map +1 -1
  331. package/types/ops/PolicySetOps.d.ts +3 -2
  332. package/types/ops/PolicySetOps.d.ts.map +1 -1
  333. package/types/ops/RealmOps.d.ts +3 -2
  334. package/types/ops/RealmOps.d.ts.map +1 -1
  335. package/types/ops/ResourceTypeOps.d.ts +3 -2
  336. package/types/ops/ResourceTypeOps.d.ts.map +1 -1
  337. package/types/ops/Saml2Ops.d.ts +3 -2
  338. package/types/ops/Saml2Ops.d.ts.map +1 -1
  339. package/types/ops/ScriptOps.d.ts +3 -2
  340. package/types/ops/ScriptOps.d.ts.map +1 -1
  341. package/types/ops/ServiceOps.d.ts +4 -3
  342. package/types/ops/ServiceOps.d.ts.map +1 -1
  343. package/types/ops/ThemeOps.d.ts +3 -2
  344. package/types/ops/ThemeOps.d.ts.map +1 -1
  345. package/types/ops/cloud/AdminFederationOps.d.ts +3 -2
  346. package/types/ops/cloud/AdminFederationOps.d.ts.map +1 -1
  347. package/types/ops/cloud/FeatureOps.d.ts +3 -2
  348. package/types/ops/cloud/FeatureOps.d.ts.map +1 -1
  349. package/types/ops/cloud/LogOps.d.ts +3 -2
  350. package/types/ops/cloud/LogOps.d.ts.map +1 -1
  351. package/types/ops/cloud/SecretsOps.d.ts +3 -2
  352. package/types/ops/cloud/SecretsOps.d.ts.map +1 -1
  353. package/types/ops/cloud/ServiceAccountOps.d.ts +7 -6
  354. package/types/ops/cloud/ServiceAccountOps.d.ts.map +1 -1
  355. package/types/ops/cloud/StartupOps.d.ts +3 -2
  356. package/types/ops/cloud/StartupOps.d.ts.map +1 -1
  357. package/types/ops/cloud/VariablesOps.d.ts +3 -2
  358. package/types/ops/cloud/VariablesOps.d.ts.map +1 -1
  359. package/types/ops/utils/Console.d.ts +1 -1
  360. package/types/ops/utils/Console.d.ts.map +1 -1
  361. package/types/ops/utils/DataProtection.d.ts +1 -1
  362. package/types/ops/utils/DataProtection.d.ts.map +1 -1
  363. package/types/ops/utils/ExportImportUtils.d.ts +3 -2
  364. package/types/ops/utils/ExportImportUtils.d.ts.map +1 -1
  365. package/types/ops/utils/OpsUtils.d.ts +73 -17
  366. package/types/ops/utils/OpsUtils.d.ts.map +1 -1
  367. package/types/ops/utils/ScriptValidationUtils.d.ts +20 -1
  368. package/types/ops/utils/ScriptValidationUtils.d.ts.map +1 -1
  369. package/types/ops/utils/{Version.d.ts → VersionUtils.d.ts} +4 -4
  370. package/types/ops/utils/VersionUtils.d.ts.map +1 -0
  371. package/types/shared/Constants.d.ts +34 -0
  372. package/types/shared/Constants.d.ts.map +1 -0
  373. package/types/shared/State.d.ts +38 -38
  374. package/types/shared/State.d.ts.map +1 -1
  375. package/types/utils/SetupPollyForFrodoLib.d.ts +1 -1
  376. package/types/utils/SetupPollyForFrodoLib.d.ts.map +1 -1
  377. package/cjs/lib/Frodo.js +0 -85
  378. package/cjs/lib/Frodo.js.map +0 -1
  379. package/cjs/ops/utils/Version.js.map +0 -1
  380. package/cjs/ops/utils/Version.test.js.map +0 -1
  381. package/cjs/ops/utils/Wordwrap.js +0 -12
  382. package/cjs/ops/utils/Wordwrap.js.map +0 -1
  383. package/cjs/ops/utils/Wordwrap.test.js +0 -22
  384. package/cjs/ops/utils/Wordwrap.test.js.map +0 -1
  385. package/cjs/storage/StaticStorage.js +0 -31
  386. package/cjs/storage/StaticStorage.js.map +0 -1
  387. package/esm/lib/Frodo.js +0 -59
  388. package/esm/lib/Frodo.js.map +0 -1
  389. package/esm/ops/utils/Version.js.map +0 -1
  390. package/esm/ops/utils/Version.test.js.map +0 -1
  391. package/esm/ops/utils/Wordwrap.js +0 -5
  392. package/esm/ops/utils/Wordwrap.js.map +0 -1
  393. package/esm/ops/utils/Wordwrap.test.js +0 -19
  394. package/esm/ops/utils/Wordwrap.test.js.map +0 -1
  395. package/esm/storage/StaticStorage.js +0 -15
  396. package/esm/storage/StaticStorage.js.map +0 -1
  397. package/types/lib/Frodo.d.ts +0 -1159
  398. package/types/lib/Frodo.d.ts.map +0 -1
  399. package/types/ops/utils/Version.d.ts.map +0 -1
  400. package/types/ops/utils/Wordwrap.d.ts +0 -2
  401. package/types/ops/utils/Wordwrap.d.ts.map +0 -1
  402. package/types/storage/StaticStorage.d.ts +0 -15
  403. package/types/storage/StaticStorage.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ScriptOps.js","names":["v4","uuidv4","applyNameCollisionPolicy","createProgressIndicator","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","getScript","getScriptByName","_getScriptByName","getScripts","_getScripts","putScript","_putScript","deleteScript","convertBase64TextToArray","convertTextArrayToBase64","getMetadata","validateScriptDecoded","state","scriptName","scriptId","scriptData","exportScript","exportScriptByName","exportScripts","importScripts","importData","reUuid","validate","createScriptExportTemplate","meta","script","result","length","Error","Array","isArray","error","_error$response","response","status","message","name","type","newName","exportData","_id","scriptList","total","outcome","existingId","Object","keys","scriptSkeleton","newId"],"sources":["../../src/ops/ScriptOps.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid';\nimport { applyNameCollisionPolicy } from './utils/OpsUtils';\nimport {\n createProgressIndicator,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from './utils/Console';\nimport {\n getScript,\n getScriptByName as _getScriptByName,\n getScripts as _getScripts,\n putScript as _putScript,\n deleteScript,\n} from '../api/ScriptApi';\nimport {\n convertBase64TextToArray,\n convertTextArrayToBase64,\n getMetadata,\n} from './utils/ExportImportUtils';\nimport { ScriptSkeleton } from '../api/ApiTypes';\nimport { ExportMetaData } from '../ops/OpsTypes';\nimport { validateScriptDecoded } from './utils/ScriptValidationUtils';\nimport State from '../shared/State';\n\nexport default (state: State) => {\n return {\n /**\n * Get all scripts\n * @returns {Promise<ScriptSkeleton[]>} a promise that resolves to an array of script objects\n */\n async getScripts(): Promise<ScriptSkeleton[]> {\n return getScripts({ state });\n },\n\n /**\n * Get script by name\n * @param {string} name name of the script\n * @returns {Promise<ScriptSkeleton>} promise that resolves to a script object\n */\n async getScriptByName(scriptName: string): Promise<ScriptSkeleton> {\n return getScriptByName({ scriptName, state });\n },\n\n /**\n * Create or update script\n * @param {string} scriptId script uuid\n * @param {ScriptSkeleton} scriptData script object\n * @returns {Promise<boolean>} a status object\n */\n async putScript(\n scriptId: string,\n scriptData: ScriptSkeleton\n ): Promise<boolean> {\n return putScript({ scriptId, scriptData, state });\n },\n\n /**\n * Export script by id\n * @param {string} scriptId script uuid\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\n async exportScript(scriptId: string): Promise<ScriptExportInterface> {\n return exportScript({ scriptId, state });\n },\n\n /**\n * Export script by name\n * @param {string} name script name\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\n async exportScriptByName(\n scriptName: string\n ): Promise<ScriptExportInterface> {\n return exportScriptByName({ scriptName, state });\n },\n\n /**\n * Export all scripts\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\n async exportScripts(): Promise<ScriptExportInterface> {\n return exportScripts({ state });\n },\n\n /**\n * Import scripts\n * @param {string} scriptName Optional name of script. If supplied, only the script of that name is imported\n * @param {ScriptExportInterface} importData Script import data\n * @param {boolean} reUuid true to generate a new uuid for each script on import, false otherwise\n * @returns {Promise<boolean>} true if no errors occurred during import, false otherwise\n */\n async importScripts(\n scriptName: string,\n importData: ScriptExportInterface,\n reUuid = false,\n validate = false\n ): Promise<boolean> {\n return importScripts({\n scriptName,\n importData,\n reUuid,\n validate,\n state,\n });\n },\n\n getScript(scriptId: string) {\n return getScript({ scriptId, state });\n },\n\n deleteScript(scriptId: string) {\n return deleteScript({ scriptId, state });\n },\n };\n};\n\nexport interface ScriptExportInterface {\n meta?: ExportMetaData;\n script: Record<string, ScriptSkeleton>;\n}\n\n/**\n * Create an empty idp export template\n * @returns {ScriptExportInterface} an empty idp export template\n */\nexport function createScriptExportTemplate({\n state,\n}: {\n state: State;\n}): ScriptExportInterface {\n return {\n meta: getMetadata({ state }),\n script: {},\n } as ScriptExportInterface;\n}\n\n/**\n * Get all scripts\n * @returns {Promise<ScriptSkeleton[]>} a promise that resolves to an array of script objects\n */\nexport async function getScripts({\n state,\n}: {\n state: State;\n}): Promise<ScriptSkeleton[]> {\n const { result } = await _getScripts({ state });\n return result;\n}\n\n/**\n * Get script by name\n * @param {string} scriptName name of the script\n * @returns {Promise<ScriptSkeleton>} promise that resolves to a script object\n */\nexport async function getScriptByName({\n scriptName,\n state,\n}: {\n scriptName: string;\n state: State;\n}): Promise<ScriptSkeleton> {\n const { result } = await _getScriptByName({ scriptName, state });\n switch (result.length) {\n case 1:\n return result[0];\n case 0:\n throw new Error(`Script '${scriptName}' not found`);\n default:\n throw new Error(`${result.length} scripts '${scriptName}' found`);\n }\n}\n\n/**\n * Create or update script\n * @param {string} scriptId script uuid\n * @param {ScriptSkeleton} scriptData script object\n * @returns {Promise<boolean>} a status object\n */\nexport async function putScript({\n scriptId,\n scriptData,\n state,\n}: {\n scriptId: string;\n scriptData: ScriptSkeleton;\n state: State;\n}): Promise<boolean> {\n try {\n if (Array.isArray(scriptData.script)) {\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n }\n const result = await _putScript({ scriptId, scriptData, state });\n return result;\n } catch (error) {\n if (error.response?.status === 409) {\n printMessage({\n message: `createOrUpdateScript WARNING: script with name ${scriptData.name} already exists, using renaming policy... <name> => <name - imported (n)>`,\n type: 'warn',\n state,\n });\n const newName = applyNameCollisionPolicy(scriptData.name);\n scriptData.name = newName;\n const result = await putScript({ scriptId, scriptData, state });\n printMessage({\n message: `Saved script as ${newName}`,\n type: 'warn',\n state,\n });\n return result;\n }\n throw error;\n }\n}\n\n/**\n * Export script by id\n * @param {string} scriptId script uuid\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\nexport async function exportScript({\n scriptId,\n state,\n}: {\n scriptId: string;\n state: State;\n}): Promise<ScriptExportInterface> {\n debugMessage({ message: `ScriptOps.exportScriptById: start`, state });\n const scriptData = await getScript({ scriptId, state });\n scriptData.script = convertBase64TextToArray(scriptData.script);\n const exportData = createScriptExportTemplate({ state });\n exportData.script[scriptData._id] = scriptData;\n debugMessage({ message: `ScriptOps.exportScriptById: end`, state });\n return exportData;\n}\n\n/**\n * Export script by name\n * @param {string} scriptName script name\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\nexport async function exportScriptByName({\n scriptName,\n state,\n}: {\n scriptName: string;\n state: State;\n}): Promise<ScriptExportInterface> {\n debugMessage({ message: `ScriptOps.exportScriptByName: start`, state });\n const scriptData = await getScriptByName({ scriptName, state });\n scriptData.script = convertBase64TextToArray(scriptData.script as string);\n const exportData = createScriptExportTemplate({ state });\n exportData.script[scriptData._id] = scriptData;\n debugMessage({ message: `ScriptOps.exportScriptByName: end`, state });\n return exportData;\n}\n\n/**\n * Export all scripts\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\nexport async function exportScripts({\n state,\n}: {\n state: State;\n}): Promise<ScriptExportInterface> {\n const scriptList = await getScripts({ state });\n const exportData = createScriptExportTemplate({ state });\n createProgressIndicator({\n total: scriptList.length,\n message: `Exporting ${scriptList.length} scripts...`,\n state,\n });\n for (const script of scriptList) {\n updateProgressIndicator({\n message: `Reading script ${script.name}`,\n state,\n });\n const scriptData = await getScriptByName({\n scriptName: script.name,\n state,\n });\n scriptData.script = convertBase64TextToArray(scriptData.script as string);\n exportData.script[scriptData._id] = scriptData;\n }\n stopProgressIndicator({\n message: `Exported ${scriptList.length} scripts.`,\n state,\n });\n return exportData;\n}\n\n/**\n * Import scripts\n * @param {string} scriptName Optional name of script. If supplied, only the script of that name is imported\n * @param {ScriptExportInterface} importData Script import data\n * @param {boolean} reUuid true to generate a new uuid for each script on import, false otherwise\n * @returns {Promise<boolean>} true if no errors occurred during import, false otherwise\n */\nexport async function importScripts({\n scriptName,\n importData,\n reUuid = false,\n validate = false,\n state,\n}: {\n scriptName: string;\n importData: ScriptExportInterface;\n reUuid?: boolean;\n validate?: boolean;\n state: State;\n}): Promise<boolean> {\n let outcome = true;\n debugMessage({ message: `ScriptOps.importScripts: start`, state });\n for (const existingId of Object.keys(importData.script)) {\n const scriptSkeleton = importData.script[existingId];\n let newId = existingId;\n if (reUuid) {\n newId = uuidv4();\n debugMessage({\n message: `ScriptOps.importScripts: Re-uuid-ing script ${scriptSkeleton.name} ${existingId} => ${newId}...`,\n state,\n });\n scriptSkeleton._id = newId;\n }\n if (scriptName) {\n debugMessage({\n message: `ScriptOps.importScripts: Renaming script ${scriptSkeleton.name} => ${scriptName}...`,\n state,\n });\n scriptSkeleton.name = scriptName;\n }\n if (validate) {\n if (!validateScriptDecoded({ scriptSkeleton, state })) {\n outcome = false;\n printMessage({\n message: `Error importing script '${scriptSkeleton.name}': Script is not valid`,\n type: 'error',\n state,\n });\n continue;\n }\n }\n try {\n await putScript({ scriptId: newId, scriptData: scriptSkeleton, state });\n } catch (error) {\n outcome = false;\n printMessage({\n message: `Error importing script '${scriptSkeleton.name}': ${error.message}`,\n type: 'error',\n state,\n });\n debugMessage({ message: error, state });\n }\n if (scriptName) break;\n }\n debugMessage({ message: `ScriptOps.importScripts: end`, state });\n return outcome;\n}\n\nexport { getScript, deleteScript };\n"],"mappings":"AAAA,SAASA,EAAE,IAAIC,MAAM,QAAQ,MAAM;AAAC,SAC3BC,wBAAwB;AAAA,SAE/BC,uBAAuB,EACvBC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB;AAAA,SAGvBC,SAAS,EACTC,eAAe,IAAIC,gBAAgB,EACnCC,UAAU,IAAIC,WAAW,EACzBC,SAAS,IAAIC,UAAU,EACvBC,YAAY;AAAA,SAGZC,wBAAwB,EACxBC,wBAAwB,EACxBC,WAAW;AAAA,SAIJC,qBAAqB;AAG9B,gBAAgBC,KAAY,IAAK;EAC/B,OAAO;IACL;AACJ;AACA;AACA;IACI,MAAMT,UAAUA,CAAA,EAA8B;MAC5C,OAAOA,UAAU,CAAC;QAAES;MAAM,CAAC,CAAC;IAC9B,CAAC;IAED;AACJ;AACA;AACA;AACA;IACI,MAAMX,eAAeA,CAACY,UAAkB,EAA2B;MACjE,OAAOZ,eAAe,CAAC;QAAEY,UAAU;QAAED;MAAM,CAAC,CAAC;IAC/C,CAAC;IAED;AACJ;AACA;AACA;AACA;AACA;IACI,MAAMP,SAASA,CACbS,QAAgB,EAChBC,UAA0B,EACR;MAClB,OAAOV,SAAS,CAAC;QAAES,QAAQ;QAAEC,UAAU;QAAEH;MAAM,CAAC,CAAC;IACnD,CAAC;IAED;AACJ;AACA;AACA;AACA;IACI,MAAMI,YAAYA,CAACF,QAAgB,EAAkC;MACnE,OAAOE,YAAY,CAAC;QAAEF,QAAQ;QAAEF;MAAM,CAAC,CAAC;IAC1C,CAAC;IAED;AACJ;AACA;AACA;AACA;IACI,MAAMK,kBAAkBA,CACtBJ,UAAkB,EACc;MAChC,OAAOI,kBAAkB,CAAC;QAAEJ,UAAU;QAAED;MAAM,CAAC,CAAC;IAClD,CAAC;IAED;AACJ;AACA;AACA;IACI,MAAMM,aAAaA,CAAA,EAAmC;MACpD,OAAOA,aAAa,CAAC;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,SAAS,EAAEO,YAAY"}
1
+ {"version":3,"file":"ScriptOps.js","names":["v4","uuidv4","applyNameCollisionPolicy","createProgressIndicator","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","getScript","getScriptByName","_getScriptByName","getScripts","_getScripts","putScript","_putScript","deleteScript","convertBase64TextToArray","convertTextArrayToBase64","getMetadata","validateScriptDecoded","state","scriptName","scriptId","scriptData","exportScript","exportScriptByName","exportScripts","importScripts","importData","reUuid","validate","createScriptExportTemplate","meta","script","result","length","Error","Array","isArray","error","_error$response","response","status","message","name","type","newName","exportData","_id","scriptList","total","outcome","existingId","Object","keys","scriptSkeleton","newId"],"sources":["../../src/ops/ScriptOps.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid';\nimport { applyNameCollisionPolicy } from './utils/OpsUtils';\nimport {\n createProgressIndicator,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from './utils/Console';\nimport {\n getScript,\n getScriptByName as _getScriptByName,\n getScripts as _getScripts,\n putScript as _putScript,\n deleteScript,\n} from '../api/ScriptApi';\nimport {\n convertBase64TextToArray,\n convertTextArrayToBase64,\n getMetadata,\n} from './utils/ExportImportUtils';\nimport { ScriptSkeleton } from '../api/ApiTypes';\nimport { ExportMetaData } from '../ops/OpsTypes';\nimport { validateScriptDecoded } from './utils/ScriptValidationUtils';\nimport { State } from '../shared/State';\n\nexport type Script = {\n /**\n * Get all scripts\n * @returns {Promise<ScriptSkeleton[]>} a promise that resolves to an array of script objects\n */\n getScripts(): Promise<ScriptSkeleton[]>;\n /**\n * Get script by name\n * @param {string} name name of the script\n * @returns {Promise<ScriptSkeleton>} promise that resolves to a script object\n */\n getScriptByName(scriptName: string): Promise<ScriptSkeleton>;\n /**\n * Create or update script\n * @param {string} scriptId script uuid\n * @param {ScriptSkeleton} scriptData script object\n * @returns {Promise<boolean>} a status object\n */\n putScript(scriptId: string, scriptData: ScriptSkeleton): Promise<boolean>;\n /**\n * Export script by id\n * @param {string} scriptId script uuid\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\n exportScript(scriptId: string): Promise<ScriptExportInterface>;\n /**\n * Export script by name\n * @param {string} name script name\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\n exportScriptByName(scriptName: string): Promise<ScriptExportInterface>;\n /**\n * Export all scripts\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\n exportScripts(): Promise<ScriptExportInterface>;\n /**\n * Import scripts\n * @param {string} scriptName Optional name of script. If supplied, only the script of that name is imported\n * @param {ScriptExportInterface} importData Script import data\n * @param {boolean} reUuid true to generate a new uuid for each script on import, false otherwise\n * @returns {Promise<boolean>} true if no errors occurred during import, false otherwise\n */\n importScripts(\n scriptName: string,\n importData: ScriptExportInterface,\n reUuid?: boolean,\n validate?: boolean\n ): Promise<boolean>;\n getScript(scriptId: string): Promise<any>;\n deleteScript(scriptId: string): Promise<any>;\n};\n\nexport default (state: State): Script => {\n return {\n /**\n * Get all scripts\n * @returns {Promise<ScriptSkeleton[]>} a promise that resolves to an array of script objects\n */\n async getScripts(): Promise<ScriptSkeleton[]> {\n return getScripts({ state });\n },\n\n /**\n * Get script by name\n * @param {string} name name of the script\n * @returns {Promise<ScriptSkeleton>} promise that resolves to a script object\n */\n async getScriptByName(scriptName: string): Promise<ScriptSkeleton> {\n return getScriptByName({ scriptName, state });\n },\n\n /**\n * Create or update script\n * @param {string} scriptId script uuid\n * @param {ScriptSkeleton} scriptData script object\n * @returns {Promise<boolean>} a status object\n */\n async putScript(\n scriptId: string,\n scriptData: ScriptSkeleton\n ): Promise<boolean> {\n return putScript({ scriptId, scriptData, state });\n },\n\n /**\n * Export script by id\n * @param {string} scriptId script uuid\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\n async exportScript(scriptId: string): Promise<ScriptExportInterface> {\n return exportScript({ scriptId, state });\n },\n\n /**\n * Export script by name\n * @param {string} name script name\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\n async exportScriptByName(\n scriptName: string\n ): Promise<ScriptExportInterface> {\n return exportScriptByName({ scriptName, state });\n },\n\n /**\n * Export all scripts\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\n async exportScripts(): Promise<ScriptExportInterface> {\n return exportScripts({ state });\n },\n\n /**\n * Import scripts\n * @param {string} scriptName Optional name of script. If supplied, only the script of that name is imported\n * @param {ScriptExportInterface} importData Script import data\n * @param {boolean} reUuid true to generate a new uuid for each script on import, false otherwise\n * @returns {Promise<boolean>} true if no errors occurred during import, false otherwise\n */\n async importScripts(\n scriptName: string,\n importData: ScriptExportInterface,\n reUuid = false,\n validate = false\n ): Promise<boolean> {\n return importScripts({\n scriptName,\n importData,\n reUuid,\n validate,\n state,\n });\n },\n\n getScript(scriptId: string) {\n return getScript({ scriptId, state });\n },\n\n deleteScript(scriptId: string) {\n return deleteScript({ scriptId, state });\n },\n };\n};\n\nexport interface ScriptExportInterface {\n meta?: ExportMetaData;\n script: Record<string, ScriptSkeleton>;\n}\n\n/**\n * Create an empty idp export template\n * @returns {ScriptExportInterface} an empty idp export template\n */\nexport function createScriptExportTemplate({\n state,\n}: {\n state: State;\n}): ScriptExportInterface {\n return {\n meta: getMetadata({ state }),\n script: {},\n } as ScriptExportInterface;\n}\n\n/**\n * Get all scripts\n * @returns {Promise<ScriptSkeleton[]>} a promise that resolves to an array of script objects\n */\nexport async function getScripts({\n state,\n}: {\n state: State;\n}): Promise<ScriptSkeleton[]> {\n const { result } = await _getScripts({ state });\n return result;\n}\n\n/**\n * Get script by name\n * @param {string} scriptName name of the script\n * @returns {Promise<ScriptSkeleton>} promise that resolves to a script object\n */\nexport async function getScriptByName({\n scriptName,\n state,\n}: {\n scriptName: string;\n state: State;\n}): Promise<ScriptSkeleton> {\n const { result } = await _getScriptByName({ scriptName, state });\n switch (result.length) {\n case 1:\n return result[0];\n case 0:\n throw new Error(`Script '${scriptName}' not found`);\n default:\n throw new Error(`${result.length} scripts '${scriptName}' found`);\n }\n}\n\n/**\n * Create or update script\n * @param {string} scriptId script uuid\n * @param {ScriptSkeleton} scriptData script object\n * @returns {Promise<boolean>} a status object\n */\nexport async function putScript({\n scriptId,\n scriptData,\n state,\n}: {\n scriptId: string;\n scriptData: ScriptSkeleton;\n state: State;\n}): Promise<boolean> {\n try {\n if (Array.isArray(scriptData.script)) {\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n }\n const result = await _putScript({ scriptId, scriptData, state });\n return result;\n } catch (error) {\n if (error.response?.status === 409) {\n printMessage({\n message: `createOrUpdateScript WARNING: script with name ${scriptData.name} already exists, using renaming policy... <name> => <name - imported (n)>`,\n type: 'warn',\n state,\n });\n const newName = applyNameCollisionPolicy(scriptData.name);\n scriptData.name = newName;\n const result = await putScript({ scriptId, scriptData, state });\n printMessage({\n message: `Saved script as ${newName}`,\n type: 'warn',\n state,\n });\n return result;\n }\n throw error;\n }\n}\n\n/**\n * Export script by id\n * @param {string} scriptId script uuid\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\nexport async function exportScript({\n scriptId,\n state,\n}: {\n scriptId: string;\n state: State;\n}): Promise<ScriptExportInterface> {\n debugMessage({ message: `ScriptOps.exportScriptById: start`, state });\n const scriptData = await getScript({ scriptId, state });\n scriptData.script = convertBase64TextToArray(scriptData.script);\n const exportData = createScriptExportTemplate({ state });\n exportData.script[scriptData._id] = scriptData;\n debugMessage({ message: `ScriptOps.exportScriptById: end`, state });\n return exportData;\n}\n\n/**\n * Export script by name\n * @param {string} scriptName script name\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\nexport async function exportScriptByName({\n scriptName,\n state,\n}: {\n scriptName: string;\n state: State;\n}): Promise<ScriptExportInterface> {\n debugMessage({ message: `ScriptOps.exportScriptByName: start`, state });\n const scriptData = await getScriptByName({ scriptName, state });\n scriptData.script = convertBase64TextToArray(scriptData.script as string);\n const exportData = createScriptExportTemplate({ state });\n exportData.script[scriptData._id] = scriptData;\n debugMessage({ message: `ScriptOps.exportScriptByName: end`, state });\n return exportData;\n}\n\n/**\n * Export all scripts\n * @returns {Promise<ScriptExportInterface>} a promise that resolved to a ScriptExportInterface object\n */\nexport async function exportScripts({\n state,\n}: {\n state: State;\n}): Promise<ScriptExportInterface> {\n const scriptList = await getScripts({ state });\n const exportData = createScriptExportTemplate({ state });\n createProgressIndicator({\n total: scriptList.length,\n message: `Exporting ${scriptList.length} scripts...`,\n state,\n });\n for (const script of scriptList) {\n updateProgressIndicator({\n message: `Reading script ${script.name}`,\n state,\n });\n const scriptData = await getScriptByName({\n scriptName: script.name,\n state,\n });\n scriptData.script = convertBase64TextToArray(scriptData.script as string);\n exportData.script[scriptData._id] = scriptData;\n }\n stopProgressIndicator({\n message: `Exported ${scriptList.length} scripts.`,\n state,\n });\n return exportData;\n}\n\n/**\n * Import scripts\n * @param {string} scriptName Optional name of script. If supplied, only the script of that name is imported\n * @param {ScriptExportInterface} importData Script import data\n * @param {boolean} reUuid true to generate a new uuid for each script on import, false otherwise\n * @returns {Promise<boolean>} true if no errors occurred during import, false otherwise\n */\nexport async function importScripts({\n scriptName,\n importData,\n reUuid = false,\n validate = false,\n state,\n}: {\n scriptName: string;\n importData: ScriptExportInterface;\n reUuid?: boolean;\n validate?: boolean;\n state: State;\n}): Promise<boolean> {\n let outcome = true;\n debugMessage({ message: `ScriptOps.importScripts: start`, state });\n for (const existingId of Object.keys(importData.script)) {\n const scriptSkeleton = importData.script[existingId];\n let newId = existingId;\n if (reUuid) {\n newId = uuidv4();\n debugMessage({\n message: `ScriptOps.importScripts: Re-uuid-ing script ${scriptSkeleton.name} ${existingId} => ${newId}...`,\n state,\n });\n scriptSkeleton._id = newId;\n }\n if (scriptName) {\n debugMessage({\n message: `ScriptOps.importScripts: Renaming script ${scriptSkeleton.name} => ${scriptName}...`,\n state,\n });\n scriptSkeleton.name = scriptName;\n }\n if (validate) {\n if (!validateScriptDecoded({ scriptSkeleton, state })) {\n outcome = false;\n printMessage({\n message: `Error importing script '${scriptSkeleton.name}': Script is not valid`,\n type: 'error',\n state,\n });\n continue;\n }\n }\n try {\n await putScript({ scriptId: newId, scriptData: scriptSkeleton, state });\n } catch (error) {\n outcome = false;\n printMessage({\n message: `Error importing script '${scriptSkeleton.name}': ${error.message}`,\n type: 'error',\n state,\n });\n debugMessage({ message: error, state });\n }\n if (scriptName) break;\n }\n debugMessage({ message: `ScriptOps.importScripts: end`, state });\n return outcome;\n}\n\nexport { getScript, deleteScript };\n"],"mappings":"AAAA,SAASA,EAAE,IAAIC,MAAM,QAAQ,MAAM;AAAC,SAC3BC,wBAAwB;AAAA,SAE/BC,uBAAuB,EACvBC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB;AAAA,SAGvBC,SAAS,EACTC,eAAe,IAAIC,gBAAgB,EACnCC,UAAU,IAAIC,WAAW,EACzBC,SAAS,IAAIC,UAAU,EACvBC,YAAY;AAAA,SAGZC,wBAAwB,EACxBC,wBAAwB,EACxBC,WAAW;AAAA,SAIJC,qBAAqB;AAwD9B,gBAAgBC,KAAY,IAAa;EACvC,OAAO;IACL;AACJ;AACA;AACA;IACI,MAAMT,UAAUA,CAAA,EAA8B;MAC5C,OAAOA,UAAU,CAAC;QAAES;MAAM,CAAC,CAAC;IAC9B,CAAC;IAED;AACJ;AACA;AACA;AACA;IACI,MAAMX,eAAeA,CAACY,UAAkB,EAA2B;MACjE,OAAOZ,eAAe,CAAC;QAAEY,UAAU;QAAED;MAAM,CAAC,CAAC;IAC/C,CAAC;IAED;AACJ;AACA;AACA;AACA;AACA;IACI,MAAMP,SAASA,CACbS,QAAgB,EAChBC,UAA0B,EACR;MAClB,OAAOV,SAAS,CAAC;QAAES,QAAQ;QAAEC,UAAU;QAAEH;MAAM,CAAC,CAAC;IACnD,CAAC;IAED;AACJ;AACA;AACA;AACA;IACI,MAAMI,YAAYA,CAACF,QA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IAAK,MAAKL,KAAK,CAACI,OAAQ,EAAC;QAC5EE,IAAI,EAAE,OAAO;QACbzB;MACF,CAAC,CAAC;MACFhB,YAAY,CAAC;QAAEuC,OAAO,EAAEJ,KAAK;QAAEnB;MAAM,CAAC,CAAC;IACzC;IACA,IAAIC,UAAU,EAAE;EAClB;EACAjB,YAAY,CAAC;IAAEuC,OAAO,EAAG,8BAA6B;IAAEvB;EAAM,CAAC,CAAC;EAChE,OAAO+B,OAAO;AAChB;AAEA,SAAS3C,SAAS,EAAEO,YAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceOps.js","names":["deleteService","deleteServiceNextDescendent","getService","getListOfServices","_getListOfServices","getServiceDescendents","putService","putServiceNextDescendent","debugMessage","printMessage","state","createServiceExportTemplate","globalConfig","getFullServices","deleteFullService","serviceId","deleteFullServices","exportService","exportServices","importService","importData","clean","importServices","meta","service","message","services","result","serviceList","fullServiceData","Promise","all","map","listItem","nextDescendents","_id","error","_error$response","_error$response2","_error$response2$data","response","status","data","_error$response3","_error$response3$data","type","filter","putFullService","_rev","enabled","_error$response4","_error$response5","_error$response5$data","_error$response6","_error$response6$data","serviceData","length","descendent","_type","descendentId","undefined","serviceType","serviceNextDescendentId","serviceNextDescendentData","_error$response7","_error$response7$data","putFullServices","serviceEntries","results","id","push","_error$response8","_error$response8$data","_error$response9","_error$response9$data","detail","JSON","stringify","nextDescendent","serviceListItem","_error$response10","_error$response11","_error$response11$dat","_error$response12","_error$response12$dat","_error$response13","_error$response13$dat","exportData","_error$response14","_error$response14$dat","_error$response15","_error$response15$dat","Object","entries","_error$response16","_error$response16$dat","_error$response17","_error$response17$dat"],"sources":["../../src/ops/ServiceOps.ts"],"sourcesContent":["import { AmServiceSkeleton, FullService } from '../api/ApiTypes';\nimport {\n deleteService,\n deleteServiceNextDescendent,\n getService,\n getListOfServices as _getListOfServices,\n getServiceDescendents,\n putService,\n putServiceNextDescendent,\n} from '../api/ServiceApi';\nimport State from '../shared/State';\nimport { ServiceExportInterface } from './OpsTypes';\nimport { debugMessage, printMessage } from './utils/Console';\n\nexport default (state: State) => {\n return {\n createServiceExportTemplate(): ServiceExportInterface {\n return createServiceExportTemplate();\n },\n\n /**\n * Get list of services\n * @param {boolean} globalConfig true if the list of global services is requested, false otherwise. Default: false.\n */\n async getListOfServices(globalConfig = false) {\n return getListOfServices({ globalConfig, state });\n },\n\n /**\n * Get all services including their descendents.\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns Promise resolving to an array of services with their descendants\n */\n async getFullServices(globalConfig = false): Promise<FullService[]> {\n return getFullServices({ globalConfig, state });\n },\n\n /**\n * Deletes the specified service\n * @param {string} serviceId The service to delete\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\n async deleteFullService(serviceId: string, globalConfig = false) {\n return deleteFullService({ serviceId, globalConfig, state });\n },\n\n /**\n * Deletes all services\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\n async deleteFullServices(globalConfig = false) {\n return deleteFullServices({ globalConfig, state });\n },\n\n /**\n * Export service. The response can be saved to file as is.\n * @param serviceId service id/name\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns {Promise<ServiceExportInterface>} Promise resolving to a ServiceExportInterface object.\n */\n async exportService(\n serviceId: string,\n globalConfig = false\n ): Promise<ServiceExportInterface> {\n return exportService({ serviceId, globalConfig, state });\n },\n\n /**\n * Export all services\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\n async exportServices(\n globalConfig = false\n ): Promise<ServiceExportInterface> {\n return exportServices({ globalConfig, state });\n },\n\n /**\n * Imports a single service using a reference to the service and a file to read the data from. Optionally clean (remove) an existing service first\n * @param {string} serviceId The service id/name to add\n * @param {ServiceExportInterface} importData The service configuration export data to import\n * @param {boolean} clean Indicates whether to remove a possible existing service with the same id first.\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns Promise resolving when the service has been imported\n */\n async importService(\n serviceId: string,\n importData: ServiceExportInterface,\n clean: boolean,\n globalConfig = false\n ): Promise<AmServiceSkeleton> {\n return importService({\n serviceId,\n importData,\n clean,\n globalConfig,\n state,\n });\n },\n\n /**\n * Imports multiple services from the same file. Optionally clean (remove) existing services first\n * @param {ServiceExportInterface} importData The service configuration export data to import\n * @param {boolean} clean Indicates whether to remove possible existing services first\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\n async importServices(\n importData: ServiceExportInterface,\n clean: boolean,\n globalConfig = false\n ) {\n return importServices({\n importData,\n clean,\n globalConfig,\n state,\n });\n },\n };\n};\n\n/**\n * Create an empty service export template\n * @returns {SingleTreeExportInterface} an empty service export template\n */\nexport function createServiceExportTemplate(): ServiceExportInterface {\n return {\n meta: {},\n service: {},\n } as ServiceExportInterface;\n}\n\n/**\n * Get list of services\n * @param {boolean} globalConfig true if the list of global services is requested, false otherwise. Default: false.\n */\nexport async function getListOfServices({\n globalConfig = false,\n state,\n}: {\n globalConfig: boolean;\n state: State;\n}) {\n debugMessage({ message: `ServiceOps.getListOfServices: start`, state });\n const services = (await _getListOfServices({ globalConfig, state })).result;\n debugMessage({ message: `ServiceOps.getListOfServices: end`, state });\n return services;\n}\n\n/**\n * Get all services including their descendents.\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns Promise resolving to an array of services with their descendants\n */\nexport async function getFullServices({\n globalConfig = false,\n state,\n}: {\n globalConfig: boolean;\n state: State;\n}): Promise<FullService[]> {\n debugMessage({\n message: `ServiceOps.getFullServices: start, globalConfig=${globalConfig}`,\n state,\n });\n const serviceList = (await _getListOfServices({ globalConfig, state }))\n .result;\n\n const fullServiceData = await Promise.all(\n serviceList.map(async (listItem) => {\n try {\n const [service, nextDescendents] = await Promise.all([\n getService({ serviceId: listItem._id, globalConfig, state }),\n getServiceDescendents({\n serviceId: listItem._id,\n globalConfig,\n state,\n }),\n ]);\n\n return {\n ...service,\n nextDescendents,\n };\n } catch (error) {\n if (\n !(\n error.response?.status === 403 &&\n error.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n )\n ) {\n const message = error.response?.data?.message;\n printMessage({\n message: `Unable to retrieve data for ${listItem._id} with error: ${message}`,\n type: 'error',\n state,\n });\n }\n }\n })\n );\n\n debugMessage({ message: `ServiceOps.getFullServices: end`, state });\n return fullServiceData.filter((data) => !!data); // make sure to filter out any undefined objects\n}\n\n/**\n * Saves a service using the provide id and data, including descendents\n * @param {string} serviceId the service id / name\n * @param {string} fullServiceData service object including descendants\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns promise resolving to a service object\n */\nasync function putFullService({\n serviceId,\n fullServiceData,\n clean,\n globalConfig = false,\n state,\n}: {\n serviceId: string;\n fullServiceData: FullService;\n clean: boolean;\n globalConfig: boolean;\n state: State;\n}): Promise<AmServiceSkeleton> {\n debugMessage({\n message: `ServiceOps.putFullService: start, serviceId=${serviceId}, globalConfig=${globalConfig}`,\n state,\n });\n const nextDescendents = fullServiceData.nextDescendents;\n\n delete fullServiceData.nextDescendents;\n delete fullServiceData._rev;\n delete fullServiceData.enabled;\n\n if (clean) {\n try {\n debugMessage({ message: `ServiceOps.putFullService: clean`, state });\n await deleteFullService({ serviceId, globalConfig, state });\n } catch (error) {\n if (\n !(\n error.response?.status === 404 &&\n error.response?.data?.message === 'Not Found'\n )\n ) {\n const message = error.response?.data?.message;\n printMessage({\n message: `Error deleting service '${serviceId}' before import: ${message}`,\n type: 'error',\n state,\n });\n }\n }\n }\n\n // create service first\n const result = await putService({\n serviceId,\n serviceData: fullServiceData,\n globalConfig,\n state,\n });\n\n // return fast if no next descendents supplied\n if (nextDescendents.length === 0) {\n debugMessage({\n message: `ServiceOps.putFullService: end (w/o descendents)`,\n state,\n });\n return result;\n }\n\n // now create next descendents\n await Promise.all(\n nextDescendents.map(async (descendent) => {\n const type = descendent._type._id;\n const descendentId = descendent._id;\n debugMessage({\n message: `ServiceOps.putFullService: descendentId=${descendentId}`,\n state,\n });\n let result = undefined;\n try {\n result = await putServiceNextDescendent({\n serviceId,\n serviceType: type,\n serviceNextDescendentId: descendentId,\n serviceNextDescendentData: descendent,\n globalConfig,\n state,\n });\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage({\n message: `Put descendent '${descendentId}' of service '${serviceId}': ${message}`,\n type: 'error',\n state,\n });\n }\n return result;\n })\n );\n debugMessage({\n message: `ServiceOps.putFullService: end (w/ descendents)`,\n state,\n });\n}\n\n/**\n * Saves multiple services using the serviceEntries which contain both id and data with descendants\n * @param {[string, FullService][]} serviceEntries The services to add\n * @param {boolean} clean Indicates whether to remove possible existing services first\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns {Promise<AmService[]>} promise resolving to an array of service objects\n */\nasync function putFullServices({\n serviceEntries,\n clean,\n globalConfig = false,\n state,\n}: {\n serviceEntries: [string, FullService][];\n clean: boolean;\n globalConfig: boolean;\n state: State;\n}): Promise<AmServiceSkeleton[]> {\n debugMessage({\n message: `ServiceOps.putFullServices: start, globalConfig=${globalConfig}`,\n state,\n });\n const results: AmServiceSkeleton[] = [];\n for (const [id, data] of serviceEntries) {\n try {\n const result = await putFullService({\n serviceId: id,\n fullServiceData: data,\n clean,\n globalConfig,\n state,\n });\n results.push(result);\n printMessage({ message: `Imported: ${id}`, type: 'info', state });\n } catch (error) {\n const message = error.response?.data?.message;\n const detail = error.response?.data?.detail;\n printMessage({\n message: `Import service '${id}': ${message}`,\n type: 'error',\n state,\n });\n if (detail) {\n printMessage({\n message: `Details: ${JSON.stringify(detail)}`,\n type: 'error',\n state,\n });\n }\n }\n }\n debugMessage({ message: `ServiceOps.putFullServices: end`, state });\n return results;\n}\n\n/**\n * Deletes the specified service\n * @param {string} serviceId The service to delete\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\nexport async function deleteFullService({\n serviceId,\n globalConfig = false,\n state,\n}: {\n serviceId: string;\n globalConfig: boolean;\n state: State;\n}) {\n debugMessage({\n message: `ServiceOps.deleteFullService: start, globalConfig=${globalConfig}`,\n state,\n });\n const serviceNextDescendentData = await getServiceDescendents({\n serviceId,\n globalConfig,\n state,\n });\n\n await Promise.all(\n serviceNextDescendentData.map((nextDescendent) =>\n deleteServiceNextDescendent({\n serviceId,\n serviceType: nextDescendent._type._id,\n serviceNextDescendentId: nextDescendent._id,\n globalConfig,\n state,\n })\n )\n );\n\n await deleteService({ serviceId, globalConfig, state });\n debugMessage({ message: `ServiceOps.deleteFullService: end`, state });\n}\n\n/**\n * Deletes all services\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\nexport async function deleteFullServices({\n globalConfig = false,\n state,\n}: {\n globalConfig: boolean;\n state: State;\n}) {\n debugMessage({\n message: `ServiceOps.deleteFullServices: start, globalConfig=${globalConfig}`,\n state,\n });\n try {\n const serviceList = (await _getListOfServices({ globalConfig, state }))\n .result;\n\n await Promise.all(\n serviceList.map(async (serviceListItem) => {\n try {\n await deleteFullService({\n serviceId: serviceListItem._id,\n globalConfig,\n state,\n });\n } catch (error) {\n if (\n !(\n error.response?.status === 403 &&\n error.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n )\n ) {\n const message = error.response?.data?.message;\n printMessage({\n message: `Delete service '${serviceListItem._id}': ${message}`,\n state,\n type: 'error',\n });\n }\n }\n })\n );\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage({\n message: `Delete services: ${message}`,\n type: 'error',\n state,\n });\n }\n debugMessage({ message: `ServiceOps.deleteFullServices: end`, state });\n}\n\n/**\n * Export service. The response can be saved to file as is.\n * @param serviceId service id/name\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns {Promise<ServiceExportInterface>} Promise resolving to a ServiceExportInterface object.\n */\nexport async function exportService({\n serviceId,\n globalConfig = false,\n state,\n}: {\n serviceId: string;\n globalConfig: boolean;\n state: State;\n}): Promise<ServiceExportInterface> {\n debugMessage({\n message: `ServiceOps.exportService: start, globalConfig=${globalConfig}`,\n state,\n });\n const exportData = createServiceExportTemplate();\n try {\n const service = await getService({ serviceId, globalConfig, state });\n service.nextDescendents = await getServiceDescendents({\n serviceId,\n globalConfig,\n state,\n });\n exportData.service[serviceId] = service;\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage({\n message: `Export service '${serviceId}': ${message}`,\n type: 'error',\n state,\n });\n }\n debugMessage({ message: `ServiceOps.exportService: end`, state });\n return exportData;\n}\n\n/**\n * Export all services\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\nexport async function exportServices({\n globalConfig = false,\n state,\n}: {\n globalConfig: boolean;\n state: State;\n}): Promise<ServiceExportInterface> {\n debugMessage({\n message: `ServiceOps.exportServices: start, globalConfig=${globalConfig}`,\n state,\n });\n const exportData = createServiceExportTemplate();\n try {\n const services = await getFullServices({ globalConfig, state });\n for (const service of services) {\n exportData.service[service._type._id] = service;\n }\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage({\n message: `Export servics: ${message}`,\n type: 'error',\n state,\n });\n }\n debugMessage({ message: `ServiceOps.exportServices: end`, state });\n return exportData;\n}\n\n/**\n * Imports a single service using a reference to the service and a file to read the data from. Optionally clean (remove) an existing service first\n * @param {string} serviceId The service id/name to add\n * @param {ServiceExportInterface} importData The service configuration export data to import\n * @param {boolean} clean Indicates whether to remove a possible existing service with the same id first.\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns Promise resolving when the service has been imported\n */\nexport async function importService({\n serviceId,\n importData,\n clean,\n globalConfig = false,\n state,\n}: {\n serviceId: string;\n importData: ServiceExportInterface;\n clean: boolean;\n globalConfig: boolean;\n state: State;\n}): Promise<AmServiceSkeleton> {\n debugMessage({\n message: `ServiceOps.importService: start, globalConfig=${globalConfig}`,\n state,\n });\n const serviceData = importData.service[serviceId];\n const result = await putFullService({\n serviceId,\n fullServiceData: serviceData,\n clean,\n globalConfig,\n state,\n });\n debugMessage({ message: `ServiceOps.importService: end`, state });\n return result;\n}\n\n/**\n * Imports multiple services from the same file. Optionally clean (remove) existing services first\n * @param {ServiceExportInterface} importData The service configuration export data to import\n * @param {boolean} clean Indicates whether to remove possible existing services first\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\nexport async function importServices({\n importData,\n clean,\n globalConfig = false,\n state,\n}: {\n importData: ServiceExportInterface;\n clean: boolean;\n globalConfig: boolean;\n state: State;\n}) {\n debugMessage({\n message: `ServiceOps.importServices: start, globalConfig=${globalConfig}`,\n state,\n });\n try {\n const result = await putFullServices({\n serviceEntries: Object.entries(importData.service),\n clean,\n globalConfig,\n state,\n });\n debugMessage({ message: `ServiceOps.importServices: end`, state });\n return result;\n } catch (error) {\n const message = error.response?.data?.message;\n const detail = error.response?.data?.detail;\n printMessage({\n message: `Unable to import services: error: ${message}`,\n type: 'error',\n state,\n });\n if (detail) {\n printMessage({\n message: `Details: ${JSON.stringify(detail)}`,\n type: 'error',\n state,\n });\n }\n throw error;\n }\n}\n"],"mappings":"SAEEA,aAAa,EACbC,2BAA2B,EAC3BC,UAAU,EACVC,iBAAiB,IAAIC,kBAAkB,EACvCC,qBAAqB,EACrBC,UAAU,EACVC,wBAAwB;AAAA,SAIjBC,YAAY,EAAEC,YAAY;AAEnC,gBAAgBC,KAAY,IAAK;EAC/B,OAAO;IACLC,2BAA2BA,CAAA,EAA2B;MACpD,OAAOA,2BAA2B,CAAC,CAAC;IACtC,CAAC;IAED;AACJ;AACA;AACA;IACI,MAAMR,iBAAiBA,CAACS,YAAY,GAAG,KAAK,EAAE;MAC5C,OAAOT,iBAAiB,CAAC;QAAES,YAAY;QAAEF;MAAM,CAAC,CAAC;IACnD,CAAC;IAED;AACJ;AACA;AACA;AACA;IACI,MAAMG,eAAeA,CAACD,YAAY,GAAG,KAAK,EAA0B;MAClE,OAAOC,eAAe,CAAC;QAAED,YAAY;QAAEF;MAAM,C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,IAAI,CAACC,SAAS,CAACF,MAAM,CAAE,EAAC;QAC7C9B,IAAI,EAAE,OAAO;QACbnC;MACF,CAAC,CAAC;IACJ;IACA,MAAM0B,KAAK;EACb;AACF"}
1
+ {"version":3,"file":"ServiceOps.js","names":["deleteService","deleteServiceNextDescendent","getService","getListOfServices","_getListOfServices","getServiceDescendents","putService","putServiceNextDescendent","debugMessage","printMessage","state","createServiceExportTemplate","globalConfig","getFullServices","deleteFullService","serviceId","deleteFullServices","exportService","exportServices","importService","importData","clean","importServices","meta","service","message","services","result","serviceList","fullServiceData","Promise","all","map","listItem","nextDescendents","_id","error","_error$response","_error$response2","_error$response2$data","response","status","data","_error$response3","_error$response3$data","type","filter","putFullService","_rev","enabled","_error$response4","_error$response5","_error$response5$data","_error$response6","_error$response6$data","serviceData","length","descendent","_type","descendentId","undefined","serviceType","serviceNextDescendentId","serviceNextDescendentData","_error$response7","_error$response7$data","putFullServices","serviceEntries","results","id","push","_error$response8","_error$response8$data","_error$response9","_error$response9$data","detail","JSON","stringify","nextDescendent","serviceListItem","_error$response10","_error$response11","_error$response11$dat","_error$response12","_error$response12$dat","_error$response13","_error$response13$dat","exportData","_error$response14","_error$response14$dat","_error$response15","_error$response15$dat","Object","entries","_error$response16","_error$response16$dat","_error$response17","_error$response17$dat"],"sources":["../../src/ops/ServiceOps.ts"],"sourcesContent":["import { AmServiceSkeleton, FullService } from '../api/ApiTypes';\nimport {\n deleteService,\n deleteServiceNextDescendent,\n getService,\n getListOfServices as _getListOfServices,\n getServiceDescendents,\n putService,\n putServiceNextDescendent,\n} from '../api/ServiceApi';\nimport { State } from '../shared/State';\nimport { ServiceExportInterface } from './OpsTypes';\nimport { debugMessage, printMessage } from './utils/Console';\n\nexport type Service = {\n createServiceExportTemplate(): ServiceExportInterface;\n /**\n * Get list of services\n * @param {boolean} globalConfig true if the list of global services is requested, false otherwise. Default: false.\n */\n getListOfServices(\n globalConfig?: boolean\n ): Promise<import('../api/ServiceApi').ServiceListItem[]>;\n /**\n * Get all services including their descendents.\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns Promise resolving to an array of services with their descendants\n */\n getFullServices(globalConfig?: boolean): Promise<FullService[]>;\n /**\n * Deletes the specified service\n * @param {string} serviceId The service to delete\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\n deleteFullService(serviceId: string, globalConfig?: boolean): Promise<void>;\n /**\n * Deletes all services\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\n deleteFullServices(globalConfig?: boolean): Promise<void>;\n /**\n * Export service. The response can be saved to file as is.\n * @param serviceId service id/name\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns {Promise<ServiceExportInterface>} Promise resolving to a ServiceExportInterface object.\n */\n exportService(\n serviceId: string,\n globalConfig?: boolean\n ): Promise<ServiceExportInterface>;\n /**\n * Export all services\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\n exportServices(globalConfig?: boolean): Promise<ServiceExportInterface>;\n /**\n * Imports a single service using a reference to the service and a file to read the data from. Optionally clean (remove) an existing service first\n * @param {string} serviceId The service id/name to add\n * @param {ServiceExportInterface} importData The service configuration export data to import\n * @param {boolean} clean Indicates whether to remove a possible existing service with the same id first.\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns Promise resolving when the service has been imported\n */\n importService(\n serviceId: string,\n importData: ServiceExportInterface,\n clean: boolean,\n globalConfig?: boolean\n ): Promise<AmServiceSkeleton>;\n /**\n * Imports multiple services from the same file. Optionally clean (remove) existing services first\n * @param {ServiceExportInterface} importData The service configuration export data to import\n * @param {boolean} clean Indicates whether to remove possible existing services first\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\n importServices(\n importData: ServiceExportInterface,\n clean: boolean,\n globalConfig?: boolean\n ): Promise<AmServiceSkeleton[]>;\n};\n\nexport default (state: State): Service => {\n return {\n createServiceExportTemplate(): ServiceExportInterface {\n return createServiceExportTemplate();\n },\n\n /**\n * Get list of services\n * @param {boolean} globalConfig true if the list of global services is requested, false otherwise. Default: false.\n */\n async getListOfServices(globalConfig = false) {\n return getListOfServices({ globalConfig, state });\n },\n\n /**\n * Get all services including their descendents.\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns Promise resolving to an array of services with their descendants\n */\n async getFullServices(globalConfig = false): Promise<FullService[]> {\n return getFullServices({ globalConfig, state });\n },\n\n /**\n * Deletes the specified service\n * @param {string} serviceId The service to delete\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\n async deleteFullService(serviceId: string, globalConfig = false) {\n return deleteFullService({ serviceId, globalConfig, state });\n },\n\n /**\n * Deletes all services\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\n async deleteFullServices(globalConfig = false) {\n return deleteFullServices({ globalConfig, state });\n },\n\n /**\n * Export service. The response can be saved to file as is.\n * @param serviceId service id/name\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns {Promise<ServiceExportInterface>} Promise resolving to a ServiceExportInterface object.\n */\n async exportService(\n serviceId: string,\n globalConfig = false\n ): Promise<ServiceExportInterface> {\n return exportService({ serviceId, globalConfig, state });\n },\n\n /**\n * Export all services\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\n async exportServices(\n globalConfig = false\n ): Promise<ServiceExportInterface> {\n return exportServices({ globalConfig, state });\n },\n\n /**\n * Imports a single service using a reference to the service and a file to read the data from. Optionally clean (remove) an existing service first\n * @param {string} serviceId The service id/name to add\n * @param {ServiceExportInterface} importData The service configuration export data to import\n * @param {boolean} clean Indicates whether to remove a possible existing service with the same id first.\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns Promise resolving when the service has been imported\n */\n async importService(\n serviceId: string,\n importData: ServiceExportInterface,\n clean: boolean,\n globalConfig = false\n ): Promise<AmServiceSkeleton> {\n return importService({\n serviceId,\n importData,\n clean,\n globalConfig,\n state,\n });\n },\n\n /**\n * Imports multiple services from the same file. Optionally clean (remove) existing services first\n * @param {ServiceExportInterface} importData The service configuration export data to import\n * @param {boolean} clean Indicates whether to remove possible existing services first\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\n async importServices(\n importData: ServiceExportInterface,\n clean: boolean,\n globalConfig = false\n ) {\n return importServices({\n importData,\n clean,\n globalConfig,\n state,\n });\n },\n };\n};\n\n/**\n * Create an empty service export template\n * @returns {SingleTreeExportInterface} an empty service export template\n */\nexport function createServiceExportTemplate(): ServiceExportInterface {\n return {\n meta: {},\n service: {},\n } as ServiceExportInterface;\n}\n\n/**\n * Get list of services\n * @param {boolean} globalConfig true if the list of global services is requested, false otherwise. Default: false.\n */\nexport async function getListOfServices({\n globalConfig = false,\n state,\n}: {\n globalConfig: boolean;\n state: State;\n}) {\n debugMessage({ message: `ServiceOps.getListOfServices: start`, state });\n const services = (await _getListOfServices({ globalConfig, state })).result;\n debugMessage({ message: `ServiceOps.getListOfServices: end`, state });\n return services;\n}\n\n/**\n * Get all services including their descendents.\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns Promise resolving to an array of services with their descendants\n */\nexport async function getFullServices({\n globalConfig = false,\n state,\n}: {\n globalConfig: boolean;\n state: State;\n}): Promise<FullService[]> {\n debugMessage({\n message: `ServiceOps.getFullServices: start, globalConfig=${globalConfig}`,\n state,\n });\n const serviceList = (await _getListOfServices({ globalConfig, state }))\n .result;\n\n const fullServiceData = await Promise.all(\n serviceList.map(async (listItem) => {\n try {\n const [service, nextDescendents] = await Promise.all([\n getService({ serviceId: listItem._id, globalConfig, state }),\n getServiceDescendents({\n serviceId: listItem._id,\n globalConfig,\n state,\n }),\n ]);\n\n return {\n ...service,\n nextDescendents,\n };\n } catch (error) {\n if (\n !(\n error.response?.status === 403 &&\n error.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n )\n ) {\n const message = error.response?.data?.message;\n printMessage({\n message: `Unable to retrieve data for ${listItem._id} with error: ${message}`,\n type: 'error',\n state,\n });\n }\n }\n })\n );\n\n debugMessage({ message: `ServiceOps.getFullServices: end`, state });\n return fullServiceData.filter((data) => !!data); // make sure to filter out any undefined objects\n}\n\n/**\n * Saves a service using the provide id and data, including descendents\n * @param {string} serviceId the service id / name\n * @param {string} fullServiceData service object including descendants\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns promise resolving to a service object\n */\nasync function putFullService({\n serviceId,\n fullServiceData,\n clean,\n globalConfig = false,\n state,\n}: {\n serviceId: string;\n fullServiceData: FullService;\n clean: boolean;\n globalConfig: boolean;\n state: State;\n}): Promise<AmServiceSkeleton> {\n debugMessage({\n message: `ServiceOps.putFullService: start, serviceId=${serviceId}, globalConfig=${globalConfig}`,\n state,\n });\n const nextDescendents = fullServiceData.nextDescendents;\n\n delete fullServiceData.nextDescendents;\n delete fullServiceData._rev;\n delete fullServiceData.enabled;\n\n if (clean) {\n try {\n debugMessage({ message: `ServiceOps.putFullService: clean`, state });\n await deleteFullService({ serviceId, globalConfig, state });\n } catch (error) {\n if (\n !(\n error.response?.status === 404 &&\n error.response?.data?.message === 'Not Found'\n )\n ) {\n const message = error.response?.data?.message;\n printMessage({\n message: `Error deleting service '${serviceId}' before import: ${message}`,\n type: 'error',\n state,\n });\n }\n }\n }\n\n // create service first\n const result = await putService({\n serviceId,\n serviceData: fullServiceData,\n globalConfig,\n state,\n });\n\n // return fast if no next descendents supplied\n if (nextDescendents.length === 0) {\n debugMessage({\n message: `ServiceOps.putFullService: end (w/o descendents)`,\n state,\n });\n return result;\n }\n\n // now create next descendents\n await Promise.all(\n nextDescendents.map(async (descendent) => {\n const type = descendent._type._id;\n const descendentId = descendent._id;\n debugMessage({\n message: `ServiceOps.putFullService: descendentId=${descendentId}`,\n state,\n });\n let result = undefined;\n try {\n result = await putServiceNextDescendent({\n serviceId,\n serviceType: type,\n serviceNextDescendentId: descendentId,\n serviceNextDescendentData: descendent,\n globalConfig,\n state,\n });\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage({\n message: `Put descendent '${descendentId}' of service '${serviceId}': ${message}`,\n type: 'error',\n state,\n });\n }\n return result;\n })\n );\n debugMessage({\n message: `ServiceOps.putFullService: end (w/ descendents)`,\n state,\n });\n}\n\n/**\n * Saves multiple services using the serviceEntries which contain both id and data with descendants\n * @param {[string, FullService][]} serviceEntries The services to add\n * @param {boolean} clean Indicates whether to remove possible existing services first\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns {Promise<AmService[]>} promise resolving to an array of service objects\n */\nasync function putFullServices({\n serviceEntries,\n clean,\n globalConfig = false,\n state,\n}: {\n serviceEntries: [string, FullService][];\n clean: boolean;\n globalConfig: boolean;\n state: State;\n}): Promise<AmServiceSkeleton[]> {\n debugMessage({\n message: `ServiceOps.putFullServices: start, globalConfig=${globalConfig}`,\n state,\n });\n const results: AmServiceSkeleton[] = [];\n for (const [id, data] of serviceEntries) {\n try {\n const result = await putFullService({\n serviceId: id,\n fullServiceData: data,\n clean,\n globalConfig,\n state,\n });\n results.push(result);\n printMessage({ message: `Imported: ${id}`, type: 'info', state });\n } catch (error) {\n const message = error.response?.data?.message;\n const detail = error.response?.data?.detail;\n printMessage({\n message: `Import service '${id}': ${message}`,\n type: 'error',\n state,\n });\n if (detail) {\n printMessage({\n message: `Details: ${JSON.stringify(detail)}`,\n type: 'error',\n state,\n });\n }\n }\n }\n debugMessage({ message: `ServiceOps.putFullServices: end`, state });\n return results;\n}\n\n/**\n * Deletes the specified service\n * @param {string} serviceId The service to delete\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\nexport async function deleteFullService({\n serviceId,\n globalConfig = false,\n state,\n}: {\n serviceId: string;\n globalConfig: boolean;\n state: State;\n}) {\n debugMessage({\n message: `ServiceOps.deleteFullService: start, globalConfig=${globalConfig}`,\n state,\n });\n const serviceNextDescendentData = await getServiceDescendents({\n serviceId,\n globalConfig,\n state,\n });\n\n await Promise.all(\n serviceNextDescendentData.map((nextDescendent) =>\n deleteServiceNextDescendent({\n serviceId,\n serviceType: nextDescendent._type._id,\n serviceNextDescendentId: nextDescendent._id,\n globalConfig,\n state,\n })\n )\n );\n\n await deleteService({ serviceId, globalConfig, state });\n debugMessage({ message: `ServiceOps.deleteFullService: end`, state });\n}\n\n/**\n * Deletes all services\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\nexport async function deleteFullServices({\n globalConfig = false,\n state,\n}: {\n globalConfig: boolean;\n state: State;\n}) {\n debugMessage({\n message: `ServiceOps.deleteFullServices: start, globalConfig=${globalConfig}`,\n state,\n });\n try {\n const serviceList = (await _getListOfServices({ globalConfig, state }))\n .result;\n\n await Promise.all(\n serviceList.map(async (serviceListItem) => {\n try {\n await deleteFullService({\n serviceId: serviceListItem._id,\n globalConfig,\n state,\n });\n } catch (error) {\n if (\n !(\n error.response?.status === 403 &&\n error.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n )\n ) {\n const message = error.response?.data?.message;\n printMessage({\n message: `Delete service '${serviceListItem._id}': ${message}`,\n state,\n type: 'error',\n });\n }\n }\n })\n );\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage({\n message: `Delete services: ${message}`,\n type: 'error',\n state,\n });\n }\n debugMessage({ message: `ServiceOps.deleteFullServices: end`, state });\n}\n\n/**\n * Export service. The response can be saved to file as is.\n * @param serviceId service id/name\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns {Promise<ServiceExportInterface>} Promise resolving to a ServiceExportInterface object.\n */\nexport async function exportService({\n serviceId,\n globalConfig = false,\n state,\n}: {\n serviceId: string;\n globalConfig: boolean;\n state: State;\n}): Promise<ServiceExportInterface> {\n debugMessage({\n message: `ServiceOps.exportService: start, globalConfig=${globalConfig}`,\n state,\n });\n const exportData = createServiceExportTemplate();\n try {\n const service = await getService({ serviceId, globalConfig, state });\n service.nextDescendents = await getServiceDescendents({\n serviceId,\n globalConfig,\n state,\n });\n exportData.service[serviceId] = service;\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage({\n message: `Export service '${serviceId}': ${message}`,\n type: 'error',\n state,\n });\n }\n debugMessage({ message: `ServiceOps.exportService: end`, state });\n return exportData;\n}\n\n/**\n * Export all services\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\nexport async function exportServices({\n globalConfig = false,\n state,\n}: {\n globalConfig: boolean;\n state: State;\n}): Promise<ServiceExportInterface> {\n debugMessage({\n message: `ServiceOps.exportServices: start, globalConfig=${globalConfig}`,\n state,\n });\n const exportData = createServiceExportTemplate();\n try {\n const services = await getFullServices({ globalConfig, state });\n for (const service of services) {\n exportData.service[service._type._id] = service;\n }\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage({\n message: `Export servics: ${message}`,\n type: 'error',\n state,\n });\n }\n debugMessage({ message: `ServiceOps.exportServices: end`, state });\n return exportData;\n}\n\n/**\n * Imports a single service using a reference to the service and a file to read the data from. Optionally clean (remove) an existing service first\n * @param {string} serviceId The service id/name to add\n * @param {ServiceExportInterface} importData The service configuration export data to import\n * @param {boolean} clean Indicates whether to remove a possible existing service with the same id first.\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns Promise resolving when the service has been imported\n */\nexport async function importService({\n serviceId,\n importData,\n clean,\n globalConfig = false,\n state,\n}: {\n serviceId: string;\n importData: ServiceExportInterface;\n clean: boolean;\n globalConfig: boolean;\n state: State;\n}): Promise<AmServiceSkeleton> {\n debugMessage({\n message: `ServiceOps.importService: start, globalConfig=${globalConfig}`,\n state,\n });\n const serviceData = importData.service[serviceId];\n const result = await putFullService({\n serviceId,\n fullServiceData: serviceData,\n clean,\n globalConfig,\n state,\n });\n debugMessage({ message: `ServiceOps.importService: end`, state });\n return result;\n}\n\n/**\n * Imports multiple services from the same file. Optionally clean (remove) existing services first\n * @param {ServiceExportInterface} importData The service configuration export data to import\n * @param {boolean} clean Indicates whether to remove possible existing services first\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\nexport async function importServices({\n importData,\n clean,\n globalConfig = false,\n state,\n}: {\n importData: ServiceExportInterface;\n clean: boolean;\n globalConfig: boolean;\n state: State;\n}) {\n debugMessage({\n message: `ServiceOps.importServices: start, globalConfig=${globalConfig}`,\n state,\n });\n try {\n const result = await putFullServices({\n serviceEntries: Object.entries(importData.service),\n clean,\n globalConfig,\n state,\n });\n debugMessage({ message: `ServiceOps.importServices: end`, state });\n return result;\n } catch (error) {\n const message = error.response?.data?.message;\n const detail = error.response?.data?.detail;\n printMessage({\n message: `Unable to import services: error: ${message}`,\n type: 'error',\n state,\n });\n if (detail) {\n printMessage({\n message: `Details: ${JSON.stringify(detail)}`,\n type: 'error',\n state,\n });\n }\n throw error;\n }\n}\n"],"mappings":"SAEEA,aAAa,EACbC,2BAA2B,EAC3BC,UAAU,EACVC,iBAAiB,IAAIC,kBAAkB,EACvCC,qBAAqB,EACrBC,UAAU,EACVC,wBAAwB;AAAA,SAIjBC,YAAY,EAAEC,YAAY;AAsEnC,gBAAgBC,KAAY,IAAc;EACxC,OAAO;IACLC,2BAA2BA,CAAA,EAA2B;MACpD,OAAOA,2BAA2B,CAAC,CAAC;IACtC,CAAC;IAED;AACJ;AACA;AACA;IACI,MAAMR,iBAAiBA,CAACS,YAAY,GAAG,KAAK,EAAE;MAC5C,OAAOT,iBAAiB,CAAC;QAAES,YAAY;QAAEF;MAAM,CAAC,CAAC;IACnD,CAAC;IAED;AACJ;AACA;AACA;AACA;IACI,MAAMG,eAAeA,CAACD,YAAY,GAAG,KAAK,EAA0B;MAClE,OAAOC,eAAe,CAAC;QAAED,YAAY;QAAEF;MAAM,CAAC,CAAC;IACjD,CAAC;IAED;AACJ;AACA;AACA;AACA;IACI,MAAMI,iBAAiBA,CA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ACbnC;MACF,CAAC,CAAC;IACJ;IACA,MAAM0B,KAAK;EACb;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeOps.js","names":["getConfigEntity","putConfigEntity","getCurrentRealmName","debugMessage","THEMEREALM_ID","state","getThemes","getTheme","themeId","realm","getRealm","getThemeByName","themeName","putTheme","themeData","putThemeByName","putThemes","themeMap","deleteTheme","deleteThemeByName","deleteThemes","getRealmThemes","themes","entityId","found","filter","theme","_id","length","Error","name","data","isNew","realmThemes","map","isDefault","push","entityData","message","allThemeIDs","Object","keys","existingThemeIDs","defaultThemeId","newThemeIDs","id","includes","forEach","updatedThemes","Map","deletedThemes","finalThemes","undeletedThemes"],"sources":["../../src/ops/ThemeOps.ts"],"sourcesContent":["import { ThemeSkeleton, UiThemeRealmObject } from '../api/ApiTypes';\nimport { getConfigEntity, putConfigEntity } from '../api/IdmConfigApi';\nimport { getCurrentRealmName } from '../api/utils/ApiUtils';\nimport { debugMessage } from '../ops/utils/Console';\nimport State from '../shared/State';\n\nexport const THEMEREALM_ID = 'ui/themerealm';\n\nexport default (state: State) => {\n return {\n /**\n * Get all themes\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes\n */\n async getThemes(): Promise<ThemeSkeleton[]> {\n return getThemes({ state });\n },\n\n /**\n * Get theme by id\n * @param {string} themeId theme id\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\n async getTheme(\n themeId: string,\n realm: string = state.getRealm()\n ): Promise<ThemeSkeleton> {\n return getTheme({ themeId, realm, state });\n },\n\n /**\n * Get theme by name\n * @param {string} themeName theme name\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\n async getThemeByName(\n themeName: string,\n realm: string = state.getRealm()\n ): Promise<ThemeSkeleton> {\n return getThemeByName({ themeName, realm, state });\n },\n\n /**\n * Put theme by id\n * @param {string} themeId theme id\n * @param {ThemeSkeleton} themeData theme object\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\n async putTheme(\n themeId: string,\n themeData: ThemeSkeleton,\n realm: string = state.getRealm()\n ): Promise<ThemeSkeleton> {\n return putTheme({ themeId, themeData, realm, state });\n },\n\n /**\n * Put theme by name\n * @param {String} themeName theme name\n * @param {ThemeSkeleton} themeData theme object\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\n async putThemeByName(\n themeName: string,\n themeData: ThemeSkeleton,\n realm: string = state.getRealm()\n ): Promise<ThemeSkeleton> {\n return putThemeByName({ themeName, themeData, realm, state });\n },\n\n /**\n * Put all themes\n * @param {Map<string, ThemeSkeleton>} allThemesData themes object containing all themes for all realms\n * @param {string} realm realm name\n * @returns {Promise<Map<string, ThemeSkeleton>>} a promise that resolves to a themes object\n */\n async putThemes(\n themeMap: Map<string, ThemeSkeleton>\n ): Promise<Map<string, ThemeSkeleton>> {\n return putThemes({ themeMap, state });\n },\n\n /**\n * Delete theme by id\n * @param {string} themeId theme id\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object\n */\n async deleteTheme(\n themeId: string,\n realm: string = state.getRealm()\n ): Promise<ThemeSkeleton> {\n return deleteTheme({ themeId, realm, state });\n },\n\n /**\n * Delete theme by name\n * @param {string} themeName theme name\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object\n */\n async deleteThemeByName(\n themeName: string,\n realm: string = state.getRealm()\n ): Promise<ThemeSkeleton> {\n return deleteThemeByName({ themeName, realm, state });\n },\n\n /**\n * Delete all themes\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes\n */\n async deleteThemes(\n realm: string = state.getRealm()\n ): Promise<ThemeSkeleton[]> {\n return deleteThemes({ realm, state });\n },\n };\n};\n\n/**\n * Get realm themes\n * @param {UiThemeRealmObject} themes object containing themes\n * @param {string} realm realm name\n * @returns {ThemeSkeleton[]} array of theme pertaining to the current realm\n */\nfunction getRealmThemes({\n themes,\n realm,\n}: {\n themes: UiThemeRealmObject;\n realm: string;\n}): ThemeSkeleton[] {\n if (themes.realm && themes.realm[realm]) {\n return themes.realm[realm];\n }\n return [];\n}\n\n/**\n * Get all themes\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes\n */\nexport async function getThemes({\n realm = null,\n state,\n}: {\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton[]> {\n realm = realm ? realm : getCurrentRealmName(state);\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n return getRealmThemes({ themes, realm });\n}\n\n/**\n * Get theme by id\n * @param {string} themeId theme id\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function getTheme({\n themeId,\n realm,\n state,\n}: {\n themeId: string;\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton> {\n realm ? realm : getCurrentRealmName(state);\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n const found = getRealmThemes({ themes, realm }).filter(\n (theme) => theme._id === themeId\n );\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(\n `Multiple themes with id '${themeId}' found in realm '${realm}'!`\n );\n }\n throw new Error(`Theme with id '${themeId}' not found in realm '${realm}'!`);\n}\n\n/**\n * Get theme by name\n * @param {string} themeName theme name\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function getThemeByName({\n themeName,\n realm,\n state,\n}: {\n themeName: string;\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton> {\n realm ? realm : getCurrentRealmName(state);\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n const found = getRealmThemes({ themes, realm }).filter(\n (theme) => theme.name === themeName\n );\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(\n `Multiple themes with the name '${themeName}' found in realm '${realm}'!`\n );\n }\n throw new Error(`Theme '${themeName}' not found in realm '${realm}'!`);\n}\n\n/**\n * Put theme by id\n * @param {string} themeId theme id\n * @param {ThemeSkeleton} themeData theme object\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function putTheme({\n themeId,\n themeData,\n realm,\n state,\n}: {\n themeId: string;\n themeData: ThemeSkeleton;\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton> {\n realm ? realm : getCurrentRealmName(state);\n const data = themeData;\n data._id = themeId;\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n let isNew = true;\n const realmThemes = getRealmThemes({ themes, realm }).map((theme) => {\n if (theme._id === themeId) {\n isNew = false;\n return data;\n }\n if (data.isDefault) theme.isDefault = false;\n return theme;\n });\n if (isNew) {\n realmThemes.push(data);\n }\n themes.realm[realm] = realmThemes;\n const found = getRealmThemes({\n themes: await putConfigEntity({\n entityId: THEMEREALM_ID,\n entityData: themes,\n state,\n }),\n realm,\n }).filter((theme) => theme._id === themeId);\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(\n `Multiple themes with id '${themeId}' found in realm '${realm}'!`\n );\n }\n throw new Error(`Theme with id '${themeId}' not saved in realm '${realm}'!`);\n}\n\n/**\n * Put theme by name\n * @param {String} themeName theme name\n * @param {ThemeSkeleton} themeData theme object\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function putThemeByName({\n themeName,\n themeData,\n realm,\n state,\n}: {\n themeName: string;\n themeData: ThemeSkeleton;\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton> {\n realm ? realm : getCurrentRealmName(state);\n const data = themeData;\n data.name = themeName;\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n let isNew = true;\n const realmThemes = getRealmThemes({ themes, realm }).map((theme) => {\n if (theme.name === themeName) {\n isNew = false;\n return data;\n }\n if (data.isDefault) theme.isDefault = false;\n return theme;\n });\n if (isNew) {\n realmThemes.push(data);\n }\n themes['realm'][realm] = realmThemes;\n const found = getRealmThemes({\n themes: await putConfigEntity({\n entityId: THEMEREALM_ID,\n entityData: themes,\n state,\n }),\n realm,\n }).filter((theme) => theme.name === themeName);\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(\n `Multiple themes '${themeName}' found in realm '${realm}'!`\n );\n }\n throw new Error(`Theme '${themeName}' not saved in realm '${realm}'!`);\n}\n\n/**\n * Put all themes\n * @param {Map<string, ThemeSkeleton>} allThemesData themes object containing all themes for all realms\n * @param {string} realm realm name\n * @returns {Promise<Map<string, ThemeSkeleton>>} a promise that resolves to a themes object\n */\nexport async function putThemes({\n themeMap,\n realm = null,\n state,\n}: {\n themeMap: Map<string, ThemeSkeleton>;\n realm?: string;\n state: State;\n}): Promise<Map<string, ThemeSkeleton>> {\n debugMessage({ message: `ThemeApi.putThemes: start`, state });\n realm = realm ? realm : getCurrentRealmName(state);\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n const allThemeIDs = Object.keys(themeMap);\n const existingThemeIDs = [];\n let defaultThemeId = null;\n // update existing themes\n let realmThemes = getRealmThemes({ themes, realm }).map((theme) => {\n if (themeMap[theme._id]) {\n debugMessage({\n message: `Update theme: ${theme._id} - ${theme.name}`,\n state,\n });\n existingThemeIDs.push(theme._id);\n // remember the id of the last default theme\n if (themeMap[theme._id].isDefault) defaultThemeId = theme._id;\n return themeMap[theme._id];\n }\n return theme;\n });\n const newThemeIDs = allThemeIDs.filter(\n (id) => !existingThemeIDs.includes(id)\n );\n // add new themes\n newThemeIDs.forEach((themeId) => {\n debugMessage({\n message: `Add theme: ${themeMap[themeId]._id} - ${themeMap[themeId].name}`,\n state,\n });\n // remember the id of the last default theme\n if (themeMap[themeId].isDefault) defaultThemeId = themeId;\n realmThemes.push(themeMap[themeId]);\n });\n // if we imported a default theme, flag all the other themes as not default\n if (defaultThemeId) {\n realmThemes = realmThemes.map((theme) => {\n theme.isDefault = theme._id === defaultThemeId;\n return theme;\n });\n }\n themes.realm[realm] = realmThemes;\n const updatedThemes = new Map(\n getRealmThemes({\n themes: await putConfigEntity({\n entityId: THEMEREALM_ID,\n entityData: themes,\n state,\n }),\n realm,\n }).map((theme) => [theme._id, theme])\n );\n debugMessage({ message: updatedThemes, state });\n debugMessage({ message: `ThemeApi.putThemes: finished`, state });\n return updatedThemes;\n}\n\n/**\n * Delete theme by id\n * @param {string} themeId theme id\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object\n */\nexport async function deleteTheme({\n themeId,\n realm,\n state,\n}: {\n themeId: string;\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton> {\n realm ? realm : getCurrentRealmName(state);\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n const realmThemes = getRealmThemes({ themes, realm });\n const deletedThemes: ThemeSkeleton[] = [];\n const finalThemes = realmThemes.filter((theme) => {\n if (theme._id !== themeId) {\n return true;\n }\n deletedThemes.push(theme);\n return false;\n });\n if (realmThemes.length === finalThemes.length)\n throw new Error(`'${themeId}' not found in realm '${realm}'`);\n themes.realm[realm] = realmThemes;\n const undeletedThemes = getRealmThemes({\n themes: await putConfigEntity({\n entityId: THEMEREALM_ID,\n entityData: themes,\n state,\n }),\n realm,\n }).filter((theme) => deletedThemes.includes(theme));\n if (deletedThemes.length > 0 && undeletedThemes.length === 0) {\n return deletedThemes[0];\n }\n throw new Error(\n `Theme(s) with id(s) '${undeletedThemes.map(\n (theme) => theme._id\n )}' not deleted from realm '${realm}'!`\n );\n}\n\n/**\n * Delete theme by name\n * @param {string} themeName theme name\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object\n */\nexport async function deleteThemeByName({\n themeName,\n realm,\n state,\n}: {\n themeName: string;\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton> {\n realm ? realm : getCurrentRealmName(state);\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n const realmThemes = getRealmThemes({ themes, realm });\n const deletedThemes: ThemeSkeleton[] = [];\n const finalThemes = realmThemes.filter((theme) => {\n if (theme.name !== themeName) {\n return true;\n }\n deletedThemes.push(theme);\n return false;\n });\n if (realmThemes.length === finalThemes.length)\n throw new Error(`'${themeName}' not found in realm '${realm}'`);\n themes.realm[realm] = finalThemes;\n const undeletedThemes = getRealmThemes({\n themes: await putConfigEntity({\n entityId: THEMEREALM_ID,\n entityData: themes,\n state,\n }),\n realm,\n }).filter((theme) => deletedThemes.includes(theme));\n if (deletedThemes.length > 0 && undeletedThemes.length === 0) {\n return deletedThemes[0];\n }\n throw new Error(\n `Theme(s) with id(s) '${undeletedThemes.map(\n (theme) => theme._id\n )}' not deleted from realm '${realm}'!`\n );\n}\n\n/**\n * Delete all themes\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes\n */\nexport async function deleteThemes({\n realm,\n state,\n}: {\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton[]> {\n realm ? realm : getCurrentRealmName(state);\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n const realmThemes = themes.realm[realm];\n if (!realmThemes)\n throw new Error(`No theme configuration found for realm '${realm}'`);\n const deletedThemes: ThemeSkeleton[] = [];\n for (const theme of realmThemes) {\n deletedThemes.push(theme);\n }\n themes.realm[realm] = [];\n await putConfigEntity({ entityId: THEMEREALM_ID, entityData: themes, state });\n return deletedThemes;\n}\n"],"mappings":"SACSA,eAAe,EAAEC,eAAe;AAAA,SAChCC,mBAAmB;AAAA,SACnBC,YAAY;AAGrB,OAAO,MAAMC,aAAa,GAAG,eAAe;AAE5C,gBAAgBC,KAAY,IAAK;EAC/B,OAAO;IACL;AACJ;AACA;AACA;AACA;IACI,MAAMC,SAASA,CAAA,EAA6B;MAC1C,OAAOA,SAAS,CAAC;QAAED;MAAM,CAAC,CAAC;IAC7B,CAAC;IAED;AACJ;AACA;AACA;AACA;AAC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ConfigEntity","getCurrentRealmName","debugMessage","THEMEREALM_ID","state","getThemes","getTheme","themeId","realm","getRealm","getThemeByName","themeName","putTheme","themeData","putThemeByName","putThemes","themeMap","deleteTheme","deleteThemeByName","deleteThemes","getRealmThemes","themes","entityId","found","filter","theme","_id","length","Error","name","data","isNew","realmThemes","map","isDefault","push","entityData","message","allThemeIDs","Object","keys","existingThemeIDs","defaultThemeId","newThemeIDs","id","includes","forEach","updatedThemes","Map","deletedThemes","finalThemes","undeletedThemes"],"sources":["../../src/ops/ThemeOps.ts"],"sourcesContent":["import { ThemeSkeleton, UiThemeRealmObject } from '../api/ApiTypes';\nimport { getConfigEntity, putConfigEntity } from '../api/IdmConfigApi';\nimport { getCurrentRealmName } from '../api/utils/ApiUtils';\nimport { debugMessage } from '../ops/utils/Console';\nimport { State } from '../shared/State';\n\nexport const THEMEREALM_ID = 'ui/themerealm';\n\nexport type Theme = {\n /**\n * Get all themes\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes\n */\n getThemes(): Promise<ThemeSkeleton[]>;\n /**\n * Get theme by id\n * @param {string} themeId theme id\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\n getTheme(themeId: string, realm?: string): Promise<ThemeSkeleton>;\n /**\n * Get theme by name\n * @param {string} themeName theme name\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\n getThemeByName(themeName: string, realm?: string): Promise<ThemeSkeleton>;\n /**\n * Put theme by id\n * @param {string} themeId theme id\n * @param {ThemeSkeleton} themeData theme object\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\n putTheme(\n themeId: string,\n themeData: ThemeSkeleton,\n realm?: string\n ): Promise<ThemeSkeleton>;\n /**\n * Put theme by name\n * @param {String} themeName theme name\n * @param {ThemeSkeleton} themeData theme object\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\n putThemeByName(\n themeName: string,\n themeData: ThemeSkeleton,\n realm?: string\n ): Promise<ThemeSkeleton>;\n /**\n * Put all themes\n * @param {Map<string, ThemeSkeleton>} allThemesData themes object containing all themes for all realms\n * @param {string} realm realm name\n * @returns {Promise<Map<string, ThemeSkeleton>>} a promise that resolves to a themes object\n */\n putThemes(\n themeMap: Map<string, ThemeSkeleton>\n ): Promise<Map<string, ThemeSkeleton>>;\n /**\n * Delete theme by id\n * @param {string} themeId theme id\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object\n */\n deleteTheme(themeId: string, realm?: string): Promise<ThemeSkeleton>;\n /**\n * Delete theme by name\n * @param {string} themeName theme name\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object\n */\n deleteThemeByName(themeName: string, realm?: string): Promise<ThemeSkeleton>;\n /**\n * Delete all themes\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes\n */\n deleteThemes(realm?: string): Promise<ThemeSkeleton[]>;\n};\n\nexport default (state: State): Theme => {\n return {\n /**\n * Get all themes\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes\n */\n async getThemes(): Promise<ThemeSkeleton[]> {\n return getThemes({ state });\n },\n\n /**\n * Get theme by id\n * @param {string} themeId theme id\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\n async getTheme(\n themeId: string,\n realm: string = state.getRealm()\n ): Promise<ThemeSkeleton> {\n return getTheme({ themeId, realm, state });\n },\n\n /**\n * Get theme by name\n * @param {string} themeName theme name\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\n async getThemeByName(\n themeName: string,\n realm: string = state.getRealm()\n ): Promise<ThemeSkeleton> {\n return getThemeByName({ themeName, realm, state });\n },\n\n /**\n * Put theme by id\n * @param {string} themeId theme id\n * @param {ThemeSkeleton} themeData theme object\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\n async putTheme(\n themeId: string,\n themeData: ThemeSkeleton,\n realm: string = state.getRealm()\n ): Promise<ThemeSkeleton> {\n return putTheme({ themeId, themeData, realm, state });\n },\n\n /**\n * Put theme by name\n * @param {String} themeName theme name\n * @param {ThemeSkeleton} themeData theme object\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\n async putThemeByName(\n themeName: string,\n themeData: ThemeSkeleton,\n realm: string = state.getRealm()\n ): Promise<ThemeSkeleton> {\n return putThemeByName({ themeName, themeData, realm, state });\n },\n\n /**\n * Put all themes\n * @param {Map<string, ThemeSkeleton>} allThemesData themes object containing all themes for all realms\n * @param {string} realm realm name\n * @returns {Promise<Map<string, ThemeSkeleton>>} a promise that resolves to a themes object\n */\n async putThemes(\n themeMap: Map<string, ThemeSkeleton>\n ): Promise<Map<string, ThemeSkeleton>> {\n return putThemes({ themeMap, state });\n },\n\n /**\n * Delete theme by id\n * @param {string} themeId theme id\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object\n */\n async deleteTheme(\n themeId: string,\n realm: string = state.getRealm()\n ): Promise<ThemeSkeleton> {\n return deleteTheme({ themeId, realm, state });\n },\n\n /**\n * Delete theme by name\n * @param {string} themeName theme name\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object\n */\n async deleteThemeByName(\n themeName: string,\n realm: string = state.getRealm()\n ): Promise<ThemeSkeleton> {\n return deleteThemeByName({ themeName, realm, state });\n },\n\n /**\n * Delete all themes\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes\n */\n async deleteThemes(\n realm: string = state.getRealm()\n ): Promise<ThemeSkeleton[]> {\n return deleteThemes({ realm, state });\n },\n };\n};\n\n/**\n * Get realm themes\n * @param {UiThemeRealmObject} themes object containing themes\n * @param {string} realm realm name\n * @returns {ThemeSkeleton[]} array of theme pertaining to the current realm\n */\nfunction getRealmThemes({\n themes,\n realm,\n}: {\n themes: UiThemeRealmObject;\n realm: string;\n}): ThemeSkeleton[] {\n if (themes.realm && themes.realm[realm]) {\n return themes.realm[realm];\n }\n return [];\n}\n\n/**\n * Get all themes\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes\n */\nexport async function getThemes({\n realm = null,\n state,\n}: {\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton[]> {\n realm = realm ? realm : getCurrentRealmName(state);\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n return getRealmThemes({ themes, realm });\n}\n\n/**\n * Get theme by id\n * @param {string} themeId theme id\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function getTheme({\n themeId,\n realm,\n state,\n}: {\n themeId: string;\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton> {\n realm ? realm : getCurrentRealmName(state);\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n const found = getRealmThemes({ themes, realm }).filter(\n (theme) => theme._id === themeId\n );\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(\n `Multiple themes with id '${themeId}' found in realm '${realm}'!`\n );\n }\n throw new Error(`Theme with id '${themeId}' not found in realm '${realm}'!`);\n}\n\n/**\n * Get theme by name\n * @param {string} themeName theme name\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function getThemeByName({\n themeName,\n realm,\n state,\n}: {\n themeName: string;\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton> {\n realm ? realm : getCurrentRealmName(state);\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n const found = getRealmThemes({ themes, realm }).filter(\n (theme) => theme.name === themeName\n );\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(\n `Multiple themes with the name '${themeName}' found in realm '${realm}'!`\n );\n }\n throw new Error(`Theme '${themeName}' not found in realm '${realm}'!`);\n}\n\n/**\n * Put theme by id\n * @param {string} themeId theme id\n * @param {ThemeSkeleton} themeData theme object\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function putTheme({\n themeId,\n themeData,\n realm,\n state,\n}: {\n themeId: string;\n themeData: ThemeSkeleton;\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton> {\n realm ? realm : getCurrentRealmName(state);\n const data = themeData;\n data._id = themeId;\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n let isNew = true;\n const realmThemes = getRealmThemes({ themes, realm }).map((theme) => {\n if (theme._id === themeId) {\n isNew = false;\n return data;\n }\n if (data.isDefault) theme.isDefault = false;\n return theme;\n });\n if (isNew) {\n realmThemes.push(data);\n }\n themes.realm[realm] = realmThemes;\n const found = getRealmThemes({\n themes: await putConfigEntity({\n entityId: THEMEREALM_ID,\n entityData: themes,\n state,\n }),\n realm,\n }).filter((theme) => theme._id === themeId);\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(\n `Multiple themes with id '${themeId}' found in realm '${realm}'!`\n );\n }\n throw new Error(`Theme with id '${themeId}' not saved in realm '${realm}'!`);\n}\n\n/**\n * Put theme by name\n * @param {String} themeName theme name\n * @param {ThemeSkeleton} themeData theme object\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a theme object\n */\nexport async function putThemeByName({\n themeName,\n themeData,\n realm,\n state,\n}: {\n themeName: string;\n themeData: ThemeSkeleton;\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton> {\n realm ? realm : getCurrentRealmName(state);\n const data = themeData;\n data.name = themeName;\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n let isNew = true;\n const realmThemes = getRealmThemes({ themes, realm }).map((theme) => {\n if (theme.name === themeName) {\n isNew = false;\n return data;\n }\n if (data.isDefault) theme.isDefault = false;\n return theme;\n });\n if (isNew) {\n realmThemes.push(data);\n }\n themes['realm'][realm] = realmThemes;\n const found = getRealmThemes({\n themes: await putConfigEntity({\n entityId: THEMEREALM_ID,\n entityData: themes,\n state,\n }),\n realm,\n }).filter((theme) => theme.name === themeName);\n if (found.length === 1) {\n return found[0];\n }\n if (found.length > 1) {\n throw new Error(\n `Multiple themes '${themeName}' found in realm '${realm}'!`\n );\n }\n throw new Error(`Theme '${themeName}' not saved in realm '${realm}'!`);\n}\n\n/**\n * Put all themes\n * @param {Map<string, ThemeSkeleton>} allThemesData themes object containing all themes for all realms\n * @param {string} realm realm name\n * @returns {Promise<Map<string, ThemeSkeleton>>} a promise that resolves to a themes object\n */\nexport async function putThemes({\n themeMap,\n realm = null,\n state,\n}: {\n themeMap: Map<string, ThemeSkeleton>;\n realm?: string;\n state: State;\n}): Promise<Map<string, ThemeSkeleton>> {\n debugMessage({ message: `ThemeApi.putThemes: start`, state });\n realm = realm ? realm : getCurrentRealmName(state);\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n const allThemeIDs = Object.keys(themeMap);\n const existingThemeIDs = [];\n let defaultThemeId = null;\n // update existing themes\n let realmThemes = getRealmThemes({ themes, realm }).map((theme) => {\n if (themeMap[theme._id]) {\n debugMessage({\n message: `Update theme: ${theme._id} - ${theme.name}`,\n state,\n });\n existingThemeIDs.push(theme._id);\n // remember the id of the last default theme\n if (themeMap[theme._id].isDefault) defaultThemeId = theme._id;\n return themeMap[theme._id];\n }\n return theme;\n });\n const newThemeIDs = allThemeIDs.filter(\n (id) => !existingThemeIDs.includes(id)\n );\n // add new themes\n newThemeIDs.forEach((themeId) => {\n debugMessage({\n message: `Add theme: ${themeMap[themeId]._id} - ${themeMap[themeId].name}`,\n state,\n });\n // remember the id of the last default theme\n if (themeMap[themeId].isDefault) defaultThemeId = themeId;\n realmThemes.push(themeMap[themeId]);\n });\n // if we imported a default theme, flag all the other themes as not default\n if (defaultThemeId) {\n realmThemes = realmThemes.map((theme) => {\n theme.isDefault = theme._id === defaultThemeId;\n return theme;\n });\n }\n themes.realm[realm] = realmThemes;\n const updatedThemes = new Map(\n getRealmThemes({\n themes: await putConfigEntity({\n entityId: THEMEREALM_ID,\n entityData: themes,\n state,\n }),\n realm,\n }).map((theme) => [theme._id, theme])\n );\n debugMessage({ message: updatedThemes, state });\n debugMessage({ message: `ThemeApi.putThemes: finished`, state });\n return updatedThemes;\n}\n\n/**\n * Delete theme by id\n * @param {string} themeId theme id\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object\n */\nexport async function deleteTheme({\n themeId,\n realm,\n state,\n}: {\n themeId: string;\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton> {\n realm ? realm : getCurrentRealmName(state);\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n const realmThemes = getRealmThemes({ themes, realm });\n const deletedThemes: ThemeSkeleton[] = [];\n const finalThemes = realmThemes.filter((theme) => {\n if (theme._id !== themeId) {\n return true;\n }\n deletedThemes.push(theme);\n return false;\n });\n if (realmThemes.length === finalThemes.length)\n throw new Error(`'${themeId}' not found in realm '${realm}'`);\n themes.realm[realm] = realmThemes;\n const undeletedThemes = getRealmThemes({\n themes: await putConfigEntity({\n entityId: THEMEREALM_ID,\n entityData: themes,\n state,\n }),\n realm,\n }).filter((theme) => deletedThemes.includes(theme));\n if (deletedThemes.length > 0 && undeletedThemes.length === 0) {\n return deletedThemes[0];\n }\n throw new Error(\n `Theme(s) with id(s) '${undeletedThemes.map(\n (theme) => theme._id\n )}' not deleted from realm '${realm}'!`\n );\n}\n\n/**\n * Delete theme by name\n * @param {string} themeName theme name\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton>} a promise that resolves to a themes object\n */\nexport async function deleteThemeByName({\n themeName,\n realm,\n state,\n}: {\n themeName: string;\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton> {\n realm ? realm : getCurrentRealmName(state);\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n const realmThemes = getRealmThemes({ themes, realm });\n const deletedThemes: ThemeSkeleton[] = [];\n const finalThemes = realmThemes.filter((theme) => {\n if (theme.name !== themeName) {\n return true;\n }\n deletedThemes.push(theme);\n return false;\n });\n if (realmThemes.length === finalThemes.length)\n throw new Error(`'${themeName}' not found in realm '${realm}'`);\n themes.realm[realm] = finalThemes;\n const undeletedThemes = getRealmThemes({\n themes: await putConfigEntity({\n entityId: THEMEREALM_ID,\n entityData: themes,\n state,\n }),\n realm,\n }).filter((theme) => deletedThemes.includes(theme));\n if (deletedThemes.length > 0 && undeletedThemes.length === 0) {\n return deletedThemes[0];\n }\n throw new Error(\n `Theme(s) with id(s) '${undeletedThemes.map(\n (theme) => theme._id\n )}' not deleted from realm '${realm}'!`\n );\n}\n\n/**\n * Delete all themes\n * @param {string} realm realm name\n * @returns {Promise<ThemeSkeleton[]>} a promise that resolves to an array of themes\n */\nexport async function deleteThemes({\n realm,\n state,\n}: {\n realm?: string;\n state: State;\n}): Promise<ThemeSkeleton[]> {\n realm ? realm : getCurrentRealmName(state);\n const themes = await getConfigEntity({ entityId: THEMEREALM_ID, state });\n const realmThemes = themes.realm[realm];\n if (!realmThemes)\n throw new Error(`No theme configuration found for realm '${realm}'`);\n const deletedThemes: ThemeSkeleton[] = [];\n for (const theme of realmThemes) {\n deletedThemes.push(theme);\n }\n themes.realm[realm] = [];\n await putConfigEntity({ entityId: THEMEREALM_ID, entityData: themes, state });\n return deletedThemes;\n}\n"],"mappings":"SACSA,eAAe,EAAEC,eAAe;AAAA,SAChCC,mBAAmB;AAAA,SACnBC,YAAY;AAGrB,OAAO,MAAMC,aAAa,GAAG,eAAe;AA8E5C,gBAAgBC,KAAY,IAAY;EACtC,OAAO;IACL;AACJ;AACA;AACA;AACA;IACI,MAAMC,SAASA,CAAA,EAA6B;MAC1C,OAAOA,SAAS,CAAC;QAAED;MAAM,CAAC,CAAC;IAC7B,CAAC;IAED;AAC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":3,"file":"AdminFederationOps.js","names":["deleteProviderByTypeAndId","getAdminFederationProviders","_getAdminFederationProviders","putProviderByTypeAndId","_putProviderByTypeAndId","getMetadata","debugMessage","getConfigEntity","putConfigEntity","state","createAdminFederationExportTemplate","getAdminFederationProvider","providerId","providerType","providerData","deleteAdminFederationProvider","exportAdminFederationProvider","exportAdminFederationProviders","importAdminFederationProvider","importData","importFirstAdminFederationProvider","importAdminFederationProviders","ADMIN_FED_CONFIG_ID_PREFIX","meta","config","idp","result","response","foundProviders","filter","provider","_id","length","Error","message","importError","_importError$response","_importError$response2","_importError$response3","status","data","validAttributes","detail","push","attribute","Object","keys","includes","_type","exportData","errors","idpData","idpConfig","entityId","error","errorMessages","map","join","allIdpsData","imported","idpId","configId","entityData"],"sources":["../../../src/ops/cloud/AdminFederationOps.ts"],"sourcesContent":["import {\n deleteProviderByTypeAndId,\n getAdminFederationProviders as _getAdminFederationProviders,\n putProviderByTypeAndId as _putProviderByTypeAndId,\n} from '../../api/cloud/AdminFederationProvidersApi';\nimport { ExportMetaData } from '../OpsTypes';\nimport {\n AdminFederationConfigSkeleton,\n SocialIdpSkeleton,\n} from '../../api/ApiTypes';\nimport { getMetadata } from '../utils/ExportImportUtils';\nimport { debugMessage } from '../utils/Console';\nimport { getConfigEntity, putConfigEntity } from '../../api/IdmConfigApi';\nimport State from '../../shared/State';\n\nexport default (state: State) => {\n return {\n /**\n * Create an empty idp export template\n * @returns {AdminFederationExportInterface} an empty idp export template\n */\n createAdminFederationExportTemplate(): AdminFederationExportInterface {\n return createAdminFederationExportTemplate({ state });\n },\n\n /**\n * Get all admin federation providers\n * @returns {Promise} a promise that resolves to an object containing an array of admin federation providers\n */\n async getAdminFederationProviders() {\n return getAdminFederationProviders({ state });\n },\n\n /**\n * Get admin federation provider by id\n * @param {String} providerId social identity provider id/name\n * @returns {Promise} a promise that resolves a social admin federation object\n */\n async getAdminFederationProvider(providerId: string) {\n return getAdminFederationProvider({ providerId, state });\n },\n\n async putProviderByTypeAndId(\n providerType: string,\n providerId: string,\n providerData: SocialIdpSkeleton\n ) {\n return putProviderByTypeAndId({\n providerType,\n providerId,\n providerData,\n state,\n });\n },\n\n /**\n * Delete admin federation provider by id\n * @param {String} providerId admin federation provider id/name\n * @returns {Promise} a promise that resolves to an admin federation provider object\n */\n async deleteAdminFederationProvider(\n providerId: string\n ): Promise<SocialIdpSkeleton> {\n return deleteAdminFederationProvider({ providerId, state });\n },\n\n /**\n * Export admin federation provider by id\n * @param {string} providerId provider id/name\n * @returns {Promise<AdminFederationExportInterface>} a promise that resolves to a SocialProviderExportInterface object\n */\n async exportAdminFederationProvider(\n providerId: string\n ): Promise<AdminFederationExportInterface> {\n return exportAdminFederationProvider({ providerId, state });\n },\n\n /**\n * Export all providers\n * @returns {Promise<AdminFederationExportInterface>} a promise that resolves to a SocialProviderExportInterface object\n */\n async exportAdminFederationProviders(): Promise<AdminFederationExportInterface> {\n return exportAdminFederationProviders({ state });\n },\n\n /**\n * Import admin federation provider by id/name\n * @param {string} providerId provider id/name\n * @param {AdminFederationExportInterface} importData import data\n */\n async importAdminFederationProvider(\n providerId: string,\n importData: AdminFederationExportInterface\n ): Promise<SocialIdpSkeleton> {\n return importAdminFederationProvider({\n providerId,\n importData,\n state,\n });\n },\n\n /**\n * Import first provider\n * @param {AdminFederationExportInterface} importData import data\n */\n async importFirstAdminFederationProvider(\n importData: AdminFederationExportInterface\n ): Promise<SocialIdpSkeleton> {\n return importFirstAdminFederationProvider({\n importData,\n state,\n });\n },\n\n /**\n * Import all providers\n * @param {AdminFederationExportInterface} importData import data\n */\n async importAdminFederationProviders(\n importData: AdminFederationExportInterface\n ): Promise<SocialIdpSkeleton[]> {\n return importAdminFederationProviders({ importData, state });\n },\n };\n};\n\nexport interface AdminFederationExportInterface {\n meta?: ExportMetaData;\n config: Record<string, AdminFederationConfigSkeleton>;\n idp: Record<string, SocialIdpSkeleton>;\n}\n\nconst ADMIN_FED_CONFIG_ID_PREFIX = 'fidc/federation-';\n\n/**\n * Create an empty idp export template\n * @returns {AdminFederationExportInterface} an empty idp export template\n */\nexport function createAdminFederationExportTemplate({\n state,\n}: {\n state: State;\n}): AdminFederationExportInterface {\n return {\n meta: getMetadata({ state }),\n config: {},\n idp: {},\n } as AdminFederationExportInterface;\n}\n\n/**\n * Get all admin federation providers\n * @returns {Promise} a promise that resolves to an object containing an array of admin federation providers\n */\nexport async function getAdminFederationProviders({ state }: { state: State }) {\n const { result } = await _getAdminFederationProviders({ state });\n return result;\n}\n\n/**\n * Get admin federation provider by id\n * @param {String} providerId social identity provider id/name\n * @returns {Promise} a promise that resolves a social admin federation object\n */\nexport async function getAdminFederationProvider({\n providerId,\n state,\n}: {\n providerId: string;\n state: State;\n}) {\n const response = await getAdminFederationProviders({ state });\n const foundProviders = response.filter(\n (provider) => provider._id === providerId\n );\n switch (foundProviders.length) {\n case 1:\n return foundProviders[0];\n case 0:\n throw new Error(`Provider '${providerId}' not found`);\n default:\n throw new Error(\n `${foundProviders.length} providers '${providerId}' found`\n );\n }\n}\n\nexport async function putProviderByTypeAndId({\n providerType,\n providerId,\n providerData,\n state,\n}: {\n providerType: string;\n providerId: string;\n providerData: SocialIdpSkeleton;\n state: State;\n}) {\n debugMessage({\n message: `AdminFederationOps.putProviderByTypeAndId: start`,\n state,\n });\n try {\n const response = await _putProviderByTypeAndId({\n providerType,\n providerId,\n providerData,\n state,\n });\n debugMessage({\n message: `AdminFederationOps.putProviderByTypeAndId: end`,\n state,\n });\n return response;\n } catch (importError) {\n if (\n importError.response?.status === 400 &&\n importError.response?.data?.message === 'Invalid attribute specified.'\n ) {\n const { validAttributes } = importError.response.data.detail;\n validAttributes.push('_id', '_type');\n for (const attribute of Object.keys(providerData)) {\n if (!validAttributes.includes(attribute)) {\n debugMessage({\n message: `Removing invalid attribute: ${attribute}`,\n state,\n });\n delete providerData[attribute];\n }\n }\n const response = await _putProviderByTypeAndId({\n providerType,\n providerId,\n providerData,\n state,\n });\n debugMessage({\n message: `AdminFederationOps.putProviderByTypeAndId: end (after retry)`,\n state,\n });\n return response;\n } else {\n // re-throw unhandleable error\n throw importError;\n }\n }\n}\n\n/**\n * Delete admin federation provider by id\n * @param {String} providerId admin federation provider id/name\n * @returns {Promise<SocialIdpSkeleton>} a promise that resolves to an admin federation provider object\n */\nexport async function deleteAdminFederationProvider({\n providerId,\n state,\n}: {\n providerId: string;\n state: State;\n}): Promise<SocialIdpSkeleton> {\n const response = await getAdminFederationProviders({ state });\n const foundProviders = response.filter(\n (provider) => provider._id === providerId\n );\n switch (foundProviders.length) {\n case 1:\n return await deleteProviderByTypeAndId({\n providerType: foundProviders[0]._type._id,\n providerId: foundProviders[0]._id,\n state,\n });\n case 0:\n throw new Error(`Provider '${providerId}' not found`);\n default:\n throw new Error(\n `${foundProviders.length} providers '${providerId}' found`\n );\n }\n}\n\n/**\n * Export admin federation provider by id\n * @param {string} providerId provider id/name\n * @returns {Promise<AdminFederationExportInterface>} a promise that resolves to a SocialProviderExportInterface object\n */\nexport async function exportAdminFederationProvider({\n providerId,\n state,\n}: {\n providerId: string;\n state: State;\n}): Promise<AdminFederationExportInterface> {\n debugMessage({\n message: `AdminFederationOps.exportAdminFederationProvider: start`,\n state,\n });\n const exportData = createAdminFederationExportTemplate({ state });\n const errors = [];\n try {\n const idpData = await getAdminFederationProvider({ providerId, state });\n exportData.idp[idpData._id] = idpData;\n const idpConfig = await getConfigEntity({\n entityId: `${ADMIN_FED_CONFIG_ID_PREFIX}${providerId}`,\n state,\n });\n exportData.config[idpConfig._id] = idpConfig;\n } catch (error) {\n errors.push(error);\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n throw new Error(`Export error:\\n${errorMessages}`);\n }\n debugMessage({\n message: `AdminFederationOps.exportAdminFederationProvider: end`,\n state,\n });\n return exportData;\n}\n\n/**\n * Export all providers\n * @returns {Promise<AdminFederationExportInterface>} a promise that resolves to a SocialProviderExportInterface object\n */\nexport async function exportAdminFederationProviders({\n state,\n}: {\n state: State;\n}): Promise<AdminFederationExportInterface> {\n debugMessage({\n message: `AdminFederationOps.exportAdminFederationProviders: start`,\n state,\n });\n const exportData = createAdminFederationExportTemplate({ state });\n const errors = [];\n try {\n const allIdpsData = await getAdminFederationProviders({ state });\n for (const idpData of allIdpsData) {\n try {\n exportData.idp[idpData._id] = idpData;\n const idpConfig = await getConfigEntity({\n entityId: `${ADMIN_FED_CONFIG_ID_PREFIX}${idpData._id}`,\n state,\n });\n exportData.config[idpConfig._id] = idpConfig;\n } catch (error) {\n errors.push(error);\n }\n }\n } catch (error) {\n errors.push(error);\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n throw new Error(`Export error:\\n${errorMessages}`);\n }\n debugMessage({\n message: `AdminFederationOps.exportAdminFederationProviders: end`,\n state,\n });\n return exportData;\n}\n\n/**\n * Import admin federation provider by id/name\n * @param {string} providerId provider id/name\n * @param {AdminFederationExportInterface} importData import data\n */\nexport async function importAdminFederationProvider({\n providerId,\n importData,\n state,\n}: {\n providerId: string;\n importData: AdminFederationExportInterface;\n state: State;\n}): Promise<SocialIdpSkeleton> {\n let response = null;\n const errors = [];\n const imported = [];\n for (const idpId of Object.keys(importData.idp)) {\n if (idpId === providerId) {\n try {\n response = await putProviderByTypeAndId({\n providerType: importData.idp[idpId]._type._id,\n providerId: idpId,\n providerData: importData.idp[idpId],\n state,\n });\n const configId = `${ADMIN_FED_CONFIG_ID_PREFIX}${idpId}`;\n if (importData.config[configId]) {\n await putConfigEntity({\n entityId: configId,\n entityData: importData.config[configId],\n state,\n });\n }\n imported.push(idpId);\n } catch (error) {\n errors.push(error);\n }\n }\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n throw new Error(`Import error:\\n${errorMessages}`);\n }\n if (0 === imported.length) {\n throw new Error(`Import error:\\n${providerId} not found in import data!`);\n }\n return response;\n}\n\n/**\n * Import first provider\n * @param {AdminFederationExportInterface} importData import data\n */\nexport async function importFirstAdminFederationProvider({\n importData,\n state,\n}: {\n importData: AdminFederationExportInterface;\n state: State;\n}): Promise<SocialIdpSkeleton> {\n let response = null;\n const errors = [];\n const imported = [];\n for (const idpId of Object.keys(importData.idp)) {\n try {\n response = await putProviderByTypeAndId({\n providerType: importData.idp[idpId]._type._id,\n providerId: idpId,\n providerData: importData.idp[idpId],\n state,\n });\n const configId = `${ADMIN_FED_CONFIG_ID_PREFIX}${idpId}`;\n if (importData.config[configId]) {\n await putConfigEntity({\n entityId: configId,\n entityData: importData.config[configId],\n state,\n });\n }\n imported.push(idpId);\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n throw new Error(`Import error:\\n${errorMessages}`);\n }\n if (0 === imported.length) {\n throw new Error(`Import error:\\nNo providers found in import data!`);\n }\n return response;\n}\n\n/**\n * Import all providers\n * @param {AdminFederationExportInterface} importData import data\n */\nexport async function importAdminFederationProviders({\n importData,\n state,\n}: {\n importData: AdminFederationExportInterface;\n state: State;\n}): Promise<SocialIdpSkeleton[]> {\n const response = [];\n const errors = [];\n const imported = [];\n for (const idpId of Object.keys(importData.idp)) {\n try {\n response.push(\n await putProviderByTypeAndId({\n providerType: importData.idp[idpId]._type._id,\n providerId: idpId,\n providerData: importData.idp[idpId],\n state,\n })\n );\n const configId = `${ADMIN_FED_CONFIG_ID_PREFIX}${idpId}`;\n if (importData.config[configId]) {\n await putConfigEntity({\n entityId: configId,\n entityData: importData.config[configId],\n state,\n });\n }\n imported.push(idpId);\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n throw new Error(`Import error:\\n${errorMessages}`);\n }\n if (0 === imported.length) {\n throw new Error(`Import error:\\nNo providers found in import data!`);\n }\n return response;\n}\n"],"mappings":"SACEA,yBAAyB,EACzBC,2BAA2B,IAAIC,4BAA4B,EAC3DC,sBAAsB,IAAIC,uBAAuB;AAAA,SAO1CC,WAAW;AAAA,SACXC,YAAY;AAAA,S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E;IAC/C,IAAI;MACFE,QAAQ,CAACgB,IAAI,CACX,MAAMxC,sBAAsB,CAAC;QAC3BU,YAAY,EAAEM,UAAU,CAACM,GAAG,CAACmC,KAAK,CAAC,CAACZ,KAAK,CAACjB,GAAG;QAC7CnB,UAAU,EAAEgD,KAAK;QACjB9C,YAAY,EAAEK,UAAU,CAACM,GAAG,CAACmC,KAAK,CAAC;QACnCnD;MACF,CAAC,CACH,CAAC;MACD,MAAMoD,QAAQ,GAAI,GAAEvC,0BAA2B,GAAEsC,KAAM,EAAC;MACxD,IAAIzC,UAAU,CAACK,MAAM,CAACqC,QAAQ,CAAC,EAAE;QAC/B,MAAMrD,eAAe,CAAC;UACpB6C,QAAQ,EAAEQ,QAAQ;UAClBC,UAAU,EAAE3C,UAAU,CAACK,MAAM,CAACqC,QAAQ,CAAC;UACvCpD;QACF,CAAC,CAAC;MACJ;MACAkD,QAAQ,CAAChB,IAAI,CAACiB,KAAK,CAAC;IACtB,CAAC,CAAC,OAAON,KAAK,EAAE;MACdJ,MAAM,CAACP,IAAI,CAACW,KAAK,CAAC;IACpB;EACF;EACA,IAAIJ,MAAM,CAAClB,MAAM,EAAE;IACjB,MAAMuB,aAAa,GAAGL,MAAM,CAACM,GAAG,CAAEF,KAAK,IAAKA,KAAK,CAACpB,OAAO,CAAC,CAACuB,IAAI,CAAC,IAAI,CAAC;IACrE,MAAM,IAAIxB,KAAK,CAAE,kBAAiBsB,aAAc,EAAC,CAAC;EACpD;EACA,IAAI,CAAC,KAAKI,QAAQ,CAAC3B,MAAM,EAAE;IACzB,MAAM,IAAIC,KAAK,CAAE,mDAAkD,CAAC;EACtE;EACA,OAAON,QAAQ;AACjB"}
1
+ {"version":3,"file":"AdminFederationOps.js","names":["deleteProviderByTypeAndId","getAdminFederationProviders","_getAdminFederationProviders","putProviderByTypeAndId","_putProviderByTypeAndId","getMetadata","debugMessage","getConfigEntity","putConfigEntity","state","createAdminFederationExportTemplate","getAdminFederationProvider","providerId","providerType","providerData","deleteAdminFederationProvider","exportAdminFederationProvider","exportAdminFederationProviders","importAdminFederationProvider","importData","importFirstAdminFederationProvider","importAdminFederationProviders","ADMIN_FED_CONFIG_ID_PREFIX","meta","config","idp","result","response","foundProviders","filter","provider","_id","length","Error","message","importError","_importError$response","_importError$response2","_importError$response3","status","data","validAttributes","detail","push","attribute","Object","keys","includes","_type","exportData","errors","idpData","idpConfig","entityId","error","errorMessages","map","join","allIdpsData","imported","idpId","configId","entityData"],"sources":["../../../src/ops/cloud/AdminFederationOps.ts"],"sourcesContent":["import {\n deleteProviderByTypeAndId,\n getAdminFederationProviders as _getAdminFederationProviders,\n putProviderByTypeAndId as _putProviderByTypeAndId,\n} from '../../api/cloud/AdminFederationProvidersApi';\nimport { ExportMetaData } from '../OpsTypes';\nimport {\n AdminFederationConfigSkeleton,\n SocialIdpSkeleton,\n} from '../../api/ApiTypes';\nimport { getMetadata } from '../utils/ExportImportUtils';\nimport { debugMessage } from '../utils/Console';\nimport { getConfigEntity, putConfigEntity } from '../../api/IdmConfigApi';\nimport { State } from '../../shared/State';\n\nexport type AdminFederation = {\n /**\n * Create an empty idp export template\n * @returns {AdminFederationExportInterface} an empty idp export template\n */\n createAdminFederationExportTemplate(): AdminFederationExportInterface;\n /**\n * Get all admin federation providers\n * @returns {Promise} a promise that resolves to an object containing an array of admin federation providers\n */\n getAdminFederationProviders(): Promise<SocialIdpSkeleton[]>;\n /**\n * Get admin federation provider by id\n * @param {String} providerId social identity provider id/name\n * @returns {Promise} a promise that resolves a social admin federation object\n */\n getAdminFederationProvider(providerId: string): Promise<SocialIdpSkeleton>;\n putProviderByTypeAndId(\n providerType: string,\n providerId: string,\n providerData: SocialIdpSkeleton\n ): Promise<SocialIdpSkeleton>;\n /**\n * Delete admin federation provider by id\n * @param {String} providerId admin federation provider id/name\n * @returns {Promise} a promise that resolves to an admin federation provider object\n */\n deleteAdminFederationProvider(providerId: string): Promise<SocialIdpSkeleton>;\n /**\n * Export admin federation provider by id\n * @param {string} providerId provider id/name\n * @returns {Promise<AdminFederationExportInterface>} a promise that resolves to a SocialProviderExportInterface object\n */\n exportAdminFederationProvider(\n providerId: string\n ): Promise<AdminFederationExportInterface>;\n /**\n * Export all providers\n * @returns {Promise<AdminFederationExportInterface>} a promise that resolves to a SocialProviderExportInterface object\n */\n exportAdminFederationProviders(): Promise<AdminFederationExportInterface>;\n /**\n * Import admin federation provider by id/name\n * @param {string} providerId provider id/name\n * @param {AdminFederationExportInterface} importData import data\n */\n importAdminFederationProvider(\n providerId: string,\n importData: AdminFederationExportInterface\n ): Promise<SocialIdpSkeleton>;\n /**\n * Import first provider\n * @param {AdminFederationExportInterface} importData import data\n */\n importFirstAdminFederationProvider(\n importData: AdminFederationExportInterface\n ): Promise<SocialIdpSkeleton>;\n /**\n * Import all providers\n * @param {AdminFederationExportInterface} importData import data\n */\n importAdminFederationProviders(\n importData: AdminFederationExportInterface\n ): Promise<SocialIdpSkeleton[]>;\n};\n\nexport default (state: State): AdminFederation => {\n return {\n /**\n * Create an empty idp export template\n * @returns {AdminFederationExportInterface} an empty idp export template\n */\n createAdminFederationExportTemplate(): AdminFederationExportInterface {\n return createAdminFederationExportTemplate({ state });\n },\n\n /**\n * Get all admin federation providers\n * @returns {Promise} a promise that resolves to an object containing an array of admin federation providers\n */\n async getAdminFederationProviders() {\n return getAdminFederationProviders({ state });\n },\n\n /**\n * Get admin federation provider by id\n * @param {String} providerId social identity provider id/name\n * @returns {Promise} a promise that resolves a social admin federation object\n */\n async getAdminFederationProvider(providerId: string) {\n return getAdminFederationProvider({ providerId, state });\n },\n\n async putProviderByTypeAndId(\n providerType: string,\n providerId: string,\n providerData: SocialIdpSkeleton\n ) {\n return putProviderByTypeAndId({\n providerType,\n providerId,\n providerData,\n state,\n });\n },\n\n /**\n * Delete admin federation provider by id\n * @param {String} providerId admin federation provider id/name\n * @returns {Promise} a promise that resolves to an admin federation provider object\n */\n async deleteAdminFederationProvider(\n providerId: string\n ): Promise<SocialIdpSkeleton> {\n return deleteAdminFederationProvider({ providerId, state });\n },\n\n /**\n * Export admin federation provider by id\n * @param {string} providerId provider id/name\n * @returns {Promise<AdminFederationExportInterface>} a promise that resolves to a SocialProviderExportInterface object\n */\n async exportAdminFederationProvider(\n providerId: string\n ): Promise<AdminFederationExportInterface> {\n return exportAdminFederationProvider({ providerId, state });\n },\n\n /**\n * Export all providers\n * @returns {Promise<AdminFederationExportInterface>} a promise that resolves to a SocialProviderExportInterface object\n */\n async exportAdminFederationProviders(): Promise<AdminFederationExportInterface> {\n return exportAdminFederationProviders({ state });\n },\n\n /**\n * Import admin federation provider by id/name\n * @param {string} providerId provider id/name\n * @param {AdminFederationExportInterface} importData import data\n */\n async importAdminFederationProvider(\n providerId: string,\n importData: AdminFederationExportInterface\n ): Promise<SocialIdpSkeleton> {\n return importAdminFederationProvider({\n providerId,\n importData,\n state,\n });\n },\n\n /**\n * Import first provider\n * @param {AdminFederationExportInterface} importData import data\n */\n async importFirstAdminFederationProvider(\n importData: AdminFederationExportInterface\n ): Promise<SocialIdpSkeleton> {\n return importFirstAdminFederationProvider({\n importData,\n state,\n });\n },\n\n /**\n * Import all providers\n * @param {AdminFederationExportInterface} importData import data\n */\n async importAdminFederationProviders(\n importData: AdminFederationExportInterface\n ): Promise<SocialIdpSkeleton[]> {\n return importAdminFederationProviders({ importData, state });\n },\n };\n};\n\nexport interface AdminFederationExportInterface {\n meta?: ExportMetaData;\n config: Record<string, AdminFederationConfigSkeleton>;\n idp: Record<string, SocialIdpSkeleton>;\n}\n\nconst ADMIN_FED_CONFIG_ID_PREFIX = 'fidc/federation-';\n\n/**\n * Create an empty idp export template\n * @returns {AdminFederationExportInterface} an empty idp export template\n */\nexport function createAdminFederationExportTemplate({\n state,\n}: {\n state: State;\n}): AdminFederationExportInterface {\n return {\n meta: getMetadata({ state }),\n config: {},\n idp: {},\n } as AdminFederationExportInterface;\n}\n\n/**\n * Get all admin federation providers\n * @returns {Promise} a promise that resolves to an object containing an array of admin federation providers\n */\nexport async function getAdminFederationProviders({ state }: { state: State }) {\n const { result } = await _getAdminFederationProviders({ state });\n return result;\n}\n\n/**\n * Get admin federation provider by id\n * @param {String} providerId social identity provider id/name\n * @returns {Promise} a promise that resolves a social admin federation object\n */\nexport async function getAdminFederationProvider({\n providerId,\n state,\n}: {\n providerId: string;\n state: State;\n}) {\n const response = await getAdminFederationProviders({ state });\n const foundProviders = response.filter(\n (provider) => provider._id === providerId\n );\n switch (foundProviders.length) {\n case 1:\n return foundProviders[0];\n case 0:\n throw new Error(`Provider '${providerId}' not found`);\n default:\n throw new Error(\n `${foundProviders.length} providers '${providerId}' found`\n );\n }\n}\n\nexport async function putProviderByTypeAndId({\n providerType,\n providerId,\n providerData,\n state,\n}: {\n providerType: string;\n providerId: string;\n providerData: SocialIdpSkeleton;\n state: State;\n}) {\n debugMessage({\n message: `AdminFederationOps.putProviderByTypeAndId: start`,\n state,\n });\n try {\n const response = await _putProviderByTypeAndId({\n providerType,\n providerId,\n providerData,\n state,\n });\n debugMessage({\n message: `AdminFederationOps.putProviderByTypeAndId: end`,\n state,\n });\n return response;\n } catch (importError) {\n if (\n importError.response?.status === 400 &&\n importError.response?.data?.message === 'Invalid attribute specified.'\n ) {\n const { validAttributes } = importError.response.data.detail;\n validAttributes.push('_id', '_type');\n for (const attribute of Object.keys(providerData)) {\n if (!validAttributes.includes(attribute)) {\n debugMessage({\n message: `Removing invalid attribute: ${attribute}`,\n state,\n });\n delete providerData[attribute];\n }\n }\n const response = await _putProviderByTypeAndId({\n providerType,\n providerId,\n providerData,\n state,\n });\n debugMessage({\n message: `AdminFederationOps.putProviderByTypeAndId: end (after retry)`,\n state,\n });\n return response;\n } else {\n // re-throw unhandleable error\n throw importError;\n }\n }\n}\n\n/**\n * Delete admin federation provider by id\n * @param {String} providerId admin federation provider id/name\n * @returns {Promise<SocialIdpSkeleton>} a promise that resolves to an admin federation provider object\n */\nexport async function deleteAdminFederationProvider({\n providerId,\n state,\n}: {\n providerId: string;\n state: State;\n}): Promise<SocialIdpSkeleton> {\n const response = await getAdminFederationProviders({ state });\n const foundProviders = response.filter(\n (provider) => provider._id === providerId\n );\n switch (foundProviders.length) {\n case 1:\n return await deleteProviderByTypeAndId({\n providerType: foundProviders[0]._type._id,\n providerId: foundProviders[0]._id,\n state,\n });\n case 0:\n throw new Error(`Provider '${providerId}' not found`);\n default:\n throw new Error(\n `${foundProviders.length} providers '${providerId}' found`\n );\n }\n}\n\n/**\n * Export admin federation provider by id\n * @param {string} providerId provider id/name\n * @returns {Promise<AdminFederationExportInterface>} a promise that resolves to a SocialProviderExportInterface object\n */\nexport async function exportAdminFederationProvider({\n providerId,\n state,\n}: {\n providerId: string;\n state: State;\n}): Promise<AdminFederationExportInterface> {\n debugMessage({\n message: `AdminFederationOps.exportAdminFederationProvider: start`,\n state,\n });\n const exportData = createAdminFederationExportTemplate({ state });\n const errors = [];\n try {\n const idpData = await getAdminFederationProvider({ providerId, state });\n exportData.idp[idpData._id] = idpData;\n const idpConfig = await getConfigEntity({\n entityId: `${ADMIN_FED_CONFIG_ID_PREFIX}${providerId}`,\n state,\n });\n exportData.config[idpConfig._id] = idpConfig;\n } catch (error) {\n errors.push(error);\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n throw new Error(`Export error:\\n${errorMessages}`);\n }\n debugMessage({\n message: `AdminFederationOps.exportAdminFederationProvider: end`,\n state,\n });\n return exportData;\n}\n\n/**\n * Export all providers\n * @returns {Promise<AdminFederationExportInterface>} a promise that resolves to a SocialProviderExportInterface object\n */\nexport async function exportAdminFederationProviders({\n state,\n}: {\n state: State;\n}): Promise<AdminFederationExportInterface> {\n debugMessage({\n message: `AdminFederationOps.exportAdminFederationProviders: start`,\n state,\n });\n const exportData = createAdminFederationExportTemplate({ state });\n const errors = [];\n try {\n const allIdpsData = await getAdminFederationProviders({ state });\n for (const idpData of allIdpsData) {\n try {\n exportData.idp[idpData._id] = idpData;\n const idpConfig = await getConfigEntity({\n entityId: `${ADMIN_FED_CONFIG_ID_PREFIX}${idpData._id}`,\n state,\n });\n exportData.config[idpConfig._id] = idpConfig;\n } catch (error) {\n errors.push(error);\n }\n }\n } catch (error) {\n errors.push(error);\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n throw new Error(`Export error:\\n${errorMessages}`);\n }\n debugMessage({\n message: `AdminFederationOps.exportAdminFederationProviders: end`,\n state,\n });\n return exportData;\n}\n\n/**\n * Import admin federation provider by id/name\n * @param {string} providerId provider id/name\n * @param {AdminFederationExportInterface} importData import data\n */\nexport async function importAdminFederationProvider({\n providerId,\n importData,\n state,\n}: {\n providerId: string;\n importData: AdminFederationExportInterface;\n state: State;\n}): Promise<SocialIdpSkeleton> {\n let response = null;\n const errors = [];\n const imported = [];\n for (const idpId of Object.keys(importData.idp)) {\n if (idpId === providerId) {\n try {\n response = await putProviderByTypeAndId({\n providerType: importData.idp[idpId]._type._id,\n providerId: idpId,\n providerData: importData.idp[idpId],\n state,\n });\n const configId = `${ADMIN_FED_CONFIG_ID_PREFIX}${idpId}`;\n if (importData.config[configId]) {\n await putConfigEntity({\n entityId: configId,\n entityData: importData.config[configId],\n state,\n });\n }\n imported.push(idpId);\n } catch (error) {\n errors.push(error);\n }\n }\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n throw new Error(`Import error:\\n${errorMessages}`);\n }\n if (0 === imported.length) {\n throw new Error(`Import error:\\n${providerId} not found in import data!`);\n }\n return response;\n}\n\n/**\n * Import first provider\n * @param {AdminFederationExportInterface} importData import data\n */\nexport async function importFirstAdminFederationProvider({\n importData,\n state,\n}: {\n importData: AdminFederationExportInterface;\n state: State;\n}): Promise<SocialIdpSkeleton> {\n let response = null;\n const errors = [];\n const imported = [];\n for (const idpId of Object.keys(importData.idp)) {\n try {\n response = await putProviderByTypeAndId({\n providerType: importData.idp[idpId]._type._id,\n providerId: idpId,\n providerData: importData.idp[idpId],\n state,\n });\n const configId = `${ADMIN_FED_CONFIG_ID_PREFIX}${idpId}`;\n if (importData.config[configId]) {\n await putConfigEntity({\n entityId: configId,\n entityData: importData.config[configId],\n state,\n });\n }\n imported.push(idpId);\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n throw new Error(`Import error:\\n${errorMessages}`);\n }\n if (0 === imported.length) {\n throw new Error(`Import error:\\nNo providers found in import data!`);\n }\n return response;\n}\n\n/**\n * Import all providers\n * @param {AdminFederationExportInterface} importData import data\n */\nexport async function importAdminFederationProviders({\n importData,\n state,\n}: {\n importData: AdminFederationExportInterface;\n state: State;\n}): Promise<SocialIdpSkeleton[]> {\n const response = [];\n const errors = [];\n const imported = [];\n for (const idpId of Object.keys(importData.idp)) {\n try {\n response.push(\n await putProviderByTypeAndId({\n providerType: importData.idp[idpId]._type._id,\n providerId: idpId,\n providerData: importData.idp[idpId],\n state,\n })\n );\n const configId = `${ADMIN_FED_CONFIG_ID_PREFIX}${idpId}`;\n if (importData.config[configId]) {\n await putConfigEntity({\n entityId: configId,\n entityData: importData.config[configId],\n state,\n });\n }\n imported.push(idpId);\n } catch (error) {\n errors.push(error);\n }\n }\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n throw new Error(`Import error:\\n${errorMessages}`);\n }\n if (0 === imported.length) {\n throw new Error(`Import error:\\nNo providers found in import data!`);\n }\n return response;\n}\n"],"mappings":"SACEA,yBAAyB,EACzBC,2BAA2B,IAAIC,4BAA4B,EAC3DC,sBAAsB,IAAIC,uBAAuB;AAAA,SAO1CC,WAAW;AAAA,SACXC,YAAY;AAAA,SACZC,eAAe,EAAEC,eAAe;AAqEzC,gBAAgBC,KAAY,IAAsB;EAChD,OAAO;IACL;AACJ;AACA;AACA;IACIC,mCAAmCA,CAAA,EAAmC;MACpE,OAAOA,mCAAmC,CAAC;QAAED;MAAM,CAAC,CAAC;IACvD,CAAC;IAED;AACJ;AACA;AACA;IACI,MAAMR,2BAA2BA,CAAA,EAAG;MAClC,OAAO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QACnCnD;MACF,CAAC,CACH,CAAC;MACD,MAAMoD,QAAQ,GAAI,GAAEvC,0BAA2B,GAAEsC,KAAM,EAAC;MACxD,IAAIzC,UAAU,CAACK,MAAM,CAACqC,QAAQ,CAAC,EAAE;QAC/B,MAAMrD,eAAe,CAAC;UACpB6C,QAAQ,EAAEQ,QAAQ;UAClBC,UAAU,EAAE3C,UAAU,CAACK,MAAM,CAACqC,QAAQ,CAAC;UACvCpD;QACF,CAAC,CAAC;MACJ;MACAkD,QAAQ,CAAChB,IAAI,CAACiB,KAAK,CAAC;IACtB,CAAC,CAAC,OAAON,KAAK,EAAE;MACdJ,MAAM,CAACP,IAAI,CAACW,KAAK,CAAC;IACpB;EACF;EACA,IAAIJ,MAAM,CAAClB,MAAM,EAAE;IACjB,MAAMuB,aAAa,GAAGL,MAAM,CAACM,GAAG,CAAEF,KAAK,IAAKA,KAAK,CAACpB,OAAO,CAAC,CAACuB,IAAI,CAAC,IAAI,CAAC;IACrE,MAAM,IAAIxB,KAAK,CAAE,kBAAiBsB,aAAc,EAAC,CAAC;EACpD;EACA,IAAI,CAAC,KAAKI,QAAQ,CAAC3B,MAAM,EAAE;IACzB,MAAM,IAAIC,KAAK,CAAE,mDAAkD,CAAC;EACtE;EACA,OAAON,QAAQ;AACjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"FeatureOps.js","names":["getFeatures","_getFeatures","debugMessage","state","hasFeature","featureId","result","setFeatures","JSON","parse","stringify","error","_error$response","message","response","data","featureIds","map","feature","_id","includes"],"sources":["../../../src/ops/cloud/FeatureOps.ts"],"sourcesContent":["import {\n getFeatures as _getFeatures,\n FeatureInterface,\n} from '../../api/cloud/FeatureApi';\nimport State from '../../shared/State';\nimport { debugMessage } from '../utils/Console';\n\nexport default (state: State) => {\n return {\n /**\n * Get all features\n * @returns {Promise<FeatureInterface[]>} a promise that resolves to an array of feature objects\n */\n async getFeatures(): Promise<FeatureInterface[]> {\n return getFeatures({ state });\n },\n\n /**\n * Check if feature is available\n * @param {string} featureId feature id (e.g. 'service-accounts')\n * @returns {Promise<boolean>} a promise that resolves to true if the feature is available and to false otherwise\n */\n async hasFeature(featureId: string): Promise<boolean> {\n return hasFeature({ featureId, state });\n },\n };\n};\n\n/**\n * Get all features\n * @returns {Promise<FeatureInterface[]>} a promise that resolves to an array of feature objects\n */\nexport async function getFeatures({\n state,\n}: {\n state: State;\n}): Promise<FeatureInterface[]> {\n if (typeof state.getFeatures() !== 'undefined') return state.getFeatures();\n try {\n const { result } = await _getFeatures({ state });\n state.setFeatures(JSON.parse(JSON.stringify(result)));\n } catch (error) {\n debugMessage({ message: error.response?.data, state });\n state.setFeatures([]);\n }\n return state.getFeatures();\n}\n\n/**\n * Check if feature is available\n * @param {string} featureId feature id (e.g. 'service-accounts')\n * @returns {Promise<boolean>} a promise that resolves to true if the feature is available and to false otherwise\n */\nexport async function hasFeature({\n featureId,\n state,\n}: {\n featureId: string;\n state: State;\n}): Promise<boolean> {\n if (typeof state.getFeatures() === 'undefined') await getFeatures({ state });\n const featureIds = state.getFeatures().map((feature) => feature._id);\n return featureIds.includes(featureId);\n}\n"],"mappings":"SACEA,WAAW,IAAIC,YAAY;AAAA,SAIpBC,YAAY;AAErB,gBAAgBC,KAAY,IAAK;EAC/B,OAAO;IACL;AACJ;AACA;AACA;IACI,MAAMH,WAAWA,CAAA,EAAgC;MAC/C,OAAOA,WAAW,CAAC;QAAEG;MAAM,CAAC,CAAC;IAC/B,CAAC;IAED;AACJ;AACA;AACA;AACA;IACI,MAAMC,UAAUA,CAACC,SAAiB,EAAoB;MACpD,OAAOD,UAAU,CAAC;QAAEC,SAAS;QAAEF;MAAM,CAAC,CAAC;IACzC;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,eAAeH,WAAWA,CAAC;EAChCG;AAGF,CAAC,EAA+B;EAC9B,IAAI,OAAOA,KAAK,CAACH,WAAW,CAAC,CAAC,KAAK,WAAW,EAAE,OAAOG,KAAK,CAACH,WAAW,CAAC,CAAC;EAC1E,IAAI;IACF,MAAM;MAAEM;IAAO,CAAC,GAAG,MAAML,YAAY,CAAC;MAAEE;IAAM,CAAC,CAAC;IAChDA,KAAK,CAACI,WAAW,CAACC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,CAACJ,MAAM,CAAC,CAAC,CAAC;EACvD,CAAC,CAAC,OAAOK,KAAK,EAAE;IAAA,IAAAC,eAAA;IACdV,YAAY,CAAC;MAAEW,OAAO,GAAAD,eAAA,GAAED,KAAK,CAACG,QAAQ,cAAAF,eAAA,uBAAdA,eAAA,CAAgBG,IAAI;MAAEZ;IAAM,CAAC,CAAC;IACtDA,KAAK,CAACI,WAAW,CAAC,EAAE,CAAC;EACvB;EACA,OAAOJ,KAAK,CAACH,WAAW,CAAC,CAAC;AAC5B;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeI,UAAUA,CAAC;EAC/BC,SAAS;EACTF;AAIF,CAAC,EAAoB;EACnB,IAAI,OAAOA,KAAK,CAACH,WAAW,CAAC,CAAC,KAAK,WAAW,EAAE,MAAMA,WAAW,CAAC;IAAEG;EAAM,CAAC,CAAC;EAC5E,MAAMa,UAAU,GAAGb,KAAK,CAACH,WAAW,CAAC,CAAC,CAACiB,GAAG,CAAEC,OAAO,IAAKA,OAAO,CAACC,GAAG,CAAC;EACpE,OAAOH,UAAU,CAACI,QAAQ,CAACf,SAAS,CAAC;AACvC"}
1
+ {"version":3,"file":"FeatureOps.js","names":["getFeatures","_getFeatures","debugMessage","state","hasFeature","featureId","result","setFeatures","JSON","parse","stringify","error","_error$response","message","response","data","featureIds","map","feature","_id","includes"],"sources":["../../../src/ops/cloud/FeatureOps.ts"],"sourcesContent":["import {\n getFeatures as _getFeatures,\n FeatureInterface,\n} from '../../api/cloud/FeatureApi';\nimport { State } from '../../shared/State';\nimport { debugMessage } from '../utils/Console';\n\nexport type Feature = {\n /**\n * Get all features\n * @returns {Promise<FeatureInterface[]>} a promise that resolves to an array of feature objects\n */\n getFeatures(): Promise<FeatureInterface[]>;\n /**\n * Check if feature is available\n * @param {string} featureId feature id (e.g. 'service-accounts')\n * @returns {Promise<boolean>} a promise that resolves to true if the feature is available and to false otherwise\n */\n hasFeature(featureId: string): Promise<boolean>;\n};\n\nexport default (state: State): Feature => {\n return {\n /**\n * Get all features\n * @returns {Promise<FeatureInterface[]>} a promise that resolves to an array of feature objects\n */\n async getFeatures(): Promise<FeatureInterface[]> {\n return getFeatures({ state });\n },\n\n /**\n * Check if feature is available\n * @param {string} featureId feature id (e.g. 'service-accounts')\n * @returns {Promise<boolean>} a promise that resolves to true if the feature is available and to false otherwise\n */\n async hasFeature(featureId: string): Promise<boolean> {\n return hasFeature({ featureId, state });\n },\n };\n};\n\n/**\n * Get all features\n * @returns {Promise<FeatureInterface[]>} a promise that resolves to an array of feature objects\n */\nexport async function getFeatures({\n state,\n}: {\n state: State;\n}): Promise<FeatureInterface[]> {\n if (typeof state.getFeatures() !== 'undefined') return state.getFeatures();\n try {\n const { result } = await _getFeatures({ state });\n state.setFeatures(JSON.parse(JSON.stringify(result)));\n } catch (error) {\n debugMessage({ message: error.response?.data, state });\n state.setFeatures([]);\n }\n return state.getFeatures();\n}\n\n/**\n * Check if feature is available\n * @param {string} featureId feature id (e.g. 'service-accounts')\n * @returns {Promise<boolean>} a promise that resolves to true if the feature is available and to false otherwise\n */\nexport async function hasFeature({\n featureId,\n state,\n}: {\n featureId: string;\n state: State;\n}): Promise<boolean> {\n if (typeof state.getFeatures() === 'undefined') await getFeatures({ state });\n const featureIds = state.getFeatures().map((feature) => feature._id);\n return featureIds.includes(featureId);\n}\n"],"mappings":"SACEA,WAAW,IAAIC,YAAY;AAAA,SAIpBC,YAAY;AAgBrB,gBAAgBC,KAAY,IAAc;EACxC,OAAO;IACL;AACJ;AACA;AACA;IACI,MAAMH,WAAWA,CAAA,EAAgC;MAC/C,OAAOA,WAAW,CAAC;QAAEG;MAAM,CAAC,CAAC;IAC/B,CAAC;IAED;AACJ;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