@rockcarver/frodo-cli 0.24.5 → 2.0.0-2
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/.vscode/launch.json +15 -0
- package/CHANGELOG.md +9 -1
- package/esm/app.js +2 -5
- package/esm/app.js.map +1 -1
- package/esm/cli/FrodoCommand.js +10 -10
- package/esm/cli/FrodoCommand.js.map +1 -1
- package/esm/cli/_template/something-delete.js +2 -5
- package/esm/cli/_template/something-delete.js.map +1 -1
- package/esm/cli/_template/something-describe.js +2 -5
- package/esm/cli/_template/something-describe.js.map +1 -1
- package/esm/cli/_template/something-else-delete.js +2 -5
- package/esm/cli/_template/something-else-delete.js.map +1 -1
- package/esm/cli/_template/something-else-describe.js +2 -5
- package/esm/cli/_template/something-else-describe.js.map +1 -1
- package/esm/cli/_template/something-else-export.js +2 -5
- package/esm/cli/_template/something-else-export.js.map +1 -1
- package/esm/cli/_template/something-else-import.js +2 -5
- package/esm/cli/_template/something-else-import.js.map +1 -1
- package/esm/cli/_template/something-else-list.js +2 -5
- package/esm/cli/_template/something-else-list.js.map +1 -1
- package/esm/cli/_template/something-export.js +2 -5
- package/esm/cli/_template/something-export.js.map +1 -1
- package/esm/cli/_template/something-import.js +2 -5
- package/esm/cli/_template/something-import.js.map +1 -1
- package/esm/cli/_template/something-list.js +2 -5
- package/esm/cli/_template/something-list.js.map +1 -1
- package/esm/cli/_template/something-other-delete.js +2 -5
- package/esm/cli/_template/something-other-delete.js.map +1 -1
- package/esm/cli/_template/something-other-describe.js +2 -5
- package/esm/cli/_template/something-other-describe.js.map +1 -1
- package/esm/cli/_template/something-other-export.js +2 -5
- package/esm/cli/_template/something-other-export.js.map +1 -1
- package/esm/cli/_template/something-other-import.js +2 -5
- package/esm/cli/_template/something-other-import.js.map +1 -1
- package/esm/cli/_template/something-other-list.js +2 -5
- package/esm/cli/_template/something-other-list.js.map +1 -1
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js +3 -9
- 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 +4 -11
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-get-access-token.js +3 -9
- package/esm/cli/admin/admin-get-access-token.js.map +1 -1
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +3 -9
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js +3 -9
- 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 +3 -9
- 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 +3 -9
- 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 +3 -9
- package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
- package/esm/cli/admin/admin-remove-static-user-mapping.js +3 -9
- package/esm/cli/admin/admin-remove-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-repair-org-model.js +3 -9
- package/esm/cli/admin/admin-repair-org-model.js.map +1 -1
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +3 -9
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-show-generic-extension-attributes.js +3 -9
- package/esm/cli/admin/admin-show-generic-extension-attributes.js.map +1 -1
- package/esm/cli/agent/agent-delete.js +4 -11
- package/esm/cli/agent/agent-delete.js.map +1 -1
- package/esm/cli/agent/agent-describe.js +2 -5
- package/esm/cli/agent/agent-describe.js.map +1 -1
- package/esm/cli/agent/agent-export.js +2 -5
- package/esm/cli/agent/agent-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-delete.js +4 -11
- package/esm/cli/agent/agent-gateway-delete.js.map +1 -1
- package/esm/cli/agent/agent-gateway-describe.js +2 -5
- package/esm/cli/agent/agent-gateway-describe.js.map +1 -1
- package/esm/cli/agent/agent-gateway-export.js +2 -5
- package/esm/cli/agent/agent-gateway-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-import.js +2 -5
- package/esm/cli/agent/agent-gateway-import.js.map +1 -1
- package/esm/cli/agent/agent-gateway-list.js +2 -5
- package/esm/cli/agent/agent-gateway-list.js.map +1 -1
- package/esm/cli/agent/agent-import.js +2 -5
- package/esm/cli/agent/agent-import.js.map +1 -1
- package/esm/cli/agent/agent-java-delete.js +4 -11
- package/esm/cli/agent/agent-java-delete.js.map +1 -1
- package/esm/cli/agent/agent-java-describe.js +2 -5
- package/esm/cli/agent/agent-java-describe.js.map +1 -1
- package/esm/cli/agent/agent-java-export.js +2 -5
- package/esm/cli/agent/agent-java-export.js.map +1 -1
- package/esm/cli/agent/agent-java-import.js +2 -5
- package/esm/cli/agent/agent-java-import.js.map +1 -1
- package/esm/cli/agent/agent-java-list.js +2 -5
- package/esm/cli/agent/agent-java-list.js.map +1 -1
- package/esm/cli/agent/agent-list.js +2 -5
- package/esm/cli/agent/agent-list.js.map +1 -1
- package/esm/cli/agent/agent-web-delete.js +4 -11
- package/esm/cli/agent/agent-web-delete.js.map +1 -1
- package/esm/cli/agent/agent-web-describe.js +2 -5
- package/esm/cli/agent/agent-web-describe.js.map +1 -1
- package/esm/cli/agent/agent-web-export.js +2 -5
- package/esm/cli/agent/agent-web-export.js.map +1 -1
- package/esm/cli/agent/agent-web-import.js +2 -5
- package/esm/cli/agent/agent-web-import.js.map +1 -1
- package/esm/cli/agent/agent-web-list.js +2 -5
- package/esm/cli/agent/agent-web-list.js.map +1 -1
- package/esm/cli/app/app-delete.js +2 -5
- package/esm/cli/app/app-delete.js.map +1 -1
- package/esm/cli/app/app-describe.js +2 -5
- package/esm/cli/app/app-describe.js.map +1 -1
- package/esm/cli/app/app-export.js +4 -7
- package/esm/cli/app/app-export.js.map +1 -1
- package/esm/cli/app/app-import.js +5 -8
- package/esm/cli/app/app-import.js.map +1 -1
- package/esm/cli/app/app-list.js +3 -6
- package/esm/cli/app/app-list.js.map +1 -1
- package/esm/cli/authz/authz-policy-delete.js +4 -7
- package/esm/cli/authz/authz-policy-delete.js.map +1 -1
- package/esm/cli/authz/authz-policy-describe.js +2 -5
- package/esm/cli/authz/authz-policy-describe.js.map +1 -1
- package/esm/cli/authz/authz-policy-export.js +6 -9
- package/esm/cli/authz/authz-policy-export.js.map +1 -1
- package/esm/cli/authz/authz-policy-import.js +5 -8
- package/esm/cli/authz/authz-policy-import.js.map +1 -1
- package/esm/cli/authz/authz-policy-list.js +3 -6
- package/esm/cli/authz/authz-policy-list.js.map +1 -1
- package/esm/cli/authz/authz-set-delete.js +3 -6
- package/esm/cli/authz/authz-set-delete.js.map +1 -1
- package/esm/cli/authz/authz-set-describe.js +2 -5
- package/esm/cli/authz/authz-set-describe.js.map +1 -1
- package/esm/cli/authz/authz-set-export.js +4 -7
- package/esm/cli/authz/authz-set-export.js.map +1 -1
- package/esm/cli/authz/authz-set-import.js +5 -8
- package/esm/cli/authz/authz-set-import.js.map +1 -1
- package/esm/cli/authz/authz-set-list.js +2 -5
- package/esm/cli/authz/authz-set-list.js.map +1 -1
- package/esm/cli/authz/authz-type-delete.js +4 -7
- package/esm/cli/authz/authz-type-delete.js.map +1 -1
- package/esm/cli/authz/authz-type-describe.js +3 -6
- package/esm/cli/authz/authz-type-describe.js.map +1 -1
- package/esm/cli/authz/authz-type-export.js +5 -8
- package/esm/cli/authz/authz-type-export.js.map +1 -1
- package/esm/cli/authz/authz-type-import.js +6 -9
- package/esm/cli/authz/authz-type-import.js.map +1 -1
- package/esm/cli/authz/authz-type-list.js +2 -5
- package/esm/cli/authz/authz-type-list.js.map +1 -1
- package/esm/cli/conn/conn-delete.js +2 -5
- package/esm/cli/conn/conn-delete.js.map +1 -1
- package/esm/cli/conn/conn-describe.js +1 -4
- package/esm/cli/conn/conn-describe.js.map +1 -1
- package/esm/cli/conn/conn-list.js +1 -4
- package/esm/cli/conn/conn-list.js.map +1 -1
- package/esm/cli/conn/conn-save.js +6 -16
- package/esm/cli/conn/conn-save.js.map +1 -1
- package/esm/cli/email/email-template-export.js +4 -7
- package/esm/cli/email/email-template-export.js.map +1 -1
- package/esm/cli/email/email-template-import.js +5 -8
- package/esm/cli/email/email-template-import.js.map +1 -1
- package/esm/cli/email/email-template-list.js +2 -5
- package/esm/cli/email/email-template-list.js.map +1 -1
- package/esm/cli/esv/esv-apply.js +6 -16
- package/esm/cli/esv/esv-apply.js.map +1 -1
- package/esm/cli/esv/esv-secret-create.js +3 -8
- package/esm/cli/esv/esv-secret-create.js.map +1 -1
- package/esm/cli/esv/esv-secret-delete.js +6 -12
- package/esm/cli/esv/esv-secret-delete.js.map +1 -1
- package/esm/cli/esv/esv-secret-describe.js +3 -8
- package/esm/cli/esv/esv-secret-describe.js.map +1 -1
- package/esm/cli/esv/esv-secret-export.js +2 -5
- package/esm/cli/esv/esv-secret-export.js.map +1 -1
- package/esm/cli/esv/esv-secret-import.js +2 -5
- package/esm/cli/esv/esv-secret-import.js.map +1 -1
- package/esm/cli/esv/esv-secret-list.js +3 -8
- package/esm/cli/esv/esv-secret-list.js.map +1 -1
- package/esm/cli/esv/esv-secret-set.js +4 -9
- package/esm/cli/esv/esv-secret-set.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-activate.js +3 -8
- package/esm/cli/esv/esv-secret-version-activate.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-create.js +4 -9
- package/esm/cli/esv/esv-secret-version-create.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-deactivate.js +3 -8
- package/esm/cli/esv/esv-secret-version-deactivate.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-delete.js +5 -10
- package/esm/cli/esv/esv-secret-version-delete.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-list.js +4 -9
- package/esm/cli/esv/esv-secret-version-list.js.map +1 -1
- package/esm/cli/esv/esv-variable-create.js +3 -8
- package/esm/cli/esv/esv-variable-create.js.map +1 -1
- package/esm/cli/esv/esv-variable-delete.js +6 -12
- package/esm/cli/esv/esv-variable-delete.js.map +1 -1
- package/esm/cli/esv/esv-variable-describe.js +3 -8
- package/esm/cli/esv/esv-variable-describe.js.map +1 -1
- package/esm/cli/esv/esv-variable-export.js +2 -5
- package/esm/cli/esv/esv-variable-export.js.map +1 -1
- package/esm/cli/esv/esv-variable-import.js +2 -5
- package/esm/cli/esv/esv-variable-import.js.map +1 -1
- package/esm/cli/esv/esv-variable-list.js +3 -8
- package/esm/cli/esv/esv-variable-list.js.map +1 -1
- package/esm/cli/esv/esv-variable-set.js +5 -11
- package/esm/cli/esv/esv-variable-set.js.map +1 -1
- package/esm/cli/idm/idm-count.js +2 -5
- package/esm/cli/idm/idm-count.js.map +1 -1
- package/esm/cli/idm/idm-export.js +4 -7
- package/esm/cli/idm/idm-export.js.map +1 -1
- package/esm/cli/idm/idm-import.js +5 -8
- package/esm/cli/idm/idm-import.js.map +1 -1
- package/esm/cli/idm/idm-list.js +2 -5
- package/esm/cli/idm/idm-list.js.map +1 -1
- package/esm/cli/idp/idp-export.js +2 -5
- package/esm/cli/idp/idp-export.js.map +1 -1
- package/esm/cli/idp/idp-import.js +5 -8
- package/esm/cli/idp/idp-import.js.map +1 -1
- package/esm/cli/idp/idp-list.js +2 -5
- package/esm/cli/idp/idp-list.js.map +1 -1
- package/esm/cli/info/info.js +3 -9
- package/esm/cli/info/info.js.map +1 -1
- package/esm/cli/journey/journey-delete.js +5 -12
- package/esm/cli/journey/journey-delete.js.map +1 -1
- package/esm/cli/journey/journey-describe.js +7 -15
- package/esm/cli/journey/journey-describe.js.map +1 -1
- package/esm/cli/journey/journey-disable.js +3 -9
- package/esm/cli/journey/journey-disable.js.map +1 -1
- package/esm/cli/journey/journey-enable.js +3 -9
- package/esm/cli/journey/journey-enable.js.map +1 -1
- package/esm/cli/journey/journey-export.js +4 -7
- package/esm/cli/journey/journey-export.js.map +1 -1
- package/esm/cli/journey/journey-import.js +5 -8
- package/esm/cli/journey/journey-import.js.map +1 -1
- package/esm/cli/journey/journey-list.js +2 -5
- package/esm/cli/journey/journey-list.js.map +1 -1
- package/esm/cli/journey/journey-prune.js +4 -11
- package/esm/cli/journey/journey-prune.js.map +1 -1
- package/esm/cli/logging/logs-fetch.js +7 -17
- package/esm/cli/logging/logs-fetch.js.map +1 -1
- package/esm/cli/logging/logs-list.js +5 -15
- package/esm/cli/logging/logs-list.js.map +1 -1
- package/esm/cli/logging/logs-tail.js +7 -17
- package/esm/cli/logging/logs-tail.js.map +1 -1
- package/esm/cli/realm/realm-add-custom-domain.js +3 -8
- package/esm/cli/realm/realm-add-custom-domain.js.map +1 -1
- package/esm/cli/realm/realm-describe.js +4 -12
- package/esm/cli/realm/realm-describe.js.map +1 -1
- package/esm/cli/realm/realm-list.js +3 -8
- package/esm/cli/realm/realm-list.js.map +1 -1
- package/esm/cli/realm/realm-remove-custom-domain.js +3 -9
- package/esm/cli/realm/realm-remove-custom-domain.js.map +1 -1
- package/esm/cli/saml/saml-cot-export.js +11 -15
- package/esm/cli/saml/saml-cot-export.js.map +1 -1
- package/esm/cli/saml/saml-cot-import.js +15 -19
- package/esm/cli/saml/saml-cot-import.js.map +1 -1
- package/esm/cli/saml/saml-cot-list.js +5 -9
- package/esm/cli/saml/saml-cot-list.js.map +1 -1
- package/esm/cli/saml/saml-delete.js +5 -12
- package/esm/cli/saml/saml-delete.js.map +1 -1
- package/esm/cli/saml/saml-describe.js +2 -5
- package/esm/cli/saml/saml-describe.js.map +1 -1
- package/esm/cli/saml/saml-export.js +12 -30
- package/esm/cli/saml/saml-export.js.map +1 -1
- package/esm/cli/saml/saml-import.js +15 -36
- package/esm/cli/saml/saml-import.js.map +1 -1
- package/esm/cli/saml/saml-list.js +6 -14
- package/esm/cli/saml/saml-list.js.map +1 -1
- package/esm/cli/saml/saml-metadata-export.js +3 -6
- package/esm/cli/saml/saml-metadata-export.js.map +1 -1
- package/esm/cli/script/script-delete.js +2 -5
- package/esm/cli/script/script-delete.js.map +1 -1
- package/esm/cli/script/script-describe.js +2 -5
- package/esm/cli/script/script-describe.js.map +1 -1
- package/esm/cli/script/script-export.js +2 -5
- package/esm/cli/script/script-export.js.map +1 -1
- package/esm/cli/script/script-import.js +4 -6
- package/esm/cli/script/script-import.js.map +1 -1
- package/esm/cli/script/script-list.js +4 -6
- package/esm/cli/script/script-list.js.map +1 -1
- package/esm/cli/service/service-delete.js +3 -6
- package/esm/cli/service/service-delete.js.map +1 -1
- package/esm/cli/service/service-export.js +4 -7
- package/esm/cli/service/service-export.js.map +1 -1
- package/esm/cli/service/service-import.js +5 -8
- package/esm/cli/service/service-import.js.map +1 -1
- package/esm/cli/service/service-list.js +2 -5
- package/esm/cli/service/service-list.js.map +1 -1
- package/esm/cli/theme/theme-delete.js +4 -7
- package/esm/cli/theme/theme-delete.js.map +1 -1
- package/esm/cli/theme/theme-export.js +5 -8
- package/esm/cli/theme/theme-export.js.map +1 -1
- package/esm/cli/theme/theme-import.js +6 -9
- package/esm/cli/theme/theme-import.js.map +1 -1
- package/esm/cli/theme/theme-list.js +2 -5
- package/esm/cli/theme/theme-list.js.map +1 -1
- package/esm/launch.js +4 -3
- package/esm/launch.js.map +1 -1
- package/esm/ops/AgentOps.js +49 -82
- package/esm/ops/AgentOps.js.map +1 -1
- package/esm/ops/CirclesOfTrustOps.js +217 -2
- package/esm/ops/CirclesOfTrustOps.js.map +1 -1
- package/esm/ops/ConnectionProfileOps.js +97 -8
- package/esm/ops/ConnectionProfileOps.js.map +1 -1
- package/esm/ops/EmailTemplateOps.js +16 -25
- package/esm/ops/EmailTemplateOps.js.map +1 -1
- package/esm/ops/IdmOps.js +25 -39
- package/esm/ops/IdmOps.js.map +1 -1
- package/esm/ops/IdpOps.js +10 -18
- package/esm/ops/IdpOps.js.map +1 -1
- package/esm/ops/JourneyOps.js +49 -65
- package/esm/ops/JourneyOps.js.map +1 -1
- package/esm/ops/LogOps.js +9 -17
- package/esm/ops/LogOps.js.map +1 -1
- package/esm/ops/NodeOps.js +11 -11
- package/esm/ops/NodeOps.js.map +1 -1
- package/esm/ops/OAuth2ClientOps.js +13 -29
- package/esm/ops/OAuth2ClientOps.js.map +1 -1
- package/esm/ops/OrganizationOps.js +28 -0
- package/esm/ops/OrganizationOps.js.map +1 -0
- package/esm/ops/PolicyOps.js +22 -38
- package/esm/ops/PolicyOps.js.map +1 -1
- package/esm/ops/PolicySetOps.js +19 -37
- package/esm/ops/PolicySetOps.js.map +1 -1
- package/esm/ops/RealmOps.js +109 -0
- package/esm/ops/RealmOps.js.map +1 -0
- package/esm/ops/ResourceTypeOps.js +19 -37
- package/esm/ops/ResourceTypeOps.js.map +1 -1
- package/esm/ops/Saml2Ops.js +30 -251
- package/esm/ops/Saml2Ops.js.map +1 -1
- package/esm/ops/ScriptOps.js +14 -21
- package/esm/ops/ScriptOps.js.map +1 -1
- package/esm/ops/SecretsOps.js +223 -0
- package/esm/ops/SecretsOps.js.map +1 -0
- package/esm/ops/ServiceOps.js +20 -41
- package/esm/ops/ServiceOps.js.map +1 -1
- package/esm/ops/ThemeOps.js +20 -35
- package/esm/ops/ThemeOps.js.map +1 -1
- package/esm/ops/VariablesOps.js +133 -0
- package/esm/ops/VariablesOps.js.map +1 -0
- package/esm/utils/Config.js +3 -6
- package/esm/utils/Config.js.map +1 -1
- package/esm/utils/Console.js +2 -5
- package/esm/utils/Console.js.map +1 -1
- package/esm/utils/ExportImportUtils.js +4 -6
- package/esm/utils/ExportImportUtils.js.map +1 -1
- package/esm/utils/Version.js +3 -3
- package/esm/utils/Version.js.map +1 -1
- package/package.json +4 -4
package/esm/ops/IdpOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdpOps.js","names":["fs","Idp","createProgressBar","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getRealmString","getTypedFilename","saveJsonToFile","getSocialIdentityProviders","exportSocialProvider","exportSocialProviders","importSocialProvider","importFirstSocialProvider","importSocialProviders","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","importSocialProviderFromFile","outcome","readFile","data","JSON","parse","error","_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 fs from 'fs';\nimport { SocialIdpSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { Idp } from '@rockcarver/frodo-lib';\nimport {\n createProgressBar,\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 importSocialProvider,\n importFirstSocialProvider,\n importSocialProviders,\n} = Idp;\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 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}\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 const allIdpsData = await getSocialIdentityProviders();\n // printMessage(allIdpsData, 'data');\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressBar(`Writing provider ${idpData._id}`);\n const fileName = getTypedFilename(idpData._id, 'idp');\n const fileData = await exportSocialProvider(idpData._id);\n saveJsonToFile(fileData, fileName);\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\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,OAAOA,EAAE,MAAM,IAAI;AAEnB,SAASC,GAAG,QAAQ,uBAAuB;AAC3C,SACEC,iBAAiB,EACjBC,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,oBAAoB;EACpBC,yBAAyB;EACzBC;AACF,CAAC,GAAGhB,GAAG;;AAEP;AACA;AACA;AACA;AACA;AACA,OAAO,SAASiB,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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Q,CAAC,WAAW,CACzC,CAAC;EAEDlE,iBAAiB,CAAC+D,SAAS,CAAClB,MAAM,EAAE,wBAAwB,CAAC;EAC7D,IAAIsB,KAAK,GAAG,CAAC;EACb,KAAK,MAAM5B,IAAI,IAAIwB,SAAS,EAAE;IAC5B,MAAMb,IAAI,GAAGpD,EAAE,CAACsE,YAAY,CAAC7B,IAAI,EAAE,MAAM,CAAC;IAC1C,MAAME,QAAQ,GAAGU,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC;IACjC,MAAMmB,KAAK,GAAGC,MAAM,CAACC,IAAI,CAAC9B,QAAQ,CAAC+B,GAAG,CAAC,CAAC3B,MAAM;IAC9CsB,KAAK,IAAIE,KAAK;IACd,MAAMtD,qBAAqB,CAAC0B,QAAQ,CAAC;IACrCnC,iBAAiB,CAAE,YAAW+D,KAAM,qBAAoB9B,IAAK,EAAC,CAAC;EACjE;EACAnC,eAAe,CACZ,sBAAqB+D,KAAM,qBAAoBJ,SAAS,CAAClB,MAAO,WACnE,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"IdpOps.js","names":["frodo","fs","createProgressBar","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","importSocialProviderFromFile","outcome","readFile","data","JSON","parse","importSocialProvider","error","_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 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 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}\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 const allIdpsData =\n await frodo.oauth2oidc.external.getSocialIdentityProviders();\n // printMessage(allIdpsData, 'data');\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressBar(`Writing provider ${idpData._id}`);\n const fileName = getTypedFilename(idpData._id, 'idp');\n const fileData = await frodo.oauth2oidc.external.exportSocialProvider(\n idpData._id\n );\n saveJsonToFile(fileData, fileName);\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\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,S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AAGlD,EAAE,CAACuE,YAAY,CAAClC,IAAI,EAAE,MAAM,CAAC;IAC1C,MAAME,QAAQ,GAAGY,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC;IACjC,MAAMsB,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACnC,QAAQ,CAACoC,GAAG,CAAC,CAAC9B,MAAM;IAC9CyB,KAAK,IAAIE,KAAK;IACd,MAAMzE,KAAK,CAACyB,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"}
|
package/esm/ops/JourneyOps.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
1
2
|
import fs from 'fs';
|
|
2
3
|
import { printMessage, createProgressBar, updateProgressBar, stopProgressBar, showSpinner, succeedSpinner, failSpinner, createTable, debugMessage } from '../utils/Console';
|
|
3
|
-
import { ExportImportUtils, Journey, Types, state } from '@rockcarver/frodo-lib';
|
|
4
4
|
import * as CirclesOfTrust from './CirclesOfTrustOps';
|
|
5
5
|
import * as EmailTemplate from './EmailTemplateOps';
|
|
6
6
|
import * as Idp from './IdpOps';
|
|
@@ -10,22 +10,6 @@ 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
|
-
getJourneys,
|
|
15
|
-
importAllJourneys,
|
|
16
|
-
importJourney,
|
|
17
|
-
resolveDependencies,
|
|
18
|
-
createMultiTreeExportTemplate,
|
|
19
|
-
exportJourney,
|
|
20
|
-
onlineTreeExportResolver,
|
|
21
|
-
getTreeDescendents,
|
|
22
|
-
getNodeRef
|
|
23
|
-
} = Journey;
|
|
24
|
-
const {
|
|
25
|
-
getTypedFilename,
|
|
26
|
-
saveJsonToFile,
|
|
27
|
-
getRealmString
|
|
28
|
-
} = ExportImportUtils;
|
|
29
13
|
|
|
30
14
|
/**
|
|
31
15
|
* List all the journeys/trees
|
|
@@ -36,7 +20,7 @@ const {
|
|
|
36
20
|
export async function listJourneys(long = false, analyze = false) {
|
|
37
21
|
let journeys = [];
|
|
38
22
|
try {
|
|
39
|
-
journeys = await getJourneys();
|
|
23
|
+
journeys = await frodo.authn.journey.getJourneys();
|
|
40
24
|
if (!long && !analyze) {
|
|
41
25
|
for (const journeyStub of journeys) {
|
|
42
26
|
printMessage(`${journeyStub['_id']}`, 'data');
|
|
@@ -54,7 +38,7 @@ export async function listJourneys(long = false, analyze = false) {
|
|
|
54
38
|
const exportPromises = [];
|
|
55
39
|
try {
|
|
56
40
|
for (const journeyStub of journeys) {
|
|
57
|
-
exportPromises.push(exportJourney(journeyStub['_id'], {
|
|
41
|
+
exportPromises.push(frodo.authn.journey.exportJourney(journeyStub['_id'], {
|
|
58
42
|
useStringArrays: false,
|
|
59
43
|
deps: false
|
|
60
44
|
}));
|
|
@@ -88,12 +72,12 @@ export async function listJourneys(long = false, analyze = false) {
|
|
|
88
72
|
*/
|
|
89
73
|
export async function exportJourneyToFile(journeyId, file, options) {
|
|
90
74
|
debugMessage(`exportJourneyToFile: start`);
|
|
91
|
-
const verbose = state.
|
|
75
|
+
const verbose = state.getDebug();
|
|
92
76
|
if (!file) {
|
|
93
|
-
file = getTypedFilename(journeyId, 'journey');
|
|
77
|
+
file = frodo.utils.impex.getTypedFilename(journeyId, 'journey');
|
|
94
78
|
}
|
|
95
|
-
if (state.
|
|
96
|
-
const dir = state.
|
|
79
|
+
if (state.getDirectory()) {
|
|
80
|
+
const dir = state.getDirectory().replace(/\/$/, '');
|
|
97
81
|
debugMessage(`exportJourneyToFile: directory='${dir}'`);
|
|
98
82
|
file = `${dir}/${file}`;
|
|
99
83
|
// create directory if it doesn't exist
|
|
@@ -106,9 +90,9 @@ export async function exportJourneyToFile(journeyId, file, options) {
|
|
|
106
90
|
}
|
|
107
91
|
if (!verbose) showSpinner(`${journeyId}`);
|
|
108
92
|
try {
|
|
109
|
-
const fileData = await exportJourney(journeyId, options);
|
|
93
|
+
const fileData = await frodo.authn.journey.exportJourney(journeyId, options);
|
|
110
94
|
if (verbose) showSpinner(`${journeyId}`);
|
|
111
|
-
saveJsonToFile(fileData, file);
|
|
95
|
+
frodo.utils.impex.saveJsonToFile(fileData, file);
|
|
112
96
|
succeedSpinner(`Exported ${journeyId['brightCyan']} to ${file['brightCyan']}.`);
|
|
113
97
|
} catch (error) {
|
|
114
98
|
if (verbose) showSpinner(`${journeyId}`);
|
|
@@ -127,22 +111,22 @@ export async function exportJourneysToFile(file, options = {
|
|
|
127
111
|
}) {
|
|
128
112
|
let fileName = file;
|
|
129
113
|
if (!fileName) {
|
|
130
|
-
fileName = getTypedFilename(`all${getRealmString()}Journeys`, 'journeys');
|
|
114
|
+
fileName = frodo.utils.impex.getTypedFilename(`all${frodo.utils.impex.getRealmString()}Journeys`, 'journeys');
|
|
131
115
|
}
|
|
132
|
-
const trees = await getJourneys();
|
|
133
|
-
const fileData = createMultiTreeExportTemplate();
|
|
116
|
+
const trees = await frodo.authn.journey.getJourneys();
|
|
117
|
+
const fileData = frodo.authn.journey.createMultiTreeExportTemplate();
|
|
134
118
|
createProgressBar(trees.length, 'Exporting journeys...');
|
|
135
119
|
for (const tree of trees) {
|
|
136
120
|
updateProgressBar(`${tree._id}`);
|
|
137
121
|
try {
|
|
138
|
-
const exportData = await exportJourney(tree._id, options);
|
|
122
|
+
const exportData = await frodo.authn.journey.exportJourney(tree._id, options);
|
|
139
123
|
delete exportData.meta;
|
|
140
124
|
fileData.trees[tree._id] = exportData;
|
|
141
125
|
} catch (error) {
|
|
142
126
|
printMessage(`Error exporting journey ${tree._id}: ${error}`, 'error');
|
|
143
127
|
}
|
|
144
128
|
}
|
|
145
|
-
saveJsonToFile(fileData, fileName);
|
|
129
|
+
frodo.utils.impex.saveJsonToFile(fileData, fileName);
|
|
146
130
|
stopProgressBar(`Exported to ${fileName}`);
|
|
147
131
|
}
|
|
148
132
|
|
|
@@ -151,14 +135,14 @@ export async function exportJourneysToFile(file, options = {
|
|
|
151
135
|
* @param {TreeExportOptions} options export options
|
|
152
136
|
*/
|
|
153
137
|
export async function exportJourneysToFiles(options) {
|
|
154
|
-
const trees = await getJourneys();
|
|
138
|
+
const trees = await frodo.authn.journey.getJourneys();
|
|
155
139
|
createProgressBar(trees.length, 'Exporting journeys...');
|
|
156
140
|
for (const tree of trees) {
|
|
157
141
|
updateProgressBar(`${tree._id}`);
|
|
158
|
-
const fileName = getTypedFilename(`${tree._id}`, 'journey');
|
|
142
|
+
const fileName = frodo.utils.impex.getTypedFilename(`${tree._id}`, 'journey');
|
|
159
143
|
try {
|
|
160
|
-
const exportData = await exportJourney(tree._id, options);
|
|
161
|
-
saveJsonToFile(exportData, fileName);
|
|
144
|
+
const exportData = await frodo.authn.journey.exportJourney(tree._id, options);
|
|
145
|
+
frodo.utils.impex.saveJsonToFile(exportData, fileName);
|
|
162
146
|
} catch (error) {
|
|
163
147
|
// do we need to report status here?
|
|
164
148
|
}
|
|
@@ -173,7 +157,7 @@ export async function exportJourneysToFiles(options) {
|
|
|
173
157
|
* @param {TreeImportOptions} options import options
|
|
174
158
|
*/
|
|
175
159
|
export async function importJourneyFromFile(journeyId, file, options) {
|
|
176
|
-
const verbose = state.
|
|
160
|
+
const verbose = state.getDebug();
|
|
177
161
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
178
162
|
if (err) throw err;
|
|
179
163
|
let journeyData = JSON.parse(data);
|
|
@@ -187,17 +171,17 @@ export async function importJourneyFromFile(journeyId, file, options) {
|
|
|
187
171
|
// if a journeyId was specified, only import the matching journey
|
|
188
172
|
if (journeyData && journeyId === journeyData.tree._id) {
|
|
189
173
|
// attempt dependency resolution for single tree import
|
|
190
|
-
const installedJourneys = (await getJourneys()).map(x => x._id);
|
|
174
|
+
const installedJourneys = (await frodo.authn.journey.getJourneys()).map(x => x._id);
|
|
191
175
|
const unresolvedJourneys = {};
|
|
192
176
|
const resolvedJourneys = [];
|
|
193
177
|
showSpinner('Resolving dependencies');
|
|
194
|
-
await resolveDependencies(installedJourneys, {
|
|
178
|
+
await frodo.authn.journey.resolveDependencies(installedJourneys, {
|
|
195
179
|
[journeyId]: journeyData
|
|
196
180
|
}, unresolvedJourneys, resolvedJourneys);
|
|
197
181
|
if (Object.keys(unresolvedJourneys).length === 0) {
|
|
198
182
|
succeedSpinner(`Resolved all dependencies.`);
|
|
199
183
|
if (!verbose) showSpinner(`Importing ${journeyId}...`);
|
|
200
|
-
importJourney(journeyData, options).then(() => {
|
|
184
|
+
frodo.authn.journey.importJourney(journeyData, options).then(() => {
|
|
201
185
|
if (verbose) showSpinner(`Importing ${journeyId}...`);
|
|
202
186
|
succeedSpinner(`Imported ${journeyId}.`);
|
|
203
187
|
}).catch(importError => {
|
|
@@ -224,7 +208,7 @@ export async function importJourneyFromFile(journeyId, file, options) {
|
|
|
224
208
|
* @param {TreeImportOptions} options import options
|
|
225
209
|
*/
|
|
226
210
|
export async function importFirstJourneyFromFile(file, options) {
|
|
227
|
-
const verbose = state.
|
|
211
|
+
const verbose = state.getDebug();
|
|
228
212
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
229
213
|
if (err) throw err;
|
|
230
214
|
let journeyData = cloneDeep(JSON.parse(data));
|
|
@@ -247,17 +231,17 @@ export async function importFirstJourneyFromFile(file, options) {
|
|
|
247
231
|
// if a journeyId was specified, only import the matching journey
|
|
248
232
|
if (journeyData && journeyId) {
|
|
249
233
|
// attempt dependency resolution for single tree import
|
|
250
|
-
const installedJourneys = (await getJourneys()).map(x => x._id);
|
|
234
|
+
const installedJourneys = (await frodo.authn.journey.getJourneys()).map(x => x._id);
|
|
251
235
|
const unresolvedJourneys = {};
|
|
252
236
|
const resolvedJourneys = [];
|
|
253
237
|
showSpinner('Resolving dependencies');
|
|
254
|
-
await resolveDependencies(installedJourneys, {
|
|
238
|
+
await frodo.authn.journey.resolveDependencies(installedJourneys, {
|
|
255
239
|
[journeyId]: journeyData
|
|
256
240
|
}, unresolvedJourneys, resolvedJourneys);
|
|
257
241
|
if (Object.keys(unresolvedJourneys).length === 0) {
|
|
258
242
|
succeedSpinner(`Resolved all dependencies.`);
|
|
259
243
|
if (!verbose) showSpinner(`Importing ${journeyId}...`);
|
|
260
|
-
importJourney(journeyData, options).then(() => {
|
|
244
|
+
frodo.authn.journey.importJourney(journeyData, options).then(() => {
|
|
261
245
|
if (verbose) showSpinner(`Importing ${journeyId}...`);
|
|
262
246
|
succeedSpinner(`Imported ${journeyId}.`);
|
|
263
247
|
}).catch(importError => {
|
|
@@ -287,7 +271,7 @@ export async function importJourneysFromFile(file, options) {
|
|
|
287
271
|
fs.readFile(file, 'utf8', (err, data) => {
|
|
288
272
|
if (err) throw err;
|
|
289
273
|
const fileData = JSON.parse(data);
|
|
290
|
-
importAllJourneys(fileData.trees, options);
|
|
274
|
+
frodo.authn.journey.importAllJourneys(fileData.trees, options);
|
|
291
275
|
});
|
|
292
276
|
}
|
|
293
277
|
|
|
@@ -305,7 +289,7 @@ export async function importJourneysFromFiles(options) {
|
|
|
305
289
|
const journeyData = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
306
290
|
allJourneysData.trees[journeyData.tree._id] = journeyData;
|
|
307
291
|
}
|
|
308
|
-
importAllJourneys(allJourneysData.trees, options);
|
|
292
|
+
frodo.authn.journey.importAllJourneys(allJourneysData.trees, options);
|
|
309
293
|
}
|
|
310
294
|
|
|
311
295
|
/**
|
|
@@ -314,15 +298,15 @@ export async function importJourneysFromFiles(options) {
|
|
|
314
298
|
* @returns {string[]} Colored string array of classifications
|
|
315
299
|
*/
|
|
316
300
|
export function getJourneyClassification(journey) {
|
|
317
|
-
return
|
|
301
|
+
return getJourneyClassification(journey).map(it => {
|
|
318
302
|
switch (it) {
|
|
319
|
-
case
|
|
303
|
+
case 'standard':
|
|
320
304
|
return it.toString()['brightGreen'];
|
|
321
|
-
case
|
|
305
|
+
case 'cloud':
|
|
322
306
|
return it.toString()['brightMagenta'];
|
|
323
|
-
case
|
|
307
|
+
case 'custom':
|
|
324
308
|
return it.toString()['brightRed'];
|
|
325
|
-
case
|
|
309
|
+
case 'premium':
|
|
326
310
|
return it.toString()['brightYellow'];
|
|
327
311
|
}
|
|
328
312
|
});
|
|
@@ -334,15 +318,15 @@ export function getJourneyClassification(journey) {
|
|
|
334
318
|
* @returns {string[]} Colored string array of classifications
|
|
335
319
|
*/
|
|
336
320
|
export function getJourneyClassificationMd(journey) {
|
|
337
|
-
return
|
|
321
|
+
return getJourneyClassification(journey).map(it => {
|
|
338
322
|
switch (it) {
|
|
339
|
-
case
|
|
323
|
+
case 'standard':
|
|
340
324
|
return `:green_circle: \`${it.toString()}\``;
|
|
341
|
-
case
|
|
325
|
+
case 'cloud':
|
|
342
326
|
return `:purple_circle: \`${it.toString()}\``;
|
|
343
|
-
case
|
|
327
|
+
case 'custom':
|
|
344
328
|
return `:red_circle: \`${it.toString()}\``;
|
|
345
|
-
case
|
|
329
|
+
case 'premium':
|
|
346
330
|
return `:yellow_circle: \`${it.toString()}\``;
|
|
347
331
|
}
|
|
348
332
|
});
|
|
@@ -426,7 +410,7 @@ function describeTreeDescendentsMd(descendents, depth = 0) {
|
|
|
426
410
|
* @param {SingleTreeExportInterface} journeyData journey export object
|
|
427
411
|
* @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function
|
|
428
412
|
*/
|
|
429
|
-
export async function describeJourney(journeyData, resolveTreeExport = onlineTreeExportResolver) {
|
|
413
|
+
export async function describeJourney(journeyData, resolveTreeExport = frodo.authn.journey.onlineTreeExportResolver) {
|
|
430
414
|
var _journeyData$meta, _journeyData$tree$uiC, _journeyData$themes;
|
|
431
415
|
const allNodes = {
|
|
432
416
|
...journeyData.nodes,
|
|
@@ -442,8 +426,8 @@ export async function describeJourney(journeyData, resolveTreeExport = onlineTre
|
|
|
442
426
|
}
|
|
443
427
|
|
|
444
428
|
// initialize AM version from file
|
|
445
|
-
if (!state.
|
|
446
|
-
state.
|
|
429
|
+
if (!state.getAmVersion() && (_journeyData$meta = journeyData.meta) !== null && _journeyData$meta !== void 0 && _journeyData$meta.originAmVersion) {
|
|
430
|
+
state.setAmVersion(journeyData.meta.originAmVersion);
|
|
447
431
|
}
|
|
448
432
|
|
|
449
433
|
// Journey Name
|
|
@@ -459,7 +443,7 @@ export async function describeJourney(journeyData, resolveTreeExport = onlineTre
|
|
|
459
443
|
printMessage(`\nStatus\n${journeyData.tree.enabled === false ? 'disabled'['brightRed'] : 'enabled'['brightGreen']}`);
|
|
460
444
|
|
|
461
445
|
// Classification
|
|
462
|
-
if (state.
|
|
446
|
+
if (state.getAmVersion()) {
|
|
463
447
|
printMessage(`\nClassification\n${getJourneyClassification(journeyData).join(', ')}`, 'data');
|
|
464
448
|
}
|
|
465
449
|
|
|
@@ -470,7 +454,7 @@ export async function describeJourney(journeyData, resolveTreeExport = onlineTre
|
|
|
470
454
|
}
|
|
471
455
|
|
|
472
456
|
// Dependency Tree
|
|
473
|
-
const descendents = await getTreeDescendents(journeyData, resolveTreeExport);
|
|
457
|
+
const descendents = await frodo.authn.journey.getTreeDescendents(journeyData, resolveTreeExport);
|
|
474
458
|
describeTreeDescendents(descendents);
|
|
475
459
|
|
|
476
460
|
// Node Types
|
|
@@ -485,7 +469,7 @@ export async function describeJourney(journeyData, resolveTreeExport = onlineTre
|
|
|
485
469
|
if (Object.entries(allNodes).length) {
|
|
486
470
|
printMessage(`\nNodes (${Object.entries(allNodes).length}):`, 'data');
|
|
487
471
|
for (const nodeObj of Object.values(allNodes)) {
|
|
488
|
-
printMessage(`- ${Node.getOneLineDescription(nodeObj, getNodeRef(nodeObj, journeyData))}`, 'data');
|
|
472
|
+
printMessage(`- ${Node.getOneLineDescription(nodeObj, frodo.authn.journey.getNodeRef(nodeObj, journeyData))}`, 'data');
|
|
489
473
|
}
|
|
490
474
|
}
|
|
491
475
|
|
|
@@ -553,7 +537,7 @@ export async function describeJourney(journeyData, resolveTreeExport = onlineTre
|
|
|
553
537
|
* @param {SingleTreeExportInterface} journeyData journey export object
|
|
554
538
|
* @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function
|
|
555
539
|
*/
|
|
556
|
-
export async function describeJourneyMd(journeyData, resolveTreeExport = onlineTreeExportResolver) {
|
|
540
|
+
export async function describeJourneyMd(journeyData, resolveTreeExport = frodo.authn.journey.onlineTreeExportResolver) {
|
|
557
541
|
var _journeyData$meta2, _journeyData$tree$uiC2, _journeyData$themes2;
|
|
558
542
|
const allNodes = {
|
|
559
543
|
...journeyData.nodes,
|
|
@@ -569,8 +553,8 @@ export async function describeJourneyMd(journeyData, resolveTreeExport = onlineT
|
|
|
569
553
|
}
|
|
570
554
|
|
|
571
555
|
// initialize AM version from file
|
|
572
|
-
if (!state.
|
|
573
|
-
state.
|
|
556
|
+
if (!state.getAmVersion() && (_journeyData$meta2 = journeyData.meta) !== null && _journeyData$meta2 !== void 0 && _journeyData$meta2.originAmVersion) {
|
|
557
|
+
state.setAmVersion(journeyData.meta.originAmVersion);
|
|
574
558
|
}
|
|
575
559
|
|
|
576
560
|
// Journey Name
|
|
@@ -590,7 +574,7 @@ export async function describeJourneyMd(journeyData, resolveTreeExport = onlineT
|
|
|
590
574
|
printMessage(`\n[]()\n`, 'data');
|
|
591
575
|
|
|
592
576
|
// Dependency Tree
|
|
593
|
-
const descendents = await getTreeDescendents(journeyData, resolveTreeExport);
|
|
577
|
+
const descendents = await frodo.authn.journey.getTreeDescendents(journeyData, resolveTreeExport);
|
|
594
578
|
printMessage(describeTreeDescendentsMd(descendents), 'data');
|
|
595
579
|
|
|
596
580
|
// Node Types
|
|
@@ -608,7 +592,7 @@ export async function describeJourneyMd(journeyData, resolveTreeExport = onlineT
|
|
|
608
592
|
printMessage(`## Nodes (${Object.entries(allNodes).length})`, 'data');
|
|
609
593
|
printMessage(Node.getTableHeaderMd(), 'data');
|
|
610
594
|
for (const nodeObj of Object.values(allNodes)) {
|
|
611
|
-
printMessage(`${Node.getTableRowMd(nodeObj, getNodeRef(nodeObj, journeyData))}`, 'data');
|
|
595
|
+
printMessage(`${Node.getTableRowMd(nodeObj, frodo.authn.journey.getNodeRef(nodeObj, journeyData))}`, 'data');
|
|
612
596
|
}
|
|
613
597
|
}
|
|
614
598
|
|