@rockcarver/frodo-cli 2.0.0-5 → 2.0.0-7

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 (344) hide show
  1. package/CHANGELOG.md +39 -1
  2. package/esm/app.js +4 -1
  3. package/esm/app.js.map +1 -1
  4. package/esm/cli/_template/something-delete.js +4 -1
  5. package/esm/cli/_template/something-delete.js.map +1 -1
  6. package/esm/cli/_template/something-describe.js +4 -1
  7. package/esm/cli/_template/something-describe.js.map +1 -1
  8. package/esm/cli/_template/something-else-delete.js +4 -1
  9. package/esm/cli/_template/something-else-delete.js.map +1 -1
  10. package/esm/cli/_template/something-else-describe.js +4 -1
  11. package/esm/cli/_template/something-else-describe.js.map +1 -1
  12. package/esm/cli/_template/something-else-export.js +4 -1
  13. package/esm/cli/_template/something-else-export.js.map +1 -1
  14. package/esm/cli/_template/something-else-import.js +4 -1
  15. package/esm/cli/_template/something-else-import.js.map +1 -1
  16. package/esm/cli/_template/something-else-list.js +4 -1
  17. package/esm/cli/_template/something-else-list.js.map +1 -1
  18. package/esm/cli/_template/something-export.js +4 -1
  19. package/esm/cli/_template/something-export.js.map +1 -1
  20. package/esm/cli/_template/something-import.js +4 -1
  21. package/esm/cli/_template/something-import.js.map +1 -1
  22. package/esm/cli/_template/something-list.js +4 -1
  23. package/esm/cli/_template/something-list.js.map +1 -1
  24. package/esm/cli/_template/something-other-delete.js +4 -1
  25. package/esm/cli/_template/something-other-delete.js.map +1 -1
  26. package/esm/cli/_template/something-other-describe.js +4 -1
  27. package/esm/cli/_template/something-other-describe.js.map +1 -1
  28. package/esm/cli/_template/something-other-export.js +4 -1
  29. package/esm/cli/_template/something-other-export.js.map +1 -1
  30. package/esm/cli/_template/something-other-import.js +4 -1
  31. package/esm/cli/_template/something-other-import.js.map +1 -1
  32. package/esm/cli/_template/something-other-list.js +4 -1
  33. package/esm/cli/_template/something-other-list.js.map +1 -1
  34. package/esm/cli/admin/admin-add-autoid-static-user-mapping.js +8 -2
  35. package/esm/cli/admin/admin-add-autoid-static-user-mapping.js.map +1 -1
  36. package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js +10 -3
  37. package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js.map +1 -1
  38. package/esm/cli/admin/admin-federation-export.js +45 -0
  39. package/esm/cli/admin/admin-federation-export.js.map +1 -0
  40. package/esm/cli/admin/admin-federation-import.js +49 -0
  41. package/esm/cli/admin/admin-federation-import.js.map +1 -0
  42. package/esm/cli/admin/admin-federation-list.js +29 -0
  43. package/esm/cli/admin/admin-federation-list.js.map +1 -0
  44. package/esm/cli/admin/admin-federation.js +13 -0
  45. package/esm/cli/admin/admin-federation.js.map +1 -0
  46. package/esm/cli/admin/admin-get-access-token.js +8 -2
  47. package/esm/cli/admin/admin-get-access-token.js.map +1 -1
  48. package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +8 -2
  49. package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +1 -1
  50. package/esm/cli/admin/admin-hide-generic-extension-attributes.js +8 -2
  51. package/esm/cli/admin/admin-hide-generic-extension-attributes.js.map +1 -1
  52. package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +8 -2
  53. package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js.map +1 -1
  54. package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +8 -2
  55. package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js.map +1 -1
  56. package/esm/cli/admin/admin-list-static-user-mappings.js +8 -2
  57. package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
  58. package/esm/cli/admin/admin-remove-static-user-mapping.js +8 -2
  59. package/esm/cli/admin/admin-remove-static-user-mapping.js.map +1 -1
  60. package/esm/cli/admin/admin-repair-org-model.js +8 -2
  61. package/esm/cli/admin/admin-repair-org-model.js.map +1 -1
  62. package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +8 -2
  63. package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js.map +1 -1
  64. package/esm/cli/admin/admin-show-generic-extension-attributes.js +8 -2
  65. package/esm/cli/admin/admin-show-generic-extension-attributes.js.map +1 -1
  66. package/esm/cli/admin/admin.js +1 -0
  67. package/esm/cli/admin/admin.js.map +1 -1
  68. package/esm/cli/agent/agent-delete.js +10 -3
  69. package/esm/cli/agent/agent-delete.js.map +1 -1
  70. package/esm/cli/agent/agent-describe.js +4 -1
  71. package/esm/cli/agent/agent-describe.js.map +1 -1
  72. package/esm/cli/agent/agent-export.js +4 -1
  73. package/esm/cli/agent/agent-export.js.map +1 -1
  74. package/esm/cli/agent/agent-gateway-delete.js +10 -3
  75. package/esm/cli/agent/agent-gateway-delete.js.map +1 -1
  76. package/esm/cli/agent/agent-gateway-describe.js +4 -1
  77. package/esm/cli/agent/agent-gateway-describe.js.map +1 -1
  78. package/esm/cli/agent/agent-gateway-export.js +4 -1
  79. package/esm/cli/agent/agent-gateway-export.js.map +1 -1
  80. package/esm/cli/agent/agent-gateway-import.js +4 -1
  81. package/esm/cli/agent/agent-gateway-import.js.map +1 -1
  82. package/esm/cli/agent/agent-gateway-list.js +4 -1
  83. package/esm/cli/agent/agent-gateway-list.js.map +1 -1
  84. package/esm/cli/agent/agent-import.js +4 -1
  85. package/esm/cli/agent/agent-import.js.map +1 -1
  86. package/esm/cli/agent/agent-java-delete.js +10 -3
  87. package/esm/cli/agent/agent-java-delete.js.map +1 -1
  88. package/esm/cli/agent/agent-java-describe.js +4 -1
  89. package/esm/cli/agent/agent-java-describe.js.map +1 -1
  90. package/esm/cli/agent/agent-java-export.js +4 -1
  91. package/esm/cli/agent/agent-java-export.js.map +1 -1
  92. package/esm/cli/agent/agent-java-import.js +4 -1
  93. package/esm/cli/agent/agent-java-import.js.map +1 -1
  94. package/esm/cli/agent/agent-java-list.js +4 -1
  95. package/esm/cli/agent/agent-java-list.js.map +1 -1
  96. package/esm/cli/agent/agent-list.js +4 -1
  97. package/esm/cli/agent/agent-list.js.map +1 -1
  98. package/esm/cli/agent/agent-web-delete.js +10 -3
  99. package/esm/cli/agent/agent-web-delete.js.map +1 -1
  100. package/esm/cli/agent/agent-web-describe.js +4 -1
  101. package/esm/cli/agent/agent-web-describe.js.map +1 -1
  102. package/esm/cli/agent/agent-web-export.js +4 -1
  103. package/esm/cli/agent/agent-web-export.js.map +1 -1
  104. package/esm/cli/agent/agent-web-import.js +4 -1
  105. package/esm/cli/agent/agent-web-import.js.map +1 -1
  106. package/esm/cli/agent/agent-web-list.js +4 -1
  107. package/esm/cli/agent/agent-web-list.js.map +1 -1
  108. package/esm/cli/app/app-delete.js +4 -1
  109. package/esm/cli/app/app-delete.js.map +1 -1
  110. package/esm/cli/app/app-describe.js +4 -1
  111. package/esm/cli/app/app-describe.js.map +1 -1
  112. package/esm/cli/app/app-export.js +6 -3
  113. package/esm/cli/app/app-export.js.map +1 -1
  114. package/esm/cli/app/app-import.js +7 -4
  115. package/esm/cli/app/app-import.js.map +1 -1
  116. package/esm/cli/app/app-list.js +4 -1
  117. package/esm/cli/app/app-list.js.map +1 -1
  118. package/esm/cli/authz/authz-policy-delete.js +6 -3
  119. package/esm/cli/authz/authz-policy-delete.js.map +1 -1
  120. package/esm/cli/authz/authz-policy-describe.js +4 -1
  121. package/esm/cli/authz/authz-policy-describe.js.map +1 -1
  122. package/esm/cli/authz/authz-policy-export.js +8 -5
  123. package/esm/cli/authz/authz-policy-export.js.map +1 -1
  124. package/esm/cli/authz/authz-policy-import.js +7 -4
  125. package/esm/cli/authz/authz-policy-import.js.map +1 -1
  126. package/esm/cli/authz/authz-policy-list.js +5 -2
  127. package/esm/cli/authz/authz-policy-list.js.map +1 -1
  128. package/esm/cli/authz/authz-set-delete.js +5 -2
  129. package/esm/cli/authz/authz-set-delete.js.map +1 -1
  130. package/esm/cli/authz/authz-set-describe.js +4 -1
  131. package/esm/cli/authz/authz-set-describe.js.map +1 -1
  132. package/esm/cli/authz/authz-set-export.js +6 -3
  133. package/esm/cli/authz/authz-set-export.js.map +1 -1
  134. package/esm/cli/authz/authz-set-import.js +7 -4
  135. package/esm/cli/authz/authz-set-import.js.map +1 -1
  136. package/esm/cli/authz/authz-set-list.js +4 -1
  137. package/esm/cli/authz/authz-set-list.js.map +1 -1
  138. package/esm/cli/authz/authz-type-delete.js +6 -3
  139. package/esm/cli/authz/authz-type-delete.js.map +1 -1
  140. package/esm/cli/authz/authz-type-describe.js +5 -2
  141. package/esm/cli/authz/authz-type-describe.js.map +1 -1
  142. package/esm/cli/authz/authz-type-export.js +7 -4
  143. package/esm/cli/authz/authz-type-export.js.map +1 -1
  144. package/esm/cli/authz/authz-type-import.js +8 -5
  145. package/esm/cli/authz/authz-type-import.js.map +1 -1
  146. package/esm/cli/authz/authz-type-list.js +4 -1
  147. package/esm/cli/authz/authz-type-list.js.map +1 -1
  148. package/esm/cli/conn/conn-save.js +18 -5
  149. package/esm/cli/conn/conn-save.js.map +1 -1
  150. package/esm/cli/email/email-template-export.js +6 -3
  151. package/esm/cli/email/email-template-export.js.map +1 -1
  152. package/esm/cli/email/email-template-import.js +7 -4
  153. package/esm/cli/email/email-template-import.js.map +1 -1
  154. package/esm/cli/email/email-template-list.js +4 -1
  155. package/esm/cli/email/email-template-list.js.map +1 -1
  156. package/esm/cli/esv/esv-apply.js +15 -5
  157. package/esm/cli/esv/esv-apply.js.map +1 -1
  158. package/esm/cli/esv/esv-secret-create.js +4 -1
  159. package/esm/cli/esv/esv-secret-create.js.map +1 -1
  160. package/esm/cli/esv/esv-secret-delete.js +5 -2
  161. package/esm/cli/esv/esv-secret-delete.js.map +1 -1
  162. package/esm/cli/esv/esv-secret-describe.js +4 -1
  163. package/esm/cli/esv/esv-secret-describe.js.map +1 -1
  164. package/esm/cli/esv/esv-secret-export.js +4 -1
  165. package/esm/cli/esv/esv-secret-export.js.map +1 -1
  166. package/esm/cli/esv/esv-secret-import.js +4 -1
  167. package/esm/cli/esv/esv-secret-import.js.map +1 -1
  168. package/esm/cli/esv/esv-secret-list.js +4 -1
  169. package/esm/cli/esv/esv-secret-list.js.map +1 -1
  170. package/esm/cli/esv/esv-secret-set.js +4 -1
  171. package/esm/cli/esv/esv-secret-set.js.map +1 -1
  172. package/esm/cli/esv/esv-secret-version-activate.js +4 -1
  173. package/esm/cli/esv/esv-secret-version-activate.js.map +1 -1
  174. package/esm/cli/esv/esv-secret-version-create.js +4 -1
  175. package/esm/cli/esv/esv-secret-version-create.js.map +1 -1
  176. package/esm/cli/esv/esv-secret-version-deactivate.js +4 -1
  177. package/esm/cli/esv/esv-secret-version-deactivate.js.map +1 -1
  178. package/esm/cli/esv/esv-secret-version-delete.js +5 -2
  179. package/esm/cli/esv/esv-secret-version-delete.js.map +1 -1
  180. package/esm/cli/esv/esv-secret-version-list.js +4 -1
  181. package/esm/cli/esv/esv-secret-version-list.js.map +1 -1
  182. package/esm/cli/esv/esv-variable-create.js +4 -1
  183. package/esm/cli/esv/esv-variable-create.js.map +1 -1
  184. package/esm/cli/esv/esv-variable-delete.js +5 -2
  185. package/esm/cli/esv/esv-variable-delete.js.map +1 -1
  186. package/esm/cli/esv/esv-variable-describe.js +4 -1
  187. package/esm/cli/esv/esv-variable-describe.js.map +1 -1
  188. package/esm/cli/esv/esv-variable-export.js +4 -1
  189. package/esm/cli/esv/esv-variable-export.js.map +1 -1
  190. package/esm/cli/esv/esv-variable-import.js +4 -1
  191. package/esm/cli/esv/esv-variable-import.js.map +1 -1
  192. package/esm/cli/esv/esv-variable-list.js +4 -1
  193. package/esm/cli/esv/esv-variable-list.js.map +1 -1
  194. package/esm/cli/esv/esv-variable-set.js +5 -2
  195. package/esm/cli/esv/esv-variable-set.js.map +1 -1
  196. package/esm/cli/idm/idm-count.js +4 -1
  197. package/esm/cli/idm/idm-count.js.map +1 -1
  198. package/esm/cli/idm/idm-export.js +6 -3
  199. package/esm/cli/idm/idm-export.js.map +1 -1
  200. package/esm/cli/idm/idm-import.js +7 -4
  201. package/esm/cli/idm/idm-import.js.map +1 -1
  202. package/esm/cli/idm/idm-list.js +4 -1
  203. package/esm/cli/idm/idm-list.js.map +1 -1
  204. package/esm/cli/idp/idp-export.js +4 -1
  205. package/esm/cli/idp/idp-export.js.map +1 -1
  206. package/esm/cli/idp/idp-import.js +7 -4
  207. package/esm/cli/idp/idp-import.js.map +1 -1
  208. package/esm/cli/idp/idp-list.js +4 -1
  209. package/esm/cli/idp/idp-list.js.map +1 -1
  210. package/esm/cli/info/info.js +8 -2
  211. package/esm/cli/info/info.js.map +1 -1
  212. package/esm/cli/journey/journey-delete.js +5 -2
  213. package/esm/cli/journey/journey-delete.js.map +1 -1
  214. package/esm/cli/journey/journey-describe.js +14 -6
  215. package/esm/cli/journey/journey-describe.js.map +1 -1
  216. package/esm/cli/journey/journey-disable.js +8 -2
  217. package/esm/cli/journey/journey-disable.js.map +1 -1
  218. package/esm/cli/journey/journey-enable.js +8 -2
  219. package/esm/cli/journey/journey-enable.js.map +1 -1
  220. package/esm/cli/journey/journey-export.js +6 -3
  221. package/esm/cli/journey/journey-export.js.map +1 -1
  222. package/esm/cli/journey/journey-import.js +7 -4
  223. package/esm/cli/journey/journey-import.js.map +1 -1
  224. package/esm/cli/journey/journey-list.js +4 -1
  225. package/esm/cli/journey/journey-list.js.map +1 -1
  226. package/esm/cli/journey/journey-prune.js +10 -3
  227. package/esm/cli/journey/journey-prune.js.map +1 -1
  228. package/esm/cli/log/log-fetch.js +16 -6
  229. package/esm/cli/log/log-fetch.js.map +1 -1
  230. package/esm/cli/log/log-key-delete.js +5 -2
  231. package/esm/cli/log/log-key-delete.js.map +1 -1
  232. package/esm/cli/log/log-key-describe.js +4 -1
  233. package/esm/cli/log/log-key-describe.js.map +1 -1
  234. package/esm/cli/log/log-key-list.js +4 -1
  235. package/esm/cli/log/log-key-list.js.map +1 -1
  236. package/esm/cli/log/log-list.js +14 -4
  237. package/esm/cli/log/log-list.js.map +1 -1
  238. package/esm/cli/log/log-tail.js +16 -6
  239. package/esm/cli/log/log-tail.js.map +1 -1
  240. package/esm/cli/realm/realm-add-custom-domain.js +4 -1
  241. package/esm/cli/realm/realm-add-custom-domain.js.map +1 -1
  242. package/esm/cli/realm/realm-describe.js +4 -1
  243. package/esm/cli/realm/realm-describe.js.map +1 -1
  244. package/esm/cli/realm/realm-list.js +4 -1
  245. package/esm/cli/realm/realm-list.js.map +1 -1
  246. package/esm/cli/realm/realm-remove-custom-domain.js +8 -2
  247. package/esm/cli/realm/realm-remove-custom-domain.js.map +1 -1
  248. package/esm/cli/saml/saml-cot-export.js +6 -3
  249. package/esm/cli/saml/saml-cot-export.js.map +1 -1
  250. package/esm/cli/saml/saml-cot-import.js +7 -4
  251. package/esm/cli/saml/saml-cot-import.js.map +1 -1
  252. package/esm/cli/saml/saml-cot-list.js +4 -1
  253. package/esm/cli/saml/saml-cot-list.js.map +1 -1
  254. package/esm/cli/saml/saml-delete.js +11 -4
  255. package/esm/cli/saml/saml-delete.js.map +1 -1
  256. package/esm/cli/saml/saml-describe.js +4 -1
  257. package/esm/cli/saml/saml-describe.js.map +1 -1
  258. package/esm/cli/saml/saml-export.js +6 -3
  259. package/esm/cli/saml/saml-export.js.map +1 -1
  260. package/esm/cli/saml/saml-import.js +7 -4
  261. package/esm/cli/saml/saml-import.js.map +1 -1
  262. package/esm/cli/saml/saml-list.js +4 -1
  263. package/esm/cli/saml/saml-list.js.map +1 -1
  264. package/esm/cli/saml/saml-metadata-export.js +5 -2
  265. package/esm/cli/saml/saml-metadata-export.js.map +1 -1
  266. package/esm/cli/script/script-delete.js +4 -1
  267. package/esm/cli/script/script-delete.js.map +1 -1
  268. package/esm/cli/script/script-describe.js +4 -1
  269. package/esm/cli/script/script-describe.js.map +1 -1
  270. package/esm/cli/script/script-export.js +4 -1
  271. package/esm/cli/script/script-export.js.map +1 -1
  272. package/esm/cli/script/script-import.js +4 -1
  273. package/esm/cli/script/script-import.js.map +1 -1
  274. package/esm/cli/script/script-list.js +4 -1
  275. package/esm/cli/script/script-list.js.map +1 -1
  276. package/esm/cli/service/service-delete.js +5 -2
  277. package/esm/cli/service/service-delete.js.map +1 -1
  278. package/esm/cli/service/service-export.js +6 -3
  279. package/esm/cli/service/service-export.js.map +1 -1
  280. package/esm/cli/service/service-import.js +7 -4
  281. package/esm/cli/service/service-import.js.map +1 -1
  282. package/esm/cli/service/service-list.js +4 -1
  283. package/esm/cli/service/service-list.js.map +1 -1
  284. package/esm/cli/theme/theme-delete.js +6 -3
  285. package/esm/cli/theme/theme-delete.js.map +1 -1
  286. package/esm/cli/theme/theme-export.js +7 -4
  287. package/esm/cli/theme/theme-export.js.map +1 -1
  288. package/esm/cli/theme/theme-import.js +8 -5
  289. package/esm/cli/theme/theme-import.js.map +1 -1
  290. package/esm/cli/theme/theme-list.js +4 -1
  291. package/esm/cli/theme/theme-list.js.map +1 -1
  292. package/esm/ops/AdminFederationOps.js +216 -0
  293. package/esm/ops/AdminFederationOps.js.map +1 -0
  294. package/esm/ops/AgentOps.js +62 -36
  295. package/esm/ops/AgentOps.js.map +1 -1
  296. package/esm/ops/CirclesOfTrustOps.js +22 -10
  297. package/esm/ops/CirclesOfTrustOps.js.map +1 -1
  298. package/esm/ops/ConnectionProfileOps.js +10 -3
  299. package/esm/ops/ConnectionProfileOps.js.map +1 -1
  300. package/esm/ops/EmailTemplateOps.js +23 -15
  301. package/esm/ops/EmailTemplateOps.js.map +1 -1
  302. package/esm/ops/IdmOps.js +34 -21
  303. package/esm/ops/IdmOps.js.map +1 -1
  304. package/esm/ops/IdpOps.js +17 -9
  305. package/esm/ops/IdpOps.js.map +1 -1
  306. package/esm/ops/JourneyOps.js +46 -30
  307. package/esm/ops/JourneyOps.js.map +1 -1
  308. package/esm/ops/LogOps.js +21 -11
  309. package/esm/ops/LogOps.js.map +1 -1
  310. package/esm/ops/NodeOps.js +5 -2
  311. package/esm/ops/NodeOps.js.map +1 -1
  312. package/esm/ops/OAuth2ClientOps.js +26 -13
  313. package/esm/ops/OAuth2ClientOps.js.map +1 -1
  314. package/esm/ops/OrganizationOps.js +8 -2
  315. package/esm/ops/OrganizationOps.js.map +1 -1
  316. package/esm/ops/PolicyOps.js +36 -21
  317. package/esm/ops/PolicyOps.js.map +1 -1
  318. package/esm/ops/PolicySetOps.js +35 -18
  319. package/esm/ops/PolicySetOps.js.map +1 -1
  320. package/esm/ops/RealmOps.js +11 -6
  321. package/esm/ops/RealmOps.js.map +1 -1
  322. package/esm/ops/ResourceTypeOps.js +34 -18
  323. package/esm/ops/ResourceTypeOps.js.map +1 -1
  324. package/esm/ops/Saml2Ops.js +43 -23
  325. package/esm/ops/Saml2Ops.js.map +1 -1
  326. package/esm/ops/ScriptOps.js +18 -10
  327. package/esm/ops/ScriptOps.js.map +1 -1
  328. package/esm/ops/SecretsOps.js +28 -14
  329. package/esm/ops/SecretsOps.js.map +1 -1
  330. package/esm/ops/ServiceOps.js +38 -17
  331. package/esm/ops/ServiceOps.js.map +1 -1
  332. package/esm/ops/ThemeOps.js +35 -19
  333. package/esm/ops/ThemeOps.js.map +1 -1
  334. package/esm/ops/VariablesOps.js +23 -12
  335. package/esm/ops/VariablesOps.js.map +1 -1
  336. package/esm/utils/Config.js +6 -3
  337. package/esm/utils/Config.js.map +1 -1
  338. package/esm/utils/Console.js +5 -2
  339. package/esm/utils/Console.js.map +1 -1
  340. package/esm/utils/ExportImportUtils.js +6 -3
  341. package/esm/utils/ExportImportUtils.js.map +1 -1
  342. package/esm/utils/Version.js +7 -3
  343. package/esm/utils/Version.js.map +1 -1
  344. package/package.json +2 -2
