@rockcarver/frodo-cli 2.0.0-13 → 2.0.0-14
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 +9 -1
- package/esm/app.js +1 -1
- package/esm/app.js.map +1 -1
- package/esm/cli/FrodoCommand.js +3 -3
- package/esm/cli/FrodoCommand.js.map +1 -1
- package/esm/cli/_template/something-delete.js +2 -2
- package/esm/cli/_template/something-delete.js.map +1 -1
- package/esm/cli/_template/something-describe.js +2 -2
- package/esm/cli/_template/something-describe.js.map +1 -1
- package/esm/cli/_template/something-else-delete.js +2 -2
- package/esm/cli/_template/something-else-delete.js.map +1 -1
- package/esm/cli/_template/something-else-describe.js +2 -2
- package/esm/cli/_template/something-else-describe.js.map +1 -1
- package/esm/cli/_template/something-else-export.js +2 -2
- package/esm/cli/_template/something-else-export.js.map +1 -1
- package/esm/cli/_template/something-else-import.js +2 -2
- package/esm/cli/_template/something-else-import.js.map +1 -1
- package/esm/cli/_template/something-else-list.js +2 -2
- package/esm/cli/_template/something-else-list.js.map +1 -1
- package/esm/cli/_template/something-export.js +2 -2
- package/esm/cli/_template/something-export.js.map +1 -1
- package/esm/cli/_template/something-import.js +2 -2
- package/esm/cli/_template/something-import.js.map +1 -1
- package/esm/cli/_template/something-list.js +2 -2
- package/esm/cli/_template/something-list.js.map +1 -1
- package/esm/cli/_template/something-other-delete.js +2 -2
- package/esm/cli/_template/something-other-delete.js.map +1 -1
- package/esm/cli/_template/something-other-describe.js +2 -2
- package/esm/cli/_template/something-other-describe.js.map +1 -1
- package/esm/cli/_template/something-other-export.js +2 -2
- package/esm/cli/_template/something-other-export.js.map +1 -1
- package/esm/cli/_template/something-other-import.js +2 -2
- package/esm/cli/_template/something-other-import.js.map +1 -1
- package/esm/cli/_template/something-other-list.js +2 -2
- package/esm/cli/_template/something-other-list.js.map +1 -1
- package/esm/cli/_template/something.js +1 -1
- package/esm/cli/_template/something.js.map +1 -1
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js +1 -1
- 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 +3 -3
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-federation-export.js +2 -2
- package/esm/cli/admin/admin-federation-export.js.map +1 -1
- package/esm/cli/admin/admin-federation-import.js +2 -2
- package/esm/cli/admin/admin-federation-import.js.map +1 -1
- package/esm/cli/admin/admin-federation-list.js +2 -2
- package/esm/cli/admin/admin-federation-list.js.map +1 -1
- package/esm/cli/admin/admin-get-access-token.js +2 -2
- package/esm/cli/admin/admin-get-access-token.js.map +1 -1
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +2 -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 +2 -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 +1 -1
- 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 +1 -1
- 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 +2 -2
- package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
- package/esm/cli/admin/admin-remove-static-user-mapping.js +1 -1
- package/esm/cli/admin/admin-remove-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-repair-org-model.js +2 -2
- package/esm/cli/admin/admin-repair-org-model.js.map +1 -1
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +2 -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 +2 -2
- package/esm/cli/admin/admin-show-generic-extension-attributes.js.map +1 -1
- package/esm/cli/admin/admin.js +1 -1
- package/esm/cli/admin/admin.js.map +1 -1
- package/esm/cli/agent/agent-delete.js +2 -2
- package/esm/cli/agent/agent-delete.js.map +1 -1
- package/esm/cli/agent/agent-describe.js +2 -2
- package/esm/cli/agent/agent-describe.js.map +1 -1
- package/esm/cli/agent/agent-export.js +3 -3
- package/esm/cli/agent/agent-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-delete.js +2 -2
- package/esm/cli/agent/agent-gateway-delete.js.map +1 -1
- package/esm/cli/agent/agent-gateway-describe.js +2 -2
- package/esm/cli/agent/agent-gateway-describe.js.map +1 -1
- package/esm/cli/agent/agent-gateway-export.js +3 -3
- package/esm/cli/agent/agent-gateway-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-import.js +3 -3
- package/esm/cli/agent/agent-gateway-import.js.map +1 -1
- package/esm/cli/agent/agent-gateway-list.js +2 -2
- package/esm/cli/agent/agent-gateway-list.js.map +1 -1
- package/esm/cli/agent/agent-import.js +3 -3
- package/esm/cli/agent/agent-import.js.map +1 -1
- package/esm/cli/agent/agent-java-delete.js +2 -2
- package/esm/cli/agent/agent-java-delete.js.map +1 -1
- package/esm/cli/agent/agent-java-describe.js +2 -2
- package/esm/cli/agent/agent-java-describe.js.map +1 -1
- package/esm/cli/agent/agent-java-export.js +3 -3
- package/esm/cli/agent/agent-java-export.js.map +1 -1
- package/esm/cli/agent/agent-java-import.js +3 -3
- package/esm/cli/agent/agent-java-import.js.map +1 -1
- package/esm/cli/agent/agent-java-list.js +2 -2
- package/esm/cli/agent/agent-java-list.js.map +1 -1
- package/esm/cli/agent/agent-list.js +2 -2
- package/esm/cli/agent/agent-list.js.map +1 -1
- package/esm/cli/agent/agent-web-delete.js +2 -2
- package/esm/cli/agent/agent-web-delete.js.map +1 -1
- package/esm/cli/agent/agent-web-describe.js +2 -2
- package/esm/cli/agent/agent-web-describe.js.map +1 -1
- package/esm/cli/agent/agent-web-export.js +3 -3
- package/esm/cli/agent/agent-web-export.js.map +1 -1
- package/esm/cli/agent/agent-web-import.js +3 -3
- package/esm/cli/agent/agent-web-import.js.map +1 -1
- package/esm/cli/agent/agent-web-list.js +2 -2
- package/esm/cli/agent/agent-web-list.js.map +1 -1
- package/esm/cli/agent/agent.js +1 -1
- package/esm/cli/agent/agent.js.map +1 -1
- package/esm/cli/app/app-delete.js +2 -2
- package/esm/cli/app/app-delete.js.map +1 -1
- package/esm/cli/app/app-describe.js +2 -2
- package/esm/cli/app/app-describe.js.map +1 -1
- package/esm/cli/app/app-export.js +3 -3
- package/esm/cli/app/app-export.js.map +1 -1
- package/esm/cli/app/app-import.js +3 -3
- package/esm/cli/app/app-import.js.map +1 -1
- package/esm/cli/app/app-list.js +3 -3
- package/esm/cli/app/app-list.js.map +1 -1
- package/esm/cli/app/app.js +1 -1
- package/esm/cli/app/app.js.map +1 -1
- package/esm/cli/authz/authz-policy-delete.js +3 -3
- package/esm/cli/authz/authz-policy-delete.js.map +1 -1
- package/esm/cli/authz/authz-policy-describe.js +3 -3
- package/esm/cli/authz/authz-policy-describe.js.map +1 -1
- package/esm/cli/authz/authz-policy-export.js +3 -3
- package/esm/cli/authz/authz-policy-export.js.map +1 -1
- package/esm/cli/authz/authz-policy-import.js +2 -2
- package/esm/cli/authz/authz-policy-import.js.map +1 -1
- package/esm/cli/authz/authz-policy-list.js +3 -3
- package/esm/cli/authz/authz-policy-list.js.map +1 -1
- package/esm/cli/authz/authz-set-delete.js +3 -3
- package/esm/cli/authz/authz-set-delete.js.map +1 -1
- package/esm/cli/authz/authz-set-describe.js +3 -3
- package/esm/cli/authz/authz-set-describe.js.map +1 -1
- package/esm/cli/authz/authz-set-export.js +3 -3
- package/esm/cli/authz/authz-set-export.js.map +1 -1
- package/esm/cli/authz/authz-set-import.js +2 -2
- package/esm/cli/authz/authz-set-import.js.map +1 -1
- package/esm/cli/authz/authz-set-list.js +2 -2
- package/esm/cli/authz/authz-set-list.js.map +1 -1
- package/esm/cli/authz/authz-type-delete.js +3 -3
- package/esm/cli/authz/authz-type-delete.js.map +1 -1
- package/esm/cli/authz/authz-type-describe.js +3 -3
- package/esm/cli/authz/authz-type-describe.js.map +1 -1
- package/esm/cli/authz/authz-type-export.js +3 -3
- package/esm/cli/authz/authz-type-export.js.map +1 -1
- package/esm/cli/authz/authz-type-import.js +3 -3
- package/esm/cli/authz/authz-type-import.js.map +1 -1
- package/esm/cli/authz/authz-type-list.js +3 -3
- package/esm/cli/authz/authz-type-list.js.map +1 -1
- package/esm/cli/authz/authz.js +1 -1
- package/esm/cli/authz/authz.js.map +1 -1
- package/esm/cli/conn/conn-delete.js +1 -1
- package/esm/cli/conn/conn-delete.js.map +1 -1
- package/esm/cli/conn/conn-describe.js +1 -1
- package/esm/cli/conn/conn-describe.js.map +1 -1
- package/esm/cli/conn/conn-list.js +1 -1
- package/esm/cli/conn/conn-list.js.map +1 -1
- package/esm/cli/conn/conn-save.js +4 -4
- package/esm/cli/conn/conn-save.js.map +1 -1
- package/esm/cli/conn/conn.js +1 -1
- package/esm/cli/conn/conn.js.map +1 -1
- package/esm/cli/email/email-template-export.js +3 -3
- package/esm/cli/email/email-template-export.js.map +1 -1
- package/esm/cli/email/email-template-import.js +3 -3
- package/esm/cli/email/email-template-import.js.map +1 -1
- package/esm/cli/email/email-template-list.js +3 -3
- package/esm/cli/email/email-template-list.js.map +1 -1
- package/esm/cli/email/email.js +1 -1
- package/esm/cli/email/email.js.map +1 -1
- package/esm/cli/esv/esv-apply.js +2 -2
- package/esm/cli/esv/esv-apply.js.map +1 -1
- package/esm/cli/esv/esv-secret-create.js +3 -3
- package/esm/cli/esv/esv-secret-create.js.map +1 -1
- package/esm/cli/esv/esv-secret-delete.js +3 -3
- package/esm/cli/esv/esv-secret-delete.js.map +1 -1
- package/esm/cli/esv/esv-secret-describe.js +3 -3
- package/esm/cli/esv/esv-secret-describe.js.map +1 -1
- package/esm/cli/esv/esv-secret-export.js +2 -2
- package/esm/cli/esv/esv-secret-export.js.map +1 -1
- package/esm/cli/esv/esv-secret-import.js +2 -2
- package/esm/cli/esv/esv-secret-import.js.map +1 -1
- package/esm/cli/esv/esv-secret-list.js +3 -3
- package/esm/cli/esv/esv-secret-list.js.map +1 -1
- package/esm/cli/esv/esv-secret-set.js +3 -3
- package/esm/cli/esv/esv-secret-set.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-activate.js +3 -3
- package/esm/cli/esv/esv-secret-version-activate.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-create.js +4 -4
- package/esm/cli/esv/esv-secret-version-create.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-deactivate.js +3 -3
- package/esm/cli/esv/esv-secret-version-deactivate.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-delete.js +3 -3
- package/esm/cli/esv/esv-secret-version-delete.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-list.js +3 -3
- package/esm/cli/esv/esv-secret-version-list.js.map +1 -1
- package/esm/cli/esv/esv-variable-create.js +3 -3
- package/esm/cli/esv/esv-variable-create.js.map +1 -1
- package/esm/cli/esv/esv-variable-delete.js +3 -3
- package/esm/cli/esv/esv-variable-delete.js.map +1 -1
- package/esm/cli/esv/esv-variable-describe.js +3 -3
- package/esm/cli/esv/esv-variable-describe.js.map +1 -1
- package/esm/cli/esv/esv-variable-export.js +2 -2
- package/esm/cli/esv/esv-variable-export.js.map +1 -1
- package/esm/cli/esv/esv-variable-import.js +2 -2
- package/esm/cli/esv/esv-variable-import.js.map +1 -1
- package/esm/cli/esv/esv-variable-list.js +3 -3
- package/esm/cli/esv/esv-variable-list.js.map +1 -1
- package/esm/cli/esv/esv-variable-set.js +2 -2
- package/esm/cli/esv/esv-variable-set.js.map +1 -1
- package/esm/cli/esv/esv.js +1 -1
- package/esm/cli/esv/esv.js.map +1 -1
- package/esm/cli/idm/idm-count.js +3 -3
- package/esm/cli/idm/idm-count.js.map +1 -1
- package/esm/cli/idm/idm-export.js +3 -3
- package/esm/cli/idm/idm-export.js.map +1 -1
- package/esm/cli/idm/idm-import.js +3 -3
- package/esm/cli/idm/idm-import.js.map +1 -1
- package/esm/cli/idm/idm-list.js +2 -2
- package/esm/cli/idm/idm-list.js.map +1 -1
- package/esm/cli/idm/idm.js +1 -1
- package/esm/cli/idm/idm.js.map +1 -1
- package/esm/cli/idp/idp-export.js +6 -6
- package/esm/cli/idp/idp-export.js.map +1 -1
- package/esm/cli/idp/idp-import.js +7 -7
- package/esm/cli/idp/idp-import.js.map +1 -1
- package/esm/cli/idp/idp-list.js +2 -2
- package/esm/cli/idp/idp-list.js.map +1 -1
- package/esm/cli/idp/idp.js +1 -1
- package/esm/cli/idp/idp.js.map +1 -1
- package/esm/cli/info/info.js +3 -3
- package/esm/cli/info/info.js.map +1 -1
- package/esm/cli/journey/journey-delete.js +2 -2
- package/esm/cli/journey/journey-delete.js.map +1 -1
- package/esm/cli/journey/journey-describe.js +5 -5
- package/esm/cli/journey/journey-describe.js.map +1 -1
- package/esm/cli/journey/journey-disable.js +3 -3
- package/esm/cli/journey/journey-disable.js.map +1 -1
- package/esm/cli/journey/journey-enable.js +3 -3
- package/esm/cli/journey/journey-enable.js.map +1 -1
- package/esm/cli/journey/journey-export.js +3 -3
- package/esm/cli/journey/journey-export.js.map +1 -1
- package/esm/cli/journey/journey-import.js +3 -3
- package/esm/cli/journey/journey-import.js.map +1 -1
- package/esm/cli/journey/journey-list.js +1 -1
- package/esm/cli/journey/journey-list.js.map +1 -1
- package/esm/cli/journey/journey-prune.js +15 -11
- package/esm/cli/journey/journey-prune.js.map +1 -1
- package/esm/cli/journey/journey.js +1 -1
- package/esm/cli/journey/journey.js.map +1 -1
- package/esm/cli/log/log-fetch.js +4 -4
- package/esm/cli/log/log-fetch.js.map +1 -1
- package/esm/cli/log/log-key-delete.js +3 -3
- package/esm/cli/log/log-key-delete.js.map +1 -1
- package/esm/cli/log/log-key-describe.js +2 -2
- package/esm/cli/log/log-key-describe.js.map +1 -1
- package/esm/cli/log/log-key-list.js +2 -2
- package/esm/cli/log/log-key-list.js.map +1 -1
- package/esm/cli/log/log-list.js +2 -2
- package/esm/cli/log/log-list.js.map +1 -1
- package/esm/cli/log/log-tail.js +4 -4
- package/esm/cli/log/log-tail.js.map +1 -1
- package/esm/cli/log/log.js +1 -1
- package/esm/cli/log/log.js.map +1 -1
- package/esm/cli/realm/realm-add-custom-domain.js +3 -3
- package/esm/cli/realm/realm-add-custom-domain.js.map +1 -1
- package/esm/cli/realm/realm-describe.js +2 -2
- package/esm/cli/realm/realm-describe.js.map +1 -1
- package/esm/cli/realm/realm-list.js +3 -3
- package/esm/cli/realm/realm-list.js.map +1 -1
- package/esm/cli/realm/realm-remove-custom-domain.js +2 -2
- package/esm/cli/realm/realm-remove-custom-domain.js.map +1 -1
- package/esm/cli/realm/realm.js +1 -1
- package/esm/cli/realm/realm.js.map +1 -1
- package/esm/cli/saml/saml-cot-export.js +3 -3
- package/esm/cli/saml/saml-cot-export.js.map +1 -1
- package/esm/cli/saml/saml-cot-import.js +3 -3
- package/esm/cli/saml/saml-cot-import.js.map +1 -1
- package/esm/cli/saml/saml-cot-list.js +3 -3
- package/esm/cli/saml/saml-cot-list.js.map +1 -1
- package/esm/cli/saml/saml-delete.js +2 -2
- package/esm/cli/saml/saml-delete.js.map +1 -1
- package/esm/cli/saml/saml-describe.js +3 -3
- package/esm/cli/saml/saml-describe.js.map +1 -1
- package/esm/cli/saml/saml-export.js +3 -3
- package/esm/cli/saml/saml-export.js.map +1 -1
- package/esm/cli/saml/saml-import.js +3 -3
- package/esm/cli/saml/saml-import.js.map +1 -1
- package/esm/cli/saml/saml-list.js +3 -3
- package/esm/cli/saml/saml-list.js.map +1 -1
- package/esm/cli/saml/saml-metadata-export.js +3 -3
- package/esm/cli/saml/saml-metadata-export.js.map +1 -1
- package/esm/cli/saml/saml.js +1 -1
- package/esm/cli/saml/saml.js.map +1 -1
- package/esm/cli/script/script-delete.js +2 -2
- package/esm/cli/script/script-delete.js.map +1 -1
- package/esm/cli/script/script-describe.js +2 -2
- package/esm/cli/script/script-describe.js.map +1 -1
- package/esm/cli/script/script-export.js +3 -3
- package/esm/cli/script/script-export.js.map +1 -1
- package/esm/cli/script/script-import.js +3 -3
- package/esm/cli/script/script-import.js.map +1 -1
- package/esm/cli/script/script-list.js +3 -3
- package/esm/cli/script/script-list.js.map +1 -1
- package/esm/cli/script/script.js +1 -1
- package/esm/cli/script/script.js.map +1 -1
- package/esm/cli/service/service-delete.js +2 -2
- package/esm/cli/service/service-delete.js.map +1 -1
- package/esm/cli/service/service-export.js +2 -2
- package/esm/cli/service/service-export.js.map +1 -1
- package/esm/cli/service/service-import.js +2 -2
- package/esm/cli/service/service-import.js.map +1 -1
- package/esm/cli/service/service-list.js +2 -2
- package/esm/cli/service/service-list.js.map +1 -1
- package/esm/cli/service/service.js +1 -1
- package/esm/cli/service/service.js.map +1 -1
- package/esm/cli/shell/shell.js +7 -7
- package/esm/cli/shell/shell.js.map +1 -1
- package/esm/cli/theme/theme-delete.js +3 -3
- package/esm/cli/theme/theme-delete.js.map +1 -1
- package/esm/cli/theme/theme-export.js +3 -3
- package/esm/cli/theme/theme-export.js.map +1 -1
- package/esm/cli/theme/theme-import.js +3 -3
- package/esm/cli/theme/theme-import.js.map +1 -1
- package/esm/cli/theme/theme-list.js +2 -2
- package/esm/cli/theme/theme-list.js.map +1 -1
- package/esm/cli/theme/theme.js +1 -1
- package/esm/cli/theme/theme.js.map +1 -1
- package/esm/loader.js +1 -1
- package/esm/loader.js.map +1 -1
- package/esm/ops/AdminFederationOps.js +3 -3
- package/esm/ops/AdminFederationOps.js.map +1 -1
- package/esm/ops/AgentOps.js +13 -13
- package/esm/ops/AgentOps.js.map +1 -1
- package/esm/ops/CirclesOfTrustOps.js +4 -4
- package/esm/ops/CirclesOfTrustOps.js.map +1 -1
- package/esm/ops/ConnectionProfileOps.js +1 -1
- package/esm/ops/ConnectionProfileOps.js.map +1 -1
- package/esm/ops/EmailTemplateOps.js +42 -44
- package/esm/ops/EmailTemplateOps.js.map +1 -1
- package/esm/ops/IdmOps.js +40 -56
- package/esm/ops/IdmOps.js.map +1 -1
- package/esm/ops/IdpOps.js +29 -26
- package/esm/ops/IdpOps.js.map +1 -1
- package/esm/ops/JourneyOps.js +42 -17
- package/esm/ops/JourneyOps.js.map +1 -1
- package/esm/ops/LogOps.js.map +1 -1
- package/esm/ops/NodeOps.js.map +1 -1
- package/esm/ops/OAuth2ClientOps.js +3 -3
- package/esm/ops/OAuth2ClientOps.js.map +1 -1
- package/esm/ops/OrganizationOps.js +9 -23
- package/esm/ops/OrganizationOps.js.map +1 -1
- package/esm/ops/PolicyOps.js +10 -10
- package/esm/ops/PolicyOps.js.map +1 -1
- package/esm/ops/PolicySetOps.js +9 -9
- package/esm/ops/PolicySetOps.js.map +1 -1
- package/esm/ops/RealmOps.js +9 -9
- package/esm/ops/RealmOps.js.map +1 -1
- package/esm/ops/ResourceTypeOps.js +8 -8
- package/esm/ops/ResourceTypeOps.js.map +1 -1
- package/esm/ops/Saml2Ops.js +25 -30
- package/esm/ops/Saml2Ops.js.map +1 -1
- package/esm/ops/ScriptOps.js +6 -5
- package/esm/ops/ScriptOps.js.map +1 -1
- package/esm/ops/SecretsOps.js +18 -17
- package/esm/ops/SecretsOps.js.map +1 -1
- package/esm/ops/ServiceOps.js +1 -1
- package/esm/ops/ServiceOps.js.map +1 -1
- package/esm/ops/ThemeOps.js +18 -18
- package/esm/ops/ThemeOps.js.map +1 -1
- package/esm/ops/VariablesOps.js +9 -12
- package/esm/ops/VariablesOps.js.map +1 -1
- package/esm/utils/Config.js.map +1 -1
- package/esm/utils/Console.js +3 -2
- package/esm/utils/Console.js.map +1 -1
- package/esm/utils/ExportImportUtils.js +2 -2
- package/esm/utils/ExportImportUtils.js.map +1 -1
- package/esm/utils/Version.js +3 -3
- package/esm/utils/Version.js.map +1 -1
- package/package.json +5 -3
package/esm/ops/IdmOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdmOps.js","names":["frodo","fs","fse","path","propertiesReader","replaceall","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","readFiles","unSubstituteEnvParams","validateScriptHooks","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":["../../src/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, readFiles } from '../utils/ExportImportUtils';\n\nconst { unSubstituteEnvParams, validateScriptHooks } = frodo.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,EAAEC,SAAS,QAAQ,4BAA4B;AAExE,MAAM;EAAEC,qBAAqB;EAAEC;AAAoB,CAAC,GAAGZ,KAAK,CAACa,KAAK;AAClE,MAAM;EACJC,oBAAoB;EACpBC,oBAAoB;EACpBC,eAAe;EACfC,eAAe;EACfC;AACF,CAAC,GAAGlB,KAAK,CAACmB,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,MAAM,IAAKA,MAAM,CAACG,IAAI,CAAC;IAC/B,IAAIL,OAAO,CAACM,MAAM,EAAE;MAClBtB,YAAY,CACT,wGAAuGgB,OAAO,CAACO,IAAI,CAClH,IACF,CAAE,EAAC,EACH,MACF,CAAC;IACH;EACF,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdxB,YAAY,CAACwB,KAAK,EAAE,OAAO,CAAC;IAC5BxB,YAAY,CACT,4CAA2CwB,KAAK,CAACC,OAAQ,EAAC,EAC3D,OACF,CAAC;EACH;AAC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,qBAAqB,CAClB,oBAAmBqG,MAAM,CAAChF,MAAO,iBAAgB,EAClD,OACF,CAAC;IACD;EACF;EAEArB,qBAAqB,CAAE,YAAW6D,OAAO,CAACxC,MAAO,iBAAgB,EAAE,SAAS,CAAC;AAC/E;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAesF,mBAAmBA,CAACC,IAAI,EAAE;EAC9C,IAAIC,KAAK,GAAG,CAAC;EACb,IAAIP,MAAM,GAAG;IACXA,MAAM,EAAE,EAAE;IACVQ,WAAW,EAAE,CAAC;IACdC,kBAAkB,EAAE,IAAI;IACxBC,uBAAuB,EAAE,MAAM;IAC/BC,iBAAiB,EAAE,CAAC,CAAC;IACrBC,qBAAqB,EAAE,CAAC;EAC1B,CAAC;EACD,IAAI;IACF,GAAG;MACDZ,MAAM,GAAG,MAAM5F,4BAA4B,CACzCkG,IAAI,EACJ,EAAE,EACFN,MAAM,CAACS,kBACT,CAAC;MACDF,KAAK,IAAIP,MAAM,CAACQ,WAAW;IAC7B,CAAC,QAAQR,MAAM,CAACS,kBAAkB;IAClChH,YAAY,CAAE,GAAE6G,IAAK,KAAIC,KAAM,EAAC,CAAC;EACnC,CAAC,CAAC,OAAOtF,KAAK,EAAE;IACdxB,YAAY,CAACwB,KAAK,CAACiC,QAAQ,CAACC,IAAI,EAAE,OAAO,CAAC;IAC1C1D,YAAY,CAAE,2CAA0CwB,KAAM,EAAC,EAAE,OAAO,CAAC;EAC3E;AACF"}
|
|
1
|
+
{"version":3,"file":"IdmOps.js","names":["frodo","fs","fse","path","propertiesReader","replaceall","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","readFiles","unSubstituteEnvParams","validateScriptHooks","utils","testConnectorServers","readConfigEntities","readConfigEntity","updateConfigEntity","idm","config","queryManagedObjects","managed","warnAboutOfflineConnectorServers","all","offline","filter","status","ok","map","name","length","join","error","message","listAllConfigEntities","configurations","configEntity","_id","readConfigEntitiesError","exportConfigEntity","id","file","fileName","writeFile","JSON","stringify","err","exportAllRawConfigEntities","directory","existsSync","mkdirSync","undefined","entityPromises","push","catch","readConfigEntityError","_readConfigEntityErro","_readConfigEntityErro2","_readConfigEntityErro3","_readConfigEntityErro4","_readConfigEntityErro5","_readConfigEntityErro6","_readConfigEntityErro7","_readConfigEntityErro8","_readConfigEntityErro9","response","data","includes","reason","_readConfigEntityErro10","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","updateConfigEntityError","importConfigEntityFromFile","importAllRawConfigEntities","baseDirectory","files","jsonFiles","toLowerCase","endsWith","content","substring","everyScriptValid","jsObject","isScriptValid","allSettled","errors","result","importAllConfigEntities","entriesToImport","envReader","unsubstituted","countManagedObjects","type"],"sources":["../../src/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';\n\nimport {\n createProgressIndicator,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename, readFiles } from '../utils/ExportImportUtils';\n\nconst { unSubstituteEnvParams, validateScriptHooks } = frodo.utils;\nconst {\n testConnectorServers,\n readConfigEntities,\n readConfigEntity,\n updateConfigEntity,\n} = frodo.idm.config;\nconst { queryManagedObjects } = frodo.idm.managed;\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 readConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n } catch (readConfigEntitiesError) {\n printMessage(readConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${readConfigEntitiesError}`,\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 readConfigEntity(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 readConfigEntities();\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 readConfigEntity(configEntity._id).catch((readConfigEntityError) => {\n if (\n !(\n readConfigEntityError.response?.status === 403 &&\n readConfigEntityError.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 readConfigEntityError.response?.status === 404 &&\n readConfigEntityError.response?.data?.reason === 'Not Found'\n )\n ) &&\n // https://bugster.forgerock.org/jira/browse/OPENIDM-18270\n !(\n readConfigEntityError.response?.status === 404 &&\n readConfigEntityError.response?.data?.message ===\n 'No configuration exists for id org.apache.felix.fileinstall/openidm'\n )\n ) {\n printMessage(readConfigEntityError.response?.data, 'error');\n printMessage(\n `Error getting config entity ${configEntity._id}: ${readConfigEntityError}`,\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 (readConfigEntitiesError) {\n printMessage(readConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${readConfigEntitiesError}`,\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 readConfigEntities();\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(readConfigEntity(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 (readConfigEntitiesError) {\n printMessage(readConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${readConfigEntitiesError}`,\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 updateConfigEntity(entityId, entityData);\n } catch (updateConfigEntityError) {\n printMessage(updateConfigEntityError, 'error');\n printMessage(`Error: ${updateConfigEntityError}`, '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 updateConfigEntity(entityId, entityData);\n } catch (updateConfigEntityError) {\n printMessage(updateConfigEntityError, 'error');\n printMessage(`Error: ${updateConfigEntityError}`, '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 updateConfigEntity(file.entityId, JSON.parse(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 updateConfigEntity(entityId, JSON.parse(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: string) {\n try {\n const result = await queryManagedObjects(type);\n printMessage(`${type}: ${result.length}`);\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;AAEnC,SACEC,uBAAuB,EACvBC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,4BAA4B;AAExE,MAAM;EAAEC,qBAAqB;EAAEC;AAAoB,CAAC,GA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AK,EAAE;IACdzB,YAAY,CAACyB,KAAK,CAACiC,QAAQ,CAACC,IAAI,EAAE,OAAO,CAAC;IAC1C3D,YAAY,CAAE,2CAA0CyB,KAAM,EAAC,EAAE,OAAO,CAAC;EAC3E;AACF"}
|
package/esm/ops/IdpOps.js
CHANGED
|
@@ -3,12 +3,12 @@ import fs from 'fs';
|
|
|
3
3
|
import { createProgressBar, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
|
|
4
4
|
import { getRealmString, getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
|
|
5
5
|
const {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
readSocialIdentityProviders,
|
|
7
|
+
exportSocialIdentityProvider,
|
|
8
|
+
exportSocialIdentityProviders,
|
|
9
|
+
importFirstSocialIdentityProvider,
|
|
10
|
+
importSocialIdentityProvider,
|
|
11
|
+
importSocialIdentityProviders
|
|
12
12
|
} = frodo.oauth2oidc.external;
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -47,7 +47,7 @@ export function getTableRowMd(socialIdpObj) {
|
|
|
47
47
|
*/
|
|
48
48
|
export async function listSocialProviders() {
|
|
49
49
|
try {
|
|
50
|
-
const providers = await
|
|
50
|
+
const providers = await readSocialIdentityProviders();
|
|
51
51
|
providers.sort((a, b) => a._id.localeCompare(b._id));
|
|
52
52
|
providers.forEach(socialIdentityProvider => {
|
|
53
53
|
printMessage(`${socialIdentityProvider._id}`, 'data');
|
|
@@ -63,8 +63,8 @@ export async function listSocialProviders() {
|
|
|
63
63
|
* @param {string} providerId provider id/name
|
|
64
64
|
* @param {string} file optional export file name
|
|
65
65
|
*/
|
|
66
|
-
export async function
|
|
67
|
-
debugMessage(`cli.IdpOps.
|
|
66
|
+
export async function exportSocialIdentityProviderToFile(providerId, file = '') {
|
|
67
|
+
debugMessage(`cli.IdpOps.exportSocialIdentityProviderToFile: start`);
|
|
68
68
|
let fileName = file;
|
|
69
69
|
if (!fileName) {
|
|
70
70
|
fileName = getTypedFilename(providerId, 'idp');
|
|
@@ -72,41 +72,41 @@ export async function exportSocialProviderToFile(providerId, file = '') {
|
|
|
72
72
|
createProgressBar(1, `Exporting ${providerId}`);
|
|
73
73
|
try {
|
|
74
74
|
updateProgressBar(`Writing file ${fileName}`);
|
|
75
|
-
const fileData = await
|
|
75
|
+
const fileData = await exportSocialIdentityProvider(providerId);
|
|
76
76
|
saveJsonToFile(fileData, fileName);
|
|
77
77
|
stopProgressBar(`Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`);
|
|
78
78
|
} catch (err) {
|
|
79
79
|
stopProgressBar(`${err}`);
|
|
80
80
|
printMessage(`${err}`, 'error');
|
|
81
81
|
}
|
|
82
|
-
debugMessage(`cli.IdpOps.
|
|
82
|
+
debugMessage(`cli.IdpOps.exportSocialIdentityProviderToFile: end`);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
86
|
* Export all providers
|
|
87
87
|
* @param {string} file optional export file name
|
|
88
88
|
*/
|
|
89
|
-
export async function
|
|
89
|
+
export async function exportSocialIdentityProvidersToFile(file = '') {
|
|
90
90
|
let fileName = file;
|
|
91
91
|
if (!fileName) {
|
|
92
92
|
fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');
|
|
93
93
|
}
|
|
94
|
-
const fileData = await
|
|
94
|
+
const fileData = await exportSocialIdentityProviders();
|
|
95
95
|
saveJsonToFile(fileData, fileName);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* Export all providers to individual files
|
|
100
100
|
*/
|
|
101
|
-
export async function
|
|
102
|
-
debugMessage(`cli.IdpOps.
|
|
101
|
+
export async function exportSocialIdentityProvidersToFiles() {
|
|
102
|
+
debugMessage(`cli.IdpOps.exportSocialIdentityProvidersToFiles: start`);
|
|
103
103
|
try {
|
|
104
|
-
const allIdpsData = await
|
|
104
|
+
const allIdpsData = await readSocialIdentityProviders();
|
|
105
105
|
createProgressBar(allIdpsData.length, 'Exporting providers');
|
|
106
106
|
for (const idpData of allIdpsData) {
|
|
107
107
|
try {
|
|
108
108
|
const fileName = getTypedFilename(idpData._id, 'idp');
|
|
109
|
-
const fileData = await
|
|
109
|
+
const fileData = await exportSocialIdentityProvider(idpData._id);
|
|
110
110
|
saveJsonToFile(fileData, fileName);
|
|
111
111
|
updateProgressBar(`Exported provider ${idpData._id}`);
|
|
112
112
|
} catch (error) {
|
|
@@ -118,7 +118,7 @@ export async function exportSocialProvidersToFiles() {
|
|
|
118
118
|
stopProgressBar(`${error}`);
|
|
119
119
|
printMessage(`${error}`, 'error');
|
|
120
120
|
}
|
|
121
|
-
debugMessage(`cli.IdpOps.
|
|
121
|
+
debugMessage(`cli.IdpOps.exportSocialIdentityProvidersToFiles: end`);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
/**
|
|
@@ -127,14 +127,15 @@ export async function exportSocialProvidersToFiles() {
|
|
|
127
127
|
* @param {string} file import file name
|
|
128
128
|
* @returns {Promise<boolean>} true if provider was imported successfully, false otherwise
|
|
129
129
|
*/
|
|
130
|
-
export async function
|
|
130
|
+
export async function importSocialIdentityProviderFromFile(providerId, file) {
|
|
131
131
|
let outcome = false;
|
|
132
132
|
showSpinner(`Importing provider ${providerId} from ${file}...`);
|
|
133
133
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
134
134
|
if (err) throw err;
|
|
135
135
|
try {
|
|
136
136
|
const fileData = JSON.parse(data);
|
|
137
|
-
|
|
137
|
+
await importSocialIdentityProvider(providerId, fileData);
|
|
138
|
+
outcome = true;
|
|
138
139
|
succeedSpinner(`Successfully imported provider ${providerId} from ${file}.`);
|
|
139
140
|
} catch (error) {
|
|
140
141
|
var _error$response;
|
|
@@ -150,14 +151,15 @@ export async function importSocialProviderFromFile(providerId, file) {
|
|
|
150
151
|
* @param {String} file import file name
|
|
151
152
|
* @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise
|
|
152
153
|
*/
|
|
153
|
-
export async function
|
|
154
|
+
export async function importFirstSocialIdentityProviderFromFile(file) {
|
|
154
155
|
let outcome = false;
|
|
155
156
|
showSpinner(`Importing first provider from ${file}...`);
|
|
156
157
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
157
158
|
if (err) throw err;
|
|
158
159
|
try {
|
|
159
160
|
const fileData = JSON.parse(data);
|
|
160
|
-
|
|
161
|
+
await importFirstSocialIdentityProvider(fileData);
|
|
162
|
+
outcome = true;
|
|
161
163
|
succeedSpinner(`Successfully imported first provider from ${file}.`);
|
|
162
164
|
} catch (error) {
|
|
163
165
|
var _error$response2;
|
|
@@ -173,14 +175,15 @@ export async function importFirstSocialProviderFromFile(file) {
|
|
|
173
175
|
* @param {string} file import file name
|
|
174
176
|
* @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise
|
|
175
177
|
*/
|
|
176
|
-
export async function
|
|
178
|
+
export async function importSocialIdentityProvidersFromFile(file) {
|
|
177
179
|
let outcome = false;
|
|
178
180
|
showSpinner(`Importing providers from ${file}...`);
|
|
179
181
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
180
182
|
if (err) throw err;
|
|
181
183
|
try {
|
|
182
184
|
const fileData = JSON.parse(data);
|
|
183
|
-
|
|
185
|
+
await importSocialIdentityProviders(fileData);
|
|
186
|
+
outcome = true;
|
|
184
187
|
succeedSpinner(`Successfully imported providers from ${file}.`);
|
|
185
188
|
} catch (error) {
|
|
186
189
|
var _error$response3;
|
|
@@ -194,7 +197,7 @@ export async function importSocialProvidersFromFile(file) {
|
|
|
194
197
|
/**
|
|
195
198
|
* Import providers from *.idp.json files in current working directory
|
|
196
199
|
*/
|
|
197
|
-
export async function
|
|
200
|
+
export async function importSocialIdentityProvidersFromFiles() {
|
|
198
201
|
const names = fs.readdirSync('.');
|
|
199
202
|
const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.idp.json'));
|
|
200
203
|
createProgressBar(jsonFiles.length, 'Importing providers...');
|
|
@@ -204,7 +207,7 @@ export async function importSocialProvidersFromFiles() {
|
|
|
204
207
|
const fileData = JSON.parse(data);
|
|
205
208
|
const count = Object.keys(fileData.idp).length;
|
|
206
209
|
total += count;
|
|
207
|
-
await
|
|
210
|
+
await importSocialIdentityProviders(fileData);
|
|
208
211
|
updateProgressBar(`Imported ${count} provider(s) from ${file}`);
|
|
209
212
|
}
|
|
210
213
|
stopProgressBar(`Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`);
|
package/esm/ops/IdpOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdpOps.js","names":["frodo","fs","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getRealmString","getTypedFilename","saveJsonToFile","getSocialIdentityProviders","exportSocialProvider","exportSocialProviders","importFirstSocialProvider","importSocialProvider","importSocialProviders","oauth2oidc","external","getOneLineDescription","socialIdpObj","description","_id","_type","getTableHeaderMd","markdown","getTableRowMd","row","enabled","name","listSocialProviders","providers","sort","a","b","localeCompare","forEach","socialIdentityProvider","err","message","exportSocialProviderToFile","providerId","file","fileName","fileData","exportSocialProvidersToFile","exportSocialProvidersToFiles","allIdpsData","length","idpData","error","importSocialProviderFromFile","outcome","readFile","data","JSON","parse","_error$response","response","importFirstSocialProviderFromFile","_error$response2","importSocialProvidersFromFile","_error$response3","importSocialProvidersFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","total","readFileSync","count","Object","keys","idp"],"sources":["../../src/ops/IdpOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport type { SocialIdpSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport {\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n} from '../utils/ExportImportUtils';\n\nconst {\n getSocialIdentityProviders,\n exportSocialProvider,\n exportSocialProviders,\n importFirstSocialProvider,\n importSocialProvider,\n importSocialProviders,\n} = frodo.oauth2oidc.external;\n\n/**\n * Get a one-line description of the social idp object\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(socialIdpObj: SocialIdpSkeleton): string {\n const description = `[${socialIdpObj._id['brightCyan']}] ${socialIdpObj._type._id}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Type |\\n';\n markdown += '| ------- | ------ | ---- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the social idp in markdown\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a table-row of the social idp in markdown\n */\nexport function getTableRowMd(socialIdpObj: SocialIdpSkeleton): string {\n const row = `| ${socialIdpObj._id} | ${\n socialIdpObj.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n } | ${socialIdpObj._type.name} |`;\n return row;\n}\n\n/**\n * List providers\n */\nexport async function listSocialProviders() {\n try {\n const providers = await getSocialIdentityProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n } catch (err) {\n printMessage(`listSocialProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n */\nexport async function exportSocialProviderToFile(\n providerId: string,\n file = ''\n) {\n debugMessage(`cli.IdpOps.exportSocialProviderToFile: start`);\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'idp');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await exportSocialProvider(providerId);\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialProviderToFile: end`);\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n */\nexport async function exportSocialProvidersToFile(file = '') {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');\n }\n const fileData = await exportSocialProviders();\n saveJsonToFile(fileData, fileName);\n}\n\n/**\n * Export all providers to individual files\n */\nexport async function exportSocialProvidersToFiles() {\n debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: start`);\n try {\n const allIdpsData = await getSocialIdentityProviders();\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n try {\n const fileName = getTypedFilename(idpData._id, 'idp');\n const fileData = await exportSocialProvider(idpData._id);\n saveJsonToFile(fileData, fileName);\n updateProgressBar(`Exported provider ${idpData._id}`);\n } catch (error) {\n printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');\n }\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n } catch (error) {\n stopProgressBar(`${error}`);\n printMessage(`${error}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: end`);\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if provider was imported successfully, false otherwise\n */\nexport async function importSocialProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing provider ${providerId} from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await importSocialProvider(providerId, fileData);\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise\n */\nexport async function importFirstSocialProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing first provider from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await importFirstSocialProvider(fileData);\n succeedSpinner(`Successfully imported first provider from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing first provider from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise\n */\nexport async function importSocialProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing providers from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await importSocialProviders(fileData);\n succeedSpinner(`Successfully imported providers from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing providers from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n */\nexport async function importSocialProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.idp.json')\n );\n\n createProgressBar(jsonFiles.length, 'Importing providers...');\n let total = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await importSocialProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,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CAAEtC,IAAI,IAClCA,IAAI,CAACuC,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,WAAW,CACzC,CAAC;EAEDrE,iBAAiB,CAACkE,SAAS,CAAClB,MAAM,EAAE,wBAAwB,CAAC;EAC7D,IAAIsB,KAAK,GAAG,CAAC;EACb,KAAK,MAAM5B,IAAI,IAAIwB,SAAS,EAAE;IAC5B,MAAMZ,IAAI,GAAGvD,EAAE,CAACwE,YAAY,CAAC7B,IAAI,EAAE,MAAM,CAAC;IAC1C,MAAME,QAAQ,GAAGW,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC;IACjC,MAAMkB,KAAK,GAAGC,MAAM,CAACC,IAAI,CAAC9B,QAAQ,CAAC+B,GAAG,CAAC,CAAC3B,MAAM;IAC9CsB,KAAK,IAAIE,KAAK;IACd,MAAMxD,qBAAqB,CAAC4B,QAAQ,CAAC;IACrCrC,iBAAiB,CAAE,YAAWiE,KAAM,qBAAoB9B,IAAK,EAAC,CAAC;EACjE;EACArC,eAAe,CACZ,sBAAqBiE,KAAM,qBAAoBJ,SAAS,CAAClB,MAAO,WACnE,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"IdpOps.js","names":["frodo","fs","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getRealmString","getTypedFilename","saveJsonToFile","readSocialIdentityProviders","exportSocialIdentityProvider","exportSocialIdentityProviders","importFirstSocialIdentityProvider","importSocialIdentityProvider","importSocialIdentityProviders","oauth2oidc","external","getOneLineDescription","socialIdpObj","description","_id","_type","getTableHeaderMd","markdown","getTableRowMd","row","enabled","name","listSocialProviders","providers","sort","a","b","localeCompare","forEach","socialIdentityProvider","err","message","exportSocialIdentityProviderToFile","providerId","file","fileName","fileData","exportSocialIdentityProvidersToFile","exportSocialIdentityProvidersToFiles","allIdpsData","length","idpData","error","importSocialIdentityProviderFromFile","outcome","readFile","data","JSON","parse","_error$response","response","importFirstSocialIdentityProviderFromFile","_error$response2","importSocialIdentityProvidersFromFile","_error$response3","importSocialIdentityProvidersFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","total","readFileSync","count","Object","keys","idp"],"sources":["../../src/ops/IdpOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { SocialIdpSkeleton } from '@rockcarver/frodo-lib/types/api/SocialIdentityProvidersApi';\nimport fs from 'fs';\n\nimport {\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n} from '../utils/ExportImportUtils';\n\nconst {\n readSocialIdentityProviders,\n exportSocialIdentityProvider,\n exportSocialIdentityProviders,\n importFirstSocialIdentityProvider,\n importSocialIdentityProvider,\n importSocialIdentityProviders,\n} = frodo.oauth2oidc.external;\n\n/**\n * Get a one-line description of the social idp object\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(socialIdpObj: SocialIdpSkeleton): string {\n const description = `[${socialIdpObj._id['brightCyan']}] ${socialIdpObj._type._id}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Type |\\n';\n markdown += '| ------- | ------ | ---- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the social idp in markdown\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a table-row of the social idp in markdown\n */\nexport function getTableRowMd(socialIdpObj: SocialIdpSkeleton): string {\n const row = `| ${socialIdpObj._id} | ${\n socialIdpObj.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n } | ${socialIdpObj._type.name} |`;\n return row;\n}\n\n/**\n * List providers\n */\nexport async function listSocialProviders() {\n try {\n const providers = await readSocialIdentityProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n } catch (err) {\n printMessage(`listSocialProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n */\nexport async function exportSocialIdentityProviderToFile(\n providerId: string,\n file = ''\n) {\n debugMessage(`cli.IdpOps.exportSocialIdentityProviderToFile: start`);\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'idp');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await exportSocialIdentityProvider(providerId);\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialIdentityProviderToFile: end`);\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n */\nexport async function exportSocialIdentityProvidersToFile(file = '') {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');\n }\n const fileData = await exportSocialIdentityProviders();\n saveJsonToFile(fileData, fileName);\n}\n\n/**\n * Export all providers to individual files\n */\nexport async function exportSocialIdentityProvidersToFiles() {\n debugMessage(`cli.IdpOps.exportSocialIdentityProvidersToFiles: start`);\n try {\n const allIdpsData = await readSocialIdentityProviders();\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n try {\n const fileName = getTypedFilename(idpData._id, 'idp');\n const fileData = await exportSocialIdentityProvider(idpData._id);\n saveJsonToFile(fileData, fileName);\n updateProgressBar(`Exported provider ${idpData._id}`);\n } catch (error) {\n printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');\n }\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n } catch (error) {\n stopProgressBar(`${error}`);\n printMessage(`${error}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialIdentityProvidersToFiles: end`);\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if provider was imported successfully, false otherwise\n */\nexport async function importSocialIdentityProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing provider ${providerId} from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importSocialIdentityProvider(providerId, fileData);\n outcome = true;\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise\n */\nexport async function importFirstSocialIdentityProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing first provider from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importFirstSocialIdentityProvider(fileData);\n outcome = true;\n succeedSpinner(`Successfully imported first provider from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing first provider from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise\n */\nexport async function importSocialIdentityProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing providers from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n await importSocialIdentityProviders(fileData);\n outcome = true;\n succeedSpinner(`Successfully imported providers from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing providers from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n */\nexport async function importSocialIdentityProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.idp.json')\n );\n\n createProgressBar(jsonFiles.length, 'Importing providers...');\n let total = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await importSocialIdentityProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAE7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,cAAc,EACdC,gBAAgB,EAChBC,cAAc,QACT,4BAA4B;AAEnC,MAAM;EACJC,2BAA2B;EAC3BC,4BAA4B;EAC5BC,6BAA6B;EAC7BC,iCAAiC;EACjCC,4BAA4B;EAC5BC;AACF,CAAC,GAAGlB,KAAK,CAACmB,UAAU,CAACC,QAAQ;;AAE7B;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAACC,YAA+B,EAAU;EAC7E,MAAMC,WAAW,GAAI,IAAGD,YAAY,CAACE,GAAG,CAAC,YAAY,CAAE,KAAIF,YAAY,CAACG,KAAK,CAACD,GAAI,EAAC;EACnF,OAAOD,WAAW;AACpB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,gBAAgBA,CAAA,EAAW;EACzC,IAAIC,QAAQ,GAAG,EAAE;EACjBA,QAAQ,IAAI,+BAA+B;EAC3CA,QAAQ,IAAI,6BAA6B;EACzC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ClB,MAAO,WACnE,CAAC;AACH"}
|
package/esm/ops/JourneyOps.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import {
|
|
3
|
+
import { createProgressBar, createTable, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
|
|
4
4
|
import * as CirclesOfTrust from './CirclesOfTrustOps';
|
|
5
5
|
import * as EmailTemplate from './EmailTemplateOps';
|
|
6
6
|
import * as Idp from './IdpOps';
|
|
@@ -8,23 +8,24 @@ import * as Node from './NodeOps';
|
|
|
8
8
|
import * as Saml2 from './Saml2Ops';
|
|
9
9
|
import * as Script from './ScriptOps';
|
|
10
10
|
import * as Theme from './ThemeOps';
|
|
11
|
-
import wordwrap from './utils/Wordwrap';
|
|
12
11
|
import { cloneDeep } from './utils/OpsUtils';
|
|
12
|
+
import wordwrap from './utils/Wordwrap';
|
|
13
13
|
const {
|
|
14
14
|
getTypedFilename,
|
|
15
15
|
saveJsonToFile,
|
|
16
16
|
getRealmString
|
|
17
17
|
} = frodo.utils;
|
|
18
18
|
const {
|
|
19
|
-
|
|
19
|
+
readJourneys,
|
|
20
20
|
exportJourney,
|
|
21
21
|
createMultiTreeExportTemplate,
|
|
22
22
|
resolveDependencies,
|
|
23
|
-
|
|
23
|
+
importJourneys,
|
|
24
24
|
importJourney,
|
|
25
25
|
getTreeDescendents,
|
|
26
26
|
getNodeRef,
|
|
27
|
-
onlineTreeExportResolver
|
|
27
|
+
onlineTreeExportResolver,
|
|
28
|
+
getJourneyClassification: _getJourneyClassification
|
|
28
29
|
} = frodo.authn.journey;
|
|
29
30
|
|
|
30
31
|
/**
|
|
@@ -36,7 +37,7 @@ const {
|
|
|
36
37
|
export async function listJourneys(long = false, analyze = false) {
|
|
37
38
|
let journeys = [];
|
|
38
39
|
try {
|
|
39
|
-
journeys = await
|
|
40
|
+
journeys = await readJourneys();
|
|
40
41
|
if (!long && !analyze) {
|
|
41
42
|
for (const journeyStub of journeys) {
|
|
42
43
|
printMessage(`${journeyStub['_id']}`, 'data');
|
|
@@ -129,7 +130,7 @@ export async function exportJourneysToFile(file, options = {
|
|
|
129
130
|
if (!fileName) {
|
|
130
131
|
fileName = getTypedFilename(`all${getRealmString()}Journeys`, 'journeys');
|
|
131
132
|
}
|
|
132
|
-
const trees = await
|
|
133
|
+
const trees = await readJourneys();
|
|
133
134
|
const fileData = createMultiTreeExportTemplate();
|
|
134
135
|
createProgressBar(trees.length, 'Exporting journeys...');
|
|
135
136
|
for (const tree of trees) {
|
|
@@ -151,7 +152,7 @@ export async function exportJourneysToFile(file, options = {
|
|
|
151
152
|
* @param {TreeExportOptions} options export options
|
|
152
153
|
*/
|
|
153
154
|
export async function exportJourneysToFiles(options) {
|
|
154
|
-
const trees = await
|
|
155
|
+
const trees = await readJourneys();
|
|
155
156
|
createProgressBar(trees.length, 'Exporting journeys...');
|
|
156
157
|
for (const tree of trees) {
|
|
157
158
|
updateProgressBar(`${tree._id}`);
|
|
@@ -187,7 +188,7 @@ export async function importJourneyFromFile(journeyId, file, options) {
|
|
|
187
188
|
// if a journeyId was specified, only import the matching journey
|
|
188
189
|
if (journeyData && journeyId === journeyData.tree._id) {
|
|
189
190
|
// attempt dependency resolution for single tree import
|
|
190
|
-
const installedJourneys = (await
|
|
191
|
+
const installedJourneys = (await readJourneys()).map(x => x._id);
|
|
191
192
|
const unresolvedJourneys = {};
|
|
192
193
|
const resolvedJourneys = [];
|
|
193
194
|
showSpinner('Resolving dependencies');
|
|
@@ -247,7 +248,7 @@ export async function importFirstJourneyFromFile(file, options) {
|
|
|
247
248
|
// if a journeyId was specified, only import the matching journey
|
|
248
249
|
if (journeyData && journeyId) {
|
|
249
250
|
// attempt dependency resolution for single tree import
|
|
250
|
-
const installedJourneys = (await
|
|
251
|
+
const installedJourneys = (await readJourneys()).map(x => x._id);
|
|
251
252
|
const unresolvedJourneys = {};
|
|
252
253
|
const resolvedJourneys = [];
|
|
253
254
|
showSpinner('Resolving dependencies');
|
|
@@ -286,8 +287,22 @@ export async function importFirstJourneyFromFile(file, options) {
|
|
|
286
287
|
export async function importJourneysFromFile(file, options) {
|
|
287
288
|
fs.readFile(file, 'utf8', (err, data) => {
|
|
288
289
|
if (err) throw err;
|
|
289
|
-
|
|
290
|
-
|
|
290
|
+
try {
|
|
291
|
+
const fileData = JSON.parse(data);
|
|
292
|
+
importJourneys(fileData.trees, options);
|
|
293
|
+
} catch (error) {
|
|
294
|
+
if (error.name === 'UnresolvedDependenciesError') {
|
|
295
|
+
for (const journey of Object.keys(error.unresolvedJourneys)) {
|
|
296
|
+
printMessage({
|
|
297
|
+
message: ` - ${journey} requires ${error.unresolvedJourneys[journey]}`,
|
|
298
|
+
type: 'info',
|
|
299
|
+
state
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
} else {
|
|
303
|
+
printMessage(`${error.message}`, 'error');
|
|
304
|
+
}
|
|
305
|
+
}
|
|
291
306
|
});
|
|
292
307
|
}
|
|
293
308
|
|
|
@@ -305,7 +320,12 @@ export async function importJourneysFromFiles(options) {
|
|
|
305
320
|
const journeyData = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
306
321
|
allJourneysData.trees[journeyData.tree._id] = journeyData;
|
|
307
322
|
}
|
|
308
|
-
|
|
323
|
+
try {
|
|
324
|
+
await importJourneys(allJourneysData.trees, options);
|
|
325
|
+
} catch (error) {
|
|
326
|
+
var _error$response2, _error$response2$data;
|
|
327
|
+
printMessage(`${((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.message) || error.message}`, 'error');
|
|
328
|
+
}
|
|
309
329
|
}
|
|
310
330
|
|
|
311
331
|
/**
|
|
@@ -314,7 +334,7 @@ export async function importJourneysFromFiles(options) {
|
|
|
314
334
|
* @returns {string[]} Colored string array of classifications
|
|
315
335
|
*/
|
|
316
336
|
export function getJourneyClassification(journey) {
|
|
317
|
-
return
|
|
337
|
+
return _getJourneyClassification(journey).map(it => {
|
|
318
338
|
switch (it) {
|
|
319
339
|
case 'standard':
|
|
320
340
|
return it['brightGreen'];
|
|
@@ -334,7 +354,7 @@ export function getJourneyClassification(journey) {
|
|
|
334
354
|
* @returns {string[]} Colored string array of classifications
|
|
335
355
|
*/
|
|
336
356
|
export function getJourneyClassificationMd(journey) {
|
|
337
|
-
return
|
|
357
|
+
return _getJourneyClassification(journey).map(it => {
|
|
338
358
|
switch (it) {
|
|
339
359
|
case 'standard':
|
|
340
360
|
return `:green_circle: \`${it}\``;
|
|
@@ -470,8 +490,13 @@ export async function describeJourney(journeyData, resolveTreeExport = onlineTre
|
|
|
470
490
|
}
|
|
471
491
|
|
|
472
492
|
// Dependency Tree
|
|
473
|
-
|
|
474
|
-
|
|
493
|
+
try {
|
|
494
|
+
const descendents = await getTreeDescendents(journeyData, resolveTreeExport);
|
|
495
|
+
describeTreeDescendents(descendents);
|
|
496
|
+
} catch (error) {
|
|
497
|
+
printMessage(`Error resolving inner tree dependencies:`, 'error');
|
|
498
|
+
printMessage(error.stack, 'error');
|
|
499
|
+
}
|
|
475
500
|
|
|
476
501
|
// Node Types
|
|
477
502
|
if (Object.entries(nodeTypeMap).length) {
|