backbone-integrations 0.5.22

Integration registry: connectors, integration accounts and an idempotent inbound event lane, with one OAuth flow (HMAC-bound state, PKCE)
Documentation
//! Repository trait for Example aggregate
//!
//! Generated by backbone-schema. Do not edit manually.
//!
//! This trait defines the persistence contract for the Example aggregate.
//! Implementation lives in the infrastructure layer.

use anyhow::Result;
use async_trait::async_trait;

use crate::domain::entity::{Example, ExampleStatus};
use backbone_core::repository::{DomainPaginationParams, DomainPaginatedResult};

pub type ExamplePaginationParams = DomainPaginationParams;
pub type ExamplePaginatedResult = DomainPaginatedResult<Example>;

/// Filter parameters for list queries
#[derive(Debug, Clone, Default)]
pub struct ExampleFilter {
    pub name: Option<String>,
    pub status: Option<ExampleStatus>,
}

impl ExampleFilter {
    pub fn has_filters(&self) -> bool {
        self.name.is_some() || self.status.is_some()
    }
}

/// Repository trait for Example aggregate.
#[async_trait]
pub trait ExampleRepository: Send + Sync {
    // =========================================================================
    // Core CRUD
    // =========================================================================

    async fn save(&self, entity: &Example) -> Result<Example>;
    async fn find_by_id(&self, id: &str) -> Result<Option<Example>>;
    async fn find_all(&self) -> Result<Vec<Example>>;
    async fn update(&self, id: &str, entity: &Example) -> Result<Option<Example>>;
    async fn delete(&self, id: &str) -> Result<bool>;

    // =========================================================================
    // Pagination
    // =========================================================================

    async fn list(&self, params: ExamplePaginationParams) -> Result<ExamplePaginatedResult>;
    async fn list_with_filters(
        &self,
        params: ExamplePaginationParams,
        filters: ExampleFilter,
    ) -> Result<ExamplePaginatedResult>;
    async fn count(&self) -> Result<u64>;
    async fn count_with_filters(&self, filters: ExampleFilter) -> Result<u64>;
    async fn exists(&self, id: &str) -> Result<bool>;

    // =========================================================================
    // Soft delete
    // =========================================================================

    async fn soft_delete(&self, id: &str) -> Result<bool>;
    async fn restore(&self, id: &str) -> Result<Option<Example>>;
    async fn list_deleted(&self, params: ExamplePaginationParams) -> Result<ExamplePaginatedResult>;
    async fn empty_trash(&self) -> Result<u64>;

    // =========================================================================
    // Bulk operations
    // =========================================================================

    async fn bulk_save(&self, entities: &[Example]) -> Result<Vec<Example>>;
    async fn bulk_delete(&self, ids: &[&str]) -> Result<u64>;
}