@rockcarver/frodo-lib 0.16.2-9 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (355) hide show
  1. package/CHANGELOG.md +217 -1
  2. package/cjs/api/AgentApi.js +14 -61
  3. package/cjs/api/AgentApi.js.map +1 -1
  4. package/cjs/api/AgentApi.test.js.map +1 -1
  5. package/cjs/api/ApiTypes.js +0 -5
  6. package/cjs/api/ApiTypes.js.map +1 -1
  7. package/cjs/api/AuthenticateApi.js +9 -20
  8. package/cjs/api/AuthenticateApi.js.map +1 -1
  9. package/cjs/api/AuthenticateApi.test.js.map +1 -0
  10. package/cjs/api/BaseApi.js +82 -124
  11. package/cjs/api/BaseApi.js.map +1 -1
  12. package/cjs/api/CirclesOfTrustApi.js +8 -32
  13. package/cjs/api/CirclesOfTrustApi.js.map +1 -1
  14. package/cjs/api/IdmConfigApi.js +9 -34
  15. package/cjs/api/IdmConfigApi.js.map +1 -1
  16. package/cjs/api/LogApi.js +8 -31
  17. package/cjs/api/LogApi.js.map +1 -1
  18. package/cjs/api/ManagedObjectApi.js +34 -31
  19. package/cjs/api/ManagedObjectApi.js.map +1 -1
  20. package/cjs/api/NodeApi.js +10 -41
  21. package/cjs/api/NodeApi.js.map +1 -1
  22. package/cjs/api/NodeApi.test.js.map +1 -1
  23. package/cjs/api/OAuth2ClientApi.js +7 -26
  24. package/cjs/api/OAuth2ClientApi.js.map +1 -1
  25. package/cjs/api/OAuth2OIDCApi.js +28 -34
  26. package/cjs/api/OAuth2OIDCApi.js.map +1 -1
  27. package/cjs/api/OAuth2OIDCApi.test.js.map +1 -0
  28. package/cjs/api/OAuth2ProviderApi.js +5 -15
  29. package/cjs/api/OAuth2ProviderApi.js.map +1 -1
  30. package/cjs/api/RealmApi.js +8 -34
  31. package/cjs/api/RealmApi.js.map +1 -1
  32. package/cjs/api/Saml2Api.js +16 -67
  33. package/cjs/api/Saml2Api.js.map +1 -1
  34. package/cjs/api/ScriptApi.js +8 -30
  35. package/cjs/api/ScriptApi.js.map +1 -1
  36. package/cjs/api/SecretsApi.js +14 -64
  37. package/cjs/api/SecretsApi.js.map +1 -1
  38. package/cjs/api/SecretsApi.test.js.map +1 -1
  39. package/cjs/api/ServerInfoApi.js +6 -21
  40. package/cjs/api/ServerInfoApi.js.map +1 -1
  41. package/cjs/api/ServiceApi.js +49 -47
  42. package/cjs/api/ServiceApi.js.map +1 -1
  43. package/cjs/api/SocialIdentityProvidersApi.js +9 -36
  44. package/cjs/api/SocialIdentityProvidersApi.js.map +1 -1
  45. package/cjs/api/StartupApi.js +5 -24
  46. package/cjs/api/StartupApi.js.map +1 -1
  47. package/cjs/api/StartupApi.test.js.map +1 -1
  48. package/cjs/api/TreeApi.js +8 -30
  49. package/cjs/api/TreeApi.js.map +1 -1
  50. package/cjs/api/TreeApi.test.js.map +1 -1
  51. package/cjs/api/VariablesApi.js +9 -37
  52. package/cjs/api/VariablesApi.js.map +1 -1
  53. package/cjs/api/VariablesApi.test.js.map +1 -1
  54. package/cjs/api/utils/ApiUtils.js +47 -57
  55. package/cjs/api/utils/ApiUtils.js.map +1 -1
  56. package/cjs/api/utils/ApiUtils.test.js.map +1 -1
  57. package/cjs/api/utils/Base64.js +5 -15
  58. package/cjs/api/utils/Base64.js.map +1 -1
  59. package/cjs/ext/axios-curlirize/curlirize.js +2 -9
  60. package/cjs/ext/axios-curlirize/curlirize.js.map +1 -1
  61. package/cjs/ext/axios-curlirize/lib/CurlHelper.js +7 -22
  62. package/cjs/ext/axios-curlirize/lib/CurlHelper.js.map +1 -1
  63. package/cjs/index.js +30 -89
  64. package/cjs/index.js.map +1 -1
  65. package/cjs/ops/AdminOps.js +27 -165
  66. package/cjs/ops/AdminOps.js.map +1 -1
  67. package/cjs/ops/AgentOps.js +2 -159
  68. package/cjs/ops/AgentOps.js.map +1 -1
  69. package/cjs/ops/AgentOps.test.js.map +1 -1
  70. package/cjs/ops/AuthenticateOps.js +265 -226
  71. package/cjs/ops/AuthenticateOps.js.map +1 -1
  72. package/cjs/ops/AuthenticateOps.test.js.map +1 -1
  73. package/cjs/ops/CirclesOfTrustOps.js +13 -91
  74. package/cjs/ops/CirclesOfTrustOps.js.map +1 -1
  75. package/cjs/ops/ConnectionProfileOps.js +220 -136
  76. package/cjs/ops/ConnectionProfileOps.js.map +1 -1
  77. package/cjs/ops/ConnectionProfileOps.test.js.map +1 -1
  78. package/cjs/ops/EmailTemplateOps.js +35 -379
  79. package/cjs/ops/EmailTemplateOps.js.map +1 -1
  80. package/cjs/ops/EmailTemplateOps.test.js.map +1 -1
  81. package/cjs/ops/IdmOps.js +52 -426
  82. package/cjs/ops/IdmOps.js.map +1 -1
  83. package/cjs/ops/IdmOps.test.js.map +1 -1
  84. package/cjs/ops/IdpOps.js +11 -94
  85. package/cjs/ops/IdpOps.js.map +1 -1
  86. package/cjs/ops/IdpOps.test.js.map +1 -1
  87. package/cjs/ops/JoseOps.js +81 -0
  88. package/cjs/ops/JoseOps.js.map +1 -0
  89. package/cjs/ops/JoseOps.test.js.map +1 -0
  90. package/cjs/ops/JourneyOps.js +139 -370
  91. package/cjs/ops/JourneyOps.js.map +1 -1
  92. package/cjs/ops/JourneyOps.test.js.map +1 -1
  93. package/cjs/ops/LogOps.js +14 -47
  94. package/cjs/ops/LogOps.js.map +1 -1
  95. package/cjs/ops/ManagedObjectOps.js +4 -12
  96. package/cjs/ops/ManagedObjectOps.js.map +1 -1
  97. package/cjs/ops/NodeOps.js +9 -67
  98. package/cjs/ops/NodeOps.js.map +1 -1
  99. package/cjs/ops/OAuth2ClientOps.js +10 -40
  100. package/cjs/ops/OAuth2ClientOps.js.map +1 -1
  101. package/cjs/ops/OpsTypes.js +0 -5
  102. package/cjs/ops/OpsTypes.js.map +1 -1
  103. package/cjs/ops/OrganizationOps.js +6 -25
  104. package/cjs/ops/OrganizationOps.js.map +1 -1
  105. package/cjs/ops/RealmOps.js +0 -19
  106. package/cjs/ops/RealmOps.js.map +1 -1
  107. package/cjs/ops/Saml2Ops.js +11 -107
  108. package/cjs/ops/Saml2Ops.js.map +1 -1
  109. package/cjs/ops/Saml2Ops.test.js.map +1 -1
  110. package/cjs/ops/ScriptOps.js +26 -73
  111. package/cjs/ops/ScriptOps.js.map +1 -1
  112. package/cjs/ops/SecretsOps.js +2 -58
  113. package/cjs/ops/SecretsOps.js.map +1 -1
  114. package/cjs/ops/ServiceAccountOps.js +61 -0
  115. package/cjs/ops/ServiceAccountOps.js.map +1 -0
  116. package/cjs/ops/ServiceAccountOps.test.js.map +1 -0
  117. package/cjs/ops/ServiceOps.js +55 -101
  118. package/cjs/ops/ServiceOps.js.map +1 -1
  119. package/cjs/ops/StartupOps.js +2 -23
  120. package/cjs/ops/StartupOps.js.map +1 -1
  121. package/cjs/ops/ThemeOps.js +230 -436
  122. package/cjs/ops/ThemeOps.js.map +1 -1
  123. package/cjs/ops/ThemeOps.test.js.map +1 -0
  124. package/cjs/ops/VariablesOps.js +0 -38
  125. package/cjs/ops/VariablesOps.js.map +1 -1
  126. package/cjs/ops/utils/Console.js +29 -62
  127. package/cjs/ops/utils/Console.js.map +1 -1
  128. package/cjs/ops/utils/DataProtection.js +13 -47
  129. package/cjs/ops/utils/DataProtection.js.map +1 -1
  130. package/cjs/ops/utils/DataProtection.test.js.map +1 -1
  131. package/cjs/ops/utils/ExportImportUtils.js +36 -74
  132. package/cjs/ops/utils/ExportImportUtils.js.map +1 -1
  133. package/cjs/ops/utils/ExportImportUtils.test.js.map +1 -1
  134. package/cjs/ops/utils/OpsUtils.js +27 -43
  135. package/cjs/ops/utils/OpsUtils.js.map +1 -1
  136. package/cjs/ops/utils/OpsUtils.test.js.map +1 -1
  137. package/cjs/ops/utils/ValidationUtils.js +0 -13
  138. package/cjs/ops/utils/ValidationUtils.js.map +1 -1
  139. package/cjs/ops/utils/ValidationUtils.test.js.map +1 -1
  140. package/cjs/ops/utils/Version.js +2 -12
  141. package/cjs/ops/utils/Version.js.map +1 -1
  142. package/cjs/ops/utils/Version.test.js.map +1 -1
  143. package/cjs/ops/utils/Wordwrap.js +1 -2
  144. package/cjs/ops/utils/Wordwrap.js.map +1 -1
  145. package/cjs/ops/utils/Wordwrap.test.js.map +1 -0
  146. package/cjs/shared/State.js +239 -0
  147. package/cjs/shared/State.js.map +1 -0
  148. package/cjs/shared/State.test.js.map +1 -0
  149. package/cjs/storage/StaticStorage.js.map +1 -1
  150. package/cjs/test/mocks/AuthenticateApi/step/default_steps.json +88 -0
  151. package/cjs/test/mocks/ForgeRockApiMockEngine.js +161 -83
  152. package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
  153. package/cjs/test/mocks/IdmConfigApi/getConfigEntity/managed.json +4420 -0
  154. package/cjs/test/mocks/OAuth2OIDCApi/accessToken/body.json +6 -0
  155. package/cjs/test/mocks/OAuth2OIDCApi/accessToken/headers.json +19 -0
  156. package/cjs/test/mocks/OAuth2OIDCApi/authorize/headers.json +38 -0
  157. package/cjs/test/mocks/ServerInfoApi/getServerInfo/info.json +25 -0
  158. package/cjs/test/mocks/ServerInfoApi/getServerVersionInfo/version.json +8 -0
  159. package/cjs/utils/AutoSetupPolly.js +79 -0
  160. package/cjs/utils/AutoSetupPolly.js.map +1 -0
  161. package/cjs/utils/SetupJest.js +6 -0
  162. package/cjs/utils/SetupJest.js.map +1 -0
  163. package/cjs/{test/mocks → utils}/snapshotResolve.js +10 -12
  164. package/cjs/utils/snapshotResolve.js.map +1 -0
  165. package/esm/api/AgentApi.mjs +19 -21
  166. package/esm/api/AgentApi.test.mjs +6 -15
  167. package/esm/api/ApiTypes.mjs +0 -5
  168. package/esm/api/AuthenticateApi.mjs +7 -10
  169. package/esm/api/AuthenticateApi.test.mjs +39 -0
  170. package/esm/api/BaseApi.mjs +96 -81
  171. package/esm/api/CirclesOfTrustApi.mjs +9 -12
  172. package/esm/api/IdmConfigApi.mjs +11 -12
  173. package/esm/api/LogApi.mjs +6 -10
  174. package/esm/api/ManagedObjectApi.mjs +23 -8
  175. package/esm/api/NodeApi.mjs +13 -15
  176. package/esm/api/NodeApi.test.mjs +13 -17
  177. package/esm/api/OAuth2ClientApi.mjs +7 -9
  178. package/esm/api/OAuth2OIDCApi.mjs +15 -9
  179. package/esm/api/OAuth2OIDCApi.test.mjs +53 -0
  180. package/esm/api/OAuth2ProviderApi.mjs +3 -5
  181. package/esm/api/RealmApi.mjs +10 -13
  182. package/esm/api/Saml2Api.mjs +25 -29
  183. package/esm/api/ScriptApi.mjs +9 -11
  184. package/esm/api/SecretsApi.mjs +21 -24
  185. package/esm/api/SecretsApi.test.mjs +9 -31
  186. package/esm/api/ServerInfoApi.mjs +5 -9
  187. package/esm/api/ServiceApi.mjs +53 -26
  188. package/esm/api/SocialIdentityProvidersApi.mjs +11 -13
  189. package/esm/api/StartupApi.mjs +5 -10
  190. package/esm/api/StartupApi.test.mjs +4 -7
  191. package/esm/api/TreeApi.mjs +9 -11
  192. package/esm/api/TreeApi.test.mjs +24 -61
  193. package/esm/api/VariablesApi.mjs +11 -13
  194. package/esm/api/VariablesApi.test.mjs +80 -222
  195. package/esm/api/utils/ApiUtils.mjs +45 -48
  196. package/esm/api/utils/ApiUtils.test.mjs +33 -32
  197. package/esm/api/utils/Base64.mjs +5 -9
  198. package/esm/ext/axios-curlirize/curlirize.mjs +2 -7
  199. package/esm/ext/axios-curlirize/lib/CurlHelper.mjs +7 -20
  200. package/esm/index.mjs +23 -13
  201. package/esm/ops/AdminOps.mjs +33 -119
  202. package/esm/ops/AgentOps.mjs +37 -80
  203. package/esm/ops/AgentOps.test.mjs +5 -45
  204. package/esm/ops/AuthenticateOps.mjs +241 -175
  205. package/esm/ops/AuthenticateOps.test.mjs +7 -9
  206. package/esm/ops/CirclesOfTrustOps.mjs +24 -61
  207. package/esm/ops/ConnectionProfileOps.mjs +192 -82
  208. package/esm/ops/ConnectionProfileOps.test.mjs +19 -19
  209. package/esm/ops/EmailTemplateOps.mjs +18 -276
  210. package/esm/ops/EmailTemplateOps.test.mjs +19 -44
  211. package/esm/ops/IdmOps.mjs +30 -327
  212. package/esm/ops/IdmOps.test.mjs +47 -54
  213. package/esm/ops/IdpOps.mjs +21 -59
  214. package/esm/ops/IdpOps.test.mjs +5 -5
  215. package/esm/ops/JoseOps.mjs +41 -0
  216. package/esm/ops/JoseOps.test.mjs +137 -0
  217. package/esm/ops/JourneyOps.mjs +146 -289
  218. package/esm/ops/JourneyOps.test.mjs +29 -27
  219. package/esm/ops/LogOps.mjs +15 -25
  220. package/esm/ops/ManagedObjectOps.mjs +6 -6
  221. package/esm/ops/NodeOps.mjs +9 -47
  222. package/esm/ops/OAuth2ClientOps.mjs +13 -19
  223. package/esm/ops/OpsTypes.mjs +1 -3
  224. package/esm/ops/OrganizationOps.mjs +7 -14
  225. package/esm/ops/RealmOps.mjs +4 -7
  226. package/esm/ops/Saml2Ops.mjs +28 -62
  227. package/esm/ops/Saml2Ops.test.mjs +20 -23
  228. package/esm/ops/ScriptOps.mjs +29 -47
  229. package/esm/ops/SecretsOps.mjs +15 -31
  230. package/esm/ops/ServiceAccountOps.mjs +41 -0
  231. package/esm/ops/ServiceAccountOps.test.mjs +51 -0
  232. package/esm/ops/ServiceOps.mjs +66 -83
  233. package/esm/ops/StartupOps.mjs +4 -13
  234. package/esm/ops/ThemeOps.mjs +189 -298
  235. package/esm/{api/ThemeApi.test.mjs → ops/ThemeOps.test.mjs} +91 -96
  236. package/esm/ops/VariablesOps.mjs +9 -18
  237. package/esm/ops/utils/Console.mjs +28 -46
  238. package/esm/ops/utils/DataProtection.mjs +15 -28
  239. package/esm/ops/utils/DataProtection.test.mjs +8 -8
  240. package/esm/ops/utils/ExportImportUtils.mjs +34 -43
  241. package/esm/ops/utils/ExportImportUtils.test.mjs +20 -18
  242. package/esm/ops/utils/OpsUtils.mjs +27 -21
  243. package/esm/ops/utils/OpsUtils.test.mjs +155 -27
  244. package/esm/ops/utils/ValidationUtils.mjs +0 -9
  245. package/esm/ops/utils/Version.mjs +2 -3
  246. package/esm/ops/utils/Version.test.mjs +0 -2
  247. package/esm/ops/utils/Wordwrap.mjs +1 -1
  248. package/esm/ops/utils/Wordwrap.test.mjs +19 -0
  249. package/esm/shared/State.mjs +164 -0
  250. package/esm/shared/State.test.mjs +249 -0
  251. package/esm/test/mocks/AuthenticateApi/step/default_steps.json +88 -0
  252. package/esm/test/mocks/ForgeRockApiMockEngine.mjs +147 -31
  253. package/esm/test/mocks/IdmConfigApi/getConfigEntity/managed.json +4420 -0
  254. package/esm/test/mocks/OAuth2OIDCApi/accessToken/body.json +6 -0
  255. package/esm/test/mocks/OAuth2OIDCApi/accessToken/headers.json +19 -0
  256. package/esm/test/mocks/OAuth2OIDCApi/authorize/headers.json +38 -0
  257. package/esm/test/mocks/ServerInfoApi/getServerInfo/info.json +25 -0
  258. package/esm/test/mocks/ServerInfoApi/getServerVersionInfo/version.json +8 -0
  259. package/esm/utils/AutoSetupPolly.mjs +72 -0
  260. package/esm/utils/SetupJest.mjs +3 -0
  261. package/esm/{test/mocks → utils}/snapshotResolve.mjs +10 -12
  262. package/package.json +36 -26
  263. package/types/api/AgentApi.d.ts.map +1 -1
  264. package/types/api/ApiTypes.d.ts +15 -16
  265. package/types/api/ApiTypes.d.ts.map +1 -1
  266. package/types/api/AuthenticateApi.d.ts +1 -1
  267. package/types/api/AuthenticateApi.d.ts.map +1 -1
  268. package/types/api/BaseApi.d.ts +2 -0
  269. package/types/api/BaseApi.d.ts.map +1 -1
  270. package/types/api/CirclesOfTrustApi.d.ts.map +1 -1
  271. package/types/api/IdmConfigApi.d.ts.map +1 -1
  272. package/types/api/LogApi.d.ts.map +1 -1
  273. package/types/api/ManagedObjectApi.d.ts +9 -1
  274. package/types/api/ManagedObjectApi.d.ts.map +1 -1
  275. package/types/api/NodeApi.d.ts.map +1 -1
  276. package/types/api/OAuth2ClientApi.d.ts.map +1 -1
  277. package/types/api/OAuth2OIDCApi.d.ts +4 -2
  278. package/types/api/OAuth2OIDCApi.d.ts.map +1 -1
  279. package/types/api/OAuth2ProviderApi.d.ts.map +1 -1
  280. package/types/api/RealmApi.d.ts.map +1 -1
  281. package/types/api/Saml2Api.d.ts.map +1 -1
  282. package/types/api/ScriptApi.d.ts.map +1 -1
  283. package/types/api/SecretsApi.d.ts.map +1 -1
  284. package/types/api/ServerInfoApi.d.ts.map +1 -1
  285. package/types/api/ServiceApi.d.ts +14 -7
  286. package/types/api/ServiceApi.d.ts.map +1 -1
  287. package/types/api/SocialIdentityProvidersApi.d.ts.map +1 -1
  288. package/types/api/StartupApi.d.ts.map +1 -1
  289. package/types/api/TreeApi.d.ts.map +1 -1
  290. package/types/api/VariablesApi.d.ts.map +1 -1
  291. package/types/api/utils/ApiUtils.d.ts +1 -0
  292. package/types/api/utils/ApiUtils.d.ts.map +1 -1
  293. package/types/index.d.ts +11 -5
  294. package/types/index.d.ts.map +1 -1
  295. package/types/ops/AuthenticateOps.d.ts +10 -2
  296. package/types/ops/AuthenticateOps.d.ts.map +1 -1
  297. package/types/ops/ConnectionProfileOps.d.ts +49 -21
  298. package/types/ops/ConnectionProfileOps.d.ts.map +1 -1
  299. package/types/ops/EmailTemplateOps.d.ts +14 -33
  300. package/types/ops/EmailTemplateOps.d.ts.map +1 -1
  301. package/types/ops/IdmOps.d.ts +29 -37
  302. package/types/ops/IdmOps.d.ts.map +1 -1
  303. package/types/ops/JoseOps.d.ts +33 -0
  304. package/types/ops/JoseOps.d.ts.map +1 -0
  305. package/types/ops/JourneyOps.d.ts.map +1 -1
  306. package/types/ops/LogOps.d.ts.map +1 -1
  307. package/types/ops/NodeOps.d.ts.map +1 -1
  308. package/types/ops/OAuth2ClientOps.d.ts.map +1 -1
  309. package/types/ops/OpsTypes.d.ts +1 -1
  310. package/types/ops/OpsTypes.d.ts.map +1 -1
  311. package/types/ops/OrganizationOps.d.ts.map +1 -1
  312. package/types/ops/ScriptOps.d.ts.map +1 -1
  313. package/types/ops/ServiceAccountOps.d.ts +20 -0
  314. package/types/ops/ServiceAccountOps.d.ts.map +1 -0
  315. package/types/ops/ServiceOps.d.ts +18 -10
  316. package/types/ops/ServiceOps.d.ts.map +1 -1
  317. package/types/ops/ThemeOps.d.ts +35 -50
  318. package/types/ops/ThemeOps.d.ts.map +1 -1
  319. package/types/ops/utils/Console.d.ts +1 -1
  320. package/types/ops/utils/Console.d.ts.map +1 -1
  321. package/types/ops/utils/DataProtection.d.ts.map +1 -1
  322. package/types/ops/utils/ExportImportUtils.d.ts +5 -2
  323. package/types/ops/utils/ExportImportUtils.d.ts.map +1 -1
  324. package/types/ops/utils/OpsUtils.d.ts +6 -0
  325. package/types/ops/utils/OpsUtils.d.ts.map +1 -1
  326. package/types/ops/utils/Wordwrap.d.ts.map +1 -1
  327. package/types/shared/State.d.ts +223 -0
  328. package/types/shared/State.d.ts.map +1 -0
  329. package/types/test/mocks/ForgeRockApiMockEngine.d.ts +19 -1
  330. package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
  331. package/types/utils/AutoSetupPolly.d.ts +1 -0
  332. package/types/utils/AutoSetupPolly.d.ts.map +1 -0
  333. package/types/utils/SetupJest.d.ts +1 -0
  334. package/types/utils/SetupJest.d.ts.map +1 -0
  335. package/types/utils/snapshotResolve.d.ts +1 -0
  336. package/types/utils/snapshotResolve.d.ts.map +1 -0
  337. package/cjs/api/EmailTemplateApi.js +0 -73
  338. package/cjs/api/EmailTemplateApi.js.map +0 -1
  339. package/cjs/api/ThemeApi.js +0 -367
  340. package/cjs/api/ThemeApi.js.map +0 -1
  341. package/cjs/api/ThemeApi.test.js.map +0 -1
  342. package/cjs/storage/SessionStorage.js +0 -91
  343. package/cjs/storage/SessionStorage.js.map +0 -1
  344. package/cjs/test/mocks/snapshotResolve.js.map +0 -1
  345. package/esm/api/EmailTemplateApi.mjs +0 -34
  346. package/esm/api/ThemeApi.mjs +0 -271
  347. package/esm/storage/SessionStorage.mjs +0 -79
  348. package/types/api/EmailTemplateApi.d.ts +0 -22
  349. package/types/api/EmailTemplateApi.d.ts.map +0 -1
  350. package/types/api/ThemeApi.d.ts +0 -56
  351. package/types/api/ThemeApi.d.ts.map +0 -1
  352. package/types/storage/SessionStorage.d.ts +0 -71
  353. package/types/storage/SessionStorage.d.ts.map +0 -1
  354. package/types/test/mocks/snapshotResolve.d.ts +0 -1
  355. package/types/test/mocks/snapshotResolve.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"IdmOps.js","names":["listAllConfigEntities","configEntities","getAllConfigEntities","getAllConfigEntitiesError","printMessage","forEach","configEntity","_id","exportConfigEntity","id","file","fileName","getTypedFilename","getConfigEntity","fs","writeFile","JSON","stringify","err","exportAllRawConfigEntities","directory","existsSync","mkdirSync","createProgressIndicator","undefined","entityPromises","x","push","catch","getConfigEntityError","response","status","data","message","Promise","all","then","result","item","fse","outputFile","stopProgressIndicator","exportAllConfigEntities","entitiesFile","envFile","entriesToExport","readFile","entriesData","parse","idm","envParams","propertiesReader","includes","configEntityString","each","key","value","replaceall","error","importConfigEntity","entityId","validate","entityData","readFileSync","path","resolve","process","cwd","jsObject","isValid","validateScriptHooks","putConfigEntity","putConfigEntityError","importAllRawConfigEntities","baseDirectory","files","readFiles","jsonFiles","filter","toLowerCase","endsWith","map","content","substring","length","everyScriptValid","isScriptValid","allSettled","results","errors","reason","importAllConfigEntities","entriesToImport","envReader","unsubstituted","unSubstituteEnvParams","countManagedObjects","type","count","resultCount","pagedResultsCookie","totalPagedResultsPolicy","totalPagedResults","remainingPagedResults","queryAllManagedObjectsByType"],"sources":["ops/IdmOps.ts"],"sourcesContent":["/* eslint-disable no-await-in-loop */\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\nimport {\n getAllConfigEntities,\n getConfigEntity,\n putConfigEntity,\n queryAllManagedObjectsByType,\n} from '../api/IdmConfigApi';\nimport {\n createProgressIndicator,\n printMessage,\n stopProgressIndicator,\n} from './utils/Console';\nimport { getTypedFilename } from './utils/ExportImportUtils';\nimport { readFiles, unSubstituteEnvParams } from './utils/OpsUtils';\nimport { validateScriptHooks } from './utils/ValidationUtils';\n\n/**\n * List all IDM configuration objects\n */\nexport async function listAllConfigEntities() {\n let configEntities = [];\n try {\n configEntities = await getAllConfigEntities();\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n if ('configurations' in configEntities) {\n configEntities['configurations'].forEach((configEntity) => {\n printMessage(`${configEntity._id}`, 'data');\n });\n }\n}\n\n/**\n * Export an IDM configuration object.\n * @param {String} id the desired configuration object\n * @param {String} file optional export file\n */\nexport async function exportConfigEntity(id, file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`${id}`, 'idm');\n }\n const configEntity = await getConfigEntity(id);\n fs.writeFile(fileName, JSON.stringify(configEntity, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${id} export to file`, 'error');\n }\n return '';\n });\n}\n\n/**\n * Export all IDM configuration objects into separate JSON files in a directory specified by <directory>\n * @param {String} directory export directory\n */\nexport async function exportAllRawConfigEntities(directory) {\n let configEntities = [];\n try {\n configEntities = await getAllConfigEntities();\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n if ('configurations' in configEntities) {\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n undefined,\n 'Exporting config objects...',\n 'indeterminate'\n );\n const entityPromises = [];\n configEntities['configurations'].forEach((x) => {\n entityPromises.push(\n getConfigEntity(x._id).catch((getConfigEntityError) => {\n if (\n !(\n getConfigEntityError.response?.status === 403 &&\n getConfigEntityError.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n ) &&\n // https://bugster.forgerock.org/jira/browse/OPENIDM-18270\n !(\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.message ===\n 'No configuration exists for id org.apache.felix.fileinstall/openidm'\n )\n ) {\n printMessage(getConfigEntityError.response?.data, 'error');\n printMessage(\n `Error getting config entity ${x._id}: ${getConfigEntityError}`,\n 'error'\n );\n }\n })\n );\n });\n Promise.all(entityPromises).then((result) => {\n result.forEach((item) => {\n if (item != null) {\n fse.outputFile(\n `${directory}/${item._id}.json`,\n JSON.stringify(item, null, 2),\n // eslint-disable-next-line consistent-return\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n });\n stopProgressIndicator('Exported config objects.', 'success');\n });\n }\n}\n\n/**\n * Export all IDM configuration objects\n * @param {String} directory export directory\n * @param {String} entitiesFile JSON file that specifies the config entities to export/import\n * @param {String} envFile File that defines environment specific variables for replacement during configuration export/import\n */\nexport async function exportAllConfigEntities(\n directory,\n entitiesFile,\n envFile\n) {\n let entriesToExport = [];\n // read list of entities to export\n fs.readFile(entitiesFile, 'utf8', async (err, data) => {\n if (err) throw err;\n const entriesData = JSON.parse(data);\n entriesToExport = entriesData.idm;\n // console.log(`entriesToExport ${entriesToExport}`);\n\n // read list of configs to parameterize for environment specific values\n const envParams = propertiesReader(envFile);\n\n let configEntities = [];\n try {\n configEntities = await getAllConfigEntities();\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n if ('configurations' in configEntities) {\n // create export directory if not exist\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n undefined,\n 'Exporting config objects...',\n 'indeterminate'\n );\n const entityPromises = [];\n configEntities['configurations'].forEach((x) => {\n if (entriesToExport.includes(x._id)) {\n entityPromises.push(getConfigEntity(x._id));\n }\n });\n Promise.all(entityPromises).then((result) => {\n result.forEach((item) => {\n if (item != null) {\n let configEntityString = JSON.stringify(item, null, 2);\n envParams.each((key, value) => {\n configEntityString = replaceall(\n value,\n `\\${${key}}`,\n configEntityString\n );\n });\n fse.outputFile(\n `${directory}/${item._id}.json`,\n configEntityString,\n // eslint-disable-next-line consistent-return\n (error) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${error}`,\n 'error'\n );\n }\n }\n );\n }\n });\n stopProgressIndicator(null, 'success');\n });\n }\n });\n}\n\n/**\n * Import an IDM configuration object.\n * @param entityId the configuration object to import\n * @param file optional file to import\n */\nexport async function importConfigEntity(\n entityId: string,\n file?: string,\n validate?: boolean\n) {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const entityData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n\n const jsObject = JSON.parse(entityData);\n const isValid = validateScriptHooks(jsObject);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await putConfigEntity(entityId, entityData);\n } catch (putConfigEntityError) {\n printMessage(putConfigEntityError, 'error');\n printMessage(`Error: ${putConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>\n * @param baseDirectory export directory\n * @param validate validate script hooks\n */\nexport async function importAllRawConfigEntities(\n baseDirectory: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ path, content }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n undefined,\n 'Importing config objects...',\n 'indeterminate'\n );\n\n const entityPromises = jsonFiles.map((file) => {\n return putConfigEntity(file.entityId, file.content);\n });\n\n await Promise.allSettled(entityPromises).then((results) => {\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(\n `Failed to import ${errors.length} config objects:`,\n 'error'\n );\n errors.forEach((error) => {\n printMessage(`- ${error.reason}`, 'error');\n });\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(\n `Imported ${results.length} config objects`,\n 'success'\n );\n });\n}\n\n/**\n * Import all IDM configuration objects\n * @param baseDirectory import directory\n * @param entitiesFile JSON file that specifies the config entities to export/import\n * @param envFile File that defines environment specific variables for replacement during configuration export/import\n * @param validate validate script hooks\n */\nexport async function importAllConfigEntities(\n baseDirectory: string,\n entitiesFile: string,\n envFile: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const entriesToImport = JSON.parse(fs.readFileSync(entitiesFile, 'utf8')).idm;\n\n const envReader = propertiesReader(envFile);\n\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content, path }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n undefined,\n 'Importing config objects...',\n 'indeterminate'\n );\n\n const entityPromises = jsonFiles\n .filter(({ entityId }) => {\n return entriesToImport.includes(entityId);\n })\n .map(({ entityId, content }) => {\n const unsubstituted = unSubstituteEnvParams(content, envReader);\n return putConfigEntity(entityId, unsubstituted);\n });\n\n await Promise.allSettled(entityPromises).then((results) => {\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(\n `Failed to import ${errors.length} config objects:`,\n 'error'\n );\n errors.forEach((error) => {\n printMessage(`- ${error.reason}`, 'error');\n });\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(\n `Imported ${results.length} config objects`,\n 'success'\n );\n });\n}\n\n/**\n * Count number of managed objects of a given type\n * @param {String} type managed object type, e.g. alpha_user\n */\nexport async function countManagedObjects(type) {\n let count = 0;\n let result = {\n result: [],\n resultCount: 0,\n pagedResultsCookie: null,\n totalPagedResultsPolicy: 'NONE',\n totalPagedResults: -1,\n remainingPagedResults: -1,\n };\n try {\n do {\n result = await queryAllManagedObjectsByType(\n type,\n [],\n result.pagedResultsCookie\n );\n count += result.resultCount;\n } while (result.pagedResultsCookie);\n printMessage(`${type}: ${count}`);\n } catch (error) {\n printMessage(error.response.data, 'error');\n printMessage(`Error querying managed objects by type: ${error}`, 'error');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAKA;;AACA;;AACA;;;;;;;;AAEA;AACA;AACA;SACsBA,qB;;;AAkBtB;AACA;AACA;AACA;AACA;;;;6CAtBO,aAAuC;IAC5C,IAAIC,cAAc,GAAG,EAArB;;IACA,IAAI;MACFA,cAAc,SAAS,IAAAC,kCAAA,GAAvB;IACD,CAFD,CAEE,OAAOC,yBAAP,EAAkC;MAClC,IAAAC,qBAAA,EAAaD,yBAAb,EAAwC,OAAxC;MACA,IAAAC,qBAAA,2CACoCD,yBADpC,GAEE,OAFF;IAID;;IACD,IAAI,oBAAoBF,cAAxB,EAAwC;MACtCA,cAAc,CAAC,gBAAD,CAAd,CAAiCI,OAAjC,CAA0CC,YAAD,IAAkB;QACzD,IAAAF,qBAAA,YAAgBE,YAAY,CAACC,GAA7B,GAAoC,MAApC;MACD,CAFD;IAGD;EACF,C;;;;SAOqBC,kB;;;AActB;AACA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KAAK,IAAI7D,MAAM,CAAC8D,WAAhB;MACD,CAPD,QAOS9D,MAAM,CAAC+D,kBAPhB;;MAQA,IAAAhG,qBAAA,YAAgB6F,IAAhB,eAAyBC,KAAzB;IACD,CAVD,CAUE,OAAOxC,KAAP,EAAc;MACd,IAAAtD,qBAAA,EAAasD,KAAK,CAAC5B,QAAN,CAAeE,IAA5B,EAAkC,OAAlC;MACA,IAAA5B,qBAAA,oDAAwDsD,KAAxD,GAAiE,OAAjE;IACD;EACF,C"}
