@rockcarver/frodo-cli 2.0.0-8 → 2.0.0
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 +1 -0
- package/CHANGELOG.md +1180 -715
- package/README.md +2 -2
- package/dist/app.cjs +187758 -0
- package/dist/app.cjs.map +1 -0
- package/dist/app.d.cts +2 -0
- package/dist/chunk-MPPKDFVI.cjs +56 -0
- package/dist/chunk-MPPKDFVI.cjs.map +1 -0
- package/dist/launch.cjs +27 -0
- package/dist/launch.cjs.map +1 -0
- package/dist/launch.d.cts +1 -0
- package/dist/loader.cjs +836 -0
- package/dist/loader.cjs.map +1 -0
- package/dist/loader.d.cts +3 -0
- package/global-jest-setup.js +5 -0
- package/package.json +68 -57
- package/tsup.config.ts +40 -0
- package/esm/app.js +0 -61
- package/esm/app.js.map +0 -1
- package/esm/cli/FrodoCommand.js +0 -147
- package/esm/cli/FrodoCommand.js.map +0 -1
- package/esm/cli/_template/something-delete.js +0 -22
- package/esm/cli/_template/something-delete.js.map +0 -1
- package/esm/cli/_template/something-describe.js +0 -22
- package/esm/cli/_template/something-describe.js.map +0 -1
- package/esm/cli/_template/something-else-delete.js +0 -22
- package/esm/cli/_template/something-else-delete.js.map +0 -1
- package/esm/cli/_template/something-else-describe.js +0 -22
- package/esm/cli/_template/something-else-describe.js.map +0 -1
- package/esm/cli/_template/something-else-export.js +0 -22
- package/esm/cli/_template/something-else-export.js.map +0 -1
- package/esm/cli/_template/something-else-import.js +0 -22
- package/esm/cli/_template/something-else-import.js.map +0 -1
- package/esm/cli/_template/something-else-list.js +0 -22
- package/esm/cli/_template/something-else-list.js.map +0 -1
- package/esm/cli/_template/something-else.js +0 -10
- package/esm/cli/_template/something-else.js.map +0 -1
- package/esm/cli/_template/something-export.js +0 -22
- package/esm/cli/_template/something-export.js.map +0 -1
- package/esm/cli/_template/something-import.js +0 -22
- package/esm/cli/_template/something-import.js.map +0 -1
- package/esm/cli/_template/something-list.js +0 -22
- package/esm/cli/_template/something-list.js.map +0 -1
- package/esm/cli/_template/something-other-delete.js +0 -22
- package/esm/cli/_template/something-other-delete.js.map +0 -1
- package/esm/cli/_template/something-other-describe.js +0 -22
- package/esm/cli/_template/something-other-describe.js.map +0 -1
- package/esm/cli/_template/something-other-export.js +0 -22
- package/esm/cli/_template/something-other-export.js.map +0 -1
- package/esm/cli/_template/something-other-import.js +0 -22
- package/esm/cli/_template/something-other-import.js.map +0 -1
- package/esm/cli/_template/something-other-list.js +0 -22
- package/esm/cli/_template/something-other-list.js.map +0 -1
- package/esm/cli/_template/something-other.js +0 -10
- package/esm/cli/_template/something-other.js.map +0 -1
- package/esm/cli/_template/something.js +0 -16
- package/esm/cli/_template/something.js.map +0 -1
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js +0 -27
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js.map +0 -1
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js +0 -86
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js.map +0 -1
- package/esm/cli/admin/admin-federation-export.js +0 -45
- package/esm/cli/admin/admin-federation-export.js.map +0 -1
- package/esm/cli/admin/admin-federation-import.js +0 -49
- package/esm/cli/admin/admin-federation-import.js.map +0 -1
- package/esm/cli/admin/admin-federation-list.js +0 -29
- package/esm/cli/admin/admin-federation-list.js.map +0 -1
- package/esm/cli/admin/admin-federation.js +0 -13
- package/esm/cli/admin/admin-federation.js.map +0 -1
- package/esm/cli/admin/admin-get-access-token.js +0 -28
- package/esm/cli/admin/admin-get-access-token.js.map +0 -1
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +0 -28
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +0 -1
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js +0 -28
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js.map +0 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +0 -30
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js.map +0 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +0 -30
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js.map +0 -1
- package/esm/cli/admin/admin-list-static-user-mappings.js +0 -31
- package/esm/cli/admin/admin-list-static-user-mappings.js.map +0 -1
- package/esm/cli/admin/admin-remove-static-user-mapping.js +0 -27
- package/esm/cli/admin/admin-remove-static-user-mapping.js.map +0 -1
- package/esm/cli/admin/admin-repair-org-model.js +0 -28
- package/esm/cli/admin/admin-repair-org-model.js.map +0 -1
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +0 -28
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js.map +0 -1
- package/esm/cli/admin/admin-show-generic-extension-attributes.js +0 -28
- package/esm/cli/admin/admin-show-generic-extension-attributes.js.map +0 -1
- package/esm/cli/admin/admin.js +0 -22
- package/esm/cli/admin/admin.js.map +0 -1
- package/esm/cli/agent/agent-delete.js +0 -52
- package/esm/cli/agent/agent-delete.js.map +0 -1
- package/esm/cli/agent/agent-describe.js +0 -22
- package/esm/cli/agent/agent-describe.js.map +0 -1
- package/esm/cli/agent/agent-export.js +0 -42
- package/esm/cli/agent/agent-export.js.map +0 -1
- package/esm/cli/agent/agent-gateway-delete.js +0 -52
- package/esm/cli/agent/agent-gateway-delete.js.map +0 -1
- package/esm/cli/agent/agent-gateway-describe.js +0 -22
- package/esm/cli/agent/agent-gateway-describe.js.map +0 -1
- package/esm/cli/agent/agent-gateway-export.js +0 -42
- package/esm/cli/agent/agent-gateway-export.js.map +0 -1
- package/esm/cli/agent/agent-gateway-import.js +0 -47
- package/esm/cli/agent/agent-gateway-import.js.map +0 -1
- package/esm/cli/agent/agent-gateway-list.js +0 -23
- package/esm/cli/agent/agent-gateway-list.js.map +0 -1
- package/esm/cli/agent/agent-gateway.js +0 -10
- package/esm/cli/agent/agent-gateway.js.map +0 -1
- package/esm/cli/agent/agent-import.js +0 -47
- package/esm/cli/agent/agent-import.js.map +0 -1
- package/esm/cli/agent/agent-java-delete.js +0 -52
- package/esm/cli/agent/agent-java-delete.js.map +0 -1
- package/esm/cli/agent/agent-java-describe.js +0 -22
- package/esm/cli/agent/agent-java-describe.js.map +0 -1
- package/esm/cli/agent/agent-java-export.js +0 -42
- package/esm/cli/agent/agent-java-export.js.map +0 -1
- package/esm/cli/agent/agent-java-import.js +0 -47
- package/esm/cli/agent/agent-java-import.js.map +0 -1
- package/esm/cli/agent/agent-java-list.js +0 -23
- package/esm/cli/agent/agent-java-list.js.map +0 -1
- package/esm/cli/agent/agent-java.js +0 -10
- package/esm/cli/agent/agent-java.js.map +0 -1
- package/esm/cli/agent/agent-list.js +0 -23
- package/esm/cli/agent/agent-list.js.map +0 -1
- package/esm/cli/agent/agent-web-delete.js +0 -52
- package/esm/cli/agent/agent-web-delete.js.map +0 -1
- package/esm/cli/agent/agent-web-describe.js +0 -22
- package/esm/cli/agent/agent-web-describe.js.map +0 -1
- package/esm/cli/agent/agent-web-export.js +0 -42
- package/esm/cli/agent/agent-web-export.js.map +0 -1
- package/esm/cli/agent/agent-web-import.js +0 -47
- package/esm/cli/agent/agent-web-import.js.map +0 -1
- package/esm/cli/agent/agent-web-list.js +0 -23
- package/esm/cli/agent/agent-web-list.js.map +0 -1
- package/esm/cli/agent/agent-web.js +0 -10
- package/esm/cli/agent/agent-web.js.map +0 -1
- package/esm/cli/agent/agent.js +0 -17
- package/esm/cli/agent/agent.js.map +0 -1
- package/esm/cli/app/app-delete.js +0 -22
- package/esm/cli/app/app-delete.js.map +0 -1
- package/esm/cli/app/app-describe.js +0 -22
- package/esm/cli/app/app-describe.js.map +0 -1
- package/esm/cli/app/app-export.js +0 -52
- package/esm/cli/app/app-export.js.map +0 -1
- package/esm/cli/app/app-import.js +0 -57
- package/esm/cli/app/app-import.js.map +0 -1
- package/esm/cli/app/app-list.js +0 -25
- package/esm/cli/app/app-list.js.map +0 -1
- package/esm/cli/app/app.js +0 -21
- package/esm/cli/app/app.js.map +0 -1
- package/esm/cli/authz/authz-policy-delete.js +0 -43
- package/esm/cli/authz/authz-policy-delete.js.map +0 -1
- package/esm/cli/authz/authz-policy-describe.js +0 -30
- package/esm/cli/authz/authz-policy-describe.js.map +0 -1
- package/esm/cli/authz/authz-policy-export.js +0 -75
- package/esm/cli/authz/authz-policy-export.js.map +0 -1
- package/esm/cli/authz/authz-policy-import.js +0 -65
- package/esm/cli/authz/authz-policy-import.js.map +0 -1
- package/esm/cli/authz/authz-policy-list.js +0 -37
- package/esm/cli/authz/authz-policy-list.js.map +0 -1
- package/esm/cli/authz/authz-policy.js +0 -10
- package/esm/cli/authz/authz-policy.js.map +0 -1
- package/esm/cli/authz/authz-set-delete.js +0 -37
- package/esm/cli/authz/authz-set-delete.js.map +0 -1
- package/esm/cli/authz/authz-set-describe.js +0 -30
- package/esm/cli/authz/authz-set-describe.js.map +0 -1
- package/esm/cli/authz/authz-set-export.js +0 -55
- package/esm/cli/authz/authz-set-export.js.map +0 -1
- package/esm/cli/authz/authz-set-import.js +0 -61
- package/esm/cli/authz/authz-set-import.js.map +0 -1
- package/esm/cli/authz/authz-set-list.js +0 -25
- package/esm/cli/authz/authz-set-list.js.map +0 -1
- package/esm/cli/authz/authz-set.js +0 -10
- package/esm/cli/authz/authz-set.js.map +0 -1
- package/esm/cli/authz/authz-type-delete.js +0 -43
- package/esm/cli/authz/authz-type-delete.js.map +0 -1
- package/esm/cli/authz/authz-type-describe.js +0 -34
- package/esm/cli/authz/authz-type-describe.js.map +0 -1
- package/esm/cli/authz/authz-type-export.js +0 -49
- package/esm/cli/authz/authz-type-export.js.map +0 -1
- package/esm/cli/authz/authz-type-import.js +0 -55
- package/esm/cli/authz/authz-type-import.js.map +0 -1
- package/esm/cli/authz/authz-type-list.js +0 -26
- package/esm/cli/authz/authz-type-list.js.map +0 -1
- package/esm/cli/authz/authz-type.js +0 -10
- package/esm/cli/authz/authz-type.js.map +0 -1
- package/esm/cli/authz/authz.js +0 -12
- package/esm/cli/authz/authz.js.map +0 -1
- package/esm/cli/conn/conn-delete.js +0 -14
- package/esm/cli/conn/conn-delete.js.map +0 -1
- package/esm/cli/conn/conn-describe.js +0 -15
- package/esm/cli/conn/conn-describe.js.map +0 -1
- package/esm/cli/conn/conn-list.js +0 -15
- package/esm/cli/conn/conn-list.js.map +0 -1
- package/esm/cli/conn/conn-save.js +0 -107
- package/esm/cli/conn/conn-save.js.map +0 -1
- package/esm/cli/conn/conn.js +0 -15
- package/esm/cli/conn/conn.js.map +0 -1
- package/esm/cli/email/email-template-export.js +0 -40
- package/esm/cli/email/email-template-export.js.map +0 -1
- package/esm/cli/email/email-template-import.js +0 -45
- package/esm/cli/email/email-template-import.js.map +0 -1
- package/esm/cli/email/email-template-list.js +0 -25
- package/esm/cli/email/email-template-list.js.map +0 -1
- package/esm/cli/email/email-template.js +0 -8
- package/esm/cli/email/email-template.js.map +0 -1
- package/esm/cli/email/email.js +0 -11
- package/esm/cli/email/email.js.map +0 -1
- package/esm/cli/esv/esv-apply.js +0 -62
- package/esm/cli/esv/esv-apply.js.map +0 -1
- package/esm/cli/esv/esv-secret-create.js +0 -25
- package/esm/cli/esv/esv-secret-create.js.map +0 -1
- package/esm/cli/esv/esv-secret-delete.js +0 -35
- package/esm/cli/esv/esv-secret-delete.js.map +0 -1
- package/esm/cli/esv/esv-secret-describe.js +0 -25
- package/esm/cli/esv/esv-secret-describe.js.map +0 -1
- package/esm/cli/esv/esv-secret-export.js +0 -22
- package/esm/cli/esv/esv-secret-export.js.map +0 -1
- package/esm/cli/esv/esv-secret-import.js +0 -22
- package/esm/cli/esv/esv-secret-import.js.map +0 -1
- package/esm/cli/esv/esv-secret-list.js +0 -25
- package/esm/cli/esv/esv-secret-list.js.map +0 -1
- package/esm/cli/esv/esv-secret-set.js +0 -25
- package/esm/cli/esv/esv-secret-set.js.map +0 -1
- package/esm/cli/esv/esv-secret-version-activate.js +0 -30
- package/esm/cli/esv/esv-secret-version-activate.js.map +0 -1
- package/esm/cli/esv/esv-secret-version-create.js +0 -25
- package/esm/cli/esv/esv-secret-version-create.js.map +0 -1
- package/esm/cli/esv/esv-secret-version-deactivate.js +0 -30
- package/esm/cli/esv/esv-secret-version-deactivate.js.map +0 -1
- package/esm/cli/esv/esv-secret-version-delete.js +0 -35
- package/esm/cli/esv/esv-secret-version-delete.js.map +0 -1
- package/esm/cli/esv/esv-secret-version-list.js +0 -25
- package/esm/cli/esv/esv-secret-version-list.js.map +0 -1
- package/esm/cli/esv/esv-secret-version.js +0 -10
- package/esm/cli/esv/esv-secret-version.js.map +0 -1
- package/esm/cli/esv/esv-secret.js +0 -16
- package/esm/cli/esv/esv-secret.js.map +0 -1
- package/esm/cli/esv/esv-variable-create.js +0 -24
- package/esm/cli/esv/esv-variable-create.js.map +0 -1
- package/esm/cli/esv/esv-variable-delete.js +0 -35
- package/esm/cli/esv/esv-variable-delete.js.map +0 -1
- package/esm/cli/esv/esv-variable-describe.js +0 -25
- package/esm/cli/esv/esv-variable-describe.js.map +0 -1
- package/esm/cli/esv/esv-variable-export.js +0 -22
- package/esm/cli/esv/esv-variable-export.js.map +0 -1
- package/esm/cli/esv/esv-variable-import.js +0 -22
- package/esm/cli/esv/esv-variable-import.js.map +0 -1
- package/esm/cli/esv/esv-variable-list.js +0 -25
- package/esm/cli/esv/esv-variable-list.js.map +0 -1
- package/esm/cli/esv/esv-variable-set.js +0 -31
- package/esm/cli/esv/esv-variable-set.js.map +0 -1
- package/esm/cli/esv/esv-variable.js +0 -15
- package/esm/cli/esv/esv-variable.js.map +0 -1
- package/esm/cli/esv/esv.js +0 -12
- package/esm/cli/esv/esv.js.map +0 -1
- package/esm/cli/idm/idm-count.js +0 -25
- package/esm/cli/idm/idm-count.js.map +0 -1
- package/esm/cli/idm/idm-export.js +0 -42
- package/esm/cli/idm/idm-export.js.map +0 -1
- package/esm/cli/idm/idm-import.js +0 -45
- package/esm/cli/idm/idm-import.js.map +0 -1
- package/esm/cli/idm/idm-list.js +0 -29
- package/esm/cli/idm/idm-list.js.map +0 -1
- package/esm/cli/idm/idm.js +0 -13
- package/esm/cli/idm/idm.js.map +0 -1
- package/esm/cli/idp/idp-export.js +0 -42
- package/esm/cli/idp/idp-export.js.map +0 -1
- package/esm/cli/idp/idp-import.js +0 -45
- package/esm/cli/idp/idp-import.js.map +0 -1
- package/esm/cli/idp/idp-list.js +0 -28
- package/esm/cli/idp/idp-list.js.map +0 -1
- package/esm/cli/idp/idp.js +0 -12
- package/esm/cli/idp/idp.js.map +0 -1
- package/esm/cli/info/info.js +0 -54
- package/esm/cli/info/info.js.map +0 -1
- package/esm/cli/journey/journey-delete.js +0 -34
- package/esm/cli/journey/journey-delete.js.map +0 -1
- package/esm/cli/journey/journey-describe.js +0 -125
- package/esm/cli/journey/journey-describe.js.map +0 -1
- package/esm/cli/journey/journey-disable.js +0 -43
- package/esm/cli/journey/journey-disable.js.map +0 -1
- package/esm/cli/journey/journey-enable.js +0 -43
- package/esm/cli/journey/journey-enable.js.map +0 -1
- package/esm/cli/journey/journey-export.js +0 -50
- package/esm/cli/journey/journey-export.js.map +0 -1
- package/esm/cli/journey/journey-import.js +0 -57
- package/esm/cli/journey/journey-import.js.map +0 -1
- package/esm/cli/journey/journey-list.js +0 -25
- package/esm/cli/journey/journey-list.js.map +0 -1
- package/esm/cli/journey/journey-prune.js +0 -38
- package/esm/cli/journey/journey-prune.js.map +0 -1
- package/esm/cli/journey/journey.js +0 -17
- package/esm/cli/journey/journey.js.map +0 -1
- package/esm/cli/log/log-fetch.js +0 -101
- package/esm/cli/log/log-fetch.js.map +0 -1
- package/esm/cli/log/log-key-delete.js +0 -35
- package/esm/cli/log/log-key-delete.js.map +0 -1
- package/esm/cli/log/log-key-describe.js +0 -22
- package/esm/cli/log/log-key-describe.js.map +0 -1
- package/esm/cli/log/log-key-list.js +0 -26
- package/esm/cli/log/log-key-list.js.map +0 -1
- package/esm/cli/log/log-key.js +0 -8
- package/esm/cli/log/log-key.js.map +0 -1
- package/esm/cli/log/log-list.js +0 -59
- package/esm/cli/log/log-list.js.map +0 -1
- package/esm/cli/log/log-tail.js +0 -56
- package/esm/cli/log/log-tail.js.map +0 -1
- package/esm/cli/log/log.js +0 -17
- package/esm/cli/log/log.js.map +0 -1
- package/esm/cli/realm/realm-add-custom-domain.js +0 -25
- package/esm/cli/realm/realm-add-custom-domain.js.map +0 -1
- package/esm/cli/realm/realm-describe.js +0 -24
- package/esm/cli/realm/realm-describe.js.map +0 -1
- package/esm/cli/realm/realm-list.js +0 -25
- package/esm/cli/realm/realm-list.js.map +0 -1
- package/esm/cli/realm/realm-remove-custom-domain.js +0 -27
- package/esm/cli/realm/realm-remove-custom-domain.js.map +0 -1
- package/esm/cli/realm/realm.js +0 -18
- package/esm/cli/realm/realm.js.map +0 -1
- package/esm/cli/saml/saml-cot-export.js +0 -43
- package/esm/cli/saml/saml-cot-export.js.map +0 -1
- package/esm/cli/saml/saml-cot-import.js +0 -49
- package/esm/cli/saml/saml-cot-import.js.map +0 -1
- package/esm/cli/saml/saml-cot-list.js +0 -26
- package/esm/cli/saml/saml-cot-list.js.map +0 -1
- package/esm/cli/saml/saml-cot.js +0 -8
- package/esm/cli/saml/saml-cot.js.map +0 -1
- package/esm/cli/saml/saml-delete.js +0 -38
- package/esm/cli/saml/saml-delete.js.map +0 -1
- package/esm/cli/saml/saml-describe.js +0 -25
- package/esm/cli/saml/saml-describe.js.map +0 -1
- package/esm/cli/saml/saml-export.js +0 -40
- package/esm/cli/saml/saml-export.js.map +0 -1
- package/esm/cli/saml/saml-import.js +0 -45
- package/esm/cli/saml/saml-import.js.map +0 -1
- package/esm/cli/saml/saml-list.js +0 -25
- package/esm/cli/saml/saml-list.js.map +0 -1
- package/esm/cli/saml/saml-metadata-export.js +0 -35
- package/esm/cli/saml/saml-metadata-export.js.map +0 -1
- package/esm/cli/saml/saml-metadata.js +0 -6
- package/esm/cli/saml/saml-metadata.js.map +0 -1
- package/esm/cli/saml/saml.js +0 -16
- package/esm/cli/saml/saml.js.map +0 -1
- package/esm/cli/script/script-delete.js +0 -22
- package/esm/cli/script/script-delete.js.map +0 -1
- package/esm/cli/script/script-describe.js +0 -22
- package/esm/cli/script/script-describe.js.map +0 -1
- package/esm/cli/script/script-export.js +0 -62
- package/esm/cli/script/script-export.js.map +0 -1
- package/esm/cli/script/script-import.js +0 -35
- package/esm/cli/script/script-import.js.map +0 -1
- package/esm/cli/script/script-list.js +0 -26
- package/esm/cli/script/script-list.js.map +0 -1
- package/esm/cli/script/script.js +0 -18
- package/esm/cli/script/script.js.map +0 -1
- package/esm/cli/service/service-delete.js +0 -22
- package/esm/cli/service/service-delete.js.map +0 -1
- package/esm/cli/service/service-export.js +0 -40
- package/esm/cli/service/service-export.js.map +0 -1
- package/esm/cli/service/service-import.js +0 -47
- package/esm/cli/service/service-import.js.map +0 -1
- package/esm/cli/service/service-list.js +0 -20
- package/esm/cli/service/service-list.js.map +0 -1
- package/esm/cli/service/service.js +0 -13
- package/esm/cli/service/service.js.map +0 -1
- package/esm/cli/theme/theme-delete.e2e.test_.js.map +0 -1
- package/esm/cli/theme/theme-delete.js +0 -40
- package/esm/cli/theme/theme-delete.js.map +0 -1
- package/esm/cli/theme/theme-export.js +0 -45
- package/esm/cli/theme/theme-export.js.map +0 -1
- package/esm/cli/theme/theme-import.js +0 -50
- package/esm/cli/theme/theme-import.js.map +0 -1
- package/esm/cli/theme/theme-list.e2e.test_.js.map +0 -1
- package/esm/cli/theme/theme-list.js +0 -25
- package/esm/cli/theme/theme-list.js.map +0 -1
- package/esm/cli/theme/theme.js +0 -13
- package/esm/cli/theme/theme.js.map +0 -1
- package/esm/help/SampleData.js +0 -7
- package/esm/help/SampleData.js.map +0 -1
- package/esm/launch.js +0 -15
- package/esm/launch.js.map +0 -1
- package/esm/loader.js +0 -40
- package/esm/loader.js.map +0 -1
- package/esm/ops/AdminFederationOps.js +0 -216
- package/esm/ops/AdminFederationOps.js.map +0 -1
- package/esm/ops/AgentOps.js +0 -691
- package/esm/ops/AgentOps.js.map +0 -1
- package/esm/ops/CirclesOfTrustOps.js +0 -260
- package/esm/ops/CirclesOfTrustOps.js.map +0 -1
- package/esm/ops/ConnectionProfileOps.js +0 -125
- package/esm/ops/ConnectionProfileOps.js.map +0 -1
- package/esm/ops/EmailTemplateOps.js +0 -361
- package/esm/ops/EmailTemplateOps.js.map +0 -1
- package/esm/ops/IdmOps.js +0 -360
- package/esm/ops/IdmOps.js.map +0 -1
- package/esm/ops/IdpOps.js +0 -212
- package/esm/ops/IdpOps.js.map +0 -1
- package/esm/ops/JourneyOps.js +0 -669
- package/esm/ops/JourneyOps.js.map +0 -1
- package/esm/ops/LogOps.js +0 -149
- package/esm/ops/LogOps.js.map +0 -1
- package/esm/ops/NodeOps.js +0 -89
- package/esm/ops/NodeOps.js.map +0 -1
- package/esm/ops/OAuth2ClientOps.js +0 -271
- package/esm/ops/OAuth2ClientOps.js.map +0 -1
- package/esm/ops/OrganizationOps.js +0 -34
- package/esm/ops/OrganizationOps.js.map +0 -1
- package/esm/ops/PolicyOps.js +0 -493
- package/esm/ops/PolicyOps.js.map +0 -1
- package/esm/ops/PolicySetOps.js +0 -379
- package/esm/ops/PolicySetOps.js.map +0 -1
- package/esm/ops/RealmOps.js +0 -116
- package/esm/ops/RealmOps.js.map +0 -1
- package/esm/ops/ResourceTypeOps.js +0 -452
- package/esm/ops/ResourceTypeOps.js.map +0 -1
- package/esm/ops/Saml2Ops.js +0 -293
- package/esm/ops/Saml2Ops.js.map +0 -1
- package/esm/ops/Saml2Ops.test_.js.map +0 -1
- package/esm/ops/ScriptOps.js +0 -383
- package/esm/ops/ScriptOps.js.map +0 -1
- package/esm/ops/SecretsOps.js +0 -237
- package/esm/ops/SecretsOps.js.map +0 -1
- package/esm/ops/ServiceOps.js +0 -213
- package/esm/ops/ServiceOps.js.map +0 -1
- package/esm/ops/ThemeOps.js +0 -361
- package/esm/ops/ThemeOps.js.map +0 -1
- package/esm/ops/VariablesOps.js +0 -144
- package/esm/ops/VariablesOps.js.map +0 -1
- package/esm/ops/utils/OpsUtils.js +0 -9
- package/esm/ops/utils/OpsUtils.js.map +0 -1
- package/esm/ops/utils/Wordwrap.js +0 -5
- package/esm/ops/utils/Wordwrap.js.map +0 -1
- package/esm/storage/StaticStorage.js +0 -12
- package/esm/storage/StaticStorage.js.map +0 -1
- package/esm/utils/Config.js +0 -43
- package/esm/utils/Config.js.map +0 -1
- package/esm/utils/Console.js +0 -537
- package/esm/utils/Console.js.map +0 -1
- package/esm/utils/ExportImportUtils.js +0 -93
- package/esm/utils/ExportImportUtils.js.map +0 -1
- package/esm/utils/Version.js +0 -139
- package/esm/utils/Version.js.map +0 -1
package/esm/ops/IdmOps.js
DELETED
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
import { frodo } from '@rockcarver/frodo-lib';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import propertiesReader from 'properties-reader';
|
|
6
|
-
import replaceall from 'replaceall';
|
|
7
|
-
import { createProgressIndicator, printMessage, stopProgressIndicator } from '../utils/Console';
|
|
8
|
-
import { getTypedFilename } from '../utils/ExportImportUtils';
|
|
9
|
-
const {
|
|
10
|
-
validateScriptHooks
|
|
11
|
-
} = frodo.helper.script;
|
|
12
|
-
const {
|
|
13
|
-
readFiles,
|
|
14
|
-
unSubstituteEnvParams
|
|
15
|
-
} = frodo.helper.utils;
|
|
16
|
-
const {
|
|
17
|
-
testConnectorServers,
|
|
18
|
-
getAllConfigEntities,
|
|
19
|
-
getConfigEntity,
|
|
20
|
-
putConfigEntity,
|
|
21
|
-
queryAllManagedObjectsByType
|
|
22
|
-
} = frodo.idm.config;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Warn about and list offline remote connector servers
|
|
26
|
-
*/
|
|
27
|
-
export async function warnAboutOfflineConnectorServers() {
|
|
28
|
-
try {
|
|
29
|
-
const all = await testConnectorServers();
|
|
30
|
-
const offline = all.filter(status => !status.ok).map(status => status.name);
|
|
31
|
-
if (offline.length) {
|
|
32
|
-
printMessage(`\nThe following connector server(s) are offline and their connectors and configuration unavailable:\n${offline.join('\n')}`, 'warn');
|
|
33
|
-
}
|
|
34
|
-
} catch (error) {
|
|
35
|
-
printMessage(error, 'error');
|
|
36
|
-
printMessage(`Error getting offline connector servers: ${error.message}`, 'error');
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* List all IDM configuration objects
|
|
42
|
-
*/
|
|
43
|
-
export async function listAllConfigEntities() {
|
|
44
|
-
try {
|
|
45
|
-
const {
|
|
46
|
-
configurations
|
|
47
|
-
} = await getAllConfigEntities();
|
|
48
|
-
for (const configEntity of configurations) {
|
|
49
|
-
printMessage(`${configEntity._id}`, 'data');
|
|
50
|
-
}
|
|
51
|
-
} catch (getAllConfigEntitiesError) {
|
|
52
|
-
printMessage(getAllConfigEntitiesError, 'error');
|
|
53
|
-
printMessage(`Error getting config entities: ${getAllConfigEntitiesError}`, 'error');
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Export an IDM configuration object.
|
|
59
|
-
* @param {String} id the desired configuration object
|
|
60
|
-
* @param {String} file optional export file
|
|
61
|
-
*/
|
|
62
|
-
export async function exportConfigEntity(id, file) {
|
|
63
|
-
let fileName = file;
|
|
64
|
-
if (!fileName) {
|
|
65
|
-
fileName = getTypedFilename(`${id}`, 'idm');
|
|
66
|
-
}
|
|
67
|
-
const configEntity = await getConfigEntity(id);
|
|
68
|
-
fs.writeFile(fileName, JSON.stringify(configEntity, null, 2), err => {
|
|
69
|
-
if (err) {
|
|
70
|
-
return printMessage(`ERROR - can't save ${id} export to file`, 'error');
|
|
71
|
-
}
|
|
72
|
-
return '';
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Export all IDM configuration objects into separate JSON files in a directory specified by <directory>
|
|
78
|
-
* @param {String} directory export directory
|
|
79
|
-
*/
|
|
80
|
-
export async function exportAllRawConfigEntities(directory) {
|
|
81
|
-
try {
|
|
82
|
-
const {
|
|
83
|
-
configurations
|
|
84
|
-
} = await getAllConfigEntities();
|
|
85
|
-
if (!fs.existsSync(directory)) {
|
|
86
|
-
fs.mkdirSync(directory);
|
|
87
|
-
}
|
|
88
|
-
createProgressIndicator('indeterminate', undefined, 'Exporting config objects...');
|
|
89
|
-
const entityPromises = [];
|
|
90
|
-
for (const configEntity of configurations) {
|
|
91
|
-
entityPromises.push(getConfigEntity(configEntity._id).catch(getConfigEntityError => {
|
|
92
|
-
var _getConfigEntityError, _getConfigEntityError2, _getConfigEntityError3, _getConfigEntityError4, _getConfigEntityError5, _getConfigEntityError6, _getConfigEntityError7, _getConfigEntityError8, _getConfigEntityError9;
|
|
93
|
-
if (!(((_getConfigEntityError = getConfigEntityError.response) === null || _getConfigEntityError === void 0 ? void 0 : _getConfigEntityError.status) === 403 && ((_getConfigEntityError2 = getConfigEntityError.response) === null || _getConfigEntityError2 === void 0 ? void 0 : (_getConfigEntityError3 = _getConfigEntityError2.data) === null || _getConfigEntityError3 === void 0 ? void 0 : _getConfigEntityError3.message) === 'This operation is not available in ForgeRock Identity Cloud.') && !(
|
|
94
|
-
// list of config entities, which do not exist by default or ever.
|
|
95
|
-
|
|
96
|
-
['script', 'notificationFactory', 'apiVersion', 'metrics', 'repo.init', 'endpoint/validateQueryFilter', 'endpoint/oauthproxy', 'external.rest', 'scheduler', 'org.apache.felix.fileinstall/openidm', 'cluster', 'endpoint/mappingDetails', 'fieldPolicy/teammember'].includes(configEntity._id) && ((_getConfigEntityError4 = getConfigEntityError.response) === null || _getConfigEntityError4 === void 0 ? void 0 : _getConfigEntityError4.status) === 404 && ((_getConfigEntityError5 = getConfigEntityError.response) === null || _getConfigEntityError5 === void 0 ? void 0 : (_getConfigEntityError6 = _getConfigEntityError5.data) === null || _getConfigEntityError6 === void 0 ? void 0 : _getConfigEntityError6.reason) === 'Not Found') &&
|
|
97
|
-
// https://bugster.forgerock.org/jira/browse/OPENIDM-18270
|
|
98
|
-
!(((_getConfigEntityError7 = getConfigEntityError.response) === null || _getConfigEntityError7 === void 0 ? void 0 : _getConfigEntityError7.status) === 404 && ((_getConfigEntityError8 = getConfigEntityError.response) === null || _getConfigEntityError8 === void 0 ? void 0 : (_getConfigEntityError9 = _getConfigEntityError8.data) === null || _getConfigEntityError9 === void 0 ? void 0 : _getConfigEntityError9.message) === 'No configuration exists for id org.apache.felix.fileinstall/openidm')) {
|
|
99
|
-
var _getConfigEntityError10;
|
|
100
|
-
printMessage((_getConfigEntityError10 = getConfigEntityError.response) === null || _getConfigEntityError10 === void 0 ? void 0 : _getConfigEntityError10.data, 'error');
|
|
101
|
-
printMessage(`Error getting config entity ${configEntity._id}: ${getConfigEntityError}`, 'error');
|
|
102
|
-
}
|
|
103
|
-
}));
|
|
104
|
-
}
|
|
105
|
-
const results = await Promise.all(entityPromises);
|
|
106
|
-
for (const item of results) {
|
|
107
|
-
if (item != null) {
|
|
108
|
-
fse.outputFile(`${directory}/${item._id}.json`, JSON.stringify(item, null, 2), err => {
|
|
109
|
-
if (err) {
|
|
110
|
-
return printMessage(`ERROR - can't save config ${item._id} to file - ${err}`, 'error');
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
stopProgressIndicator('Exported config objects.', 'success');
|
|
116
|
-
} catch (getAllConfigEntitiesError) {
|
|
117
|
-
printMessage(getAllConfigEntitiesError, 'error');
|
|
118
|
-
printMessage(`Error getting config entities: ${getAllConfigEntitiesError}`, 'error');
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Export all IDM configuration objects
|
|
124
|
-
* @param {String} directory export directory
|
|
125
|
-
* @param {String} entitiesFile JSON file that specifies the config entities to export/import
|
|
126
|
-
* @param {String} envFile File that defines environment specific variables for replacement during configuration export/import
|
|
127
|
-
*/
|
|
128
|
-
export async function exportAllConfigEntities(directory, entitiesFile, envFile) {
|
|
129
|
-
let entriesToExport = [];
|
|
130
|
-
// read list of entities to export
|
|
131
|
-
fs.readFile(entitiesFile, 'utf8', async (err, data) => {
|
|
132
|
-
if (err) throw err;
|
|
133
|
-
const entriesData = JSON.parse(data);
|
|
134
|
-
entriesToExport = entriesData.idm;
|
|
135
|
-
// console.log(`entriesToExport ${entriesToExport}`);
|
|
136
|
-
|
|
137
|
-
// read list of configs to parameterize for environment specific values
|
|
138
|
-
const envParams = propertiesReader(envFile);
|
|
139
|
-
try {
|
|
140
|
-
const {
|
|
141
|
-
configurations
|
|
142
|
-
} = await getAllConfigEntities();
|
|
143
|
-
// create export directory if not exist
|
|
144
|
-
if (!fs.existsSync(directory)) {
|
|
145
|
-
fs.mkdirSync(directory);
|
|
146
|
-
}
|
|
147
|
-
createProgressIndicator('indeterminate', undefined, 'Exporting config objects...');
|
|
148
|
-
const entityPromises = [];
|
|
149
|
-
for (const configEntity of configurations) {
|
|
150
|
-
if (entriesToExport.includes(configEntity._id)) {
|
|
151
|
-
entityPromises.push(getConfigEntity(configEntity._id));
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
const results = await Promise.all(entityPromises);
|
|
155
|
-
for (const item of results) {
|
|
156
|
-
if (item != null) {
|
|
157
|
-
let configEntityString = JSON.stringify(item, null, 2);
|
|
158
|
-
envParams.each((key, value) => {
|
|
159
|
-
configEntityString = replaceall(value, `\${${key}}`, configEntityString);
|
|
160
|
-
});
|
|
161
|
-
fse.outputFile(`${directory}/${item._id}.json`, configEntityString, error => {
|
|
162
|
-
if (err) {
|
|
163
|
-
return printMessage(`ERROR - can't save config ${item._id} to file - ${error}`, 'error');
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
stopProgressIndicator(null, 'success');
|
|
169
|
-
} catch (getAllConfigEntitiesError) {
|
|
170
|
-
printMessage(getAllConfigEntitiesError, 'error');
|
|
171
|
-
printMessage(`Error getting config entities: ${getAllConfigEntitiesError}`, 'error');
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Import an IDM configuration object by id from file.
|
|
178
|
-
* @param entityId the configuration object to import
|
|
179
|
-
* @param file optional file to import
|
|
180
|
-
* @param validate validate script hooks
|
|
181
|
-
*/
|
|
182
|
-
export async function importConfigEntityByIdFromFile(entityId, file, validate) {
|
|
183
|
-
if (!file) {
|
|
184
|
-
file = getTypedFilename(entityId, 'idm');
|
|
185
|
-
}
|
|
186
|
-
const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');
|
|
187
|
-
const entityData = JSON.parse(fileData);
|
|
188
|
-
const isValid = validateScriptHooks(entityData);
|
|
189
|
-
if (validate && !isValid) {
|
|
190
|
-
printMessage('Invalid IDM configuration object', 'error');
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
try {
|
|
194
|
-
await putConfigEntity(entityId, entityData);
|
|
195
|
-
} catch (putConfigEntityError) {
|
|
196
|
-
printMessage(putConfigEntityError, 'error');
|
|
197
|
-
printMessage(`Error: ${putConfigEntityError}`, 'error');
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Import IDM configuration object from file.
|
|
203
|
-
* @param file optional file to import
|
|
204
|
-
* @param validate validate script hooks
|
|
205
|
-
*/
|
|
206
|
-
export async function importConfigEntityFromFile(file, validate) {
|
|
207
|
-
const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');
|
|
208
|
-
const entityData = JSON.parse(fileData);
|
|
209
|
-
const entityId = entityData._id;
|
|
210
|
-
const isValid = validateScriptHooks(entityData);
|
|
211
|
-
if (validate && !isValid) {
|
|
212
|
-
printMessage('Invalid IDM configuration object', 'error');
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
try {
|
|
216
|
-
await putConfigEntity(entityId, entityData);
|
|
217
|
-
} catch (putConfigEntityError) {
|
|
218
|
-
printMessage(putConfigEntityError, 'error');
|
|
219
|
-
printMessage(`Error: ${putConfigEntityError}`, 'error');
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Import all IDM configuration objects from separate JSON files in a directory specified by <directory>
|
|
225
|
-
* @param baseDirectory export directory
|
|
226
|
-
* @param validate validate script hooks
|
|
227
|
-
*/
|
|
228
|
-
export async function importAllRawConfigEntities(baseDirectory, validate) {
|
|
229
|
-
if (!fs.existsSync(baseDirectory)) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
const files = await readFiles(baseDirectory);
|
|
233
|
-
const jsonFiles = files.filter(({
|
|
234
|
-
path
|
|
235
|
-
}) => path.toLowerCase().endsWith('.json')).map(({
|
|
236
|
-
path,
|
|
237
|
-
content
|
|
238
|
-
}) => ({
|
|
239
|
-
// Remove .json extension
|
|
240
|
-
entityId: path.substring(0, path.length - 5),
|
|
241
|
-
content,
|
|
242
|
-
path
|
|
243
|
-
}));
|
|
244
|
-
let everyScriptValid = true;
|
|
245
|
-
for (const file of jsonFiles) {
|
|
246
|
-
const jsObject = JSON.parse(file.content);
|
|
247
|
-
const isScriptValid = validateScriptHooks(jsObject);
|
|
248
|
-
if (!isScriptValid) {
|
|
249
|
-
printMessage(`Invalid script hook in ${file.path}`, 'error');
|
|
250
|
-
everyScriptValid = false;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
if (validate && !everyScriptValid) {
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
createProgressIndicator('indeterminate', undefined, 'Importing config objects...');
|
|
257
|
-
const entityPromises = jsonFiles.map(file => {
|
|
258
|
-
return putConfigEntity(file.entityId, file.content);
|
|
259
|
-
});
|
|
260
|
-
const results = await Promise.allSettled(entityPromises);
|
|
261
|
-
const errors = results.filter(result => result.status === 'rejected');
|
|
262
|
-
if (errors.length > 0) {
|
|
263
|
-
printMessage(`Failed to import ${errors.length} config objects:`, 'error');
|
|
264
|
-
for (const error of errors) {
|
|
265
|
-
printMessage(`- ${error.reason}`, 'error');
|
|
266
|
-
}
|
|
267
|
-
stopProgressIndicator(`Failed to import ${errors.length} config objects`, 'error');
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
stopProgressIndicator(`Imported ${results.length} config objects`, 'success');
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Import all IDM configuration objects
|
|
275
|
-
* @param baseDirectory import directory
|
|
276
|
-
* @param entitiesFile JSON file that specifies the config entities to export/import
|
|
277
|
-
* @param envFile File that defines environment specific variables for replacement during configuration export/import
|
|
278
|
-
* @param validate validate script hooks
|
|
279
|
-
*/
|
|
280
|
-
export async function importAllConfigEntities(baseDirectory, entitiesFile, envFile, validate) {
|
|
281
|
-
if (!fs.existsSync(baseDirectory)) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
const entriesToImport = JSON.parse(fs.readFileSync(entitiesFile, 'utf8')).idm;
|
|
285
|
-
const envReader = propertiesReader(envFile);
|
|
286
|
-
const files = await readFiles(baseDirectory);
|
|
287
|
-
const jsonFiles = files.filter(({
|
|
288
|
-
path
|
|
289
|
-
}) => path.toLowerCase().endsWith('.json')).map(({
|
|
290
|
-
content,
|
|
291
|
-
path
|
|
292
|
-
}) => ({
|
|
293
|
-
// Remove .json extension
|
|
294
|
-
entityId: path.substring(0, path.length - 5),
|
|
295
|
-
content,
|
|
296
|
-
path
|
|
297
|
-
}));
|
|
298
|
-
let everyScriptValid = true;
|
|
299
|
-
for (const file of jsonFiles) {
|
|
300
|
-
const jsObject = JSON.parse(file.content);
|
|
301
|
-
const isScriptValid = validateScriptHooks(jsObject);
|
|
302
|
-
if (!isScriptValid) {
|
|
303
|
-
printMessage(`Invalid script hook in ${file.path}`, 'error');
|
|
304
|
-
everyScriptValid = false;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
if (validate && !everyScriptValid) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
createProgressIndicator('indeterminate', undefined, 'Importing config objects...');
|
|
311
|
-
const entityPromises = jsonFiles.filter(({
|
|
312
|
-
entityId
|
|
313
|
-
}) => {
|
|
314
|
-
return entriesToImport.includes(entityId);
|
|
315
|
-
}).map(({
|
|
316
|
-
entityId,
|
|
317
|
-
content
|
|
318
|
-
}) => {
|
|
319
|
-
const unsubstituted = unSubstituteEnvParams(content, envReader);
|
|
320
|
-
return putConfigEntity(entityId, unsubstituted);
|
|
321
|
-
});
|
|
322
|
-
const results = await Promise.allSettled(entityPromises);
|
|
323
|
-
const errors = results.filter(result => result.status === 'rejected');
|
|
324
|
-
if (errors.length > 0) {
|
|
325
|
-
printMessage(`Failed to import ${errors.length} config objects:`, 'error');
|
|
326
|
-
for (const error of errors) {
|
|
327
|
-
printMessage(`- ${error.reason}`, 'error');
|
|
328
|
-
}
|
|
329
|
-
stopProgressIndicator(`Failed to import ${errors.length} config objects`, 'error');
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
stopProgressIndicator(`Imported ${results.length} config objects`, 'success');
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Count number of managed objects of a given type
|
|
337
|
-
* @param {String} type managed object type, e.g. alpha_user
|
|
338
|
-
*/
|
|
339
|
-
export async function countManagedObjects(type) {
|
|
340
|
-
let count = 0;
|
|
341
|
-
let result = {
|
|
342
|
-
result: [],
|
|
343
|
-
resultCount: 0,
|
|
344
|
-
pagedResultsCookie: null,
|
|
345
|
-
totalPagedResultsPolicy: 'NONE',
|
|
346
|
-
totalPagedResults: -1,
|
|
347
|
-
remainingPagedResults: -1
|
|
348
|
-
};
|
|
349
|
-
try {
|
|
350
|
-
do {
|
|
351
|
-
result = await queryAllManagedObjectsByType(type, [], result.pagedResultsCookie);
|
|
352
|
-
count += result.resultCount;
|
|
353
|
-
} while (result.pagedResultsCookie);
|
|
354
|
-
printMessage(`${type}: ${count}`);
|
|
355
|
-
} catch (error) {
|
|
356
|
-
printMessage(error.response.data, 'error');
|
|
357
|
-
printMessage(`Error querying managed objects by type: ${error}`, 'error');
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
//# sourceMappingURL=IdmOps.js.map
|
package/esm/ops/IdmOps.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IdmOps.js","names":["frodo","fs","fse","path","propertiesReader","replaceall","createProgressIndicator","printMessage","stopProgressIndicator","getTypedFilename","validateScriptHooks","helper","script","readFiles","unSubstituteEnvParams","utils","testConnectorServers","getAllConfigEntities","getConfigEntity","putConfigEntity","queryAllManagedObjectsByType","idm","config","warnAboutOfflineConnectorServers","all","offline","filter","status","ok","map","name","length","join","error","message","listAllConfigEntities","configurations","configEntity","_id","getAllConfigEntitiesError","exportConfigEntity","id","file","fileName","writeFile","JSON","stringify","err","exportAllRawConfigEntities","directory","existsSync","mkdirSync","undefined","entityPromises","push","catch","getConfigEntityError","_getConfigEntityError","_getConfigEntityError2","_getConfigEntityError3","_getConfigEntityError4","_getConfigEntityError5","_getConfigEntityError6","_getConfigEntityError7","_getConfigEntityError8","_getConfigEntityError9","response","data","includes","reason","_getConfigEntityError10","results","Promise","item","outputFile","exportAllConfigEntities","entitiesFile","envFile","entriesToExport","readFile","entriesData","parse","envParams","configEntityString","each","key","value","importConfigEntityByIdFromFile","entityId","validate","fileData","readFileSync","resolve","process","cwd","entityData","isValid","putConfigEntityError","importConfigEntityFromFile","importAllRawConfigEntities","baseDirectory","files","jsonFiles","toLowerCase","endsWith","content","substring","everyScriptValid","jsObject","isScriptValid","allSettled","errors","result","importAllConfigEntities","entriesToImport","envReader","unsubstituted","countManagedObjects","type","count","resultCount","pagedResultsCookie","totalPagedResultsPolicy","totalPagedResults","remainingPagedResults"],"sources":["../../src/ops/IdmOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport fse from 'fs-extra';\nimport path from 'path';\nimport propertiesReader from 'properties-reader';\nimport replaceall from 'replaceall';\nimport {\n createProgressIndicator,\n printMessage,\n stopProgressIndicator,\n} from '../utils/Console';\nimport { getTypedFilename } from '../utils/ExportImportUtils';\n\nconst { validateScriptHooks } = frodo.helper.script;\nconst { readFiles, unSubstituteEnvParams } = frodo.helper.utils;\nconst {\n testConnectorServers,\n getAllConfigEntities,\n getConfigEntity,\n putConfigEntity,\n queryAllManagedObjectsByType,\n} = frodo.idm.config;\n\n/**\n * Warn about and list offline remote connector servers\n */\nexport async function warnAboutOfflineConnectorServers() {\n try {\n const all = await testConnectorServers();\n const offline = all\n .filter((status) => !status.ok)\n .map((status) => status.name);\n if (offline.length) {\n printMessage(\n `\\nThe following connector server(s) are offline and their connectors and configuration unavailable:\\n${offline.join(\n '\\n'\n )}`,\n 'warn'\n );\n }\n } catch (error) {\n printMessage(error, 'error');\n printMessage(\n `Error getting offline connector servers: ${error.message}`,\n 'error'\n );\n }\n}\n\n/**\n * List all IDM configuration objects\n */\nexport async function listAllConfigEntities() {\n try {\n const { configurations } = await getAllConfigEntities();\n for (const configEntity of configurations) {\n printMessage(`${configEntity._id}`, 'data');\n }\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export an IDM configuration object.\n * @param {String} id the desired configuration object\n * @param {String} file optional export file\n */\nexport async function exportConfigEntity(id, file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`${id}`, 'idm');\n }\n const configEntity = await getConfigEntity(id);\n fs.writeFile(fileName, JSON.stringify(configEntity, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${id} export to file`, 'error');\n }\n return '';\n });\n}\n\n/**\n * Export all IDM configuration objects into separate JSON files in a directory specified by <directory>\n * @param {String} directory export directory\n */\nexport async function exportAllRawConfigEntities(directory) {\n try {\n const { configurations } = await getAllConfigEntities();\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n entityPromises.push(\n getConfigEntity(configEntity._id).catch((getConfigEntityError) => {\n if (\n !(\n getConfigEntityError.response?.status === 403 &&\n getConfigEntityError.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n ) &&\n !(\n // list of config entities, which do not exist by default or ever.\n (\n [\n 'script',\n 'notificationFactory',\n 'apiVersion',\n 'metrics',\n 'repo.init',\n 'endpoint/validateQueryFilter',\n 'endpoint/oauthproxy',\n 'external.rest',\n 'scheduler',\n 'org.apache.felix.fileinstall/openidm',\n 'cluster',\n 'endpoint/mappingDetails',\n 'fieldPolicy/teammember',\n ].includes(configEntity._id) &&\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.reason === 'Not Found'\n )\n ) &&\n // https://bugster.forgerock.org/jira/browse/OPENIDM-18270\n !(\n getConfigEntityError.response?.status === 404 &&\n getConfigEntityError.response?.data?.message ===\n 'No configuration exists for id org.apache.felix.fileinstall/openidm'\n )\n ) {\n printMessage(getConfigEntityError.response?.data, 'error');\n printMessage(\n `Error getting config entity ${configEntity._id}: ${getConfigEntityError}`,\n 'error'\n );\n }\n })\n );\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n fse.outputFile(\n `${directory}/${item._id}.json`,\n JSON.stringify(item, null, 2),\n (err) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${err}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator('Exported config objects.', 'success');\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n}\n\n/**\n * Export all IDM configuration objects\n * @param {String} directory export directory\n * @param {String} entitiesFile JSON file that specifies the config entities to export/import\n * @param {String} envFile File that defines environment specific variables for replacement during configuration export/import\n */\nexport async function exportAllConfigEntities(\n directory,\n entitiesFile,\n envFile\n) {\n let entriesToExport = [];\n // read list of entities to export\n fs.readFile(entitiesFile, 'utf8', async (err, data) => {\n if (err) throw err;\n const entriesData = JSON.parse(data);\n entriesToExport = entriesData.idm;\n // console.log(`entriesToExport ${entriesToExport}`);\n\n // read list of configs to parameterize for environment specific values\n const envParams = propertiesReader(envFile);\n\n try {\n const { configurations } = await getAllConfigEntities();\n // create export directory if not exist\n if (!fs.existsSync(directory)) {\n fs.mkdirSync(directory);\n }\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Exporting config objects...'\n );\n const entityPromises = [];\n for (const configEntity of configurations) {\n if (entriesToExport.includes(configEntity._id)) {\n entityPromises.push(getConfigEntity(configEntity._id));\n }\n }\n const results = await Promise.all(entityPromises);\n for (const item of results) {\n if (item != null) {\n let configEntityString = JSON.stringify(item, null, 2);\n envParams.each((key, value) => {\n configEntityString = replaceall(\n value,\n `\\${${key}}`,\n configEntityString\n );\n });\n fse.outputFile(\n `${directory}/${item._id}.json`,\n configEntityString,\n (error) => {\n if (err) {\n return printMessage(\n `ERROR - can't save config ${item._id} to file - ${error}`,\n 'error'\n );\n }\n }\n );\n }\n }\n stopProgressIndicator(null, 'success');\n } catch (getAllConfigEntitiesError) {\n printMessage(getAllConfigEntitiesError, 'error');\n printMessage(\n `Error getting config entities: ${getAllConfigEntitiesError}`,\n 'error'\n );\n }\n });\n}\n\n/**\n * Import an IDM configuration object by id from file.\n * @param entityId the configuration object to import\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityByIdFromFile(\n entityId: string,\n file?: string,\n validate?: boolean\n) {\n if (!file) {\n file = getTypedFilename(entityId, 'idm');\n }\n\n const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n\n const entityData = JSON.parse(fileData);\n const isValid = validateScriptHooks(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await putConfigEntity(entityId, entityData);\n } catch (putConfigEntityError) {\n printMessage(putConfigEntityError, 'error');\n printMessage(`Error: ${putConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import IDM configuration object from file.\n * @param file optional file to import\n * @param validate validate script hooks\n */\nexport async function importConfigEntityFromFile(\n file: string,\n validate?: boolean\n) {\n const fileData = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');\n const entityData = JSON.parse(fileData);\n const entityId = entityData._id;\n const isValid = validateScriptHooks(entityData);\n if (validate && !isValid) {\n printMessage('Invalid IDM configuration object', 'error');\n return;\n }\n\n try {\n await putConfigEntity(entityId, entityData);\n } catch (putConfigEntityError) {\n printMessage(putConfigEntityError, 'error');\n printMessage(`Error: ${putConfigEntityError}`, 'error');\n }\n}\n\n/**\n * Import all IDM configuration objects from separate JSON files in a directory specified by <directory>\n * @param baseDirectory export directory\n * @param validate validate script hooks\n */\nexport async function importAllRawConfigEntities(\n baseDirectory: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ path, content }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles.map((file) => {\n return putConfigEntity(file.entityId, file.content);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Import all IDM configuration objects\n * @param baseDirectory import directory\n * @param entitiesFile JSON file that specifies the config entities to export/import\n * @param envFile File that defines environment specific variables for replacement during configuration export/import\n * @param validate validate script hooks\n */\nexport async function importAllConfigEntities(\n baseDirectory: string,\n entitiesFile: string,\n envFile: string,\n validate?: boolean\n) {\n if (!fs.existsSync(baseDirectory)) {\n return;\n }\n const entriesToImport = JSON.parse(fs.readFileSync(entitiesFile, 'utf8')).idm;\n\n const envReader = propertiesReader(envFile);\n\n const files = await readFiles(baseDirectory);\n const jsonFiles = files\n .filter(({ path }) => path.toLowerCase().endsWith('.json'))\n .map(({ content, path }) => ({\n // Remove .json extension\n entityId: path.substring(0, path.length - 5),\n content,\n path,\n }));\n\n let everyScriptValid = true;\n for (const file of jsonFiles) {\n const jsObject = JSON.parse(file.content);\n const isScriptValid = validateScriptHooks(jsObject);\n if (!isScriptValid) {\n printMessage(`Invalid script hook in ${file.path}`, 'error');\n everyScriptValid = false;\n }\n }\n\n if (validate && !everyScriptValid) {\n return;\n }\n\n createProgressIndicator(\n 'indeterminate',\n undefined,\n 'Importing config objects...'\n );\n\n const entityPromises = jsonFiles\n .filter(({ entityId }) => {\n return entriesToImport.includes(entityId);\n })\n .map(({ entityId, content }) => {\n const unsubstituted = unSubstituteEnvParams(content, envReader);\n return putConfigEntity(entityId, unsubstituted);\n });\n\n const results = await Promise.allSettled(entityPromises);\n const errors = results.filter(\n (result): result is PromiseRejectedResult => result.status === 'rejected'\n );\n\n if (errors.length > 0) {\n printMessage(`Failed to import ${errors.length} config objects:`, 'error');\n for (const error of errors) {\n printMessage(`- ${error.reason}`, 'error');\n }\n stopProgressIndicator(\n `Failed to import ${errors.length} config objects`,\n 'error'\n );\n return;\n }\n\n stopProgressIndicator(`Imported ${results.length} config objects`, 'success');\n}\n\n/**\n * Count number of managed objects of a given type\n * @param {String} type managed object type, e.g. alpha_user\n */\nexport async function countManagedObjects(type) {\n let count = 0;\n let result = {\n result: [],\n resultCount: 0,\n pagedResultsCookie: null,\n totalPagedResultsPolicy: 'NONE',\n totalPagedResults: -1,\n remainingPagedResults: -1,\n };\n try {\n do {\n result = await queryAllManagedObjectsByType(\n type,\n [],\n result.pagedResultsCookie\n );\n count += result.resultCount;\n } while (result.pagedResultsCookie);\n printMessage(`${type}: ${count}`);\n } catch (error) {\n printMessage(error.response.data, 'error');\n printMessage(`Error querying managed objects by type: ${error}`, 'error');\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,GAAG,MAAM,UAAU;AAC1B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,gBAAgB,MAAM,mBAAmB;AAChD,OAAOC,UAAU,MAAM,YAAY;AACnC,SACEC,uBAAuB,EACvBC,YAAY,EACZC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,gBAAgB,QAAQ,4BAA4B;AAE7D,MAAM;EAAEC;AAAoB,CAAC,GAAGV,KAAK,CAACW,MAAM,CAACC,MAAM;AACnD,MAAM;EAAEC,SAAS;EAAEC;AAAsB,CAAC,GAAGd,KAAK,CAACW,MAAM,CAACI,KAAK;AAC/D,MAAM;EACJC,oBAAoB;EACpBC,oBAAoB;EACpBC,eAAe;EACfC,eAAe;EACfC;AACF,CAAC,GAAGpB,KAAK,CAACqB,GAAG,CAACC,MAAM;;AAEpB;AACA;AACA;AACA,OAAO,eAAeC,gCAAgCA,CAAA,EAAG;EACvD,IAAI;IACF,MAAMC,GAAG,GAAG,MAAMR,oBAAoB,CAAC,CAAC;IACxC,MAAMS,OAAO,GAAGD,GAAG,CAChBE,MAAM,CAAEC,MAAM,IA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,CAAE,2CAA0C0B,KAAM,EAAC,EAAE,OAAO,CAAC;EAC3E;AACF"}
|
package/esm/ops/IdpOps.js
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { frodo } from '@rockcarver/frodo-lib';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import { createProgressBar, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
|
|
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;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Get a one-line description of the social idp object
|
|
16
|
-
* @param {SocialIdpSkeleton} socialIdpObj social idp object to describe
|
|
17
|
-
* @returns {string} a one-line description
|
|
18
|
-
*/
|
|
19
|
-
export function getOneLineDescription(socialIdpObj) {
|
|
20
|
-
const description = `[${socialIdpObj._id['brightCyan']}] ${socialIdpObj._type._id}`;
|
|
21
|
-
return description;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Get markdown table header
|
|
26
|
-
* @returns {string} markdown table header
|
|
27
|
-
*/
|
|
28
|
-
export function getTableHeaderMd() {
|
|
29
|
-
let markdown = '';
|
|
30
|
-
markdown += '| Name/Id | Status | Type |\n';
|
|
31
|
-
markdown += '| ------- | ------ | ---- |';
|
|
32
|
-
return markdown;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Get a table-row of the social idp in markdown
|
|
37
|
-
* @param {SocialIdpSkeleton} socialIdpObj social idp object to describe
|
|
38
|
-
* @returns {string} a table-row of the social idp in markdown
|
|
39
|
-
*/
|
|
40
|
-
export function getTableRowMd(socialIdpObj) {
|
|
41
|
-
const row = `| ${socialIdpObj._id} | ${socialIdpObj.enabled === false ? ':o: `disabled`' : ':white_check_mark: `enabled`'} | ${socialIdpObj._type.name} |`;
|
|
42
|
-
return row;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* List providers
|
|
47
|
-
*/
|
|
48
|
-
export async function listSocialProviders() {
|
|
49
|
-
try {
|
|
50
|
-
const providers = await getSocialIdentityProviders();
|
|
51
|
-
providers.sort((a, b) => a._id.localeCompare(b._id));
|
|
52
|
-
providers.forEach(socialIdentityProvider => {
|
|
53
|
-
printMessage(`${socialIdentityProvider._id}`, 'data');
|
|
54
|
-
});
|
|
55
|
-
} catch (err) {
|
|
56
|
-
printMessage(`listSocialProviders ERROR: ${err.message}`, 'error');
|
|
57
|
-
printMessage(err, 'error');
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Export provider by id
|
|
63
|
-
* @param {string} providerId provider id/name
|
|
64
|
-
* @param {string} file optional export file name
|
|
65
|
-
*/
|
|
66
|
-
export async function exportSocialProviderToFile(providerId, file = '') {
|
|
67
|
-
debugMessage(`cli.IdpOps.exportSocialProviderToFile: start`);
|
|
68
|
-
let fileName = file;
|
|
69
|
-
if (!fileName) {
|
|
70
|
-
fileName = getTypedFilename(providerId, 'idp');
|
|
71
|
-
}
|
|
72
|
-
createProgressBar(1, `Exporting ${providerId}`);
|
|
73
|
-
try {
|
|
74
|
-
updateProgressBar(`Writing file ${fileName}`);
|
|
75
|
-
const fileData = await exportSocialProvider(providerId);
|
|
76
|
-
saveJsonToFile(fileData, fileName);
|
|
77
|
-
stopProgressBar(`Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`);
|
|
78
|
-
} catch (err) {
|
|
79
|
-
stopProgressBar(`${err}`);
|
|
80
|
-
printMessage(`${err}`, 'error');
|
|
81
|
-
}
|
|
82
|
-
debugMessage(`cli.IdpOps.exportSocialProviderToFile: end`);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Export all providers
|
|
87
|
-
* @param {string} file optional export file name
|
|
88
|
-
*/
|
|
89
|
-
export async function exportSocialProvidersToFile(file = '') {
|
|
90
|
-
let fileName = file;
|
|
91
|
-
if (!fileName) {
|
|
92
|
-
fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');
|
|
93
|
-
}
|
|
94
|
-
const fileData = await exportSocialProviders();
|
|
95
|
-
saveJsonToFile(fileData, fileName);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Export all providers to individual files
|
|
100
|
-
*/
|
|
101
|
-
export async function exportSocialProvidersToFiles() {
|
|
102
|
-
debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: start`);
|
|
103
|
-
try {
|
|
104
|
-
const allIdpsData = await getSocialIdentityProviders();
|
|
105
|
-
createProgressBar(allIdpsData.length, 'Exporting providers');
|
|
106
|
-
for (const idpData of allIdpsData) {
|
|
107
|
-
try {
|
|
108
|
-
const fileName = getTypedFilename(idpData._id, 'idp');
|
|
109
|
-
const fileData = await exportSocialProvider(idpData._id);
|
|
110
|
-
saveJsonToFile(fileData, fileName);
|
|
111
|
-
updateProgressBar(`Exported provider ${idpData._id}`);
|
|
112
|
-
} catch (error) {
|
|
113
|
-
printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
stopProgressBar(`${allIdpsData.length} providers exported.`);
|
|
117
|
-
} catch (error) {
|
|
118
|
-
stopProgressBar(`${error}`);
|
|
119
|
-
printMessage(`${error}`, 'error');
|
|
120
|
-
}
|
|
121
|
-
debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: end`);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Import provider by id/name
|
|
126
|
-
* @param {string} providerId provider id/name
|
|
127
|
-
* @param {string} file import file name
|
|
128
|
-
* @returns {Promise<boolean>} true if provider was imported successfully, false otherwise
|
|
129
|
-
*/
|
|
130
|
-
export async function importSocialProviderFromFile(providerId, file) {
|
|
131
|
-
let outcome = false;
|
|
132
|
-
showSpinner(`Importing provider ${providerId} from ${file}...`);
|
|
133
|
-
fs.readFile(file, 'utf8', async (err, data) => {
|
|
134
|
-
if (err) throw err;
|
|
135
|
-
try {
|
|
136
|
-
const fileData = JSON.parse(data);
|
|
137
|
-
outcome = await importSocialProvider(providerId, fileData);
|
|
138
|
-
succeedSpinner(`Successfully imported provider ${providerId} from ${file}.`);
|
|
139
|
-
} catch (error) {
|
|
140
|
-
var _error$response;
|
|
141
|
-
failSpinner(`Error importing provider ${providerId} from ${file}.`);
|
|
142
|
-
printMessage(((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || error, 'error');
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
return outcome;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Import first provider from file
|
|
150
|
-
* @param {String} file import file name
|
|
151
|
-
* @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise
|
|
152
|
-
*/
|
|
153
|
-
export async function importFirstSocialProviderFromFile(file) {
|
|
154
|
-
let outcome = false;
|
|
155
|
-
showSpinner(`Importing first provider from ${file}...`);
|
|
156
|
-
fs.readFile(file, 'utf8', async (err, data) => {
|
|
157
|
-
if (err) throw err;
|
|
158
|
-
try {
|
|
159
|
-
const fileData = JSON.parse(data);
|
|
160
|
-
outcome = await importFirstSocialProvider(fileData);
|
|
161
|
-
succeedSpinner(`Successfully imported first provider from ${file}.`);
|
|
162
|
-
} catch (error) {
|
|
163
|
-
var _error$response2;
|
|
164
|
-
failSpinner(`Error importing first provider from ${file}.`);
|
|
165
|
-
printMessage(((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) || error, 'error');
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
return outcome;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Import all providers from file
|
|
173
|
-
* @param {string} file import file name
|
|
174
|
-
* @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise
|
|
175
|
-
*/
|
|
176
|
-
export async function importSocialProvidersFromFile(file) {
|
|
177
|
-
let outcome = false;
|
|
178
|
-
showSpinner(`Importing providers from ${file}...`);
|
|
179
|
-
fs.readFile(file, 'utf8', async (err, data) => {
|
|
180
|
-
if (err) throw err;
|
|
181
|
-
try {
|
|
182
|
-
const fileData = JSON.parse(data);
|
|
183
|
-
outcome = await importSocialProviders(fileData);
|
|
184
|
-
succeedSpinner(`Successfully imported providers from ${file}.`);
|
|
185
|
-
} catch (error) {
|
|
186
|
-
var _error$response3;
|
|
187
|
-
failSpinner(`Error importing providers from ${file}.`);
|
|
188
|
-
printMessage(((_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || error, 'error');
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
return outcome;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Import providers from *.idp.json files in current working directory
|
|
196
|
-
*/
|
|
197
|
-
export async function importSocialProvidersFromFiles() {
|
|
198
|
-
const names = fs.readdirSync('.');
|
|
199
|
-
const jsonFiles = names.filter(name => name.toLowerCase().endsWith('.idp.json'));
|
|
200
|
-
createProgressBar(jsonFiles.length, 'Importing providers...');
|
|
201
|
-
let total = 0;
|
|
202
|
-
for (const file of jsonFiles) {
|
|
203
|
-
const data = fs.readFileSync(file, 'utf8');
|
|
204
|
-
const fileData = JSON.parse(data);
|
|
205
|
-
const count = Object.keys(fileData.idp).length;
|
|
206
|
-
total += count;
|
|
207
|
-
await importSocialProviders(fileData);
|
|
208
|
-
updateProgressBar(`Imported ${count} provider(s) from ${file}`);
|
|
209
|
-
}
|
|
210
|
-
stopProgressBar(`Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`);
|
|
211
|
-
}
|
|
212
|
-
//# sourceMappingURL=IdpOps.js.map
|