1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// SPDX-FileCopyrightText: 2025-2026 RAprogramm <andrey.rozanov.vl@gmail.com>
// SPDX-License-Identifier: MIT
//! Command definition and parsing for CQRS-style operations.
//!
//! This module handles parsing of `#[command(...)]` attributes that define
//! domain-specific business operations on entities. Commands follow the
//! CQRS (Command Query Responsibility Segregation) pattern, providing
//! explicit, named operations instead of generic CRUD.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────────┐
//! │ Command Parsing │
//! ├─────────────────────────────────────────────────────────────────────┤
//! │ │
//! │ Attribute Parser Output │
//! │ │
//! │ #[command(Register)] parse_command_attrs() CommandDef │
//! │ #[command(UpdateEmail: │ │ │
//! │ email, name)] │ ├── name │
//! │ #[command(Deactivate, │ ├── source │
//! │ requires_id)] │ ├── requires_id│
//! │ ▼ └── kind │
//! │ │
//! │ Vec<CommandDef> │
//! │ │ │
//! │ ▼ │
//! │ Code Generation │
//! │ ├── RegisterUser struct │
//! │ ├── UpdateEmailUser struct │
//! │ ├── UserCommand enum │
//! │ └── UserCommandHandler trait │
//! │ │
//! └─────────────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Command Syntax
//!
//! Commands support multiple syntax forms:
//!
//! ## Simple Command
//!
//! Uses fields marked with `#[field(create)]`:
//!
//! ```rust,ignore
//! #[command(Register)]
//! ```
//!
//! ## Field-Specific Command
//!
//! Uses only the listed fields (requires ID):
//!
//! ```rust,ignore
//! #[command(UpdateEmail: email)]
//! #[command(UpdateProfile: name, avatar, bio)]
//! ```
//!
//! ## ID-Only Command
//!
//! No fields, just the entity ID:
//!
//! ```rust,ignore
//! #[command(Deactivate, requires_id)]
//! #[command(Delete, requires_id, kind = "delete")]
//! ```
//!
//! ## Custom Payload Command
//!
//! Uses an external struct for the payload:
//!
//! ```rust,ignore
//! #[command(Transfer, payload = "TransferPayload")]
//! #[command(Transfer, payload = "TransferPayload", result = "TransferResult")]
//! ```
//!
//! # Command Options
//!
//! | Option | Type | Description |
//! |--------|------|-------------|
//! | `requires_id` | flag | Command needs entity ID |
//! | `source` | string | Field source: `"create"`, `"update"`, `"none"` |
//! | `payload` | string | Custom payload struct type |
//! | `result` | string | Custom result type |
//! | `kind` | string | Kind hint: `"create"`, `"update"`, `"delete"`, `"custom"` |
//! | `security` | string | Security override: scheme name or `"none"` |
//!
//! # Generated Code
//!
//! For entity `User` with commands:
//!
//! ```rust,ignore
//! #[command(Register)]
//! #[command(UpdateEmail: email)]
//! #[command(Deactivate, requires_id)]
//! ```
//!
//! Generates:
//!
//! ```rust,ignore
//! // Command structs
//! pub struct RegisterUser {
//! pub name: String,
//! pub email: String,
//! }
//!
//! pub struct UpdateEmailUser {
//! pub id: Uuid,
//! pub email: String,
//! }
//!
//! pub struct DeactivateUser {
//! pub id: Uuid,
//! }
//!
//! // Command enum
//! pub enum UserCommand {
//! Register(RegisterUser),
//! UpdateEmail(UpdateEmailUser),
//! Deactivate(DeactivateUser),
//! }
//!
//! // Handler trait
//! #[async_trait]
//! pub trait UserCommandHandler {
//! async fn handle_register(&self, cmd: RegisterUser) -> Result<User, Error>;
//! async fn handle_update_email(&self, cmd: UpdateEmailUser) -> Result<User, Error>;
//! async fn handle_deactivate(&self, cmd: DeactivateUser) -> Result<(), Error>;
//! }
//! ```
//!
//! # Module Structure
//!
//! | Module | Purpose |
//! |--------|---------|
//! | [`types`] | Type definitions: `CommandDef`, `CommandSource`, `CommandKindHint` |
//! | [`parser`] | Attribute parsing: `parse_command_attrs` |
pub use parse_command_attrs;
pub use ;