refactor(sdk): split hooks, dsr-portal, provider, sync approaching 500 LOC
All four files split into focused sibling modules so every file lands
comfortably under the 300-LOC soft target (hard cap 500):
hooks.ts (474→43) → hooks-core / hooks-dsgvo / hooks-compliance
hooks-rag-security / hooks-ui
dsr-portal.ts (464→129) → dsr-portal-translations / dsr-portal-render
provider.tsx (462→247) → provider-effects / provider-callbacks
sync.ts (435→299) → sync-storage / sync-conflict
Zero behaviour changes. All public APIs remain importable from the
original paths (hooks.ts re-exports every hook, provider.tsx keeps all
named exports, sync.ts preserves StateSyncManager + factory).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo } from 'react'
|
||||
import { useCompliance } from './hooks-core'
|
||||
|
||||
// =============================================================================
|
||||
// RAG HOOKS
|
||||
// =============================================================================
|
||||
|
||||
export function useRAG() {
|
||||
const { rag } = useCompliance()
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
search: rag.search.bind(rag),
|
||||
searchByRegulation: rag.searchByRegulation.bind(rag),
|
||||
searchByArticle: rag.searchByArticle.bind(rag),
|
||||
ask: rag.ask.bind(rag),
|
||||
askAboutRegulation: rag.askAboutRegulation.bind(rag),
|
||||
explainArticle: rag.explainArticle.bind(rag),
|
||||
checkCompliance: rag.checkCompliance.bind(rag),
|
||||
getQuickAnswer: rag.getQuickAnswer.bind(rag),
|
||||
findRelevantArticles: rag.findRelevantArticles.bind(rag),
|
||||
availableRegulations: rag.getAvailableRegulations(),
|
||||
chatHistory: rag.getChatHistory(),
|
||||
clearChatHistory: rag.clearChatHistory.bind(rag),
|
||||
startNewSession: rag.startNewSession.bind(rag),
|
||||
}),
|
||||
[rag]
|
||||
)
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// SECURITY HOOKS
|
||||
// =============================================================================
|
||||
|
||||
export function useSecurity() {
|
||||
const { security, state } = useCompliance()
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
// SBOM
|
||||
sbom: state.sbom,
|
||||
components: security.getComponents(),
|
||||
vulnerableComponents: security.getVulnerableComponents(),
|
||||
licenseSummary: security.getLicenseSummary(),
|
||||
|
||||
// Issues
|
||||
issues: state.securityIssues,
|
||||
openIssues: security.getOpenIssues(),
|
||||
criticalIssues: security.getCriticalIssues(),
|
||||
getIssuesBySeverity: security.getIssuesBySeverity.bind(security),
|
||||
getIssuesByTool: security.getIssuesByTool.bind(security),
|
||||
|
||||
// Backlog
|
||||
backlog: state.securityBacklog,
|
||||
overdueBacklogItems: security.getOverdueBacklogItems(),
|
||||
|
||||
// Scanning
|
||||
startScan: security.startScan.bind(security),
|
||||
getScanResult: security.getScanResult.bind(security),
|
||||
lastScanResult: security.getLastScanResult(),
|
||||
|
||||
// Summary
|
||||
summary: security.getSecuritySummary(),
|
||||
securityScore: security.getSecurityScore(),
|
||||
availableTools: security.getAvailableTools(),
|
||||
}),
|
||||
[security, state]
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user