//! Project and git repository models. use chrono::{DateTime, Utc}; use serde::Serialize; use sqlx::FromRow; use super::super::id_types::*; use super::super::validated_types::*; /// A creator's project (collection of items). #[derive(Debug, Clone, FromRow, Serialize)] pub struct DbProject { /// Database primary key. pub id: ProjectId, /// Owning user's ID. pub user_id: UserId, /// URL-safe slug unique per user. pub slug: Slug, /// Display title. pub title: String, /// Optional longer description. pub description: Option, /// Category type (e.g. software, music, blog). pub project_type: super::super::ProjectType, /// URL to the project's cover image. pub cover_image_url: Option, /// Whether this project is publicly visible. pub is_public: bool, /// When the project was created. pub created_at: DateTime, /// When the project was last modified. pub updated_at: DateTime, /// Generation counter for ETag-based HTTP caching. Bumped on any project-visible write. pub cache_generation: i64, /// Linked MT community ID (None if not yet provisioned or MT unavailable). pub mt_community_id: Option, /// Platform features enabled for this project (e.g. audio, blog, downloads). pub features: Vec, /// Pricing model: free, buy_once, pwyw, or subscription. pub pricing_model: super::super::PricingKind, /// Price in cents (for buy_once); 0 for free projects. pub price_cents: i32, /// Minimum price in cents when PWYW is enabled (floor). pub pwyw_min_cents: Option, /// Whether this project requires license verification (phone-home) on content access. pub license_verification_enabled: bool, /// AI content tier: handmade, assisted, or generated. pub ai_tier: super::super::AiTier, /// Required disclosure text when ai_tier is assisted. pub ai_disclosure: Option, } /// A git repository tracked on disk, optionally linked to a project. #[derive(Debug, Clone, FromRow, Serialize)] pub struct DbGitRepo { /// Database primary key. pub id: GitRepoId, /// Owning user's ID. pub user_id: UserId, /// Bare repository name (no path separators). pub name: String, /// Linked project (many repos can link to one project). pub project_id: Option, /// When the repo was registered. pub created_at: DateTime, /// Visibility: public, unlisted, or private. pub visibility: super::super::Visibility, /// Short description of the repository (editable via settings). pub description: String, } /// A project row with an aggregated public item count (avoids N+1 queries). #[derive(Debug, Clone, FromRow)] #[allow(dead_code)] // Fields populated by sqlx query, read during type conversion pub struct DbProjectWithItemCount { /// Database primary key. pub id: ProjectId, /// Owning user's ID. pub user_id: UserId, /// URL-safe slug unique per user. pub slug: Slug, /// Display title. pub title: String, /// Optional longer description. pub description: Option, /// Category type. pub project_type: super::super::ProjectType, /// URL to the project's cover image. pub cover_image_url: Option, /// Whether this project is publicly visible. pub is_public: bool, /// When the project was created. pub created_at: DateTime, /// When the project was last modified. pub updated_at: DateTime, /// Number of public items in this project. pub item_count: i64, } /// A tabbed content section within a project. #[derive(Debug, Clone, FromRow, Serialize)] pub struct DbProjectSection { /// Database primary key. pub id: ProjectSectionId, /// Parent project ID. pub project_id: ProjectId, /// Section tab title. pub title: String, /// URL-safe slug (unique per project). pub slug: String, /// Markdown body content. pub body: String, /// Display order among sibling sections. pub sort_order: i32, /// When this section was created. pub created_at: DateTime, /// When this section was last modified. pub updated_at: DateTime, }