Skip to main content

Command

Description

Represents an intention to change the state of the system. Commands are imperative and typically handled by a single Command Handler.

Definition Schema

The definition for a command component expects the following structure:

{
"$defs": {
"CommandParameterInputDTO": {
"description": "Generic DTO for defining a parameter (field) in a generated 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": "CommandParameterInputDTO",
"type": "object"
}
},
"description": "DTO for defining a command class.",
"example": {
"command_name": "CreatePostCommand",
"parameters": [
{
"param_name": "title",
"param_type_str": "str"
},
{
"default_value_str": "None",
"param_name": "content",
"param_type_str": "Optional[str]"
},
{
"param_name": "author_id",
"param_type_str": "int"
}
]
},
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"parameters": {
"items": {
"$ref": "#/$defs/CommandParameterInputDTO"
},
"title": "Parameters",
"type": "array"
},
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Description"
}
},
"required": [
"name"
],
"title": "CommandInputDTO",
"type": "object"
}

Naming and Location Conventions

Class: PascalCase, typically ends with 'Command'. File: ${command_name}.py (based on ${command_name}). Location: app/application/${bounded_ctx}/commands. (Requires context: ['bounded_ctx'])

Example Definition

{
"command_name": "CreatePostCommand",
"parameters": [
{
"param_name": "title",
"param_type_str": "str"
},
{
"param_name": "content",
"param_type_str": "Optional[str]",
"default_value_str": "None"
},
{
"param_name": "author_id",
"param_type_str": "int"
}
]
}