@rockcarver/frodo-cli 2.0.0-5 → 2.0.0-7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -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 +45 -0
- package/esm/cli/admin/admin-federation-export.js.map +1 -0
- package/esm/cli/admin/admin-federation-import.js +49 -0
- package/esm/cli/admin/admin-federation-import.js.map +1 -0
- package/esm/cli/admin/admin-federation-list.js +29 -0
- package/esm/cli/admin/admin-federation-list.js.map +1 -0
- package/esm/cli/admin/admin-federation.js +13 -0
- package/esm/cli/admin/admin-federation.js.map +1 -0
- 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/admin/admin.js +1 -0
- package/esm/cli/admin/admin.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 +216 -0
- package/esm/ops/AdminFederationOps.js.map +1 -0
- 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 +26 -13
- 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
|
@@ -2,6 +2,22 @@ import { frodo, state } from '@rockcarver/frodo-lib';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { createObjectTable, createProgressBar, createTable, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
|
|
4
4
|
import { getTypedFilename, saveJsonToFile, titleCase } from '../utils/ExportImportUtils';
|
|
5
|
+
const {
|
|
6
|
+
getRealmName
|
|
7
|
+
} = frodo.helper.utils;
|
|
8
|
+
const {
|
|
9
|
+
getResourceTypes,
|
|
10
|
+
getResourceType,
|
|
11
|
+
getResourceTypeByName,
|
|
12
|
+
exportResourceType,
|
|
13
|
+
exportResourceTypeByName,
|
|
14
|
+
exportResourceTypes,
|
|
15
|
+
importResourceType,
|
|
16
|
+
importResourceTypeByName,
|
|
17
|
+
importFirstResourceType,
|
|
18
|
+
importResourceTypes
|
|
19
|
+
} = frodo.authz.resourceType;
|
|
20
|
+
|
|
5
21
|
/**
|
|
6
22
|
* List resource types
|
|
7
23
|
* @param {boolean} long more fields
|
|
@@ -10,7 +26,7 @@ import { getTypedFilename, saveJsonToFile, titleCase } from '../utils/ExportImpo
|
|
|
10
26
|
export async function listResourceTypes(long = false) {
|
|
11
27
|
let outcome = false;
|
|
12
28
|
try {
|
|
13
|
-
const resourceTypes = await
|
|
29
|
+
const resourceTypes = await getResourceTypes();
|
|
14
30
|
resourceTypes.sort((a, b) => a.name.localeCompare(b.name));
|
|
15
31
|
if (long) {
|
|
16
32
|
const table = createTable(['Name', 'Description', 'Uuid']);
|
|
@@ -40,7 +56,7 @@ export async function listResourceTypes(long = false) {
|
|
|
40
56
|
export async function describeResourceType(resourceTypeUuid, json = false) {
|
|
41
57
|
let outcome = false;
|
|
42
58
|
try {
|
|
43
|
-
const resourceType = await
|
|
59
|
+
const resourceType = await getResourceType(resourceTypeUuid);
|
|
44
60
|
if (json) {
|
|
45
61
|
printMessage(resourceType, 'data');
|
|
46
62
|
} else {
|
|
@@ -69,7 +85,7 @@ export async function describeResourceType(resourceTypeUuid, json = false) {
|
|
|
69
85
|
export async function describeResourceTypeByName(resourceTypeName, json = false) {
|
|
70
86
|
let outcome = false;
|
|
71
87
|
try {
|
|
72
|
-
const resourceType = await
|
|
88
|
+
const resourceType = await getResourceTypeByName(resourceTypeName);
|
|
73
89
|
if (json) {
|
|
74
90
|
printMessage(resourceType, 'data');
|
|
75
91
|
} else {
|
|
@@ -101,7 +117,7 @@ export async function deleteResourceType(resourceTypeUuid) {
|
|
|
101
117
|
const errors = [];
|
|
102
118
|
try {
|
|
103
119
|
debugMessage(`Deleting resource type ${resourceTypeUuid}`);
|
|
104
|
-
await
|
|
120
|
+
await deleteResourceType(resourceTypeUuid);
|
|
105
121
|
} catch (error) {
|
|
106
122
|
errors.push(error);
|
|
107
123
|
}
|
|
@@ -131,7 +147,7 @@ export async function deleteResourceTypeByName(resourceTypeName) {
|
|
|
131
147
|
const errors = [];
|
|
132
148
|
try {
|
|
133
149
|
debugMessage(`Deleting resource type ${resourceTypeName}`);
|
|
134
|
-
await
|
|
150
|
+
await deleteResourceTypeByName(resourceTypeName);
|
|
135
151
|
} catch (error) {
|
|
136
152
|
errors.push(error);
|
|
137
153
|
}
|
|
@@ -161,7 +177,7 @@ export async function deleteResourceTypes() {
|
|
|
161
177
|
try {
|
|
162
178
|
showSpinner(`Retrieving all resource types...`);
|
|
163
179
|
try {
|
|
164
|
-
resourceTypes = await
|
|
180
|
+
resourceTypes = await getResourceTypes();
|
|
165
181
|
succeedSpinner(`Found ${resourceTypes.length} resource types.`);
|
|
166
182
|
} catch (error) {
|
|
167
183
|
error.message = `Error retrieving all resource types: ${error.message}`;
|
|
@@ -173,7 +189,7 @@ export async function deleteResourceTypes() {
|
|
|
173
189
|
const resourceTypeId = resourceType.uuid;
|
|
174
190
|
try {
|
|
175
191
|
debugMessage(`Deleting resource type ${resourceTypeId}`);
|
|
176
|
-
await
|
|
192
|
+
await deleteResourceType(resourceTypeId);
|
|
177
193
|
updateProgressBar(`Deleted ${resourceTypeId}`);
|
|
178
194
|
} catch (error) {
|
|
179
195
|
error.message = `Error deleting resource type ${resourceTypeId}: ${error}`;
|
|
@@ -212,7 +228,7 @@ export async function exportResourceTypeToFile(resourceTypeUuid, file) {
|
|
|
212
228
|
if (file) {
|
|
213
229
|
fileName = file;
|
|
214
230
|
}
|
|
215
|
-
const exportData = await
|
|
231
|
+
const exportData = await exportResourceType(resourceTypeUuid);
|
|
216
232
|
saveJsonToFile(exportData, fileName);
|
|
217
233
|
succeedSpinner(`Exported ${resourceTypeUuid} to ${fileName}.`);
|
|
218
234
|
outcome = true;
|
|
@@ -238,7 +254,7 @@ export async function exportResourceTypeByNameToFile(resourceTypeName, file) {
|
|
|
238
254
|
if (file) {
|
|
239
255
|
fileName = file;
|
|
240
256
|
}
|
|
241
|
-
const exportData = await
|
|
257
|
+
const exportData = await exportResourceTypeByName(resourceTypeName);
|
|
242
258
|
saveJsonToFile(exportData, fileName);
|
|
243
259
|
succeedSpinner(`Exported ${resourceTypeName} to ${fileName}.`);
|
|
244
260
|
outcome = true;
|
|
@@ -259,11 +275,11 @@ export async function exportResourceTypesToFile(file) {
|
|
|
259
275
|
debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFile: begin`);
|
|
260
276
|
showSpinner(`Exporting all resource types...`);
|
|
261
277
|
try {
|
|
262
|
-
let fileName = getTypedFilename(`all${titleCase(
|
|
278
|
+
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}ResourceTypes`, 'resourcetype.authz');
|
|
263
279
|
if (file) {
|
|
264
280
|
fileName = file;
|
|
265
281
|
}
|
|
266
|
-
const exportData = await
|
|
282
|
+
const exportData = await exportResourceTypes();
|
|
267
283
|
saveJsonToFile(exportData, fileName);
|
|
268
284
|
succeedSpinner(`Exported all resource types to ${fileName}.`);
|
|
269
285
|
outcome = true;
|
|
@@ -282,12 +298,12 @@ export async function exportResourceTypesToFiles() {
|
|
|
282
298
|
debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFiles: begin`);
|
|
283
299
|
const errors = [];
|
|
284
300
|
try {
|
|
285
|
-
const resourceTypes = await
|
|
301
|
+
const resourceTypes = await getResourceTypes();
|
|
286
302
|
createProgressBar(resourceTypes.length, 'Exporting resource types...');
|
|
287
303
|
for (const resourceType of resourceTypes) {
|
|
288
304
|
const file = getTypedFilename(resourceType.name, 'resourcetype.authz');
|
|
289
305
|
try {
|
|
290
|
-
const exportData = await
|
|
306
|
+
const exportData = await exportResourceType(resourceType.uuid);
|
|
291
307
|
saveJsonToFile(exportData, file);
|
|
292
308
|
updateProgressBar(`Exported ${resourceType.name}.`);
|
|
293
309
|
} catch (error) {
|
|
@@ -317,7 +333,7 @@ export async function importResourceTypeFromFile(resourceTypeId, file) {
|
|
|
317
333
|
try {
|
|
318
334
|
const data = fs.readFileSync(file, 'utf8');
|
|
319
335
|
const fileData = JSON.parse(data);
|
|
320
|
-
await
|
|
336
|
+
await importResourceType(resourceTypeId, fileData);
|
|
321
337
|
outcome = true;
|
|
322
338
|
succeedSpinner(`Imported ${resourceTypeId}.`);
|
|
323
339
|
} catch (error) {
|
|
@@ -341,7 +357,7 @@ export async function importResourceTypeByNameFromFile(resourceTypeName, file) {
|
|
|
341
357
|
try {
|
|
342
358
|
const data = fs.readFileSync(file, 'utf8');
|
|
343
359
|
const fileData = JSON.parse(data);
|
|
344
|
-
await
|
|
360
|
+
await importResourceTypeByName(resourceTypeName, fileData);
|
|
345
361
|
outcome = true;
|
|
346
362
|
succeedSpinner(`Imported ${resourceTypeName}.`);
|
|
347
363
|
} catch (error) {
|
|
@@ -364,7 +380,7 @@ export async function importFirstResourceTypeFromFile(file) {
|
|
|
364
380
|
try {
|
|
365
381
|
const data = fs.readFileSync(file, 'utf8');
|
|
366
382
|
const fileData = JSON.parse(data);
|
|
367
|
-
await
|
|
383
|
+
await importFirstResourceType(fileData);
|
|
368
384
|
outcome = true;
|
|
369
385
|
succeedSpinner(`Imported ${file}.`);
|
|
370
386
|
} catch (error) {
|
|
@@ -387,7 +403,7 @@ export async function importResourceTypesFromFile(file) {
|
|
|
387
403
|
try {
|
|
388
404
|
const data = fs.readFileSync(file, 'utf8');
|
|
389
405
|
const fileData = JSON.parse(data);
|
|
390
|
-
await
|
|
406
|
+
await importResourceTypes(fileData);
|
|
391
407
|
outcome = true;
|
|
392
408
|
succeedSpinner(`Imported ${file}.`);
|
|
393
409
|
} catch (error) {
|
|
@@ -416,7 +432,7 @@ export async function importResourceTypesFromFiles() {
|
|
|
416
432
|
const fileData = JSON.parse(data);
|
|
417
433
|
const count = Object.keys(fileData.resourcetype).length;
|
|
418
434
|
total += count;
|
|
419
|
-
await
|
|
435
|
+
await importResourceTypes(fileData);
|
|
420
436
|
updateProgressBar(`Imported ${count} resource types from ${file}`);
|
|
421
437
|
} catch (error) {
|
|
422
438
|
errors.push(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceTypeOps.js","names":["frodo","state","fs","createObjectTable","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","listResourceTypes","long","outcome","resourceTypes","authz","resourceType","getResourceTypes","sort","a","b","name","localeCompare","table","push","description","uuid","toString","err","message","describeResourceType","resourceTypeUuid","json","getResourceType","error","_error$response","response","status","getRealm","_error$response2","_error$response2$data","data","describeResourceTypeByName","resourceTypeName","getResourceTypeByName","_error$response3","_error$response4","_error$response4$data","deleteResourceType","errors","length","errorMessages","map","_error$response5","_error$response5$data","join","deleteResourceTypeByName","_error$response6","_error$response6$data","deleteResourceTypes","resourceTypeId","exportResourceTypeToFile","file","fileName","exportData","exportResourceType","exportResourceTypeByNameToFile","exportResourceTypeByName","exportResourceTypesToFile","helper","utils","getRealmName","exportResourceTypes","exportResourceTypesToFiles","importResourceTypeFromFile","readFileSync","fileData","JSON","parse","importResourceType","importResourceTypeByNameFromFile","importResourceTypeByName","importFirstResourceTypeFromFile","importFirstResourceType","importResourceTypesFromFile","importResourceTypes","importResourceTypesFromFiles","names","readdirSync","files","filter","toLowerCase","endsWith","total","count","Object","keys","resourcetype"],"sources":["ops/ResourceTypeOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport type { ResourceTypeSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport {\n createObjectTable,\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getTypedFilename,\n saveJsonToFile,\n titleCase,\n} from '../utils/ExportImportUtils';\nimport { ResourceTypeExportInterface } from '@rockcarver/frodo-lib/types/ops/ResourceTypeOps';\n\n/**\n * List resource types\n * @param {boolean} long more fields\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listResourceTypes(long = false): Promise<boolean> {\n let outcome = false;\n try {\n const resourceTypes = await frodo.authz.resourceType.getResourceTypes();\n resourceTypes.sort((a, b) => a.name.localeCompare(b.name));\n if (long) {\n const table = createTable(['Name', 'Description', 'Uuid']);\n for (const resourceType of resourceTypes) {\n table.push([\n `${resourceType.name}`,\n `${resourceType.description}`,\n `${resourceType.uuid}`,\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const resourceType of resourceTypes) {\n printMessage(`${resourceType.name}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listResourceTypes ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Describe resource type by uuid\n * @param {string} resourceTypeUuid resource type uuid\n * @param {boolean} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describeResourceType(\n resourceTypeUuid: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n try {\n const resourceType = await frodo.authz.resourceType.getResourceType(\n resourceTypeUuid\n );\n if (json) {\n printMessage(resourceType, 'data');\n } else {\n const table = createObjectTable(resourceType);\n printMessage(table.toString(), 'data');\n }\n outcome = true;\n } catch (error) {\n if (error.response?.status === 404) {\n printMessage(\n `Resource Type with uuid ${resourceTypeUuid} does not exist in realm ${state.getRealm()}`,\n 'error'\n );\n } else {\n printMessage(error.response?.data?.message || error.message, 'error');\n }\n }\n return outcome;\n}\n\n/**\n * Describe resource type by name\n * @param {string} resourceTypeName resource type name\n * @param {boolean} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describeResourceTypeByName(\n resourceTypeName: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n try {\n const resourceType = await frodo.authz.resourceType.getResourceTypeByName(\n resourceTypeName\n );\n if (json) {\n printMessage(resourceType, 'data');\n } else {\n const table = createObjectTable(resourceType);\n printMessage(table.toString(), 'data');\n }\n outcome = true;\n } catch (error) {\n if (error.response?.status === 404) {\n printMessage(\n `Resource Type with name ${resourceTypeName} does not exist in realm ${state.getRealm()}`,\n 'error'\n );\n } else {\n printMessage(error.response?.data?.message || error.message, 'error');\n }\n }\n return outcome;\n}\n\n/**\n * Delete resource type by uuid\n * @param {string} resourceTypeUuid resource type uuid\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteResourceType(\n resourceTypeUuid: string\n): Promise<boolean | ResourceTypeSkeleton> {\n debugMessage(`cli.ResourceTypeOps.deleteResourceType: begin`);\n showSpinner(`Deleting ${resourceTypeUuid}...`);\n let outcome = false;\n const errors = [];\n try {\n debugMessage(`Deleting resource type ${resourceTypeUuid}`);\n await frodo.authz.resourceType.deleteResourceType(resourceTypeUuid);\n } catch (error) {\n errors.push(error);\n }\n if (errors.length) {\n const errorMessages = errors\n .map((error) => error.response?.data?.message || error.message)\n .join('\\n');\n failSpinner(`Error deleting ${resourceTypeUuid}: ${errorMessages}`);\n } else {\n succeedSpinner(`Deleted ${resourceTypeUuid}.`);\n outcome = true;\n }\n debugMessage(\n `cli.ResourceTypeOps.deleteResourceType: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Delete resource type by name\n * @param {string} resourceTypeName resource type name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteResourceTypeByName(\n resourceTypeName: string\n): Promise<boolean | ResourceTypeSkeleton> {\n debugMessage(`cli.ResourceTypeOps.deleteResourceTypeByName: begin`);\n showSpinner(`Deleting ${resourceTypeName}...`);\n let outcome = false;\n const errors = [];\n try {\n debugMessage(`Deleting resource type ${resourceTypeName}`);\n await frodo.authz.resourceType.deleteResourceTypeByName(resourceTypeName);\n } catch (error) {\n errors.push(error);\n }\n if (errors.length) {\n const errorMessages = errors\n .map((error) => error.response?.data?.message || error.message)\n .join('\\n');\n failSpinner(`Error deleting ${resourceTypeName}: ${errorMessages}`);\n } else {\n succeedSpinner(`Deleted ${resourceTypeName}.`);\n outcome = true;\n }\n debugMessage(\n `cli.ResourceTypeOps.deleteResourceTypeByName: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Delete all resource types\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteResourceTypes(): Promise<\n boolean | ResourceTypeSkeleton\n> {\n debugMessage(`cli.ResourceTypeOps.deleteResourceTypes: begin`);\n let outcome = false;\n const errors = [];\n let resourceTypes: ResourceTypeSkeleton[] = [];\n try {\n showSpinner(`Retrieving all resource types...`);\n try {\n resourceTypes = await frodo.authz.resourceType.getResourceTypes();\n succeedSpinner(`Found ${resourceTypes.length} resource types.`);\n } catch (error) {\n error.message = `Error retrieving all resource types: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (resourceTypes.length)\n createProgressBar(\n resourceTypes.length,\n `Deleting ${resourceTypes.length} resource types...`\n );\n for (const resourceType of resourceTypes) {\n const resourceTypeId = resourceType.uuid;\n try {\n debugMessage(`Deleting resource type ${resourceTypeId}`);\n await frodo.authz.resourceType.deleteResourceType(resourceTypeId);\n updateProgressBar(`Deleted ${resourceTypeId}`);\n } catch (error) {\n error.message = `Error deleting resource type ${resourceTypeId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting resource types: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (resourceTypes.length)\n stopProgressBar(`Error deleting all resource types: ${errorMessages}`);\n } else {\n if (resourceTypes.length)\n stopProgressBar(`Deleted ${resourceTypes.length} resource types.`);\n outcome = true;\n }\n }\n debugMessage(\n `cli.ResourceTypeOps.deleteResourceTypes: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Export resource type to file\n * @param {string} resourceTypeUuid resource type uuid\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypeToFile(\n resourceTypeUuid: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.exportResourceTypeToFile: begin`);\n showSpinner(`Exporting ${resourceTypeUuid}...`);\n try {\n let fileName = getTypedFilename(resourceTypeUuid, 'resourcetype.authz');\n if (file) {\n fileName = file;\n }\n const exportData = await frodo.authz.resourceType.exportResourceType(\n resourceTypeUuid\n );\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported ${resourceTypeUuid} to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${resourceTypeUuid}: ${error.message}`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypeToFile: end`);\n return outcome;\n}\n\n/**\n * Export resource type by name to file\n * @param {string} resourceTypeName resource type name\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypeByNameToFile(\n resourceTypeName: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.exportResourceTypeByNameToFile: begin`);\n showSpinner(`Exporting ${resourceTypeName}...`);\n try {\n let fileName = getTypedFilename(resourceTypeName, 'resourcetype.authz');\n if (file) {\n fileName = file;\n }\n const exportData = await frodo.authz.resourceType.exportResourceTypeByName(\n resourceTypeName\n );\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported ${resourceTypeName} to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${resourceTypeName}: ${error.message}`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypeByNameToFile: end`);\n return outcome;\n}\n\n/**\n * Export resource types to file\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypesToFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFile: begin`);\n showSpinner(`Exporting all resource types...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(\n frodo.helper.utils.getRealmName(state.getRealm())\n )}ResourceTypes`,\n 'resourcetype.authz'\n );\n if (file) {\n fileName = file;\n }\n const exportData = await frodo.authz.resourceType.exportResourceTypes();\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported all resource types to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting resource types: ${error.message}`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFile: end`);\n return outcome;\n}\n\n/**\n * Export all resource types to separate files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypesToFiles(): Promise<boolean> {\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFiles: begin`);\n const errors = [];\n try {\n const resourceTypes: ResourceTypeSkeleton[] =\n await frodo.authz.resourceType.getResourceTypes();\n createProgressBar(resourceTypes.length, 'Exporting resource types...');\n for (const resourceType of resourceTypes) {\n const file = getTypedFilename(resourceType.name, 'resourcetype.authz');\n try {\n const exportData: ResourceTypeExportInterface =\n await frodo.authz.resourceType.exportResourceType(resourceType.uuid);\n saveJsonToFile(exportData, file);\n updateProgressBar(`Exported ${resourceType.name}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${resourceType.name}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting resource types to files`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import resource type from file\n * @param {string} resourceTypeId resource type id\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypeFromFile(\n resourceTypeId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importResourceTypeFromFile: begin`);\n showSpinner(`Importing ${resourceTypeId}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await frodo.authz.resourceType.importResourceType(resourceTypeId, fileData);\n outcome = true;\n succeedSpinner(`Imported ${resourceTypeId}.`);\n } catch (error) {\n failSpinner(`Error importing ${resourceTypeId}: ${error.message}`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypeFromFile: end`);\n return outcome;\n}\n\n/**\n * Import resource type by name from file\n * @param {string} resourceTypeName resource type name\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypeByNameFromFile(\n resourceTypeName: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importResourceTypeByNameFromFile: begin`);\n showSpinner(`Importing ${resourceTypeName}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await frodo.authz.resourceType.importResourceTypeByName(\n resourceTypeName,\n fileData\n );\n outcome = true;\n succeedSpinner(`Imported ${resourceTypeName}.`);\n } catch (error) {\n failSpinner(`Error importing ${resourceTypeName}: ${error.message}`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypeByNameFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first resource type from file\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstResourceTypeFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importFirstResourceTypeFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await frodo.authz.resourceType.importFirstResourceType(fileData);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importFirstResourceTypeFromFile: end`);\n return outcome;\n}\n\n/**\n * Import resource types from file\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypesFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await frodo.authz.resourceType.importResourceTypes(fileData);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFile: end`);\n return outcome;\n}\n\n/**\n * Import resource types from files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypesFromFiles(): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFiles: begin`);\n const names = fs.readdirSync('.');\n const files = names.filter((name) =>\n name.toLowerCase().endsWith('.resourcetype.authz.json')\n );\n createProgressBar(files.length, 'Importing resource types...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: ResourceTypeExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.resourcetype).length;\n total += count;\n await frodo.authz.resourceType.importResourceTypes(fileData);\n updateProgressBar(`Imported ${count} resource types from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing resource types from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} resource types from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing resource types from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,gBAAgB,EAChBC,cAAc,EACdC,SAAS,QACJ,4BAA4B;AAGnC;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,iBAAiBA,CAACC,IAAI,GAAG,KAAK,EAAoB;EACtE,IAAIC,OAAO,GAAG,KAAK;EACnB,IAAI;IACF,MAAMC,aAAa,GAAG,MAAMnB,KAAK,CAACoB,KAAK,CAACC,YAAY,CAACC,gBAAgB,CAAC,CAAC;IACvEH,aAAa,CAACI,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,IAAI,CAACC,aAAa,CAACF,CAAC,CAACC,IAAI,CAAC,CAAC;IAC1D,IAAIT,IAAI,EAAE;MACR,MAAMW,KAAK,GAAGvB,WAAW,CAAC,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;MAC1D,KAAK,MAAMgB,YAAY,IAAIF,aAAa,EAAE;QACxCS,KAAK,CAACC,IAAI,CAAC,CACR,GAAER,YAAY,CAACK,IAAK,EAAC,EACrB,GAAEL,YAAY,CAACS,WAAY,EAAC,EAC5B,GAAET,YAAY,CAACU,I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CAAC/C,MAAM;QACvD2C,KAAK,IAAIC,KAAK;QACd,MAAMnG,KAAK,CAACoB,KAAK,CAACC,YAAY,CAACqE,mBAAmB,CAACT,QAAQ,CAAC;QAC5DrE,iBAAiB,CAAE,YAAWuF,KAAM,wBAAuBhC,IAAK,EAAC,CAAC;MACpE,CAAC,CAAC,OAAO5B,KAAK,EAAE;QACde,MAAM,CAACzB,IAAI,CAACU,KAAK,CAAC;QAClB3B,iBAAiB,CAAE,uCAAsCuD,IAAK,EAAC,CAAC;QAChE3D,YAAY,CAAC+B,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACA7B,eAAe,CACZ,sBAAqBwF,KAAM,wBAAuBJ,KAAK,CAACvC,MAAO,SAClE,CAAC;EACH,CAAC,CAAC,OAAOhB,KAAK,EAAE;IACde,MAAM,CAACzB,IAAI,CAACU,KAAK,CAAC;IAClB7B,eAAe,CAAE,4CAA2C,CAAC;IAC7DF,YAAY,CAAC+B,KAAK,EAAE,OAAO,CAAC;EAC9B;EACAjC,YAAY,CAAE,uDAAsD,CAAC;EACrE,OAAO,CAAC,KAAKgD,MAAM,CAACC,MAAM;AAC5B"}
|
|
1
|
+
{"version":3,"file":"ResourceTypeOps.js","names":["frodo","state","fs","createObjectTable","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","getRealmName","helper","utils","getResourceTypes","getResourceType","getResourceTypeByName","exportResourceType","exportResourceTypeByName","exportResourceTypes","importResourceType","importResourceTypeByName","importFirstResourceType","importResourceTypes","authz","resourceType","listResourceTypes","long","outcome","resourceTypes","sort","a","b","name","localeCompare","table","push","description","uuid","toString","err","message","describeResourceType","resourceTypeUuid","json","error","_error$response","response","status","getRealm","_error$response2","_error$response2$data","data","describeResourceTypeByName","resourceTypeName","_error$response3","_error$response4","_error$response4$data","deleteResourceType","errors","length","errorMessages","map","_error$response5","_error$response5$data","join","deleteResourceTypeByName","_error$response6","_error$response6$data","deleteResourceTypes","resourceTypeId","exportResourceTypeToFile","file","fileName","exportData","exportResourceTypeByNameToFile","exportResourceTypesToFile","exportResourceTypesToFiles","importResourceTypeFromFile","readFileSync","fileData","JSON","parse","importResourceTypeByNameFromFile","importFirstResourceTypeFromFile","importResourceTypesFromFile","importResourceTypesFromFiles","names","readdirSync","files","filter","toLowerCase","endsWith","total","count","Object","keys","resourcetype"],"sources":["ops/ResourceTypeOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport type { ResourceTypeSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport {\n createObjectTable,\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getTypedFilename,\n saveJsonToFile,\n titleCase,\n} from '../utils/ExportImportUtils';\nimport { ResourceTypeExportInterface } from '@rockcarver/frodo-lib/types/ops/ResourceTypeOps';\n\nconst { getRealmName } = frodo.helper.utils;\nconst {\n getResourceTypes,\n getResourceType,\n getResourceTypeByName,\n exportResourceType,\n exportResourceTypeByName,\n exportResourceTypes,\n importResourceType,\n importResourceTypeByName,\n importFirstResourceType,\n importResourceTypes,\n} = frodo.authz.resourceType;\n\n/**\n * List resource types\n * @param {boolean} long more fields\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listResourceTypes(long = false): Promise<boolean> {\n let outcome = false;\n try {\n const resourceTypes = await getResourceTypes();\n resourceTypes.sort((a, b) => a.name.localeCompare(b.name));\n if (long) {\n const table = createTable(['Name', 'Description', 'Uuid']);\n for (const resourceType of resourceTypes) {\n table.push([\n `${resourceType.name}`,\n `${resourceType.description}`,\n `${resourceType.uuid}`,\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const resourceType of resourceTypes) {\n printMessage(`${resourceType.name}`, 'data');\n }\n }\n outcome = true;\n } catch (err) {\n printMessage(`listResourceTypes ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Describe resource type by uuid\n * @param {string} resourceTypeUuid resource type uuid\n * @param {boolean} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describeResourceType(\n resourceTypeUuid: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n try {\n const resourceType = await getResourceType(resourceTypeUuid);\n if (json) {\n printMessage(resourceType, 'data');\n } else {\n const table = createObjectTable(resourceType);\n printMessage(table.toString(), 'data');\n }\n outcome = true;\n } catch (error) {\n if (error.response?.status === 404) {\n printMessage(\n `Resource Type with uuid ${resourceTypeUuid} does not exist in realm ${state.getRealm()}`,\n 'error'\n );\n } else {\n printMessage(error.response?.data?.message || error.message, 'error');\n }\n }\n return outcome;\n}\n\n/**\n * Describe resource type by name\n * @param {string} resourceTypeName resource type name\n * @param {boolean} json JSON output\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function describeResourceTypeByName(\n resourceTypeName: string,\n json = false\n): Promise<boolean> {\n let outcome = false;\n try {\n const resourceType = await getResourceTypeByName(resourceTypeName);\n if (json) {\n printMessage(resourceType, 'data');\n } else {\n const table = createObjectTable(resourceType);\n printMessage(table.toString(), 'data');\n }\n outcome = true;\n } catch (error) {\n if (error.response?.status === 404) {\n printMessage(\n `Resource Type with name ${resourceTypeName} does not exist in realm ${state.getRealm()}`,\n 'error'\n );\n } else {\n printMessage(error.response?.data?.message || error.message, 'error');\n }\n }\n return outcome;\n}\n\n/**\n * Delete resource type by uuid\n * @param {string} resourceTypeUuid resource type uuid\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteResourceType(\n resourceTypeUuid: string\n): Promise<boolean | ResourceTypeSkeleton> {\n debugMessage(`cli.ResourceTypeOps.deleteResourceType: begin`);\n showSpinner(`Deleting ${resourceTypeUuid}...`);\n let outcome = false;\n const errors = [];\n try {\n debugMessage(`Deleting resource type ${resourceTypeUuid}`);\n await deleteResourceType(resourceTypeUuid);\n } catch (error) {\n errors.push(error);\n }\n if (errors.length) {\n const errorMessages = errors\n .map((error) => error.response?.data?.message || error.message)\n .join('\\n');\n failSpinner(`Error deleting ${resourceTypeUuid}: ${errorMessages}`);\n } else {\n succeedSpinner(`Deleted ${resourceTypeUuid}.`);\n outcome = true;\n }\n debugMessage(\n `cli.ResourceTypeOps.deleteResourceType: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Delete resource type by name\n * @param {string} resourceTypeName resource type name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteResourceTypeByName(\n resourceTypeName: string\n): Promise<boolean | ResourceTypeSkeleton> {\n debugMessage(`cli.ResourceTypeOps.deleteResourceTypeByName: begin`);\n showSpinner(`Deleting ${resourceTypeName}...`);\n let outcome = false;\n const errors = [];\n try {\n debugMessage(`Deleting resource type ${resourceTypeName}`);\n await deleteResourceTypeByName(resourceTypeName);\n } catch (error) {\n errors.push(error);\n }\n if (errors.length) {\n const errorMessages = errors\n .map((error) => error.response?.data?.message || error.message)\n .join('\\n');\n failSpinner(`Error deleting ${resourceTypeName}: ${errorMessages}`);\n } else {\n succeedSpinner(`Deleted ${resourceTypeName}.`);\n outcome = true;\n }\n debugMessage(\n `cli.ResourceTypeOps.deleteResourceTypeByName: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Delete all resource types\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function deleteResourceTypes(): Promise<\n boolean | ResourceTypeSkeleton\n> {\n debugMessage(`cli.ResourceTypeOps.deleteResourceTypes: begin`);\n let outcome = false;\n const errors = [];\n let resourceTypes: ResourceTypeSkeleton[] = [];\n try {\n showSpinner(`Retrieving all resource types...`);\n try {\n resourceTypes = await getResourceTypes();\n succeedSpinner(`Found ${resourceTypes.length} resource types.`);\n } catch (error) {\n error.message = `Error retrieving all resource types: ${error.message}`;\n failSpinner(error.message);\n throw error;\n }\n if (resourceTypes.length)\n createProgressBar(\n resourceTypes.length,\n `Deleting ${resourceTypes.length} resource types...`\n );\n for (const resourceType of resourceTypes) {\n const resourceTypeId = resourceType.uuid;\n try {\n debugMessage(`Deleting resource type ${resourceTypeId}`);\n await deleteResourceType(resourceTypeId);\n updateProgressBar(`Deleted ${resourceTypeId}`);\n } catch (error) {\n error.message = `Error deleting resource type ${resourceTypeId}: ${error}`;\n updateProgressBar(error.message);\n errors.push(error);\n }\n }\n } catch (error) {\n error.message = `Error deleting resource types: ${error}`;\n errors.push(error);\n } finally {\n if (errors.length) {\n const errorMessages = errors.map((error) => error.message).join('\\n');\n if (resourceTypes.length)\n stopProgressBar(`Error deleting all resource types: ${errorMessages}`);\n } else {\n if (resourceTypes.length)\n stopProgressBar(`Deleted ${resourceTypes.length} resource types.`);\n outcome = true;\n }\n }\n debugMessage(\n `cli.ResourceTypeOps.deleteResourceTypes: end [outcome=${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Export resource type to file\n * @param {string} resourceTypeUuid resource type uuid\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypeToFile(\n resourceTypeUuid: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.exportResourceTypeToFile: begin`);\n showSpinner(`Exporting ${resourceTypeUuid}...`);\n try {\n let fileName = getTypedFilename(resourceTypeUuid, 'resourcetype.authz');\n if (file) {\n fileName = file;\n }\n const exportData = await exportResourceType(resourceTypeUuid);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported ${resourceTypeUuid} to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${resourceTypeUuid}: ${error.message}`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypeToFile: end`);\n return outcome;\n}\n\n/**\n * Export resource type by name to file\n * @param {string} resourceTypeName resource type name\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypeByNameToFile(\n resourceTypeName: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.exportResourceTypeByNameToFile: begin`);\n showSpinner(`Exporting ${resourceTypeName}...`);\n try {\n let fileName = getTypedFilename(resourceTypeName, 'resourcetype.authz');\n if (file) {\n fileName = file;\n }\n const exportData = await exportResourceTypeByName(resourceTypeName);\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported ${resourceTypeName} to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${resourceTypeName}: ${error.message}`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypeByNameToFile: end`);\n return outcome;\n}\n\n/**\n * Export resource types to file\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypesToFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFile: begin`);\n showSpinner(`Exporting all resource types...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}ResourceTypes`,\n 'resourcetype.authz'\n );\n if (file) {\n fileName = file;\n }\n const exportData = await exportResourceTypes();\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported all resource types to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting resource types: ${error.message}`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFile: end`);\n return outcome;\n}\n\n/**\n * Export all resource types to separate files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportResourceTypesToFiles(): Promise<boolean> {\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFiles: begin`);\n const errors = [];\n try {\n const resourceTypes: ResourceTypeSkeleton[] = await getResourceTypes();\n createProgressBar(resourceTypes.length, 'Exporting resource types...');\n for (const resourceType of resourceTypes) {\n const file = getTypedFilename(resourceType.name, 'resourcetype.authz');\n try {\n const exportData: ResourceTypeExportInterface =\n await exportResourceType(resourceType.uuid);\n saveJsonToFile(exportData, file);\n updateProgressBar(`Exported ${resourceType.name}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${resourceType.name}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting resource types to files`);\n }\n debugMessage(`cli.ResourceTypeOps.exportResourceTypesToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import resource type from file\n * @param {string} resourceTypeId resource type id\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypeFromFile(\n resourceTypeId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importResourceTypeFromFile: begin`);\n showSpinner(`Importing ${resourceTypeId}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importResourceType(resourceTypeId, fileData);\n outcome = true;\n succeedSpinner(`Imported ${resourceTypeId}.`);\n } catch (error) {\n failSpinner(`Error importing ${resourceTypeId}: ${error.message}`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypeFromFile: end`);\n return outcome;\n}\n\n/**\n * Import resource type by name from file\n * @param {string} resourceTypeName resource type name\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypeByNameFromFile(\n resourceTypeName: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importResourceTypeByNameFromFile: begin`);\n showSpinner(`Importing ${resourceTypeName}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importResourceTypeByName(resourceTypeName, fileData);\n outcome = true;\n succeedSpinner(`Imported ${resourceTypeName}.`);\n } catch (error) {\n failSpinner(`Error importing ${resourceTypeName}: ${error.message}`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypeByNameFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first resource type from file\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstResourceTypeFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importFirstResourceTypeFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstResourceType(fileData);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importFirstResourceTypeFromFile: end`);\n return outcome;\n}\n\n/**\n * Import resource types from file\n * @param {string} file file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypesFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importResourceTypes(fileData);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFile: end`);\n return outcome;\n}\n\n/**\n * Import resource types from files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importResourceTypesFromFiles(): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFiles: begin`);\n const names = fs.readdirSync('.');\n const files = names.filter((name) =>\n name.toLowerCase().endsWith('.resourcetype.authz.json')\n );\n createProgressBar(files.length, 'Importing resource types...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: ResourceTypeExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.resourcetype).length;\n total += count;\n await importResourceTypes(fileData);\n updateProgressBar(`Imported ${count} resource types from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing resource types from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} resource types from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing resource types from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.ResourceTypeOps.importResourceTypesFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,gBAAgB,EAChBC,cAAc,EACdC,SAAS,QACJ,4BAA4B;AAGnC,MAAM;EAAEC;AAAa,CAAC,GAAGhB,KAAK,CAACiB,MAAM,CAACC,KAAK;AAC3C,MAAM;EACJC,gBAAgB;EAChBC,eAAe;EACfC,qBAAqB;EACrBC,kBAAkB;EAClBC,wBAAwB;EACxBC,mBAAmB;EACnBC,kBAAkB;EAClBC,wBAAwB;EACxBC,uBAAuB;EACvBC;AACF,CAAC,GAAG5B,KAAK,CAAC6B,KAAK,CAACC,YAAY;;AAE5B;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,iBAAiBA,CAACC,IAAI,GAAG,KAAK,EAAoB;EACtE,IAAIC,OAAO,GAAG,KAAK;EACnB,IAAI;IACF,MAAMC,aAAa,GAAG,MAAMf,gBAAgB,CAAC,CAAC;IAC9Ce,aAAa,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,IAAI,CAACC,aAAa,CAACF,CAAC,CAACC,IAAI,CAAC,CAAC;IAC1D,IAAIN,IAAI,EAAE;MACR,MAAMQ,KAAK,GAAGnC,WAAW,CAAC,CAAC,MAAM,EAA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,OAAO,CAAC;MAC9B;IACF;IACAxC,eAAe,CACZ,sBAAqBwF,KAAM,wBAAuBJ,KAAK,CAAC7B,MAAO,SAClE,CAAC;EACH,CAAC,CAAC,OAAOf,KAAK,EAAE;IACdc,MAAM,CAACvB,IAAI,CAACS,KAAK,CAAC;IAClBxC,eAAe,CAAE,4CAA2C,CAAC;IAC7DF,YAAY,CAAC0C,KAAK,EAAE,OAAO,CAAC;EAC9B;EACA5C,YAAY,CAAE,uDAAsD,CAAC;EACrE,OAAO,CAAC,KAAK0D,MAAM,CAACC,MAAM;AAC5B"}
|
package/esm/ops/Saml2Ops.js
CHANGED
|
@@ -2,6 +2,26 @@ import { frodo } from '@rockcarver/frodo-lib';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { createObjectTable, createProgressBar, createTable, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
|
|
4
4
|
import { saveTextToFile } from '../utils/ExportImportUtils';
|
|
5
|
+
const {
|
|
6
|
+
decode
|
|
7
|
+
} = frodo.helper.base64;
|
|
8
|
+
const {
|
|
9
|
+
getTypedFilename,
|
|
10
|
+
saveJsonToFile,
|
|
11
|
+
getRealmString,
|
|
12
|
+
validateImport
|
|
13
|
+
} = frodo.utils.impex;
|
|
14
|
+
const {
|
|
15
|
+
getSaml2ProviderStubs,
|
|
16
|
+
getProviderByLocationAndId,
|
|
17
|
+
getSaml2ProviderStub,
|
|
18
|
+
getProviderMetadataUrl,
|
|
19
|
+
getProviderMetadata,
|
|
20
|
+
exportSaml2Provider,
|
|
21
|
+
exportSaml2Providers,
|
|
22
|
+
importSaml2Provider,
|
|
23
|
+
importSaml2Providers
|
|
24
|
+
} = frodo.saml2.entityProvider;
|
|
5
25
|
const roleMap = {
|
|
6
26
|
identityProvider: 'IDP',
|
|
7
27
|
serviceProvider: 'SP',
|
|
@@ -57,7 +77,7 @@ export function getTableRowMd(saml2ProviderObj) {
|
|
|
57
77
|
* @param {boolean} long Long list format with details
|
|
58
78
|
*/
|
|
59
79
|
export async function listSaml2Providers(long = false) {
|
|
60
|
-
const providerList = await
|
|
80
|
+
const providerList = await getSaml2ProviderStubs();
|
|
61
81
|
providerList.sort((a, b) => a._id.localeCompare(b._id));
|
|
62
82
|
if (!long) {
|
|
63
83
|
for (const provider of providerList) {
|
|
@@ -78,19 +98,19 @@ export async function listSaml2Providers(long = false) {
|
|
|
78
98
|
*/
|
|
79
99
|
export async function describeSaml2Provider(entityId) {
|
|
80
100
|
try {
|
|
81
|
-
const stub = await
|
|
101
|
+
const stub = await getSaml2ProviderStub(entityId);
|
|
82
102
|
printMessage(stub);
|
|
83
103
|
const {
|
|
84
104
|
location
|
|
85
105
|
} = stub;
|
|
86
106
|
const id = stub._id;
|
|
87
107
|
const roles = stub.roles.map(role => roleMap[role]).join(', ');
|
|
88
|
-
const rawProviderData = await
|
|
108
|
+
const rawProviderData = await getProviderByLocationAndId(location, id);
|
|
89
109
|
delete rawProviderData._id;
|
|
90
110
|
delete rawProviderData._rev;
|
|
91
111
|
rawProviderData.location = location;
|
|
92
112
|
rawProviderData.roles = roles;
|
|
93
|
-
rawProviderData.metadataUrl =
|
|
113
|
+
rawProviderData.metadataUrl = getProviderMetadataUrl(entityId);
|
|
94
114
|
const table = createObjectTable(rawProviderData);
|
|
95
115
|
printMessage(table.toString());
|
|
96
116
|
} catch (error) {
|
|
@@ -106,12 +126,12 @@ export async function describeSaml2Provider(entityId) {
|
|
|
106
126
|
export async function exportSaml2MetadataToFile(entityId, file = null) {
|
|
107
127
|
let fileName = file;
|
|
108
128
|
if (!fileName) {
|
|
109
|
-
fileName =
|
|
129
|
+
fileName = getTypedFilename(entityId, 'metadata', 'xml');
|
|
110
130
|
}
|
|
111
131
|
createProgressBar(1, `Exporting metadata for: ${entityId}`);
|
|
112
132
|
try {
|
|
113
133
|
updateProgressBar(`Writing file ${fileName}`);
|
|
114
|
-
const metaData = await
|
|
134
|
+
const metaData = await getProviderMetadata(entityId);
|
|
115
135
|
saveTextToFile(metaData, fileName);
|
|
116
136
|
updateProgressBar(`Exported provider ${entityId}`);
|
|
117
137
|
stopProgressBar(`Exported ${entityId.brightCyan} metadata to ${fileName.brightCyan}.`);
|
|
@@ -130,12 +150,12 @@ export async function exportSaml2ProviderToFile(entityId, file = null) {
|
|
|
130
150
|
debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: start [entityId=${entityId}, file=${file}]`);
|
|
131
151
|
let fileName = file;
|
|
132
152
|
if (!fileName) {
|
|
133
|
-
fileName =
|
|
153
|
+
fileName = getTypedFilename(entityId, 'saml');
|
|
134
154
|
}
|
|
135
155
|
try {
|
|
136
156
|
createProgressBar(1, `Exporting provider ${entityId}`);
|
|
137
|
-
const fileData = await
|
|
138
|
-
|
|
157
|
+
const fileData = await exportSaml2Provider(entityId);
|
|
158
|
+
saveJsonToFile(fileData, fileName);
|
|
139
159
|
updateProgressBar(`Exported provider ${entityId}`);
|
|
140
160
|
stopProgressBar(`Exported ${entityId.brightCyan} to ${fileName.brightCyan}.`);
|
|
141
161
|
} catch (err) {
|
|
@@ -153,11 +173,11 @@ export async function exportSaml2ProvidersToFile(file = null) {
|
|
|
153
173
|
debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: start [file=${file}]`);
|
|
154
174
|
let fileName = file;
|
|
155
175
|
if (!fileName) {
|
|
156
|
-
fileName =
|
|
176
|
+
fileName = getTypedFilename(`all${getRealmString()}Providers`, 'saml');
|
|
157
177
|
}
|
|
158
178
|
try {
|
|
159
|
-
const exportData = await
|
|
160
|
-
|
|
179
|
+
const exportData = await exportSaml2Providers();
|
|
180
|
+
saveJsonToFile(exportData, fileName);
|
|
161
181
|
} catch (error) {
|
|
162
182
|
var _error$response;
|
|
163
183
|
printMessage(error.message, 'error');
|
|
@@ -170,13 +190,13 @@ export async function exportSaml2ProvidersToFile(file = null) {
|
|
|
170
190
|
* Export all entity providers to individual files
|
|
171
191
|
*/
|
|
172
192
|
export async function exportSaml2ProvidersToFiles() {
|
|
173
|
-
const stubs = await
|
|
193
|
+
const stubs = await getSaml2ProviderStubs();
|
|
174
194
|
if (stubs.length > 0) {
|
|
175
195
|
createProgressBar(stubs.length, 'Exporting providers');
|
|
176
196
|
for (const stub of stubs) {
|
|
177
|
-
const fileName =
|
|
178
|
-
const fileData = await
|
|
179
|
-
|
|
197
|
+
const fileName = getTypedFilename(stub.entityId, 'saml');
|
|
198
|
+
const fileData = await exportSaml2Provider(stub.entityId);
|
|
199
|
+
saveJsonToFile(fileData, fileName);
|
|
180
200
|
updateProgressBar(`Exported provider ${stub.entityId}`);
|
|
181
201
|
}
|
|
182
202
|
stopProgressBar(`${stubs.length} providers exported.`);
|
|
@@ -196,7 +216,7 @@ export async function importSaml2ProviderFromFile(entityId, file) {
|
|
|
196
216
|
const fileData = JSON.parse(data);
|
|
197
217
|
showSpinner(`Importing ${entityId}...`);
|
|
198
218
|
try {
|
|
199
|
-
await
|
|
219
|
+
await importSaml2Provider(entityId, fileData);
|
|
200
220
|
succeedSpinner(`Imported ${entityId}.`);
|
|
201
221
|
} catch (error) {
|
|
202
222
|
failSpinner(`Error importing ${entityId}: ${error.message}`);
|
|
@@ -214,10 +234,10 @@ export async function importFirstSaml2ProviderFromFile(file) {
|
|
|
214
234
|
const fileData = JSON.parse(data);
|
|
215
235
|
// pick the first provider and run with it
|
|
216
236
|
const entityId64 = Object.keys(fileData.saml.remote)[0] || Object.keys(fileData.saml.hosted)[0];
|
|
217
|
-
const entityId =
|
|
237
|
+
const entityId = decode(entityId64);
|
|
218
238
|
showSpinner(`Importing ${entityId}...`);
|
|
219
239
|
try {
|
|
220
|
-
await
|
|
240
|
+
await importSaml2Provider(entityId, fileData);
|
|
221
241
|
succeedSpinner(`Imported ${entityId}.`);
|
|
222
242
|
} catch (error) {
|
|
223
243
|
failSpinner(`Error importing ${entityId}: ${error.message}`);
|
|
@@ -233,8 +253,8 @@ export async function importSaml2ProvidersFromFile(file) {
|
|
|
233
253
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
234
254
|
if (err) throw err;
|
|
235
255
|
const fileData = JSON.parse(data);
|
|
236
|
-
if (
|
|
237
|
-
await
|
|
256
|
+
if (validateImport(fileData.meta)) {
|
|
257
|
+
await importSaml2Providers(fileData);
|
|
238
258
|
} else {
|
|
239
259
|
printMessage('Import validation failed...', 'error');
|
|
240
260
|
}
|
|
@@ -257,8 +277,8 @@ export async function importSaml2ProvidersFromFiles() {
|
|
|
257
277
|
for (const file of jsonFiles) {
|
|
258
278
|
const data = fs.readFileSync(file, 'utf8');
|
|
259
279
|
const fileData = JSON.parse(data);
|
|
260
|
-
if (
|
|
261
|
-
const myStatus = await
|
|
280
|
+
if (validateImport(fileData.meta)) {
|
|
281
|
+
const myStatus = await importSaml2Providers(fileData);
|
|
262
282
|
totalStatus.total += myStatus.total;
|
|
263
283
|
totalStatus.successes += myStatus.successes;
|
|
264
284
|
totalStatus.warnings += myStatus.warnings;
|
package/esm/ops/Saml2Ops.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Saml2Ops.js","names":["frodo","fs","createObjectTable","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","saveTextToFile","roleMap","identityProvider","serviceProvider","attributeQueryProvider","xacmlPolicyEnforcementPoint","getOneLineDescription","saml2ProviderObj","roles","key","value","Object","entries","push","description","entityId","entityLocation","length","join","getTableHeaderMd","markdown","getTableRowMd","row","listSaml2Providers","long","providerList","saml2","entityProvider","getSaml2ProviderStubs","sort","a","b","_id","localeCompare","provider","table","location","map","role","toString","describeSaml2Provider","stub","getSaml2ProviderStub","id","rawProviderData","getProviderByLocationAndId","_rev","metadataUrl","getProviderMetadataUrl","error","message","exportSaml2MetadataToFile","file","fileName","utils","impex","getTypedFilename","metaData","getProviderMetadata","brightCyan","exportSaml2ProviderToFile","fileData","exportSaml2Provider","saveJsonToFile","err","exportSaml2ProvidersToFile","getRealmString","exportData","exportSaml2Providers","_error$response","response","status","exportSaml2ProvidersToFiles","stubs","importSaml2ProviderFromFile","readFile","data","JSON","parse","importSaml2Provider","importFirstSaml2ProviderFromFile","entityId64","keys","saml","remote","hosted","helper","base64","decode","importSaml2ProvidersFromFile","validateImport","meta","importSaml2Providers","importSaml2ProvidersFromFiles","names","readdirSync","jsonFiles","filter","name","toLowerCase","endsWith","totalStatus","total","successes","warnings","failures","readFileSync","myStatus"],"sources":["ops/Saml2Ops.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport {\n createObjectTable,\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport { saveTextToFile } from '../utils/ExportImportUtils';\nimport type {\n MultiOpStatusInterface,\n Saml2ExportInterface,\n} from '@rockcarver/frodo-lib/types/ops/OpsTypes';\nimport type { Saml2ProviderSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\n\nconst roleMap = {\n identityProvider: 'IDP',\n serviceProvider: 'SP',\n attributeQueryProvider: 'AttrQuery',\n xacmlPolicyEnforcementPoint: 'XACML PEP',\n};\n\n/**\n * Get a one-line description of the saml2 provider object\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n saml2ProviderObj: Saml2ProviderSkeleton\n): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const description = `[${saml2ProviderObj.entityId['brightCyan']}]${\n ' (' + saml2ProviderObj.entityLocation\n }${roles.length ? ' ' + roles.join(', ') + ')' : ')'}`;\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 += '| Entity Id | Location | Role(s) |\\n';\n markdown += '| --------- | -------- | ------- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the saml2 provider in markdown\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a table-row of the saml2 provider in markdown\n */\nexport function getTableRowMd(saml2ProviderObj: Saml2ProviderSkeleton): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const row = `| ${saml2ProviderObj.entityId} | ${\n saml2ProviderObj.entityLocation\n } | ${roles.length ? roles.join(', ') : ''} |`;\n return row;\n}\n\n/**\n * List entity providers\n * @param {boolean} long Long list format with details\n */\nexport async function listSaml2Providers(long = false) {\n const providerList = await frodo.saml2.entityProvider.getSaml2ProviderStubs();\n providerList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const provider of providerList) {\n printMessage(`${provider.entityId}`, 'data');\n }\n } else {\n const table = createTable([\n 'Entity Id'['brightCyan'],\n 'Location'['brightCyan'],\n 'Role(s)'['brightCyan'],\n ]);\n for (const provider of providerList) {\n table.push([\n provider.entityId,\n provider.location,\n provider.roles.map((role) => roleMap[role]).join(', '),\n ]);\n }\n printMessage(table.toString());\n }\n}\n\n/**\n * Describe an entity provider's configuration\n * @param {String} entityId Provider entity id\n */\nexport async function describeSaml2Provider(entityId) {\n try {\n const stub = await frodo.saml2.entityProvider.getSaml2ProviderStub(\n entityId\n );\n printMessage(stub);\n const { location } = stub;\n const id = stub._id;\n const roles = stub.roles.map((role: string) => roleMap[role]).join(', ');\n const rawProviderData =\n await frodo.saml2.entityProvider.getProviderByLocationAndId(location, id);\n delete rawProviderData._id;\n delete rawProviderData._rev;\n rawProviderData.location = location;\n rawProviderData.roles = roles;\n rawProviderData.metadataUrl =\n frodo.saml2.entityProvider.getProviderMetadataUrl(entityId);\n const table = createObjectTable(rawProviderData);\n printMessage(table.toString());\n } catch (error) {\n printMessage(error.message, 'error');\n }\n}\n\n/**\n * Export provider metadata to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n */\nexport async function exportSaml2MetadataToFile(entityId, file = null) {\n let fileName = file;\n if (!fileName) {\n fileName = frodo.utils.impex.getTypedFilename(entityId, 'metadata', 'xml');\n }\n createProgressBar(1, `Exporting metadata for: ${entityId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const metaData = await frodo.saml2.entityProvider.getProviderMetadata(\n entityId\n );\n saveTextToFile(metaData, fileName);\n updateProgressBar(`Exported provider ${entityId}`);\n stopProgressBar(\n `Exported ${entityId.brightCyan} metadata to ${fileName.brightCyan}.`\n );\n } catch (error) {\n stopProgressBar(`${error}`);\n printMessage(error, 'error');\n }\n}\n\n/**\n * Export a single entity provider to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n */\nexport async function exportSaml2ProviderToFile(entityId, file = null) {\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: start [entityId=${entityId}, file=${file}]`\n );\n let fileName = file;\n if (!fileName) {\n fileName = frodo.utils.impex.getTypedFilename(entityId, 'saml');\n }\n try {\n createProgressBar(1, `Exporting provider ${entityId}`);\n const fileData = await frodo.saml2.entityProvider.exportSaml2Provider(\n entityId\n );\n frodo.utils.impex.saveJsonToFile(fileData, fileName);\n updateProgressBar(`Exported provider ${entityId}`);\n stopProgressBar(\n `Exported ${entityId.brightCyan} to ${fileName.brightCyan}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(err, 'error');\n }\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: end [entityId=${entityId}, file=${fileName}]`\n );\n}\n\n/**\n * Export all entity providers to one file\n * @param {String} file Optional filename\n */\nexport async function exportSaml2ProvidersToFile(file = null) {\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: start [file=${file}]`);\n let fileName = file;\n if (!fileName) {\n fileName = frodo.utils.impex.getTypedFilename(\n `all${frodo.utils.impex.getRealmString()}Providers`,\n 'saml'\n );\n }\n try {\n const exportData = await frodo.saml2.entityProvider.exportSaml2Providers();\n frodo.utils.impex.saveJsonToFile(exportData, fileName);\n } catch (error) {\n printMessage(error.message, 'error');\n printMessage(\n `exportSaml2ProvidersToFile: ${error.response?.status}`,\n 'error'\n );\n }\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: end [file=${file}]`);\n}\n\n/**\n * Export all entity providers to individual files\n */\nexport async function exportSaml2ProvidersToFiles() {\n const stubs = await frodo.saml2.entityProvider.getSaml2ProviderStubs();\n if (stubs.length > 0) {\n createProgressBar(stubs.length, 'Exporting providers');\n for (const stub of stubs) {\n const fileName = frodo.utils.impex.getTypedFilename(\n stub.entityId,\n 'saml'\n );\n const fileData = await frodo.saml2.entityProvider.exportSaml2Provider(\n stub.entityId\n );\n frodo.utils.impex.saveJsonToFile(fileData, fileName);\n updateProgressBar(`Exported provider ${stub.entityId}`);\n }\n stopProgressBar(`${stubs.length} providers exported.`);\n } else {\n printMessage('No entity providers found.', 'info');\n }\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} entityId Provider entity id\n * @param {String} file Import file name\n */\nexport async function importSaml2ProviderFromFile(\n entityId: string,\n file: string\n) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n showSpinner(`Importing ${entityId}...`);\n try {\n await frodo.saml2.entityProvider.importSaml2Provider(entityId, fileData);\n succeedSpinner(`Imported ${entityId}.`);\n } catch (error) {\n failSpinner(`Error importing ${entityId}: ${error.message}`);\n }\n });\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} file Import file name\n */\nexport async function importFirstSaml2ProviderFromFile(file: string) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data) as Saml2ExportInterface;\n // pick the first provider and run with it\n const entityId64 =\n Object.keys(fileData.saml.remote)[0] ||\n Object.keys(fileData.saml.hosted)[0];\n const entityId = frodo.helper.base64.decode(entityId64);\n showSpinner(`Importing ${entityId}...`);\n try {\n await frodo.saml2.entityProvider.importSaml2Provider(entityId, fileData);\n succeedSpinner(`Imported ${entityId}.`);\n } catch (error) {\n failSpinner(`Error importing ${entityId}: ${error.message}`);\n }\n });\n}\n\n/**\n * Import all SAML entity providers from file\n * @param {String} file Import file name\n */\nexport async function importSaml2ProvidersFromFile(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 await frodo.saml2.entityProvider.importSaml2Providers(fileData);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all SAML entity providers from all *.saml.json files in the current directory\n */\nexport async function importSaml2ProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.saml.json')\n );\n createProgressBar(jsonFiles.length, 'Importing providers...');\n const totalStatus: MultiOpStatusInterface = {\n total: 0,\n successes: 0,\n warnings: 0,\n failures: 0,\n };\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (frodo.utils.impex.validateImport(fileData.meta)) {\n const myStatus = await frodo.saml2.entityProvider.importSaml2Providers(\n fileData\n );\n totalStatus.total += myStatus.total;\n totalStatus.successes += myStatus.successes;\n totalStatus.warnings += myStatus.warnings;\n totalStatus.failures += myStatus.failures;\n updateProgressBar(\n `Imported ${myStatus.successes}/${myStatus.total} provider(s) from ${file}.`\n );\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressBar(\n `Imported ${totalStatus.successes} of ${totalStatus.total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AACnB,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBA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KAAK,IAAIK,QAAQ,CAACL,KAAK;MACnCD,WAAW,CAACE,SAAS,IAAII,QAAQ,CAACJ,SAAS;MAC3CF,WAAW,CAACG,QAAQ,IAAIG,QAAQ,CAACH,QAAQ;MACzCH,WAAW,CAACI,QAAQ,IAAIE,QAAQ,CAACF,QAAQ;MACzC1G,iBAAiB,CACd,YAAW4G,QAAQ,CAACJ,SAAU,IAAGI,QAAQ,CAACL,KAAM,qBAAoBlD,IAAK,GAC5E,CAAC;IACH,CAAC,MAAM;MACLzD,YAAY,CAAE,iBAAgByD,IAAK,UAAS,EAAE,OAAO,CAAC;IACxD;EACF;EACAvD,eAAe,CACZ,YAAWwG,WAAW,CAACE,SAAU,OAAMF,WAAW,CAACC,KAAM,qBAAoBN,SAAS,CAAC/E,MAAO,WACjG,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"Saml2Ops.js","names":["frodo","fs","createObjectTable","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","saveTextToFile","decode","helper","base64","getTypedFilename","saveJsonToFile","getRealmString","validateImport","utils","impex","getSaml2ProviderStubs","getProviderByLocationAndId","getSaml2ProviderStub","getProviderMetadataUrl","getProviderMetadata","exportSaml2Provider","exportSaml2Providers","importSaml2Provider","importSaml2Providers","saml2","entityProvider","roleMap","identityProvider","serviceProvider","attributeQueryProvider","xacmlPolicyEnforcementPoint","getOneLineDescription","saml2ProviderObj","roles","key","value","Object","entries","push","description","entityId","entityLocation","length","join","getTableHeaderMd","markdown","getTableRowMd","row","listSaml2Providers","long","providerList","sort","a","b","_id","localeCompare","provider","table","location","map","role","toString","describeSaml2Provider","stub","id","rawProviderData","_rev","metadataUrl","error","message","exportSaml2MetadataToFile","file","fileName","metaData","brightCyan","exportSaml2ProviderToFile","fileData","err","exportSaml2ProvidersToFile","exportData","_error$response","response","status","exportSaml2ProvidersToFiles","stubs","importSaml2ProviderFromFile","readFile","data","JSON","parse","importFirstSaml2ProviderFromFile","entityId64","keys","saml","remote","hosted","importSaml2ProvidersFromFile","meta","importSaml2ProvidersFromFiles","names","readdirSync","jsonFiles","filter","name","toLowerCase","endsWith","totalStatus","total","successes","warnings","failures","readFileSync","myStatus"],"sources":["ops/Saml2Ops.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport {\n createObjectTable,\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport { saveTextToFile } from '../utils/ExportImportUtils';\nimport type {\n MultiOpStatusInterface,\n Saml2ExportInterface,\n} from '@rockcarver/frodo-lib/types/ops/OpsTypes';\nimport type { Saml2ProviderSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\n\nconst { decode } = frodo.helper.base64;\nconst { getTypedFilename, saveJsonToFile, getRealmString, validateImport } =\n frodo.utils.impex;\nconst {\n getSaml2ProviderStubs,\n getProviderByLocationAndId,\n getSaml2ProviderStub,\n getProviderMetadataUrl,\n getProviderMetadata,\n exportSaml2Provider,\n exportSaml2Providers,\n importSaml2Provider,\n importSaml2Providers,\n} = frodo.saml2.entityProvider;\n\nconst roleMap = {\n identityProvider: 'IDP',\n serviceProvider: 'SP',\n attributeQueryProvider: 'AttrQuery',\n xacmlPolicyEnforcementPoint: 'XACML PEP',\n};\n\n/**\n * Get a one-line description of the saml2 provider object\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n saml2ProviderObj: Saml2ProviderSkeleton\n): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const description = `[${saml2ProviderObj.entityId['brightCyan']}]${\n ' (' + saml2ProviderObj.entityLocation\n }${roles.length ? ' ' + roles.join(', ') + ')' : ')'}`;\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 += '| Entity Id | Location | Role(s) |\\n';\n markdown += '| --------- | -------- | ------- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the saml2 provider in markdown\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a table-row of the saml2 provider in markdown\n */\nexport function getTableRowMd(saml2ProviderObj: Saml2ProviderSkeleton): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const row = `| ${saml2ProviderObj.entityId} | ${\n saml2ProviderObj.entityLocation\n } | ${roles.length ? roles.join(', ') : ''} |`;\n return row;\n}\n\n/**\n * List entity providers\n * @param {boolean} long Long list format with details\n */\nexport async function listSaml2Providers(long = false) {\n const providerList = await getSaml2ProviderStubs();\n providerList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const provider of providerList) {\n printMessage(`${provider.entityId}`, 'data');\n }\n } else {\n const table = createTable([\n 'Entity Id'['brightCyan'],\n 'Location'['brightCyan'],\n 'Role(s)'['brightCyan'],\n ]);\n for (const provider of providerList) {\n table.push([\n provider.entityId,\n provider.location,\n provider.roles.map((role) => roleMap[role]).join(', '),\n ]);\n }\n printMessage(table.toString());\n }\n}\n\n/**\n * Describe an entity provider's configuration\n * @param {String} entityId Provider entity id\n */\nexport async function describeSaml2Provider(entityId) {\n try {\n const stub = await getSaml2ProviderStub(entityId);\n printMessage(stub);\n const { location } = stub;\n const id = stub._id;\n const roles = stub.roles.map((role: string) => roleMap[role]).join(', ');\n const rawProviderData = await getProviderByLocationAndId(location, id);\n delete rawProviderData._id;\n delete rawProviderData._rev;\n rawProviderData.location = location;\n rawProviderData.roles = roles;\n rawProviderData.metadataUrl = getProviderMetadataUrl(entityId);\n const table = createObjectTable(rawProviderData);\n printMessage(table.toString());\n } catch (error) {\n printMessage(error.message, 'error');\n }\n}\n\n/**\n * Export provider metadata to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n */\nexport async function exportSaml2MetadataToFile(entityId, file = null) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(entityId, 'metadata', 'xml');\n }\n createProgressBar(1, `Exporting metadata for: ${entityId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const metaData = await getProviderMetadata(entityId);\n saveTextToFile(metaData, fileName);\n updateProgressBar(`Exported provider ${entityId}`);\n stopProgressBar(\n `Exported ${entityId.brightCyan} metadata to ${fileName.brightCyan}.`\n );\n } catch (error) {\n stopProgressBar(`${error}`);\n printMessage(error, 'error');\n }\n}\n\n/**\n * Export a single entity provider to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n */\nexport async function exportSaml2ProviderToFile(entityId, file = null) {\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: start [entityId=${entityId}, file=${file}]`\n );\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(entityId, 'saml');\n }\n try {\n createProgressBar(1, `Exporting provider ${entityId}`);\n const fileData = await exportSaml2Provider(entityId);\n saveJsonToFile(fileData, fileName);\n updateProgressBar(`Exported provider ${entityId}`);\n stopProgressBar(\n `Exported ${entityId.brightCyan} to ${fileName.brightCyan}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(err, 'error');\n }\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: end [entityId=${entityId}, file=${fileName}]`\n );\n}\n\n/**\n * Export all entity providers to one file\n * @param {String} file Optional filename\n */\nexport async function exportSaml2ProvidersToFile(file = null) {\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: start [file=${file}]`);\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'saml');\n }\n try {\n const exportData = await exportSaml2Providers();\n saveJsonToFile(exportData, fileName);\n } catch (error) {\n printMessage(error.message, 'error');\n printMessage(\n `exportSaml2ProvidersToFile: ${error.response?.status}`,\n 'error'\n );\n }\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: end [file=${file}]`);\n}\n\n/**\n * Export all entity providers to individual files\n */\nexport async function exportSaml2ProvidersToFiles() {\n const stubs = await getSaml2ProviderStubs();\n if (stubs.length > 0) {\n createProgressBar(stubs.length, 'Exporting providers');\n for (const stub of stubs) {\n const fileName = getTypedFilename(stub.entityId, 'saml');\n const fileData = await exportSaml2Provider(stub.entityId);\n saveJsonToFile(fileData, fileName);\n updateProgressBar(`Exported provider ${stub.entityId}`);\n }\n stopProgressBar(`${stubs.length} providers exported.`);\n } else {\n printMessage('No entity providers found.', 'info');\n }\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} entityId Provider entity id\n * @param {String} file Import file name\n */\nexport async function importSaml2ProviderFromFile(\n entityId: string,\n file: string\n) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n showSpinner(`Importing ${entityId}...`);\n try {\n await importSaml2Provider(entityId, fileData);\n succeedSpinner(`Imported ${entityId}.`);\n } catch (error) {\n failSpinner(`Error importing ${entityId}: ${error.message}`);\n }\n });\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} file Import file name\n */\nexport async function importFirstSaml2ProviderFromFile(file: string) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data) as Saml2ExportInterface;\n // pick the first provider and run with it\n const entityId64 =\n Object.keys(fileData.saml.remote)[0] ||\n Object.keys(fileData.saml.hosted)[0];\n const entityId = decode(entityId64);\n showSpinner(`Importing ${entityId}...`);\n try {\n await importSaml2Provider(entityId, fileData);\n succeedSpinner(`Imported ${entityId}.`);\n } catch (error) {\n failSpinner(`Error importing ${entityId}: ${error.message}`);\n }\n });\n}\n\n/**\n * Import all SAML entity providers from file\n * @param {String} file Import file name\n */\nexport async function importSaml2ProvidersFromFile(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 await importSaml2Providers(fileData);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all SAML entity providers from all *.saml.json files in the current directory\n */\nexport async function importSaml2ProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.saml.json')\n );\n createProgressBar(jsonFiles.length, 'Importing providers...');\n const totalStatus: MultiOpStatusInterface = {\n total: 0,\n successes: 0,\n warnings: 0,\n failures: 0,\n };\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n const myStatus = await importSaml2Providers(fileData);\n totalStatus.total += myStatus.total;\n totalStatus.successes += myStatus.successes;\n totalStatus.warnings += myStatus.warnings;\n totalStatus.failures += myStatus.failures;\n updateProgressBar(\n `Imported ${myStatus.successes}/${myStatus.total} provider(s) from ${file}.`\n );\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressBar(\n `Imported ${totalStatus.successes} of ${totalStatus.total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AACnB,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SAASC,cAAc,QAAQ,4BAA4B;AAO3D,MAAM;EAAEC;AAAO,CAAC,GAAGb,KAAK,CAACc,MAAM,CAACC,MAAM;AACtC,MAAM;EAAEC,gBAAgB;EAAEC,cAAc;EAAEC,cAAc;EAAEC;AAAe,CAAC,GACxEnB,KAAK,CAACoB,KAAK,CAACC,KAAK;AACnB,MAAM;EACJC,qBAAqB;EACrBC,0BAA0B;EAC1BC,oBAAoB;EAC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