import { Queue } from 'bullmq';
import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
import type { Redis } from 'ioredis';
import { type Config } from '../common/config.js';
import { type AuditService } from '../audit/index.js';
import type { ID } from '../common/types.js';
/**
 * Dependencies for GdprService
 *
 * Use these to inject dependencies for testing or custom configurations.
 * If not provided, defaults to global singletons for backward compatibility.
 */
export interface GdprServiceDependencies {
    /** Drizzle database instance */
    database?: NodePgDatabase;
    /** Redis client instance */
    redis?: Redis;
    /** Application configuration */
    config?: Config;
    /** Audit service instance */
    auditService?: AuditService;
}
export type GdprExportStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'expired';
export interface GdprExportRequest {
    id: ID;
    userId: ID;
    tenantId: ID;
    status: GdprExportStatus;
    requestedAt: string;
    completedAt?: string;
    expiresAt?: string;
    downloadUrl?: string;
    error?: string;
    metadata?: Record<string, unknown>;
}
export interface GdprExportData {
    exportId: ID;
    userId: ID;
    tenantId: ID;
    exportTimestamp: string;
    dataCategories: string[];
    retentionPeriods: Record<string, string>;
    data: {
        intents: GdprIntentData[];
        events: GdprEventData[];
        escalations: GdprEscalationData[];
        auditRecords: GdprAuditData[];
    };
    metadata: {
        totalRecords: number;
        exportVersion: string;
        gdprArticle: string;
    };
}
export interface GdprIntentData {
    id: ID;
    goal: string;
    intentType: string | null;
    status: string;
    context: Record<string, unknown>;
    metadata: Record<string, unknown>;
    createdAt: string;
    updatedAt: string;
    deletedAt?: string | null;
}
export interface GdprEventData {
    id: ID;
    intentId: ID;
    eventType: string;
    payload: Record<string, unknown>;
    occurredAt: string;
}
export interface GdprEscalationData {
    id: ID;
    intentId: ID;
    reason: string;
    reasonCategory: string;
    escalatedTo: string;
    status: string;
    createdAt: string;
    resolvedAt?: string | null;
}
export interface GdprAuditData {
    id: ID;
    eventType: string;
    action: string;
    outcome: string;
    eventTime: string;
    metadata?: Record<string, unknown>;
}
export interface GdprErasureResult {
    userId: ID;
    tenantId: ID;
    erasedAt: string;
    counts: {
        intents: number;
        events: number;
        escalations: number;
    };
}
/**
 * GDPR Service for data export and erasure
 */
export declare class GdprService {
    private db;
    private redis;
    private config;
    private auditService;
    private auditHelper;
    private readonly cachePrefix;
    private readonly exportTtlSeconds;
    /**
     * Create a new GdprService instance.
     *
     * @param deps - Optional dependencies for dependency injection.
     *               If not provided, uses global singletons (backward compatible).
     *
     * @example
     * // Default usage (backward compatible)
     * const service = new GdprService();
     *
     * @example
     * // With dependency injection (for testing)
     * const service = new GdprService({
     *   database: mockDb,
     *   redis: mockRedis,
     *   config: testConfig,
     *   auditService: mockAuditService,
     * });
     */
    constructor(deps?: GdprServiceDependencies);
    /**
     * Export all user data for GDPR compliance (Article 15 - Right of Access)
     * Uses extended statement timeout for complex multi-table queries.
     * Protected by circuit breaker to prevent cascading failures.
     *
     * @param userId - The user/entity ID to export data for
     * @param tenantId - The tenant context
     * @returns Complete export data structure
     * @throws StatementTimeoutError if the query exceeds the long query timeout
     * @throws CircuitBreakerOpenError if the GDPR service circuit breaker is open
     */
    exportUserData(userId: ID, tenantId: ID): Promise<GdprExportData>;
    /**
     * Create an async export request (queues the export job)
     *
     * @param userId - The user/entity ID to export data for
     * @param tenantId - The tenant context
     * @param requestedBy - User who initiated the request
     * @returns Export request record
     */
    createExportRequest(userId: ID, tenantId: ID, requestedBy: ID): Promise<GdprExportRequest>;
    /**
     * Get export request status
     *
     * @param requestId - The export request ID
     * @param tenantId - The tenant context for validation
     * @returns Export request or null if not found/expired
     */
    getExportRequest(requestId: ID, tenantId: ID): Promise<GdprExportRequest | null>;
    /**
     * Update export request status
     *
     * @param requestId - The export request ID
     * @param updates - Fields to update
     */
    updateExportRequest(requestId: ID, updates: Partial<GdprExportRequest>): Promise<GdprExportRequest | null>;
    /**
     * Store completed export data
     *
     * @param requestId - The export request ID
     * @param data - The export data
     */
    storeExportData(requestId: ID, data: GdprExportData): Promise<string>;
    /**
     * Get stored export data for download
     *
     * @param requestId - The export request ID
     * @param tenantId - The tenant context for validation
     * @returns Export data or null if not found/expired
     */
    getExportData(requestId: ID, tenantId: ID): Promise<GdprExportData | null>;
    /**
     * Soft delete all user data (Article 17 - Right to Erasure)
     * Protected by circuit breaker to prevent cascading failures.
     *
     * @param userId - The user/entity ID to erase data for
     * @param tenantId - The tenant context
     * @param erasedBy - User who initiated the erasure
     * @returns Erasure result with counts
     * @throws CircuitBreakerOpenError if the GDPR service circuit breaker is open
     */
    eraseUserData(userId: ID, tenantId: ID, erasedBy: ID): Promise<GdprErasureResult>;
}
/**
 * Get or create the GDPR export queue
 */
export declare function getGdprExportQueue(): Queue;
/**
 * Enqueue a GDPR export job
 *
 * @param requestId - The export request ID
 * @param userId - The user to export data for
 * @param tenantId - The tenant context
 */
export declare function enqueueGdprExport(requestId: ID, userId: ID, tenantId: ID): Promise<void>;
/**
 * Register GDPR export worker
 */
export declare function registerGdprWorker(): void;
/**
 * Shutdown GDPR export worker
 */
export declare function shutdownGdprWorker(): Promise<void>;
/**
 * Create a new GDPR service instance with dependency injection.
 *
 * This is the preferred way to create services in production code
 * as it makes dependencies explicit and testable.
 *
 * @param deps - Optional dependencies. If not provided, uses global singletons.
 * @returns Configured GdprService instance
 *
 * @example
 * // Default usage (backward compatible)
 * const service = createGdprService();
 *
 * @example
 * // With custom dependencies
 * const service = createGdprService({
 *   database: customDb,
 *   redis: customRedis,
 *   config: customConfig,
 * });
 */
export declare function createGdprService(deps?: GdprServiceDependencies): GdprService;
//# sourceMappingURL=gdpr.d.ts.map