Skip to main content

ironflow_api/entities/
step.rs

1//! Step-related DTOs.
2
3use chrono::{DateTime, Utc};
4use ironflow_store::models::{Step, StepKind, StepStatus};
5use rust_decimal::Decimal;
6use serde::{Deserialize, Serialize};
7use serde_json::Value;
8use uuid::Uuid;
9
10/// Step response DTO — public API representation of a step.
11///
12/// # Examples
13///
14/// ```
15/// use ironflow_store::models::Step;
16/// use ironflow_api::entities::StepResponse;
17/// ```
18#[derive(Debug, Serialize, Deserialize)]
19pub struct StepResponse {
20    /// Unique step identifier.
21    pub id: Uuid,
22    /// Parent run ID.
23    pub run_id: Uuid,
24    /// Step name.
25    pub name: String,
26    /// Step operation type.
27    pub kind: StepKind,
28    /// Execution order (0-based).
29    pub position: u32,
30    /// Current status.
31    pub status: StepStatus,
32    /// Input configuration.
33    pub input: Option<Value>,
34    /// Step output.
35    pub output: Option<Value>,
36    /// Optional error message.
37    pub error: Option<String>,
38    /// Execution duration in milliseconds.
39    pub duration_ms: u64,
40    /// Cost in USD.
41    pub cost_usd: Decimal,
42    /// Input token count (agent steps).
43    pub input_tokens: Option<u64>,
44    /// Output token count (agent steps).
45    pub output_tokens: Option<u64>,
46    /// When created.
47    pub created_at: DateTime<Utc>,
48    /// When updated.
49    pub updated_at: DateTime<Utc>,
50    /// When execution started.
51    pub started_at: Option<DateTime<Utc>>,
52    /// When execution completed.
53    pub completed_at: Option<DateTime<Utc>>,
54}
55
56impl From<Step> for StepResponse {
57    fn from(step: Step) -> Self {
58        StepResponse {
59            id: step.id,
60            run_id: step.run_id,
61            name: step.name,
62            kind: step.kind,
63            position: step.position,
64            status: step.status.state,
65            input: step.input,
66            output: step.output,
67            error: step.error,
68            duration_ms: step.duration_ms,
69            cost_usd: step.cost_usd,
70            input_tokens: step.input_tokens,
71            output_tokens: step.output_tokens,
72            created_at: step.created_at,
73            updated_at: step.updated_at,
74            started_at: step.started_at,
75            completed_at: step.completed_at,
76        }
77    }
78}