package/esm/ops/IdmOps.js CHANGED
@@ -1,19 +1,32 @@
1
- /* eslint-disable no-await-in-loop */
1
+ import { frodo } from '@rockcarver/frodo-lib';
2
2
  import fs from 'fs';
3
3
  import fse from 'fs-extra';
4
4
  import path from 'path';
5
5
  import propertiesReader from 'properties-reader';
6
6
  import replaceall from 'replaceall';
7
- import { frodo } from '@rockcarver/frodo-lib';
8
7
  import { createProgressIndicator, printMessage, stopProgressIndicator } from '../utils/Console';
9
8
  import { getTypedFilename } from '../utils/ExportImportUtils';
9
+ const {
10
+ validateScriptHooks
11
+ } = frodo.helper.script;
12
+ const {
13
+ readFiles,
14
+ unSubstituteEnvParams
15
+ } = frodo.helper.utils;
16
+ const {
17
+ testConnectorServers,
18
+ getAllConfigEntities,
19
+ getConfigEntity,
20
+ putConfigEntity,
21
+ queryAllManagedObjectsByType
22
+ } = frodo.idm.config;
10
23
 
11
24
  /**
12
25
  * Warn about and list offline remote connector servers
13
26
  */
14
27
  export async function warnAboutOfflineConnectorServers() {
15
28
  try {
16
- const all = await frodo.idm.config.testConnectorServers();
29
+ const all = await testConnectorServers();
17
30
  const offline = all.filter(status => !status.ok).map(status => status.name);
18
31
  if (offline.length) {
19
32
  printMessage(`\nThe following connector server(s) are offline and their connectors and configuration unavailable:\n${offline.join('\n')}`, 'warn');
@@ -31,7 +44,7 @@ export async function listAllConfigEntities() {
31
44
  try {
32
45
  const {
33
46
  configurations
34
- } = await frodo.idm.config.getAllConfigEntities();
47
+ } = await getAllConfigEntities();
35
48
  for (const configEntity of configurations) {
36
49
  printMessage(`${configEntity._id}`, 'data');
37
50
  }
@@ -51,7 +64,7 @@ export async function exportConfigEntity(id, file) {
51
64
  if (!fileName) {
52
65
  fileName = getTypedFilename(`${id}`, 'idm');
53
66
  }
54
- const configEntity = await frodo.idm.config.getConfigEntity(id);
67
+ const configEntity = await getConfigEntity(id);
55
68
  fs.writeFile(fileName, JSON.stringify(configEntity, null, 2), err => {
56
69
  if (err) {
57
70
  return printMessage(`ERROR - can't save ${id} export to file`, 'error');
@@ -68,14 +81,14 @@ export async function exportAllRawConfigEntities(directory) {
68
81
  try {
69
82
  const {
70
83
  configurations
71
- } = await frodo.idm.config.getAllConfigEntities();
84
+ } = await getAllConfigEntities();
72
85
  if (!fs.existsSync(directory)) {
73
86
  fs.mkdirSync(directory);
74
87
  }
75
88
  createProgressIndicator('indeterminate', undefined, 'Exporting config objects...');
76
89
  const entityPromises = [];
77
90
  for (const configEntity of configurations) {
78
- entityPromises.push(frodo.idm.config.getConfigEntity(configEntity._id).catch(getConfigEntityError => {
91
+ entityPromises.push(getConfigEntity(configEntity._id).catch(getConfigEntityError => {
79
92
  var _getConfigEntityError, _getConfigEntityError2, _getConfigEntityError3, _getConfigEntityError4, _getConfigEntityError5, _getConfigEntityError6, _getConfigEntityError7, _getConfigEntityError8, _getConfigEntityError9;
80
93
  if (!(((_getConfigEntityError = getConfigEntityError.response) === null || _getConfigEntityError === void 0 ? void 0 : _getConfigEntityError.status) === 403 && ((_getConfigEntityError2 = getConfigEntityError.response) === null || _getConfigEntityError2 === void 0 ? void 0 : (_getConfigEntityError3 = _getConfigEntityError2.data) === null || _getConfigEntityError3 === void 0 ? void 0 : _getConfigEntityError3.message) === 'This operation is not available in ForgeRock Identity Cloud.') && !(
81
94
  // list of config entities, which do not exist by default or ever.
@@ -126,7 +139,7 @@ export async function exportAllConfigEntities(directory, entitiesFile, envFile)
126
139
  try {
127
140
  const {
128
141
  configurations
129
- } = await frodo.idm.config.getAllConfigEntities();
142
+ } = await getAllConfigEntities();
130
143
  // create export directory if not exist
131
144
  if (!fs.existsSync(directory)) {
132
145
  fs.mkdirSync(directory);
@@ -135,7 +148,7 @@ export async function exportAllConfigEntities(directory, entitiesFile, envFile)
135
148
  const entityPromises = [];
136
149
  for (const configEntity of configurations) {
137
150
  if (entriesToExport.includes(configEntity._id)) {
138
- entityPromises.push(frodo.idm.config.getConfigEntity(configEntity._id));
151
+ entityPromises.push(getConfigEntity(configEntity._id));
139
152
  }
140
153
  }
141
154
  const results = await Promise.all(entityPromises);
@@ -172,13 +185,13 @@ export async function importConfigEntityByIdFromFile(entityId, file, validate) {
172
185
  }
173
186
  const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');
174
187
  const entityData = JSON.parse(fileData);
175
- const isValid = frodo.helper.script.validateScriptHooks(entityData);
188
+ const isValid = validateScriptHooks(entityData);
176
189
  if (validate && !isValid) {
177
190
  printMessage('Invalid IDM configuration object', 'error');
178
191
  return;
179
192
  }
180
193
  try {
181
- await frodo.idm.config.putConfigEntity(entityId, entityData);
194
+ await putConfigEntity(entityId, entityData);
182
195
  } catch (putConfigEntityError) {
183
196
  printMessage(putConfigEntityError, 'error');
184
197
  printMessage(`Error: ${putConfigEntityError}`, 'error');
@@ -194,13 +207,13 @@ export async function importConfigEntityFromFile(file, validate) {
194
207
  const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');
195
208
  const entityData = JSON.parse(fileData);
196
209
  const entityId = entityData._id;
197
- const isValid = frodo.helper.script.validateScriptHooks(entityData);
210
+ const isValid = validateScriptHooks(entityData);
198
211
  if (validate && !isValid) {
199
212
  printMessage('Invalid IDM configuration object', 'error');
200
213
  return;
201
214
  }
202
215
  try {
203
- await frodo.idm.config.putConfigEntity(entityId, entityData);
216
+ await putConfigEntity(entityId, entityData);
204
217
  } catch (putConfigEntityError) {
205
218
  printMessage(putConfigEntityError, 'error');
206
219
  printMessage(`Error: ${putConfigEntityError}`, 'error');
@@ -216,7 +229,7 @@ export async function importAllRawConfigEntities(baseDirectory, validate) {
216
229
  if (!fs.existsSync(baseDirectory)) {
217
230
  return;
218
231
  }
219
- const files = await frodo.helper.utils.readFiles(baseDirectory);
232
+ const files = await readFiles(baseDirectory);
220
233
  const jsonFiles = files.filter(({
221
234
  path
222
235
  }) => path.toLowerCase().endsWith('.json')).map(({
@@ -231,7 +244,7 @@ export async function importAllRawConfigEntities(baseDirectory, validate) {
231
244
  let everyScriptValid = true;
232
245
  for (const file of jsonFiles) {
233
246
  const jsObject = JSON.parse(file.content);
234
- const isScriptValid = frodo.helper.script.validateScriptHooks(jsObject);
247
+ const isScriptValid = validateScriptHooks(jsObject);
235
248
  if (!isScriptValid) {
236
249
  printMessage(`Invalid script hook in ${file.path}`, 'error');
237
250
  everyScriptValid = false;
@@ -242,7 +255,7 @@ export async function importAllRawConfigEntities(baseDirectory, validate) {
242
255
  }
243
256
  createProgressIndicator('indeterminate', undefined, 'Importing config objects...');
244
257
  const entityPromises = jsonFiles.map(file => {
245
- return frodo.idm.config.putConfigEntity(file.entityId, file.content);
258
+ return putConfigEntity(file.entityId, file.content);
246
259
  });
247
260
  const results = await Promise.allSettled(entityPromises);
248
261
  const errors = results.filter(result => result.status === 'rejected');
@@ -270,7 +283,7 @@ export async function importAllConfigEntities(baseDirectory, entitiesFile, envFi
270
283
  }
271
284
  const entriesToImport = JSON.parse(fs.readFileSync(entitiesFile, 'utf8')).idm;
272
285
  const envReader = propertiesReader(envFile);
273
- const files = await frodo.helper.utils.readFiles(baseDirectory);
286
+ const files = await readFiles(baseDirectory);
274
287
  const jsonFiles = files.filter(({
275
288
  path
276
289
  }) => path.toLowerCase().endsWith('.json')).map(({
@@ -285,7 +298,7 @@ export async function importAllConfigEntities(baseDirectory, entitiesFile, envFi
285
298
  let everyScriptValid = true;
286
299
  for (const file of jsonFiles) {
287
300
  const jsObject = JSON.parse(file.content);
288
- const isScriptValid = frodo.helper.script.validateScriptHooks(jsObject);
301
+ const isScriptValid = validateScriptHooks(jsObject);
289
302
  if (!isScriptValid) {
290
303
  printMessage(`Invalid script hook in ${file.path}`, 'error');
291
304
  everyScriptValid = false;
@@ -303,8 +316,8 @@ export async function importAllConfigEntities(baseDirectory, entitiesFile, envFi
303
316
  entityId,
304
317
  content
305
318
  }) => {
306
- const unsubstituted = frodo.helper.utils.unSubstituteEnvParams(content, envReader);
307
- return frodo.idm.config.putConfigEntity(entityId, unsubstituted);
319
+ const unsubstituted = unSubstituteEnvParams(content, envReader);
320
+ return putConfigEntity(entityId, unsubstituted);
308
321
  });
309
322
  const results = await Promise.allSettled(entityPromises);
310
323
  const errors = results.filter(result => result.status === 'rejected');
@@ -335,7 +348,7 @@ export async function countManagedObjects(type) {
335
348
  };
336
349
  try {
337
350
  do {
338
- result = await frodo.idm.config.queryAllManagedObjectsByType(type, [], result.pagedResultsCookie);
351
+ result = await queryAllManagedObjectsByType(type, [], result.pagedResultsCookie);
339
352
  count += result.resultCount;
340
353
  } while (result.pagedResultsCookie);
341
354
  printMessage(`${type}: ${count}`);
@@ -1 +1 @@
1
- {"version":3,"file":"IdmOps.js","names":["fs","fse","path","propertiesReader","replaceall","frodo","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","warnAboutOfflineConnectorServers","all","idm","config","testConnectorServers","offline","filter","status","ok","map","name","length","join","error","message","listAllConfigEntities","configurations","getAllConfigEntities","configEntity","_id","getAllConfigEntitiesError","exportConfigEntity","id","file","fileName","getConfigEntity","writeFile","JSON","stringify","err","exportAllRawConfigEntities","directory","existsSync","mkdirSync","undefined","entityPromises","push","catch","getConfigEntityError","_getConfigEntityError","_getConfigEntityError2","_getConfigEntityError3","_getConfigEntityError4","_getConfigEntityError5","_getConfigEntityError6","_getConfigEntityError7","_getConfigEntityError8","_getConfigEntityError9","response","data","includes","reason","_getConfigEntityError10","results","Promise","item","outputFile","exportAllConfigEntities","entitiesFile","envFile","entriesToExport","readFile","entriesData","parse","envParams","configEntityString","each","key","value","importConfigEntityByIdFromFile","entityId","validate","fileData","readFileSync","resolve","process","cwd","entityData","isValid","helper","script","validateScriptHooks","putConfigEntity","putConfigEntityError","importConfigEntityFromFile","importAllRawConfigEntities","baseDirectory","files","utils","readFiles","jsonFiles","toLowerCase","endsWith","content","substring","everyScriptValid","jsObject","isScriptValid","allSettled","errors","result","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';\n\nimport { frodo } from '@rockcarver/frodo-lib';\nimport {\n createProgressIndicator,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename } from '../utils/ExportImportUtils';\n\n/**\n * Warn about and list offline remote connector servers\n */\nexport async function warnAboutOfflineConnectorServers() {\n try {\n const all = await frodo.idm.config.testConnectorServers();\n const offline = all\n .filter((status) => !status.ok)\n .map((status) => status.name);\n if (offline.length) {\n printMessage(\n `\\nThe following connector server(s) are offline and their connectors and configuration unavailable:\\n${offline.join(\n '\\n'\n )}`,\n 'warn'\n );\n }\n } catch (error) {\n printMessage(error, 'error');\n printMessage(\n `Error getting offline connector servers: ${error.message}`,\n 'error'\n );\n }\n}\n\n/**\n * List all IDM configuration objects\n */\nexport async function listAllConfigEntities() {\n try {\n const { configurations } = await frodo.idm.config.getAllConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\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 frodo.idm.config.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 try {\n const { configurations } = await frodo.idm.config.getAllConfigEntities();\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n entityPromises.push(\n frodo.idm.config\n .getConfigEntity(configEntity._id)\n .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 !(\n // list of config entities, which do not exist by default or ever.\n (\n [\n 'script',\n 'notificationFactory',\n 'apiVersion',\n 'metrics',\n 'repo.init',\n 'endpoint/validateQueryFilter',\n 'endpoint/oauthproxy',\n 'external.rest',\n 'scheduler',\n 'org.apache.felix.fileinstall/openidm',\n 'cluster',\n 'endpoint/mappingDetails',\n 'fieldPolicy/teammember',\n ].includes(configEntity._id) &&\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.reason === 'Not Found'\n )\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 ${configEntity._id}: ${getConfigEntityError}`,\n 'error'\n );\n }\n })\n );\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n fse.outputFile(\n `${directory}/${item._id}.json`,\n JSON.stringify(item, null, 2),\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 } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\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 try {\n const { configurations } = await frodo.idm.config.getAllConfigEntities();\n // create export directory if not exist\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(\n frodo.idm.config.getConfigEntity(configEntity._id)\n );\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\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 (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 } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n });\n}\n\n/**\n * Import an IDM configuration object by id from file.\n * @param entityId the configuration object to import\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityByIdFromFile(\n entityId: string,\n file?: string,\n validate?: boolean\n) {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n\n const entityData = JSON.parse(fileData);\n const isValid = frodo.helper.script.validateScriptHooks(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await frodo.idm.config.putConfigEntity(entityId, entityData);\n } catch (putConfigEntityError) {\n printMessage(putConfigEntityError, 'error');\n printMessage(`Error: ${putConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import IDM configuration object from file.\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityFromFile(\n file: string,\n validate?: boolean\n) {\n const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n const entityData = JSON.parse(fileData);\n const entityId = entityData._id;\n const isValid = frodo.helper.script.validateScriptHooks(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await frodo.idm.config.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 frodo.helper.utils.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 = frodo.helper.script.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 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles.map((file) => {\n return frodo.idm.config.putConfigEntity(file.entityId, file.content);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\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(`Imported ${results.length} config objects`, 'success');\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 frodo.helper.utils.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 = frodo.helper.script.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 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles\n .filter(({ entityId }) => {\n return entriesToImport.includes(entityId);\n })\n .map(({ entityId, content }) => {\n const unsubstituted = frodo.helper.utils.unSubstituteEnvParams(\n content,\n envReader\n );\n return frodo.idm.config.putConfigEntity(entityId, unsubstituted);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\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(`Imported ${results.length} config objects`, 'success');\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 frodo.idm.config.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":"AAAA;AACA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAC1B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,gBAAgB,MAAM,mBAAmB;AAChD,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,KAAK,QAAQ,uBAAuB;AAC7C,SACEC,uBAAuB,EACvBC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,gBAAgB,QAAQ,4BAA4B;;AAE7D;AACA;AACA;AACA,OAAO,eAAeC,gCAAgCA,CAAA,EAAG;EACvD,IAAI;IACF,MAAMC,GAAG,GAAG,MAAMN,KAAK,CAACO,GAAG,CAACC,MAAM,CAACC,oBAAoB,CAAC,CAAC;IACzD,MAAMC,OAAO,GAAGJ,GAAG,CAChBK,MAAM,CAAEC,MAAM,IAAK,CAACA,MAAM,CAACC,EAAE,CAAC,CAC9BC,GAAG,CAAEF,MAAM,IAAKA,MAAM,CAACG,IAAI,CAAC;IAC/B,IAAIL,OAAO,CAACM,MAAM,EAAE;MAClBd,YAAY,CACT,wGAAuGQ,OAAO,CAACO,IAAI,CAClH,IACF,CAAE,EAAC,EACH,MACF,CAAC;IACH;EACF,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdhB,YAAY,CAACgB,KAAK,EAAE,OAAO,CAAC;IAC5BhB,YAAY,CACT,4CAA2CgB,KAAK,CAACC,OAAQ,EAAC,EA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AE,EACFP,MAAM,CAACU,kBACT,CAAC;MACDF,KAAK,IAAIR,MAAM,CAACS,WAAW;IAC7B,CAAC,QAAQT,MAAM,CAACU,kBAAkB;IAClCjH,YAAY,CAAE,GAAE8G,IAAK,KAAIC,KAAM,EAAC,CAAC;EACnC,CAAC,CAAC,OAAO/F,KAAK,EAAE;IACdhB,YAAY,CAACgB,KAAK,CAACmC,QAAQ,CAACC,IAAI,EAAE,OAAO,CAAC;IAC1CpD,YAAY,CAAE,2CAA0CgB,KAAM,EAAC,EAAE,OAAO,CAAC;EAC3E;AACF"}
1
+ {"version":3,"file":"IdmOps.js","names":["frodo","fs","fse","path","propertiesReader","replaceall","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","validateScriptHooks","helper","script","readFiles","unSubstituteEnvParams","utils","testConnectorServers","getAllConfigEntities","getConfigEntity","putConfigEntity","queryAllManagedObjectsByType","idm","config","warnAboutOfflineConnectorServers","all","offline","filter","status","ok","map","name","length","join","error","message","listAllConfigEntities","configurations","configEntity","_id","getAllConfigEntitiesError","exportConfigEntity","id","file","fileName","writeFile","JSON","stringify","err","exportAllRawConfigEntities","directory","existsSync","mkdirSync","undefined","entityPromises","push","catch","getConfigEntityError","_getConfigEntityError","_getConfigEntityError2","_getConfigEntityError3","_getConfigEntityError4","_getConfigEntityError5","_getConfigEntityError6","_getConfigEntityError7","_getConfigEntityError8","_getConfigEntityError9","response","data","includes","reason","_getConfigEntityError10","results","Promise","item","outputFile","exportAllConfigEntities","entitiesFile","envFile","entriesToExport","readFile","entriesData","parse","envParams","configEntityString","each","key","value","importConfigEntityByIdFromFile","entityId","validate","fileData","readFileSync","resolve","process","cwd","entityData","isValid","putConfigEntityError","importConfigEntityFromFile","importAllRawConfigEntities","baseDirectory","files","jsonFiles","toLowerCase","endsWith","content","substring","everyScriptValid","jsObject","isScriptValid","allSettled","errors","result","importAllConfigEntities","entriesToImport","envReader","unsubstituted","countManagedObjects","type","count","resultCount","pagedResultsCookie","totalPagedResultsPolicy","totalPagedResults","remainingPagedResults"],"sources":["ops/IdmOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\nimport {\n createProgressIndicator,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename } from '../utils/ExportImportUtils';\n\nconst { validateScriptHooks } = frodo.helper.script;\nconst { readFiles, unSubstituteEnvParams } = frodo.helper.utils;\nconst {\n testConnectorServers,\n getAllConfigEntities,\n getConfigEntity,\n putConfigEntity,\n queryAllManagedObjectsByType,\n} = frodo.idm.config;\n\n/**\n * Warn about and list offline remote connector servers\n */\nexport async function warnAboutOfflineConnectorServers() {\n try {\n const all = await testConnectorServers();\n const offline = all\n .filter((status) => !status.ok)\n .map((status) => status.name);\n if (offline.length) {\n printMessage(\n `\\nThe following connector server(s) are offline and their connectors and configuration unavailable:\\n${offline.join(\n '\\n'\n )}`,\n 'warn'\n );\n }\n } catch (error) {\n printMessage(error, 'error');\n printMessage(\n `Error getting offline connector servers: ${error.message}`,\n 'error'\n );\n }\n}\n\n/**\n * List all IDM configuration objects\n */\nexport async function listAllConfigEntities() {\n try {\n const { configurations } = await getAllConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\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 try {\n const { configurations } = await getAllConfigEntities();\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n entityPromises.push(\n getConfigEntity(configEntity._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 !(\n // list of config entities, which do not exist by default or ever.\n (\n [\n 'script',\n 'notificationFactory',\n 'apiVersion',\n 'metrics',\n 'repo.init',\n 'endpoint/validateQueryFilter',\n 'endpoint/oauthproxy',\n 'external.rest',\n 'scheduler',\n 'org.apache.felix.fileinstall/openidm',\n 'cluster',\n 'endpoint/mappingDetails',\n 'fieldPolicy/teammember',\n ].includes(configEntity._id) &&\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.reason === 'Not Found'\n )\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 ${configEntity._id}: ${getConfigEntityError}`,\n 'error'\n );\n }\n })\n );\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n fse.outputFile(\n `${directory}/${item._id}.json`,\n JSON.stringify(item, null, 2),\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 } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\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 try {\n const { configurations } = await getAllConfigEntities();\n // create export directory if not exist\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(getConfigEntity(configEntity._id));\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\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 (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 } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n });\n}\n\n/**\n * Import an IDM configuration object by id from file.\n * @param entityId the configuration object to import\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityByIdFromFile(\n entityId: string,\n file?: string,\n validate?: boolean\n) {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n\n const entityData = JSON.parse(fileData);\n const isValid = validateScriptHooks(entityData);\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 IDM configuration object from file.\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityFromFile(\n file: string,\n validate?: boolean\n) {\n const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n const entityData = JSON.parse(fileData);\n const entityId = entityData._id;\n const isValid = validateScriptHooks(entityData);\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 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles.map((file) => {\n return putConfigEntity(file.entityId, file.content);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\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(`Imported ${results.length} config objects`, 'success');\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 'indeterminate',\n undefined,\n 'Importing config objects...'\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 const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\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(`Imported ${results.length} config objects`, 'success');\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":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAC1B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,gBAAgB,MAAM,mBAAmB;AAChD,OAAOC,UAAU,MAAM,YAAY;AACnC,SACEC,uBAAuB,EACvBC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,gBAAgB,QAAQ,4BAA4B;AAE7D,MAAM;EAAEC;AAAoB,CAAC,GAAGV,KAAK,CAACW,MAAM,CAACC,MAAM;AACnD,MAAM;EAAEC,SAAS;EAAEC;AAAsB,CAAC,GAAGd,KAAK,CAACW,MAAM,CAACI,KAAK;AAC/D,MAAM;EACJC,oBAAoB;EACpBC,oBAAoB;EACpBC,eAAe;EACfC,eAAe;EACfC;AACF,CAAC,GAAGpB,KAAK,CAACqB,GAAG,CAACC,MAAM;;AAEpB;AACA;AACA;AACA,OAAO,eAAeC,gCAAgCA,CAAA,EAAG;EACvD,IAAI;IACF,MAAMC,GAAG,GAAG,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E;IACd1B,YAAY,CAAC0B,KAAK,CAACiC,QAAQ,CAACC,IAAI,EAAE,OAAO,CAAC;IAC1C5D,YAAY,CAAE,2CAA0C0B,KAAM,EAAC,EAAE,OAAO,CAAC;EAC3E;AACF"}
package/esm/ops/IdpOps.js CHANGED
@@ -2,6 +2,14 @@ import { frodo } from '@rockcarver/frodo-lib';
2
2
  import fs from 'fs';
3
3
  import { createProgressBar, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
4
4
  import { getRealmString, getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
5
+ const {
6
+ getSocialIdentityProviders,
7
+ exportSocialProvider,
8
+ exportSocialProviders,
9
+ importFirstSocialProvider,
10
+ importSocialProvider,
11
+ importSocialProviders
12
+ } = frodo.oauth2oidc.external;
5
13
 
6
14
  /**
7
15
  * Get a one-line description of the social idp object
@@ -39,7 +47,7 @@ export function getTableRowMd(socialIdpObj) {
39
47
  */
40
48
  export async function listSocialProviders() {
41
49
  try {
42
- const providers = await frodo.oauth2oidc.external.getSocialIdentityProviders();
50
+ const providers = await getSocialIdentityProviders();
43
51
  providers.sort((a, b) => a._id.localeCompare(b._id));
44
52
  providers.forEach(socialIdentityProvider => {
45
53
  printMessage(`${socialIdentityProvider._id}`, 'data');
@@ -64,7 +72,7 @@ export async function exportSocialProviderToFile(providerId, file = '') {
64
72
  createProgressBar(1, `Exporting ${providerId}`);
65
73
  try {
66
74
  updateProgressBar(`Writing file ${fileName}`);
67
- const fileData = await frodo.oauth2oidc.external.exportSocialProvider(providerId);
75
+ const fileData = await exportSocialProvider(providerId);
68
76
  saveJsonToFile(fileData, fileName);
69
77
  stopProgressBar(`Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`);
70
78
  } catch (err) {
@@ -83,7 +91,7 @@ export async function exportSocialProvidersToFile(file = '') {
83
91
  if (!fileName) {
84
92
  fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');
85
93
  }
86
- const fileData = await frodo.oauth2oidc.external.exportSocialProviders();
94
+ const fileData = await exportSocialProviders();
87
95
  saveJsonToFile(fileData, fileName);
88
96
  }
89
97
 
@@ -93,12 +101,12 @@ export async function exportSocialProvidersToFile(file = '') {
93
101
  export async function exportSocialProvidersToFiles() {
94
102
  debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: start`);
95
103
  try {
96
- const allIdpsData = await frodo.oauth2oidc.external.getSocialIdentityProviders();
104
+ const allIdpsData = await getSocialIdentityProviders();
97
105
  createProgressBar(allIdpsData.length, 'Exporting providers');
98
106
  for (const idpData of allIdpsData) {
99
107
  try {
100
108
  const fileName = getTypedFilename(idpData._id, 'idp');
101
- const fileData = await frodo.oauth2oidc.external.exportSocialProvider(idpData._id);
109
+ const fileData = await exportSocialProvider(idpData._id);
102
110
  saveJsonToFile(fileData, fileName);
103
111
  updateProgressBar(`Exported provider ${idpData._id}`);
104
112
  } catch (error) {
@@ -126,7 +134,7 @@ export async function importSocialProviderFromFile(providerId, file) {
126
134
  if (err) throw err;
127
135
  try {
128
136
  const fileData = JSON.parse(data);
129
- outcome = await frodo.oauth2oidc.external.importSocialProvider(providerId, fileData);
137
+ outcome = await importSocialProvider(providerId, fileData);
130
138
  succeedSpinner(`Successfully imported provider ${providerId} from ${file}.`);
131
139
  } catch (error) {
132
140
  var _error$response;
@@ -149,7 +157,7 @@ export async function importFirstSocialProviderFromFile(file) {
149
157
  if (err) throw err;
150
158
  try {
151
159
  const fileData = JSON.parse(data);
152
- outcome = await frodo.oauth2oidc.external.importFirstSocialProvider(fileData);
160
+ outcome = await importFirstSocialProvider(fileData);
153
161
  succeedSpinner(`Successfully imported first provider from ${file}.`);
154
162
  } catch (error) {
155
163
  var _error$response2;
@@ -172,7 +180,7 @@ export async function importSocialProvidersFromFile(file) {
172
180
  if (err) throw err;
173
181
  try {
174
182
  const fileData = JSON.parse(data);
175
- outcome = await frodo.oauth2oidc.external.importSocialProviders(fileData);
183
+ outcome = await importSocialProviders(fileData);
176
184
  succeedSpinner(`Successfully imported providers from ${file}.`);
177
185
  } catch (error) {
178
186
  var _error$response3;
@@ -196,7 +204,7 @@ export async function importSocialProvidersFromFiles() {
196
204
  const fileData = JSON.parse(data);
197
205
  const count = Object.keys(fileData.idp).length;
198
206
  total += count;
199
- await frodo.oauth2oidc.external.importSocialProviders(fileData);
207
+ await importSocialProviders(fileData);
200
208
  updateProgressBar(`Imported ${count} provider(s) from ${file}`);
201
209
  }
202
210
  stopProgressBar(`Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`);
@@ -1 +1 @@
1
- {"version":3,"file":"IdpOps.js","names":["frodo","fs","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getRealmString","getTypedFilename","saveJsonToFile","getOneLineDescription","socialIdpObj","description","_id","_type","getTableHeaderMd","markdown","getTableRowMd","row","enabled","name","listSocialProviders","providers","oauth2oidc","external","getSocialIdentityProviders","sort","a","b","localeCompare","forEach","socialIdentityProvider","err","message","exportSocialProviderToFile","providerId","file","fileName","fileData","exportSocialProvider","exportSocialProvidersToFile","exportSocialProviders","exportSocialProvidersToFiles","allIdpsData","length","idpData","error","importSocialProviderFromFile","outcome","readFile","data","JSON","parse","importSocialProvider","_error$response","response","importFirstSocialProviderFromFile","importFirstSocialProvider","_error$response2","importSocialProvidersFromFile","importSocialProviders","_error$response3","importSocialProvidersFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","total","readFileSync","count","Object","keys","idp"],"sources":["ops/IdpOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport type { SocialIdpSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport {\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n} from '../utils/ExportImportUtils';\n\n/**\n * Get a one-line description of the social idp object\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(socialIdpObj: SocialIdpSkeleton): string {\n const description = `[${socialIdpObj._id['brightCyan']}] ${socialIdpObj._type._id}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Type |\\n';\n markdown += '| ------- | ------ | ---- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the social idp in markdown\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a table-row of the social idp in markdown\n */\nexport function getTableRowMd(socialIdpObj: SocialIdpSkeleton): string {\n const row = `| ${socialIdpObj._id} | ${\n socialIdpObj.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n } | ${socialIdpObj._type.name} |`;\n return row;\n}\n\n/**\n * List providers\n */\nexport async function listSocialProviders() {\n try {\n const providers =\n await frodo.oauth2oidc.external.getSocialIdentityProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n } catch (err) {\n printMessage(`listSocialProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n */\nexport async function exportSocialProviderToFile(\n providerId: string,\n file = ''\n) {\n debugMessage(`cli.IdpOps.exportSocialProviderToFile: start`);\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'idp');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await frodo.oauth2oidc.external.exportSocialProvider(\n providerId\n );\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialProviderToFile: end`);\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n */\nexport async function exportSocialProvidersToFile(file = '') {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');\n }\n const fileData = await frodo.oauth2oidc.external.exportSocialProviders();\n saveJsonToFile(fileData, fileName);\n}\n\n/**\n * Export all providers to individual files\n */\nexport async function exportSocialProvidersToFiles() {\n debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: start`);\n try {\n const allIdpsData =\n await frodo.oauth2oidc.external.getSocialIdentityProviders();\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n try {\n const fileName = getTypedFilename(idpData._id, 'idp');\n const fileData = await frodo.oauth2oidc.external.exportSocialProvider(\n idpData._id\n );\n saveJsonToFile(fileData, fileName);\n updateProgressBar(`Exported provider ${idpData._id}`);\n } catch (error) {\n printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');\n }\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n } catch (error) {\n stopProgressBar(`${error}`);\n printMessage(`${error}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: end`);\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if provider was imported successfully, false otherwise\n */\nexport async function importSocialProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing provider ${providerId} from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await frodo.oauth2oidc.external.importSocialProvider(\n providerId,\n fileData\n );\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise\n */\nexport async function importFirstSocialProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing first provider from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await frodo.oauth2oidc.external.importFirstSocialProvider(\n fileData\n );\n succeedSpinner(`Successfully imported first provider from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing first provider from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise\n */\nexport async function importSocialProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing providers from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await frodo.oauth2oidc.external.importSocialProviders(fileData);\n succeedSpinner(`Successfully imported providers from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing providers from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n */\nexport async function importSocialProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.idp.json')\n );\n\n createProgressBar(jsonFiles.length, 'Importing providers...');\n let total = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await frodo.oauth2oidc.external.importSocialProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ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AAC;EACF,OAAOE,OAAO;AAChB;;AAEA;AACA;AACA;AACA,OAAO,eAAec,8BAA8BA,CAAA,EAAG;EACrD,MAAMC,KAAK,GAAGjE,EAAE,CAACkE,WAAW,CAAC,GAAG,CAAC;EACjC,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAE9C,IAAI,IAClCA,IAAI,CAAC+C,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,WAAW,CACzC,CAAC;EAEDrE,iBAAiB,CAACkE,SAAS,CAACrB,MAAM,EAAE,wBAAwB,CAAC;EAC7D,IAAIyB,KAAK,GAAG,CAAC;EACb,KAAK,MAAMjC,IAAI,IAAI6B,SAAS,EAAE;IAC5B,MAAMf,IAAI,GAAGpD,EAAE,CAACwE,YAAY,CAAClC,IAAI,EAAE,MAAM,CAAC;IAC1C,MAAME,QAAQ,GAAGa,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC;IACjC,MAAMqB,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACnC,QAAQ,CAACoC,GAAG,CAAC,CAAC9B,MAAM;IAC9CyB,KAAK,IAAIE,KAAK;IACd,MAAM1E,KAAK,CAAC0B,UAAU,CAACC,QAAQ,CAACoC,qBAAqB,CAACtB,QAAQ,CAAC;IAC/DhC,iBAAiB,CAAE,YAAWiE,KAAM,qBAAoBnC,IAAK,EAAC,CAAC;EACjE;EACAhC,eAAe,CACZ,sBAAqBiE,KAAM,qBAAoBJ,SAAS,CAACrB,MAAO,WACnE,CAAC;AACH"}
1
+ {"version":3,"file":"IdpOps.js","names":["frodo","fs","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getRealmString","getTypedFilename","saveJsonToFile","getSocialIdentityProviders","exportSocialProvider","exportSocialProviders","importFirstSocialProvider","importSocialProvider","importSocialProviders","oauth2oidc","external","getOneLineDescription","socialIdpObj","description","_id","_type","getTableHeaderMd","markdown","getTableRowMd","row","enabled","name","listSocialProviders","providers","sort","a","b","localeCompare","forEach","socialIdentityProvider","err","message","exportSocialProviderToFile","providerId","file","fileName","fileData","exportSocialProvidersToFile","exportSocialProvidersToFiles","allIdpsData","length","idpData","error","importSocialProviderFromFile","outcome","readFile","data","JSON","parse","_error$response","response","importFirstSocialProviderFromFile","_error$response2","importSocialProvidersFromFile","_error$response3","importSocialProvidersFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","total","readFileSync","count","Object","keys","idp"],"sources":["ops/IdpOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport type { SocialIdpSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport {\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n} from '../utils/ExportImportUtils';\n\nconst {\n getSocialIdentityProviders,\n exportSocialProvider,\n exportSocialProviders,\n importFirstSocialProvider,\n importSocialProvider,\n importSocialProviders,\n} = frodo.oauth2oidc.external;\n\n/**\n * Get a one-line description of the social idp object\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(socialIdpObj: SocialIdpSkeleton): string {\n const description = `[${socialIdpObj._id['brightCyan']}] ${socialIdpObj._type._id}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Type |\\n';\n markdown += '| ------- | ------ | ---- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the social idp in markdown\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a table-row of the social idp in markdown\n */\nexport function getTableRowMd(socialIdpObj: SocialIdpSkeleton): string {\n const row = `| ${socialIdpObj._id} | ${\n socialIdpObj.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n } | ${socialIdpObj._type.name} |`;\n return row;\n}\n\n/**\n * List providers\n */\nexport async function listSocialProviders() {\n try {\n const providers = await getSocialIdentityProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n } catch (err) {\n printMessage(`listSocialProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n */\nexport async function exportSocialProviderToFile(\n providerId: string,\n file = ''\n) {\n debugMessage(`cli.IdpOps.exportSocialProviderToFile: start`);\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'idp');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await exportSocialProvider(providerId);\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialProviderToFile: end`);\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n */\nexport async function exportSocialProvidersToFile(file = '') {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');\n }\n const fileData = await exportSocialProviders();\n saveJsonToFile(fileData, fileName);\n}\n\n/**\n * Export all providers to individual files\n */\nexport async function exportSocialProvidersToFiles() {\n debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: start`);\n try {\n const allIdpsData = await getSocialIdentityProviders();\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n try {\n const fileName = getTypedFilename(idpData._id, 'idp');\n const fileData = await exportSocialProvider(idpData._id);\n saveJsonToFile(fileData, fileName);\n updateProgressBar(`Exported provider ${idpData._id}`);\n } catch (error) {\n printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');\n }\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n } catch (error) {\n stopProgressBar(`${error}`);\n printMessage(`${error}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: end`);\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if provider was imported successfully, false otherwise\n */\nexport async function importSocialProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing provider ${providerId} from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await importSocialProvider(providerId, fileData);\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise\n */\nexport async function importFirstSocialProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing first provider from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await importFirstSocialProvider(fileData);\n succeedSpinner(`Successfully imported first provider from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing first provider from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise\n */\nexport async function importSocialProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing providers from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await importSocialProviders(fileData);\n succeedSpinner(`Successfully imported providers from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing providers from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n */\nexport async function importSocialProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.idp.json')\n );\n\n createProgressBar(jsonFiles.length, 'Importing providers...');\n let total = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await importSocialProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,cAAc,EACdC,gBAAgB,EAChBC,cAAc,QACT,4BAA4B;AAEnC,MAAM;EACJC,0BAA0B;EAC1BC,oBAAoB;EACpBC,qBAAqB;EACrBC,yBAAyB;EACzBC,oBAAoB;EACpBC;AACF,CAAC,GAAGlB,KAAK,CAACmB,UAAU,CAACC,QAAQ;;AAE7B;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAACC,YAA+B,EAAU;EAC7E,MAAMC,WAAW,GAAI,IAAGD,YAAY,CAACE,GAAG,CAAC,YAAY,CAAE,KAAIF,YAAY,CAACG,KAAK,CAACD,GAAI,EAAC;EACnF,OAAOD,WAAW;AACpB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,gBAAgBA,CAAA,EAAW;EACzC,IAAIC,QAAQ,GAAG,EAAE;EACjBA,QAAQ,IAAI,+BAA+B;EAC3CA,QA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