Domain Event
Description
Represents a significant occurrence in the domain. Domain Events are facts about things that have happened.
Definition Schema
The definition for a domain_event
component expects the following structure:
{
"$defs": {
"EventParameterInputDTO": {
"description": "Generic DTO for defining a parameter (field) in a generated event class.",
"example": {
"default_value_str": null,
"param_name": "user_id",
"param_type_str": "int"
},
"properties": {
"param_name": {
"title": "Param Name",
"type": "string"
},
"param_type_str": {
"title": "Param Type Str",
"type": "string"
},
"default_value_str": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Default Value Str"
}
},
"required": [
"param_name",
"param_type_str"
],
"title": "EventParameterInputDTO",
"type": "object"
}
},
"description": "DTO for defining an event class.",
"example": {
"event_name": "UserCreated",
"parameters": [
{
"param_name": "user_id",
"param_type_str": "int"
},
{
"param_name": "username",
"param_type_str": "str"
},
{
"param_name": "created_at",
"param_type_str": "datetime"
}
]
},
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"parameters": {
"items": {
"$ref": "#/$defs/EventParameterInputDTO"
},
"title": "Parameters",
"type": "array"
}
},
"required": [
"name"
],
"title": "EventInputDTO",
"type": "object"
}
Naming and Location Conventions
Class: PascalCase, typically ends with 'Event'. File: ${domain_event_name}.py
(based on ${domain_event_name}
). Location: app/domain/${bounded_ctx}/events
. (Requires context: ['bounded_ctx'])
Example Definition
{
"event_name": "UserCreated",
"parameters": [
{
"param_name": "user_id",
"param_type_str": "int"
},
{
"param_name": "username",
"param_type_str": "str"
},
{
"param_name": "created_at",
"param_type_str": "datetime"
}
]
}