51 lines
3.1 KiB
TypeScript
51 lines
3.1 KiB
TypeScript
import type { AssessorRepository } from '../persistence/assessor-repository';
|
|
import type { RegulatoryMappingBatchRun, RegulatoryMappingDecision, RegulatoryMappingRun } from './regulatory-mapping';
|
|
import type { AiOverviewRun } from './ai-overview';
|
|
|
|
/**
|
|
* The only Core reads the Compliance Engine performs (AGENTS.md, "Core Engine and engines"). The engine
|
|
* never receives a repository method that writes Core data.
|
|
*/
|
|
export type ComplianceReadPort = Pick<AssessorRepository,
|
|
'getUnifiedResultById' | 'queryUnifiedResults' | 'getProject' | 'listProjects' | 'listAssessments' | 'listProjectScanRuns'>;
|
|
|
|
export function complianceReadPortFrom(repository: ComplianceReadPort): ComplianceReadPort {
|
|
return {
|
|
getUnifiedResultById: (resultProjectionId, projectId) => repository.getUnifiedResultById(resultProjectionId, projectId),
|
|
queryUnifiedResults: query => repository.queryUnifiedResults(query),
|
|
getProject: projectId => repository.getProject(projectId),
|
|
listProjects: () => repository.listProjects(),
|
|
listAssessments: projectId => repository.listAssessments(projectId),
|
|
listProjectScanRuns: projectId => repository.listProjectScanRuns(projectId)
|
|
};
|
|
}
|
|
|
|
/** The engine's project data, delivered beside the Core project export. */
|
|
export interface ComplianceProjectExport {
|
|
regulatoryMappingBatchRuns: RegulatoryMappingBatchRun[];
|
|
/** Mappings and decisions are global and keyed by scanner rule, not by project. */
|
|
regulatoryMappingRuns: RegulatoryMappingRun[];
|
|
regulatoryMappingDecisions: RegulatoryMappingDecision[];
|
|
/** Succeeded AI overview runs of the project (table of migration 025, owned by the engine). */
|
|
aiOverviewRuns: AiOverviewRun[];
|
|
}
|
|
|
|
/** The engine's own storage: mapping runs, accept/reject decisions, batches and AI overview runs. */
|
|
export interface ComplianceStore {
|
|
createAiOverviewRun(run: AiOverviewRun): Promise<AiOverviewRun>;
|
|
updateAiOverviewRun(run: AiOverviewRun): Promise<AiOverviewRun>;
|
|
listAiOverviewRuns(projectId: string, scopeKey?: string): Promise<AiOverviewRun[]>;
|
|
/** Removes runs of a project; the engine prunes runs whose timeslot no longer exists in the Core. */
|
|
deleteAiOverviewRuns(projectId: string, runIds: string[]): Promise<void>;
|
|
getRegulatoryMappingRun(id: string): Promise<RegulatoryMappingRun | null>;
|
|
claimRegulatoryMappingRun(run: RegulatoryMappingRun, forceRegeneration: boolean): Promise<{ run: RegulatoryMappingRun; claimed: boolean }>;
|
|
saveRegulatoryMappingRun(run: RegulatoryMappingRun): Promise<RegulatoryMappingRun>;
|
|
listRegulatoryMappingRuns(): Promise<RegulatoryMappingRun[]>;
|
|
createRegulatoryMappingBatchRun(run: RegulatoryMappingBatchRun): Promise<RegulatoryMappingBatchRun>;
|
|
updateRegulatoryMappingBatchRun(run: RegulatoryMappingBatchRun): Promise<RegulatoryMappingBatchRun>;
|
|
listRegulatoryMappingBatchRuns(projectId: string, scopeKey?: string): Promise<RegulatoryMappingBatchRun[]>;
|
|
createRegulatoryMappingDecision(decision: RegulatoryMappingDecision, expectedLatestDecisionId?: string): Promise<RegulatoryMappingDecision>;
|
|
listRegulatoryMappingDecisions(ruleKey: string): Promise<RegulatoryMappingDecision[]>;
|
|
exportProject(projectId: string): Promise<ComplianceProjectExport>;
|
|
}
|