@rockcarver/frodo-cli 2.0.0-4 → 2.0.0-40

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 (486) hide show
  1. package/CHANGELOG.md +308 -5
  2. package/esm/app.js +22 -5
  3. package/esm/app.js.map +1 -1
  4. package/esm/cli/FrodoCommand.js +33 -7
  5. package/esm/cli/FrodoCommand.js.map +1 -1
  6. package/esm/cli/_template/something-delete.js +7 -5
  7. package/esm/cli/_template/something-delete.js.map +1 -1
  8. package/esm/cli/_template/something-describe.js +7 -5
  9. package/esm/cli/_template/something-describe.js.map +1 -1
  10. package/esm/cli/_template/something-else-delete.js +7 -5
  11. package/esm/cli/_template/something-else-delete.js.map +1 -1
  12. package/esm/cli/_template/something-else-describe.js +7 -5
  13. package/esm/cli/_template/something-else-describe.js.map +1 -1
  14. package/esm/cli/_template/something-else-export.js +8 -6
  15. package/esm/cli/_template/something-else-export.js.map +1 -1
  16. package/esm/cli/_template/something-else-import.js +7 -5
  17. package/esm/cli/_template/something-else-import.js.map +1 -1
  18. package/esm/cli/_template/something-else-list.js +7 -5
  19. package/esm/cli/_template/something-else-list.js.map +1 -1
  20. package/esm/cli/_template/something-else.js +1 -1
  21. package/esm/cli/_template/something-else.js.map +1 -1
  22. package/esm/cli/_template/something-export.js +8 -6
  23. package/esm/cli/_template/something-export.js.map +1 -1
  24. package/esm/cli/_template/something-import.js +7 -5
  25. package/esm/cli/_template/something-import.js.map +1 -1
  26. package/esm/cli/_template/something-list.js +7 -5
  27. package/esm/cli/_template/something-list.js.map +1 -1
  28. package/esm/cli/_template/something-other-delete.js +7 -5
  29. package/esm/cli/_template/something-other-delete.js.map +1 -1
  30. package/esm/cli/_template/something-other-describe.js +7 -5
  31. package/esm/cli/_template/something-other-describe.js.map +1 -1
  32. package/esm/cli/_template/something-other-export.js +8 -6
  33. package/esm/cli/_template/something-other-export.js.map +1 -1
  34. package/esm/cli/_template/something-other-import.js +7 -5
  35. package/esm/cli/_template/something-other-import.js.map +1 -1
  36. package/esm/cli/_template/something-other-list.js +7 -5
  37. package/esm/cli/_template/something-other-list.js.map +1 -1
  38. package/esm/cli/_template/something-other.js +1 -1
  39. package/esm/cli/_template/something-other.js.map +1 -1
  40. package/esm/cli/_template/something.js +2 -2
  41. package/esm/cli/_template/something.js.map +1 -1
  42. package/esm/cli/admin/admin-add-autoid-static-user-mapping.js +10 -5
  43. package/esm/cli/admin/admin-add-autoid-static-user-mapping.js.map +1 -1
  44. package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js +14 -8
  45. package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js.map +1 -1
  46. package/esm/cli/admin/admin-execute-rfc7523-authz-grant-flow.js +41 -0
  47. package/esm/cli/admin/admin-execute-rfc7523-authz-grant-flow.js.map +1 -0
  48. package/esm/cli/admin/admin-federation-export.js +44 -0
  49. package/esm/cli/admin/admin-federation-export.js.map +1 -0
  50. package/esm/cli/admin/admin-federation-import.js +48 -0
  51. package/esm/cli/admin/admin-federation-import.js.map +1 -0
  52. package/esm/cli/admin/admin-federation-list.js +28 -0
  53. package/esm/cli/admin/admin-federation-list.js.map +1 -0
  54. package/esm/cli/admin/admin-federation.js +13 -0
  55. package/esm/cli/admin/admin-federation.js.map +1 -0
  56. package/esm/cli/admin/admin-generate-rfc7523-authz-grant-artefacts.js +43 -0
  57. package/esm/cli/admin/admin-generate-rfc7523-authz-grant-artefacts.js.map +1 -0
  58. package/esm/cli/admin/admin-get-access-token.js +12 -7
  59. package/esm/cli/admin/admin-get-access-token.js.map +1 -1
  60. package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +13 -8
  61. package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +1 -1
  62. package/esm/cli/admin/admin-hide-generic-extension-attributes.js +11 -6
  63. package/esm/cli/admin/admin-hide-generic-extension-attributes.js.map +1 -1
  64. package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +11 -6
  65. package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js.map +1 -1
  66. package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +11 -6
  67. package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js.map +1 -1
  68. package/esm/cli/admin/admin-list-static-user-mappings.js +12 -7
  69. package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
  70. package/esm/cli/admin/admin-remove-static-user-mapping.js +12 -6
  71. package/esm/cli/admin/admin-remove-static-user-mapping.js.map +1 -1
  72. package/esm/cli/admin/admin-repair-org-model.js +11 -6
  73. package/esm/cli/admin/admin-repair-org-model.js.map +1 -1
  74. package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +12 -7
  75. package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js.map +1 -1
  76. package/esm/cli/admin/admin-show-generic-extension-attributes.js +11 -6
  77. package/esm/cli/admin/admin-show-generic-extension-attributes.js.map +1 -1
  78. package/esm/cli/admin/admin-train-auto-access-model.js +32 -0
  79. package/esm/cli/admin/admin-train-auto-access-model.js.map +1 -0
  80. package/esm/cli/admin/admin.js +8 -2
  81. package/esm/cli/admin/admin.js.map +1 -1
  82. package/esm/cli/agent/agent-delete.js +13 -7
  83. package/esm/cli/agent/agent-delete.js.map +1 -1
  84. package/esm/cli/agent/agent-describe.js +7 -5
  85. package/esm/cli/agent/agent-describe.js.map +1 -1
  86. package/esm/cli/agent/agent-export.js +12 -10
  87. package/esm/cli/agent/agent-export.js.map +1 -1
  88. package/esm/cli/agent/agent-gateway-delete.js +13 -7
  89. package/esm/cli/agent/agent-gateway-delete.js.map +1 -1
  90. package/esm/cli/agent/agent-gateway-describe.js +7 -5
  91. package/esm/cli/agent/agent-gateway-describe.js.map +1 -1
  92. package/esm/cli/agent/agent-gateway-export.js +12 -10
  93. package/esm/cli/agent/agent-gateway-export.js.map +1 -1
  94. package/esm/cli/agent/agent-gateway-import.js +8 -6
  95. package/esm/cli/agent/agent-gateway-import.js.map +1 -1
  96. package/esm/cli/agent/agent-gateway-list.js +7 -5
  97. package/esm/cli/agent/agent-gateway-list.js.map +1 -1
  98. package/esm/cli/agent/agent-gateway.js +1 -1
  99. package/esm/cli/agent/agent-gateway.js.map +1 -1
  100. package/esm/cli/agent/agent-import.js +8 -6
  101. package/esm/cli/agent/agent-import.js.map +1 -1
  102. package/esm/cli/agent/agent-java-delete.js +13 -7
  103. package/esm/cli/agent/agent-java-delete.js.map +1 -1
  104. package/esm/cli/agent/agent-java-describe.js +7 -5
  105. package/esm/cli/agent/agent-java-describe.js.map +1 -1
  106. package/esm/cli/agent/agent-java-export.js +12 -10
  107. package/esm/cli/agent/agent-java-export.js.map +1 -1
  108. package/esm/cli/agent/agent-java-import.js +8 -6
  109. package/esm/cli/agent/agent-java-import.js.map +1 -1
  110. package/esm/cli/agent/agent-java-list.js +7 -5
  111. package/esm/cli/agent/agent-java-list.js.map +1 -1
  112. package/esm/cli/agent/agent-java.js +1 -1
  113. package/esm/cli/agent/agent-java.js.map +1 -1
  114. package/esm/cli/agent/agent-list.js +7 -5
  115. package/esm/cli/agent/agent-list.js.map +1 -1
  116. package/esm/cli/agent/agent-web-delete.js +13 -7
  117. package/esm/cli/agent/agent-web-delete.js.map +1 -1
  118. package/esm/cli/agent/agent-web-describe.js +7 -5
  119. package/esm/cli/agent/agent-web-describe.js.map +1 -1
  120. package/esm/cli/agent/agent-web-export.js +12 -10
  121. package/esm/cli/agent/agent-web-export.js.map +1 -1
  122. package/esm/cli/agent/agent-web-import.js +8 -6
  123. package/esm/cli/agent/agent-web-import.js.map +1 -1
  124. package/esm/cli/agent/agent-web-list.js +7 -5
  125. package/esm/cli/agent/agent-web-list.js.map +1 -1
  126. package/esm/cli/agent/agent-web.js +3 -3
  127. package/esm/cli/agent/agent-web.js.map +1 -1
  128. package/esm/cli/agent/agent.js +2 -2
  129. package/esm/cli/agent/agent.js.map +1 -1
  130. package/esm/cli/app/app-delete.js +27 -9
  131. package/esm/cli/app/app-delete.js.map +1 -1
  132. package/esm/cli/app/app-describe.js +9 -6
  133. package/esm/cli/app/app-describe.js.map +1 -1
  134. package/esm/cli/app/app-export.js +17 -14
  135. package/esm/cli/app/app-export.js.map +1 -1
  136. package/esm/cli/app/app-import.js +21 -18
  137. package/esm/cli/app/app-import.js.map +1 -1
  138. package/esm/cli/app/app-list.js +12 -9
  139. package/esm/cli/app/app-list.js.map +1 -1
  140. package/esm/cli/app/app.js +8 -12
  141. package/esm/cli/app/app.js.map +1 -1
  142. package/esm/cli/authn/authn-describe.js +29 -0
  143. package/esm/cli/authn/authn-describe.js.map +1 -0
  144. package/esm/cli/authn/authn-export.js +25 -0
  145. package/esm/cli/authn/authn-export.js.map +1 -0
  146. package/esm/cli/authn/authn-import.js +25 -0
  147. package/esm/cli/authn/authn-import.js.map +1 -0
  148. package/esm/cli/authn/authn.js +12 -0
  149. package/esm/cli/authn/authn.js.map +1 -0
  150. package/esm/cli/authz/authz-policy-delete.js +11 -9
  151. package/esm/cli/authz/authz-policy-delete.js.map +1 -1
  152. package/esm/cli/authz/authz-policy-describe.js +8 -6
  153. package/esm/cli/authz/authz-policy-describe.js.map +1 -1
  154. package/esm/cli/authz/authz-policy-export.js +18 -16
  155. package/esm/cli/authz/authz-policy-export.js.map +1 -1
  156. package/esm/cli/authz/authz-policy-import.js +11 -9
  157. package/esm/cli/authz/authz-policy-import.js.map +1 -1
  158. package/esm/cli/authz/authz-policy-list.js +11 -9
  159. package/esm/cli/authz/authz-policy-list.js.map +1 -1
  160. package/esm/cli/authz/authz-policy.js +1 -1
  161. package/esm/cli/authz/authz-policy.js.map +1 -1
  162. package/esm/cli/authz/authz-set-delete.js +11 -9
  163. package/esm/cli/authz/authz-set-delete.js.map +1 -1
  164. package/esm/cli/authz/authz-set-describe.js +8 -6
  165. package/esm/cli/authz/authz-set-describe.js.map +1 -1
  166. package/esm/cli/authz/authz-set-export.js +14 -12
  167. package/esm/cli/authz/authz-set-export.js.map +1 -1
  168. package/esm/cli/authz/authz-set-import.js +11 -9
  169. package/esm/cli/authz/authz-set-import.js.map +1 -1
  170. package/esm/cli/authz/authz-set-list.js +8 -6
  171. package/esm/cli/authz/authz-set-list.js.map +1 -1
  172. package/esm/cli/authz/authz-set.js +1 -1
  173. package/esm/cli/authz/authz-set.js.map +1 -1
  174. package/esm/cli/authz/authz-type-delete.js +13 -11
  175. package/esm/cli/authz/authz-type-delete.js.map +1 -1
  176. package/esm/cli/authz/authz-type-describe.js +9 -7
  177. package/esm/cli/authz/authz-type-describe.js.map +1 -1
  178. package/esm/cli/authz/authz-type-export.js +16 -14
  179. package/esm/cli/authz/authz-type-export.js.map +1 -1
  180. package/esm/cli/authz/authz-type-import.js +14 -12
  181. package/esm/cli/authz/authz-type-import.js.map +1 -1
  182. package/esm/cli/authz/authz-type-list.js +9 -7
  183. package/esm/cli/authz/authz-type-list.js.map +1 -1
  184. package/esm/cli/authz/authz-type.js +1 -1
  185. package/esm/cli/authz/authz-type.js.map +1 -1
  186. package/esm/cli/authz/authz.js +2 -2
  187. package/esm/cli/authz/authz.js.map +1 -1
  188. package/esm/cli/config/config-delete.js +21 -0
  189. package/esm/cli/config/config-delete.js.map +1 -0
  190. package/esm/cli/config/config-describe.js +21 -0
  191. package/esm/cli/config/config-describe.js.map +1 -0
  192. package/esm/cli/config/config-export.js +43 -0
  193. package/esm/cli/config/config-export.js.map +1 -0
  194. package/esm/cli/config/config-import.js +21 -0
  195. package/esm/cli/config/config-import.js.map +1 -0
  196. package/esm/cli/config/config-list.js +21 -0
  197. package/esm/cli/config/config-list.js.map +1 -0
  198. package/esm/cli/config/config.js +20 -0
  199. package/esm/cli/config/config.js.map +1 -0
  200. package/esm/cli/conn/conn-delete.js +2 -3
  201. package/esm/cli/conn/conn-delete.js.map +1 -1
  202. package/esm/cli/conn/conn-describe.js +2 -3
  203. package/esm/cli/conn/conn-describe.js.map +1 -1
  204. package/esm/cli/conn/conn-list.js +2 -3
  205. package/esm/cli/conn/conn-list.js.map +1 -1
  206. package/esm/cli/conn/conn-save.js +31 -16
  207. package/esm/cli/conn/conn-save.js.map +1 -1
  208. package/esm/cli/conn/conn.js +2 -2
  209. package/esm/cli/conn/conn.js.map +1 -1
  210. package/esm/cli/email/email-template-export.js +14 -12
  211. package/esm/cli/email/email-template-export.js.map +1 -1
  212. package/esm/cli/email/email-template-import.js +15 -13
  213. package/esm/cli/email/email-template-import.js.map +1 -1
  214. package/esm/cli/email/email-template-list.js +9 -7
  215. package/esm/cli/email/email-template-list.js.map +1 -1
  216. package/esm/cli/email/email-template.js +1 -1
  217. package/esm/cli/email/email-template.js.map +1 -1
  218. package/esm/cli/email/email.js +2 -2
  219. package/esm/cli/email/email.js.map +1 -1
  220. package/esm/cli/esv/esv-apply.js +18 -9
  221. package/esm/cli/esv/esv-apply.js.map +1 -1
  222. package/esm/cli/esv/esv-secret-create.js +10 -7
  223. package/esm/cli/esv/esv-secret-create.js.map +1 -1
  224. package/esm/cli/esv/esv-secret-delete.js +13 -10
  225. package/esm/cli/esv/esv-secret-delete.js.map +1 -1
  226. package/esm/cli/esv/esv-secret-describe.js +10 -7
  227. package/esm/cli/esv/esv-secret-describe.js.map +1 -1
  228. package/esm/cli/esv/esv-secret-export.js +22 -7
  229. package/esm/cli/esv/esv-secret-export.js.map +1 -1
  230. package/esm/cli/esv/esv-secret-import.js +7 -5
  231. package/esm/cli/esv/esv-secret-import.js.map +1 -1
  232. package/esm/cli/esv/esv-secret-list.js +11 -8
  233. package/esm/cli/esv/esv-secret-list.js.map +1 -1
  234. package/esm/cli/esv/esv-secret-set.js +10 -7
  235. package/esm/cli/esv/esv-secret-set.js.map +1 -1
  236. package/esm/cli/esv/esv-secret-version-activate.js +10 -8
  237. package/esm/cli/esv/esv-secret-version-activate.js.map +1 -1
  238. package/esm/cli/esv/esv-secret-version-create.js +10 -7
  239. package/esm/cli/esv/esv-secret-version-create.js.map +1 -1
  240. package/esm/cli/esv/esv-secret-version-deactivate.js +10 -8
  241. package/esm/cli/esv/esv-secret-version-deactivate.js.map +1 -1
  242. package/esm/cli/esv/esv-secret-version-delete.js +13 -10
  243. package/esm/cli/esv/esv-secret-version-delete.js.map +1 -1
  244. package/esm/cli/esv/esv-secret-version-list.js +10 -7
  245. package/esm/cli/esv/esv-secret-version-list.js.map +1 -1
  246. package/esm/cli/esv/esv-secret-version.js +1 -1
  247. package/esm/cli/esv/esv-secret-version.js.map +1 -1
  248. package/esm/cli/esv/esv-secret.js +2 -3
  249. package/esm/cli/esv/esv-secret.js.map +1 -1
  250. package/esm/cli/esv/esv-variable-create.js +11 -7
  251. package/esm/cli/esv/esv-variable-create.js.map +1 -1
  252. package/esm/cli/esv/esv-variable-delete.js +13 -9
  253. package/esm/cli/esv/esv-variable-delete.js.map +1 -1
  254. package/esm/cli/esv/esv-variable-describe.js +11 -8
  255. package/esm/cli/esv/esv-variable-describe.js.map +1 -1
  256. package/esm/cli/esv/esv-variable-export.js +23 -7
  257. package/esm/cli/esv/esv-variable-export.js.map +1 -1
  258. package/esm/cli/esv/esv-variable-import.js +7 -5
  259. package/esm/cli/esv/esv-variable-import.js.map +1 -1
  260. package/esm/cli/esv/esv-variable-list.js +11 -8
  261. package/esm/cli/esv/esv-variable-list.js.map +1 -1
  262. package/esm/cli/esv/esv-variable-set.js +12 -8
  263. package/esm/cli/esv/esv-variable-set.js.map +1 -1
  264. package/esm/cli/esv/esv-variable.js +2 -3
  265. package/esm/cli/esv/esv-variable.js.map +1 -1
  266. package/esm/cli/esv/esv.js +2 -2
  267. package/esm/cli/esv/esv.js.map +1 -1
  268. package/esm/cli/idm/idm-count.js +10 -8
  269. package/esm/cli/idm/idm-count.js.map +1 -1
  270. package/esm/cli/idm/idm-export.js +24 -16
  271. package/esm/cli/idm/idm-export.js.map +1 -1
  272. package/esm/cli/idm/idm-import.js +22 -14
  273. package/esm/cli/idm/idm-import.js.map +1 -1
  274. package/esm/cli/idm/idm-list.js +9 -7
  275. package/esm/cli/idm/idm-list.js.map +1 -1
  276. package/esm/cli/idm/idm.js +2 -2
  277. package/esm/cli/idm/idm.js.map +1 -1
  278. package/esm/cli/idp/idp-export.js +12 -10
  279. package/esm/cli/idp/idp-export.js.map +1 -1
  280. package/esm/cli/idp/idp-import.js +15 -13
  281. package/esm/cli/idp/idp-import.js.map +1 -1
  282. package/esm/cli/idp/idp-list.js +8 -6
  283. package/esm/cli/idp/idp-list.js.map +1 -1
  284. package/esm/cli/idp/idp.js +2 -2
  285. package/esm/cli/idp/idp.js.map +1 -1
  286. package/esm/cli/info/info.js +13 -8
  287. package/esm/cli/info/info.js.map +1 -1
  288. package/esm/cli/journey/journey-delete.js +14 -8
  289. package/esm/cli/journey/journey-delete.js.map +1 -1
  290. package/esm/cli/journey/journey-describe.js +22 -12
  291. package/esm/cli/journey/journey-describe.js.map +1 -1
  292. package/esm/cli/journey/journey-disable.js +11 -12
  293. package/esm/cli/journey/journey-disable.js.map +1 -1
  294. package/esm/cli/journey/journey-enable.js +11 -12
  295. package/esm/cli/journey/journey-enable.js.map +1 -1
  296. package/esm/cli/journey/journey-export.js +24 -13
  297. package/esm/cli/journey/journey-export.js.map +1 -1
  298. package/esm/cli/journey/journey-import.js +15 -13
  299. package/esm/cli/journey/journey-import.js.map +1 -1
  300. package/esm/cli/journey/journey-list.js +7 -5
  301. package/esm/cli/journey/journey-list.js.map +1 -1
  302. package/esm/cli/journey/journey-prune.js +23 -13
  303. package/esm/cli/journey/journey-prune.js.map +1 -1
  304. package/esm/cli/journey/journey.js +2 -2
  305. package/esm/cli/journey/journey.js.map +1 -1
  306. package/esm/cli/{logging/logs-fetch.js → log/log-fetch.js} +68 -36
  307. package/esm/cli/log/log-fetch.js.map +1 -0
  308. package/esm/cli/log/log-key-delete.js +34 -0
  309. package/esm/cli/log/log-key-delete.js.map +1 -0
  310. package/esm/cli/log/log-key-describe.js +21 -0
  311. package/esm/cli/log/log-key-describe.js.map +1 -0
  312. package/esm/cli/log/log-key-list.js +25 -0
  313. package/esm/cli/log/log-key-list.js.map +1 -0
  314. package/esm/cli/log/log-key.js +8 -0
  315. package/esm/cli/log/log-key.js.map +1 -0
  316. package/esm/cli/log/log-list.js +80 -0
  317. package/esm/cli/log/log-list.js.map +1 -0
  318. package/esm/cli/log/log-tail.js +77 -0
  319. package/esm/cli/log/log-tail.js.map +1 -0
  320. package/esm/cli/{logging/logs.js → log/log.js} +6 -3
  321. package/esm/cli/log/log.js.map +1 -0
  322. package/esm/cli/oauth/oauth-client-delete.js +21 -0
  323. package/esm/cli/oauth/oauth-client-delete.js.map +1 -0
  324. package/esm/cli/oauth/oauth-client-describe.js +21 -0
  325. package/esm/cli/oauth/oauth-client-describe.js.map +1 -0
  326. package/esm/cli/oauth/oauth-client-export.js +51 -0
  327. package/esm/cli/oauth/oauth-client-export.js.map +1 -0
  328. package/esm/cli/oauth/oauth-client-import.js +56 -0
  329. package/esm/cli/oauth/oauth-client-import.js.map +1 -0
  330. package/esm/cli/oauth/oauth-client-list.js +24 -0
  331. package/esm/cli/oauth/oauth-client-list.js.map +1 -0
  332. package/esm/cli/oauth/oauth-client.js +14 -0
  333. package/esm/cli/oauth/oauth-client.js.map +1 -0
  334. package/esm/cli/oauth/oauth.js +13 -0
  335. package/esm/cli/oauth/oauth.js.map +1 -0
  336. package/esm/cli/realm/realm-add-custom-domain.js +8 -6
  337. package/esm/cli/realm/realm-add-custom-domain.js.map +1 -1
  338. package/esm/cli/realm/realm-describe.js +8 -6
  339. package/esm/cli/realm/realm-describe.js.map +1 -1
  340. package/esm/cli/realm/realm-list.js +8 -6
  341. package/esm/cli/realm/realm-list.js.map +1 -1
  342. package/esm/cli/realm/realm-remove-custom-domain.js +11 -6
  343. package/esm/cli/realm/realm-remove-custom-domain.js.map +1 -1
  344. package/esm/cli/realm/realm.js +2 -2
  345. package/esm/cli/realm/realm.js.map +1 -1
  346. package/esm/cli/saml/saml-cot-export.js +14 -12
  347. package/esm/cli/saml/saml-cot-export.js.map +1 -1
  348. package/esm/cli/saml/saml-cot-import.js +15 -13
  349. package/esm/cli/saml/saml-cot-import.js.map +1 -1
  350. package/esm/cli/saml/saml-cot-list.js +9 -7
  351. package/esm/cli/saml/saml-cot-list.js.map +1 -1
  352. package/esm/cli/saml/saml-cot.js +1 -1
  353. package/esm/cli/saml/saml-cot.js.map +1 -1
  354. package/esm/cli/saml/saml-delete.js +14 -8
  355. package/esm/cli/saml/saml-delete.js.map +1 -1
  356. package/esm/cli/saml/saml-describe.js +9 -7
  357. package/esm/cli/saml/saml-describe.js.map +1 -1
  358. package/esm/cli/saml/saml-export.js +14 -12
  359. package/esm/cli/saml/saml-export.js.map +1 -1
  360. package/esm/cli/saml/saml-import.js +15 -13
  361. package/esm/cli/saml/saml-import.js.map +1 -1
  362. package/esm/cli/saml/saml-list.js +9 -7
  363. package/esm/cli/saml/saml-list.js.map +1 -1
  364. package/esm/cli/saml/saml-metadata-export.js +10 -8
  365. package/esm/cli/saml/saml-metadata-export.js.map +1 -1
  366. package/esm/cli/saml/saml-metadata.js +1 -1
  367. package/esm/cli/saml/saml-metadata.js.map +1 -1
  368. package/esm/cli/saml/saml.js +2 -2
  369. package/esm/cli/saml/saml.js.map +1 -1
  370. package/esm/cli/script/script-delete.js +21 -8
  371. package/esm/cli/script/script-delete.js.map +1 -1
  372. package/esm/cli/script/script-describe.js +7 -5
  373. package/esm/cli/script/script-describe.js.map +1 -1
  374. package/esm/cli/script/script-export.js +12 -14
  375. package/esm/cli/script/script-export.js.map +1 -1
  376. package/esm/cli/script/script-import.js +9 -7
  377. package/esm/cli/script/script-import.js.map +1 -1
  378. package/esm/cli/script/script-list.js +10 -8
  379. package/esm/cli/script/script-list.js.map +1 -1
  380. package/esm/cli/script/script.js +3 -5
  381. package/esm/cli/script/script.js.map +1 -1
  382. package/esm/cli/service/service-delete.js +8 -5
  383. package/esm/cli/service/service-delete.js.map +1 -1
  384. package/esm/cli/service/service-export.js +13 -11
  385. package/esm/cli/service/service-export.js.map +1 -1
  386. package/esm/cli/service/service-import.js +11 -10
  387. package/esm/cli/service/service-import.js.map +1 -1
  388. package/esm/cli/service/service-list.js +7 -4
  389. package/esm/cli/service/service-list.js.map +1 -1
  390. package/esm/cli/service/service.js +2 -2
  391. package/esm/cli/service/service.js.map +1 -1
  392. package/esm/cli/shell/shell.js +57 -0
  393. package/esm/cli/shell/shell.js.map +1 -0
  394. package/esm/cli/theme/theme-delete.js +13 -11
  395. package/esm/cli/theme/theme-delete.js.map +1 -1
  396. package/esm/cli/theme/theme-export.js +16 -14
  397. package/esm/cli/theme/theme-export.js.map +1 -1
  398. package/esm/cli/theme/theme-import.js +16 -14
  399. package/esm/cli/theme/theme-import.js.map +1 -1
  400. package/esm/cli/theme/theme-list.js +8 -6
  401. package/esm/cli/theme/theme-list.js.map +1 -1
  402. package/esm/cli/theme/theme.js +2 -2
  403. package/esm/cli/theme/theme.js.map +1 -1
  404. package/esm/help/SampleData.js +7 -0
  405. package/esm/help/SampleData.js.map +1 -0
  406. package/esm/launch.js +1 -1
  407. package/esm/launch.js.map +1 -1
  408. package/esm/loader.js +2 -2
  409. package/esm/loader.js.map +1 -1
  410. package/esm/ops/AdminFederationOps.js +231 -0
  411. package/esm/ops/AdminFederationOps.js.map +1 -0
  412. package/esm/ops/AdminOps.js +151 -0
  413. package/esm/ops/AdminOps.js.map +1 -0
  414. package/esm/ops/AgentOps.js +213 -150
  415. package/esm/ops/AgentOps.js.map +1 -1
  416. package/esm/ops/ApplicationOps.js +324 -0
  417. package/esm/ops/ApplicationOps.js.map +1 -0
  418. package/esm/ops/AuthenticationSettingsOps.js +90 -0
  419. package/esm/ops/AuthenticationSettingsOps.js.map +1 -0
  420. package/esm/ops/CirclesOfTrustOps.js +98 -78
  421. package/esm/ops/CirclesOfTrustOps.js.map +1 -1
  422. package/esm/ops/ConfigOps.js +130 -0
  423. package/esm/ops/ConfigOps.js.map +1 -0
  424. package/esm/ops/ConnectionProfileOps.js +12 -6
  425. package/esm/ops/ConnectionProfileOps.js.map +1 -1
  426. package/esm/ops/EmailTemplateOps.js +125 -125
  427. package/esm/ops/EmailTemplateOps.js.map +1 -1
  428. package/esm/ops/IdmOps.js +72 -103
  429. package/esm/ops/IdmOps.js.map +1 -1
  430. package/esm/ops/IdpOps.js +106 -73
  431. package/esm/ops/IdpOps.js.map +1 -1
  432. package/esm/ops/JourneyOps.js +176 -114
  433. package/esm/ops/JourneyOps.js.map +1 -1
  434. package/esm/ops/LogOps.js +92 -30
  435. package/esm/ops/LogOps.js.map +1 -1
  436. package/esm/ops/NodeOps.js +6 -3
  437. package/esm/ops/NodeOps.js.map +1 -1
  438. package/esm/ops/OAuth2ClientOps.js +71 -49
  439. package/esm/ops/OAuth2ClientOps.js.map +1 -1
  440. package/esm/ops/OrganizationOps.js +14 -22
  441. package/esm/ops/OrganizationOps.js.map +1 -1
  442. package/esm/ops/PolicyOps.js +127 -86
  443. package/esm/ops/PolicyOps.js.map +1 -1
  444. package/esm/ops/PolicySetOps.js +108 -76
  445. package/esm/ops/PolicySetOps.js.map +1 -1
  446. package/esm/ops/RealmOps.js +18 -11
  447. package/esm/ops/RealmOps.js.map +1 -1
  448. package/esm/ops/ResourceTypeOps.js +105 -87
  449. package/esm/ops/ResourceTypeOps.js.map +1 -1
  450. package/esm/ops/Saml2Ops.js +116 -87
  451. package/esm/ops/Saml2Ops.js.map +1 -1
  452. package/esm/ops/Saml2Ops.test_.js.map +1 -1
  453. package/esm/ops/ScriptOps.js +205 -82
  454. package/esm/ops/ScriptOps.js.map +1 -1
  455. package/esm/ops/SecretsOps.js +289 -79
  456. package/esm/ops/SecretsOps.js.map +1 -1
  457. package/esm/ops/ServiceOps.js +71 -44
  458. package/esm/ops/ServiceOps.js.map +1 -1
  459. package/esm/ops/ThemeOps.js +160 -147
  460. package/esm/ops/ThemeOps.js.map +1 -1
  461. package/esm/ops/VariablesOps.js +252 -65
  462. package/esm/ops/VariablesOps.js.map +1 -1
  463. package/esm/ops/utils/OpsUtils.js +1 -1
  464. package/esm/ops/utils/OpsUtils.js.map +1 -1
  465. package/esm/ops/utils/Wordwrap.js +1 -1
  466. package/esm/ops/utils/Wordwrap.js.map +1 -1
  467. package/esm/storage/StaticStorage.js +1 -1
  468. package/esm/storage/StaticStorage.js.map +1 -1
  469. package/esm/utils/Config.js +153 -4
  470. package/esm/utils/Config.js.map +1 -1
  471. package/esm/utils/Console.js +78 -35
  472. package/esm/utils/Console.js.map +1 -1
  473. package/esm/utils/Version.js +19 -16
  474. package/esm/utils/Version.js.map +1 -1
  475. package/global-jest-setup.js +4 -0
  476. package/package.json +55 -37
  477. package/esm/cli/logging/logs-fetch.js.map +0 -1
  478. package/esm/cli/logging/logs-list.js +0 -49
  479. package/esm/cli/logging/logs-list.js.map +0 -1
  480. package/esm/cli/logging/logs-tail.js +0 -46
  481. package/esm/cli/logging/logs-tail.js.map +0 -1
  482. package/esm/cli/logging/logs.js.map +0 -1
  483. package/esm/cli/theme/theme-delete.e2e.test_.js.map +0 -1
  484. package/esm/cli/theme/theme-list.e2e.test_.js.map +0 -1
  485. package/esm/utils/ExportImportUtils.js +0 -90
  486. package/esm/utils/ExportImportUtils.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigOps.js","names":["frodo","state","fs","fse","printMessage","extractScriptToFile","getRealmName","getTypedFilename","titleCase","saveJsonToFile","getFilePath","getWorkingDirectory","utils","exportFullConfiguration","config","stringify","json","exportEverythingToFile","file","includeMeta","options","useStringArrays","noDecode","exportData","fileName","getRealm","exportEverythingToFiles","extract","meta","baseDirectory","Object","entries","forEach","type","obj","existsSync","mkdirSync","samlData","saml","cot","hosted","metadata","remote","id","value","concat","filename","entityId","samlType","authentication","includes","slice","lastIndexOf","recursive","outputFile","err","name"],"sources":["../../src/ops/ConfigOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport {\n FullExportInterface,\n FullExportOptions,\n} from '@rockcarver/frodo-lib/types/ops/ConfigOps';\nimport { ScriptExportInterface } from '@rockcarver/frodo-lib/types/ops/ScriptOps';\nimport fs from 'fs';\nimport fse from 'fs-extra';\n\nimport { printMessage } from '../utils/Console';\nimport { extractScriptToFile } from './ScriptOps';\n\nconst {\n getRealmName,\n getTypedFilename,\n titleCase,\n saveJsonToFile,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst { exportFullConfiguration } = frodo.config;\nconst { stringify } = frodo.utils.json;\n\n/**\n * Export everything to separate files\n * @param file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {FullExportOptions} options export options\n */\nexport async function exportEverythingToFile(\n file,\n includeMeta = true,\n options: FullExportOptions = {\n useStringArrays: true,\n noDecode: false,\n }\n): Promise<void> {\n const exportData = await exportFullConfiguration(options);\n let fileName = getTypedFilename(\n `${titleCase(getRealmName(state.getRealm()))}`,\n `everything`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);\n}\n\n/**\n * Export everything to separate files\n * @param extract Extracts the scripts from the exports into separate files if true\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n * @param {FullExportOptions} options export options\n */\nexport async function exportEverythingToFiles(\n extract = false,\n includeMeta = true,\n options: FullExportOptions = {\n useStringArrays: true,\n noDecode: false,\n }\n): Promise<void> {\n const exportData: FullExportInterface =\n await exportFullConfiguration(options);\n delete exportData.meta;\n const baseDirectory = getWorkingDirectory(true);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(exportData).forEach(([type, obj]: [string, any]) => {\n if (obj) {\n if (!fs.existsSync(`${baseDirectory}/${type}`)) {\n fs.mkdirSync(`${baseDirectory}/${type}`);\n }\n if (type == 'saml') {\n const samlData = {\n saml: {\n cot: {},\n hosted: {},\n metadata: {},\n remote: {},\n },\n };\n if (obj.cot) {\n if (!fs.existsSync(`${baseDirectory}/cot`)) {\n fs.mkdirSync(`${baseDirectory}/cot`);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(obj.cot).forEach(([id, value]: [string, any]) => {\n samlData.saml.cot = {\n [id]: value,\n };\n saveJsonToFile(\n samlData,\n `${baseDirectory}/cot/${getTypedFilename(id, 'cot.saml')}`,\n includeMeta\n );\n });\n samlData.saml.cot = {};\n }\n Object.entries(obj.hosted)\n .concat(Object.entries(obj.remote))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .forEach(([id, value]: [string, any]) => {\n const filename = getTypedFilename(\n value.entityId ? value.entityId : id,\n type\n );\n const samlType = obj.hosted[id] ? 'hosted' : 'remote';\n samlData.saml[samlType][id] = value;\n samlData.saml.metadata = {\n [id]: obj.metadata[id],\n };\n saveJsonToFile(\n samlData,\n `${baseDirectory}/${type}/${filename}`,\n includeMeta\n );\n samlData.saml[samlType] = {};\n });\n } else if (type == 'authentication') {\n const fileName = getTypedFilename(\n `${frodo.utils.getRealmName(state.getRealm())}Realm`,\n 'authentication.settings'\n );\n saveJsonToFile(\n {\n authentication: obj,\n },\n `${baseDirectory}/${type}/${fileName}`,\n includeMeta\n );\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Object.entries(obj).forEach(([id, value]: [string, any]) => {\n if (type == 'config') {\n if (value != null) {\n const filename = `${id}.json`;\n if (filename.includes('/')) {\n fs.mkdirSync(\n `${baseDirectory}/${type}/${filename.slice(\n 0,\n filename.lastIndexOf('/')\n )}`,\n {\n recursive: true,\n }\n );\n }\n fse.outputFile(\n `${baseDirectory}/${type}/${filename}`,\n stringify(value),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n } else {\n const filename = getTypedFilename(\n value && value.name ? value.name : id,\n type\n );\n if (extract && type == 'script') {\n extractScriptToFile(\n exportData as ScriptExportInterface,\n id,\n type\n );\n }\n saveJsonToFile(\n {\n [type]: {\n [id]: value,\n },\n },\n `${baseDirectory}/${type}/${filename}`,\n includeMeta\n );\n }\n });\n }\n }\n });\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAMpD,OAAOC,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IG,QAAQ,CAACI,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAC1BhD,EAAE,CAACkC,SAAS,CACT,GAAEP,aAAc,IAAGI,IAAK,IAAGa,QAAQ,CAACK,KAAK,CACxC,CAAC,EACDL,QAAQ,CAACM,WAAW,CAAC,GAAG,CAC1B,CAAE,EAAC,EACH;kBACEC,SAAS,EAAE;gBACb,CACF,CAAC;cACH;cACAlD,GAAG,CAACmD,UAAU,CACX,GAAEzB,aAAc,IAAGI,IAAK,IAAGa,QAAS,EAAC,EACtC/B,SAAS,CAAC6B,KAAK,CAAC,EACfW,GAAG,IAAK;gBACP,IAAIA,GAAG,EAAE;kBACP,OAAOnD,YAAY,CAChB,6BAA4BuC,EAAG,cAAaY,GAAI,EAAC,EAClD,OACF,CAAC;gBACH;cACF,CACF,CAAC;YACH;UACF,CAAC,MAAM;YACL,MAAMT,QAAQ,GAAGvC,gBAAgB,CAC/BqC,KAAK,IAAIA,KAAK,CAACY,IAAI,GAAGZ,KAAK,CAACY,IAAI,GAAGb,EAAE,EACrCV,IACF,CAAC;YACD,IAAIN,OAAO,IAAIM,IAAI,IAAI,QAAQ,EAAE;cAC/B5B,mBAAmB,CACjBkB,UAAU,EACVoB,EAAE,EACFV,IACF,CAAC;YACH;YACAxB,cAAc,CACZ;cACE,CAACwB,IAAI,GAAG;gBACN,CAACU,EAAE,GAAGC;cACR;YACF,CAAC,EACA,GAAEf,aAAc,IAAGI,IAAK,IAAGa,QAAS,EAAC,EACtC3B,WACF,CAAC;UACH;QACF,CAAC,CAAC;MACJ;IACF;EACF,CAAC,CAAC;AACJ"}
@@ -1,6 +1,13 @@
1
- import fs from 'fs';
2
1
  import { frodo, state } from '@rockcarver/frodo-lib';
2
+ import fs from 'fs';
3
3
  import { createObjectTable, createTable, debugMessage, failSpinner, printMessage, showSpinner, succeedSpinner } from '../utils/Console';
4
+ const {
5
+ getAccessTokenForServiceAccount
6
+ } = frodo.login;
7
+ const {
8
+ getConnectionProfilesPath,
9
+ getConnectionProfileByHost
10
+ } = frodo.conn;
4
11
 
5
12
  /**
6
13
  * List connection profiles
@@ -8,7 +15,7 @@ import { createObjectTable, createTable, debugMessage, failSpinner, printMessage
8
15
  * @param {State} state library state
9
16
  */
10
17
  export function listConnectionProfiles(long = false) {
11
- const filename = frodo.conn.getConnectionProfilesPath();
18
+ const filename = getConnectionProfilesPath();
12
19
  try {
13
20
  const data = fs.readFileSync(filename, 'utf8');
14
21
  const connectionsData = JSON.parse(data);
@@ -27,7 +34,6 @@ export function listConnectionProfiles(long = false) {
27
34
  });
28
35
  // getUniqueNames(5, Object.keys(connectionsData));
29
36
  }
30
-
31
37
  printMessage('Any unique substring of a saved host can be used as the value for host parameter in all commands', 'info');
32
38
  }
33
39
  } catch (e) {
@@ -42,7 +48,7 @@ export function listConnectionProfiles(long = false) {
42
48
  */
43
49
  export async function describeConnectionProfile(host, showSecrets) {
44
50
  debugMessage(`ConnectionProfileOps.describeConnectionProfile: start`);
45
- const profile = await frodo.conn.getConnectionProfileByHost(host);
51
+ const profile = await getConnectionProfileByHost(host);
46
52
  if (profile) {
47
53
  debugMessage(profile);
48
54
  const present = '[present]';
@@ -99,7 +105,7 @@ export async function addExistingServiceAccount(serviceAccountId, privateKeyFile
99
105
  const jwk = JSON.parse(data.toString());
100
106
  if (validate) {
101
107
  showSpinner(`Validating service account ${serviceAccountId}...`);
102
- const token = await frodo.login.getAccessTokenForServiceAccount(serviceAccountId, jwk);
108
+ const token = await getAccessTokenForServiceAccount(serviceAccountId, jwk);
103
109
  if (token === null) {
104
110
  failSpinner(`Failed to validate service account ${serviceAccountId}.`);
105
111
  return false;
@@ -115,4 +121,4 @@ export async function addExistingServiceAccount(serviceAccountId, privateKeyFile
115
121
  }
116
122
  return false;
117
123
  }
118
- //# sourceMappingURL=ConnectionProfileOps.js.map
124
+ //# sourceMappingURL=ConnectionProfileOps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionProfileOps.js","names":["fs","frodo","state","createObjectTable","createTable","debugMessage","failSpinner","printMessage","showSpinner","succeedSpinner","listConnectionProfiles","long","filename","conn","getConnectionProfilesPath","data","readFileSync","connectionsData","JSON","parse","Object","keys","length","table","forEach","c","push","svcacctName","svcacctId","username","logApiKey","toString","e","message","describeConnectionProfile","host","showSecrets","profile","getConnectionProfileByHost","present","jwk","svcacctJwk","password","logApiSecret","authenticationService","keyMap","tenant","authenticationHeaderOverrides","stringify","addExistingServiceAccount","serviceAccountId","privateKeyFile","validate","token","login","getAccessTokenForServiceAccount","setServiceAccountId","setServiceAccountJwk","err"],"sources":["ops/ConnectionProfileOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { frodo, state } from '@rockcarver/frodo-lib';\nimport {\n createObjectTable,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n succeedSpinner,\n} from '../utils/Console';\n\n/**\n * List connection profiles\n * @param {boolean} long Long list format with details\n * @param {State} state library state\n */\nexport function listConnectionProfiles(long = false) {\n const filename = frodo.conn.getConnectionProfilesPath();\n try {\n const data = fs.readFileSync(filename, 'utf8');\n const connectionsData = JSON.parse(data);\n if (Object.keys(connectionsData).length < 1) {\n printMessage(`No connections defined yet in ${filename}`, 'info');\n } else {\n if (long) {\n const table = createTable([\n 'Host',\n 'Service Account',\n 'Username',\n 'Log API Key',\n ]);\n Object.keys(connectionsData).forEach((c) => {\n table.push([\n c,\n connectionsData[c].svcacctName || connectionsData[c].svcacctId,\n connectionsData[c].username,\n connectionsData[c].logApiKey,\n ]);\n });\n printMessage(table.toString(), 'data');\n } else {\n Object.keys(connectionsData).forEach((c) => {\n printMessage(`${c}`, 'data');\n });\n // getUniqueNames(5, Object.keys(connectionsData));\n }\n printMessage(\n 'Any unique substring of a saved host can be used as the value for host parameter in all commands',\n 'info'\n );\n }\n } catch (e) {\n printMessage(`No connections found in ${filename} (${e.message})`, 'error');\n }\n}\n\n/**\n * Describe connection profile\n * @param {string} host Host URL or unique substring\n * @param {boolean} showSecrets Whether secrets should be shown in clear text or not\n */\nexport async function describeConnectionProfile(\n host: string,\n showSecrets: boolean\n) {\n debugMessage(`ConnectionProfileOps.describeConnectionProfile: start`);\n const profile = await frodo.conn.getConnectionProfileByHost(host);\n if (profile) {\n debugMessage(profile);\n const present = '[present]';\n const jwk = profile.svcacctJwk;\n if (!showSecrets) {\n if (profile.password) profile.password = present;\n if (profile.logApiSecret) profile.logApiSecret = present;\n if (profile.svcacctJwk) (profile as unknown)['svcacctJwk'] = present;\n }\n if (!profile.username) {\n delete profile.username;\n delete profile.password;\n }\n if (!profile.logApiKey) {\n delete profile.logApiKey;\n delete profile.logApiSecret;\n }\n if (!profile.svcacctId) {\n delete profile.svcacctId;\n delete profile.svcacctJwk;\n delete profile.svcacctName;\n }\n if (showSecrets && jwk) {\n (profile as unknown)['svcacctJwk'] = 'see below';\n }\n if (!profile.authenticationService) {\n delete profile.authenticationService;\n }\n const keyMap = {\n tenant: 'Host',\n username: 'Username',\n password: 'Password',\n logApiKey: 'Log API Key',\n logApiSecret: 'Log API Secret',\n authenticationService: 'Authentication Service',\n authenticationHeaderOverrides: 'Authentication Header Overrides',\n svcacctName: 'Service Account Name',\n svcacctId: 'Service Account Id',\n svcacctJwk: 'Service Account JWK',\n };\n const table = createObjectTable(profile, keyMap);\n printMessage(table.toString(), 'data');\n if (showSecrets && jwk) {\n printMessage(JSON.stringify(jwk), 'data');\n }\n } else {\n printMessage(`No connection profile ${host} found`);\n }\n debugMessage(`ConnectionProfileOps.describeConnectionProfile: end`);\n}\n\nexport async function addExistingServiceAccount(\n serviceAccountId: string,\n privateKeyFile: string,\n validate: boolean\n): Promise<boolean> {\n try {\n const data = fs.readFileSync(privateKeyFile);\n const jwk = JSON.parse(data.toString());\n if (validate) {\n showSpinner(`Validating service account ${serviceAccountId}...`);\n const token = await frodo.login.getAccessTokenForServiceAccount(\n serviceAccountId,\n jwk\n );\n if (token === null) {\n failSpinner(`Failed to validate service account ${serviceAccountId}.`);\n return false;\n } else {\n succeedSpinner(\n `Successfully validated service account ${serviceAccountId}.`\n );\n }\n }\n state.setServiceAccountId(serviceAccountId);\n state.setServiceAccountJwk(jwk);\n return true;\n } catch (err) {\n failSpinner(\n `Failed to validate service account ${serviceAccountId}: ${err}.`\n );\n }\n return false;\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,SAASC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SACEC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,cAAc,QACT,kBAAkB;;AAEzB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAACC,IAAI,GAAG,KAAK,EAAE;EACnD,MAAMC,QAAQ,GAAGX,KAAK,CAACY,IAAI,CAACC,yBAAyB,CAAC,CAAC;EACvD,IAAI;IACF,MAAMC,IAAI,GAAGf,EAAE,CAACgB,YAAY,CAACJ,QAAQ,EAAE,MAAM,CAAC;IAC9C,MAAMK,eAAe,GAAGC,IAAI,CAACC,KAAK,CAACJ,IAAI,CAAC;IACxC,IAAIK,MAAM,CAACC,IAAI,CAACJ,eAAe,CAAC,CAACK,MAAM,GAAG,CAAC,EAAE;MAC3Cf,YAAY,CAAE,iCAAgCK,QAAS,EAAC,EAAE,MAAM,CAAC;IACnE,CAAC,MAAM;MACL,IAAID,IAAI,EAAE;QACR,MAAMY,KAAK,GAAGnB,WAAW,CAAC,CACxB,MAAM,EACN,iBAAiB,EACjB,UAAU,EACV,aAAa,CACd,CAAC;QACFgB,MAAM,CAACC,IAAI,CAACJ,eAAe,CAAC,CAACO,OAAO,CAAEC,CAAC,IAAK;UAC1CF,KAAK,CAACG,IAAI,CAAC,CACTD,CAAC,EACDR,eAAe,CAACQ,CAAC,CAAC,CAACE,WAAW,IAAIV,eAAe,CAACQ,CAAC,CAAC,CAACG,SAAS,EAC9DX,eAAe,CAACQ,CAAC,CAAC,CAACI,QAAQ,EAC3BZ,eAAe,CAACQ,CAAC,CAAC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,MAAMX,GAAG,GAAGtB,IAAI,CAACC,KAAK,CAACJ,IAAI,CAACgB,QAAQ,CAAC,CAAC,CAAC;IACvC,IAAIqB,QAAQ,EAAE;MACZ5C,WAAW,CAAE,8BAA6B0C,gBAAiB,KAAI,CAAC;MAChE,MAAMG,KAAK,GAAG,MAAMpD,KAAK,CAACqD,KAAK,CAACC,+BAA+B,CAC7DL,gBAAgB,EAChBV,GACF,CAAC;MACD,IAAIa,KAAK,KAAK,IAAI,EAAE;QAClB/C,WAAW,CAAE,sCAAqC4C,gBAAiB,GAAE,CAAC;QACtE,OAAO,KAAK;MACd,CAAC,MAAM;QACLzC,cAAc,CACX,0CAAyCyC,gBAAiB,GAC7D,CAAC;MACH;IACF;IACAhD,KAAK,CAACsD,mBAAmB,CAACN,gBAAgB,CAAC;IAC3ChD,KAAK,CAACuD,oBAAoB,CAACjB,GAAG,CAAC;IAC/B,OAAO,IAAI;EACb,CAAC,CAAC,OAAOkB,GAAG,EAAE;IACZpD,WAAW,CACR,sCAAqC4C,gBAAiB,KAAIQ,GAAI,GACjE,CAAC;EACH;EACA,OAAO,KAAK;AACd"}
1
+ {"version":3,"file":"ConnectionProfileOps.js","names":["frodo","state","fs","createObjectTable","createTable","debugMessage","failSpinner","printMessage","showSpinner","succeedSpinner","getAccessTokenForServiceAccount","login","getConnectionProfilesPath","getConnectionProfileByHost","conn","listConnectionProfiles","long","filename","data","readFileSync","connectionsData","JSON","parse","Object","keys","length","table","forEach","c","push","svcacctName","svcacctId","username","logApiKey","toString","e","message","describeConnectionProfile","host","showSecrets","profile","present","jwk","svcacctJwk","password","logApiSecret","authenticationService","keyMap","tenant","authenticationHeaderOverrides","stringify","addExistingServiceAccount","serviceAccountId","privateKeyFile","validate","token","setServiceAccountId","setServiceAccountJwk","err"],"sources":["../../src/ops/ConnectionProfileOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\n\nimport {\n createObjectTable,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n succeedSpinner,\n} from '../utils/Console';\n\nconst { getAccessTokenForServiceAccount } = frodo.login;\nconst { getConnectionProfilesPath, getConnectionProfileByHost } = frodo.conn;\n\n/**\n * List connection profiles\n * @param {boolean} long Long list format with details\n * @param {State} state library state\n */\nexport function listConnectionProfiles(long = false) {\n const filename = getConnectionProfilesPath();\n try {\n const data = fs.readFileSync(filename, 'utf8');\n const connectionsData = JSON.parse(data);\n if (Object.keys(connectionsData).length < 1) {\n printMessage(`No connections defined yet in ${filename}`, 'info');\n } else {\n if (long) {\n const table = createTable([\n 'Host',\n 'Service Account',\n 'Username',\n 'Log API Key',\n ]);\n Object.keys(connectionsData).forEach((c) => {\n table.push([\n c,\n connectionsData[c].svcacctName || connectionsData[c].svcacctId,\n connectionsData[c].username,\n connectionsData[c].logApiKey,\n ]);\n });\n printMessage(table.toString(), 'data');\n } else {\n Object.keys(connectionsData).forEach((c) => {\n printMessage(`${c}`, 'data');\n });\n // getUniqueNames(5, Object.keys(connectionsData));\n }\n printMessage(\n 'Any unique substring of a saved host can be used as the value for host parameter in all commands',\n 'info'\n );\n }\n } catch (e) {\n printMessage(`No connections found in ${filename} (${e.message})`, 'error');\n }\n}\n\n/**\n * Describe connection profile\n * @param {string} host Host URL or unique substring\n * @param {boolean} showSecrets Whether secrets should be shown in clear text or not\n */\nexport async function describeConnectionProfile(\n host: string,\n showSecrets: boolean\n) {\n debugMessage(`ConnectionProfileOps.describeConnectionProfile: start`);\n const profile = await getConnectionProfileByHost(host);\n if (profile) {\n debugMessage(profile);\n const present = '[present]';\n const jwk = profile.svcacctJwk;\n if (!showSecrets) {\n if (profile.password) profile.password = present;\n if (profile.logApiSecret) profile.logApiSecret = present;\n if (profile.svcacctJwk) (profile as unknown)['svcacctJwk'] = present;\n }\n if (!profile.username) {\n delete profile.username;\n delete profile.password;\n }\n if (!profile.logApiKey) {\n delete profile.logApiKey;\n delete profile.logApiSecret;\n }\n if (!profile.svcacctId) {\n delete profile.svcacctId;\n delete profile.svcacctJwk;\n delete profile.svcacctName;\n }\n if (showSecrets && jwk) {\n (profile as unknown)['svcacctJwk'] = 'see below';\n }\n if (!profile.authenticationService) {\n delete profile.authenticationService;\n }\n const keyMap = {\n tenant: 'Host',\n username: 'Username',\n password: 'Password',\n logApiKey: 'Log API Key',\n logApiSecret: 'Log API Secret',\n authenticationService: 'Authentication Service',\n authenticationHeaderOverrides: 'Authentication Header Overrides',\n svcacctName: 'Service Account Name',\n svcacctId: 'Service Account Id',\n svcacctJwk: 'Service Account JWK',\n };\n const table = createObjectTable(profile, keyMap);\n printMessage(table.toString(), 'data');\n if (showSecrets && jwk) {\n printMessage(JSON.stringify(jwk), 'data');\n }\n } else {\n printMessage(`No connection profile ${host} found`);\n }\n debugMessage(`ConnectionProfileOps.describeConnectionProfile: end`);\n}\n\nexport async function addExistingServiceAccount(\n serviceAccountId: string,\n privateKeyFile: string,\n validate: boolean\n): Promise<boolean> {\n try {\n const data = fs.readFileSync(privateKeyFile);\n const jwk = JSON.parse(data.toString());\n if (validate) {\n showSpinner(`Validating service account ${serviceAccountId}...`);\n const token = await getAccessTokenForServiceAccount(\n serviceAccountId,\n jwk\n );\n if (token === null) {\n failSpinner(`Failed to validate service account ${serviceAccountId}.`);\n return false;\n } else {\n succeedSpinner(\n `Successfully validated service account ${serviceAccountId}.`\n );\n }\n }\n state.setServiceAccountId(serviceAccountId);\n state.setServiceAccountJwk(jwk);\n return true;\n } catch (err) {\n failSpinner(\n `Failed to validate service account ${serviceAccountId}: ${err}.`\n );\n }\n return false;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,cAAc,QACT,kBAAkB;AAEzB,MAAM;EAAEC;AAAgC,CAAC,GAAGV,KAAK,CAACW,KAAK;A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QACtE,OAAO,KAAK;MACd,CAAC,MAAM;QACL3C,cAAc,CACX,0CAAyC2C,gBAAiB,GAC7D,CAAC;MACH;IACF;IACAnD,KAAK,CAACuD,mBAAmB,CAACJ,gBAAgB,CAAC;IAC3CnD,KAAK,CAACwD,oBAAoB,CAACf,GAAG,CAAC;IAC/B,OAAO,IAAI;EACb,CAAC,CAAC,OAAOgB,GAAG,EAAE;IACZpD,WAAW,CACR,sCAAqC8C,gBAAiB,KAAIM,GAAI,GACjE,CAAC;EACH;EACA,OAAO,KAAK;AACd"}
@@ -1,11 +1,23 @@
1
1
  import { frodo } from '@rockcarver/frodo-lib';
2
2
  import fs from 'fs';
3
- import { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
4
- import { createProgressIndicator, updateProgressIndicator, stopProgressIndicator, printMessage, createTable, showSpinner, succeedSpinner, failSpinner, debugMessage } from '../utils/Console';
5
- import wordwrap from './utils/Wordwrap';
6
3
  import path from 'path';
4
+ import { createProgressIndicator, createTable, debugMessage, printMessage, stopProgressIndicator, updateProgressIndicator } from '../utils/Console';
7
5
  import { cloneDeep } from './utils/OpsUtils';
8
- const EMAIL_TEMPLATE_TYPE = frodo.email.template.EMAIL_TEMPLATE_TYPE;
6
+ import wordwrap from './utils/Wordwrap';
7
+ const {
8
+ validateImport,
9
+ getTypedFilename,
10
+ saveJsonToFile,
11
+ getFilePath,
12
+ getWorkingDirectory
13
+ } = frodo.utils;
14
+ const {
15
+ EMAIL_TEMPLATE_TYPE,
16
+ readEmailTemplates,
17
+ readEmailTemplate,
18
+ exportEmailTemplates,
19
+ updateEmailTemplate
20
+ } = frodo.email.template;
9
21
  const EMAIL_TEMPLATE_FILE_TYPE = 'template.email';
10
22
  const regexEmailTemplateType = new RegExp(`${EMAIL_TEMPLATE_TYPE}/`, 'g');
11
23
 
@@ -58,7 +70,7 @@ export function getTableRowMd(templateObj) {
58
70
  export async function listEmailTemplates(long = false) {
59
71
  let emailTemplates = [];
60
72
  try {
61
- emailTemplates = (await frodo.email.template.getEmailTemplates()).result;
73
+ emailTemplates = await readEmailTemplates();
62
74
  } catch (error) {
63
75
  printMessage(`Error retrieving email templates: ${error.message}`, 'error');
64
76
  }
@@ -93,22 +105,24 @@ export async function listEmailTemplates(long = false) {
93
105
  * Export single email template to a file
94
106
  * @param {string} templateId email template id to export
95
107
  * @param {string} file filename where to export the template data
108
+ * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
96
109
  */
97
- export async function exportEmailTemplateToFile(templateId, file) {
110
+ export async function exportEmailTemplateToFile(templateId, file, includeMeta = true) {
98
111
  let fileName = file;
99
112
  if (!fileName) {
100
113
  fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);
101
114
  }
102
- createProgressIndicator('determinate', 1, `Exporting ${templateId}`);
115
+ const filePath = getFilePath(fileName, true);
116
+ const indicatorId = createProgressIndicator('determinate', 1, `Exporting ${templateId}`);
103
117
  try {
104
- const templateData = await frodo.email.template.getEmailTemplate(templateId);
105
- updateProgressIndicator(`Writing file ${fileName}`);
118
+ const templateData = await readEmailTemplate(templateId);
119
+ updateProgressIndicator(indicatorId, `Writing file ${filePath}`);
106
120
  const fileData = getFileDataTemplate();
107
121
  fileData.emailTemplate[templateId] = templateData;
108
- saveJsonToFile(fileData, fileName);
109
- stopProgressIndicator(`Exported ${templateId['brightCyan']} to ${fileName['brightCyan']}.`);
122
+ saveJsonToFile(fileData, filePath, includeMeta);
123
+ stopProgressIndicator(indicatorId, `Exported ${templateId['brightCyan']} to ${filePath['brightCyan']}.`);
110
124
  } catch (err) {
111
- stopProgressIndicator(`${err}`);
125
+ stopProgressIndicator(indicatorId, `${err}`);
112
126
  printMessage(err, 'error');
113
127
  }
114
128
  }
@@ -116,49 +130,41 @@ export async function exportEmailTemplateToFile(templateId, file) {
116
130
  /**
117
131
  * Export all email templates to file
118
132
  * @param {String} file optional filename
133
+ * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
119
134
  */
120
- export async function exportEmailTemplatesToFile(file) {
135
+ export async function exportEmailTemplatesToFile(file, includeMeta = true) {
121
136
  let fileName = file;
122
137
  if (!fileName) {
123
138
  fileName = getTypedFilename(`allEmailTemplates`, EMAIL_TEMPLATE_FILE_TYPE);
124
139
  }
140
+ const filePath = getFilePath(fileName, true);
125
141
  try {
126
- const fileData = getFileDataTemplate();
127
- const response = await frodo.email.template.getEmailTemplates();
128
- const templates = response.result;
129
- createProgressIndicator('determinate', response.resultCount, 'Exporting email templates');
130
- for (const template of templates) {
131
- const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');
132
- updateProgressIndicator(`Exporting ${templateId}`);
133
- fileData.emailTemplate[templateId] = template;
134
- }
135
- saveJsonToFile(fileData, fileName);
136
- stopProgressIndicator(`${response.resultCount} templates exported to ${fileName}.`);
142
+ const exportData = await exportEmailTemplates();
143
+ saveJsonToFile(exportData, filePath, includeMeta);
137
144
  } catch (err) {
138
- stopProgressIndicator(`${err}`);
139
145
  printMessage(err, 'error');
140
146
  }
141
147
  }
142
148
 
143
149
  /**
144
150
  * Export all email templates to separate files
151
+ * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
145
152
  */
146
- export async function exportEmailTemplatesToFiles() {
153
+ export async function exportEmailTemplatesToFiles(includeMeta = true) {
154
+ let indicatorId;
147
155
  try {
148
- const response = await frodo.email.template.getEmailTemplates();
149
- const templates = response.result;
150
- createProgressIndicator('determinate', response.resultCount, 'Exporting email templates');
151
- for (const template of templates) {
152
- const templateId = template._id.replace(`${EMAIL_TEMPLATE_TYPE}/`, '');
156
+ const exportData = Object.entries((await exportEmailTemplates()).emailTemplate);
157
+ indicatorId = createProgressIndicator('determinate', exportData.length, 'Writing email templates');
158
+ for (const [templateId, template] of exportData) {
153
159
  const fileName = getTypedFilename(templateId, EMAIL_TEMPLATE_FILE_TYPE);
154
160
  const fileData = getFileDataTemplate();
155
- updateProgressIndicator(`Exporting ${templateId}`);
161
+ updateProgressIndicator(indicatorId, `Exporting ${templateId}`);
156
162
  fileData.emailTemplate[templateId] = template;
157
- saveJsonToFile(fileData, fileName);
163
+ saveJsonToFile(fileData, getFilePath(fileName, true), includeMeta);
158
164
  }
159
- stopProgressIndicator(`${response.resultCount} templates exported.`);
165
+ stopProgressIndicator(indicatorId, `${exportData.length} templates written.`);
160
166
  } catch (err) {
161
- stopProgressIndicator(`${err}`);
167
+ stopProgressIndicator(indicatorId, `${err}`);
162
168
  printMessage(err, 'error');
163
169
  }
164
170
  }
@@ -170,31 +176,29 @@ export async function exportEmailTemplatesToFiles() {
170
176
  * @param {boolean} raw import raw data file lacking frodo export envelop
171
177
  */
172
178
  export async function importEmailTemplateFromFile(templateId, file, raw = false) {
173
- // eslint-disable-next-line no-param-reassign
174
179
  templateId = templateId.replaceAll(`${EMAIL_TEMPLATE_TYPE}/`, '');
175
- fs.readFile(file, 'utf8', async (err, data) => {
176
- if (err) throw err;
180
+ const filePath = getFilePath(file);
181
+ try {
182
+ const data = fs.readFileSync(filePath, 'utf8');
177
183
  const fileData = JSON.parse(data);
178
- if (raw || frodo.utils.impex.validateImport(fileData.meta)) {
179
- createProgressIndicator('determinate', 1, `Importing ${templateId}`);
180
- if (fileData.emailTemplate[templateId] || raw && fileData._id === templateId) {
181
- try {
182
- const emailTemplateData = raw ? s2sConvert(fileData) : fileData.emailTemplate[templateId];
183
- await frodo.email.template.putEmailTemplate(templateId, emailTemplateData);
184
- updateProgressIndicator(`Importing ${templateId}`);
185
- stopProgressIndicator(`Imported ${templateId}`);
186
- } catch (putEmailTemplateError) {
187
- stopProgressIndicator(`${putEmailTemplateError}`);
188
- printMessage(putEmailTemplateError, 'error');
189
- }
190
- } else {
191
- stopProgressIndicator(`Email template ${templateId} not found in ${file}!`);
192
- printMessage(`Email template ${templateId} not found in ${file}!`, 'error');
184
+ const indicatorId = createProgressIndicator('determinate', 1, `Importing ${templateId}`);
185
+ if (fileData.emailTemplate && fileData.emailTemplate[templateId] || raw && getTemplateIdFromFileName(file) === templateId) {
186
+ try {
187
+ const emailTemplateData = raw ? s2sConvert(fileData) : fileData.emailTemplate[templateId];
188
+ await updateEmailTemplate(templateId, emailTemplateData);
189
+ updateProgressIndicator(indicatorId, `Importing ${templateId}`);
190
+ stopProgressIndicator(indicatorId, `Imported ${templateId}`);
191
+ } catch (updateEmailTemplateError) {
192
+ stopProgressIndicator(indicatorId, `${updateEmailTemplateError}`);
193
+ printMessage(updateEmailTemplateError, 'error');
193
194
  }
194
195
  } else {
195
- printMessage('Import validation failed...', 'error');
196
+ stopProgressIndicator(indicatorId, `Email template ${templateId} not found in ${filePath}!`);
197
+ printMessage(`Email template ${templateId} not found in ${filePath}!`, 'error');
196
198
  }
197
- });
199
+ } catch (error) {
200
+ printMessage(`Error importing email template ${templateId}: ${error}`, 'error');
201
+ }
198
202
  }
199
203
 
200
204
  /**
@@ -202,28 +206,24 @@ export async function importEmailTemplateFromFile(templateId, file, raw = false)
202
206
  * @param {string} file optional filename
203
207
  */
204
208
  export async function importEmailTemplatesFromFile(file) {
205
- fs.readFile(file, 'utf8', async (err, data) => {
206
- if (err) throw err;
209
+ try {
210
+ const data = fs.readFileSync(getFilePath(file), 'utf8');
207
211
  const fileData = JSON.parse(data);
208
- if (frodo.utils.impex.validateImport(fileData.meta)) {
209
- createProgressIndicator('determinate', Object.keys(fileData.emailTemplate).length, `Importing email templates`);
210
- for (const id in fileData.emailTemplate) {
211
- if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {
212
- const templateId = id.replace(regexEmailTemplateType, '');
213
- try {
214
- await frodo.email.template.putEmailTemplate(templateId, fileData.emailTemplate[templateId]);
215
- updateProgressIndicator(`Imported ${templateId}`);
216
- } catch (putEmailTemplateError) {
217
- printMessage(`\nError importing ${templateId}`, 'error');
218
- printMessage(putEmailTemplateError.response.data, 'error');
219
- }
220
- }
212
+ const indicatorId = createProgressIndicator('determinate', Object.keys(fileData.emailTemplate).length, `Importing email templates`);
213
+ for (const id of Object.keys(fileData.emailTemplate)) {
214
+ const templateId = id.replace(regexEmailTemplateType, '');
215
+ try {
216
+ await updateEmailTemplate(templateId, fileData.emailTemplate[templateId]);
217
+ updateProgressIndicator(indicatorId, `Imported ${templateId}`);
218
+ } catch (updateEmailTemplateError) {
219
+ printMessage(`\nError importing ${templateId}`, 'error');
220
+ printMessage(updateEmailTemplateError.response.data, 'error');
221
221
  }
222
- stopProgressIndicator(`Done.`);
223
- } else {
224
- printMessage('Import validation failed...', 'error');
225
222
  }
226
- });
223
+ stopProgressIndicator(indicatorId, `Done.`);
224
+ } catch (error) {
225
+ printMessage(`Error importing email templates: ${error}`, 'error');
226
+ }
227
227
  }
228
228
 
229
229
  /**
@@ -231,11 +231,13 @@ export async function importEmailTemplatesFromFile(file) {
231
231
  * @param {string} file file name
232
232
  * @returns {string} email template id/name
233
233
  */
234
- function getEmailTemplateIdFromFile(file) {
235
- debugMessage(`cli.EmailTemplateOps.getEmailTemplateIdFromFile: file=${file}`);
236
- const fileName = path.basename(file);
237
- const templateId = fileName.substring(14, fileName.indexOf('.'));
238
- debugMessage(`cli.EmailTemplateOps.getEmailTemplateIdFromFile: templateId=${templateId}`);
234
+ function getTemplateIdFromFileName(file) {
235
+ debugMessage(`cli.EmailTemplateOps.getTemplateIdFromFileName: file=${file}`);
236
+ const basename = path.basename(file);
237
+ const keys = basename.split('-');
238
+ if (keys[0] !== EMAIL_TEMPLATE_TYPE || keys.length <= 1) throw new Error(`Filename does not indicate a raw email template: ${file}`);
239
+ const templateId = keys[1].split('.')[0];
240
+ debugMessage(`cli.EmailTemplateOps.getTemplateIdFromFileName: templateId=${templateId}`);
239
241
  return templateId;
240
242
  }
241
243
 
@@ -262,28 +264,28 @@ function s2sConvert(templateData) {
262
264
  * @param {boolean} raw import raw data file lacking frodo export envelop
263
265
  */
264
266
  export async function importEmailTemplatesFromFiles(raw = false) {
265
- const names = fs.readdirSync('.');
266
- const jsonFiles = raw ? names.filter(name => name.startsWith(`${EMAIL_TEMPLATE_TYPE}-`) && name.endsWith(`.json`)) : names.filter(name => name.toLowerCase().endsWith(`${EMAIL_TEMPLATE_FILE_TYPE}.json`));
267
- createProgressIndicator('determinate', jsonFiles.length, 'Importing email templates...');
267
+ const names = fs.readdirSync(getWorkingDirectory());
268
+ const jsonFiles = names.filter(name => raw ? name.startsWith(`${EMAIL_TEMPLATE_TYPE}-`) && name.endsWith(`.json`) : name.toLowerCase().endsWith(`${EMAIL_TEMPLATE_FILE_TYPE}.json`)).map(name => getFilePath(name));
269
+ const indicatorId = createProgressIndicator('determinate', jsonFiles.length, 'Importing email templates...');
268
270
  let total = 0;
269
271
  let totalErrors = 0;
270
272
  for (const file of jsonFiles) {
271
273
  const data = fs.readFileSync(file, 'utf8');
272
274
  const fileData = JSON.parse(data);
273
- if (raw && file.startsWith('emailTemplate-') || frodo.utils.impex.validateImport(fileData.meta)) {
275
+ if (raw && file.startsWith('emailTemplate-') || validateImport(fileData.meta)) {
274
276
  let errors = 0;
275
277
  if (raw) {
276
278
  total++;
277
- const templateId = getEmailTemplateIdFromFile(file);
279
+ const templateId = getTemplateIdFromFileName(file);
278
280
  try {
279
281
  const templateData = s2sConvert(fileData);
280
- await frodo.email.template.putEmailTemplate(templateId, templateData);
281
- } catch (putEmailTemplateError) {
282
- var _putEmailTemplateErro;
282
+ await updateEmailTemplate(templateId, templateData);
283
+ } catch (updateEmailTemplateError) {
284
+ var _updateEmailTemplateE;
283
285
  errors += 1;
284
286
  printMessage(`\nError importing ${templateId}`, 'error');
285
- printMessage(putEmailTemplateError, 'error');
286
- printMessage((_putEmailTemplateErro = putEmailTemplateError.response) === null || _putEmailTemplateErro === void 0 ? void 0 : _putEmailTemplateErro.data, 'error');
287
+ printMessage(updateEmailTemplateError, 'error');
288
+ printMessage((_updateEmailTemplateE = updateEmailTemplateError.response) === null || _updateEmailTemplateE === void 0 ? void 0 : _updateEmailTemplateE.data, 'error');
287
289
  }
288
290
  } else {
289
291
  total += Object.keys(fileData.emailTemplate).length;
@@ -291,22 +293,22 @@ export async function importEmailTemplatesFromFiles(raw = false) {
291
293
  if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {
292
294
  const templateId = id.replace(regexEmailTemplateType, '');
293
295
  try {
294
- await frodo.email.template.putEmailTemplate(templateId, fileData.emailTemplate[templateId]);
295
- } catch (putEmailTemplateError) {
296
+ await updateEmailTemplate(templateId, fileData.emailTemplate[templateId]);
297
+ } catch (updateEmailTemplateError) {
296
298
  errors += 1;
297
299
  printMessage(`\nError importing ${templateId}`, 'error');
298
- printMessage(putEmailTemplateError.response.data, 'error');
300
+ printMessage(updateEmailTemplateError.response.data, 'error');
299
301
  }
300
302
  }
301
303
  }
302
304
  }
303
305
  totalErrors += errors;
304
- updateProgressIndicator(`Imported ${file}`);
306
+ updateProgressIndicator(indicatorId, `Imported ${file}`);
305
307
  } else {
306
308
  printMessage(`Validation of ${file} failed!`, 'error');
307
309
  }
308
310
  }
309
- stopProgressIndicator(`Imported ${total - totalErrors} of ${total} email template(s) from ${jsonFiles.length} file(s).`);
311
+ stopProgressIndicator(indicatorId, `Imported ${total - totalErrors} of ${total} email template(s) from ${jsonFiles.length} file(s).`);
310
312
  }
311
313
 
312
314
  /**
@@ -314,40 +316,38 @@ export async function importEmailTemplatesFromFiles(raw = false) {
314
316
  * @param {String} file optional filename
315
317
  */
316
318
  export async function importFirstEmailTemplateFromFile(file, raw = false) {
317
- fs.readFile(file, 'utf8', async (err, data) => {
318
- if (err) throw err;
319
+ let indicatorId;
320
+ try {
321
+ const data = fs.readFileSync(getFilePath(file), 'utf8');
319
322
  const fileData = JSON.parse(data);
320
- if (raw && file.startsWith('emailTemplate-') || frodo.utils.impex.validateImport(fileData.meta)) {
321
- showSpinner(`Importing first email template`);
322
- if (raw) {
323
- const templateId = getEmailTemplateIdFromFile(file);
323
+ indicatorId = createProgressIndicator('indeterminate', 0, `Importing first email template`);
324
+ if (raw) {
325
+ try {
326
+ const templateId = getTemplateIdFromFileName(file);
327
+ const templateData = s2sConvert(fileData);
328
+ await updateEmailTemplate(templateId, templateData);
329
+ stopProgressIndicator(indicatorId, `Imported ${templateId}`, 'success');
330
+ } catch (error) {
331
+ var _error$response;
332
+ stopProgressIndicator(indicatorId, `Error importing email template: ${error}`, 'fail');
333
+ printMessage((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, 'error');
334
+ }
335
+ } else {
336
+ for (const id of Object.keys(fileData.emailTemplate)) {
324
337
  try {
325
- const templateData = s2sConvert(fileData);
326
- await frodo.email.template.putEmailTemplate(templateId, templateData);
327
- succeedSpinner(`Imported ${templateId}`);
328
- } catch (putEmailTemplateError) {
329
- var _putEmailTemplateErro2;
330
- failSpinner(`Error importing ${templateId}`);
331
- printMessage((_putEmailTemplateErro2 = putEmailTemplateError.response) === null || _putEmailTemplateErro2 === void 0 ? void 0 : _putEmailTemplateErro2.data, 'error');
332
- }
333
- } else {
334
- for (const id in fileData.emailTemplate) {
335
- if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {
336
- try {
337
- await frodo.email.template.putEmailTemplate(id.replace(regexEmailTemplateType, ''), fileData.emailTemplate[id]);
338
- succeedSpinner(`Imported ${id}`);
339
- } catch (putEmailTemplateError) {
340
- var _putEmailTemplateErro3;
341
- failSpinner(`Error importing ${id}`);
342
- printMessage((_putEmailTemplateErro3 = putEmailTemplateError.response) === null || _putEmailTemplateErro3 === void 0 ? void 0 : _putEmailTemplateErro3.data, 'error');
343
- }
344
- break;
345
- }
338
+ await updateEmailTemplate(id.replace(regexEmailTemplateType, ''), fileData.emailTemplate[id]);
339
+ stopProgressIndicator(indicatorId, `Imported ${id}`, 'success');
340
+ } catch (updateEmailTemplateError) {
341
+ var _updateEmailTemplateE2;
342
+ stopProgressIndicator(indicatorId, `Error importing ${id}`, 'fail');
343
+ printMessage((_updateEmailTemplateE2 = updateEmailTemplateError.response) === null || _updateEmailTemplateE2 === void 0 ? void 0 : _updateEmailTemplateE2.data, 'error');
346
344
  }
345
+ break;
347
346
  }
348
- } else {
349
- printMessage('Import validation failed...', 'error');
350
347
  }
351
- });
348
+ } catch (error) {
349
+ stopProgressIndicator(indicatorId, `Error importing first email template`, 'fail');
350
+ printMessage(`Error importing first email template: ${error}`, 'error');
351
+ }
352
352
  }
353
- //# sourceMappingURL=EmailTemplateOps.js.map
353
+ //# sourceMappingURL=EmailTemplateOps.js.map