backbone-pos 0.5.33

Point of sale — cashier session, ticket + multi-tender; orchestrates billing (revenue) + payment (settlement), posts no GL directly
Documentation
//! Auth configuration for PosProfile handlers
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! Implements `ResourcePolicy<PosProfile>` with entity-specific permission
//! string constants. Guard middleware logic lives in backbone-auth.

use backbone_auth::{ResourcePolicy, ResourceAction, PermissionGuard, ServicePermissionGuard};
use async_trait::async_trait;

use crate::application::service::PosProfileService;
use crate::domain::entity::PosProfile;

/// Permission string constants for PosProfile operations.
pub mod permissions {
    pub const LIST:        &str = "pos_profile:list";
    pub const READ:        &str = "pos_profile:read";
    pub const CREATE:      &str = "pos_profile:create";
    pub const UPDATE:      &str = "pos_profile:update";
    pub const DELETE:      &str = "pos_profile:delete";
    pub const RESTORE:     &str = "pos_profile:restore";
    pub const TRASH:       &str = "pos_profile:trash";
    pub const EMPTY_TRASH: &str = "pos_profile:empty_trash";
    pub const BULK_CREATE: &str = "pos_profile:bulk_create";
    pub const UPSERT:      &str = "pos_profile:upsert";
}

/// Resource policy for PosProfile — maps CRUD actions to permission strings.
pub struct PosProfilePolicy;

#[async_trait]
impl ResourcePolicy<PosProfile> for PosProfilePolicy {
    async fn can(
        &self,
        action: ResourceAction,
        _entity: &PosProfile,
        ctx: &backbone_auth::middleware::AuthContext,
    ) -> bool {
        let required = match action {
            ResourceAction::Read | ResourceAction::List => permissions::READ,
            ResourceAction::Create => permissions::CREATE,
            ResourceAction::Update | ResourceAction::Patch => permissions::UPDATE,
            ResourceAction::Delete | ResourceAction::HardDelete => permissions::DELETE,
            ResourceAction::Restore => permissions::RESTORE,
            ResourceAction::Custom(_) => return false,
        };
        ctx.permissions.iter().any(|p| p == required)
    }
}

/// Permission guard for PosProfile handlers.
///
/// Wraps `PosProfileService` and checks `PosProfilePolicy` before delegating.
pub type PosProfileGuard = PermissionGuard<PosProfile>;

/// Service-integrated permission guard for PosProfile (for use in generated handlers).
pub type PosProfileServiceGuard = ServicePermissionGuard<PosProfile, PosProfileService, PosProfilePolicy>;

// <<< CUSTOM
// END CUSTOM