AshDispatch.Resources.ManualTrigger (AshDispatch v0.5.0)
View SourceNon-persisted resource for manually triggering events from admin interfaces.
This resource provides actions for:
- Listing available events (with optional user filtering)
- Checking user preference status for events
- Previewing event content before sending
- Manually dispatching events with custom configuration
Configuration
Configure the user resource, domain, and preference provider in your app's config:
config :ash_dispatch,
event_modules: [...],
user_resource: MyApp.Accounts.User, # Ash resource for users
user_domain: MyApp.Accounts, # Domain that contains the user resource
preference_provider: MyApp.PreferenceProvider # Behavior implementationUsage
Add to your domain:
resources do
resource AshDispatch.Resources.ManualTrigger do
define :list_manual_trigger_events, action: :list_events
define :preview_manual_trigger, action: :preview
define :trigger_manual_event, action: :trigger
end
endTypeScript RPC
typescript_rpc do
resource AshDispatch.Resources.ManualTrigger do
rpc_action :list_manual_trigger_events, :list_events
rpc_action :preview_manual_trigger, :preview
rpc_action :trigger_manual_event, :trigger
end
end
Summary
Types
@type t() :: %AshDispatch.Resources.ManualTrigger{ __lateral_join_source__: term(), __meta__: term(), __metadata__: term(), __order__: term(), aggregates: term(), audience: term(), calculations: term(), category: term(), channels: term(), context_data: term(), description: term(), domain: term(), event_id: term(), example_context: term(), from_address: term(), html_body: term(), notification_message: term(), notification_title: term(), preference_enabled: term(), recipient: term(), recipient_email: term(), required_context: term(), required_resources: term(), skip_preferences: term(), subject: term(), text_body: term(), transport: term(), user_configurable: term() }
Functions
Validates that the keys in the provided input are valid for at least one action on the resource.
Raises a KeyError error at compile time if not. This exists because generally a struct should only ever
be created by Ash as a result of a successful action. You should not be creating records manually in code,
e.g %MyResource{value: 1, value: 2}. Generally that is fine, but often with embedded resources it is nice
to be able to validate the keys that are being provided, e.g
Resource
|> Ash.Changeset.for_create(:create, %{embedded: EmbeddedResource.input(foo: 1, bar: 2)})
|> Ash.create()
Same as input/1, except restricts the keys to values accepted by the action provided.