1
+ {"version":3,"file":"IdmOps.js","names":["getAllConfigEntities","getAllConfigEntitiesRaw","getConfigEntitiesByType","type","getConfigEntitiesByTypeRaw","getConfigEntity","entityId","getConfigEntityRaw","putConfigEntity","entityData","putConfigEntityRaw","queryAllManagedObjectsByType","fields","pageCookie","queryAllManagedObjectsByTypeRaw"],"sources":["ops/IdmOps.ts"],"sourcesContent":["import {\n getAllConfigEntities as getAllConfigEntitiesRaw,\n getConfigEntity as getConfigEntityRaw,\n putConfigEntity as putConfigEntityRaw,\n getConfigEntitiesByType as getConfigEntitiesByTypeRaw,\n queryAllManagedObjectsByType as queryAllManagedObjectsByTypeRaw,\n} from '../api/IdmConfigApi';\n\n/**\n * Get all IDM config entities\n * @returns {Promise} a promise that resolves to all IDM config entities\n */\nexport async function getAllConfigEntities() {\n return getAllConfigEntitiesRaw();\n}\n\n/**\n * Get IDM config entities by type\n * @param {String} type the desired type of config entity\n * @returns {Promise} a promise that resolves to an object containing all IDM config entities of the desired type\n */\nexport async function getConfigEntitiesByType(type) {\n return getConfigEntitiesByTypeRaw(type);\n}\n\n/**\n * Get an IDM config entity\n * @param {string} entityId the desired config entity\n * @returns {Promise<unknown>} a promise that resolves to an IDM config entity\n */\nexport async function getConfigEntity(entityId) {\n return getConfigEntityRaw(entityId);\n}\n\n/**\n * Put IDM config entity\n * @param {string} entityId config entity id\n * @param {string} entityData config entity object\n * @returns {Promise<unknown>} a promise that resolves to an IDM config entity\n */\nexport async function putConfigEntity(\n entityId: string,\n entityData: string | object\n) {\n return putConfigEntityRaw(entityId, entityData);\n}\n\n/**\n * Query managed objects\n * @param {String} type managed object type\n * @param {[String]} fields fields to retrieve\n * @param {String} pageCookie paged results cookie\n * @returns {Promise<{result: any[]; resultCount: number; pagedResultsCookie: any; totalPagedResultsPolicy: string; totalPagedResults: number; remainingPagedResults: number;}>} a promise that resolves to managed objects of the desired type\n */\nexport async function queryAllManagedObjectsByType(\n type,\n fields,\n pageCookie\n): Promise<{\n result: unknown[];\n resultCount: number;\n pagedResultsCookie: string;\n totalPagedResultsPolicy: string;\n totalPagedResults: number;\n remainingPagedResults: number;\n}> {\n return queryAllManagedObjectsByTypeRaw(type, fields, pageCookie);\n}\n"],"mappings":";;;;;;;;;;AAAA;AAM6B;AAAA;AAE7B;AACA;AACA;AACA;AAHA,SAIsBA,oBAAoB;EAAA;AAAA;AAI1C;AACA;AACA;AACA;AACA;AAJA;EAAA,0CAJO,aAAsC;IAC3C,OAAO,IAAAC,kCAAuB,GAAE;EAClC,CAAC;EAAA;AAAA;AAAA,SAOqBC,uBAAuB;EAAA;AAAA;AAI7C;AACA;AACA;AACA;AACA;AAJA;EAAA,6CAJO,WAAuCC,IAAI,EAAE;IAClD,OAAO,IAAAC,qCAA0B,EAACD,IAAI,CAAC;EACzC,CAAC;EAAA;AAAA;AAAA,SAOqBE,eAAe;EAAA;AAAA;AAIrC;AACA;AACA;AACA;AACA;AACA;AALA;EAAA,qCAJO,WAA+BC,QAAQ,EAAE;IAC9C,OAAO,IAAAC,6BAAkB,EAACD,QAAQ,CAAC;EACrC,CAAC;EAAA;AAAA;AAAA,SAQqBE,eAAe;EAAA;AAAA;AAOrC;AACA;AACA;AACA;AACA;AACA;AACA;AANA;EAAA,qCAPO,WACLF,QAAgB,EAChBG,UAA2B,EAC3B;IACA,OAAO,IAAAC,6BAAkB,EAACJ,QAAQ,EAAEG,UAAU,CAAC;EACjD,CAAC;EAAA;AAAA;AAAA,SASqBE,4BAA4B;EAAA;AAAA;AAAA;EAAA,kDAA3C,WACLR,IAAI,EACJS,MAAM,EACNC,UAAU,EAQT;IACD,OAAO,IAAAC,0CAA+B,EAACX,IAAI,EAAES,MAAM,EAAEC,UAAU,CAAC;EAClE,CAAC;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"IdmOps.test.js","names":["mock","MockAdapter","axios","state","default","session","setTenant","setRealm","setCookieName","setCookieValue","setDeploymentType","global","CLOUD_DEPLOYMENT_TYPE_KEY","describe","test","expect","Idm","countManagedObjects","toBeDefined","exportAllConfigEntities","exportAllRawConfigEntities","exportConfigEntity","importAllConfigEntities","importAllRawConfigEntities","beforeEach","mockfs","load","resolve","path","dirname","importConfigEntity","uploaded","mockPutConfigEntity","id","data","restore","toMatchSnapshot","afterEach","listAllConfigEntities","mockListAllConfigEntities","assertions","toBeTruthy"],"sources":["ops/IdmOps.test.ts"],"sourcesContent":["import mockfs from 'mock-fs';\nimport axios from 'axios';\nimport MockAdapter from 'axios-mock-adapter';\nimport { Idm, state } from '../index';\nimport * as global from '../storage/StaticStorage';\nimport {\n mockListAllConfigEntities,\n mockPutConfigEntity,\n} from '../test/mocks/ForgeRockApiMockEngine';\nimport path, { resolve } from 'path';\n\nconst mock = new MockAdapter(axios);\n\nstate.default.session.setTenant('https://openam-frodo-dev.forgeblocks.com/am');\nstate.default.session.setRealm('alpha');\nstate.default.session.setCookieName('cookieName');\nstate.default.session.setCookieValue('cookieValue');\nstate.default.session.setDeploymentType(global.CLOUD_DEPLOYMENT_TYPE_KEY);\n\ndescribe('IdmOps - countManagedObjects()', () => {\n test('countManagedObjects() 0: Method is implemented', async () => {\n expect(Idm.countManagedObjects).toBeDefined();\n });\n});\n\ndescribe('IdmOps - exportAllConfigEntities()', () => {\n test('exportAllConfigEntities() 0: Method is implemented', async () => {\n expect(Idm.exportAllConfigEntities).toBeDefined();\n });\n});\n\ndescribe('IdmOps - exportAllRawConfigEntities()', () => {\n test('exportAllRawConfigEntities() 0: Method is implemented', async () => {\n expect(Idm.exportAllRawConfigEntities).toBeDefined();\n });\n});\n\ndescribe('IdmOps - exportConfigEntity()', () => {\n test('exportConfigEntity() 0: Method is implemented', async () => {\n expect(Idm.exportConfigEntity).toBeDefined();\n });\n});\n\ndescribe('IdmOps - importAllConfigEntities()', () => {\n test('importAllConfigEntities() 0: Method is implemented', async () => {\n expect(Idm.importAllConfigEntities).toBeDefined();\n });\n});\n\ndescribe('IdmOps - importAllRawConfigEntities()', () => {\n test('importAllRawConfigEntities() 0: Method is implemented', async () => {\n expect(Idm.importAllRawConfigEntities).toBeDefined();\n });\n});\n\ndescribe('IdmOps - importConfigEntity()', () => {\n beforeEach(() => {\n mockfs({\n 'emailTemplatewelcome.idm.json': mockfs.load(\n resolve(\n path.dirname('.'),\n './src/test/mocks/IdmConfigApi/getConfigEntity/emailTemplate/welcome.json'\n )\n ),\n });\n });\n test('importConfigEntity() 0: Method is implemented', async () => {\n expect(Idm.importConfigEntity).toBeDefined();\n });\n\n test('importConfigEntity() 1: Import a config entity', async () => {\n let uploaded: string | null = null;\n mockPutConfigEntity(mock, (id, data) => {\n uploaded = data;\n });\n\n await Idm.importConfigEntity('emailTemplate/welcome');\n\n expect(uploaded).toBeDefined();\n\n // Restore fs so we may use snapshots\n mockfs.restore();\n expect(uploaded).toMatchSnapshot();\n });\n\n afterEach(() => {\n mockfs.restore();\n });\n});\n\ndescribe('IdmOps - listAllConfigEntities()', () => {\n test('listAllConfigEntities() 0: Method is implemented', async () => {\n expect(Idm.listAllConfigEntities).toBeDefined();\n });\n\n test('listSocialProviders() 1: List social identity providers', async () => {\n mockListAllConfigEntities(mock);\n expect.assertions(1);\n await Idm.listAllConfigEntities();\n expect(true).toBeTruthy();\n });\n});\n"],"mappings":";;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;;;;;;;;;;;AAEA,IAAMA,IAAI,GAAG,IAAIC,yBAAJ,CAAgBC,cAAhB,CAAb;;AAEAC,YAAA,CAAMC,OAAN,CAAcC,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Y;IAC1E,IAAAyB,iDAAA,EAA0BvC,IAA1B;IACAe,MAAM,CAACyB,UAAP,CAAkB,CAAlB;IACA,MAAMxB,UAAA,CAAIsB,qBAAJ,EAAN;IACAvB,MAAM,CAAC,IAAD,CAAN,CAAa0B,UAAb;EACD,CALG,EAAJ;AAMD,CAXO,CAAR"}
1
+ {"version":3,"file":"IdmOps.test.js","names":["mock","MockAdapter","axios","__dirname","path","dirname","fileURLToPath","state","setHost","setRealm","setCookieName","setCookieValue","setDeploymentType","global","CLOUD_DEPLOYMENT_TYPE_KEY","describe","test","expect","Idm","getAllConfigEntities","toBeDefined","mockGetAllConfigEntities","assertions","configEntities","toBeTruthy","configurations","length","toBeGreaterThan","getConfigEntitiesByType","mockGetConfigEntitiesByType","configEntity","toMatchSnapshot","getConfigEntity","mockGetConfigEntity","putConfigEntity","templateData","JSON","parse","fs","readFileSync","resolve","uploaded","mockPutConfigEntity","id","data","queryAllManagedObjectsByType"],"sources":["ops/IdmOps.test.ts"],"sourcesContent":["import fs from 'fs';\nimport axios from 'axios';\nimport MockAdapter from 'axios-mock-adapter';\nimport { fileURLToPath } from 'url';\nimport { Idm, state } from '../index';\nimport * as global from '../storage/StaticStorage';\nimport {\n mockGetAllConfigEntities,\n mockPutConfigEntity,\n mockGetConfigEntity,\n mockGetConfigEntitiesByType,\n} from '../test/mocks/ForgeRockApiMockEngine';\nimport path from 'path';\n\nconst mock = new MockAdapter(axios);\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nstate.setHost('https://openam-frodo-dev.forgeblocks.com/am');\nstate.setRealm('alpha');\nstate.setCookieName('cookieName');\nstate.setCookieValue('cookieValue');\nstate.setDeploymentType(global.CLOUD_DEPLOYMENT_TYPE_KEY);\n\ndescribe('IdmOps - getAllConfigEntities()', () => {\n test('getAllConfigEntities() 0: Method is implemented', async () => {\n expect(Idm.getAllConfigEntities).toBeDefined();\n });\n test('getAllConfigEntities() 1: get all config entities', async () => {\n mockGetAllConfigEntities(mock);\n expect.assertions(2);\n const configEntities = await Idm.getAllConfigEntities();\n expect(configEntities).toBeTruthy();\n expect(configEntities.configurations.length).toBeGreaterThan(0);\n });\n});\n\ndescribe('IdmOps - getConfigEntitiesByType()', () => {\n test('getConfigEntitiesByType() 0: Method is implemented', async () => {\n expect(Idm.getConfigEntitiesByType).toBeDefined();\n });\n test('getConfigEntitiesByType() 1: Get config entity by type', async () => {\n mockGetConfigEntitiesByType(mock);\n expect.assertions(2);\n const configEntity = await Idm.getConfigEntitiesByType('emailTemplate');\n expect(configEntity).toBeTruthy();\n expect(configEntity).toMatchSnapshot();\n });\n});\n\ndescribe('IdmOps - getConfigEntity()', () => {\n test('getConfigEntity() 0: Method is implemented', async () => {\n expect(Idm.getConfigEntity).toBeDefined();\n });\n test('getConfigEntity() 1: Get config entity by Id', async () => {\n mockGetConfigEntity(mock);\n // expect.assertions(2);\n const configEntity = await Idm.getConfigEntity('managed');\n expect(configEntity).toBeTruthy();\n expect(configEntity).toMatchSnapshot();\n });\n});\n\ndescribe('IdmOps - putConfigEntity()', () => {\n test('putConfigEntity() 0: Method is implemented', async () => {\n expect(Idm.putConfigEntity).toBeDefined();\n });\n\n test('putConfigEntity() 1: Put a config entity', async () => {\n const templateData = JSON.parse(\n fs.readFileSync(\n path.resolve(\n __dirname,\n '../test/mocks/IdmConfigApi/getConfigEntity/emailTemplate/welcome.json'\n ),\n 'utf8'\n )\n );\n\n let uploaded: string | null = null;\n mockPutConfigEntity(mock, (id, data) => {\n uploaded = data;\n });\n\n await Idm.putConfigEntity('emailTemplate/welcome', templateData);\n\n expect(uploaded).toBeDefined();\n\n expect(uploaded).toMatchSnapshot();\n });\n});\n\ndescribe('IdmOps - queryAllManagedObjectsByType()', () => {\n test('queryAllManagedObjectsByType() 0: Method is implemented', async () => {\n expect(Idm.queryAllManagedObjectsByType).toBeDefined();\n });\n});\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AAAwB;AAAA;AAAA;AAAA;AAA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ACrB,WAAW,EAAE;IAE9BH,MAAM,CAACwB,QAAQ,CAAC,CAACV,eAAe,EAAE;EACpC,CAAC,EAAC;AACJ,CAAC,CAAC;AAEFhB,QAAQ,CAAC,yCAAyC,EAAE,MAAM;EACxDC,IAAI,CAAC,yDAAyD,iCAAE,aAAY;IAC1EC,MAAM,CAACC,UAAG,CAAC2B,4BAA4B,CAAC,CAACzB,WAAW,EAAE;EACxD,CAAC,EAAC;AACJ,CAAC,CAAC"}
package/cjs/ops/IdpOps.js CHANGED
@@ -12,25 +12,15 @@ exports.importSocialProviderFromFile = importSocialProviderFromFile;
12
12
  exports.importSocialProvidersFromFile = importSocialProvidersFromFile;
13
13
  exports.importSocialProvidersFromFiles = importSocialProvidersFromFiles;
14
14
  exports.listSocialProviders = listSocialProviders;
15
-
16
15
  var _fs = _interopRequireDefault(require("fs"));
17
-
18
16
  var _SocialIdentityProvidersApi = require("../api/SocialIdentityProvidersApi");
19
-
20
17
  var _ScriptApi = require("../api/ScriptApi");
21
-
22
18
  var _ScriptOps = require("./ScriptOps");
23
-
24
19
  var _ExportImportUtils = require("./utils/ExportImportUtils");
25
-
26
20
  var _Console = require("./utils/Console");
27
-
28
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
-
30
22
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
31
-
32
23
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
33
-
34
24
  // use a function vs a template variable to avoid problems in loops
35
25
  function getFileDataTemplate() {
36
26
  return {
@@ -39,11 +29,10 @@ function getFileDataTemplate() {
39
29
  idp: {}
40
30
  };
41
31
  }
32
+
42
33
  /**
43
34
  * List providers
44
35
  */
45
-
46
-
47
36
  function listSocialProviders() {
48
37
  return _listSocialProviders.apply(this, arguments);
49
38
  }
@@ -52,8 +41,6 @@ function listSocialProviders() {
52
41
  * @param {String} providerId social identity provider id/name
53
42
  * @returns {Promise} a promise that resolves a social identity provider object
54
43
  */
55
-
56
-
57
44
  function _listSocialProviders() {
58
45
  _listSocialProviders = _asyncToGenerator(function* () {
59
46
  try {
@@ -69,7 +56,6 @@ function _listSocialProviders() {
69
56
  });
70
57
  return _listSocialProviders.apply(this, arguments);
71
58
  }
72
-
73
59
  function getSocialProvider(_x) {
74
60
  return _getSocialProvider.apply(this, arguments);
75
61
  }
@@ -78,20 +64,15 @@ function getSocialProvider(_x) {
78
64
  * @param {String} providerId provider id/name
79
65
  * @param {String} file optional export file name
80
66
  */
81
-
82
-
83
67
  function _getSocialProvider() {
84
68
  _getSocialProvider = _asyncToGenerator(function* (providerId) {
85
69
  return (0, _SocialIdentityProvidersApi.getSocialIdentityProviders)().then(response => {
86
70
  var foundProviders = response.result.filter(provider => provider._id === providerId);
87
-
88
71
  switch (foundProviders.length) {
89
72
  case 1:
90
73
  return foundProviders[0];
91
-
92
74
  case 0:
93
75
  throw new Error("Provider '".concat(providerId, "' not found"));
94
-
95
76
  default:
96
77
  throw new Error("".concat(foundProviders.length, " providers '").concat(providerId, "' found"));
97
78
  }
@@ -99,7 +80,6 @@ function _getSocialProvider() {
99
80
  });
100
81
  return _getSocialProvider.apply(this, arguments);
101
82
  }
102
-
103
83
  function exportSocialProviderToFile(_x2) {
104
84
  return _exportSocialProviderToFile.apply(this, arguments);
105
85
  }
@@ -107,31 +87,24 @@ function exportSocialProviderToFile(_x2) {
107
87
  * Export all providers
108
88
  * @param {String} file optional export file name
109
89
  */
110
-
111
-
112
90
  function _exportSocialProviderToFile() {
113
91
  _exportSocialProviderToFile = _asyncToGenerator(function* (providerId) {
114
92
  var file = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
115
93
  var fileName = file;
116
-
117
94
  if (!fileName) {
118
95
  fileName = (0, _ExportImportUtils.getTypedFilename)(providerId, 'idp');
119
96
  }
120
-
121
97
  (0, _Console.createProgressIndicator)(1, "Exporting ".concat(providerId));
122
-
123
98
  try {
124
99
  var idpData = yield getSocialProvider(providerId);
125
100
  (0, _Console.updateProgressIndicator)("Writing file ".concat(fileName));
126
101
  var fileData = getFileDataTemplate();
127
102
  fileData.idp[idpData._id] = idpData;
128
-
129
103
  if (idpData.transform) {
130
104
  var scriptData = yield (0, _ScriptApi.getScript)(idpData.transform);
131
105
  scriptData.script = (0, _ExportImportUtils.convertBase64TextToArray)(scriptData.script);
132
106
  fileData.script[idpData.transform] = scriptData;
133
107
  }
134
-
135
108
  (0, _ExportImportUtils.saveJsonToFile)(fileData, fileName);
136
109
  (0, _Console.stopProgressIndicator)("Exported ".concat(providerId['brightCyan'], " to ").concat(fileName['brightCyan'], "."));
137
110
  } catch (err) {
@@ -141,31 +114,24 @@ function _exportSocialProviderToFile() {
141
114
  });
142
115
  return _exportSocialProviderToFile.apply(this, arguments);
143
116
  }
144
-
145
117
  function exportSocialProvidersToFile(_x3) {
146
118
  return _exportSocialProvidersToFile.apply(this, arguments);
147
119
  }
148
120
  /**
149
121
  * Export all providers to individual files
150
122
  */
151
-
152
-
153
123
  function _exportSocialProvidersToFile() {
154
124
  _exportSocialProvidersToFile = _asyncToGenerator(function* (file) {
155
125
  var fileName = file;
156
-
157
126
  if (!fileName) {
158
127
  fileName = (0, _ExportImportUtils.getTypedFilename)("all".concat((0, _ExportImportUtils.getRealmString)(), "Providers"), 'idp');
159
128
  }
160
-
161
129
  var fileData = getFileDataTemplate();
162
130
  var allIdpsData = (yield (0, _SocialIdentityProvidersApi.getSocialIdentityProviders)()).result;
163
131
  (0, _Console.createProgressIndicator)(allIdpsData.length, 'Exporting providers');
164
-
165
132
  for (var idpData of allIdpsData) {
166
133
  (0, _Console.updateProgressIndicator)("Exporting provider ".concat(idpData._id));
167
134
  fileData.idp[idpData._id] = idpData;
168
-
169
135
  if (idpData.transform) {
170
136
  // eslint-disable-next-line no-await-in-loop
171
137
  var scriptData = yield (0, _ScriptApi.getScript)(idpData.transform);
@@ -173,13 +139,11 @@ function _exportSocialProvidersToFile() {
173
139
  fileData.script[idpData.transform] = scriptData;
174
140
  }
175
141
  }
176
-
177
142
  (0, _ExportImportUtils.saveJsonToFile)(fileData, fileName);
178
143
  (0, _Console.stopProgressIndicator)("".concat(allIdpsData.length, " providers exported to ").concat(fileName, "."));
179
144
  });
180
145
  return _exportSocialProvidersToFile.apply(this, arguments);
181
146
  }
182
-
183
147
  function exportSocialProvidersToFiles() {
184
148
  return _exportSocialProvidersToFiles.apply(this, arguments);
185
149
  }
@@ -188,35 +152,28 @@ function exportSocialProvidersToFiles() {
188
152
  * @param {String} providerId provider id/name
189
153
  * @param {String} file import file name
190
154
  */
191
-
192
-
193
155
  function _exportSocialProvidersToFiles() {
194
156
  _exportSocialProvidersToFiles = _asyncToGenerator(function* () {
195
- var allIdpsData = yield (yield (0, _SocialIdentityProvidersApi.getSocialIdentityProviders)()).result; // printMessage(allIdpsData, 'data');
196
-
157
+ var allIdpsData = yield (yield (0, _SocialIdentityProvidersApi.getSocialIdentityProviders)()).result;
158
+ // printMessage(allIdpsData, 'data');
197
159
  (0, _Console.createProgressIndicator)(allIdpsData.length, 'Exporting providers');
198
-
199
160
  for (var idpData of allIdpsData) {
200
161
  (0, _Console.updateProgressIndicator)("Writing provider ".concat(idpData._id));
201
162
  var fileName = (0, _ExportImportUtils.getTypedFilename)(idpData._id, 'idp');
202
163
  var fileData = getFileDataTemplate();
203
164
  fileData.idp[idpData._id] = idpData;
204
-
205
165
  if (idpData.transform) {
206
166
  // eslint-disable-next-line no-await-in-loop
207
167
  var scriptData = yield (0, _ScriptApi.getScript)(idpData.transform);
208
168
  scriptData.script = (0, _ExportImportUtils.convertBase64TextToArray)(scriptData.script);
209
169
  fileData.script[idpData.transform] = scriptData;
210
170
  }
211
-
212
171
  (0, _ExportImportUtils.saveJsonToFile)(fileData, fileName);
213
172
  }
214
-
215
173
  (0, _Console.stopProgressIndicator)("".concat(allIdpsData.length, " providers exported."));
216
174
  });
217
175
  return _exportSocialProvidersToFiles.apply(this, arguments);
218
176
  }
219
-
220
177
  function importSocialProviderFromFile(_x4, _x5) {
221
178
  return _importSocialProviderFromFile.apply(this, arguments);
222
179
  }
@@ -224,19 +181,15 @@ function importSocialProviderFromFile(_x4, _x5) {
224
181
  * Import first provider from file
225
182
  * @param {String} file import file name
226
183
  */
227
-
228
-
229
184
  function _importSocialProviderFromFile() {
230
185
  _importSocialProviderFromFile = _asyncToGenerator(function* (providerId, file) {
231
186
  _fs.default.readFile(file, 'utf8', /*#__PURE__*/function () {
232
187
  var _ref = _asyncToGenerator(function* (err, data) {
233
188
  if (err) throw err;
234
189
  var fileData = JSON.parse(data);
235
-
236
190
  if ((0, _ExportImportUtils.validateImport)(fileData.meta)) {
237
191
  (0, _Console.createProgressIndicator)(1, 'Importing provider...');
238
192
  var found = false;
239
-
240
193
  var _loop = function* _loop(idpId) {
241
194
  if ({}.hasOwnProperty.call(fileData.idp, idpId)) {
242
195
  if (idpId === providerId) {
@@ -244,13 +197,11 @@ function _importSocialProviderFromFile() {
244
197
  (0, _Console.updateProgressIndicator)("Importing ".concat(fileData.idp[idpId]._id));
245
198
  var scriptId = fileData.idp[idpId].transform;
246
199
  var scriptData = fileData.script[scriptId];
247
-
248
200
  if (scriptId && scriptData) {
249
- scriptData.script = (0, _ExportImportUtils.convertTextArrayToBase64)(scriptData.script); // eslint-disable-next-line no-await-in-loop
250
-
201
+ scriptData.script = (0, _ExportImportUtils.convertTextArrayToBase64)(scriptData.script);
202
+ // eslint-disable-next-line no-await-in-loop
251
203
  yield (0, _ScriptOps.createOrUpdateScript)(fileData.idp[idpId].transform, fileData.script[fileData.idp[idpId].transform]);
252
204
  }
253
-
254
205
  (0, _SocialIdentityProvidersApi.putProviderByTypeAndId)(fileData.idp[idpId]._type._id, idpId, fileData.idp[idpId]).then(() => {
255
206
  (0, _Console.stopProgressIndicator)("Successfully imported provider ".concat(providerId, "."));
256
207
  }).catch(importProviderErr => {
@@ -262,13 +213,10 @@ function _importSocialProviderFromFile() {
262
213
  }
263
214
  }
264
215
  };
265
-
266
216
  for (var idpId in fileData.idp) {
267
217
  var _ret = yield* _loop(idpId);
268
-
269
218
  if (_ret === "break") break;
270
219
  }
271
-
272
220
  if (!found) {
273
221
  (0, _Console.stopProgressIndicator)("Provider ".concat(providerId.brightCyan, " not found in ").concat(file.brightCyan, "!"));
274
222
  }
@@ -276,7 +224,6 @@ function _importSocialProviderFromFile() {
276
224
  (0, _Console.printMessage)('Import validation failed...', 'error');
277
225
  }
278
226
  });
279
-
280
227
  return function (_x8, _x9) {
281
228
  return _ref.apply(this, arguments);
282
229
  };
@@ -284,7 +231,6 @@ function _importSocialProviderFromFile() {
284
231
  });
285
232
  return _importSocialProviderFromFile.apply(this, arguments);
286
233
  }
287
-
288
234
  function importFirstSocialProviderFromFile(_x6) {
289
235
  return _importFirstSocialProviderFromFile.apply(this, arguments);
290
236
  }
@@ -292,30 +238,24 @@ function importFirstSocialProviderFromFile(_x6) {
292
238
  * Import all providers from file
293
239
  * @param {String} file import file name
294
240
  */
295
-
296
-
297
241
  function _importFirstSocialProviderFromFile() {
298
242
  _importFirstSocialProviderFromFile = _asyncToGenerator(function* (file) {
299
243
  _fs.default.readFile(file, 'utf8', /*#__PURE__*/function () {
300
244
  var _ref2 = _asyncToGenerator(function* (err, data) {
301
245
  if (err) throw err;
302
246
  var fileData = JSON.parse(data);
303
-
304
247
  if ((0, _ExportImportUtils.validateImport)(fileData.meta)) {
305
248
  (0, _Console.createProgressIndicator)(1, 'Importing provider...');
306
-
307
249
  var _loop2 = function* _loop2(idpId) {
308
250
  if ({}.hasOwnProperty.call(fileData.idp, idpId)) {
309
251
  (0, _Console.updateProgressIndicator)("Importing ".concat(fileData.idp[idpId]._id));
310
252
  var scriptId = fileData.idp[idpId].transform;
311
253
  var scriptData = fileData.script[scriptId];
312
-
313
254
  if (scriptId && scriptData) {
314
- scriptData.script = (0, _ExportImportUtils.convertTextArrayToBase64)(scriptData.script); // eslint-disable-next-line no-await-in-loop
315
-
255
+ scriptData.script = (0, _ExportImportUtils.convertTextArrayToBase64)(scriptData.script);
256
+ // eslint-disable-next-line no-await-in-loop
316
257
  yield (0, _ScriptOps.createOrUpdateScript)(fileData.idp[idpId].transform, fileData.script[fileData.idp[idpId].transform]);
317
258
  }
318
-
319
259
  (0, _SocialIdentityProvidersApi.putProviderByTypeAndId)(fileData.idp[idpId]._type._id, idpId, fileData.idp[idpId]).then(result => {
320
260
  if (result == null) {
321
261
  (0, _Console.stopProgressIndicator)("Error importing provider ".concat(fileData.idp[idpId]._id));
@@ -327,17 +267,14 @@ function _importFirstSocialProviderFromFile() {
327
267
  return "break";
328
268
  }
329
269
  };
330
-
331
270
  for (var idpId in fileData.idp) {
332
271
  var _ret2 = yield* _loop2(idpId);
333
-
334
272
  if (_ret2 === "break") break;
335
273
  }
336
274
  } else {
337
275
  (0, _Console.printMessage)('Import validation failed...', 'error');
338
276
  }
339
277
  });
340
-
341
278
  return function (_x10, _x11) {
342
279
  return _ref2.apply(this, arguments);
343
280
  };
@@ -345,51 +282,41 @@ function _importFirstSocialProviderFromFile() {
345
282
  });
346
283
  return _importFirstSocialProviderFromFile.apply(this, arguments);
347
284
  }
348
-
349
285
  function importSocialProvidersFromFile(_x7) {
350
286
  return _importSocialProvidersFromFile.apply(this, arguments);
351
287
  }
352
288
  /**
353
289
  * Import providers from *.idp.json files in current working directory
354
290
  */
355
-
356
-
357
291
  function _importSocialProvidersFromFile() {
358
292
  _importSocialProvidersFromFile = _asyncToGenerator(function* (file) {
359
293
  _fs.default.readFile(file, 'utf8', /*#__PURE__*/function () {
360
294
  var _ref3 = _asyncToGenerator(function* (err, data) {
361
295
  if (err) throw err;
362
296
  var fileData = JSON.parse(data);
363
-
364
297
  if ((0, _ExportImportUtils.validateImport)(fileData.meta)) {
365
298
  (0, _Console.createProgressIndicator)(Object.keys(fileData.idp).length, 'Importing providers...');
366
-
367
299
  for (var idpId in fileData.idp) {
368
300
  if ({}.hasOwnProperty.call(fileData.idp, idpId)) {
369
301
  var scriptId = fileData.idp[idpId].transform;
370
302
  var scriptData = fileData.script[scriptId];
371
-
372
303
  if (scriptId && scriptData) {
373
- scriptData.script = (0, _ExportImportUtils.convertTextArrayToBase64)(scriptData.script); // eslint-disable-next-line no-await-in-loop
374
-
304
+ scriptData.script = (0, _ExportImportUtils.convertTextArrayToBase64)(scriptData.script);
305
+ // eslint-disable-next-line no-await-in-loop
375
306
  yield (0, _ScriptOps.createOrUpdateScript)(fileData.idp[idpId].transform, fileData.script[fileData.idp[idpId].transform]);
376
- } // eslint-disable-next-line no-await-in-loop
377
-
378
-
307
+ }
308
+ // eslint-disable-next-line no-await-in-loop
379
309
  var result = yield (0, _SocialIdentityProvidersApi.putProviderByTypeAndId)(fileData.idp[idpId]._type._id, idpId, fileData.idp[idpId]);
380
-
381
310
  if (!result) {
382
311
  (0, _Console.updateProgressIndicator)("Successfully imported ".concat(fileData.idp[idpId].name));
383
312
  }
384
313
  }
385
314
  }
386
-
387
315
  (0, _Console.stopProgressIndicator)("Providers imported.");
388
316
  } else {
389
317
  (0, _Console.printMessage)('Import validation failed...', 'error');
390
318
  }
391
319
  });
392
-
393
320
  return function (_x12, _x13) {
394
321
  return _ref3.apply(this, arguments);
395
322
  };
@@ -397,45 +324,35 @@ function _importSocialProvidersFromFile() {
397
324
  });
398
325
  return _importSocialProvidersFromFile.apply(this, arguments);
399
326
  }
400
-
401
327
  function importSocialProvidersFromFiles() {
402
328
  return _importSocialProvidersFromFiles.apply(this, arguments);
403
329
  }
404
-
405
330
  function _importSocialProvidersFromFiles() {
406
331
  _importSocialProvidersFromFiles = _asyncToGenerator(function* () {
407
332
  var names = _fs.default.readdirSync('.');
408
-
409
333
  var jsonFiles = names.filter(name => name.toLowerCase().endsWith('.idp.json'));
410
334
  (0, _Console.createProgressIndicator)(jsonFiles.length, 'Importing providers...');
411
335
  var total = 0;
412
-
413
336
  for (var file of jsonFiles) {
414
337
  var data = _fs.default.readFileSync(file, 'utf8');
415
-
416
338
  var fileData = JSON.parse(data);
417
-
418
339
  if ((0, _ExportImportUtils.validateImport)(fileData.meta)) {
419
340
  var count = Object.keys(fileData.idp).length;
420
341
  total += count;
421
-
422
342
  for (var idpId in fileData.idp) {
423
343
  if ({}.hasOwnProperty.call(fileData.idp, idpId)) {
424
344
  // eslint-disable-next-line no-await-in-loop
425
345
  var result = yield (0, _SocialIdentityProvidersApi.putProviderByTypeAndId)(fileData.idp[idpId]._type._id, idpId, fileData.idp[idpId]);
426
-
427
346
  if (result == null) {
428
347
  (0, _Console.printMessage)("Error importing ".concat(count, " providers from ").concat(file), 'error');
429
348
  }
430
349
  }
431
350
  }
432
-
433
351
  (0, _Console.updateProgressIndicator)("Imported ".concat(count, " provider(s) from ").concat(file));
434
352
  } else {
435
353
  (0, _Console.printMessage)("Validation of ".concat(file, " failed!"), 'error');
436
354
  }
437
355
  }
438
-
439
356
  (0, _Console.stopProgressIndicator)("Finished importing ".concat(total, " provider(s) from ").concat(jsonFiles.length, " file(s)."));
440
357
  });
441
358
  return _importSocialProvidersFromFiles.apply(this, arguments);