mix ash_dispatch.gen (AshDispatch v0.5.1)
View SourceGenerates missing files for AshDispatch events based on DSL definitions.
This generator introspects all events and counters defined in resources using
AshDispatch.Resource and generates missing template files, TypeScript types,
and the complete SDK.
Usage
mix ash_dispatch.gen # Generate all missing files
mix ash_dispatch.gen --check # Exit with error if files missing (for CI)
mix ash_dispatch.gen --dry-run # Show what would be generated
mix ash_dispatch.gen --verbose # Show detailed outputIntegration with mix ash.codegen
This task is automatically called when running mix ash.codegen:
mix ash.codegen # Runs all extension codegens
mix ash.codegen --check # CI mode - fail if files missing
mix ash.codegen --dry-run # Preview all changesWhat Gets Generated
Email Templates
For each :email channel defined in your events:
| File | When Generated |
|---|---|
email.html.heex | Always for email channels |
email.text.eex | Always for email channels |
email.{variant}.html.heex | When channel has variant: :xxx |
email.{variant}.text.eex | When channel has variant: :xxx |
Templates are placed in {event_module_dir}/templates/.
TypeScript SDK
Generates a complete SDK in lib/ash-dispatch/ (next to your ash_typescript output):
| File | Description |
|---|---|
types.ts | Counter types, defaults, metadata, and accessors |
events.ts | Event ID types and metadata |
store.ts | Zustand store for counter state |
channel.ts | Phoenix channel utilities |
index.ts | Re-exports all SDK modules |
hooks/use-channel.ts | Channel connection hook |
hooks/use-counter.ts | Single counter access hook |
hooks/use-notifications.ts | Notification actions hook |
Configuration
TypeScript SDK generation requires ash_typescript to be configured:
# TypeScript output path (required for SDK generation)
config :ash_typescript,
output_file: "apps/frontend/src/lib/ash_rpc.ts"
# SDK will be generated to: apps/frontend/src/lib/ash-dispatch/Without this configuration, only templates and event modules will be generated. You can also explicitly configure the SDK output path:
config :ash_dispatch,
sdk_output_path: "apps/frontend/src/lib/ash-dispatch"See the Code Generation guide for details.