@rockcarver/frodo-cli 0.24.5 → 2.0.0-2

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 (337) hide show
  1. package/.vscode/launch.json +15 -0
  2. package/CHANGELOG.md +9 -1
  3. package/esm/app.js +2 -5
  4. package/esm/app.js.map +1 -1
  5. package/esm/cli/FrodoCommand.js +10 -10
  6. package/esm/cli/FrodoCommand.js.map +1 -1
  7. package/esm/cli/_template/something-delete.js +2 -5
  8. package/esm/cli/_template/something-delete.js.map +1 -1
  9. package/esm/cli/_template/something-describe.js +2 -5
  10. package/esm/cli/_template/something-describe.js.map +1 -1
  11. package/esm/cli/_template/something-else-delete.js +2 -5
  12. package/esm/cli/_template/something-else-delete.js.map +1 -1
  13. package/esm/cli/_template/something-else-describe.js +2 -5
  14. package/esm/cli/_template/something-else-describe.js.map +1 -1
  15. package/esm/cli/_template/something-else-export.js +2 -5
  16. package/esm/cli/_template/something-else-export.js.map +1 -1
  17. package/esm/cli/_template/something-else-import.js +2 -5
  18. package/esm/cli/_template/something-else-import.js.map +1 -1
  19. package/esm/cli/_template/something-else-list.js +2 -5
  20. package/esm/cli/_template/something-else-list.js.map +1 -1
  21. package/esm/cli/_template/something-export.js +2 -5
  22. package/esm/cli/_template/something-export.js.map +1 -1
  23. package/esm/cli/_template/something-import.js +2 -5
  24. package/esm/cli/_template/something-import.js.map +1 -1
  25. package/esm/cli/_template/something-list.js +2 -5
  26. package/esm/cli/_template/something-list.js.map +1 -1
  27. package/esm/cli/_template/something-other-delete.js +2 -5
  28. package/esm/cli/_template/something-other-delete.js.map +1 -1
  29. package/esm/cli/_template/something-other-describe.js +2 -5
  30. package/esm/cli/_template/something-other-describe.js.map +1 -1
  31. package/esm/cli/_template/something-other-export.js +2 -5
  32. package/esm/cli/_template/something-other-export.js.map +1 -1
  33. package/esm/cli/_template/something-other-import.js +2 -5
  34. package/esm/cli/_template/something-other-import.js.map +1 -1
  35. package/esm/cli/_template/something-other-list.js +2 -5
  36. package/esm/cli/_template/something-other-list.js.map +1 -1
  37. package/esm/cli/admin/admin-add-autoid-static-user-mapping.js +3 -9
  38. package/esm/cli/admin/admin-add-autoid-static-user-mapping.js.map +1 -1
  39. package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js +4 -11
  40. package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js.map +1 -1
  41. package/esm/cli/admin/admin-get-access-token.js +3 -9
  42. package/esm/cli/admin/admin-get-access-token.js.map +1 -1
  43. package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +3 -9
  44. package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +1 -1
  45. package/esm/cli/admin/admin-hide-generic-extension-attributes.js +3 -9
  46. package/esm/cli/admin/admin-hide-generic-extension-attributes.js.map +1 -1
  47. package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +3 -9
  48. package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js.map +1 -1
  49. package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +3 -9
  50. package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js.map +1 -1
  51. package/esm/cli/admin/admin-list-static-user-mappings.js +3 -9
  52. package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
  53. package/esm/cli/admin/admin-remove-static-user-mapping.js +3 -9
  54. package/esm/cli/admin/admin-remove-static-user-mapping.js.map +1 -1
  55. package/esm/cli/admin/admin-repair-org-model.js +3 -9
  56. package/esm/cli/admin/admin-repair-org-model.js.map +1 -1
  57. package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +3 -9
  58. package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js.map +1 -1
  59. package/esm/cli/admin/admin-show-generic-extension-attributes.js +3 -9
  60. package/esm/cli/admin/admin-show-generic-extension-attributes.js.map +1 -1
  61. package/esm/cli/agent/agent-delete.js +4 -11
  62. package/esm/cli/agent/agent-delete.js.map +1 -1
  63. package/esm/cli/agent/agent-describe.js +2 -5
  64. package/esm/cli/agent/agent-describe.js.map +1 -1
  65. package/esm/cli/agent/agent-export.js +2 -5
  66. package/esm/cli/agent/agent-export.js.map +1 -1
  67. package/esm/cli/agent/agent-gateway-delete.js +4 -11
  68. package/esm/cli/agent/agent-gateway-delete.js.map +1 -1
  69. package/esm/cli/agent/agent-gateway-describe.js +2 -5
  70. package/esm/cli/agent/agent-gateway-describe.js.map +1 -1
  71. package/esm/cli/agent/agent-gateway-export.js +2 -5
  72. package/esm/cli/agent/agent-gateway-export.js.map +1 -1
  73. package/esm/cli/agent/agent-gateway-import.js +2 -5
  74. package/esm/cli/agent/agent-gateway-import.js.map +1 -1
  75. package/esm/cli/agent/agent-gateway-list.js +2 -5
  76. package/esm/cli/agent/agent-gateway-list.js.map +1 -1
  77. package/esm/cli/agent/agent-import.js +2 -5
  78. package/esm/cli/agent/agent-import.js.map +1 -1
  79. package/esm/cli/agent/agent-java-delete.js +4 -11
  80. package/esm/cli/agent/agent-java-delete.js.map +1 -1
  81. package/esm/cli/agent/agent-java-describe.js +2 -5
  82. package/esm/cli/agent/agent-java-describe.js.map +1 -1
  83. package/esm/cli/agent/agent-java-export.js +2 -5
  84. package/esm/cli/agent/agent-java-export.js.map +1 -1
  85. package/esm/cli/agent/agent-java-import.js +2 -5
  86. package/esm/cli/agent/agent-java-import.js.map +1 -1
  87. package/esm/cli/agent/agent-java-list.js +2 -5
  88. package/esm/cli/agent/agent-java-list.js.map +1 -1
  89. package/esm/cli/agent/agent-list.js +2 -5
  90. package/esm/cli/agent/agent-list.js.map +1 -1
  91. package/esm/cli/agent/agent-web-delete.js +4 -11
  92. package/esm/cli/agent/agent-web-delete.js.map +1 -1
  93. package/esm/cli/agent/agent-web-describe.js +2 -5
  94. package/esm/cli/agent/agent-web-describe.js.map +1 -1
  95. package/esm/cli/agent/agent-web-export.js +2 -5
  96. package/esm/cli/agent/agent-web-export.js.map +1 -1
  97. package/esm/cli/agent/agent-web-import.js +2 -5
  98. package/esm/cli/agent/agent-web-import.js.map +1 -1
  99. package/esm/cli/agent/agent-web-list.js +2 -5
  100. package/esm/cli/agent/agent-web-list.js.map +1 -1
  101. package/esm/cli/app/app-delete.js +2 -5
  102. package/esm/cli/app/app-delete.js.map +1 -1
  103. package/esm/cli/app/app-describe.js +2 -5
  104. package/esm/cli/app/app-describe.js.map +1 -1
  105. package/esm/cli/app/app-export.js +4 -7
  106. package/esm/cli/app/app-export.js.map +1 -1
  107. package/esm/cli/app/app-import.js +5 -8
  108. package/esm/cli/app/app-import.js.map +1 -1
  109. package/esm/cli/app/app-list.js +3 -6
  110. package/esm/cli/app/app-list.js.map +1 -1
  111. package/esm/cli/authz/authz-policy-delete.js +4 -7
  112. package/esm/cli/authz/authz-policy-delete.js.map +1 -1
  113. package/esm/cli/authz/authz-policy-describe.js +2 -5
  114. package/esm/cli/authz/authz-policy-describe.js.map +1 -1
  115. package/esm/cli/authz/authz-policy-export.js +6 -9
  116. package/esm/cli/authz/authz-policy-export.js.map +1 -1
  117. package/esm/cli/authz/authz-policy-import.js +5 -8
  118. package/esm/cli/authz/authz-policy-import.js.map +1 -1
  119. package/esm/cli/authz/authz-policy-list.js +3 -6
  120. package/esm/cli/authz/authz-policy-list.js.map +1 -1
  121. package/esm/cli/authz/authz-set-delete.js +3 -6
  122. package/esm/cli/authz/authz-set-delete.js.map +1 -1
  123. package/esm/cli/authz/authz-set-describe.js +2 -5
  124. package/esm/cli/authz/authz-set-describe.js.map +1 -1
  125. package/esm/cli/authz/authz-set-export.js +4 -7
  126. package/esm/cli/authz/authz-set-export.js.map +1 -1
  127. package/esm/cli/authz/authz-set-import.js +5 -8
  128. package/esm/cli/authz/authz-set-import.js.map +1 -1
  129. package/esm/cli/authz/authz-set-list.js +2 -5
  130. package/esm/cli/authz/authz-set-list.js.map +1 -1
  131. package/esm/cli/authz/authz-type-delete.js +4 -7
  132. package/esm/cli/authz/authz-type-delete.js.map +1 -1
  133. package/esm/cli/authz/authz-type-describe.js +3 -6
  134. package/esm/cli/authz/authz-type-describe.js.map +1 -1
  135. package/esm/cli/authz/authz-type-export.js +5 -8
  136. package/esm/cli/authz/authz-type-export.js.map +1 -1
  137. package/esm/cli/authz/authz-type-import.js +6 -9
  138. package/esm/cli/authz/authz-type-import.js.map +1 -1
  139. package/esm/cli/authz/authz-type-list.js +2 -5
  140. package/esm/cli/authz/authz-type-list.js.map +1 -1
  141. package/esm/cli/conn/conn-delete.js +2 -5
  142. package/esm/cli/conn/conn-delete.js.map +1 -1
  143. package/esm/cli/conn/conn-describe.js +1 -4
  144. package/esm/cli/conn/conn-describe.js.map +1 -1
  145. package/esm/cli/conn/conn-list.js +1 -4
  146. package/esm/cli/conn/conn-list.js.map +1 -1
  147. package/esm/cli/conn/conn-save.js +6 -16
  148. package/esm/cli/conn/conn-save.js.map +1 -1
  149. package/esm/cli/email/email-template-export.js +4 -7
  150. package/esm/cli/email/email-template-export.js.map +1 -1
  151. package/esm/cli/email/email-template-import.js +5 -8
  152. package/esm/cli/email/email-template-import.js.map +1 -1
  153. package/esm/cli/email/email-template-list.js +2 -5
  154. package/esm/cli/email/email-template-list.js.map +1 -1
  155. package/esm/cli/esv/esv-apply.js +6 -16
  156. package/esm/cli/esv/esv-apply.js.map +1 -1
  157. package/esm/cli/esv/esv-secret-create.js +3 -8
  158. package/esm/cli/esv/esv-secret-create.js.map +1 -1
  159. package/esm/cli/esv/esv-secret-delete.js +6 -12
  160. package/esm/cli/esv/esv-secret-delete.js.map +1 -1
  161. package/esm/cli/esv/esv-secret-describe.js +3 -8
  162. package/esm/cli/esv/esv-secret-describe.js.map +1 -1
  163. package/esm/cli/esv/esv-secret-export.js +2 -5
  164. package/esm/cli/esv/esv-secret-export.js.map +1 -1
  165. package/esm/cli/esv/esv-secret-import.js +2 -5
  166. package/esm/cli/esv/esv-secret-import.js.map +1 -1
  167. package/esm/cli/esv/esv-secret-list.js +3 -8
  168. package/esm/cli/esv/esv-secret-list.js.map +1 -1
  169. package/esm/cli/esv/esv-secret-set.js +4 -9
  170. package/esm/cli/esv/esv-secret-set.js.map +1 -1
  171. package/esm/cli/esv/esv-secret-version-activate.js +3 -8
  172. package/esm/cli/esv/esv-secret-version-activate.js.map +1 -1
  173. package/esm/cli/esv/esv-secret-version-create.js +4 -9
  174. package/esm/cli/esv/esv-secret-version-create.js.map +1 -1
  175. package/esm/cli/esv/esv-secret-version-deactivate.js +3 -8
  176. package/esm/cli/esv/esv-secret-version-deactivate.js.map +1 -1
  177. package/esm/cli/esv/esv-secret-version-delete.js +5 -10
  178. package/esm/cli/esv/esv-secret-version-delete.js.map +1 -1
  179. package/esm/cli/esv/esv-secret-version-list.js +4 -9
  180. package/esm/cli/esv/esv-secret-version-list.js.map +1 -1
  181. package/esm/cli/esv/esv-variable-create.js +3 -8
  182. package/esm/cli/esv/esv-variable-create.js.map +1 -1
  183. package/esm/cli/esv/esv-variable-delete.js +6 -12
  184. package/esm/cli/esv/esv-variable-delete.js.map +1 -1
  185. package/esm/cli/esv/esv-variable-describe.js +3 -8
  186. package/esm/cli/esv/esv-variable-describe.js.map +1 -1
  187. package/esm/cli/esv/esv-variable-export.js +2 -5
  188. package/esm/cli/esv/esv-variable-export.js.map +1 -1
  189. package/esm/cli/esv/esv-variable-import.js +2 -5
  190. package/esm/cli/esv/esv-variable-import.js.map +1 -1
  191. package/esm/cli/esv/esv-variable-list.js +3 -8
  192. package/esm/cli/esv/esv-variable-list.js.map +1 -1
  193. package/esm/cli/esv/esv-variable-set.js +5 -11
  194. package/esm/cli/esv/esv-variable-set.js.map +1 -1
  195. package/esm/cli/idm/idm-count.js +2 -5
  196. package/esm/cli/idm/idm-count.js.map +1 -1
  197. package/esm/cli/idm/idm-export.js +4 -7
  198. package/esm/cli/idm/idm-export.js.map +1 -1
  199. package/esm/cli/idm/idm-import.js +5 -8
  200. package/esm/cli/idm/idm-import.js.map +1 -1
  201. package/esm/cli/idm/idm-list.js +2 -5
  202. package/esm/cli/idm/idm-list.js.map +1 -1
  203. package/esm/cli/idp/idp-export.js +2 -5
  204. package/esm/cli/idp/idp-export.js.map +1 -1
  205. package/esm/cli/idp/idp-import.js +5 -8
  206. package/esm/cli/idp/idp-import.js.map +1 -1
  207. package/esm/cli/idp/idp-list.js +2 -5
  208. package/esm/cli/idp/idp-list.js.map +1 -1
  209. package/esm/cli/info/info.js +3 -9
  210. package/esm/cli/info/info.js.map +1 -1
  211. package/esm/cli/journey/journey-delete.js +5 -12
  212. package/esm/cli/journey/journey-delete.js.map +1 -1
  213. package/esm/cli/journey/journey-describe.js +7 -15
  214. package/esm/cli/journey/journey-describe.js.map +1 -1
  215. package/esm/cli/journey/journey-disable.js +3 -9
  216. package/esm/cli/journey/journey-disable.js.map +1 -1
  217. package/esm/cli/journey/journey-enable.js +3 -9
  218. package/esm/cli/journey/journey-enable.js.map +1 -1
  219. package/esm/cli/journey/journey-export.js +4 -7
  220. package/esm/cli/journey/journey-export.js.map +1 -1
  221. package/esm/cli/journey/journey-import.js +5 -8
  222. package/esm/cli/journey/journey-import.js.map +1 -1
  223. package/esm/cli/journey/journey-list.js +2 -5
  224. package/esm/cli/journey/journey-list.js.map +1 -1
  225. package/esm/cli/journey/journey-prune.js +4 -11
  226. package/esm/cli/journey/journey-prune.js.map +1 -1
  227. package/esm/cli/logging/logs-fetch.js +7 -17
  228. package/esm/cli/logging/logs-fetch.js.map +1 -1
  229. package/esm/cli/logging/logs-list.js +5 -15
  230. package/esm/cli/logging/logs-list.js.map +1 -1
  231. package/esm/cli/logging/logs-tail.js +7 -17
  232. package/esm/cli/logging/logs-tail.js.map +1 -1
  233. package/esm/cli/realm/realm-add-custom-domain.js +3 -8
  234. package/esm/cli/realm/realm-add-custom-domain.js.map +1 -1
  235. package/esm/cli/realm/realm-describe.js +4 -12
  236. package/esm/cli/realm/realm-describe.js.map +1 -1
  237. package/esm/cli/realm/realm-list.js +3 -8
  238. package/esm/cli/realm/realm-list.js.map +1 -1
  239. package/esm/cli/realm/realm-remove-custom-domain.js +3 -9
  240. package/esm/cli/realm/realm-remove-custom-domain.js.map +1 -1
  241. package/esm/cli/saml/saml-cot-export.js +11 -15
  242. package/esm/cli/saml/saml-cot-export.js.map +1 -1
  243. package/esm/cli/saml/saml-cot-import.js +15 -19
  244. package/esm/cli/saml/saml-cot-import.js.map +1 -1
  245. package/esm/cli/saml/saml-cot-list.js +5 -9
  246. package/esm/cli/saml/saml-cot-list.js.map +1 -1
  247. package/esm/cli/saml/saml-delete.js +5 -12
  248. package/esm/cli/saml/saml-delete.js.map +1 -1
  249. package/esm/cli/saml/saml-describe.js +2 -5
  250. package/esm/cli/saml/saml-describe.js.map +1 -1
  251. package/esm/cli/saml/saml-export.js +12 -30
  252. package/esm/cli/saml/saml-export.js.map +1 -1
  253. package/esm/cli/saml/saml-import.js +15 -36
  254. package/esm/cli/saml/saml-import.js.map +1 -1
  255. package/esm/cli/saml/saml-list.js +6 -14
  256. package/esm/cli/saml/saml-list.js.map +1 -1
  257. package/esm/cli/saml/saml-metadata-export.js +3 -6
  258. package/esm/cli/saml/saml-metadata-export.js.map +1 -1
  259. package/esm/cli/script/script-delete.js +2 -5
  260. package/esm/cli/script/script-delete.js.map +1 -1
  261. package/esm/cli/script/script-describe.js +2 -5
  262. package/esm/cli/script/script-describe.js.map +1 -1
  263. package/esm/cli/script/script-export.js +2 -5
  264. package/esm/cli/script/script-export.js.map +1 -1
  265. package/esm/cli/script/script-import.js +4 -6
  266. package/esm/cli/script/script-import.js.map +1 -1
  267. package/esm/cli/script/script-list.js +4 -6
  268. package/esm/cli/script/script-list.js.map +1 -1
  269. package/esm/cli/service/service-delete.js +3 -6
  270. package/esm/cli/service/service-delete.js.map +1 -1
  271. package/esm/cli/service/service-export.js +4 -7
  272. package/esm/cli/service/service-export.js.map +1 -1
  273. package/esm/cli/service/service-import.js +5 -8
  274. package/esm/cli/service/service-import.js.map +1 -1
  275. package/esm/cli/service/service-list.js +2 -5
  276. package/esm/cli/service/service-list.js.map +1 -1
  277. package/esm/cli/theme/theme-delete.js +4 -7
  278. package/esm/cli/theme/theme-delete.js.map +1 -1
  279. package/esm/cli/theme/theme-export.js +5 -8
  280. package/esm/cli/theme/theme-export.js.map +1 -1
  281. package/esm/cli/theme/theme-import.js +6 -9
  282. package/esm/cli/theme/theme-import.js.map +1 -1
  283. package/esm/cli/theme/theme-list.js +2 -5
  284. package/esm/cli/theme/theme-list.js.map +1 -1
  285. package/esm/launch.js +4 -3
  286. package/esm/launch.js.map +1 -1
  287. package/esm/ops/AgentOps.js +49 -82
  288. package/esm/ops/AgentOps.js.map +1 -1
  289. package/esm/ops/CirclesOfTrustOps.js +217 -2
  290. package/esm/ops/CirclesOfTrustOps.js.map +1 -1
  291. package/esm/ops/ConnectionProfileOps.js +97 -8
  292. package/esm/ops/ConnectionProfileOps.js.map +1 -1
  293. package/esm/ops/EmailTemplateOps.js +16 -25
  294. package/esm/ops/EmailTemplateOps.js.map +1 -1
  295. package/esm/ops/IdmOps.js +25 -39
  296. package/esm/ops/IdmOps.js.map +1 -1
  297. package/esm/ops/IdpOps.js +10 -18
  298. package/esm/ops/IdpOps.js.map +1 -1
  299. package/esm/ops/JourneyOps.js +49 -65
  300. package/esm/ops/JourneyOps.js.map +1 -1
  301. package/esm/ops/LogOps.js +9 -17
  302. package/esm/ops/LogOps.js.map +1 -1
  303. package/esm/ops/NodeOps.js +11 -11
  304. package/esm/ops/NodeOps.js.map +1 -1
  305. package/esm/ops/OAuth2ClientOps.js +13 -29
  306. package/esm/ops/OAuth2ClientOps.js.map +1 -1
  307. package/esm/ops/OrganizationOps.js +28 -0
  308. package/esm/ops/OrganizationOps.js.map +1 -0
  309. package/esm/ops/PolicyOps.js +22 -38
  310. package/esm/ops/PolicyOps.js.map +1 -1
  311. package/esm/ops/PolicySetOps.js +19 -37
  312. package/esm/ops/PolicySetOps.js.map +1 -1
  313. package/esm/ops/RealmOps.js +109 -0
  314. package/esm/ops/RealmOps.js.map +1 -0
  315. package/esm/ops/ResourceTypeOps.js +19 -37
  316. package/esm/ops/ResourceTypeOps.js.map +1 -1
  317. package/esm/ops/Saml2Ops.js +30 -251
  318. package/esm/ops/Saml2Ops.js.map +1 -1
  319. package/esm/ops/ScriptOps.js +14 -21
  320. package/esm/ops/ScriptOps.js.map +1 -1
  321. package/esm/ops/SecretsOps.js +223 -0
  322. package/esm/ops/SecretsOps.js.map +1 -0
  323. package/esm/ops/ServiceOps.js +20 -41
  324. package/esm/ops/ServiceOps.js.map +1 -1
  325. package/esm/ops/ThemeOps.js +20 -35
  326. package/esm/ops/ThemeOps.js.map +1 -1
  327. package/esm/ops/VariablesOps.js +133 -0
  328. package/esm/ops/VariablesOps.js.map +1 -0
  329. package/esm/utils/Config.js +3 -6
  330. package/esm/utils/Config.js.map +1 -1
  331. package/esm/utils/Console.js +2 -5
  332. package/esm/utils/Console.js.map +1 -1
  333. package/esm/utils/ExportImportUtils.js +4 -6
  334. package/esm/utils/ExportImportUtils.js.map +1 -1
  335. package/esm/utils/Version.js +3 -3
  336. package/esm/utils/Version.js.map +1 -1
  337. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"EmailTemplateOps.js","names":["fs","EmailTemplate","ExportImportUtils","getTypedFilename","saveJsonToFile","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","printMessage","createTable","showSpinner","succeedSpinner","failSpinner","debugMessage","wordwrap","path","cloneDeep","EMAIL_TEMPLATE_FILE_TYPE","EMAIL_TEMPLATE_TYPE","getEmailTemplate","getEmailTemplates","putEmailTemplate","validateImport","regexEmailTemplateType","RegExp","getFileDataTemplate","meta","emailTemplate","getOneLineDescription","templateObj","description","_id","split","displayName","defaultLocale","subject","Object","values","getTableHeaderMd","markdown","getTableRowMd","templateId","replace","locales","keys","length","filter","locale","join","row","name","listEmailTemplates","long","emailTemplates","result","error","message","sort","a","b","localeCompare","entries","table","push","enabled","from","toString","exportEmailTemplateToFile","file","fileName","templateData","fileData","err","exportEmailTemplatesToFile","response","templates","resultCount","template","exportEmailTemplatesToFiles","importEmailTemplateFromFile","raw","replaceAll","readFile","data","JSON","parse","emailTemplateData","s2sConvert","putEmailTemplateError","importEmailTemplatesFromFile","id","hasOwnProperty","call","getEmailTemplateIdFromFile","basename","substring","indexOf","html","convertedData","importEmailTemplatesFromFiles","names","readdirSync","jsonFiles","startsWith","endsWith","toLowerCase","total","totalErrors","readFileSync","errors","_putEmailTemplateErro","importFirstEmailTemplateFromFile","_putEmailTemplateErro2","_putEmailTemplateErro3"],"sources":["ops/EmailTemplateOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { EmailTemplateSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { EmailTemplate, ExportImportUtils } from '@rockcarver/frodo-lib';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\nimport {\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n printMessage,\n createTable,\n showSpinner,\n succeedSpinner,\n failSpinner,\n debugMessage,\n} from '../utils/Console';\nimport wordwrap from './utils/Wordwrap';\nimport path from 'path';\nimport { cloneDeep } from './utils/OpsUtils';\n\nconst EMAIL_TEMPLATE_FILE_TYPE = 'template.email';\nconst {\n EMAIL_TEMPLATE_TYPE,\n getEmailTemplate,\n getEmailTemplates,\n putEmailTemplate,\n} = EmailTemplate;\nconst { validateImport } = ExportImportUtils;\n\nconst regexEmailTemplateType = new RegExp(`${EMAIL_TEMPLATE_TYPE}/`, 'g');\n\n// use a function vs a template variable to avoid problems in loops\nfunction getFileDataTemplate() {\n return {\n meta: {},\n emailTemplate: {},\n };\n}\n\n/**\n * Get a one-line description of the email template\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n templateObj: EmailTemplateSkeleton\n): string {\n const description = `[${templateObj._id.split('/')[1]['brightCyan']}] ${\n templateObj.displayName ? templateObj.displayName : ''\n } - ${\n templateObj.defaultLocale\n ? templateObj.subject[templateObj.defaultLocale]\n : Object.values(templateObj.subject)[0]\n }`;\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 += '| Display Name | Locale(s) | Subject | Id |\\n';\n markdown += '| ------------ | --------- | ------- | ---|';\n return markdown;\n}\n\n/**\n * Get a table-row of the email template in markdown\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a table-row of the email template in markdown\n */\nexport function getTableRowMd(templateObj: EmailTemplateSkeleton): string {\n const templateId = templateObj._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const locales = `${templateObj.defaultLocale}${\n Object.keys(templateObj.subject).length > 1\n ? ` (${Object.keys(templateObj.subject)\n .filter((locale) => locale !== templateObj.defaultLocale)\n .join(',')})`\n : ''\n }`;\n const row = `| ${\n templateObj.name ? templateObj.name : templateId\n } | ${locales} | ${\n templateObj.subject[templateObj.defaultLocale]\n } | \\`${templateId}\\` |`;\n return row;\n}\n\n/**\n * List email templates\n * @param {boolean} long Long list format with details\n * @return {Promise<unknown[]>} a promise that resolves to an array of email template objects\n */\nexport async function listEmailTemplates(long = false): Promise<unknown[]> {\n let emailTemplates = [];\n try {\n emailTemplates = (await getEmailTemplates()).result;\n } catch (error) {\n printMessage(`Error retrieving email templates: ${error.message}`, 'error');\n }\n emailTemplates.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const [, emailTemplate] of emailTemplates.entries()) {\n printMessage(\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n 'data'\n );\n }\n } else {\n const table = createTable([\n 'Id'['brightCyan'],\n 'Name'['brightCyan'],\n 'Status'['brightCyan'],\n 'Locale(s)'['brightCyan'],\n 'From'['brightCyan'],\n 'Subject'['brightCyan'],\n ]);\n for (const emailTemplate of emailTemplates) {\n table.push([\n // Id\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n // Name\n `${emailTemplate.displayName ? emailTemplate.displayName : ''}`,\n // Status\n emailTemplate.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n // Locale(s)\n `${emailTemplate.defaultLocale}${\n Object.keys(emailTemplate.subject).length > 1\n ? ` (${Object.keys(emailTemplate.subject)\n .filter((locale) => locale !== emailTemplate.defaultLocale)\n .join(',')})`\n : ''\n }`,\n // From\n `${emailTemplate.from ? emailTemplate.from : ''}`,\n // Subject\n wordwrap(emailTemplate.subject[emailTemplate.defaultLocale], 40),\n ]);\n }\n printMessage(table.toString(), 'data');\n }\n return emailTemplates;\n}\n\n/**\n * Export single email template to a file\n * @param {string} templateId email template id to export\n * @param {string} file filename where to export the template data\n */\nexport async function exportEmailTemplateToFile(\n templateId: string,\n file: string\n) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n }\n createProgressIndicator('determinate', 1, `Exporting ${templateId}`);\n try {\n const templateData = await getEmailTemplate(templateId);\n updateProgressIndicator(`Writing file ${fileName}`);\n const fileData = getFileDataTemplate();\n fileData.emailTemplate[templateId] = templateData;\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `Exported ${templateId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to file\n * @param {String} file optional filename\n */\nexport async function exportEmailTemplatesToFile(file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allEmailTemplates`, EMAIL_TEMPLATE_FILE_TYPE);\n }\n try {\n const fileData = getFileDataTemplate();\n const response = await getEmailTemplates();\n const templates = response.result;\n createProgressIndicator(\n 'determinate',\n response.resultCount,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n }\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `${response.resultCount} templates exported to ${fileName}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to separate files\n */\nexport async function exportEmailTemplatesToFiles() {\n try {\n const response = await getEmailTemplates();\n const templates = response.result;\n createProgressIndicator(\n 'determinate',\n response.resultCount,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n const fileData = getFileDataTemplate();\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n saveJsonToFile(fileData, fileName);\n }\n stopProgressIndicator(`${response.resultCount} templates exported.`);\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Import email template by id from file\n * @param {string} templateId email template id\n * @param {string} file optional filename\n * @param {boolean} raw import raw data file lacking frodo export envelop\n */\nexport async function importEmailTemplateFromFile(\n templateId: string,\n file: string,\n raw = false\n) {\n // eslint-disable-next-line no-param-reassign\n templateId = templateId.replaceAll(`${EMAIL_TEMPLATE_TYPE}/`, '');\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (raw || validateImport(fileData.meta)) {\n createProgressIndicator('determinate', 1, `Importing ${templateId}`);\n if (\n fileData.emailTemplate[templateId] ||\n (raw && fileData._id === templateId)\n ) {\n try {\n const emailTemplateData = raw\n ? s2sConvert(fileData)\n : fileData.emailTemplate[templateId];\n await putEmailTemplate(templateId, emailTemplateData);\n updateProgressIndicator(`Importing ${templateId}`);\n stopProgressIndicator(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n stopProgressIndicator(`${putEmailTemplateError}`);\n printMessage(putEmailTemplateError, 'error');\n }\n } else {\n stopProgressIndicator(\n `Email template ${templateId} not found in ${file}!`\n );\n printMessage(\n `Email template ${templateId} not found in ${file}!`,\n 'error'\n );\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all email templates from file\n * @param {string} file optional filename\n */\nexport async function importEmailTemplatesFromFile(file: string) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(\n 'determinate',\n Object.keys(fileData.emailTemplate).length,\n `Importing email templates`\n );\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n // eslint-disable-next-line no-await-in-loop\n await putEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n updateProgressIndicator(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError.response.data, 'error');\n }\n }\n }\n stopProgressIndicator(`Done.`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Helper function to get email template id from file name\n * @param {string} file file name\n * @returns {string} email template id/name\n */\nfunction getEmailTemplateIdFromFile(file: string) {\n debugMessage(`cli.EmailTemplateOps.getEmailTemplateIdFromFile: file=${file}`);\n const fileName = path.basename(file);\n const templateId = fileName.substring(14, fileName.indexOf('.'));\n debugMessage(\n `cli.EmailTemplateOps.getEmailTemplateIdFromFile: templateId=${templateId}`\n );\n return templateId;\n}\n\n/**\n * Convert template for s2s purposes (software-to-saas migration)\n * @param {EmailTemplateSkeleton} templateData template object\n * @returns {EmailTemplateSkeleton} converted template object\n */\nfunction s2sConvert(\n templateData: EmailTemplateSkeleton\n): EmailTemplateSkeleton {\n if (templateData.message && !templateData.html) {\n const convertedData = cloneDeep(templateData);\n convertedData.html = cloneDeep(templateData.message);\n debugMessage(`cli.EmailTemplateOps.s2sConvert: templateData:`);\n debugMessage(templateData);\n debugMessage(`cli.EmailTemplateOps.s2sConvert: convertedData:`);\n debugMessage(convertedData);\n return convertedData;\n }\n return templateData;\n}\n\n/**\n * Import all email templates from separate files\n * @param {boolean} raw import raw data file lacking frodo export envelop\n */\nexport async function importEmailTemplatesFromFiles(raw = false) {\n const names = fs.readdirSync('.');\n const jsonFiles = raw\n ? names.filter(\n (name) =>\n name.startsWith(`${EMAIL_TEMPLATE_TYPE}-`) && name.endsWith(`.json`)\n )\n : names.filter((name) =>\n name.toLowerCase().endsWith(`${EMAIL_TEMPLATE_FILE_TYPE}.json`)\n );\n createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing email templates...'\n );\n let total = 0;\n let totalErrors = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (\n (raw && file.startsWith('emailTemplate-')) ||\n validateImport(fileData.meta)\n ) {\n let errors = 0;\n if (raw) {\n total++;\n const templateId = getEmailTemplateIdFromFile(file);\n try {\n const templateData = s2sConvert(fileData);\n await putEmailTemplate(templateId, templateData);\n } catch (putEmailTemplateError) {\n errors += 1;\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError, 'error');\n printMessage(putEmailTemplateError.response?.data, 'error');\n }\n } else {\n total += Object.keys(fileData.emailTemplate).length;\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n await putEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n } catch (putEmailTemplateError) {\n errors += 1;\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError.response.data, 'error');\n }\n }\n }\n }\n totalErrors += errors;\n updateProgressIndicator(`Imported ${file}`);\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n `Imported ${total - totalErrors} of ${total} email template(s) from ${\n jsonFiles.length\n } file(s).`\n );\n}\n\n/**\n * Import first email template from file\n * @param {String} file optional filename\n */\nexport async function importFirstEmailTemplateFromFile(\n file: string,\n raw = false\n) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (\n (raw && file.startsWith('emailTemplate-')) ||\n validateImport(fileData.meta)\n ) {\n showSpinner(`Importing first email template`);\n if (raw) {\n const templateId = getEmailTemplateIdFromFile(file);\n try {\n const templateData = s2sConvert(fileData);\n await putEmailTemplate(templateId, templateData);\n succeedSpinner(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n failSpinner(`Error importing ${templateId}`);\n printMessage(putEmailTemplateError.response?.data, 'error');\n }\n } else {\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n try {\n await putEmailTemplate(\n id.replace(regexEmailTemplateType, ''),\n fileData.emailTemplate[id]\n );\n succeedSpinner(`Imported ${id}`);\n } catch (putEmailTemplateError) {\n failSpinner(`Error importing ${id}`);\n printMessage(putEmailTemplateError.response?.data, 'error');\n }\n break;\n }\n }\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAEnB,SAASC,aAAa,EAAEC,iBAAiB,QAAQ,uBAAuB;AACxE,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAC7E,SACEC,uBAAuB,EACvBC,uBAAuB,EACvBC,qBAAqB,EACrBC,YAAY,EACZC,WAAW,EACXC,WAAW,EACXC,cAAc,EACdC,WAAW,EACXC,YAAY,QACP,kBAAkB;AACzB,OAAOC,QAAQ,MAAM,kBAAkB;AACvC,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,SAAS,QAAQ,kBAAkB;AAE5C,MAAMC,wBAAwB,GAAG,gBAAgB;AACjD,MAAM;EACJC,mBAAmB;EACnBC,gBAAgB;EAChBC,iBAAiB;EACjBC;AACF,CAAC,GAAGpB,aAAa;AACjB,MAAM;EAAEqB;AAAe,CAAC,GAAGpB,iBAAiB;AAE5C,MAAMqB,sBAAsB,GAAG,IAAIC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AC,6BAA6B,EAAE,OAAO,CAAC;IACtD;EACF,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"EmailTemplateOps.js","names":["frodo","fs","getTypedFilename","saveJsonToFile","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","printMessage","createTable","showSpinner","succeedSpinner","failSpinner","debugMessage","wordwrap","path","cloneDeep","EMAIL_TEMPLATE_TYPE","email","template","EMAIL_TEMPLATE_FILE_TYPE","regexEmailTemplateType","RegExp","getFileDataTemplate","meta","emailTemplate","getOneLineDescription","templateObj","description","_id","split","displayName","defaultLocale","subject","Object","values","getTableHeaderMd","markdown","getTableRowMd","templateId","replace","locales","keys","length","filter","locale","join","row","name","listEmailTemplates","long","emailTemplates","getEmailTemplates","result","error","message","sort","a","b","localeCompare","entries","table","push","enabled","from","toString","exportEmailTemplateToFile","file","fileName","templateData","getEmailTemplate","fileData","err","exportEmailTemplatesToFile","response","templates","resultCount","exportEmailTemplatesToFiles","importEmailTemplateFromFile","raw","replaceAll","readFile","data","JSON","parse","utils","impex","validateImport","emailTemplateData","s2sConvert","putEmailTemplate","putEmailTemplateError","importEmailTemplatesFromFile","id","hasOwnProperty","call","getEmailTemplateIdFromFile","basename","substring","indexOf","html","convertedData","importEmailTemplatesFromFiles","names","readdirSync","jsonFiles","startsWith","endsWith","toLowerCase","total","totalErrors","readFileSync","errors","_putEmailTemplateErro","importFirstEmailTemplateFromFile","_putEmailTemplateErro2","_putEmailTemplateErro3"],"sources":["ops/EmailTemplateOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport type { EmailTemplateSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\nimport {\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n printMessage,\n createTable,\n showSpinner,\n succeedSpinner,\n failSpinner,\n debugMessage,\n} from '../utils/Console';\nimport wordwrap from './utils/Wordwrap';\nimport path from 'path';\nimport { cloneDeep } from './utils/OpsUtils';\n\nconst EMAIL_TEMPLATE_TYPE = frodo.email.template.EMAIL_TEMPLATE_TYPE;\nconst EMAIL_TEMPLATE_FILE_TYPE = 'template.email';\n\nconst regexEmailTemplateType = new RegExp(`${EMAIL_TEMPLATE_TYPE}/`, 'g');\n\n// use a function vs a template variable to avoid problems in loops\nfunction getFileDataTemplate() {\n return {\n meta: {},\n emailTemplate: {},\n };\n}\n\n/**\n * Get a one-line description of the email template\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n templateObj: EmailTemplateSkeleton\n): string {\n const description = `[${templateObj._id.split('/')[1]['brightCyan']}] ${\n templateObj.displayName ? templateObj.displayName : ''\n } - ${\n templateObj.defaultLocale\n ? templateObj.subject[templateObj.defaultLocale]\n : Object.values(templateObj.subject)[0]\n }`;\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 += '| Display Name | Locale(s) | Subject | Id |\\n';\n markdown += '| ------------ | --------- | ------- | ---|';\n return markdown;\n}\n\n/**\n * Get a table-row of the email template in markdown\n * @param {EmailTemplateSkeleton} templateObj email template object to describe\n * @returns {string} a table-row of the email template in markdown\n */\nexport function getTableRowMd(templateObj: EmailTemplateSkeleton): string {\n const templateId = templateObj._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const locales = `${templateObj.defaultLocale}${\n Object.keys(templateObj.subject).length > 1\n ? ` (${Object.keys(templateObj.subject)\n .filter((locale) => locale !== templateObj.defaultLocale)\n .join(',')})`\n : ''\n }`;\n const row = `| ${\n templateObj.name ? templateObj.name : templateId\n } | ${locales} | ${\n templateObj.subject[templateObj.defaultLocale]\n } | \\`${templateId}\\` |`;\n return row;\n}\n\n/**\n * List email templates\n * @param {boolean} long Long list format with details\n * @return {Promise<unknown[]>} a promise that resolves to an array of email template objects\n */\nexport async function listEmailTemplates(long = false): Promise<unknown[]> {\n let emailTemplates = [];\n try {\n emailTemplates = (await frodo.email.template.getEmailTemplates()).result;\n } catch (error) {\n printMessage(`Error retrieving email templates: ${error.message}`, 'error');\n }\n emailTemplates.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const [, emailTemplate] of emailTemplates.entries()) {\n printMessage(\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n 'data'\n );\n }\n } else {\n const table = createTable([\n 'Id'['brightCyan'],\n 'Name'['brightCyan'],\n 'Status'['brightCyan'],\n 'Locale(s)'['brightCyan'],\n 'From'['brightCyan'],\n 'Subject'['brightCyan'],\n ]);\n for (const emailTemplate of emailTemplates) {\n table.push([\n // Id\n `${emailTemplate._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '')}`,\n // Name\n `${emailTemplate.displayName ? emailTemplate.displayName : ''}`,\n // Status\n emailTemplate.enabled === false\n ? 'disabled'['brightRed']\n : 'enabled'['brightGreen'],\n // Locale(s)\n `${emailTemplate.defaultLocale}${\n Object.keys(emailTemplate.subject).length > 1\n ? ` (${Object.keys(emailTemplate.subject)\n .filter((locale) => locale !== emailTemplate.defaultLocale)\n .join(',')})`\n : ''\n }`,\n // From\n `${emailTemplate.from ? emailTemplate.from : ''}`,\n // Subject\n wordwrap(emailTemplate.subject[emailTemplate.defaultLocale], 40),\n ]);\n }\n printMessage(table.toString(), 'data');\n }\n return emailTemplates;\n}\n\n/**\n * Export single email template to a file\n * @param {string} templateId email template id to export\n * @param {string} file filename where to export the template data\n */\nexport async function exportEmailTemplateToFile(\n templateId: string,\n file: string\n) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n }\n createProgressIndicator('determinate', 1, `Exporting ${templateId}`);\n try {\n const templateData = await frodo.email.template.getEmailTemplate(\n templateId\n );\n updateProgressIndicator(`Writing file ${fileName}`);\n const fileData = getFileDataTemplate();\n fileData.emailTemplate[templateId] = templateData;\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `Exported ${templateId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to file\n * @param {String} file optional filename\n */\nexport async function exportEmailTemplatesToFile(file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allEmailTemplates`, EMAIL_TEMPLATE_FILE_TYPE);\n }\n try {\n const fileData = getFileDataTemplate();\n const response = await frodo.email.template.getEmailTemplates();\n const templates = response.result;\n createProgressIndicator(\n 'determinate',\n response.resultCount,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n }\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `${response.resultCount} templates exported to ${fileName}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all email templates to separate files\n */\nexport async function exportEmailTemplatesToFiles() {\n try {\n const response = await frodo.email.template.getEmailTemplates();\n const templates = response.result;\n createProgressIndicator(\n 'determinate',\n response.resultCount,\n 'Exporting email templates'\n );\n for (const template of templates) {\n const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');\n const fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);\n const fileData = getFileDataTemplate();\n updateProgressIndicator(`Exporting ${templateId}`);\n fileData.emailTemplate[templateId] = template;\n saveJsonToFile(fileData, fileName);\n }\n stopProgressIndicator(`${response.resultCount} templates exported.`);\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Import email template by id from file\n * @param {string} templateId email template id\n * @param {string} file optional filename\n * @param {boolean} raw import raw data file lacking frodo export envelop\n */\nexport async function importEmailTemplateFromFile(\n templateId: string,\n file: string,\n raw = false\n) {\n // eslint-disable-next-line no-param-reassign\n templateId = templateId.replaceAll(`${EMAIL_TEMPLATE_TYPE}/`, '');\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (raw || frodo.utils.impex.validateImport(fileData.meta)) {\n createProgressIndicator('determinate', 1, `Importing ${templateId}`);\n if (\n fileData.emailTemplate[templateId] ||\n (raw && fileData._id === templateId)\n ) {\n try {\n const emailTemplateData = raw\n ? s2sConvert(fileData)\n : fileData.emailTemplate[templateId];\n await frodo.email.template.putEmailTemplate(\n templateId,\n emailTemplateData\n );\n updateProgressIndicator(`Importing ${templateId}`);\n stopProgressIndicator(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n stopProgressIndicator(`${putEmailTemplateError}`);\n printMessage(putEmailTemplateError, 'error');\n }\n } else {\n stopProgressIndicator(\n `Email template ${templateId} not found in ${file}!`\n );\n printMessage(\n `Email template ${templateId} not found in ${file}!`,\n 'error'\n );\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all email templates from file\n * @param {string} file optional filename\n */\nexport async function importEmailTemplatesFromFile(file: string) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (frodo.utils.impex.validateImport(fileData.meta)) {\n createProgressIndicator(\n 'determinate',\n Object.keys(fileData.emailTemplate).length,\n `Importing email templates`\n );\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n await frodo.email.template.putEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n updateProgressIndicator(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError.response.data, 'error');\n }\n }\n }\n stopProgressIndicator(`Done.`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Helper function to get email template id from file name\n * @param {string} file file name\n * @returns {string} email template id/name\n */\nfunction getEmailTemplateIdFromFile(file: string) {\n debugMessage(`cli.EmailTemplateOps.getEmailTemplateIdFromFile: file=${file}`);\n const fileName = path.basename(file);\n const templateId = fileName.substring(14, fileName.indexOf('.'));\n debugMessage(\n `cli.EmailTemplateOps.getEmailTemplateIdFromFile: templateId=${templateId}`\n );\n return templateId;\n}\n\n/**\n * Convert template for s2s purposes (software-to-saas migration)\n * @param {EmailTemplateSkeleton} templateData template object\n * @returns {EmailTemplateSkeleton} converted template object\n */\nfunction s2sConvert(\n templateData: EmailTemplateSkeleton\n): EmailTemplateSkeleton {\n if (templateData.message && !templateData.html) {\n const convertedData = cloneDeep(templateData);\n convertedData.html = cloneDeep(templateData.message);\n debugMessage(`cli.EmailTemplateOps.s2sConvert: templateData:`);\n debugMessage(templateData);\n debugMessage(`cli.EmailTemplateOps.s2sConvert: convertedData:`);\n debugMessage(convertedData);\n return convertedData;\n }\n return templateData;\n}\n\n/**\n * Import all email templates from separate files\n * @param {boolean} raw import raw data file lacking frodo export envelop\n */\nexport async function importEmailTemplatesFromFiles(raw = false) {\n const names = fs.readdirSync('.');\n const jsonFiles = raw\n ? names.filter(\n (name) =>\n name.startsWith(`${EMAIL_TEMPLATE_TYPE}-`) && name.endsWith(`.json`)\n )\n : names.filter((name) =>\n name.toLowerCase().endsWith(`${EMAIL_TEMPLATE_FILE_TYPE}.json`)\n );\n createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing email templates...'\n );\n let total = 0;\n let totalErrors = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (\n (raw && file.startsWith('emailTemplate-')) ||\n frodo.utils.impex.validateImport(fileData.meta)\n ) {\n let errors = 0;\n if (raw) {\n total++;\n const templateId = getEmailTemplateIdFromFile(file);\n try {\n const templateData = s2sConvert(fileData);\n await frodo.email.template.putEmailTemplate(templateId, templateData);\n } catch (putEmailTemplateError) {\n errors += 1;\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError, 'error');\n printMessage(putEmailTemplateError.response?.data, 'error');\n }\n } else {\n total += Object.keys(fileData.emailTemplate).length;\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n const templateId = id.replace(regexEmailTemplateType, '');\n try {\n await frodo.email.template.putEmailTemplate(\n templateId,\n fileData.emailTemplate[templateId]\n );\n } catch (putEmailTemplateError) {\n errors += 1;\n printMessage(`\\nError importing ${templateId}`, 'error');\n printMessage(putEmailTemplateError.response.data, 'error');\n }\n }\n }\n }\n totalErrors += errors;\n updateProgressIndicator(`Imported ${file}`);\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n `Imported ${total - totalErrors} of ${total} email template(s) from ${\n jsonFiles.length\n } file(s).`\n );\n}\n\n/**\n * Import first email template from file\n * @param {String} file optional filename\n */\nexport async function importFirstEmailTemplateFromFile(\n file: string,\n raw = false\n) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (\n (raw && file.startsWith('emailTemplate-')) ||\n frodo.utils.impex.validateImport(fileData.meta)\n ) {\n showSpinner(`Importing first email template`);\n if (raw) {\n const templateId = getEmailTemplateIdFromFile(file);\n try {\n const templateData = s2sConvert(fileData);\n await frodo.email.template.putEmailTemplate(templateId, templateData);\n succeedSpinner(`Imported ${templateId}`);\n } catch (putEmailTemplateError) {\n failSpinner(`Error importing ${templateId}`);\n printMessage(putEmailTemplateError.response?.data, 'error');\n }\n } else {\n for (const id in fileData.emailTemplate) {\n if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {\n try {\n await frodo.email.template.putEmailTemplate(\n id.replace(regexEmailTemplateType, ''),\n fileData.emailTemplate[id]\n );\n succeedSpinner(`Imported ${id}`);\n } catch (putEmailTemplateError) {\n failSpinner(`Error importing ${id}`);\n printMessage(putEmailTemplateError.response?.data, 'error');\n }\n break;\n }\n }\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAC7E,SACEC,uBAAuB,EACvBC,uBAAuB,EACvBC,qBAAqB,EACrBC,YAAY,EACZC,WAAW,EACXC,WAAW,EACXC,cAAc,EACdC,WAAW,EACXC,YAAY,QACP,kBAAkB;AACzB,OAAOC,QAAQ,MAAM,kBAAkB;AACvC,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,SAAS,QAAQ,kBAAkB;AAE5C,MAAMC,mBAAmB,GAAGhB,KAAK,CAACiB,KAAK,CAACC,QAAQ,CAACF,mBAAmB;AACpE,MAAMG,wBAAwB,GAAG,gBAAgB;AAEjD,MAAMC,sBAAsB,GAAG,IAAIC,MAAM,CAAE,GAAEL,mBAAoB,GAAE,EAAE,GAAG,CAAC;;AAEzE;AACA,SAASM,mBAAmBA,CAAA,EAAG;EAC7B,OAAO;IACLC,IAAI,EAAE,CAAC,CAAC;IACRC,aAAa,EAAE,CAAC;EAClB,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACnCC,WAAkC,EAC1B;EACR,MAAMC,WAAW,GAAI,IAAGD,WAAW,CAACE,GAAG,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAE,KAClEH,WAAW,CAACI,WAAW,GAAGJ,WAAW,CAACI,WAAW,GAAG,EACrD,MACCJ,WAAW,CAACK,aAAa,GACrBL,WAAW,CAACM,OAAO,CAACN,WAAW,CAACK,aAAa,CAAC,GAC9CE,MAAM,CAACC,MAAM,CAACR,WAAW,CAACM,OAAO,CAAC,CAAC,CAAC,CACzC,EAAC;EACF,OAAOL,WAAW;AACpB;;AAEA;AACA;AACA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esm/ops/IdmOps.js CHANGED
@@ -4,30 +4,16 @@ 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 { Idm, Utils, ValidationUtils } from '@rockcarver/frodo-lib';
7
+ import { frodo } from '@rockcarver/frodo-lib';
8
8
  import { createProgressIndicator, printMessage, stopProgressIndicator } from '../utils/Console';
9
9
  import { getTypedFilename } from '../utils/ExportImportUtils';
10
- const {
11
- readFiles,
12
- unSubstituteEnvParams
13
- } = Utils;
14
- const {
15
- validateScriptHooks
16
- } = ValidationUtils;
17
- const {
18
- getAllConfigEntities,
19
- getConfigEntity,
20
- putConfigEntity,
21
- queryAllManagedObjectsByType,
22
- testConnectorServers
23
- } = Idm;
24
10
 
25
11
  /**
26
12
  * Warn about and list offline remote connector servers
27
13
  */
28
14
  export async function warnAboutOfflineConnectorServers() {
29
15
  try {
30
- const all = await testConnectorServers();
16
+ const all = await frodo.idm.config.testConnectorServers();
31
17
  const offline = all.filter(status => !status.ok).map(status => status.name);
32
18
  if (offline.length) {
33
19
  printMessage(`\nThe following connector server(s) are offline and their connectors and configuration unavailable:\n${offline.join('\n')}`, 'warn');
@@ -45,7 +31,7 @@ export async function listAllConfigEntities() {
45
31
  try {
46
32
  const {
47
33
  configurations
48
- } = await getAllConfigEntities();
34
+ } = await frodo.idm.config.getAllConfigEntities();
49
35
  for (const configEntity of configurations) {
50
36
  printMessage(`${configEntity._id}`, 'data');
51
37
  }
@@ -65,7 +51,7 @@ export async function exportConfigEntity(id, file) {
65
51
  if (!fileName) {
66
52
  fileName = getTypedFilename(`${id}`, 'idm');
67
53
  }
68
- const configEntity = await getConfigEntity(id);
54
+ const configEntity = await frodo.idm.config.getConfigEntity(id);
69
55
  fs.writeFile(fileName, JSON.stringify(configEntity, null, 2), err => {
70
56
  if (err) {
71
57
  return printMessage(`ERROR - can't save ${id} export to file`, 'error');
@@ -82,14 +68,14 @@ export async function exportAllRawConfigEntities(directory) {
82
68
  try {
83
69
  const {
84
70
  configurations
85
- } = await getAllConfigEntities();
71
+ } = await frodo.idm.config.getAllConfigEntities();
86
72
  if (!fs.existsSync(directory)) {
87
73
  fs.mkdirSync(directory);
88
74
  }
89
75
  createProgressIndicator('indeterminate', undefined, 'Exporting config objects...');
90
76
  const entityPromises = [];
91
77
  for (const configEntity of configurations) {
92
- entityPromises.push(getConfigEntity(configEntity._id).catch(getConfigEntityError => {
78
+ entityPromises.push(frodo.idm.config.getConfigEntity(configEntity._id).catch(getConfigEntityError => {
93
79
  var _getConfigEntityError, _getConfigEntityError2, _getConfigEntityError3, _getConfigEntityError4, _getConfigEntityError5, _getConfigEntityError6, _getConfigEntityError7, _getConfigEntityError8, _getConfigEntityError9;
94
80
  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.') && !(
95
81
  // list of config entities, which do not exist by default or ever.
@@ -140,7 +126,7 @@ export async function exportAllConfigEntities(directory, entitiesFile, envFile)
140
126
  try {
141
127
  const {
142
128
  configurations
143
- } = await getAllConfigEntities();
129
+ } = await frodo.idm.config.getAllConfigEntities();
144
130
  // create export directory if not exist
145
131
  if (!fs.existsSync(directory)) {
146
132
  fs.mkdirSync(directory);
@@ -149,7 +135,7 @@ export async function exportAllConfigEntities(directory, entitiesFile, envFile)
149
135
  const entityPromises = [];
150
136
  for (const configEntity of configurations) {
151
137
  if (entriesToExport.includes(configEntity._id)) {
152
- entityPromises.push(getConfigEntity(configEntity._id));
138
+ entityPromises.push(frodo.idm.config.getConfigEntity(configEntity._id));
153
139
  }
154
140
  }
155
141
  const results = await Promise.all(entityPromises);
@@ -184,15 +170,15 @@ export async function importConfigEntityByIdFromFile(entityId, file, validate) {
184
170
  if (!file) {
185
171
  file = getTypedFilename(entityId, 'idm');
186
172
  }
187
- const entityData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');
188
- const jsObject = JSON.parse(entityData);
189
- const isValid = validateScriptHooks(jsObject);
173
+ const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');
174
+ const entityData = JSON.parse(fileData);
175
+ const isValid = frodo.helper.script.validateScriptHooks(entityData);
190
176
  if (validate && !isValid) {
191
177
  printMessage('Invalid IDM configuration object', 'error');
192
178
  return;
193
179
  }
194
180
  try {
195
- await putConfigEntity(entityId, entityData);
181
+ await frodo.idm.config.putConfigEntity(entityId, entityData);
196
182
  } catch (putConfigEntityError) {
197
183
  printMessage(putConfigEntityError, 'error');
198
184
  printMessage(`Error: ${putConfigEntityError}`, 'error');
@@ -205,16 +191,16 @@ export async function importConfigEntityByIdFromFile(entityId, file, validate) {
205
191
  * @param validate validate script hooks
206
192
  */
207
193
  export async function importConfigEntityFromFile(file, validate) {
208
- const importData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');
209
- const jsObject = JSON.parse(importData);
210
- const entityId = jsObject._id;
211
- const isValid = validateScriptHooks(jsObject);
194
+ const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');
195
+ const entityData = JSON.parse(fileData);
196
+ const entityId = entityData._id;
197
+ const isValid = frodo.helper.script.validateScriptHooks(entityData);
212
198
  if (validate && !isValid) {
213
199
  printMessage('Invalid IDM configuration object', 'error');
214
200
  return;
215
201
  }
216
202
  try {
217
- await putConfigEntity(entityId, importData);
203
+ await frodo.idm.config.putConfigEntity(entityId, entityData);
218
204
  } catch (putConfigEntityError) {
219
205
  printMessage(putConfigEntityError, 'error');
220
206
  printMessage(`Error: ${putConfigEntityError}`, 'error');
@@ -230,7 +216,7 @@ export async function importAllRawConfigEntities(baseDirectory, validate) {
230
216
  if (!fs.existsSync(baseDirectory)) {
231
217
  return;
232
218
  }
233
- const files = await readFiles(baseDirectory);
219
+ const files = await frodo.helper.utils.readFiles(baseDirectory);
234
220
  const jsonFiles = files.filter(({
235
221
  path
236
222
  }) => path.toLowerCase().endsWith('.json')).map(({
@@ -245,7 +231,7 @@ export async function importAllRawConfigEntities(baseDirectory, validate) {
245
231
  let everyScriptValid = true;
246
232
  for (const file of jsonFiles) {
247
233
  const jsObject = JSON.parse(file.content);
248
- const isScriptValid = validateScriptHooks(jsObject);
234
+ const isScriptValid = frodo.helper.script.validateScriptHooks(jsObject);
249
235
  if (!isScriptValid) {
250
236
  printMessage(`Invalid script hook in ${file.path}`, 'error');
251
237
  everyScriptValid = false;
@@ -256,7 +242,7 @@ export async function importAllRawConfigEntities(baseDirectory, validate) {
256
242
  }
257
243
  createProgressIndicator('indeterminate', undefined, 'Importing config objects...');
258
244
  const entityPromises = jsonFiles.map(file => {
259
- return putConfigEntity(file.entityId, file.content);
245
+ return frodo.idm.config.putConfigEntity(file.entityId, file.content);
260
246
  });
261
247
  const results = await Promise.allSettled(entityPromises);
262
248
  const errors = results.filter(result => result.status === 'rejected');
@@ -284,7 +270,7 @@ export async function importAllConfigEntities(baseDirectory, entitiesFile, envFi
284
270
  }
285
271
  const entriesToImport = JSON.parse(fs.readFileSync(entitiesFile, 'utf8')).idm;
286
272
  const envReader = propertiesReader(envFile);
287
- const files = await readFiles(baseDirectory);
273
+ const files = await frodo.helper.utils.readFiles(baseDirectory);
288
274
  const jsonFiles = files.filter(({
289
275
  path
290
276
  }) => path.toLowerCase().endsWith('.json')).map(({
@@ -299,7 +285,7 @@ export async function importAllConfigEntities(baseDirectory, entitiesFile, envFi
299
285
  let everyScriptValid = true;
300
286
  for (const file of jsonFiles) {
301
287
  const jsObject = JSON.parse(file.content);
302
- const isScriptValid = validateScriptHooks(jsObject);
288
+ const isScriptValid = frodo.helper.script.validateScriptHooks(jsObject);
303
289
  if (!isScriptValid) {
304
290
  printMessage(`Invalid script hook in ${file.path}`, 'error');
305
291
  everyScriptValid = false;
@@ -317,8 +303,8 @@ export async function importAllConfigEntities(baseDirectory, entitiesFile, envFi
317
303
  entityId,
318
304
  content
319
305
  }) => {
320
- const unsubstituted = unSubstituteEnvParams(content, envReader);
321
- return putConfigEntity(entityId, unsubstituted);
306
+ const unsubstituted = frodo.helper.utils.unSubstituteEnvParams(content, envReader);
307
+ return frodo.idm.config.putConfigEntity(entityId, unsubstituted);
322
308
  });
323
309
  const results = await Promise.allSettled(entityPromises);
324
310
  const errors = results.filter(result => result.status === 'rejected');
@@ -349,7 +335,7 @@ export async function countManagedObjects(type) {
349
335
  };
350
336
  try {
351
337
  do {
352
- result = await queryAllManagedObjectsByType(type, [], result.pagedResultsCookie);
338
+ result = await frodo.idm.config.queryAllManagedObjectsByType(type, [], result.pagedResultsCookie);
353
339
  count += result.resultCount;
354
340
  } while (result.pagedResultsCookie);
355
341
  printMessage(`${type}: ${count}`);
@@ -1 +1 @@
1
- {"version":3,"file":"IdmOps.js","names":["fs","fse","path","propertiesReader","replaceall","Idm","Utils","ValidationUtils","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","readFiles","unSubstituteEnvParams","validateScriptHooks","getAllConfigEntities","getConfigEntity","putConfigEntity","queryAllManagedObjectsByType","testConnectorServers","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","idm","envParams","configEntityString","each","key","value","importConfigEntityByIdFromFile","entityId","validate","entityData","readFileSync","resolve","process","cwd","jsObject","isValid","putConfigEntityError","importConfigEntityFromFile","importData","importAllRawConfigEntities","baseDirectory","files","jsonFiles","toLowerCase","endsWith","content","substring","everyScriptValid","isScriptValid","allSettled","errors","result","importAllConfigEntities","entriesToImport","envReader","unsubstituted","countManagedObjects","type","count","resultCount","pagedResultsCookie","totalPagedResultsPolicy","totalPagedResults","remainingPagedResults"],"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 { Idm, Utils, ValidationUtils } from '@rockcarver/frodo-lib';\nimport {\n createProgressIndicator,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename } from '../utils/ExportImportUtils';\n\nconst { readFiles, unSubstituteEnvParams } = Utils;\nconst { validateScriptHooks } = ValidationUtils;\nconst {\n getAllConfigEntities,\n getConfigEntity,\n putConfigEntity,\n queryAllManagedObjectsByType,\n testConnectorServers,\n} = Idm;\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 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 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 importData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n const jsObject = JSON.parse(importData);\n const entityId = jsObject._id;\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, importData);\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;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,GAAG,EAAEC,KAAK,EAAEC,eAAe,QAAQ,uBAAuB;AACnE,SACEC,uBAAuB,EACvBC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,gBAAgB,QAAQ,4BAA4B;AAE7D,MAAM;EAAEC,SAAS;EAAEC;AAAsB,CAAC,GAAGP,KAAK;AAClD,MAAM;EAAEQ;AAAoB,CAAC,GAAGP,eAAe;AAC/C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,kBACT,CAAC;MACDF,KAAK,IAAIP,MAAM,CAACQ,WAAW;IAC7B,CAAC,QAAQR,MAAM,CAACS,kBAAkB;IAClC9G,YAAY,CAAE,GAAE2G,IAAK,KAAIC,KAAM,EAAC,CAAC;EACnC,CAAC,CAAC,OAAOvF,KAAK,EAAE;IACdrB,YAAY,CAACqB,KAAK,CAACiC,QAAQ,CAACC,IAAI,EAAE,OAAO,CAAC;IAC1CvD,YAAY,CAAE,2CAA0CqB,KAAM,EAAC,EAAE,OAAO,CAAC;EAC3E;AACF"}
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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AM,EAAE,EAAE;IACVS,WAAW,EAAE,CAAC;IACdC,kBAAkB,EAAE,IAAI;IACxBC,uBAAuB,EAAE,MAAM;IAC/BC,iBAAiB,EAAE,CAAC,CAAC;IACrBC,qBAAqB,EAAE,CAAC;EAC1B,CAAC;EACD,IAAI;IACF,GAAG;MACDb,MAAM,GAAG,MAAMzG,KAAK,CAACO,GAAG,CAACC,MAAM,CAAC+G,4BAA4B,CAC1DP,IAAI,EACJ,EAAE,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"}
package/esm/ops/IdpOps.js CHANGED
@@ -1,15 +1,7 @@
1
+ import { frodo } from '@rockcarver/frodo-lib';
1
2
  import fs from 'fs';
2
- import { Idp } from '@rockcarver/frodo-lib';
3
3
  import { createProgressBar, 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
- importSocialProvider,
10
- importFirstSocialProvider,
11
- importSocialProviders
12
- } = Idp;
13
5
 
14
6
  /**
15
7
  * Get a one-line description of the social idp object
@@ -47,7 +39,7 @@ export function getTableRowMd(socialIdpObj) {
47
39
  */
48
40
  export async function listSocialProviders() {
49
41
  try {
50
- const providers = await getSocialIdentityProviders();
42
+ const providers = await frodo.oauth2oidc.external.getSocialIdentityProviders();
51
43
  providers.sort((a, b) => a._id.localeCompare(b._id));
52
44
  providers.forEach(socialIdentityProvider => {
53
45
  printMessage(`${socialIdentityProvider._id}`, 'data');
@@ -71,7 +63,7 @@ export async function exportSocialProviderToFile(providerId, file = '') {
71
63
  createProgressBar(1, `Exporting ${providerId}`);
72
64
  try {
73
65
  updateProgressBar(`Writing file ${fileName}`);
74
- const fileData = await exportSocialProvider(providerId);
66
+ const fileData = await frodo.oauth2oidc.external.exportSocialProvider(providerId);
75
67
  saveJsonToFile(fileData, fileName);
76
68
  stopProgressBar(`Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`);
77
69
  } catch (err) {
@@ -89,7 +81,7 @@ export async function exportSocialProvidersToFile(file = '') {
89
81
  if (!fileName) {
90
82
  fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');
91
83
  }
92
- const fileData = await exportSocialProviders();
84
+ const fileData = await frodo.oauth2oidc.external.exportSocialProviders();
93
85
  saveJsonToFile(fileData, fileName);
94
86
  }
95
87
 
@@ -97,13 +89,13 @@ export async function exportSocialProvidersToFile(file = '') {
97
89
  * Export all providers to individual files
98
90
  */
99
91
  export async function exportSocialProvidersToFiles() {
100
- const allIdpsData = await getSocialIdentityProviders();
92
+ const allIdpsData = await frodo.oauth2oidc.external.getSocialIdentityProviders();
101
93
  // printMessage(allIdpsData, 'data');
102
94
  createProgressBar(allIdpsData.length, 'Exporting providers');
103
95
  for (const idpData of allIdpsData) {
104
96
  updateProgressBar(`Writing provider ${idpData._id}`);
105
97
  const fileName = getTypedFilename(idpData._id, 'idp');
106
- const fileData = await exportSocialProvider(idpData._id);
98
+ const fileData = await frodo.oauth2oidc.external.exportSocialProvider(idpData._id);
107
99
  saveJsonToFile(fileData, fileName);
108
100
  }
109
101
  stopProgressBar(`${allIdpsData.length} providers exported.`);
@@ -122,7 +114,7 @@ export async function importSocialProviderFromFile(providerId, file) {
122
114
  if (err) throw err;
123
115
  try {
124
116
  const fileData = JSON.parse(data);
125
- outcome = await importSocialProvider(providerId, fileData);
117
+ outcome = await frodo.oauth2oidc.external.importSocialProvider(providerId, fileData);
126
118
  succeedSpinner(`Successfully imported provider ${providerId} from ${file}.`);
127
119
  } catch (error) {
128
120
  var _error$response;
@@ -145,7 +137,7 @@ export async function importFirstSocialProviderFromFile(file) {
145
137
  if (err) throw err;
146
138
  try {
147
139
  const fileData = JSON.parse(data);
148
- outcome = await importFirstSocialProvider(fileData);
140
+ outcome = await frodo.oauth2oidc.external.importFirstSocialProvider(fileData);
149
141
  succeedSpinner(`Successfully imported first provider from ${file}.`);
150
142
  } catch (error) {
151
143
  var _error$response2;
@@ -168,7 +160,7 @@ export async function importSocialProvidersFromFile(file) {
168
160
  if (err) throw err;
169
161
  try {
170
162
  const fileData = JSON.parse(data);
171
- outcome = await importSocialProviders(fileData);
163
+ outcome = await frodo.oauth2oidc.external.importSocialProviders(fileData);
172
164
  succeedSpinner(`Successfully imported providers from ${file}.`);
173
165
  } catch (error) {
174
166
  var _error$response3;
@@ -192,7 +184,7 @@ export async function importSocialProvidersFromFiles() {
192
184
  const fileData = JSON.parse(data);
193
185
  const count = Object.keys(fileData.idp).length;
194
186
  total += count;
195
- await importSocialProviders(fileData);
187
+ await frodo.oauth2oidc.external.importSocialProviders(fileData);
196
188
  updateProgressBar(`Imported ${count} provider(s) from ${file}`);
197
189
  }
198
190
  stopProgressBar(`Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`);