agentics-domain 0.3.0

Domain types and validation models for the Agentics challenge platform.
Documentation
//! Shared API model types used by backend crates and mirrored by the frontend schemas.
//!
//! Response DTO policy: optional response fields should serialize absent values
//! by using `#[serde(skip_serializing_if = "Option::is_none")]`. The public JSON
//! contract avoids explicit `null` fields so generated frontend schemas can map
//! these fields to `field?: T`. Use explicit `null` only when the API semantics
//! require distinguishing "present but empty" from "not present", and document
//! that exception next to the field.

pub mod auth;
pub mod challenge;
pub mod challenge_creation;
pub mod evaluation;
pub mod github;
pub mod hashes;
pub mod ids;
pub mod images;
pub mod localization;
pub mod names;
pub mod paths;
pub mod pioneer_codes;
pub mod request;
pub mod urls;

#[cfg(test)]
mod contract_tests;

use serde::{Deserialize, Serialize};

use agentics_error::ServiceErrorCode;

pub use agentics_error::ErrorDetail;

/// Standard error response shape used by all API extractors and handlers.
#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct ErrorResponse {
    pub error: ErrorBody,
}

/// Standard nested API error body.
#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct ErrorBody {
    pub code: ServiceErrorCode,
    pub message: String,
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub details: Vec<ErrorDetail>,
}

/// Health-check response returned by the API server.
#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct HealthResponse {
    pub status: String,
    pub service: String,
    pub environment: String,
    pub database: DatabaseHealth,
}

/// Database portion of the health-check response.
#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct DatabaseHealth {
    pub connected: bool,
    pub current_time: String,
}

/// Generic response for endpoints that only need to return an id.
#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
pub struct IdOnlyResponse {
    pub id: String,
}