@rockcarver/frodo-cli 2.0.0-6 → 2.0.0-7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/esm/app.js +4 -1
- package/esm/app.js.map +1 -1
- package/esm/cli/_template/something-delete.js +4 -1
- package/esm/cli/_template/something-delete.js.map +1 -1
- package/esm/cli/_template/something-describe.js +4 -1
- package/esm/cli/_template/something-describe.js.map +1 -1
- package/esm/cli/_template/something-else-delete.js +4 -1
- package/esm/cli/_template/something-else-delete.js.map +1 -1
- package/esm/cli/_template/something-else-describe.js +4 -1
- package/esm/cli/_template/something-else-describe.js.map +1 -1
- package/esm/cli/_template/something-else-export.js +4 -1
- package/esm/cli/_template/something-else-export.js.map +1 -1
- package/esm/cli/_template/something-else-import.js +4 -1
- package/esm/cli/_template/something-else-import.js.map +1 -1
- package/esm/cli/_template/something-else-list.js +4 -1
- package/esm/cli/_template/something-else-list.js.map +1 -1
- package/esm/cli/_template/something-export.js +4 -1
- package/esm/cli/_template/something-export.js.map +1 -1
- package/esm/cli/_template/something-import.js +4 -1
- package/esm/cli/_template/something-import.js.map +1 -1
- package/esm/cli/_template/something-list.js +4 -1
- package/esm/cli/_template/something-list.js.map +1 -1
- package/esm/cli/_template/something-other-delete.js +4 -1
- package/esm/cli/_template/something-other-delete.js.map +1 -1
- package/esm/cli/_template/something-other-describe.js +4 -1
- package/esm/cli/_template/something-other-describe.js.map +1 -1
- package/esm/cli/_template/something-other-export.js +4 -1
- package/esm/cli/_template/something-other-export.js.map +1 -1
- package/esm/cli/_template/something-other-import.js +4 -1
- package/esm/cli/_template/something-other-import.js.map +1 -1
- package/esm/cli/_template/something-other-list.js +4 -1
- package/esm/cli/_template/something-other-list.js.map +1 -1
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js +8 -2
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js +10 -3
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-federation-export.js +4 -1
- package/esm/cli/admin/admin-federation-export.js.map +1 -1
- package/esm/cli/admin/admin-federation-import.js +7 -4
- package/esm/cli/admin/admin-federation-import.js.map +1 -1
- package/esm/cli/admin/admin-federation-list.js +4 -1
- package/esm/cli/admin/admin-federation-list.js.map +1 -1
- package/esm/cli/admin/admin-get-access-token.js +8 -2
- package/esm/cli/admin/admin-get-access-token.js.map +1 -1
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +8 -2
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js +8 -2
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js.map +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +8 -2
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +8 -2
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-static-user-mappings.js +8 -2
- package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
- package/esm/cli/admin/admin-remove-static-user-mapping.js +8 -2
- package/esm/cli/admin/admin-remove-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-repair-org-model.js +8 -2
- package/esm/cli/admin/admin-repair-org-model.js.map +1 -1
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +8 -2
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-show-generic-extension-attributes.js +8 -2
- package/esm/cli/admin/admin-show-generic-extension-attributes.js.map +1 -1
- package/esm/cli/agent/agent-delete.js +10 -3
- package/esm/cli/agent/agent-delete.js.map +1 -1
- package/esm/cli/agent/agent-describe.js +4 -1
- package/esm/cli/agent/agent-describe.js.map +1 -1
- package/esm/cli/agent/agent-export.js +4 -1
- package/esm/cli/agent/agent-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-delete.js +10 -3
- package/esm/cli/agent/agent-gateway-delete.js.map +1 -1
- package/esm/cli/agent/agent-gateway-describe.js +4 -1
- package/esm/cli/agent/agent-gateway-describe.js.map +1 -1
- package/esm/cli/agent/agent-gateway-export.js +4 -1
- package/esm/cli/agent/agent-gateway-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-import.js +4 -1
- package/esm/cli/agent/agent-gateway-import.js.map +1 -1
- package/esm/cli/agent/agent-gateway-list.js +4 -1
- package/esm/cli/agent/agent-gateway-list.js.map +1 -1
- package/esm/cli/agent/agent-import.js +4 -1
- package/esm/cli/agent/agent-import.js.map +1 -1
- package/esm/cli/agent/agent-java-delete.js +10 -3
- package/esm/cli/agent/agent-java-delete.js.map +1 -1
- package/esm/cli/agent/agent-java-describe.js +4 -1
- package/esm/cli/agent/agent-java-describe.js.map +1 -1
- package/esm/cli/agent/agent-java-export.js +4 -1
- package/esm/cli/agent/agent-java-export.js.map +1 -1
- package/esm/cli/agent/agent-java-import.js +4 -1
- package/esm/cli/agent/agent-java-import.js.map +1 -1
- package/esm/cli/agent/agent-java-list.js +4 -1
- package/esm/cli/agent/agent-java-list.js.map +1 -1
- package/esm/cli/agent/agent-list.js +4 -1
- package/esm/cli/agent/agent-list.js.map +1 -1
- package/esm/cli/agent/agent-web-delete.js +10 -3
- package/esm/cli/agent/agent-web-delete.js.map +1 -1
- package/esm/cli/agent/agent-web-describe.js +4 -1
- package/esm/cli/agent/agent-web-describe.js.map +1 -1
- package/esm/cli/agent/agent-web-export.js +4 -1
- package/esm/cli/agent/agent-web-export.js.map +1 -1
- package/esm/cli/agent/agent-web-import.js +4 -1
- package/esm/cli/agent/agent-web-import.js.map +1 -1
- package/esm/cli/agent/agent-web-list.js +4 -1
- package/esm/cli/agent/agent-web-list.js.map +1 -1
- package/esm/cli/app/app-delete.js +4 -1
- package/esm/cli/app/app-delete.js.map +1 -1
- package/esm/cli/app/app-describe.js +4 -1
- package/esm/cli/app/app-describe.js.map +1 -1
- package/esm/cli/app/app-export.js +6 -3
- package/esm/cli/app/app-export.js.map +1 -1
- package/esm/cli/app/app-import.js +7 -4
- package/esm/cli/app/app-import.js.map +1 -1
- package/esm/cli/app/app-list.js +4 -1
- package/esm/cli/app/app-list.js.map +1 -1
- package/esm/cli/authz/authz-policy-delete.js +6 -3
- package/esm/cli/authz/authz-policy-delete.js.map +1 -1
- package/esm/cli/authz/authz-policy-describe.js +4 -1
- package/esm/cli/authz/authz-policy-describe.js.map +1 -1
- package/esm/cli/authz/authz-policy-export.js +8 -5
- package/esm/cli/authz/authz-policy-export.js.map +1 -1
- package/esm/cli/authz/authz-policy-import.js +7 -4
- package/esm/cli/authz/authz-policy-import.js.map +1 -1
- package/esm/cli/authz/authz-policy-list.js +5 -2
- package/esm/cli/authz/authz-policy-list.js.map +1 -1
- package/esm/cli/authz/authz-set-delete.js +5 -2
- package/esm/cli/authz/authz-set-delete.js.map +1 -1
- package/esm/cli/authz/authz-set-describe.js +4 -1
- package/esm/cli/authz/authz-set-describe.js.map +1 -1
- package/esm/cli/authz/authz-set-export.js +6 -3
- package/esm/cli/authz/authz-set-export.js.map +1 -1
- package/esm/cli/authz/authz-set-import.js +7 -4
- package/esm/cli/authz/authz-set-import.js.map +1 -1
- package/esm/cli/authz/authz-set-list.js +4 -1
- package/esm/cli/authz/authz-set-list.js.map +1 -1
- package/esm/cli/authz/authz-type-delete.js +6 -3
- package/esm/cli/authz/authz-type-delete.js.map +1 -1
- package/esm/cli/authz/authz-type-describe.js +5 -2
- package/esm/cli/authz/authz-type-describe.js.map +1 -1
- package/esm/cli/authz/authz-type-export.js +7 -4
- package/esm/cli/authz/authz-type-export.js.map +1 -1
- package/esm/cli/authz/authz-type-import.js +8 -5
- package/esm/cli/authz/authz-type-import.js.map +1 -1
- package/esm/cli/authz/authz-type-list.js +4 -1
- package/esm/cli/authz/authz-type-list.js.map +1 -1
- package/esm/cli/conn/conn-save.js +18 -5
- package/esm/cli/conn/conn-save.js.map +1 -1
- package/esm/cli/email/email-template-export.js +6 -3
- package/esm/cli/email/email-template-export.js.map +1 -1
- package/esm/cli/email/email-template-import.js +7 -4
- package/esm/cli/email/email-template-import.js.map +1 -1
- package/esm/cli/email/email-template-list.js +4 -1
- package/esm/cli/email/email-template-list.js.map +1 -1
- package/esm/cli/esv/esv-apply.js +15 -5
- package/esm/cli/esv/esv-apply.js.map +1 -1
- package/esm/cli/esv/esv-secret-create.js +4 -1
- package/esm/cli/esv/esv-secret-create.js.map +1 -1
- package/esm/cli/esv/esv-secret-delete.js +5 -2
- package/esm/cli/esv/esv-secret-delete.js.map +1 -1
- package/esm/cli/esv/esv-secret-describe.js +4 -1
- package/esm/cli/esv/esv-secret-describe.js.map +1 -1
- package/esm/cli/esv/esv-secret-export.js +4 -1
- package/esm/cli/esv/esv-secret-export.js.map +1 -1
- package/esm/cli/esv/esv-secret-import.js +4 -1
- package/esm/cli/esv/esv-secret-import.js.map +1 -1
- package/esm/cli/esv/esv-secret-list.js +4 -1
- package/esm/cli/esv/esv-secret-list.js.map +1 -1
- package/esm/cli/esv/esv-secret-set.js +4 -1
- package/esm/cli/esv/esv-secret-set.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-activate.js +4 -1
- package/esm/cli/esv/esv-secret-version-activate.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-create.js +4 -1
- package/esm/cli/esv/esv-secret-version-create.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-deactivate.js +4 -1
- package/esm/cli/esv/esv-secret-version-deactivate.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-delete.js +5 -2
- package/esm/cli/esv/esv-secret-version-delete.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-list.js +4 -1
- package/esm/cli/esv/esv-secret-version-list.js.map +1 -1
- package/esm/cli/esv/esv-variable-create.js +4 -1
- package/esm/cli/esv/esv-variable-create.js.map +1 -1
- package/esm/cli/esv/esv-variable-delete.js +5 -2
- package/esm/cli/esv/esv-variable-delete.js.map +1 -1
- package/esm/cli/esv/esv-variable-describe.js +4 -1
- package/esm/cli/esv/esv-variable-describe.js.map +1 -1
- package/esm/cli/esv/esv-variable-export.js +4 -1
- package/esm/cli/esv/esv-variable-export.js.map +1 -1
- package/esm/cli/esv/esv-variable-import.js +4 -1
- package/esm/cli/esv/esv-variable-import.js.map +1 -1
- package/esm/cli/esv/esv-variable-list.js +4 -1
- package/esm/cli/esv/esv-variable-list.js.map +1 -1
- package/esm/cli/esv/esv-variable-set.js +5 -2
- package/esm/cli/esv/esv-variable-set.js.map +1 -1
- package/esm/cli/idm/idm-count.js +4 -1
- package/esm/cli/idm/idm-count.js.map +1 -1
- package/esm/cli/idm/idm-export.js +6 -3
- package/esm/cli/idm/idm-export.js.map +1 -1
- package/esm/cli/idm/idm-import.js +7 -4
- package/esm/cli/idm/idm-import.js.map +1 -1
- package/esm/cli/idm/idm-list.js +4 -1
- package/esm/cli/idm/idm-list.js.map +1 -1
- package/esm/cli/idp/idp-export.js +4 -1
- package/esm/cli/idp/idp-export.js.map +1 -1
- package/esm/cli/idp/idp-import.js +7 -4
- package/esm/cli/idp/idp-import.js.map +1 -1
- package/esm/cli/idp/idp-list.js +4 -1
- package/esm/cli/idp/idp-list.js.map +1 -1
- package/esm/cli/info/info.js +8 -2
- package/esm/cli/info/info.js.map +1 -1
- package/esm/cli/journey/journey-delete.js +5 -2
- package/esm/cli/journey/journey-delete.js.map +1 -1
- package/esm/cli/journey/journey-describe.js +14 -6
- package/esm/cli/journey/journey-describe.js.map +1 -1
- package/esm/cli/journey/journey-disable.js +8 -2
- package/esm/cli/journey/journey-disable.js.map +1 -1
- package/esm/cli/journey/journey-enable.js +8 -2
- package/esm/cli/journey/journey-enable.js.map +1 -1
- package/esm/cli/journey/journey-export.js +6 -3
- package/esm/cli/journey/journey-export.js.map +1 -1
- package/esm/cli/journey/journey-import.js +7 -4
- package/esm/cli/journey/journey-import.js.map +1 -1
- package/esm/cli/journey/journey-list.js +4 -1
- package/esm/cli/journey/journey-list.js.map +1 -1
- package/esm/cli/journey/journey-prune.js +10 -3
- package/esm/cli/journey/journey-prune.js.map +1 -1
- package/esm/cli/log/log-fetch.js +16 -6
- package/esm/cli/log/log-fetch.js.map +1 -1
- package/esm/cli/log/log-key-delete.js +5 -2
- package/esm/cli/log/log-key-delete.js.map +1 -1
- package/esm/cli/log/log-key-describe.js +4 -1
- package/esm/cli/log/log-key-describe.js.map +1 -1
- package/esm/cli/log/log-key-list.js +4 -1
- package/esm/cli/log/log-key-list.js.map +1 -1
- package/esm/cli/log/log-list.js +14 -4
- package/esm/cli/log/log-list.js.map +1 -1
- package/esm/cli/log/log-tail.js +16 -6
- package/esm/cli/log/log-tail.js.map +1 -1
- package/esm/cli/realm/realm-add-custom-domain.js +4 -1
- package/esm/cli/realm/realm-add-custom-domain.js.map +1 -1
- package/esm/cli/realm/realm-describe.js +4 -1
- package/esm/cli/realm/realm-describe.js.map +1 -1
- package/esm/cli/realm/realm-list.js +4 -1
- package/esm/cli/realm/realm-list.js.map +1 -1
- package/esm/cli/realm/realm-remove-custom-domain.js +8 -2
- package/esm/cli/realm/realm-remove-custom-domain.js.map +1 -1
- package/esm/cli/saml/saml-cot-export.js +6 -3
- package/esm/cli/saml/saml-cot-export.js.map +1 -1
- package/esm/cli/saml/saml-cot-import.js +7 -4
- package/esm/cli/saml/saml-cot-import.js.map +1 -1
- package/esm/cli/saml/saml-cot-list.js +4 -1
- package/esm/cli/saml/saml-cot-list.js.map +1 -1
- package/esm/cli/saml/saml-delete.js +11 -4
- package/esm/cli/saml/saml-delete.js.map +1 -1
- package/esm/cli/saml/saml-describe.js +4 -1
- package/esm/cli/saml/saml-describe.js.map +1 -1
- package/esm/cli/saml/saml-export.js +6 -3
- package/esm/cli/saml/saml-export.js.map +1 -1
- package/esm/cli/saml/saml-import.js +7 -4
- package/esm/cli/saml/saml-import.js.map +1 -1
- package/esm/cli/saml/saml-list.js +4 -1
- package/esm/cli/saml/saml-list.js.map +1 -1
- package/esm/cli/saml/saml-metadata-export.js +5 -2
- package/esm/cli/saml/saml-metadata-export.js.map +1 -1
- package/esm/cli/script/script-delete.js +4 -1
- package/esm/cli/script/script-delete.js.map +1 -1
- package/esm/cli/script/script-describe.js +4 -1
- package/esm/cli/script/script-describe.js.map +1 -1
- package/esm/cli/script/script-export.js +4 -1
- package/esm/cli/script/script-export.js.map +1 -1
- package/esm/cli/script/script-import.js +4 -1
- package/esm/cli/script/script-import.js.map +1 -1
- package/esm/cli/script/script-list.js +4 -1
- package/esm/cli/script/script-list.js.map +1 -1
- package/esm/cli/service/service-delete.js +5 -2
- package/esm/cli/service/service-delete.js.map +1 -1
- package/esm/cli/service/service-export.js +6 -3
- package/esm/cli/service/service-export.js.map +1 -1
- package/esm/cli/service/service-import.js +7 -4
- package/esm/cli/service/service-import.js.map +1 -1
- package/esm/cli/service/service-list.js +4 -1
- package/esm/cli/service/service-list.js.map +1 -1
- package/esm/cli/theme/theme-delete.js +6 -3
- package/esm/cli/theme/theme-delete.js.map +1 -1
- package/esm/cli/theme/theme-export.js +7 -4
- package/esm/cli/theme/theme-export.js.map +1 -1
- package/esm/cli/theme/theme-import.js +8 -5
- package/esm/cli/theme/theme-import.js.map +1 -1
- package/esm/cli/theme/theme-list.js +4 -1
- package/esm/cli/theme/theme-list.js.map +1 -1
- package/esm/ops/AdminFederationOps.js +17 -9
- package/esm/ops/AdminFederationOps.js.map +1 -1
- package/esm/ops/AgentOps.js +62 -36
- package/esm/ops/AgentOps.js.map +1 -1
- package/esm/ops/CirclesOfTrustOps.js +22 -10
- package/esm/ops/CirclesOfTrustOps.js.map +1 -1
- package/esm/ops/ConnectionProfileOps.js +10 -3
- package/esm/ops/ConnectionProfileOps.js.map +1 -1
- package/esm/ops/EmailTemplateOps.js +23 -15
- package/esm/ops/EmailTemplateOps.js.map +1 -1
- package/esm/ops/IdmOps.js +34 -21
- package/esm/ops/IdmOps.js.map +1 -1
- package/esm/ops/IdpOps.js +17 -9
- package/esm/ops/IdpOps.js.map +1 -1
- package/esm/ops/JourneyOps.js +46 -30
- package/esm/ops/JourneyOps.js.map +1 -1
- package/esm/ops/LogOps.js +21 -11
- package/esm/ops/LogOps.js.map +1 -1
- package/esm/ops/NodeOps.js +5 -2
- package/esm/ops/NodeOps.js.map +1 -1
- package/esm/ops/OAuth2ClientOps.js +25 -12
- package/esm/ops/OAuth2ClientOps.js.map +1 -1
- package/esm/ops/OrganizationOps.js +8 -2
- package/esm/ops/OrganizationOps.js.map +1 -1
- package/esm/ops/PolicyOps.js +36 -21
- package/esm/ops/PolicyOps.js.map +1 -1
- package/esm/ops/PolicySetOps.js +35 -18
- package/esm/ops/PolicySetOps.js.map +1 -1
- package/esm/ops/RealmOps.js +11 -6
- package/esm/ops/RealmOps.js.map +1 -1
- package/esm/ops/ResourceTypeOps.js +34 -18
- package/esm/ops/ResourceTypeOps.js.map +1 -1
- package/esm/ops/Saml2Ops.js +43 -23
- package/esm/ops/Saml2Ops.js.map +1 -1
- package/esm/ops/ScriptOps.js +18 -10
- package/esm/ops/ScriptOps.js.map +1 -1
- package/esm/ops/SecretsOps.js +28 -14
- package/esm/ops/SecretsOps.js.map +1 -1
- package/esm/ops/ServiceOps.js +38 -17
- package/esm/ops/ServiceOps.js.map +1 -1
- package/esm/ops/ThemeOps.js +35 -19
- package/esm/ops/ThemeOps.js.map +1 -1
- package/esm/ops/VariablesOps.js +23 -12
- package/esm/ops/VariablesOps.js.map +1 -1
- package/esm/utils/Config.js +6 -3
- package/esm/utils/Config.js.map +1 -1
- package/esm/utils/Console.js +5 -2
- package/esm/utils/Console.js.map +1 -1
- package/esm/utils/ExportImportUtils.js +6 -3
- package/esm/utils/ExportImportUtils.js.map +1 -1
- package/esm/utils/Version.js +7 -3
- package/esm/utils/Version.js.map +1 -1
- package/package.json +2 -2
|
@@ -5,7 +5,15 @@ import { createProgressIndicator, updateProgressIndicator, stopProgressIndicator
|
|
|
5
5
|
import wordwrap from './utils/Wordwrap';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { cloneDeep } from './utils/OpsUtils';
|
|
8
|
-
const
|
|
8
|
+
const {
|
|
9
|
+
validateImport
|
|
10
|
+
} = frodo.utils.impex;
|
|
11
|
+
const {
|
|
12
|
+
EMAIL_TEMPLATE_TYPE,
|
|
13
|
+
getEmailTemplates,
|
|
14
|
+
getEmailTemplate,
|
|
15
|
+
putEmailTemplate
|
|
16
|
+
} = frodo.email.template;
|
|
9
17
|
const EMAIL_TEMPLATE_FILE_TYPE = 'template.email';
|
|
10
18
|
const regexEmailTemplateType = new RegExp(`${EMAIL_TEMPLATE_TYPE}/`, 'g');
|
|
11
19
|
|
|
@@ -58,7 +66,7 @@ export function getTableRowMd(templateObj) {
|
|
|
58
66
|
export async function listEmailTemplates(long = false) {
|
|
59
67
|
let emailTemplates = [];
|
|
60
68
|
try {
|
|
61
|
-
emailTemplates = (await
|
|
69
|
+
emailTemplates = (await getEmailTemplates()).result;
|
|
62
70
|
} catch (error) {
|
|
63
71
|
printMessage(`Error retrieving email templates: ${error.message}`, 'error');
|
|
64
72
|
}
|
|
@@ -101,7 +109,7 @@ export async function exportEmailTemplateToFile(templateId, file) {
|
|
|
101
109
|
}
|
|
102
110
|
createProgressIndicator('determinate', 1, `Exporting ${templateId}`);
|
|
103
111
|
try {
|
|
104
|
-
const templateData = await
|
|
112
|
+
const templateData = await getEmailTemplate(templateId);
|
|
105
113
|
updateProgressIndicator(`Writing file ${fileName}`);
|
|
106
114
|
const fileData = getFileDataTemplate();
|
|
107
115
|
fileData.emailTemplate[templateId] = templateData;
|
|
@@ -124,7 +132,7 @@ export async function exportEmailTemplatesToFile(file) {
|
|
|
124
132
|
}
|
|
125
133
|
try {
|
|
126
134
|
const fileData = getFileDataTemplate();
|
|
127
|
-
const response = await
|
|
135
|
+
const response = await getEmailTemplates();
|
|
128
136
|
const templates = response.result;
|
|
129
137
|
createProgressIndicator('determinate', response.resultCount, 'Exporting email templates');
|
|
130
138
|
for (const template of templates) {
|
|
@@ -145,7 +153,7 @@ export async function exportEmailTemplatesToFile(file) {
|
|
|
145
153
|
*/
|
|
146
154
|
export async function exportEmailTemplatesToFiles() {
|
|
147
155
|
try {
|
|
148
|
-
const response = await
|
|
156
|
+
const response = await getEmailTemplates();
|
|
149
157
|
const templates = response.result;
|
|
150
158
|
createProgressIndicator('determinate', response.resultCount, 'Exporting email templates');
|
|
151
159
|
for (const template of templates) {
|
|
@@ -175,12 +183,12 @@ export async function importEmailTemplateFromFile(templateId, file, raw = false)
|
|
|
175
183
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
176
184
|
if (err) throw err;
|
|
177
185
|
const fileData = JSON.parse(data);
|
|
178
|
-
if (raw ||
|
|
186
|
+
if (raw || validateImport(fileData.meta)) {
|
|
179
187
|
createProgressIndicator('determinate', 1, `Importing ${templateId}`);
|
|
180
188
|
if (fileData.emailTemplate[templateId] || raw && fileData._id === templateId) {
|
|
181
189
|
try {
|
|
182
190
|
const emailTemplateData = raw ? s2sConvert(fileData) : fileData.emailTemplate[templateId];
|
|
183
|
-
await
|
|
191
|
+
await putEmailTemplate(templateId, emailTemplateData);
|
|
184
192
|
updateProgressIndicator(`Importing ${templateId}`);
|
|
185
193
|
stopProgressIndicator(`Imported ${templateId}`);
|
|
186
194
|
} catch (putEmailTemplateError) {
|
|
@@ -205,13 +213,13 @@ export async function importEmailTemplatesFromFile(file) {
|
|
|
205
213
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
206
214
|
if (err) throw err;
|
|
207
215
|
const fileData = JSON.parse(data);
|
|
208
|
-
if (
|
|
216
|
+
if (validateImport(fileData.meta)) {
|
|
209
217
|
createProgressIndicator('determinate', Object.keys(fileData.emailTemplate).length, `Importing email templates`);
|
|
210
218
|
for (const id in fileData.emailTemplate) {
|
|
211
219
|
if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {
|
|
212
220
|
const templateId = id.replace(regexEmailTemplateType, '');
|
|
213
221
|
try {
|
|
214
|
-
await
|
|
222
|
+
await putEmailTemplate(templateId, fileData.emailTemplate[templateId]);
|
|
215
223
|
updateProgressIndicator(`Imported ${templateId}`);
|
|
216
224
|
} catch (putEmailTemplateError) {
|
|
217
225
|
printMessage(`\nError importing ${templateId}`, 'error');
|
|
@@ -270,14 +278,14 @@ export async function importEmailTemplatesFromFiles(raw = false) {
|
|
|
270
278
|
for (const file of jsonFiles) {
|
|
271
279
|
const data = fs.readFileSync(file, 'utf8');
|
|
272
280
|
const fileData = JSON.parse(data);
|
|
273
|
-
if (raw && file.startsWith('emailTemplate-') ||
|
|
281
|
+
if (raw && file.startsWith('emailTemplate-') || validateImport(fileData.meta)) {
|
|
274
282
|
let errors = 0;
|
|
275
283
|
if (raw) {
|
|
276
284
|
total++;
|
|
277
285
|
const templateId = getEmailTemplateIdFromFile(file);
|
|
278
286
|
try {
|
|
279
287
|
const templateData = s2sConvert(fileData);
|
|
280
|
-
await
|
|
288
|
+
await putEmailTemplate(templateId, templateData);
|
|
281
289
|
} catch (putEmailTemplateError) {
|
|
282
290
|
var _putEmailTemplateErro;
|
|
283
291
|
errors += 1;
|
|
@@ -291,7 +299,7 @@ export async function importEmailTemplatesFromFiles(raw = false) {
|
|
|
291
299
|
if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {
|
|
292
300
|
const templateId = id.replace(regexEmailTemplateType, '');
|
|
293
301
|
try {
|
|
294
|
-
await
|
|
302
|
+
await putEmailTemplate(templateId, fileData.emailTemplate[templateId]);
|
|
295
303
|
} catch (putEmailTemplateError) {
|
|
296
304
|
errors += 1;
|
|
297
305
|
printMessage(`\nError importing ${templateId}`, 'error');
|
|
@@ -317,13 +325,13 @@ export async function importFirstEmailTemplateFromFile(file, raw = false) {
|
|
|
317
325
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
318
326
|
if (err) throw err;
|
|
319
327
|
const fileData = JSON.parse(data);
|
|
320
|
-
if (raw && file.startsWith('emailTemplate-') ||
|
|
328
|
+
if (raw && file.startsWith('emailTemplate-') || validateImport(fileData.meta)) {
|
|
321
329
|
showSpinner(`Importing first email template`);
|
|
322
330
|
if (raw) {
|
|
323
331
|
const templateId = getEmailTemplateIdFromFile(file);
|
|
324
332
|
try {
|
|
325
333
|
const templateData = s2sConvert(fileData);
|
|
326
|
-
await
|
|
334
|
+
await putEmailTemplate(templateId, templateData);
|
|
327
335
|
succeedSpinner(`Imported ${templateId}`);
|
|
328
336
|
} catch (putEmailTemplateError) {
|
|
329
337
|
var _putEmailTemplateErro2;
|
|
@@ -334,7 +342,7 @@ export async function importFirstEmailTemplateFromFile(file, raw = false) {
|
|
|
334
342
|
for (const id in fileData.emailTemplate) {
|
|
335
343
|
if ({}.hasOwnProperty.call(fileData.emailTemplate, id)) {
|
|
336
344
|
try {
|
|
337
|
-
await
|
|
345
|
+
await putEmailTemplate(id.replace(regexEmailTemplateType, ''), fileData.emailTemplate[id]);
|
|
338
346
|
succeedSpinner(`Imported ${id}`);
|
|
339
347
|
} catch (putEmailTemplateError) {
|
|
340
348
|
var _putEmailTemplateErro3;
|
|
@@ -1 +1 @@
|
|
|
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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,CAACqE,cAAc,CAACC,IAAI,CAACxB,QAAQ,CAAC9C,aAAa,EAAEoE,EAAE,CAAC,EAAE;YACtD,IAAI;cACF,MAAM5F,KAAK,CAACiB,KAAK,CAACC,QAAQ,CAACuE,gBAAgB,CACzCG,EAAE,CAACrD,OAAO,CAACnB,sBAAsB,EAAE,EAAE,CAAC,EACtCkD,QAAQ,CAAC9C,aAAa,CAACoE,EAAE,CAC3B,CAAC;cACDlF,cAAc,CAAE,YAAWkF,EAAG,EAAC,CAAC;YAClC,CAAC,CAAC,OAAOF,qBAAqB,EAAE;cAAA,IAAAyB,sBAAA;cAC9BxG,WAAW,CAAE,mBAAkBiF,EAAG,EAAC,CAAC;cACpCrF,YAAY,EAAA4G,sBAAA,GAACzB,qBAAqB,CAACjB,QAAQ,cAAA0C,sBAAA,uBAA9BA,sBAAA,CAAgClC,IAAI,EAAE,OAAO,CAAC;YAC7D;YACA;UACF;QACF;MACF;IACF,CAAC,MAAM;MACL1E,YAAY,CAAC,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","validateImport","utils","impex","EMAIL_TEMPLATE_TYPE","getEmailTemplates","getEmailTemplate","putEmailTemplate","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","result","error","message","sort","a","b","localeCompare","entries","table","push","enabled","from","toString","exportEmailTemplateToFile","file","fileName","templateData","fileData","err","exportEmailTemplatesToFile","response","templates","resultCount","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 { 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 { validateImport } = frodo.utils.impex;\nconst {\n EMAIL_TEMPLATE_TYPE,\n getEmailTemplates,\n getEmailTemplate,\n putEmailTemplate,\n} = frodo.email.template;\n\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 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 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,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,MAAM;EAAEC;AAAe,CAAC,GAAGhB,KAAK,CAACiB,KAAK,CAACC,KAAK;AAC5C,MAAM;EACJC,mBAAmB;EACnBC,iBAAiB;EACjBC,gBAAgB;EAChBC;AACF,CAAC,GAAGtB,KAAK,CAACuB,KAAK,CAACC,QAAQ;AAExB,MAAMC,wBAAwB,GAAG,gBAAgB;AAEjD,MAAMC,sBAAsB,GAAG,IAAIC,MA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MACL9E,YAAY,CAAC,6BAA6B,EAAE,OAAO,CAAC;IACtD;EACF,CAAC,CAAC;AACJ"}
|
package/esm/ops/IdmOps.js
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
import { frodo } from '@rockcarver/frodo-lib';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import fse from 'fs-extra';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import propertiesReader from 'properties-reader';
|
|
6
6
|
import replaceall from 'replaceall';
|
|
7
|
-
import { frodo } from '@rockcarver/frodo-lib';
|
|
8
7
|
import { createProgressIndicator, printMessage, stopProgressIndicator } from '../utils/Console';
|
|
9
8
|
import { getTypedFilename } from '../utils/ExportImportUtils';
|
|
9
|
+
const {
|
|
10
|
+
validateScriptHooks
|
|
11
|
+
} = frodo.helper.script;
|
|
12
|
+
const {
|
|
13
|
+
readFiles,
|
|
14
|
+
unSubstituteEnvParams
|
|
15
|
+
} = frodo.helper.utils;
|
|
16
|
+
const {
|
|
17
|
+
testConnectorServers,
|
|
18
|
+
getAllConfigEntities,
|
|
19
|
+
getConfigEntity,
|
|
20
|
+
putConfigEntity,
|
|
21
|
+
queryAllManagedObjectsByType
|
|
22
|
+
} = frodo.idm.config;
|
|
10
23
|
|
|
11
24
|
/**
|
|
12
25
|
* Warn about and list offline remote connector servers
|
|
13
26
|
*/
|
|
14
27
|
export async function warnAboutOfflineConnectorServers() {
|
|
15
28
|
try {
|
|
16
|
-
const all = await
|
|
29
|
+
const all = await testConnectorServers();
|
|
17
30
|
const offline = all.filter(status => !status.ok).map(status => status.name);
|
|
18
31
|
if (offline.length) {
|
|
19
32
|
printMessage(`\nThe following connector server(s) are offline and their connectors and configuration unavailable:\n${offline.join('\n')}`, 'warn');
|
|
@@ -31,7 +44,7 @@ export async function listAllConfigEntities() {
|
|
|
31
44
|
try {
|
|
32
45
|
const {
|
|
33
46
|
configurations
|
|
34
|
-
} = await
|
|
47
|
+
} = await getAllConfigEntities();
|
|
35
48
|
for (const configEntity of configurations) {
|
|
36
49
|
printMessage(`${configEntity._id}`, 'data');
|
|
37
50
|
}
|
|
@@ -51,7 +64,7 @@ export async function exportConfigEntity(id, file) {
|
|
|
51
64
|
if (!fileName) {
|
|
52
65
|
fileName = getTypedFilename(`${id}`, 'idm');
|
|
53
66
|
}
|
|
54
|
-
const configEntity = await
|
|
67
|
+
const configEntity = await getConfigEntity(id);
|
|
55
68
|
fs.writeFile(fileName, JSON.stringify(configEntity, null, 2), err => {
|
|
56
69
|
if (err) {
|
|
57
70
|
return printMessage(`ERROR - can't save ${id} export to file`, 'error');
|
|
@@ -68,14 +81,14 @@ export async function exportAllRawConfigEntities(directory) {
|
|
|
68
81
|
try {
|
|
69
82
|
const {
|
|
70
83
|
configurations
|
|
71
|
-
} = await
|
|
84
|
+
} = await getAllConfigEntities();
|
|
72
85
|
if (!fs.existsSync(directory)) {
|
|
73
86
|
fs.mkdirSync(directory);
|
|
74
87
|
}
|
|
75
88
|
createProgressIndicator('indeterminate', undefined, 'Exporting config objects...');
|
|
76
89
|
const entityPromises = [];
|
|
77
90
|
for (const configEntity of configurations) {
|
|
78
|
-
entityPromises.push(
|
|
91
|
+
entityPromises.push(getConfigEntity(configEntity._id).catch(getConfigEntityError => {
|
|
79
92
|
var _getConfigEntityError, _getConfigEntityError2, _getConfigEntityError3, _getConfigEntityError4, _getConfigEntityError5, _getConfigEntityError6, _getConfigEntityError7, _getConfigEntityError8, _getConfigEntityError9;
|
|
80
93
|
if (!(((_getConfigEntityError = getConfigEntityError.response) === null || _getConfigEntityError === void 0 ? void 0 : _getConfigEntityError.status) === 403 && ((_getConfigEntityError2 = getConfigEntityError.response) === null || _getConfigEntityError2 === void 0 ? void 0 : (_getConfigEntityError3 = _getConfigEntityError2.data) === null || _getConfigEntityError3 === void 0 ? void 0 : _getConfigEntityError3.message) === 'This operation is not available in ForgeRock Identity Cloud.') && !(
|
|
81
94
|
// list of config entities, which do not exist by default or ever.
|
|
@@ -126,7 +139,7 @@ export async function exportAllConfigEntities(directory, entitiesFile, envFile)
|
|
|
126
139
|
try {
|
|
127
140
|
const {
|
|
128
141
|
configurations
|
|
129
|
-
} = await
|
|
142
|
+
} = await getAllConfigEntities();
|
|
130
143
|
// create export directory if not exist
|
|
131
144
|
if (!fs.existsSync(directory)) {
|
|
132
145
|
fs.mkdirSync(directory);
|
|
@@ -135,7 +148,7 @@ export async function exportAllConfigEntities(directory, entitiesFile, envFile)
|
|
|
135
148
|
const entityPromises = [];
|
|
136
149
|
for (const configEntity of configurations) {
|
|
137
150
|
if (entriesToExport.includes(configEntity._id)) {
|
|
138
|
-
entityPromises.push(
|
|
151
|
+
entityPromises.push(getConfigEntity(configEntity._id));
|
|
139
152
|
}
|
|
140
153
|
}
|
|
141
154
|
const results = await Promise.all(entityPromises);
|
|
@@ -172,13 +185,13 @@ export async function importConfigEntityByIdFromFile(entityId, file, validate) {
|
|
|
172
185
|
}
|
|
173
186
|
const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');
|
|
174
187
|
const entityData = JSON.parse(fileData);
|
|
175
|
-
const isValid =
|
|
188
|
+
const isValid = validateScriptHooks(entityData);
|
|
176
189
|
if (validate && !isValid) {
|
|
177
190
|
printMessage('Invalid IDM configuration object', 'error');
|
|
178
191
|
return;
|
|
179
192
|
}
|
|
180
193
|
try {
|
|
181
|
-
await
|
|
194
|
+
await putConfigEntity(entityId, entityData);
|
|
182
195
|
} catch (putConfigEntityError) {
|
|
183
196
|
printMessage(putConfigEntityError, 'error');
|
|
184
197
|
printMessage(`Error: ${putConfigEntityError}`, 'error');
|
|
@@ -194,13 +207,13 @@ export async function importConfigEntityFromFile(file, validate) {
|
|
|
194
207
|
const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');
|
|
195
208
|
const entityData = JSON.parse(fileData);
|
|
196
209
|
const entityId = entityData._id;
|
|
197
|
-
const isValid =
|
|
210
|
+
const isValid = validateScriptHooks(entityData);
|
|
198
211
|
if (validate && !isValid) {
|
|
199
212
|
printMessage('Invalid IDM configuration object', 'error');
|
|
200
213
|
return;
|
|
201
214
|
}
|
|
202
215
|
try {
|
|
203
|
-
await
|
|
216
|
+
await putConfigEntity(entityId, entityData);
|
|
204
217
|
} catch (putConfigEntityError) {
|
|
205
218
|
printMessage(putConfigEntityError, 'error');
|
|
206
219
|
printMessage(`Error: ${putConfigEntityError}`, 'error');
|
|
@@ -216,7 +229,7 @@ export async function importAllRawConfigEntities(baseDirectory, validate) {
|
|
|
216
229
|
if (!fs.existsSync(baseDirectory)) {
|
|
217
230
|
return;
|
|
218
231
|
}
|
|
219
|
-
const files = await
|
|
232
|
+
const files = await readFiles(baseDirectory);
|
|
220
233
|
const jsonFiles = files.filter(({
|
|
221
234
|
path
|
|
222
235
|
}) => path.toLowerCase().endsWith('.json')).map(({
|
|
@@ -231,7 +244,7 @@ export async function importAllRawConfigEntities(baseDirectory, validate) {
|
|
|
231
244
|
let everyScriptValid = true;
|
|
232
245
|
for (const file of jsonFiles) {
|
|
233
246
|
const jsObject = JSON.parse(file.content);
|
|
234
|
-
const isScriptValid =
|
|
247
|
+
const isScriptValid = validateScriptHooks(jsObject);
|
|
235
248
|
if (!isScriptValid) {
|
|
236
249
|
printMessage(`Invalid script hook in ${file.path}`, 'error');
|
|
237
250
|
everyScriptValid = false;
|
|
@@ -242,7 +255,7 @@ export async function importAllRawConfigEntities(baseDirectory, validate) {
|
|
|
242
255
|
}
|
|
243
256
|
createProgressIndicator('indeterminate', undefined, 'Importing config objects...');
|
|
244
257
|
const entityPromises = jsonFiles.map(file => {
|
|
245
|
-
return
|
|
258
|
+
return putConfigEntity(file.entityId, file.content);
|
|
246
259
|
});
|
|
247
260
|
const results = await Promise.allSettled(entityPromises);
|
|
248
261
|
const errors = results.filter(result => result.status === 'rejected');
|
|
@@ -270,7 +283,7 @@ export async function importAllConfigEntities(baseDirectory, entitiesFile, envFi
|
|
|
270
283
|
}
|
|
271
284
|
const entriesToImport = JSON.parse(fs.readFileSync(entitiesFile, 'utf8')).idm;
|
|
272
285
|
const envReader = propertiesReader(envFile);
|
|
273
|
-
const files = await
|
|
286
|
+
const files = await readFiles(baseDirectory);
|
|
274
287
|
const jsonFiles = files.filter(({
|
|
275
288
|
path
|
|
276
289
|
}) => path.toLowerCase().endsWith('.json')).map(({
|
|
@@ -285,7 +298,7 @@ export async function importAllConfigEntities(baseDirectory, entitiesFile, envFi
|
|
|
285
298
|
let everyScriptValid = true;
|
|
286
299
|
for (const file of jsonFiles) {
|
|
287
300
|
const jsObject = JSON.parse(file.content);
|
|
288
|
-
const isScriptValid =
|
|
301
|
+
const isScriptValid = validateScriptHooks(jsObject);
|
|
289
302
|
if (!isScriptValid) {
|
|
290
303
|
printMessage(`Invalid script hook in ${file.path}`, 'error');
|
|
291
304
|
everyScriptValid = false;
|
|
@@ -303,8 +316,8 @@ export async function importAllConfigEntities(baseDirectory, entitiesFile, envFi
|
|
|
303
316
|
entityId,
|
|
304
317
|
content
|
|
305
318
|
}) => {
|
|
306
|
-
const unsubstituted =
|
|
307
|
-
return
|
|
319
|
+
const unsubstituted = unSubstituteEnvParams(content, envReader);
|
|
320
|
+
return putConfigEntity(entityId, unsubstituted);
|
|
308
321
|
});
|
|
309
322
|
const results = await Promise.allSettled(entityPromises);
|
|
310
323
|
const errors = results.filter(result => result.status === 'rejected');
|
|
@@ -335,7 +348,7 @@ export async function countManagedObjects(type) {
|
|
|
335
348
|
};
|
|
336
349
|
try {
|
|
337
350
|
do {
|
|
338
|
-
result = await
|
|
351
|
+
result = await queryAllManagedObjectsByType(type, [], result.pagedResultsCookie);
|
|
339
352
|
count += result.resultCount;
|
|
340
353
|
} while (result.pagedResultsCookie);
|
|
341
354
|
printMessage(`${type}: ${count}`);
|
package/esm/ops/IdmOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdmOps.js","names":["fs","fse","path","propertiesReader","replaceall","frodo","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","warnAboutOfflineConnectorServers","all","idm","config","testConnectorServers","offline","filter","status","ok","map","name","length","join","error","message","listAllConfigEntities","configurations","getAllConfigEntities","configEntity","_id","getAllConfigEntitiesError","exportConfigEntity","id","file","fileName","getConfigEntity","writeFile","JSON","stringify","err","exportAllRawConfigEntities","directory","existsSync","mkdirSync","undefined","entityPromises","push","catch","getConfigEntityError","_getConfigEntityError","_getConfigEntityError2","_getConfigEntityError3","_getConfigEntityError4","_getConfigEntityError5","_getConfigEntityError6","_getConfigEntityError7","_getConfigEntityError8","_getConfigEntityError9","response","data","includes","reason","_getConfigEntityError10","results","Promise","item","outputFile","exportAllConfigEntities","entitiesFile","envFile","entriesToExport","readFile","entriesData","parse","envParams","configEntityString","each","key","value","importConfigEntityByIdFromFile","entityId","validate","fileData","readFileSync","resolve","process","cwd","entityData","isValid","helper","script","validateScriptHooks","putConfigEntity","putConfigEntityError","importConfigEntityFromFile","importAllRawConfigEntities","baseDirectory","files","utils","readFiles","jsonFiles","toLowerCase","endsWith","content","substring","everyScriptValid","jsObject","isScriptValid","allSettled","errors","result","importAllConfigEntities","entriesToImport","envReader","unsubstituted","unSubstituteEnvParams","countManagedObjects","type","count","resultCount","pagedResultsCookie","totalPagedResultsPolicy","totalPagedResults","remainingPagedResults","queryAllManagedObjectsByType"],"sources":["ops/IdmOps.ts"],"sourcesContent":["/* eslint-disable no-await-in-loop */\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\n\nimport { frodo } from '@rockcarver/frodo-lib';\nimport {\n createProgressIndicator,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename } from '../utils/ExportImportUtils';\n\n/**\n * Warn about and list offline remote connector servers\n */\nexport async function warnAboutOfflineConnectorServers() {\n try {\n const all = await frodo.idm.config.testConnectorServers();\n const offline = all\n .filter((status) => !status.ok)\n .map((status) => status.name);\n if (offline.length) {\n printMessage(\n `\\nThe following connector server(s) are offline and their connectors and configuration unavailable:\\n${offline.join(\n '\\n'\n )}`,\n 'warn'\n );\n }\n } catch (error) {\n printMessage(error, 'error');\n printMessage(\n `Error getting offline connector servers: ${error.message}`,\n 'error'\n );\n }\n}\n\n/**\n * List all IDM configuration objects\n */\nexport async function listAllConfigEntities() {\n try {\n const { configurations } = await frodo.idm.config.getAllConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export an IDM configuration object.\n * @param {String} id the desired configuration object\n * @param {String} file optional export file\n */\nexport async function exportConfigEntity(id, file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`${id}`, 'idm');\n }\n const configEntity = await frodo.idm.config.getConfigEntity(id);\n fs.writeFile(fileName, JSON.stringify(configEntity, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${id} export to file`, 'error');\n }\n return '';\n });\n}\n\n/**\n * Export all IDM configuration objects into separate JSON files in a directory specified by <directory>\n * @param {String} directory export directory\n */\nexport async function exportAllRawConfigEntities(directory) {\n try {\n const { configurations } = await frodo.idm.config.getAllConfigEntities();\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n entityPromises.push(\n frodo.idm.config\n .getConfigEntity(configEntity._id)\n .catch((getConfigEntityError) => {\n if (\n !(\n getConfigEntityError.response?.status === 403 &&\n getConfigEntityError.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n ) &&\n !(\n // list of config entities, which do not exist by default or ever.\n (\n [\n 'script',\n 'notificationFactory',\n 'apiVersion',\n 'metrics',\n 'repo.init',\n 'endpoint/validateQueryFilter',\n 'endpoint/oauthproxy',\n 'external.rest',\n 'scheduler',\n 'org.apache.felix.fileinstall/openidm',\n 'cluster',\n 'endpoint/mappingDetails',\n 'fieldPolicy/teammember',\n ].includes(configEntity._id) &&\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.reason === 'Not Found'\n )\n ) &&\n // https://bugster.forgerock.org/jira/browse/OPENIDM-18270\n !(\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.message ===\n 'No configuration exists for id org.apache.felix.fileinstall/openidm'\n )\n ) {\n printMessage(getConfigEntityError.response?.data, 'error');\n printMessage(\n `Error getting config entity ${configEntity._id}: ${getConfigEntityError}`,\n 'error'\n );\n }\n })\n );\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n fse.outputFile(\n `${directory}/${item._id}.json`,\n JSON.stringify(item, null, 2),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator('Exported config objects.', 'success');\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export all IDM configuration objects\n * @param {String} directory export directory\n * @param {String} entitiesFile JSON file that specifies the config entities to export/import\n * @param {String} envFile File that defines environment specific variables for replacement during configuration export/import\n */\nexport async function exportAllConfigEntities(\n directory,\n entitiesFile,\n envFile\n) {\n let entriesToExport = [];\n // read list of entities to export\n fs.readFile(entitiesFile, 'utf8', async (err, data) => {\n if (err) throw err;\n const entriesData = JSON.parse(data);\n entriesToExport = entriesData.idm;\n // console.log(`entriesToExport ${entriesToExport}`);\n\n // read list of configs to parameterize for environment specific values\n const envParams = propertiesReader(envFile);\n\n try {\n const { configurations } = await frodo.idm.config.getAllConfigEntities();\n // create export directory if not exist\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(\n frodo.idm.config.getConfigEntity(configEntity._id)\n );\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n let configEntityString = JSON.stringify(item, null, 2);\n envParams.each((key, value) => {\n configEntityString = replaceall(\n value,\n `\\${${key}}`,\n configEntityString\n );\n });\n fse.outputFile(\n `${directory}/${item._id}.json`,\n configEntityString,\n (error) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${error}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator(null, 'success');\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n });\n}\n\n/**\n * Import an IDM configuration object by id from file.\n * @param entityId the configuration object to import\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityByIdFromFile(\n entityId: string,\n file?: string,\n validate?: boolean\n) {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n\n const entityData = JSON.parse(fileData);\n const isValid = frodo.helper.script.validateScriptHooks(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await frodo.idm.config.putConfigEntity(entityId, entityData);\n } catch (putConfigEntityError) {\n printMessage(putConfigEntityError, 'error');\n printMessage(`Error: ${putConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import IDM configuration object from file.\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityFromFile(\n file: string,\n validate?: boolean\n) {\n const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n const entityData = JSON.parse(fileData);\n const entityId = entityData._id;\n const isValid = frodo.helper.script.validateScriptHooks(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await frodo.idm.config.putConfigEntity(entityId, entityData);\n } catch (putConfigEntityError) {\n printMessage(putConfigEntityError, 'error');\n printMessage(`Error: ${putConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>\n * @param baseDirectory export directory\n * @param validate validate script hooks\n */\nexport async function importAllRawConfigEntities(\n baseDirectory: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const files = await frodo.helper.utils.readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ path, content }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = frodo.helper.script.validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles.map((file) => {\n return frodo.idm.config.putConfigEntity(file.entityId, file.content);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Import all IDM configuration objects\n * @param baseDirectory import directory\n * @param entitiesFile JSON file that specifies the config entities to export/import\n * @param envFile File that defines environment specific variables for replacement during configuration export/import\n * @param validate validate script hooks\n */\nexport async function importAllConfigEntities(\n baseDirectory: string,\n entitiesFile: string,\n envFile: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const entriesToImport = JSON.parse(fs.readFileSync(entitiesFile, 'utf8')).idm;\n\n const envReader = propertiesReader(envFile);\n\n const files = await frodo.helper.utils.readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content, path }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = frodo.helper.script.validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles\n .filter(({ entityId }) => {\n return entriesToImport.includes(entityId);\n })\n .map(({ entityId, content }) => {\n const unsubstituted = frodo.helper.utils.unSubstituteEnvParams(\n content,\n envReader\n );\n return frodo.idm.config.putConfigEntity(entityId, unsubstituted);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Count number of managed objects of a given type\n * @param {String} type managed object type, e.g. alpha_user\n */\nexport async function countManagedObjects(type) {\n let count = 0;\n let result = {\n result: [],\n resultCount: 0,\n pagedResultsCookie: null,\n totalPagedResultsPolicy: 'NONE',\n totalPagedResults: -1,\n remainingPagedResults: -1,\n };\n try {\n do {\n result = await frodo.idm.config.queryAllManagedObjectsByType(\n type,\n [],\n result.pagedResultsCookie\n );\n count += result.resultCount;\n } while (result.pagedResultsCookie);\n printMessage(`${type}: ${count}`);\n } catch (error) {\n printMessage(error.response.data, 'error');\n printMessage(`Error querying managed objects by type: ${error}`, 'error');\n }\n}\n"],"mappings":"AAAA;AACA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAC1B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,gBAAgB,MAAM,mBAAmB;AAChD,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,KAAK,QAAQ,uBAAuB;AAC7C,SACEC,uBAAuB,EACvBC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,gBAAgB,QAAQ,4BAA4B;;AAE7D;AACA;AACA;AACA,OAAO,eAAeC,gCAAgCA,CAAA,EAAG;EACvD,IAAI;IACF,MAAMC,GAAG,GAAG,MAAMN,KAAK,CAACO,GAAG,CAACC,MAAM,CAACC,oBAAoB,CAAC,CAAC;IACzD,MAAMC,OAAO,GAAGJ,GAAG,CAChBK,MAAM,CAAEC,MAAM,IAAK,CAACA,MAAM,CAACC,EAAE,CAAC,CAC9BC,GAAG,CAAEF,MAAM,IAAKA,MAAM,CAACG,IAAI,CAAC;IAC/B,IAAIL,OAAO,CAACM,MAAM,EAAE;MAClBd,YAAY,CACT,wGAAuGQ,OAAO,CAACO,IAAI,CAClH,IACF,CAAE,EAAC,EACH,MACF,CAAC;IACH;EACF,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdhB,YAAY,CAACgB,KAAK,EAAE,OAAO,CAAC;IAC5BhB,YAAY,CACT,4CAA2CgB,KAAK,CAACC,OAAQ,EAAC,EAC3D,OACF,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeC,qBAAqBA,CAAA,EAAG;EAC5C,IAAI;IACF,MAAM;MAAEC;IAAe,CAAC,GAAG,MAAMrB,KAAK,CAACO,G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,KAAM,EAAC,CAAC;EACnC,CAAC,CAAC,OAAO/F,KAAK,EAAE;IACdhB,YAAY,CAACgB,KAAK,CAACmC,QAAQ,CAACC,IAAI,EAAE,OAAO,CAAC;IAC1CpD,YAAY,CAAE,2CAA0CgB,KAAM,EAAC,EAAE,OAAO,CAAC;EAC3E;AACF"}
|
|
1
|
+
{"version":3,"file":"IdmOps.js","names":["frodo","fs","fse","path","propertiesReader","replaceall","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","validateScriptHooks","helper","script","readFiles","unSubstituteEnvParams","utils","testConnectorServers","getAllConfigEntities","getConfigEntity","putConfigEntity","queryAllManagedObjectsByType","idm","config","warnAboutOfflineConnectorServers","all","offline","filter","status","ok","map","name","length","join","error","message","listAllConfigEntities","configurations","configEntity","_id","getAllConfigEntitiesError","exportConfigEntity","id","file","fileName","writeFile","JSON","stringify","err","exportAllRawConfigEntities","directory","existsSync","mkdirSync","undefined","entityPromises","push","catch","getConfigEntityError","_getConfigEntityError","_getConfigEntityError2","_getConfigEntityError3","_getConfigEntityError4","_getConfigEntityError5","_getConfigEntityError6","_getConfigEntityError7","_getConfigEntityError8","_getConfigEntityError9","response","data","includes","reason","_getConfigEntityError10","results","Promise","item","outputFile","exportAllConfigEntities","entitiesFile","envFile","entriesToExport","readFile","entriesData","parse","envParams","configEntityString","each","key","value","importConfigEntityByIdFromFile","entityId","validate","fileData","readFileSync","resolve","process","cwd","entityData","isValid","putConfigEntityError","importConfigEntityFromFile","importAllRawConfigEntities","baseDirectory","files","jsonFiles","toLowerCase","endsWith","content","substring","everyScriptValid","jsObject","isScriptValid","allSettled","errors","result","importAllConfigEntities","entriesToImport","envReader","unsubstituted","countManagedObjects","type","count","resultCount","pagedResultsCookie","totalPagedResultsPolicy","totalPagedResults","remainingPagedResults"],"sources":["ops/IdmOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\nimport {\n createProgressIndicator,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename } from '../utils/ExportImportUtils';\n\nconst { validateScriptHooks } = frodo.helper.script;\nconst { readFiles, unSubstituteEnvParams } = frodo.helper.utils;\nconst {\n testConnectorServers,\n getAllConfigEntities,\n getConfigEntity,\n putConfigEntity,\n queryAllManagedObjectsByType,\n} = frodo.idm.config;\n\n/**\n * Warn about and list offline remote connector servers\n */\nexport async function warnAboutOfflineConnectorServers() {\n try {\n const all = await testConnectorServers();\n const offline = all\n .filter((status) => !status.ok)\n .map((status) => status.name);\n if (offline.length) {\n printMessage(\n `\\nThe following connector server(s) are offline and their connectors and configuration unavailable:\\n${offline.join(\n '\\n'\n )}`,\n 'warn'\n );\n }\n } catch (error) {\n printMessage(error, 'error');\n printMessage(\n `Error getting offline connector servers: ${error.message}`,\n 'error'\n );\n }\n}\n\n/**\n * List all IDM configuration objects\n */\nexport async function listAllConfigEntities() {\n try {\n const { configurations } = await getAllConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export an IDM configuration object.\n * @param {String} id the desired configuration object\n * @param {String} file optional export file\n */\nexport async function exportConfigEntity(id, file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`${id}`, 'idm');\n }\n const configEntity = await getConfigEntity(id);\n fs.writeFile(fileName, JSON.stringify(configEntity, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${id} export to file`, 'error');\n }\n return '';\n });\n}\n\n/**\n * Export all IDM configuration objects into separate JSON files in a directory specified by <directory>\n * @param {String} directory export directory\n */\nexport async function exportAllRawConfigEntities(directory) {\n try {\n const { configurations } = await getAllConfigEntities();\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n entityPromises.push(\n getConfigEntity(configEntity._id).catch((getConfigEntityError) => {\n if (\n !(\n getConfigEntityError.response?.status === 403 &&\n getConfigEntityError.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n ) &&\n !(\n // list of config entities, which do not exist by default or ever.\n (\n [\n 'script',\n 'notificationFactory',\n 'apiVersion',\n 'metrics',\n 'repo.init',\n 'endpoint/validateQueryFilter',\n 'endpoint/oauthproxy',\n 'external.rest',\n 'scheduler',\n 'org.apache.felix.fileinstall/openidm',\n 'cluster',\n 'endpoint/mappingDetails',\n 'fieldPolicy/teammember',\n ].includes(configEntity._id) &&\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.reason === 'Not Found'\n )\n ) &&\n // https://bugster.forgerock.org/jira/browse/OPENIDM-18270\n !(\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.message ===\n 'No configuration exists for id org.apache.felix.fileinstall/openidm'\n )\n ) {\n printMessage(getConfigEntityError.response?.data, 'error');\n printMessage(\n `Error getting config entity ${configEntity._id}: ${getConfigEntityError}`,\n 'error'\n );\n }\n })\n );\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n fse.outputFile(\n `${directory}/${item._id}.json`,\n JSON.stringify(item, null, 2),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator('Exported config objects.', 'success');\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export all IDM configuration objects\n * @param {String} directory export directory\n * @param {String} entitiesFile JSON file that specifies the config entities to export/import\n * @param {String} envFile File that defines environment specific variables for replacement during configuration export/import\n */\nexport async function exportAllConfigEntities(\n directory,\n entitiesFile,\n envFile\n) {\n let entriesToExport = [];\n // read list of entities to export\n fs.readFile(entitiesFile, 'utf8', async (err, data) => {\n if (err) throw err;\n const entriesData = JSON.parse(data);\n entriesToExport = entriesData.idm;\n // console.log(`entriesToExport ${entriesToExport}`);\n\n // read list of configs to parameterize for environment specific values\n const envParams = propertiesReader(envFile);\n\n try {\n const { configurations } = await getAllConfigEntities();\n // create export directory if not exist\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(getConfigEntity(configEntity._id));\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n let configEntityString = JSON.stringify(item, null, 2);\n envParams.each((key, value) => {\n configEntityString = replaceall(\n value,\n `\\${${key}}`,\n configEntityString\n );\n });\n fse.outputFile(\n `${directory}/${item._id}.json`,\n configEntityString,\n (error) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${error}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator(null, 'success');\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n });\n}\n\n/**\n * Import an IDM configuration object by id from file.\n * @param entityId the configuration object to import\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityByIdFromFile(\n entityId: string,\n file?: string,\n validate?: boolean\n) {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n\n const entityData = JSON.parse(fileData);\n const isValid = validateScriptHooks(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await putConfigEntity(entityId, entityData);\n } catch (putConfigEntityError) {\n printMessage(putConfigEntityError, 'error');\n printMessage(`Error: ${putConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import IDM configuration object from file.\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityFromFile(\n file: string,\n validate?: boolean\n) {\n const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n const entityData = JSON.parse(fileData);\n const entityId = entityData._id;\n const isValid = validateScriptHooks(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await putConfigEntity(entityId, entityData);\n } catch (putConfigEntityError) {\n printMessage(putConfigEntityError, 'error');\n printMessage(`Error: ${putConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>\n * @param baseDirectory export directory\n * @param validate validate script hooks\n */\nexport async function importAllRawConfigEntities(\n baseDirectory: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ path, content }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles.map((file) => {\n return putConfigEntity(file.entityId, file.content);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Import all IDM configuration objects\n * @param baseDirectory import directory\n * @param entitiesFile JSON file that specifies the config entities to export/import\n * @param envFile File that defines environment specific variables for replacement during configuration export/import\n * @param validate validate script hooks\n */\nexport async function importAllConfigEntities(\n baseDirectory: string,\n entitiesFile: string,\n envFile: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const entriesToImport = JSON.parse(fs.readFileSync(entitiesFile, 'utf8')).idm;\n\n const envReader = propertiesReader(envFile);\n\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content, path }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles\n .filter(({ entityId }) => {\n return entriesToImport.includes(entityId);\n })\n .map(({ entityId, content }) => {\n const unsubstituted = unSubstituteEnvParams(content, envReader);\n return putConfigEntity(entityId, unsubstituted);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Count number of managed objects of a given type\n * @param {String} type managed object type, e.g. alpha_user\n */\nexport async function countManagedObjects(type) {\n let count = 0;\n let result = {\n result: [],\n resultCount: 0,\n pagedResultsCookie: null,\n totalPagedResultsPolicy: 'NONE',\n totalPagedResults: -1,\n remainingPagedResults: -1,\n };\n try {\n do {\n result = await queryAllManagedObjectsByType(\n type,\n [],\n result.pagedResultsCookie\n );\n count += result.resultCount;\n } while (result.pagedResultsCookie);\n printMessage(`${type}: ${count}`);\n } catch (error) {\n printMessage(error.response.data, 'error');\n printMessage(`Error querying managed objects by type: ${error}`, 'error');\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAC1B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,gBAAgB,MAAM,mBAAmB;AAChD,OAAOC,UAAU,MAAM,YAAY;AACnC,SACEC,uBAAuB,EACvBC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,gBAAgB,QAAQ,4BAA4B;AAE7D,MAAM;EAAEC;AAAoB,CAAC,GAAGV,KAAK,CAACW,MAAM,CAACC,MAAM;AACnD,MAAM;EAAEC,SAAS;EAAEC;AAAsB,CAAC,GAAGd,KAAK,CAACW,MAAM,CAACI,KAAK;AAC/D,MAAM;EACJC,oBAAoB;EACpBC,oBAAoB;EACpBC,eAAe;EACfC,eAAe;EACfC;AACF,CAAC,GAAGpB,KAAK,CAACqB,GAAG,CAACC,MAAM;;AAEpB;AACA;AACA;AACA,OAAO,eAAeC,gCAAgCA,CAAA,EAAG;EACvD,IAAI;IACF,MAAMC,GAAG,GAAG,MAAMR,oBAAoB,CAAC,CAAC;IACxC,MAAMS,OAAO,GAAGD,GAAG,CAChBE,MAAM,CAAEC,MAAM,IAAK,CAACA,MAAM,CAACC,EAAE,CAAC,CAC9BC,GAAG,CAAEF,M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