@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/ScriptOps.js
DELETED
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
2
|
-
import chokidar from 'chokidar';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import { createProgressBar, createTable, debugMessage, failSpinner, printMessage, showSpinner, spinSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
|
|
5
|
-
import { getTypedFilename, saveJsonToFile, saveTextToFile, titleCase } from '../utils/ExportImportUtils';
|
|
6
|
-
import wordwrap from './utils/Wordwrap';
|
|
7
|
-
const {
|
|
8
|
-
getScripts,
|
|
9
|
-
exportScript,
|
|
10
|
-
exportScriptByName,
|
|
11
|
-
exportScripts,
|
|
12
|
-
importScripts
|
|
13
|
-
} = frodo.script;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Get a one-line description of the script object
|
|
17
|
-
* @param {ScriptSkeleton} scriptObj script object to describe
|
|
18
|
-
* @returns {string} a one-line description
|
|
19
|
-
*/
|
|
20
|
-
export function getOneLineDescription(scriptObj) {
|
|
21
|
-
const description = `[${scriptObj._id['brightCyan']}] ${scriptObj.context} - ${scriptObj.name}`;
|
|
22
|
-
return description;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get markdown table header
|
|
27
|
-
* @returns {string} markdown table header
|
|
28
|
-
*/
|
|
29
|
-
export function getTableHeaderMd() {
|
|
30
|
-
let markdown = '';
|
|
31
|
-
markdown += '| Name | Language | Type | Id |\n';
|
|
32
|
-
markdown += '| ---- | -------- | ---- | ---|';
|
|
33
|
-
return markdown;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Get a one-line description of the script object in markdown
|
|
38
|
-
* @param {TypesRaw.ScriptSkeleton} scriptObj script object to describe
|
|
39
|
-
* @returns {string} markdown table row
|
|
40
|
-
*/
|
|
41
|
-
export function getTableRowMd(scriptObj) {
|
|
42
|
-
const langMap = {
|
|
43
|
-
JAVASCRIPT: 'JavaSscript',
|
|
44
|
-
GROOVY: 'Groovy'
|
|
45
|
-
};
|
|
46
|
-
const description = `| ${scriptObj.name} | ${langMap[scriptObj.language]} | ${titleCase(scriptObj.context.split('_').join(' '))} | \`${scriptObj._id}\` |`;
|
|
47
|
-
return description;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* List scripts
|
|
52
|
-
* @param {boolean} long detail list
|
|
53
|
-
* @returns {Promise<boolean>} true if no errors occurred during export, false otherwise
|
|
54
|
-
*/
|
|
55
|
-
export async function listScripts(long = false) {
|
|
56
|
-
let outcome = true;
|
|
57
|
-
debugMessage(`Cli.ScriptOps.listScripts: start`);
|
|
58
|
-
try {
|
|
59
|
-
const scripts = await getScripts();
|
|
60
|
-
scripts.sort((a, b) => a.name.localeCompare(b.name));
|
|
61
|
-
if (long) {
|
|
62
|
-
const table = createTable(['Name', 'UUID', 'Language', 'Context', 'Description']);
|
|
63
|
-
const langMap = {
|
|
64
|
-
JAVASCRIPT: 'JS',
|
|
65
|
-
GROOVY: 'Groovy'
|
|
66
|
-
};
|
|
67
|
-
scripts.forEach(script => {
|
|
68
|
-
table.push([wordwrap(script.name, 25, ' '), script._id, langMap[script.language], wordwrap(titleCase(script.context.split('_').join(' ')), 25), wordwrap(script.description, 30)]);
|
|
69
|
-
});
|
|
70
|
-
printMessage(table.toString(), 'data');
|
|
71
|
-
} else {
|
|
72
|
-
scripts.forEach(script => {
|
|
73
|
-
printMessage(`${script.name}`, 'data');
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
} catch (error) {
|
|
77
|
-
outcome = false;
|
|
78
|
-
printMessage(`Error listing scripts: ${error.message}`, 'error');
|
|
79
|
-
debugMessage(error);
|
|
80
|
-
}
|
|
81
|
-
debugMessage(`Cli.ScriptOps.listScripts: end [${outcome}]`);
|
|
82
|
-
return outcome;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Export script by id to file
|
|
87
|
-
* @param {string} scriptId script uuid
|
|
88
|
-
* @param {string} file file name
|
|
89
|
-
* @returns {Promise<boolean>} true if no errors occurred during export, false otherwise
|
|
90
|
-
*/
|
|
91
|
-
export async function exportScriptToFile(scriptId, file) {
|
|
92
|
-
debugMessage(`Cli.ScriptOps.exportScriptToFile: start`);
|
|
93
|
-
try {
|
|
94
|
-
showSpinner(`Exporting script '${scriptId}'...`);
|
|
95
|
-
let fileName = getTypedFilename(scriptId, 'script');
|
|
96
|
-
if (file) {
|
|
97
|
-
fileName = file;
|
|
98
|
-
}
|
|
99
|
-
spinSpinner(`Exporting script '${scriptId}' to '${fileName}'...`);
|
|
100
|
-
const scriptExport = await exportScript(scriptId);
|
|
101
|
-
saveJsonToFile(scriptExport, fileName);
|
|
102
|
-
succeedSpinner(`Exported script '${scriptId}' to '${fileName}'.`);
|
|
103
|
-
debugMessage(`Cli.ScriptOps.exportScriptToFile: end [true]`);
|
|
104
|
-
return true;
|
|
105
|
-
} catch (error) {
|
|
106
|
-
failSpinner(`Error exporting script '${scriptId}': ${error.message}`);
|
|
107
|
-
debugMessage(error);
|
|
108
|
-
}
|
|
109
|
-
debugMessage(`Cli.ScriptOps.exportScriptToFile: end [false]`);
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Export script by name to file
|
|
115
|
-
* @param {string} name script name
|
|
116
|
-
* @param {string} file file name
|
|
117
|
-
* @returns {Promise<boolean>} true if no errors occurred during export, false otherwise
|
|
118
|
-
*/
|
|
119
|
-
export async function exportScriptByNameToFile(name, file) {
|
|
120
|
-
debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: start`);
|
|
121
|
-
try {
|
|
122
|
-
showSpinner(`Exporting script '${name}'...`);
|
|
123
|
-
let fileName = getTypedFilename(name, 'script');
|
|
124
|
-
if (file) {
|
|
125
|
-
fileName = file;
|
|
126
|
-
}
|
|
127
|
-
spinSpinner(`Exporting script '${name}' to '${fileName}'...`);
|
|
128
|
-
const scriptExport = await exportScriptByName(name);
|
|
129
|
-
saveJsonToFile(scriptExport, fileName);
|
|
130
|
-
succeedSpinner(`Exported script '${name}' to '${fileName}'.`);
|
|
131
|
-
debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: end [true]`);
|
|
132
|
-
return true;
|
|
133
|
-
} catch (error) {
|
|
134
|
-
failSpinner(`Error exporting script '${name}': ${error.message}`);
|
|
135
|
-
debugMessage(error);
|
|
136
|
-
}
|
|
137
|
-
debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: end [false]`);
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Export all scripts to single file
|
|
143
|
-
* @param {string} file file name
|
|
144
|
-
* @returns {Promise<boolean>} true if no errors occurred during export, false otherwise
|
|
145
|
-
*/
|
|
146
|
-
export async function exportScriptsToFile(file) {
|
|
147
|
-
debugMessage(`Cli.ScriptOps.exportScriptsToFile: start`);
|
|
148
|
-
try {
|
|
149
|
-
let fileName = getTypedFilename(`all${titleCase(state.getRealm())}Scripts`, 'script');
|
|
150
|
-
if (file) {
|
|
151
|
-
fileName = file;
|
|
152
|
-
}
|
|
153
|
-
const scriptExport = await exportScripts();
|
|
154
|
-
saveJsonToFile(scriptExport, fileName);
|
|
155
|
-
debugMessage(`Cli.ScriptOps.exportScriptsToFile: end [true]`);
|
|
156
|
-
return true;
|
|
157
|
-
} catch (error) {
|
|
158
|
-
printMessage(`Error exporting scripts: ${error.message}`, 'error');
|
|
159
|
-
debugMessage(error);
|
|
160
|
-
}
|
|
161
|
-
debugMessage(`Cli.ScriptOps.exportScriptsToFile: end [false]`);
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Export all scripts to individual files
|
|
167
|
-
* @returns {Promise<boolean>} true if no errors occurred during export, false otherwise
|
|
168
|
-
*/
|
|
169
|
-
export async function exportScriptsToFiles() {
|
|
170
|
-
let outcome = true;
|
|
171
|
-
debugMessage(`Cli.ScriptOps.exportScriptsToFiles: start`);
|
|
172
|
-
const scriptList = await getScripts();
|
|
173
|
-
createProgressBar(scriptList.length, 'Exporting scripts to individual files...');
|
|
174
|
-
for (const script of scriptList) {
|
|
175
|
-
try {
|
|
176
|
-
updateProgressBar(`Reading script ${script.name}`);
|
|
177
|
-
const fileName = getTypedFilename(script.name, 'script');
|
|
178
|
-
const scriptExport = await exportScriptByName(script.name);
|
|
179
|
-
saveJsonToFile(scriptExport, fileName);
|
|
180
|
-
} catch (error) {
|
|
181
|
-
outcome = false;
|
|
182
|
-
printMessage(`Error exporting script '${script.name}': ${error.message}`, 'error');
|
|
183
|
-
debugMessage(error);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
stopProgressBar(`Exported ${scriptList.length} scripts to individual files.`);
|
|
187
|
-
debugMessage(`Cli.ScriptOps.exportScriptsToFiles: end [${outcome}]`);
|
|
188
|
-
return outcome;
|
|
189
|
-
}
|
|
190
|
-
export async function exportScriptsToFilesExtract() {
|
|
191
|
-
let outcome = true;
|
|
192
|
-
debugMessage(`Cli.ScriptOps.exportScriptsToFilesExtract: start`);
|
|
193
|
-
const scriptList = await getScripts();
|
|
194
|
-
createProgressBar(scriptList.length, 'Exporting scripts to individual files...');
|
|
195
|
-
for (const script of scriptList) {
|
|
196
|
-
try {
|
|
197
|
-
updateProgressBar(`Reading script ${script.name}`);
|
|
198
|
-
const fileExtension = script.language === 'JAVASCRIPT' ? 'js' : 'groovy';
|
|
199
|
-
const scriptFileName = getTypedFilename(script.name, 'script', fileExtension);
|
|
200
|
-
const fileName = getTypedFilename(script.name, 'script');
|
|
201
|
-
const scriptExport = await exportScriptByName(script.name);
|
|
202
|
-
const scriptSkeleton = getScriptSkeleton(scriptExport);
|
|
203
|
-
const scriptText = Array.isArray(scriptSkeleton.script) ? scriptSkeleton.script.join('\n') : scriptSkeleton.script;
|
|
204
|
-
scriptSkeleton.script = `file://${scriptFileName}`;
|
|
205
|
-
saveTextToFile(scriptText, scriptFileName);
|
|
206
|
-
saveJsonToFile(scriptExport, fileName);
|
|
207
|
-
} catch (error) {
|
|
208
|
-
outcome = false;
|
|
209
|
-
printMessage(`Error exporting script '${script.name}': ${error.message}`, 'error');
|
|
210
|
-
debugMessage(error);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
stopProgressBar(`Exported ${scriptList.length} scripts to individual files.`);
|
|
214
|
-
debugMessage(`Cli.ScriptOps.exportScriptsToFilesExtract: end [${outcome}]`);
|
|
215
|
-
return outcome;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Import script(s) from file
|
|
220
|
-
* @param {string} name Optional name of script. If supplied, only the script of that name is imported
|
|
221
|
-
* @param {string} file file name
|
|
222
|
-
* @param {boolean} reUuid true to generate a new uuid for each script on import, false otherwise
|
|
223
|
-
* @returns {Promise<boolean>} true if no errors occurred during import, false otherwise
|
|
224
|
-
*/
|
|
225
|
-
export async function importScriptsFromFile(name, file, reUuid = false) {
|
|
226
|
-
let outcome = false;
|
|
227
|
-
debugMessage(`Cli.ScriptOps.importScriptsFromFile: start`);
|
|
228
|
-
fs.readFile(file, 'utf8', async (err, data) => {
|
|
229
|
-
try {
|
|
230
|
-
if (err) throw err;
|
|
231
|
-
const importData = JSON.parse(data);
|
|
232
|
-
outcome = await importScripts(name, importData, reUuid);
|
|
233
|
-
} catch (error) {
|
|
234
|
-
printMessage(`Error exporting script '${name}': ${error.message}`, 'error');
|
|
235
|
-
debugMessage(error);
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
debugMessage(`Cli.ScriptOps.importScriptsFromFile: end [${outcome}]`);
|
|
239
|
-
return outcome;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Import extracted scripts.
|
|
244
|
-
*
|
|
245
|
-
* @param watch whether or not to watch for file changes
|
|
246
|
-
*/
|
|
247
|
-
export async function importScriptsFromFiles(watch, reUuid, validateScripts) {
|
|
248
|
-
// If watch is true, it doesn't make sense to reUuid.
|
|
249
|
-
reUuid = watch ? false : reUuid;
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Run on file change detection, as well as on initial run.
|
|
253
|
-
*/
|
|
254
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
255
|
-
function onChange(path, _stats) {
|
|
256
|
-
handleScriptFileImport(path, reUuid, validateScripts).catch(error => {
|
|
257
|
-
printMessage(`Error importing script: ${error.message}`, 'error');
|
|
258
|
-
debugMessage(error);
|
|
259
|
-
process.exit(1);
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// We watch json files and script files.
|
|
264
|
-
const watcher = chokidar.watch([`./**/*.script.json`, `./**/*.script.js`, `./**/*.script.groovy`], {
|
|
265
|
-
persistent: watch
|
|
266
|
-
});
|
|
267
|
-
watcher.on('add', onChange).on('change', onChange).on('error', error => {
|
|
268
|
-
printMessage(`Watcher error: ${error}`, 'error');
|
|
269
|
-
watcher.close();
|
|
270
|
-
}).on('ready', () => {
|
|
271
|
-
if (watch) {
|
|
272
|
-
printMessage('Watching for changes...');
|
|
273
|
-
} else {
|
|
274
|
-
watcher.close();
|
|
275
|
-
printMessage('Done.');
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Handle a script file import.
|
|
282
|
-
*
|
|
283
|
-
* @param file Either a script file or an extract file
|
|
284
|
-
* @param reUuid whether or not to generate a new uuid for each script on import
|
|
285
|
-
*/
|
|
286
|
-
async function handleScriptFileImport(file, reUuid, validateScripts) {
|
|
287
|
-
debugMessage(`Cli.ScriptOps.handleScriptFileImport: start`);
|
|
288
|
-
const scriptFile = getScriptFile(file);
|
|
289
|
-
const script = getScriptExportByScriptFile(scriptFile);
|
|
290
|
-
const success = await importScripts('', script, reUuid, validateScripts);
|
|
291
|
-
if (success) {
|
|
292
|
-
printMessage(`Imported '${scriptFile}'`);
|
|
293
|
-
}
|
|
294
|
-
debugMessage(`Cli.ScriptOps.handleScriptFileImport: end`);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Get a script file from a file.
|
|
299
|
-
*
|
|
300
|
-
* @param file Either a script file or an extract file
|
|
301
|
-
* @returns The script file
|
|
302
|
-
*/
|
|
303
|
-
function getScriptFile(file) {
|
|
304
|
-
if (file.endsWith('.script.json')) {
|
|
305
|
-
return file;
|
|
306
|
-
}
|
|
307
|
-
return file.replace(/\.script\.(js|groovy)/, '.script.json');
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Get a script export from a script file.
|
|
312
|
-
*
|
|
313
|
-
* @param scriptFile The path to the script file
|
|
314
|
-
* @returns The script export
|
|
315
|
-
*/
|
|
316
|
-
function getScriptExportByScriptFile(scriptFile) {
|
|
317
|
-
const scriptExport = getScriptExport(scriptFile);
|
|
318
|
-
const scriptSkeleton = getScriptSkeleton(scriptExport);
|
|
319
|
-
const extractFile = getExtractFile(scriptSkeleton);
|
|
320
|
-
if (!extractFile) {
|
|
321
|
-
return scriptExport;
|
|
322
|
-
}
|
|
323
|
-
const scriptRaw = fs.readFileSync(extractFile, 'utf8');
|
|
324
|
-
scriptSkeleton.script = scriptRaw.split('\n');
|
|
325
|
-
return scriptExport;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Get an extract file from a script skeleton.
|
|
330
|
-
*
|
|
331
|
-
* @param scriptSkeleton The script skeleton
|
|
332
|
-
* @returns The extract file or null if there is no extract file
|
|
333
|
-
*/
|
|
334
|
-
function getExtractFile(scriptSkeleton) {
|
|
335
|
-
const extractFile = scriptSkeleton.script;
|
|
336
|
-
if (Array.isArray(extractFile)) {
|
|
337
|
-
return null;
|
|
338
|
-
}
|
|
339
|
-
if (extractFile.startsWith('file://') && (extractFile.endsWith('.js') || extractFile.endsWith('.groovy'))) {
|
|
340
|
-
return extractFile.replace('file://', '');
|
|
341
|
-
}
|
|
342
|
-
return null;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Get a script export from a file.
|
|
347
|
-
*
|
|
348
|
-
* @param file The path to a script export file
|
|
349
|
-
* @returns The script export
|
|
350
|
-
*/
|
|
351
|
-
function getScriptExport(file) {
|
|
352
|
-
const scriptExportRaw = fs.readFileSync(file, 'utf8');
|
|
353
|
-
const scriptExport = JSON.parse(scriptExportRaw);
|
|
354
|
-
return scriptExport;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Get the main script skeleton from a script export. If there is more than one
|
|
359
|
-
* script, an error is thrown.
|
|
360
|
-
*
|
|
361
|
-
* @param script Get the main script skeleton from a script export
|
|
362
|
-
* @returns The main script skeleton
|
|
363
|
-
*/
|
|
364
|
-
function getScriptSkeleton(script) {
|
|
365
|
-
const scriptId = getScriptId(script);
|
|
366
|
-
return script.script[scriptId];
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Get the main script ID from a script export. If there is more than one
|
|
371
|
-
* script, an error is thrown.
|
|
372
|
-
*
|
|
373
|
-
* @param script The script export
|
|
374
|
-
* @returns The main script ID
|
|
375
|
-
*/
|
|
376
|
-
function getScriptId(script) {
|
|
377
|
-
const scriptIds = Object.keys(script.script);
|
|
378
|
-
if (scriptIds.length !== 1) {
|
|
379
|
-
throw new Error(`Expected 1 script, found ${scriptIds.length}`);
|
|
380
|
-
}
|
|
381
|
-
return scriptIds[0];
|
|
382
|
-
}
|
|
383
|
-
//# sourceMappingURL=ScriptOps.js.map
|
package/esm/ops/ScriptOps.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptOps.js","names":["frodo","state","chokidar","fs","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","spinSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","saveTextToFile","titleCase","wordwrap","getScripts","exportScript","exportScriptByName","exportScripts","importScripts","script","getOneLineDescription","scriptObj","description","_id","context","name","getTableHeaderMd","markdown","getTableRowMd","langMap","JAVASCRIPT","GROOVY","language","split","join","listScripts","long","outcome","scripts","sort","a","b","localeCompare","table","forEach","push","toString","error","message","exportScriptToFile","scriptId","file","fileName","scriptExport","exportScriptByNameToFile","exportScriptsToFile","getRealm","exportScriptsToFiles","scriptList","length","exportScriptsToFilesExtract","fileExtension","scriptFileName","scriptSkeleton","getScriptSkeleton","scriptText","Array","isArray","importScriptsFromFile","reUuid","readFile","err","data","importData","JSON","parse","importScriptsFromFiles","watch","validateScripts","onChange","path","_stats","handleScriptFileImport","catch","process","exit","watcher","persistent","on","close","scriptFile","getScriptFile","getScriptExportByScriptFile","success","endsWith","replace","getScriptExport","extractFile","getExtractFile","scriptRaw","readFileSync","startsWith","scriptExportRaw","getScriptId","scriptIds","Object","keys","Error"],"sources":["../../src/ops/ScriptOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport chokidar from 'chokidar';\nimport fs from 'fs';\nimport {\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n spinSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getTypedFilename,\n saveJsonToFile,\n saveTextToFile,\n titleCase,\n} from '../utils/ExportImportUtils';\nimport wordwrap from './utils/Wordwrap';\nimport type { ScriptSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport type { ScriptExportInterface } from '@rockcarver/frodo-lib/types/ops/OpsTypes';\n\nconst {\n getScripts,\n exportScript,\n exportScriptByName,\n exportScripts,\n importScripts,\n} = frodo.script;\n\n/**\n * Get a one-line description of the script object\n * @param {ScriptSkeleton} scriptObj script object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(scriptObj: ScriptSkeleton): string {\n const description = `[${scriptObj._id['brightCyan']}] ${scriptObj.context} - ${scriptObj.name}`;\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 | Language | Type | Id |\\n';\n markdown += '| ---- | -------- | ---- | ---|';\n return markdown;\n}\n\n/**\n * Get a one-line description of the script object in markdown\n * @param {TypesRaw.ScriptSkeleton} scriptObj script object to describe\n * @returns {string} markdown table row\n */\nexport function getTableRowMd(scriptObj: ScriptSkeleton): string {\n const langMap = { JAVASCRIPT: 'JavaSscript', GROOVY: 'Groovy' };\n const description = `| ${scriptObj.name} | ${\n langMap[scriptObj.language]\n } | ${titleCase(scriptObj.context.split('_').join(' '))} | \\`${\n scriptObj._id\n }\\` |`;\n return description;\n}\n\n/**\n * List scripts\n * @param {boolean} long detail list\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function listScripts(long = false): Promise<boolean> {\n let outcome = true;\n debugMessage(`Cli.ScriptOps.listScripts: start`);\n try {\n const scripts = await getScripts();\n scripts.sort((a, b) => a.name.localeCompare(b.name));\n if (long) {\n const table = createTable([\n 'Name',\n 'UUID',\n 'Language',\n 'Context',\n 'Description',\n ]);\n const langMap = { JAVASCRIPT: 'JS', GROOVY: 'Groovy' };\n scripts.forEach((script) => {\n table.push([\n wordwrap(script.name, 25, ' '),\n script._id,\n langMap[script.language],\n wordwrap(titleCase(script.context.split('_').join(' ')), 25),\n wordwrap(script.description, 30),\n ]);\n });\n printMessage(table.toString(), 'data');\n } else {\n scripts.forEach((script) => {\n printMessage(`${script.name}`, 'data');\n });\n }\n } catch (error) {\n outcome = false;\n printMessage(`Error listing scripts: ${error.message}`, 'error');\n debugMessage(error);\n }\n debugMessage(`Cli.ScriptOps.listScripts: end [${outcome}]`);\n return outcome;\n}\n\n/**\n * Export script by id to file\n * @param {string} scriptId script uuid\n * @param {string} file file name\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptToFile(\n scriptId: string,\n file: string\n): Promise<boolean> {\n debugMessage(`Cli.ScriptOps.exportScriptToFile: start`);\n try {\n showSpinner(`Exporting script '${scriptId}'...`);\n let fileName = getTypedFilename(scriptId, 'script');\n if (file) {\n fileName = file;\n }\n spinSpinner(`Exporting script '${scriptId}' to '${fileName}'...`);\n const scriptExport = await exportScript(scriptId);\n saveJsonToFile(scriptExport, fileName);\n succeedSpinner(`Exported script '${scriptId}' to '${fileName}'.`);\n debugMessage(`Cli.ScriptOps.exportScriptToFile: end [true]`);\n return true;\n } catch (error) {\n failSpinner(`Error exporting script '${scriptId}': ${error.message}`);\n debugMessage(error);\n }\n debugMessage(`Cli.ScriptOps.exportScriptToFile: end [false]`);\n return false;\n}\n\n/**\n * Export script by name to file\n * @param {string} name script name\n * @param {string} file file name\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptByNameToFile(\n name: string,\n file: string\n): Promise<boolean> {\n debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: start`);\n try {\n showSpinner(`Exporting script '${name}'...`);\n let fileName = getTypedFilename(name, 'script');\n if (file) {\n fileName = file;\n }\n spinSpinner(`Exporting script '${name}' to '${fileName}'...`);\n const scriptExport = await exportScriptByName(name);\n saveJsonToFile(scriptExport, fileName);\n succeedSpinner(`Exported script '${name}' to '${fileName}'.`);\n debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: end [true]`);\n return true;\n } catch (error) {\n failSpinner(`Error exporting script '${name}': ${error.message}`);\n debugMessage(error);\n }\n debugMessage(`Cli.ScriptOps.exportScriptByNameToFile: end [false]`);\n return false;\n}\n\n/**\n * Export all scripts to single file\n * @param {string} file file name\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptsToFile(file: string): Promise<boolean> {\n debugMessage(`Cli.ScriptOps.exportScriptsToFile: start`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(state.getRealm())}Scripts`,\n 'script'\n );\n if (file) {\n fileName = file;\n }\n const scriptExport = await exportScripts();\n saveJsonToFile(scriptExport, fileName);\n debugMessage(`Cli.ScriptOps.exportScriptsToFile: end [true]`);\n return true;\n } catch (error) {\n printMessage(`Error exporting scripts: ${error.message}`, 'error');\n debugMessage(error);\n }\n debugMessage(`Cli.ScriptOps.exportScriptsToFile: end [false]`);\n return false;\n}\n\n/**\n * Export all scripts to individual files\n * @returns {Promise<boolean>} true if no errors occurred during export, false otherwise\n */\nexport async function exportScriptsToFiles(): Promise<boolean> {\n let outcome = true;\n debugMessage(`Cli.ScriptOps.exportScriptsToFiles: start`);\n const scriptList = await getScripts();\n createProgressBar(\n scriptList.length,\n 'Exporting scripts to individual files...'\n );\n for (const script of scriptList) {\n try {\n updateProgressBar(`Reading script ${script.name}`);\n const fileName = getTypedFilename(script.name, 'script');\n const scriptExport = await exportScriptByName(script.name);\n saveJsonToFile(scriptExport, fileName);\n } catch (error) {\n outcome = false;\n printMessage(\n `Error exporting script '${script.name}': ${error.message}`,\n 'error'\n );\n debugMessage(error);\n }\n }\n stopProgressBar(`Exported ${scriptList.length} scripts to individual files.`);\n debugMessage(`Cli.ScriptOps.exportScriptsToFiles: end [${outcome}]`);\n return outcome;\n}\n\nexport async function exportScriptsToFilesExtract(): Promise<boolean> {\n let outcome = true;\n debugMessage(`Cli.ScriptOps.exportScriptsToFilesExtract: start`);\n const scriptList = await getScripts();\n createProgressBar(\n scriptList.length,\n 'Exporting scripts to individual files...'\n );\n for (const script of scriptList) {\n try {\n updateProgressBar(`Reading script ${script.name}`);\n const fileExtension = script.language === 'JAVASCRIPT' ? 'js' : 'groovy';\n const scriptFileName = getTypedFilename(\n script.name,\n 'script',\n fileExtension\n );\n const fileName = getTypedFilename(script.name, 'script');\n\n const scriptExport = await exportScriptByName(script.name);\n\n const scriptSkeleton = getScriptSkeleton(scriptExport);\n\n const scriptText = Array.isArray(scriptSkeleton.script)\n ? scriptSkeleton.script.join('\\n')\n : scriptSkeleton.script;\n\n scriptSkeleton.script = `file://${scriptFileName}`;\n\n saveTextToFile(scriptText, scriptFileName);\n saveJsonToFile(scriptExport, fileName);\n } catch (error) {\n outcome = false;\n printMessage(\n `Error exporting script '${script.name}': ${error.message}`,\n 'error'\n );\n debugMessage(error);\n }\n }\n stopProgressBar(`Exported ${scriptList.length} scripts to individual files.`);\n debugMessage(`Cli.ScriptOps.exportScriptsToFilesExtract: end [${outcome}]`);\n return outcome;\n}\n\n/**\n * Import script(s) from file\n * @param {string} name Optional name of script. If supplied, only the script of that name is imported\n * @param {string} file file name\n * @param {boolean} reUuid true to generate a new uuid for each script on import, false otherwise\n * @returns {Promise<boolean>} true if no errors occurred during import, false otherwise\n */\nexport async function importScriptsFromFile(\n name: string,\n file: string,\n reUuid = false\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`Cli.ScriptOps.importScriptsFromFile: start`);\n fs.readFile(file, 'utf8', async (err, data) => {\n try {\n if (err) throw err;\n const importData = JSON.parse(data);\n outcome = await importScripts(name, importData, reUuid);\n } catch (error) {\n printMessage(\n `Error exporting script '${name}': ${error.message}`,\n 'error'\n );\n debugMessage(error);\n }\n });\n debugMessage(`Cli.ScriptOps.importScriptsFromFile: end [${outcome}]`);\n return outcome;\n}\n\n/**\n * Import extracted scripts.\n *\n * @param watch whether or not to watch for file changes\n */\nexport async function importScriptsFromFiles(\n watch: boolean,\n reUuid: boolean,\n validateScripts: boolean\n) {\n // If watch is true, it doesn't make sense to reUuid.\n reUuid = watch ? false : reUuid;\n\n /**\n * Run on file change detection, as well as on initial run.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n function onChange(path: string, _stats?: fs.Stats): void {\n handleScriptFileImport(path, reUuid, validateScripts).catch((error) => {\n printMessage(`Error importing script: ${error.message}`, 'error');\n debugMessage(error);\n process.exit(1);\n });\n }\n\n // We watch json files and script files.\n const watcher = chokidar.watch(\n [`./**/*.script.json`, `./**/*.script.js`, `./**/*.script.groovy`],\n {\n persistent: watch,\n }\n );\n\n watcher\n .on('add', onChange)\n .on('change', onChange)\n .on('error', (error) => {\n printMessage(`Watcher error: ${error}`, 'error');\n watcher.close();\n })\n .on('ready', () => {\n if (watch) {\n printMessage('Watching for changes...');\n } else {\n watcher.close();\n printMessage('Done.');\n }\n });\n}\n\n/**\n * Handle a script file import.\n *\n * @param file Either a script file or an extract file\n * @param reUuid whether or not to generate a new uuid for each script on import\n */\nasync function handleScriptFileImport(\n file: string,\n reUuid: boolean,\n validateScripts: boolean\n) {\n debugMessage(`Cli.ScriptOps.handleScriptFileImport: start`);\n const scriptFile = getScriptFile(file);\n const script = getScriptExportByScriptFile(scriptFile);\n\n const success = await importScripts('', script, reUuid, validateScripts);\n if (success) {\n printMessage(`Imported '${scriptFile}'`);\n }\n debugMessage(`Cli.ScriptOps.handleScriptFileImport: end`);\n}\n\n/**\n * Get a script file from a file.\n *\n * @param file Either a script file or an extract file\n * @returns The script file\n */\nfunction getScriptFile(file: string) {\n if (file.endsWith('.script.json')) {\n return file;\n }\n return file.replace(/\\.script\\.(js|groovy)/, '.script.json');\n}\n\n/**\n * Get a script export from a script file.\n *\n * @param scriptFile The path to the script file\n * @returns The script export\n */\nfunction getScriptExportByScriptFile(\n scriptFile: string\n): ScriptExportInterface {\n const scriptExport = getScriptExport(scriptFile);\n const scriptSkeleton = getScriptSkeleton(scriptExport);\n\n const extractFile = getExtractFile(scriptSkeleton);\n if (!extractFile) {\n return scriptExport;\n }\n\n const scriptRaw = fs.readFileSync(extractFile, 'utf8');\n scriptSkeleton.script = scriptRaw.split('\\n');\n\n return scriptExport;\n}\n\n/**\n * Get an extract file from a script skeleton.\n *\n * @param scriptSkeleton The script skeleton\n * @returns The extract file or null if there is no extract file\n */\nfunction getExtractFile(scriptSkeleton: ScriptSkeleton): string | null {\n const extractFile = scriptSkeleton.script;\n if (Array.isArray(extractFile)) {\n return null;\n }\n if (\n extractFile.startsWith('file://') &&\n (extractFile.endsWith('.js') || extractFile.endsWith('.groovy'))\n ) {\n return extractFile.replace('file://', '');\n }\n return null;\n}\n\n/**\n * Get a script export from a file.\n *\n * @param file The path to a script export file\n * @returns The script export\n */\nfunction getScriptExport(file: string): ScriptExportInterface {\n const scriptExportRaw = fs.readFileSync(file, 'utf8');\n const scriptExport = JSON.parse(scriptExportRaw) as ScriptExportInterface;\n\n return scriptExport;\n}\n\n/**\n * Get the main script skeleton from a script export. If there is more than one\n * script, an error is thrown.\n *\n * @param script Get the main script skeleton from a script export\n * @returns The main script skeleton\n */\nfunction getScriptSkeleton(script: ScriptExportInterface): ScriptSkeleton {\n const scriptId = getScriptId(script);\n return script.script[scriptId];\n}\n\n/**\n * Get the main script ID from a script export. If there is more than one\n * script, an error is thrown.\n *\n * @param script The script export\n * @returns The main script ID\n */\nfunction getScriptId(script: ScriptExportInterface): string {\n const scriptIds = Object.keys(script.script);\n if (scriptIds.length !== 1) {\n throw new Error(`Expected 1 script, found ${scriptIds.length}`);\n }\n return scriptIds[0];\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,OAAOC,QAAQ,MAAM,UAAU;AAC/B,OAAOC,EAAE,MAAM,IAAI;AACnB,SACEC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,WAAW,EACXC,eAAe,EACfC,cAAc,E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AAWA,CAACpF,MAA6B,EAAU;EAC1D,MAAMqF,SAAS,GAAGC,MAAM,CAACC,IAAI,CAACvF,MAAM,CAACA,MAAM,CAAC;EAC5C,IAAIqF,SAAS,CAAC7C,MAAM,KAAK,CAAC,EAAE;IAC1B,MAAM,IAAIgD,KAAK,CAAE,4BAA2BH,SAAS,CAAC7C,MAAO,EAAC,CAAC;EACjE;EACA,OAAO6C,SAAS,CAAC,CAAC,CAAC;AACrB"}
|
package/esm/ops/SecretsOps.js
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { frodo } from '@rockcarver/frodo-lib';
|
|
2
|
-
import { createKeyValueTable, createProgressBar, createTable, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
|
|
3
|
-
import wordwrap from './utils/Wordwrap';
|
|
4
|
-
const {
|
|
5
|
-
resolveUserName
|
|
6
|
-
} = frodo.idm.managed;
|
|
7
|
-
const {
|
|
8
|
-
getSecrets,
|
|
9
|
-
putSecret,
|
|
10
|
-
getSecretVersions,
|
|
11
|
-
getSecret,
|
|
12
|
-
setStatusOfVersionOfSecret,
|
|
13
|
-
createNewVersionOfSecret: _createNewVersionOfSecret,
|
|
14
|
-
setSecretDescription: _setSecretDescription,
|
|
15
|
-
deleteSecret: _deleteSecret,
|
|
16
|
-
deleteVersionOfSecret: _deleteVersionOfSecret
|
|
17
|
-
} = frodo.cloud.secret;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* List secrets
|
|
21
|
-
* @param {boolean} long Long version, all the fields
|
|
22
|
-
*/
|
|
23
|
-
export async function listSecrets(long) {
|
|
24
|
-
let secrets = [];
|
|
25
|
-
try {
|
|
26
|
-
secrets = (await getSecrets()).result;
|
|
27
|
-
secrets.sort((a, b) => a._id.localeCompare(b._id));
|
|
28
|
-
} catch (error) {
|
|
29
|
-
printMessage(`${error.message}`, 'error');
|
|
30
|
-
printMessage(error.response.data, 'error');
|
|
31
|
-
}
|
|
32
|
-
if (long) {
|
|
33
|
-
const table = createTable(['Id'['brightCyan'], {
|
|
34
|
-
hAlign: 'right',
|
|
35
|
-
content: 'Active\nVersion'['brightCyan']
|
|
36
|
-
}, {
|
|
37
|
-
hAlign: 'right',
|
|
38
|
-
content: 'Loaded\nVersion'['brightCyan']
|
|
39
|
-
}, 'Status'['brightCyan'], 'Description'['brightCyan'], 'Modifier'['brightCyan'], 'Modified'['brightCyan']]);
|
|
40
|
-
for (const secret of secrets) {
|
|
41
|
-
table.push([secret._id, {
|
|
42
|
-
hAlign: 'right',
|
|
43
|
-
content: secret.activeVersion
|
|
44
|
-
}, {
|
|
45
|
-
hAlign: 'right',
|
|
46
|
-
content: secret.loadedVersion
|
|
47
|
-
}, secret.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'], wordwrap(secret.description, 40), await resolveUserName('teammember', secret.lastChangedBy), new Date(secret.lastChangeDate).toLocaleString()]);
|
|
48
|
-
}
|
|
49
|
-
printMessage(table.toString(), 'data');
|
|
50
|
-
} else {
|
|
51
|
-
secrets.forEach(secret => {
|
|
52
|
-
printMessage(secret._id, 'data');
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Create secret
|
|
59
|
-
* @param {String} id secret id
|
|
60
|
-
* @param {String} value secret value
|
|
61
|
-
* @param {String} description secret description
|
|
62
|
-
* @param {String} encoding secret encoding
|
|
63
|
-
* @param {boolean} useInPlaceholders use secret in placeholders
|
|
64
|
-
*/
|
|
65
|
-
export async function createSecret(id, value, description, encoding, useInPlaceholders) {
|
|
66
|
-
showSpinner(`Creating secret ${id}...`);
|
|
67
|
-
try {
|
|
68
|
-
await putSecret(id, value, description, encoding, useInPlaceholders);
|
|
69
|
-
succeedSpinner(`Created secret ${id}`);
|
|
70
|
-
} catch (error) {
|
|
71
|
-
failSpinner(`Error: ${error.response.data.code} - ${error.response.data.message}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Set description of secret
|
|
77
|
-
* @param {String} secretId secret id
|
|
78
|
-
* @param {String} description secret description
|
|
79
|
-
*/
|
|
80
|
-
export async function setSecretDescription(secretId, description) {
|
|
81
|
-
showSpinner(`Setting description of secret ${secretId}...`);
|
|
82
|
-
try {
|
|
83
|
-
await _setSecretDescription(secretId, description);
|
|
84
|
-
succeedSpinner(`Set description of secret ${secretId}`);
|
|
85
|
-
} catch (error) {
|
|
86
|
-
failSpinner(`Error: ${error.response.data.code} - ${error.response.data.message}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Delete a secret
|
|
92
|
-
* @param {String} secretId secret id
|
|
93
|
-
*/
|
|
94
|
-
export async function deleteSecret(secretId) {
|
|
95
|
-
showSpinner(`Deleting secret ${secretId}...`);
|
|
96
|
-
try {
|
|
97
|
-
await _deleteSecret(secretId);
|
|
98
|
-
succeedSpinner(`Deleted secret ${secretId}`);
|
|
99
|
-
} catch (error) {
|
|
100
|
-
failSpinner(`Error: ${error.response.data.code} - ${error.response.data.message}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Delete all secrets
|
|
106
|
-
*/
|
|
107
|
-
export async function deleteSecrets() {
|
|
108
|
-
try {
|
|
109
|
-
const secrets = (await getSecrets()).result;
|
|
110
|
-
createProgressBar(secrets.length, `Deleting secrets...`);
|
|
111
|
-
for (const secret of secrets) {
|
|
112
|
-
try {
|
|
113
|
-
await _deleteSecret(secret._id);
|
|
114
|
-
updateProgressBar(`Deleted secret ${secret._id}`);
|
|
115
|
-
} catch (error) {
|
|
116
|
-
printMessage(`Error: ${error.response.data.code} - ${error.response.data.message}`, 'error');
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
stopProgressBar(`Secrets deleted.`);
|
|
120
|
-
} catch (error) {
|
|
121
|
-
printMessage(`Error: ${error.response.data.code} - ${error.response.data.message}`, 'error');
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* List all the versions of the secret
|
|
127
|
-
* @param {String} secretId secret id
|
|
128
|
-
*/
|
|
129
|
-
export async function listSecretVersions(secretId) {
|
|
130
|
-
let versions = [];
|
|
131
|
-
try {
|
|
132
|
-
versions = await getSecretVersions(secretId);
|
|
133
|
-
} catch (error) {
|
|
134
|
-
printMessage(`${error.message}`, 'error');
|
|
135
|
-
printMessage(error.response.data, 'error');
|
|
136
|
-
}
|
|
137
|
-
const table = createTable([{
|
|
138
|
-
hAlign: 'right',
|
|
139
|
-
content: 'Version'['brightCyan']
|
|
140
|
-
}, 'Status'['brightCyan'], 'Loaded'['brightCyan'], 'Created'['brightCyan']]);
|
|
141
|
-
// versions.sort((a, b) => a._id.localeCompare(b._id));
|
|
142
|
-
const statusMap = {
|
|
143
|
-
ENABLED: 'active'['brightGreen'],
|
|
144
|
-
DISABLED: 'inactive'['brightRed'],
|
|
145
|
-
DESTROYED: 'deleted'['brightRed']
|
|
146
|
-
};
|
|
147
|
-
for (const version of versions) {
|
|
148
|
-
table.push([{
|
|
149
|
-
hAlign: 'right',
|
|
150
|
-
content: version.version
|
|
151
|
-
}, statusMap[version.status], version.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed'], new Date(version.createDate).toLocaleString()]);
|
|
152
|
-
}
|
|
153
|
-
printMessage(table.toString());
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Describe a secret
|
|
158
|
-
* @param {String} secretId Secret id
|
|
159
|
-
*/
|
|
160
|
-
export async function describeSecret(secretId) {
|
|
161
|
-
const secret = await getSecret(secretId);
|
|
162
|
-
const table = createKeyValueTable();
|
|
163
|
-
table.push(['Name'['brightCyan'], secret._id]);
|
|
164
|
-
table.push(['Active Version'['brightCyan'], secret.activeVersion]);
|
|
165
|
-
table.push(['Loaded Version'['brightCyan'], secret.loadedVersion]);
|
|
166
|
-
table.push(['Status'['brightCyan'], secret.loaded ? 'loaded'['brightGreen'] : 'unloaded'['brightRed']]);
|
|
167
|
-
table.push(['Description'['brightCyan'], wordwrap(secret.description, 60)]);
|
|
168
|
-
table.push(['Modified'['brightCyan'], new Date(secret.lastChangeDate).toLocaleString()]);
|
|
169
|
-
table.push(['Modifier'['brightCyan'], await resolveUserName('teammember', secret.lastChangedBy)]);
|
|
170
|
-
table.push(['Modifier UUID'['brightCyan'], secret.lastChangedBy]);
|
|
171
|
-
table.push(['Encoding'['brightCyan'], secret.encoding]);
|
|
172
|
-
table.push(['Use In Placeholders'['brightCyan'], secret.useInPlaceholders]);
|
|
173
|
-
printMessage(table.toString());
|
|
174
|
-
printMessage('\nSecret Versions:');
|
|
175
|
-
await listSecretVersions(secretId);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Create new version of secret
|
|
180
|
-
* @param {String} secretId secret id
|
|
181
|
-
* @param {String} value secret value
|
|
182
|
-
*/
|
|
183
|
-
export async function createNewVersionOfSecret(secretId, value) {
|
|
184
|
-
showSpinner(`Creating new version of secret ${secretId}...`);
|
|
185
|
-
try {
|
|
186
|
-
const version = await _createNewVersionOfSecret(secretId, value);
|
|
187
|
-
succeedSpinner(`Created version ${version.version} of secret ${secretId}`);
|
|
188
|
-
} catch (error) {
|
|
189
|
-
failSpinner(`Error: ${error.response.data.code} - ${error.response.data.message}`);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Activate a version of a secret
|
|
195
|
-
* @param {String} secretId secret id
|
|
196
|
-
* @param {Number} version version of secret
|
|
197
|
-
*/
|
|
198
|
-
export async function activateVersionOfSecret(secretId, version) {
|
|
199
|
-
showSpinner(`Activating version ${version} of secret ${secretId}...`);
|
|
200
|
-
try {
|
|
201
|
-
await setStatusOfVersionOfSecret(secretId, version, 'ENABLED');
|
|
202
|
-
succeedSpinner(`Activated version ${version} of secret ${secretId}`);
|
|
203
|
-
} catch (error) {
|
|
204
|
-
failSpinner(`Error: ${error.response.data.code} - ${error.response.data.message}`);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Deactivate a version of a secret
|
|
210
|
-
* @param {String} secretId secret id
|
|
211
|
-
* @param {Number} version version of secret
|
|
212
|
-
*/
|
|
213
|
-
export async function deactivateVersionOfSecret(secretId, version) {
|
|
214
|
-
showSpinner(`Deactivating version ${version} of secret ${secretId}...`);
|
|
215
|
-
try {
|
|
216
|
-
await setStatusOfVersionOfSecret(secretId, version, 'DISABLED');
|
|
217
|
-
succeedSpinner(`Deactivated version ${version} of secret ${secretId}`);
|
|
218
|
-
} catch (error) {
|
|
219
|
-
failSpinner(`Error: ${error.response.data.code} - ${error.response.data.message}`);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Delete version of secret
|
|
225
|
-
* @param {String} secretId secret id
|
|
226
|
-
* @param {Number} version version of secret
|
|
227
|
-
*/
|
|
228
|
-
export async function deleteVersionOfSecret(secretId, version) {
|
|
229
|
-
showSpinner(`Deleting version ${version} of secret ${secretId}...`);
|
|
230
|
-
try {
|
|
231
|
-
await _deleteVersionOfSecret(secretId, version);
|
|
232
|
-
succeedSpinner(`Deleted version ${version} of secret ${secretId}`);
|
|
233
|
-
} catch (error) {
|
|
234
|
-
failSpinner(`Error: ${error.response.data.code} - ${error.response.data.message}`);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
//# sourceMappingURL=SecretsOps.js.map
|