1use serde_json::Value;
2use std::collections::HashMap;
3use stormchaser_model::workflow::RunStatus;
4pub mod auth;
6pub mod cron;
8pub mod event_rule;
10#[cfg(feature = "mcp")]
12pub mod mcp;
13pub mod schema;
15pub mod step;
17pub mod storage;
19pub mod webhook;
21pub mod workflow;
23
24use chrono::{DateTime, Utc};
25use serde::{Deserialize, Serialize};
26use utoipa::{IntoParams, ToSchema};
27
28use stormchaser_model::step::{StepInstance, StepOutput, StepStatusHistory};
29use stormchaser_model::storage::{ArtifactRegistry, BackendType};
30use stormchaser_model::test_report;
31
32#[derive(Debug, Deserialize, ToSchema)]
33pub struct AuthExchangeRequest {
35 pub sso_token: String,
37 pub callback_url: String,
39}
40
41#[derive(Debug, Serialize, Deserialize, ToSchema)]
42pub struct AuthExchangeResponse {
44 pub access_token: String,
46 pub refresh_token: Option<String>,
48 pub token_type: String,
50 pub expires_in: usize,
52}
53
54#[derive(Debug, Deserialize, ToSchema)]
55pub struct AuthRefreshRequest {
57 pub refresh_token: String,
59}
60
61#[derive(Debug, Deserialize, ToSchema)]
62pub struct EnqueueRequest {
64 pub workflow_name: String,
66 pub repo_url: String,
68 pub workflow_path: String,
70 pub git_ref: String,
72 #[schema(value_type = Object)]
74 pub inputs: Value,
75 pub overrides: Option<RunOverrides>,
77}
78
79#[derive(Debug, Deserialize, ToSchema)]
80pub struct RunOverrides {
82 pub timeout: Option<String>,
84}
85
86#[derive(Debug, Serialize, Deserialize, ToSchema)]
87pub struct EnqueueResponse {
89 pub run_id: stormchaser_model::RunId,
91 pub status: RunStatus,
93}
94
95#[derive(Debug, Deserialize, ToSchema, IntoParams)]
96#[into_params(parameter_in = Query)]
97pub struct ListRunsQuery {
99 pub workflow_name: Option<String>,
101 #[schema(value_type = Option<String>)]
102 #[param(value_type = Option<String>)]
103 pub status: Option<RunStatus>,
105 pub initiating_user: Option<String>,
107 pub repo_url: Option<String>,
109 pub workflow_path: Option<String>,
111 pub created_after: Option<DateTime<Utc>>,
113 pub created_before: Option<DateTime<Utc>>,
115 pub limit: Option<usize>,
117 pub offset: Option<usize>,
119}
120
121#[derive(Debug, Serialize, Deserialize, ToSchema, sqlx::FromRow)]
122pub struct WorkflowRunDetail {
124 pub id: stormchaser_model::RunId,
126 pub workflow_name: String,
128 pub initiating_user: String,
130 pub repo_url: String,
132 pub workflow_path: String,
134 pub git_ref: String,
136 pub status: RunStatus,
138 pub version: i32,
140 pub created_at: DateTime<Utc>,
142 pub updated_at: DateTime<Utc>,
144 pub started_resolving_at: Option<DateTime<Utc>>,
146 pub started_at: Option<DateTime<Utc>>,
148 pub finished_at: Option<DateTime<Utc>>,
150 pub error: Option<String>,
152 #[schema(value_type = Object)]
154 pub inputs: Value,
155 pub secrets: Value,
157 pub source_code: String,
159 pub dsl_version: String,
161}
162
163#[derive(Debug, Serialize, Deserialize, ToSchema)]
164pub struct WorkflowRunFullDetail {
166 pub detail: WorkflowRunDetail,
168 pub steps: Vec<StepDetail>,
170 #[schema(value_type = Vec<Object>)]
171 pub artifacts: Vec<ArtifactRegistry>,
173 pub test_summaries: Vec<TestSummaryResponse>,
175 #[schema(value_type = Vec<Object>)]
176 pub test_cases: Vec<test_report::TestCase>,
178}
179
180#[derive(Debug, Serialize, Deserialize, ToSchema)]
181pub struct StepDetail {
183 pub instance: StepInstance,
185 pub outputs: Vec<StepOutput>,
187 pub history: Vec<StepStatusHistory>,
189 pub logs: Vec<String>,
191}
192
193#[derive(Debug, Deserialize, ToSchema)]
194pub struct DirectRunRequest {
196 pub dsl: String,
198 #[schema(value_type = Object)]
200 pub inputs: Value,
201}
202
203#[derive(Debug, Deserialize, ToSchema)]
204pub struct CreateWebhookRequest {
206 pub name: String,
208 pub description: Option<String>,
210 pub source_type: String, pub secret_token: Option<String>,
214}
215
216#[derive(Debug, Deserialize, ToSchema)]
217pub struct UpdateWebhookRequest {
219 pub name: Option<String>,
221 pub description: Option<String>,
223 pub source_type: Option<String>, pub secret_token: Option<String>,
227 pub is_active: Option<bool>,
229}
230
231#[derive(Debug, Deserialize, ToSchema)]
232pub struct CreateEventRuleRequest {
234 pub name: String,
236 pub description: Option<String>,
238 pub webhook_id: stormchaser_model::WebhookId,
240 pub event_type_pattern: String,
242 pub condition_expr: Option<String>,
244 pub workflow_name: String,
246 pub repo_url: String,
248 pub workflow_path: String,
250 pub git_ref: String,
252 pub input_mappings: HashMap<String, String>,
254}
255
256#[derive(Debug, Deserialize, ToSchema)]
257pub struct CreateCronWorkflowRequest {
259 pub name: String,
261 pub description: Option<String>,
263 pub cronspec: String,
265 pub workflow_name: String,
267 pub repo_url: String,
269 pub workflow_path: String,
271 pub git_ref: String,
273 #[schema(value_type = Object)]
275 pub inputs: Value,
276}
277
278#[derive(Debug, Serialize, ToSchema)]
279pub struct CronWorkflowResponse {
281 pub id: stormchaser_model::CronWorkflowId,
283 pub secret_token: String,
285 pub external_job_id: Option<String>,
287}
288
289#[derive(Debug, Deserialize, ToSchema)]
290pub struct CreateStorageBackendRequest {
292 pub name: String,
294 pub description: Option<String>,
296 pub backend_type: BackendType,
298 #[schema(value_type = Object)]
300 pub config: Value,
301 pub aws_assume_role_arn: Option<String>,
303 pub is_default_sfs: bool,
305}
306
307#[derive(Debug, Deserialize, ToSchema)]
308pub struct UpdateStorageBackendRequest {
310 pub name: Option<String>,
312 pub description: Option<String>,
314 pub backend_type: Option<BackendType>,
316 #[schema(value_type = Object)]
318 pub config: Option<Value>,
319 pub aws_assume_role_arn: Option<String>,
321 pub is_default_sfs: Option<bool>,
323}
324
325#[derive(Debug, Serialize, Deserialize, sqlx::FromRow, ToSchema)]
326pub struct TestReportSummary {
328 pub id: stormchaser_model::TestReportId,
330 pub report_name: String,
332 pub file_name: String,
334 pub format: String,
336 pub checksum: String,
338 pub backend_id: Option<stormchaser_model::BackendId>,
340 pub remote_path: Option<String>,
342 pub created_at: DateTime<Utc>,
344}
345
346#[derive(Debug, Serialize, Deserialize, sqlx::FromRow, ToSchema)]
347pub struct TestSummaryResponse {
349 pub id: stormchaser_model::TestReportId,
351 pub run_id: stormchaser_model::RunId,
353 pub step_instance_id: stormchaser_model::StepInstanceId,
355 pub report_name: String,
357 pub total_tests: i32,
359 pub passed: i32,
361 pub failed: i32,
363 pub skipped: i32,
365 pub errors: i32,
367 pub duration_ms: i64,
369 pub created_at: DateTime<Utc>,
371}