/** * ComplianceContext — React context + value shape for ComplianceProvider. * * Phase 4: extracted from provider.tsx so the provider module stays under * the file-size cap. */ import { createContext } from 'react' import type { ComplianceClient, DSGVOModule, ComplianceModule, RAGModule, SecurityModule, } from '@breakpilot/compliance-sdk-core' import type { SDKState, SDKAction, SDKStep, CheckpointStatus, SyncState, UseCaseAssessment, Risk, Control, } from '@breakpilot/compliance-sdk-types' // Shared localStorage key prefix for provider persistence. export const SDK_STORAGE_KEY = 'breakpilot-compliance-sdk-state' export interface ComplianceContextValue { // State state: SDKState dispatch: React.Dispatch // Client client: ComplianceClient // Modules dsgvo: DSGVOModule compliance: ComplianceModule rag: RAGModule security: SecurityModule // Navigation currentStep: SDKStep | undefined goToStep: (stepId: string) => void goToNextStep: () => void goToPreviousStep: () => void canGoNext: boolean canGoPrevious: boolean // Progress completionPercentage: number phase1Completion: number phase2Completion: number // Checkpoints validateCheckpoint: (checkpointId: string) => Promise overrideCheckpoint: (checkpointId: string, reason: string) => Promise getCheckpointStatus: (checkpointId: string) => CheckpointStatus | undefined // State Updates updateUseCase: (id: string, data: Partial) => void addRisk: (risk: Risk) => void updateControl: (id: string, data: Partial) => void // Persistence saveState: () => Promise loadState: () => Promise resetState: () => void // Sync syncState: SyncState forceSyncToServer: () => Promise isOnline: boolean // Export exportState: (format: 'json' | 'pdf' | 'zip') => Promise // Command Bar isCommandBarOpen: boolean setCommandBarOpen: (open: boolean) => void // Status isInitialized: boolean isLoading: boolean error: Error | null } export const ComplianceContext = createContext(null) export interface ComplianceProviderProps { children: React.ReactNode apiEndpoint: string apiKey?: string tenantId: string userId?: string enableBackendSync?: boolean onNavigate?: (url: string) => void onError?: (error: Error) => void }