diff --git a/docs/auth0_actions_create.md b/docs/auth0_actions_create.md index c57568aea..478d85d30 100644 --- a/docs/auth0_actions_create.md +++ b/docs/auth0_actions_create.md @@ -22,7 +22,7 @@ auth0 actions create [flags] auth0 actions create auth0 actions create --name myaction auth0 actions create --name myaction --trigger post-login - auth0 actions create --name myaction --trigger post-login --code "$(cat path/to/code.js) --runtime node18 + auth0 actions create --name myaction --trigger post-login --code "$(cat path/to/code.js)" --runtime node18 auth0 actions create --name myaction --trigger post-login --code "$(cat path/to/code.js)" --dependency "lodash=4.0.0" auth0 actions create --name myaction --trigger post-login --code "$(cat path/to/code.js)" --dependency "lodash=4.0.0" --secret "SECRET=value" auth0 actions create --name myaction --trigger post-login --code "$(cat path/to/code.js)" --dependency "lodash=4.0.0" --dependency "uuid=9.0.0" --secret "API_KEY=value" --secret "SECRET=value" diff --git a/docs/auth0_event-streams_create.md b/docs/auth0_event-streams_create.md index b777bada8..50ba9b42c 100644 --- a/docs/auth0_event-streams_create.md +++ b/docs/auth0_event-streams_create.md @@ -9,7 +9,8 @@ Create a new event stream. To create interactively, use `auth0 event-streams create` with no flags. -To create non-interactively, supply the event stream name, type, subscriptions and configuration through the flags. +To create non-interactively, supply the event stream name, type, subscriptions and configuration through the flags. +Only deployed actions can be used for action configuration ## Usage ``` @@ -22,6 +23,7 @@ auth0 event-streams create [flags] auth0 event-streams create auth0 event-streams create --name my-event-stream --type eventbridge --subscriptions "user.created,user.updated" --configuration '{"aws_account_id":"325235643634","aws_region":"us-east-2"}' auth0 event-streams create --name my-event-stream --type webhook --subscriptions "user.created,user.deleted" --configuration '{"webhook_endpoint":"https://mywebhook.net","webhook_authorization":{"method":"bearer","token":"123456789"}}' + auth0 event-streams create --name my-event-stream --type action --subscriptions "user.created" --configuration '{"action_id":"b053e4ca-8b14-4233-b615-bd3bdb353977"}' auth0 event-streams create -n my-event-stream -t webhook -s "user.created,user.deleted" -c '{"webhook_endpoint":"https://mywebhook.net","webhook_authorization":{"method":"bearer","token":"123456789"}}' ``` diff --git a/docs/auth0_event-streams_update.md b/docs/auth0_event-streams_update.md index f3413a4ec..09f29a4e6 100644 --- a/docs/auth0_event-streams_update.md +++ b/docs/auth0_event-streams_update.md @@ -9,7 +9,7 @@ Update an event stream. To update interactively, use `auth0 event-streams update` with no arguments. -To update non-interactively, supply the event id, name, status, subscriptions and configuration through the flags. An event stream type CANNOT be updated hence the configuration should match the schema based on the type of event stream. Configuration for `eventbridge` streams cannot be updated. +To update non-interactively, supply the event id, name, status, subscriptions and configuration through the flags. An event stream type CANNOT be updated hence the configuration should match the schema based on the type of event stream. Configuration for `eventbridge` streams cannot be updated.Only deployed actions can be used for action configuration ## Usage ``` @@ -24,7 +24,8 @@ auth0 event-streams update [flags] auth0 event-streams update --name my-event-stream --status enabled auth0 event-streams update --name my-event-stream --status enabled --subscriptions "user.created,user.updated" auth0 event-streams update --name my-event-stream --status disabled --subscriptions "user.deleted" --configuration '{"aws_account_id":"325235643634","aws_region":"us-east-2"}' - auth0 event-streams update --name my-event-stream --status enabled --subscriptions "user.created" --configuration '{"webhook_endpoint":"https://my-new-webhook.net","webhook_authorization":{"method":"bearer","token":"0909090909"}} + auth0 event-streams update --name my-event-stream --status enabled --subscriptions "user.created" --configuration '{"webhook_endpoint":"https://my-new-webhook.net","webhook_authorization":{"method":"bearer","token":"0909090909"}}' + auth0 event-streams create --name my-event-stream --subscriptions "user.updated" --configuration '{"action_id":"b053e4ca-8b14-4233-b615-bd3bdb353977"}' auth0 event-streams update -n my-event-stream --status enabled -s "user.created" -c '{"webhook_endpoint":"https://my-new-webhook.net","webhook_authorization":{"method":"bearer","token":"987654321"}} ``` diff --git a/internal/cli/actions.go b/internal/cli/actions.go index 179df3c4c..57c501e34 100644 --- a/internal/cli/actions.go +++ b/internal/cli/actions.go @@ -76,6 +76,7 @@ var ( "send-phone-message": actionTemplateSendPhoneMessage, "custom-email-provider": actionTemplateCustomEmailProvider, "custom-phone-provider": actionTemplateCustomPhoneProvider, + "event-stream": actionTemplateEventStream, } ) @@ -201,7 +202,7 @@ func createActionCmd(cli *cli) *cobra.Command { Example: ` auth0 actions create auth0 actions create --name myaction auth0 actions create --name myaction --trigger post-login - auth0 actions create --name myaction --trigger post-login --code "$(cat path/to/code.js) --runtime node18 + auth0 actions create --name myaction --trigger post-login --code "$(cat path/to/code.js)" --runtime node18 auth0 actions create --name myaction --trigger post-login --code "$(cat path/to/code.js)" --dependency "lodash=4.0.0" auth0 actions create --name myaction --trigger post-login --code "$(cat path/to/code.js)" --dependency "lodash=4.0.0" --secret "SECRET=value" auth0 actions create --name myaction --trigger post-login --code "$(cat path/to/code.js)" --dependency "lodash=4.0.0" --dependency "uuid=9.0.0" --secret "API_KEY=value" --secret "SECRET=value" diff --git a/internal/cli/actions_embed.go b/internal/cli/actions_embed.go index bcce0280e..48d0528f5 100644 --- a/internal/cli/actions_embed.go +++ b/internal/cli/actions_embed.go @@ -31,4 +31,7 @@ var ( //go:embed data/action-template-empty.js actionTemplateEmpty string + + //go:embed data/action-template-event-stream.js + actionTemplateEventStream string ) diff --git a/internal/cli/data/action-template-event-stream.js b/internal/cli/data/action-template-event-stream.js new file mode 100644 index 000000000..4f6fe12af --- /dev/null +++ b/internal/cli/data/action-template-event-stream.js @@ -0,0 +1,9 @@ +/** + * Handler that will be called during the execution of a EventStream flow. + * + * @param {Event} event - Details about the user and the context in which they are logging in. + * @param {EventStreamAPI} api - Methods and utilities to help + */ +exports.onExecuteEventStream = async (event, api) => { + +}; diff --git a/internal/cli/event_streams.go b/internal/cli/event_streams.go index f740a2f66..72c0166fa 100644 --- a/internal/cli/event_streams.go +++ b/internal/cli/event_streams.go @@ -185,10 +185,12 @@ func createEventStreamCmd(cli *cli) *cobra.Command { Short: "Create a new event stream", Long: "Create a new event stream.\n\n" + "To create interactively, use `auth0 event-streams create` with no flags.\n\n" + - "To create non-interactively, supply the event stream name, type, subscriptions and configuration through the flags.", + "To create non-interactively, supply the event stream name, type, subscriptions and configuration through the flags. \n" + + "Only deployed actions can be used for action configuration", Example: ` auth0 event-streams create auth0 event-streams create --name my-event-stream --type eventbridge --subscriptions "user.created,user.updated" --configuration '{"aws_account_id":"325235643634","aws_region":"us-east-2"}' auth0 event-streams create --name my-event-stream --type webhook --subscriptions "user.created,user.deleted" --configuration '{"webhook_endpoint":"https://mywebhook.net","webhook_authorization":{"method":"bearer","token":"123456789"}}' + auth0 event-streams create --name my-event-stream --type action --subscriptions "user.created" --configuration '{"action_id":"b053e4ca-8b14-4233-b615-bd3bdb353977"}' auth0 event-streams create -n my-event-stream -t webhook -s "user.created,user.deleted" -c '{"webhook_endpoint":"https://mywebhook.net","webhook_authorization":{"method":"bearer","token":"123456789"}}'`, RunE: func(cmd *cobra.Command, args []string) error { if err := eventStreamName.Ask(cmd, &inputs.Name, nil); err != nil { @@ -269,13 +271,15 @@ func updateEventStreamCmd(cli *cli) *cobra.Command { "To update non-interactively, supply the event id, name, status, subscriptions and " + "configuration through the flags. An event stream type CANNOT be updated hence the configuration " + "should match the schema based on the type of event stream. Configuration for `eventbridge` streams " + - "cannot be updated.", + "cannot be updated." + + "Only deployed actions can be used for action configuration", Example: ` auth0 event-streams update auth0 event-streams update --name my-event-stream auth0 event-streams update --name my-event-stream --status enabled auth0 event-streams update --name my-event-stream --status enabled --subscriptions "user.created,user.updated" auth0 event-streams update --name my-event-stream --status disabled --subscriptions "user.deleted" --configuration '{"aws_account_id":"325235643634","aws_region":"us-east-2"}' - auth0 event-streams update --name my-event-stream --status enabled --subscriptions "user.created" --configuration '{"webhook_endpoint":"https://my-new-webhook.net","webhook_authorization":{"method":"bearer","token":"0909090909"}} + auth0 event-streams update --name my-event-stream --status enabled --subscriptions "user.created" --configuration '{"webhook_endpoint":"https://my-new-webhook.net","webhook_authorization":{"method":"bearer","token":"0909090909"}}' + auth0 event-streams create --name my-event-stream --subscriptions "user.updated" --configuration '{"action_id":"b053e4ca-8b14-4233-b615-bd3bdb353977"}' auth0 event-streams update -n my-event-stream --status enabled -s "user.created" -c '{"webhook_endpoint":"https://my-new-webhook.net","webhook_authorization":{"method":"bearer","token":"987654321"}}`, RunE: func(cmd *cobra.Command, args []string) error { if len(args) > 0 {