@rockcarver/frodo-cli 2.0.0-6 → 2.0.0-7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/esm/app.js +4 -1
- package/esm/app.js.map +1 -1
- package/esm/cli/_template/something-delete.js +4 -1
- package/esm/cli/_template/something-delete.js.map +1 -1
- package/esm/cli/_template/something-describe.js +4 -1
- package/esm/cli/_template/something-describe.js.map +1 -1
- package/esm/cli/_template/something-else-delete.js +4 -1
- package/esm/cli/_template/something-else-delete.js.map +1 -1
- package/esm/cli/_template/something-else-describe.js +4 -1
- package/esm/cli/_template/something-else-describe.js.map +1 -1
- package/esm/cli/_template/something-else-export.js +4 -1
- package/esm/cli/_template/something-else-export.js.map +1 -1
- package/esm/cli/_template/something-else-import.js +4 -1
- package/esm/cli/_template/something-else-import.js.map +1 -1
- package/esm/cli/_template/something-else-list.js +4 -1
- package/esm/cli/_template/something-else-list.js.map +1 -1
- package/esm/cli/_template/something-export.js +4 -1
- package/esm/cli/_template/something-export.js.map +1 -1
- package/esm/cli/_template/something-import.js +4 -1
- package/esm/cli/_template/something-import.js.map +1 -1
- package/esm/cli/_template/something-list.js +4 -1
- package/esm/cli/_template/something-list.js.map +1 -1
- package/esm/cli/_template/something-other-delete.js +4 -1
- package/esm/cli/_template/something-other-delete.js.map +1 -1
- package/esm/cli/_template/something-other-describe.js +4 -1
- package/esm/cli/_template/something-other-describe.js.map +1 -1
- package/esm/cli/_template/something-other-export.js +4 -1
- package/esm/cli/_template/something-other-export.js.map +1 -1
- package/esm/cli/_template/something-other-import.js +4 -1
- package/esm/cli/_template/something-other-import.js.map +1 -1
- package/esm/cli/_template/something-other-list.js +4 -1
- package/esm/cli/_template/something-other-list.js.map +1 -1
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js +8 -2
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js +10 -3
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-federation-export.js +4 -1
- package/esm/cli/admin/admin-federation-export.js.map +1 -1
- package/esm/cli/admin/admin-federation-import.js +7 -4
- package/esm/cli/admin/admin-federation-import.js.map +1 -1
- package/esm/cli/admin/admin-federation-list.js +4 -1
- package/esm/cli/admin/admin-federation-list.js.map +1 -1
- package/esm/cli/admin/admin-get-access-token.js +8 -2
- package/esm/cli/admin/admin-get-access-token.js.map +1 -1
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +8 -2
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js +8 -2
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js.map +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +8 -2
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +8 -2
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-static-user-mappings.js +8 -2
- package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
- package/esm/cli/admin/admin-remove-static-user-mapping.js +8 -2
- package/esm/cli/admin/admin-remove-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-repair-org-model.js +8 -2
- package/esm/cli/admin/admin-repair-org-model.js.map +1 -1
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +8 -2
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-show-generic-extension-attributes.js +8 -2
- package/esm/cli/admin/admin-show-generic-extension-attributes.js.map +1 -1
- package/esm/cli/agent/agent-delete.js +10 -3
- package/esm/cli/agent/agent-delete.js.map +1 -1
- package/esm/cli/agent/agent-describe.js +4 -1
- package/esm/cli/agent/agent-describe.js.map +1 -1
- package/esm/cli/agent/agent-export.js +4 -1
- package/esm/cli/agent/agent-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-delete.js +10 -3
- package/esm/cli/agent/agent-gateway-delete.js.map +1 -1
- package/esm/cli/agent/agent-gateway-describe.js +4 -1
- package/esm/cli/agent/agent-gateway-describe.js.map +1 -1
- package/esm/cli/agent/agent-gateway-export.js +4 -1
- package/esm/cli/agent/agent-gateway-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-import.js +4 -1
- package/esm/cli/agent/agent-gateway-import.js.map +1 -1
- package/esm/cli/agent/agent-gateway-list.js +4 -1
- package/esm/cli/agent/agent-gateway-list.js.map +1 -1
- package/esm/cli/agent/agent-import.js +4 -1
- package/esm/cli/agent/agent-import.js.map +1 -1
- package/esm/cli/agent/agent-java-delete.js +10 -3
- package/esm/cli/agent/agent-java-delete.js.map +1 -1
- package/esm/cli/agent/agent-java-describe.js +4 -1
- package/esm/cli/agent/agent-java-describe.js.map +1 -1
- package/esm/cli/agent/agent-java-export.js +4 -1
- package/esm/cli/agent/agent-java-export.js.map +1 -1
- package/esm/cli/agent/agent-java-import.js +4 -1
- package/esm/cli/agent/agent-java-import.js.map +1 -1
- package/esm/cli/agent/agent-java-list.js +4 -1
- package/esm/cli/agent/agent-java-list.js.map +1 -1
- package/esm/cli/agent/agent-list.js +4 -1
- package/esm/cli/agent/agent-list.js.map +1 -1
- package/esm/cli/agent/agent-web-delete.js +10 -3
- package/esm/cli/agent/agent-web-delete.js.map +1 -1
- package/esm/cli/agent/agent-web-describe.js +4 -1
- package/esm/cli/agent/agent-web-describe.js.map +1 -1
- package/esm/cli/agent/agent-web-export.js +4 -1
- package/esm/cli/agent/agent-web-export.js.map +1 -1
- package/esm/cli/agent/agent-web-import.js +4 -1
- package/esm/cli/agent/agent-web-import.js.map +1 -1
- package/esm/cli/agent/agent-web-list.js +4 -1
- package/esm/cli/agent/agent-web-list.js.map +1 -1
- package/esm/cli/app/app-delete.js +4 -1
- package/esm/cli/app/app-delete.js.map +1 -1
- package/esm/cli/app/app-describe.js +4 -1
- package/esm/cli/app/app-describe.js.map +1 -1
- package/esm/cli/app/app-export.js +6 -3
- package/esm/cli/app/app-export.js.map +1 -1
- package/esm/cli/app/app-import.js +7 -4
- package/esm/cli/app/app-import.js.map +1 -1
- package/esm/cli/app/app-list.js +4 -1
- package/esm/cli/app/app-list.js.map +1 -1
- package/esm/cli/authz/authz-policy-delete.js +6 -3
- package/esm/cli/authz/authz-policy-delete.js.map +1 -1
- package/esm/cli/authz/authz-policy-describe.js +4 -1
- package/esm/cli/authz/authz-policy-describe.js.map +1 -1
- package/esm/cli/authz/authz-policy-export.js +8 -5
- package/esm/cli/authz/authz-policy-export.js.map +1 -1
- package/esm/cli/authz/authz-policy-import.js +7 -4
- package/esm/cli/authz/authz-policy-import.js.map +1 -1
- package/esm/cli/authz/authz-policy-list.js +5 -2
- package/esm/cli/authz/authz-policy-list.js.map +1 -1
- package/esm/cli/authz/authz-set-delete.js +5 -2
- package/esm/cli/authz/authz-set-delete.js.map +1 -1
- package/esm/cli/authz/authz-set-describe.js +4 -1
- package/esm/cli/authz/authz-set-describe.js.map +1 -1
- package/esm/cli/authz/authz-set-export.js +6 -3
- package/esm/cli/authz/authz-set-export.js.map +1 -1
- package/esm/cli/authz/authz-set-import.js +7 -4
- package/esm/cli/authz/authz-set-import.js.map +1 -1
- package/esm/cli/authz/authz-set-list.js +4 -1
- package/esm/cli/authz/authz-set-list.js.map +1 -1
- package/esm/cli/authz/authz-type-delete.js +6 -3
- package/esm/cli/authz/authz-type-delete.js.map +1 -1
- package/esm/cli/authz/authz-type-describe.js +5 -2
- package/esm/cli/authz/authz-type-describe.js.map +1 -1
- package/esm/cli/authz/authz-type-export.js +7 -4
- package/esm/cli/authz/authz-type-export.js.map +1 -1
- package/esm/cli/authz/authz-type-import.js +8 -5
- package/esm/cli/authz/authz-type-import.js.map +1 -1
- package/esm/cli/authz/authz-type-list.js +4 -1
- package/esm/cli/authz/authz-type-list.js.map +1 -1
- package/esm/cli/conn/conn-save.js +18 -5
- package/esm/cli/conn/conn-save.js.map +1 -1
- package/esm/cli/email/email-template-export.js +6 -3
- package/esm/cli/email/email-template-export.js.map +1 -1
- package/esm/cli/email/email-template-import.js +7 -4
- package/esm/cli/email/email-template-import.js.map +1 -1
- package/esm/cli/email/email-template-list.js +4 -1
- package/esm/cli/email/email-template-list.js.map +1 -1
- package/esm/cli/esv/esv-apply.js +15 -5
- package/esm/cli/esv/esv-apply.js.map +1 -1
- package/esm/cli/esv/esv-secret-create.js +4 -1
- package/esm/cli/esv/esv-secret-create.js.map +1 -1
- package/esm/cli/esv/esv-secret-delete.js +5 -2
- package/esm/cli/esv/esv-secret-delete.js.map +1 -1
- package/esm/cli/esv/esv-secret-describe.js +4 -1
- package/esm/cli/esv/esv-secret-describe.js.map +1 -1
- package/esm/cli/esv/esv-secret-export.js +4 -1
- package/esm/cli/esv/esv-secret-export.js.map +1 -1
- package/esm/cli/esv/esv-secret-import.js +4 -1
- package/esm/cli/esv/esv-secret-import.js.map +1 -1
- package/esm/cli/esv/esv-secret-list.js +4 -1
- package/esm/cli/esv/esv-secret-list.js.map +1 -1
- package/esm/cli/esv/esv-secret-set.js +4 -1
- package/esm/cli/esv/esv-secret-set.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-activate.js +4 -1
- package/esm/cli/esv/esv-secret-version-activate.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-create.js +4 -1
- package/esm/cli/esv/esv-secret-version-create.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-deactivate.js +4 -1
- package/esm/cli/esv/esv-secret-version-deactivate.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-delete.js +5 -2
- package/esm/cli/esv/esv-secret-version-delete.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-list.js +4 -1
- package/esm/cli/esv/esv-secret-version-list.js.map +1 -1
- package/esm/cli/esv/esv-variable-create.js +4 -1
- package/esm/cli/esv/esv-variable-create.js.map +1 -1
- package/esm/cli/esv/esv-variable-delete.js +5 -2
- package/esm/cli/esv/esv-variable-delete.js.map +1 -1
- package/esm/cli/esv/esv-variable-describe.js +4 -1
- package/esm/cli/esv/esv-variable-describe.js.map +1 -1
- package/esm/cli/esv/esv-variable-export.js +4 -1
- package/esm/cli/esv/esv-variable-export.js.map +1 -1
- package/esm/cli/esv/esv-variable-import.js +4 -1
- package/esm/cli/esv/esv-variable-import.js.map +1 -1
- package/esm/cli/esv/esv-variable-list.js +4 -1
- package/esm/cli/esv/esv-variable-list.js.map +1 -1
- package/esm/cli/esv/esv-variable-set.js +5 -2
- package/esm/cli/esv/esv-variable-set.js.map +1 -1
- package/esm/cli/idm/idm-count.js +4 -1
- package/esm/cli/idm/idm-count.js.map +1 -1
- package/esm/cli/idm/idm-export.js +6 -3
- package/esm/cli/idm/idm-export.js.map +1 -1
- package/esm/cli/idm/idm-import.js +7 -4
- package/esm/cli/idm/idm-import.js.map +1 -1
- package/esm/cli/idm/idm-list.js +4 -1
- package/esm/cli/idm/idm-list.js.map +1 -1
- package/esm/cli/idp/idp-export.js +4 -1
- package/esm/cli/idp/idp-export.js.map +1 -1
- package/esm/cli/idp/idp-import.js +7 -4
- package/esm/cli/idp/idp-import.js.map +1 -1
- package/esm/cli/idp/idp-list.js +4 -1
- package/esm/cli/idp/idp-list.js.map +1 -1
- package/esm/cli/info/info.js +8 -2
- package/esm/cli/info/info.js.map +1 -1
- package/esm/cli/journey/journey-delete.js +5 -2
- package/esm/cli/journey/journey-delete.js.map +1 -1
- package/esm/cli/journey/journey-describe.js +14 -6
- package/esm/cli/journey/journey-describe.js.map +1 -1
- package/esm/cli/journey/journey-disable.js +8 -2
- package/esm/cli/journey/journey-disable.js.map +1 -1
- package/esm/cli/journey/journey-enable.js +8 -2
- package/esm/cli/journey/journey-enable.js.map +1 -1
- package/esm/cli/journey/journey-export.js +6 -3
- package/esm/cli/journey/journey-export.js.map +1 -1
- package/esm/cli/journey/journey-import.js +7 -4
- package/esm/cli/journey/journey-import.js.map +1 -1
- package/esm/cli/journey/journey-list.js +4 -1
- package/esm/cli/journey/journey-list.js.map +1 -1
- package/esm/cli/journey/journey-prune.js +10 -3
- package/esm/cli/journey/journey-prune.js.map +1 -1
- package/esm/cli/log/log-fetch.js +16 -6
- package/esm/cli/log/log-fetch.js.map +1 -1
- package/esm/cli/log/log-key-delete.js +5 -2
- package/esm/cli/log/log-key-delete.js.map +1 -1
- package/esm/cli/log/log-key-describe.js +4 -1
- package/esm/cli/log/log-key-describe.js.map +1 -1
- package/esm/cli/log/log-key-list.js +4 -1
- package/esm/cli/log/log-key-list.js.map +1 -1
- package/esm/cli/log/log-list.js +14 -4
- package/esm/cli/log/log-list.js.map +1 -1
- package/esm/cli/log/log-tail.js +16 -6
- package/esm/cli/log/log-tail.js.map +1 -1
- package/esm/cli/realm/realm-add-custom-domain.js +4 -1
- package/esm/cli/realm/realm-add-custom-domain.js.map +1 -1
- package/esm/cli/realm/realm-describe.js +4 -1
- package/esm/cli/realm/realm-describe.js.map +1 -1
- package/esm/cli/realm/realm-list.js +4 -1
- package/esm/cli/realm/realm-list.js.map +1 -1
- package/esm/cli/realm/realm-remove-custom-domain.js +8 -2
- package/esm/cli/realm/realm-remove-custom-domain.js.map +1 -1
- package/esm/cli/saml/saml-cot-export.js +6 -3
- package/esm/cli/saml/saml-cot-export.js.map +1 -1
- package/esm/cli/saml/saml-cot-import.js +7 -4
- package/esm/cli/saml/saml-cot-import.js.map +1 -1
- package/esm/cli/saml/saml-cot-list.js +4 -1
- package/esm/cli/saml/saml-cot-list.js.map +1 -1
- package/esm/cli/saml/saml-delete.js +11 -4
- package/esm/cli/saml/saml-delete.js.map +1 -1
- package/esm/cli/saml/saml-describe.js +4 -1
- package/esm/cli/saml/saml-describe.js.map +1 -1
- package/esm/cli/saml/saml-export.js +6 -3
- package/esm/cli/saml/saml-export.js.map +1 -1
- package/esm/cli/saml/saml-import.js +7 -4
- package/esm/cli/saml/saml-import.js.map +1 -1
- package/esm/cli/saml/saml-list.js +4 -1
- package/esm/cli/saml/saml-list.js.map +1 -1
- package/esm/cli/saml/saml-metadata-export.js +5 -2
- package/esm/cli/saml/saml-metadata-export.js.map +1 -1
- package/esm/cli/script/script-delete.js +4 -1
- package/esm/cli/script/script-delete.js.map +1 -1
- package/esm/cli/script/script-describe.js +4 -1
- package/esm/cli/script/script-describe.js.map +1 -1
- package/esm/cli/script/script-export.js +4 -1
- package/esm/cli/script/script-export.js.map +1 -1
- package/esm/cli/script/script-import.js +4 -1
- package/esm/cli/script/script-import.js.map +1 -1
- package/esm/cli/script/script-list.js +4 -1
- package/esm/cli/script/script-list.js.map +1 -1
- package/esm/cli/service/service-delete.js +5 -2
- package/esm/cli/service/service-delete.js.map +1 -1
- package/esm/cli/service/service-export.js +6 -3
- package/esm/cli/service/service-export.js.map +1 -1
- package/esm/cli/service/service-import.js +7 -4
- package/esm/cli/service/service-import.js.map +1 -1
- package/esm/cli/service/service-list.js +4 -1
- package/esm/cli/service/service-list.js.map +1 -1
- package/esm/cli/theme/theme-delete.js +6 -3
- package/esm/cli/theme/theme-delete.js.map +1 -1
- package/esm/cli/theme/theme-export.js +7 -4
- package/esm/cli/theme/theme-export.js.map +1 -1
- package/esm/cli/theme/theme-import.js +8 -5
- package/esm/cli/theme/theme-import.js.map +1 -1
- package/esm/cli/theme/theme-list.js +4 -1
- package/esm/cli/theme/theme-list.js.map +1 -1
- package/esm/ops/AdminFederationOps.js +17 -9
- package/esm/ops/AdminFederationOps.js.map +1 -1
- package/esm/ops/AgentOps.js +62 -36
- package/esm/ops/AgentOps.js.map +1 -1
- package/esm/ops/CirclesOfTrustOps.js +22 -10
- package/esm/ops/CirclesOfTrustOps.js.map +1 -1
- package/esm/ops/ConnectionProfileOps.js +10 -3
- package/esm/ops/ConnectionProfileOps.js.map +1 -1
- package/esm/ops/EmailTemplateOps.js +23 -15
- package/esm/ops/EmailTemplateOps.js.map +1 -1
- package/esm/ops/IdmOps.js +34 -21
- package/esm/ops/IdmOps.js.map +1 -1
- package/esm/ops/IdpOps.js +17 -9
- package/esm/ops/IdpOps.js.map +1 -1
- package/esm/ops/JourneyOps.js +46 -30
- package/esm/ops/JourneyOps.js.map +1 -1
- package/esm/ops/LogOps.js +21 -11
- package/esm/ops/LogOps.js.map +1 -1
- package/esm/ops/NodeOps.js +5 -2
- package/esm/ops/NodeOps.js.map +1 -1
- package/esm/ops/OAuth2ClientOps.js +25 -12
- package/esm/ops/OAuth2ClientOps.js.map +1 -1
- package/esm/ops/OrganizationOps.js +8 -2
- package/esm/ops/OrganizationOps.js.map +1 -1
- package/esm/ops/PolicyOps.js +36 -21
- package/esm/ops/PolicyOps.js.map +1 -1
- package/esm/ops/PolicySetOps.js +35 -18
- package/esm/ops/PolicySetOps.js.map +1 -1
- package/esm/ops/RealmOps.js +11 -6
- package/esm/ops/RealmOps.js.map +1 -1
- package/esm/ops/ResourceTypeOps.js +34 -18
- package/esm/ops/ResourceTypeOps.js.map +1 -1
- package/esm/ops/Saml2Ops.js +43 -23
- package/esm/ops/Saml2Ops.js.map +1 -1
- package/esm/ops/ScriptOps.js +18 -10
- package/esm/ops/ScriptOps.js.map +1 -1
- package/esm/ops/SecretsOps.js +28 -14
- package/esm/ops/SecretsOps.js.map +1 -1
- package/esm/ops/ServiceOps.js +38 -17
- package/esm/ops/ServiceOps.js.map +1 -1
- package/esm/ops/ThemeOps.js +35 -19
- package/esm/ops/ThemeOps.js.map +1 -1
- package/esm/ops/VariablesOps.js +23 -12
- package/esm/ops/VariablesOps.js.map +1 -1
- package/esm/utils/Config.js +6 -3
- package/esm/utils/Config.js.map +1 -1
- package/esm/utils/Console.js +5 -2
- package/esm/utils/Console.js.map +1 -1
- package/esm/utils/ExportImportUtils.js +6 -3
- package/esm/utils/ExportImportUtils.js.map +1 -1
- package/esm/utils/Version.js +7 -3
- package/esm/utils/Version.js.map +1 -1
- package/package.json +2 -2
package/esm/ops/IdpOps.js
CHANGED
|
@@ -2,6 +2,14 @@ import { frodo } from '@rockcarver/frodo-lib';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { createProgressBar, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
|
|
4
4
|
import { getRealmString, getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
|
|
5
|
+
const {
|
|
6
|
+
getSocialIdentityProviders,
|
|
7
|
+
exportSocialProvider,
|
|
8
|
+
exportSocialProviders,
|
|
9
|
+
importFirstSocialProvider,
|
|
10
|
+
importSocialProvider,
|
|
11
|
+
importSocialProviders
|
|
12
|
+
} = frodo.oauth2oidc.external;
|
|
5
13
|
|
|
6
14
|
/**
|
|
7
15
|
* Get a one-line description of the social idp object
|
|
@@ -39,7 +47,7 @@ export function getTableRowMd(socialIdpObj) {
|
|
|
39
47
|
*/
|
|
40
48
|
export async function listSocialProviders() {
|
|
41
49
|
try {
|
|
42
|
-
const providers = await
|
|
50
|
+
const providers = await getSocialIdentityProviders();
|
|
43
51
|
providers.sort((a, b) => a._id.localeCompare(b._id));
|
|
44
52
|
providers.forEach(socialIdentityProvider => {
|
|
45
53
|
printMessage(`${socialIdentityProvider._id}`, 'data');
|
|
@@ -64,7 +72,7 @@ export async function exportSocialProviderToFile(providerId, file = '') {
|
|
|
64
72
|
createProgressBar(1, `Exporting ${providerId}`);
|
|
65
73
|
try {
|
|
66
74
|
updateProgressBar(`Writing file ${fileName}`);
|
|
67
|
-
const fileData = await
|
|
75
|
+
const fileData = await exportSocialProvider(providerId);
|
|
68
76
|
saveJsonToFile(fileData, fileName);
|
|
69
77
|
stopProgressBar(`Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`);
|
|
70
78
|
} catch (err) {
|
|
@@ -83,7 +91,7 @@ export async function exportSocialProvidersToFile(file = '') {
|
|
|
83
91
|
if (!fileName) {
|
|
84
92
|
fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');
|
|
85
93
|
}
|
|
86
|
-
const fileData = await
|
|
94
|
+
const fileData = await exportSocialProviders();
|
|
87
95
|
saveJsonToFile(fileData, fileName);
|
|
88
96
|
}
|
|
89
97
|
|
|
@@ -93,12 +101,12 @@ export async function exportSocialProvidersToFile(file = '') {
|
|
|
93
101
|
export async function exportSocialProvidersToFiles() {
|
|
94
102
|
debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: start`);
|
|
95
103
|
try {
|
|
96
|
-
const allIdpsData = await
|
|
104
|
+
const allIdpsData = await getSocialIdentityProviders();
|
|
97
105
|
createProgressBar(allIdpsData.length, 'Exporting providers');
|
|
98
106
|
for (const idpData of allIdpsData) {
|
|
99
107
|
try {
|
|
100
108
|
const fileName = getTypedFilename(idpData._id, 'idp');
|
|
101
|
-
const fileData = await
|
|
109
|
+
const fileData = await exportSocialProvider(idpData._id);
|
|
102
110
|
saveJsonToFile(fileData, fileName);
|
|
103
111
|
updateProgressBar(`Exported provider ${idpData._id}`);
|
|
104
112
|
} catch (error) {
|
|
@@ -126,7 +134,7 @@ export async function importSocialProviderFromFile(providerId, file) {
|
|
|
126
134
|
if (err) throw err;
|
|
127
135
|
try {
|
|
128
136
|
const fileData = JSON.parse(data);
|
|
129
|
-
outcome = await
|
|
137
|
+
outcome = await importSocialProvider(providerId, fileData);
|
|
130
138
|
succeedSpinner(`Successfully imported provider ${providerId} from ${file}.`);
|
|
131
139
|
} catch (error) {
|
|
132
140
|
var _error$response;
|
|
@@ -149,7 +157,7 @@ export async function importFirstSocialProviderFromFile(file) {
|
|
|
149
157
|
if (err) throw err;
|
|
150
158
|
try {
|
|
151
159
|
const fileData = JSON.parse(data);
|
|
152
|
-
outcome = await
|
|
160
|
+
outcome = await importFirstSocialProvider(fileData);
|
|
153
161
|
succeedSpinner(`Successfully imported first provider from ${file}.`);
|
|
154
162
|
} catch (error) {
|
|
155
163
|
var _error$response2;
|
|
@@ -172,7 +180,7 @@ export async function importSocialProvidersFromFile(file) {
|
|
|
172
180
|
if (err) throw err;
|
|
173
181
|
try {
|
|
174
182
|
const fileData = JSON.parse(data);
|
|
175
|
-
outcome = await
|
|
183
|
+
outcome = await importSocialProviders(fileData);
|
|
176
184
|
succeedSpinner(`Successfully imported providers from ${file}.`);
|
|
177
185
|
} catch (error) {
|
|
178
186
|
var _error$response3;
|
|
@@ -196,7 +204,7 @@ export async function importSocialProvidersFromFiles() {
|
|
|
196
204
|
const fileData = JSON.parse(data);
|
|
197
205
|
const count = Object.keys(fileData.idp).length;
|
|
198
206
|
total += count;
|
|
199
|
-
await
|
|
207
|
+
await importSocialProviders(fileData);
|
|
200
208
|
updateProgressBar(`Imported ${count} provider(s) from ${file}`);
|
|
201
209
|
}
|
|
202
210
|
stopProgressBar(`Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`);
|
package/esm/ops/IdpOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdpOps.js","names":["frodo","fs","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getRealmString","getTypedFilename","saveJsonToFile","getOneLineDescription","socialIdpObj","description","_id","_type","getTableHeaderMd","markdown","getTableRowMd","row","enabled","name","listSocialProviders","providers","oauth2oidc","external","getSocialIdentityProviders","sort","a","b","localeCompare","forEach","socialIdentityProvider","err","message","exportSocialProviderToFile","providerId","file","fileName","fileData","exportSocialProvider","exportSocialProvidersToFile","exportSocialProviders","exportSocialProvidersToFiles","allIdpsData","length","idpData","error","importSocialProviderFromFile","outcome","readFile","data","JSON","parse","importSocialProvider","_error$response","response","importFirstSocialProviderFromFile","importFirstSocialProvider","_error$response2","importSocialProvidersFromFile","importSocialProviders","_error$response3","importSocialProvidersFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","total","readFileSync","count","Object","keys","idp"],"sources":["ops/IdpOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport type { SocialIdpSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport {\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n} from '../utils/ExportImportUtils';\n\n/**\n * Get a one-line description of the social idp object\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(socialIdpObj: SocialIdpSkeleton): string {\n const description = `[${socialIdpObj._id['brightCyan']}] ${socialIdpObj._type._id}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Type |\\n';\n markdown += '| ------- | ------ | ---- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the social idp in markdown\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a table-row of the social idp in markdown\n */\nexport function getTableRowMd(socialIdpObj: SocialIdpSkeleton): string {\n const row = `| ${socialIdpObj._id} | ${\n socialIdpObj.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n } | ${socialIdpObj._type.name} |`;\n return row;\n}\n\n/**\n * List providers\n */\nexport async function listSocialProviders() {\n try {\n const providers =\n await frodo.oauth2oidc.external.getSocialIdentityProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n } catch (err) {\n printMessage(`listSocialProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n */\nexport async function exportSocialProviderToFile(\n providerId: string,\n file = ''\n) {\n debugMessage(`cli.IdpOps.exportSocialProviderToFile: start`);\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'idp');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await frodo.oauth2oidc.external.exportSocialProvider(\n providerId\n );\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialProviderToFile: end`);\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n */\nexport async function exportSocialProvidersToFile(file = '') {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');\n }\n const fileData = await frodo.oauth2oidc.external.exportSocialProviders();\n saveJsonToFile(fileData, fileName);\n}\n\n/**\n * Export all providers to individual files\n */\nexport async function exportSocialProvidersToFiles() {\n debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: start`);\n try {\n const allIdpsData =\n await frodo.oauth2oidc.external.getSocialIdentityProviders();\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n try {\n const fileName = getTypedFilename(idpData._id, 'idp');\n const fileData = await frodo.oauth2oidc.external.exportSocialProvider(\n idpData._id\n );\n saveJsonToFile(fileData, fileName);\n updateProgressBar(`Exported provider ${idpData._id}`);\n } catch (error) {\n printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');\n }\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n } catch (error) {\n stopProgressBar(`${error}`);\n printMessage(`${error}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: end`);\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if provider was imported successfully, false otherwise\n */\nexport async function importSocialProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing provider ${providerId} from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await frodo.oauth2oidc.external.importSocialProvider(\n providerId,\n fileData\n );\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise\n */\nexport async function importFirstSocialProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing first provider from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await frodo.oauth2oidc.external.importFirstSocialProvider(\n fileData\n );\n succeedSpinner(`Successfully imported first provider from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing first provider from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise\n */\nexport async function importSocialProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing providers from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await frodo.oauth2oidc.external.importSocialProviders(fileData);\n succeedSpinner(`Successfully imported providers from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing providers from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n */\nexport async function importSocialProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.idp.json')\n );\n\n createProgressBar(jsonFiles.length, 'Importing providers...');\n let total = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await frodo.oauth2oidc.external.importSocialProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,cAAc,EACdC,gBAAgB,EAChBC,cAAc,QACT,4BAA4B;;AAEnC;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAACC,YAA+B,EAAU;EAC7E,MAAMC,WAAW,GAAI,IAAGD,YAAY,CAACE,GAAG,CAAC,YAAY,CAAE,KAAIF,YAAY,CAACG,KAAK,CAACD,GAAI,EAAC;EACnF,OAAOD,WAAW;AACpB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,gBAAgBA,CAAA,EAAW;EACzC,IAAIC,QAAQ,GAAG,EAAE;EACjBA,QAAQ,IAAI,+BAA+B;EAC3CA,QAAQ,IAAI,6BAA6B;EACzC,OAAOA,QAAQ;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACN,YAA+B,EAAU;EACrE,MAAMO,GAAG,GAAI,KAAIP,YAAY,CAACE,GAAI,MAChCF,YAAY,CAACQ,OAAO,KAAK,KAAK,GAC1B,gBAAgB,GAChB,8BACL,MAAKR,YAAY,CAACG,KAAK,CAACM,IAAK,IAAG;EACjC,OAAOF,GAAG;AACZ;;AAEA;AACA;AACA;AACA,OAAO,eAAeG,mBAAmBA,CAAA,EAAG;EAC1C,IAAI;IACF,MAAMC,SAAS,GACb,MAAMzB,KAAK,CAAC0B,UAAU,CAACC,QAAQ,CAACC,0BAA0B,CAAC,CAAC;IAC9DH,SAAS,CAACI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iCmC,IAAK,GAAE,CAAC;MACtDlC,YAAY,CAAC,EAAA2D,gBAAA,GAAAf,KAAK,CAACS,QAAQ,cAAAM,gBAAA,uBAAdA,gBAAA,CAAgBX,IAAI,KAAIJ,KAAK,EAAE,OAAO,CAAC;IACtD;EACF,CAAC,CAAC;EACF,OAAOE,OAAO;AAChB;;AAEA;AACA;AACA;AACA,OAAO,eAAec,8BAA8BA,CAAA,EAAG;EACrD,MAAMC,KAAK,GAAGjE,EAAE,CAACkE,WAAW,CAAC,GAAG,CAAC;EACjC,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAE9C,IAAI,IAClCA,IAAI,CAAC+C,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,WAAW,CACzC,CAAC;EAEDrE,iBAAiB,CAACkE,SAAS,CAACrB,MAAM,EAAE,wBAAwB,CAAC;EAC7D,IAAIyB,KAAK,GAAG,CAAC;EACb,KAAK,MAAMjC,IAAI,IAAI6B,SAAS,EAAE;IAC5B,MAAMf,IAAI,GAAGpD,EAAE,CAACwE,YAAY,CAAClC,IAAI,EAAE,MAAM,CAAC;IAC1C,MAAME,QAAQ,GAAGa,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC;IACjC,MAAMqB,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACnC,QAAQ,CAACoC,GAAG,CAAC,CAAC9B,MAAM;IAC9CyB,KAAK,IAAIE,KAAK;IACd,MAAM1E,KAAK,CAAC0B,UAAU,CAACC,QAAQ,CAACoC,qBAAqB,CAACtB,QAAQ,CAAC;IAC/DhC,iBAAiB,CAAE,YAAWiE,KAAM,qBAAoBnC,IAAK,EAAC,CAAC;EACjE;EACAhC,eAAe,CACZ,sBAAqBiE,KAAM,qBAAoBJ,SAAS,CAACrB,MAAO,WACnE,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"IdpOps.js","names":["frodo","fs","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getRealmString","getTypedFilename","saveJsonToFile","getSocialIdentityProviders","exportSocialProvider","exportSocialProviders","importFirstSocialProvider","importSocialProvider","importSocialProviders","oauth2oidc","external","getOneLineDescription","socialIdpObj","description","_id","_type","getTableHeaderMd","markdown","getTableRowMd","row","enabled","name","listSocialProviders","providers","sort","a","b","localeCompare","forEach","socialIdentityProvider","err","message","exportSocialProviderToFile","providerId","file","fileName","fileData","exportSocialProvidersToFile","exportSocialProvidersToFiles","allIdpsData","length","idpData","error","importSocialProviderFromFile","outcome","readFile","data","JSON","parse","_error$response","response","importFirstSocialProviderFromFile","_error$response2","importSocialProvidersFromFile","_error$response3","importSocialProvidersFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","total","readFileSync","count","Object","keys","idp"],"sources":["ops/IdpOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport type { SocialIdpSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport {\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n} from '../utils/ExportImportUtils';\n\nconst {\n getSocialIdentityProviders,\n exportSocialProvider,\n exportSocialProviders,\n importFirstSocialProvider,\n importSocialProvider,\n importSocialProviders,\n} = frodo.oauth2oidc.external;\n\n/**\n * Get a one-line description of the social idp object\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(socialIdpObj: SocialIdpSkeleton): string {\n const description = `[${socialIdpObj._id['brightCyan']}] ${socialIdpObj._type._id}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Type |\\n';\n markdown += '| ------- | ------ | ---- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the social idp in markdown\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a table-row of the social idp in markdown\n */\nexport function getTableRowMd(socialIdpObj: SocialIdpSkeleton): string {\n const row = `| ${socialIdpObj._id} | ${\n socialIdpObj.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n } | ${socialIdpObj._type.name} |`;\n return row;\n}\n\n/**\n * List providers\n */\nexport async function listSocialProviders() {\n try {\n const providers = await getSocialIdentityProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n } catch (err) {\n printMessage(`listSocialProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n */\nexport async function exportSocialProviderToFile(\n providerId: string,\n file = ''\n) {\n debugMessage(`cli.IdpOps.exportSocialProviderToFile: start`);\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'idp');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await exportSocialProvider(providerId);\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialProviderToFile: end`);\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n */\nexport async function exportSocialProvidersToFile(file = '') {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');\n }\n const fileData = await exportSocialProviders();\n saveJsonToFile(fileData, fileName);\n}\n\n/**\n * Export all providers to individual files\n */\nexport async function exportSocialProvidersToFiles() {\n debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: start`);\n try {\n const allIdpsData = await getSocialIdentityProviders();\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n try {\n const fileName = getTypedFilename(idpData._id, 'idp');\n const fileData = await exportSocialProvider(idpData._id);\n saveJsonToFile(fileData, fileName);\n updateProgressBar(`Exported provider ${idpData._id}`);\n } catch (error) {\n printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');\n }\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n } catch (error) {\n stopProgressBar(`${error}`);\n printMessage(`${error}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: end`);\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if provider was imported successfully, false otherwise\n */\nexport async function importSocialProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing provider ${providerId} from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await importSocialProvider(providerId, fileData);\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise\n */\nexport async function importFirstSocialProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing first provider from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await importFirstSocialProvider(fileData);\n succeedSpinner(`Successfully imported first provider from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing first provider from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise\n */\nexport async function importSocialProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing providers from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await importSocialProviders(fileData);\n succeedSpinner(`Successfully imported providers from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing providers from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n */\nexport async function importSocialProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.idp.json')\n );\n\n createProgressBar(jsonFiles.length, 'Importing providers...');\n let total = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await importSocialProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,cAAc,EACdC,gBAAgB,EAChBC,cAAc,QACT,4BAA4B;AAEnC,MAAM;EACJC,0BAA0B;EAC1BC,oBAAoB;EACpBC,qBAAqB;EACrBC,yBAAyB;EACzBC,oBAAoB;EACpBC;AACF,CAAC,GAAGlB,KAAK,CAACmB,UAAU,CAACC,QAAQ;;AAE7B;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAACC,YAA+B,EAAU;EAC7E,MAAMC,WAAW,GAAI,IAAGD,YAAY,CAACE,GAAG,CAAC,YAAY,CAAE,KAAIF,YAAY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IE,KAAK;IACd,MAAMxD,qBAAqB,CAAC4B,QAAQ,CAAC;IACrCrC,iBAAiB,CAAE,YAAWiE,KAAM,qBAAoB9B,IAAK,EAAC,CAAC;EACjE;EACArC,eAAe,CACZ,sBAAqBiE,KAAM,qBAAoBJ,SAAS,CAAClB,MAAO,WACnE,CAAC;AACH"}
|
package/esm/ops/JourneyOps.js
CHANGED
|
@@ -10,6 +10,22 @@ import * as Script from './ScriptOps';
|
|
|
10
10
|
import * as Theme from './ThemeOps';
|
|
11
11
|
import wordwrap from './utils/Wordwrap';
|
|
12
12
|
import { cloneDeep } from './utils/OpsUtils';
|
|
13
|
+
const {
|
|
14
|
+
getTypedFilename,
|
|
15
|
+
saveJsonToFile,
|
|
16
|
+
getRealmString
|
|
17
|
+
} = frodo.utils.impex;
|
|
18
|
+
const {
|
|
19
|
+
getJourneys,
|
|
20
|
+
exportJourney,
|
|
21
|
+
createMultiTreeExportTemplate,
|
|
22
|
+
resolveDependencies,
|
|
23
|
+
importAllJourneys,
|
|
24
|
+
importJourney,
|
|
25
|
+
getTreeDescendents,
|
|
26
|
+
getNodeRef,
|
|
27
|
+
onlineTreeExportResolver
|
|
28
|
+
} = frodo.authn.journey;
|
|
13
29
|
|
|
14
30
|
/**
|
|
15
31
|
* List all the journeys/trees
|
|
@@ -20,7 +36,7 @@ import { cloneDeep } from './utils/OpsUtils';
|
|
|
20
36
|
export async function listJourneys(long = false, analyze = false) {
|
|
21
37
|
let journeys = [];
|
|
22
38
|
try {
|
|
23
|
-
journeys = await
|
|
39
|
+
journeys = await getJourneys();
|
|
24
40
|
if (!long && !analyze) {
|
|
25
41
|
for (const journeyStub of journeys) {
|
|
26
42
|
printMessage(`${journeyStub['_id']}`, 'data');
|
|
@@ -38,7 +54,7 @@ export async function listJourneys(long = false, analyze = false) {
|
|
|
38
54
|
const exportPromises = [];
|
|
39
55
|
try {
|
|
40
56
|
for (const journeyStub of journeys) {
|
|
41
|
-
exportPromises.push(
|
|
57
|
+
exportPromises.push(exportJourney(journeyStub['_id'], {
|
|
42
58
|
useStringArrays: false,
|
|
43
59
|
deps: false
|
|
44
60
|
}));
|
|
@@ -74,7 +90,7 @@ export async function exportJourneyToFile(journeyId, file, options) {
|
|
|
74
90
|
debugMessage(`exportJourneyToFile: start`);
|
|
75
91
|
const verbose = state.getDebug();
|
|
76
92
|
if (!file) {
|
|
77
|
-
file =
|
|
93
|
+
file = getTypedFilename(journeyId, 'journey');
|
|
78
94
|
}
|
|
79
95
|
if (state.getDirectory()) {
|
|
80
96
|
const dir = state.getDirectory().replace(/\/$/, '');
|
|
@@ -90,9 +106,9 @@ export async function exportJourneyToFile(journeyId, file, options) {
|
|
|
90
106
|
}
|
|
91
107
|
if (!verbose) showSpinner(`${journeyId}`);
|
|
92
108
|
try {
|
|
93
|
-
const fileData = await
|
|
109
|
+
const fileData = await exportJourney(journeyId, options);
|
|
94
110
|
if (verbose) showSpinner(`${journeyId}`);
|
|
95
|
-
|
|
111
|
+
saveJsonToFile(fileData, file);
|
|
96
112
|
succeedSpinner(`Exported ${journeyId['brightCyan']} to ${file['brightCyan']}.`);
|
|
97
113
|
} catch (error) {
|
|
98
114
|
if (verbose) showSpinner(`${journeyId}`);
|
|
@@ -111,22 +127,22 @@ export async function exportJourneysToFile(file, options = {
|
|
|
111
127
|
}) {
|
|
112
128
|
let fileName = file;
|
|
113
129
|
if (!fileName) {
|
|
114
|
-
fileName =
|
|
130
|
+
fileName = getTypedFilename(`all${getRealmString()}Journeys`, 'journeys');
|
|
115
131
|
}
|
|
116
|
-
const trees = await
|
|
117
|
-
const fileData =
|
|
132
|
+
const trees = await getJourneys();
|
|
133
|
+
const fileData = createMultiTreeExportTemplate();
|
|
118
134
|
createProgressBar(trees.length, 'Exporting journeys...');
|
|
119
135
|
for (const tree of trees) {
|
|
120
136
|
updateProgressBar(`${tree._id}`);
|
|
121
137
|
try {
|
|
122
|
-
const exportData = await
|
|
138
|
+
const exportData = await exportJourney(tree._id, options);
|
|
123
139
|
delete exportData.meta;
|
|
124
140
|
fileData.trees[tree._id] = exportData;
|
|
125
141
|
} catch (error) {
|
|
126
142
|
printMessage(`Error exporting journey ${tree._id}: ${error}`, 'error');
|
|
127
143
|
}
|
|
128
144
|
}
|
|
129
|
-
|
|
145
|
+
saveJsonToFile(fileData, fileName);
|
|
130
146
|
stopProgressBar(`Exported to ${fileName}`);
|
|
131
147
|
}
|
|
132
148
|
|
|
@@ -135,14 +151,14 @@ export async function exportJourneysToFile(file, options = {
|
|
|
135
151
|
* @param {TreeExportOptions} options export options
|
|
136
152
|
*/
|
|
137
153
|
export async function exportJourneysToFiles(options) {
|
|
138
|
-
const trees = await
|
|
154
|
+
const trees = await getJourneys();
|
|
139
155
|
createProgressBar(trees.length, 'Exporting journeys...');
|
|
140
156
|
for (const tree of trees) {
|
|
141
157
|
updateProgressBar(`${tree._id}`);
|
|
142
|
-
const fileName =
|
|
158
|
+
const fileName = getTypedFilename(`${tree._id}`, 'journey');
|
|
143
159
|
try {
|
|
144
|
-
const exportData = await
|
|
145
|
-
|
|
160
|
+
const exportData = await exportJourney(tree._id, options);
|
|
161
|
+
saveJsonToFile(exportData, fileName);
|
|
146
162
|
} catch (error) {
|
|
147
163
|
// do we need to report status here?
|
|
148
164
|
}
|
|
@@ -171,17 +187,17 @@ export async function importJourneyFromFile(journeyId, file, options) {
|
|
|
171
187
|
// if a journeyId was specified, only import the matching journey
|
|
172
188
|
if (journeyData && journeyId === journeyData.tree._id) {
|
|
173
189
|
// attempt dependency resolution for single tree import
|
|
174
|
-
const installedJourneys = (await
|
|
190
|
+
const installedJourneys = (await getJourneys()).map(x => x._id);
|
|
175
191
|
const unresolvedJourneys = {};
|
|
176
192
|
const resolvedJourneys = [];
|
|
177
193
|
showSpinner('Resolving dependencies');
|
|
178
|
-
await
|
|
194
|
+
await resolveDependencies(installedJourneys, {
|
|
179
195
|
[journeyId]: journeyData
|
|
180
196
|
}, unresolvedJourneys, resolvedJourneys);
|
|
181
197
|
if (Object.keys(unresolvedJourneys).length === 0) {
|
|
182
198
|
succeedSpinner(`Resolved all dependencies.`);
|
|
183
199
|
if (!verbose) showSpinner(`Importing ${journeyId}...`);
|
|
184
|
-
|
|
200
|
+
importJourney(journeyData, options).then(() => {
|
|
185
201
|
if (verbose) showSpinner(`Importing ${journeyId}...`);
|
|
186
202
|
succeedSpinner(`Imported ${journeyId}.`);
|
|
187
203
|
}).catch(importError => {
|
|
@@ -231,17 +247,17 @@ export async function importFirstJourneyFromFile(file, options) {
|
|
|
231
247
|
// if a journeyId was specified, only import the matching journey
|
|
232
248
|
if (journeyData && journeyId) {
|
|
233
249
|
// attempt dependency resolution for single tree import
|
|
234
|
-
const installedJourneys = (await
|
|
250
|
+
const installedJourneys = (await getJourneys()).map(x => x._id);
|
|
235
251
|
const unresolvedJourneys = {};
|
|
236
252
|
const resolvedJourneys = [];
|
|
237
253
|
showSpinner('Resolving dependencies');
|
|
238
|
-
await
|
|
254
|
+
await resolveDependencies(installedJourneys, {
|
|
239
255
|
[journeyId]: journeyData
|
|
240
256
|
}, unresolvedJourneys, resolvedJourneys);
|
|
241
257
|
if (Object.keys(unresolvedJourneys).length === 0) {
|
|
242
258
|
succeedSpinner(`Resolved all dependencies.`);
|
|
243
259
|
if (!verbose) showSpinner(`Importing ${journeyId}...`);
|
|
244
|
-
|
|
260
|
+
importJourney(journeyData, options).then(() => {
|
|
245
261
|
if (verbose) showSpinner(`Importing ${journeyId}...`);
|
|
246
262
|
succeedSpinner(`Imported ${journeyId}.`);
|
|
247
263
|
}).catch(importError => {
|
|
@@ -271,7 +287,7 @@ export async function importJourneysFromFile(file, options) {
|
|
|
271
287
|
fs.readFile(file, 'utf8', (err, data) => {
|
|
272
288
|
if (err) throw err;
|
|
273
289
|
const fileData = JSON.parse(data);
|
|
274
|
-
|
|
290
|
+
importAllJourneys(fileData.trees, options);
|
|
275
291
|
});
|
|
276
292
|
}
|
|
277
293
|
|
|
@@ -289,7 +305,7 @@ export async function importJourneysFromFiles(options) {
|
|
|
289
305
|
const journeyData = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
290
306
|
allJourneysData.trees[journeyData.tree._id] = journeyData;
|
|
291
307
|
}
|
|
292
|
-
|
|
308
|
+
importAllJourneys(allJourneysData.trees, options);
|
|
293
309
|
}
|
|
294
310
|
|
|
295
311
|
/**
|
|
@@ -298,7 +314,7 @@ export async function importJourneysFromFiles(options) {
|
|
|
298
314
|
* @returns {string[]} Colored string array of classifications
|
|
299
315
|
*/
|
|
300
316
|
export function getJourneyClassification(journey) {
|
|
301
|
-
return
|
|
317
|
+
return getJourneyClassification(journey).map(it => {
|
|
302
318
|
switch (it) {
|
|
303
319
|
case 'standard':
|
|
304
320
|
return it['brightGreen'];
|
|
@@ -318,7 +334,7 @@ export function getJourneyClassification(journey) {
|
|
|
318
334
|
* @returns {string[]} Colored string array of classifications
|
|
319
335
|
*/
|
|
320
336
|
export function getJourneyClassificationMd(journey) {
|
|
321
|
-
return
|
|
337
|
+
return getJourneyClassification(journey).map(it => {
|
|
322
338
|
switch (it) {
|
|
323
339
|
case 'standard':
|
|
324
340
|
return `:green_circle: \`${it}\``;
|
|
@@ -410,7 +426,7 @@ function describeTreeDescendentsMd(descendents, depth = 0) {
|
|
|
410
426
|
* @param {SingleTreeExportInterface} journeyData journey export object
|
|
411
427
|
* @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function
|
|
412
428
|
*/
|
|
413
|
-
export async function describeJourney(journeyData, resolveTreeExport =
|
|
429
|
+
export async function describeJourney(journeyData, resolveTreeExport = onlineTreeExportResolver) {
|
|
414
430
|
var _journeyData$meta, _journeyData$tree$uiC, _journeyData$themes;
|
|
415
431
|
const allNodes = {
|
|
416
432
|
...journeyData.nodes,
|
|
@@ -454,7 +470,7 @@ export async function describeJourney(journeyData, resolveTreeExport = frodo.aut
|
|
|
454
470
|
}
|
|
455
471
|
|
|
456
472
|
// Dependency Tree
|
|
457
|
-
const descendents = await
|
|
473
|
+
const descendents = await getTreeDescendents(journeyData, resolveTreeExport);
|
|
458
474
|
describeTreeDescendents(descendents);
|
|
459
475
|
|
|
460
476
|
// Node Types
|
|
@@ -469,7 +485,7 @@ export async function describeJourney(journeyData, resolveTreeExport = frodo.aut
|
|
|
469
485
|
if (Object.entries(allNodes).length) {
|
|
470
486
|
printMessage(`\nNodes (${Object.entries(allNodes).length}):`, 'data');
|
|
471
487
|
for (const nodeObj of Object.values(allNodes)) {
|
|
472
|
-
printMessage(`- ${Node.getOneLineDescription(nodeObj,
|
|
488
|
+
printMessage(`- ${Node.getOneLineDescription(nodeObj, getNodeRef(nodeObj, journeyData))}`, 'data');
|
|
473
489
|
}
|
|
474
490
|
}
|
|
475
491
|
|
|
@@ -537,7 +553,7 @@ export async function describeJourney(journeyData, resolveTreeExport = frodo.aut
|
|
|
537
553
|
* @param {SingleTreeExportInterface} journeyData journey export object
|
|
538
554
|
* @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function
|
|
539
555
|
*/
|
|
540
|
-
export async function describeJourneyMd(journeyData, resolveTreeExport =
|
|
556
|
+
export async function describeJourneyMd(journeyData, resolveTreeExport = onlineTreeExportResolver) {
|
|
541
557
|
var _journeyData$meta2, _journeyData$tree$uiC2, _journeyData$themes2;
|
|
542
558
|
const allNodes = {
|
|
543
559
|
...journeyData.nodes,
|
|
@@ -574,7 +590,7 @@ export async function describeJourneyMd(journeyData, resolveTreeExport = frodo.a
|
|
|
574
590
|
printMessage(`\n[]()\n`, 'data');
|
|
575
591
|
|
|
576
592
|
// Dependency Tree
|
|
577
|
-
const descendents = await
|
|
593
|
+
const descendents = await getTreeDescendents(journeyData, resolveTreeExport);
|
|
578
594
|
printMessage(describeTreeDescendentsMd(descendents), 'data');
|
|
579
595
|
|
|
580
596
|
// Node Types
|
|
@@ -592,7 +608,7 @@ export async function describeJourneyMd(journeyData, resolveTreeExport = frodo.a
|
|
|
592
608
|
printMessage(`## Nodes (${Object.entries(allNodes).length})`, 'data');
|
|
593
609
|
printMessage(Node.getTableHeaderMd(), 'data');
|
|
594
610
|
for (const nodeObj of Object.values(allNodes)) {
|
|
595
|
-
printMessage(`${Node.getTableRowMd(nodeObj,
|
|
611
|
+
printMessage(`${Node.getTableRowMd(nodeObj, getNodeRef(nodeObj, journeyData))}`, 'data');
|
|
596
612
|
}
|
|
597
613
|
}
|
|
598
614
|
|