/**
 * Consent Management Service
 *
 * Provides GDPR/SOC2 compliant consent management for the INTENT module.
 * Handles user consent lifecycle including granting, revoking, validation,
 * and audit trail generation.
 *
 * @packageDocumentation
 */
import { CircuitBreakerOpenError } from '../common/circuit-breaker.js';
import type { ID } from '../common/types.js';
export { CircuitBreakerOpenError };
/**
 * Supported consent types for data processing
 */
export type ConsentType = 'data_processing' | 'analytics' | 'marketing';
/**
 * Metadata captured when consent is granted or revoked
 */
export interface ConsentMetadata {
    ipAddress?: string;
    userAgent?: string;
}
/**
 * User consent record (mapped from database row)
 */
export interface UserConsent {
    id: ID;
    userId: ID;
    tenantId: ID;
    consentType: ConsentType;
    granted: boolean;
    grantedAt: string | null;
    revokedAt: string | null;
    version: string;
    ipAddress: string | null;
    userAgent: string | null;
    createdAt: string;
    updatedAt: string;
}
/**
 * Consent policy version record
 */
export interface ConsentPolicy {
    id: ID;
    tenantId: ID;
    consentType: ConsentType;
    version: string;
    content: string;
    effectiveFrom: string;
    effectiveTo: string | null;
    createdAt: string;
}
/**
 * Consent history entry for audit trail
 */
export interface ConsentHistoryEntry {
    id: ID;
    consentType: ConsentType;
    action: 'granted' | 'revoked';
    version: string;
    timestamp: string;
    ipAddress: string | null;
    userAgent: string | null;
}
/**
 * Result of consent validation
 */
export interface ConsentValidationResult {
    valid: boolean;
    consentType: ConsentType;
    grantedAt?: string;
    version?: string;
    reason?: string;
}
/**
 * Error thrown when consent is required but not granted
 */
export declare class ConsentRequiredError extends Error {
    userId: ID;
    tenantId: ID;
    consentType: ConsentType;
    constructor(userId: ID, tenantId: ID, consentType: ConsentType, message?: string);
}
/**
 * Error thrown when consent policy is not found
 */
export declare class ConsentPolicyNotFoundError extends Error {
    tenantId: ID;
    consentType: ConsentType;
    version: string;
    constructor(tenantId: ID, consentType: ConsentType, version: string);
}
/**
 * Consent management service for GDPR/SOC2 compliance
 */
export declare class ConsentService {
    private db;
    constructor(db?: import("drizzle-orm/node-postgres").NodePgDatabase<Record<string, never>>);
    /**
     * Grant consent for a specific consent type
     *
     * Creates a new consent record or updates existing one.
     * Records the policy version and metadata for audit purposes.
     * Protected by circuit breaker to prevent cascading failures.
     *
     * @param userId - The user granting consent
     * @param tenantId - The tenant context
     * @param consentType - Type of consent being granted
     * @param version - Policy version being consented to
     * @param metadata - Optional metadata (IP, user agent)
     * @returns The created or updated consent record
     * @throws CircuitBreakerOpenError if the consent service circuit breaker is open
     */
    grantConsent(userId: ID, tenantId: ID, consentType: ConsentType, version: string, metadata?: ConsentMetadata): Promise<UserConsent>;
    /**
     * Revoke consent for a specific consent type
     *
     * Marks the consent as revoked with a timestamp.
     * Does not delete the record to maintain audit trail.
     * Protected by circuit breaker to prevent cascading failures.
     *
     * @param userId - The user revoking consent
     * @param tenantId - The tenant context
     * @param consentType - Type of consent being revoked
     * @returns The revoked consent record, or null if no active consent found
     * @throws CircuitBreakerOpenError if the consent service circuit breaker is open
     */
    revokeConsent(userId: ID, tenantId: ID, consentType: ConsentType): Promise<UserConsent | null>;
    /**
     * Get all consents for a user within a tenant
     *
     * Returns both active and revoked consents for a complete view.
     *
     * @param userId - The user ID
     * @param tenantId - The tenant context
     * @returns Array of consent records
     */
    getConsents(userId: ID, tenantId: ID): Promise<UserConsent[]>;
    /**
     * Get all active consents for a user within a tenant
     *
     * Returns only currently valid consents.
     *
     * @param userId - The user ID
     * @param tenantId - The tenant context
     * @returns Array of active consent records
     */
    getActiveConsents(userId: ID, tenantId: ID): Promise<UserConsent[]>;
    /**
     * Check if a user has valid consent for a specific type
     *
     * Returns true if consent is granted and not revoked.
     *
     * @param userId - The user ID
     * @param tenantId - The tenant context
     * @param consentType - Type of consent to check
     * @returns True if valid consent exists
     */
    hasValidConsent(userId: ID, tenantId: ID, consentType: ConsentType): Promise<boolean>;
    /**
     * Validate consent and return detailed result
     *
     * Provides detailed validation information for audit purposes.
     * Protected by circuit breaker to prevent cascading failures.
     *
     * @param userId - The user ID
     * @param tenantId - The tenant context
     * @param consentType - Type of consent to validate
     * @returns Detailed validation result
     * @throws CircuitBreakerOpenError if the consent service circuit breaker is open
     */
    validateConsent(userId: ID, tenantId: ID, consentType: ConsentType): Promise<ConsentValidationResult>;
    /**
     * Require valid consent or throw an error
     *
     * Use this for consent gate enforcement in intent processing.
     *
     * @param userId - The user ID
     * @param tenantId - The tenant context
     * @param consentType - Type of consent required
     * @throws ConsentRequiredError if consent is not granted
     */
    requireConsent(userId: ID, tenantId: ID, consentType: ConsentType): Promise<void>;
    /**
     * Get consent history for audit trail
     *
     * Returns chronological history of all consent changes.
     *
     * @param userId - The user ID
     * @param tenantId - The tenant context
     * @returns Array of consent history entries
     */
    getConsentHistory(userId: ID, tenantId: ID): Promise<ConsentHistoryEntry[]>;
    /**
     * Create a new consent policy version
     *
     * @param tenantId - The tenant context
     * @param consentType - Type of consent
     * @param version - Policy version
     * @param content - Policy text content
     * @param effectiveFrom - When the policy becomes effective
     * @returns The created policy record
     */
    createPolicy(tenantId: ID, consentType: ConsentType, version: string, content: string, effectiveFrom?: Date): Promise<ConsentPolicy>;
    /**
     * Get the current effective policy for a consent type
     *
     * @param tenantId - The tenant context
     * @param consentType - Type of consent
     * @returns The current policy or null if none exists
     */
    getCurrentPolicy(tenantId: ID, consentType: ConsentType): Promise<ConsentPolicy | null>;
    /**
     * Get a specific policy version
     *
     * @param tenantId - The tenant context
     * @param consentType - Type of consent
     * @param version - Policy version
     * @returns The policy or null if not found
     */
    getPolicy(tenantId: ID, consentType: ConsentType, version: string): Promise<ConsentPolicy | null>;
    /**
     * Get all policy versions for a consent type
     *
     * @param tenantId - The tenant context
     * @param consentType - Type of consent
     * @returns Array of policy records
     */
    getPolicyHistory(tenantId: ID, consentType: ConsentType): Promise<ConsentPolicy[]>;
    private mapConsentRow;
    private mapPolicyRow;
}
/**
 * Create a new consent service instance
 */
export declare function createConsentService(): ConsentService;
//# sourceMappingURL=consent.d.ts.map