forked from r.muellner/velum-raycast
fix: send review mapping when applying project documents
This commit is contained in:
@@ -26,7 +26,7 @@ type Hit = {
|
||||
type: string; score: number; context: string; start: number; end: number;
|
||||
kind: "content" | "path";
|
||||
};
|
||||
type Draft = { file: ProjectFile; hash: string; hits: Hit[] };
|
||||
type Draft = { file: ProjectFile; hash: string; hits: Hit[]; analysisMapping?: PlaceholderMapping };
|
||||
type PathDraft = { key: string; value: string; hits: Hit[] };
|
||||
type Preview = { drafts: Draft[]; retained: Array<{ file: ProjectFile; hash: string; output: string; directory: string }>;
|
||||
paths: PathDraft[]; mapping: PlaceholderMapping; previousMapping: PlaceholderMapping;
|
||||
@@ -157,6 +157,7 @@ async function prepare(root: string, files: ProjectFile[], rules: ProjectRule[],
|
||||
onProgress(`Dokumente analysieren: ${index + 1}/${documents.length}`);
|
||||
const data = await fs.readFile(draft.file.absPath);
|
||||
try {
|
||||
draft.analysisMapping = mapping;
|
||||
const result = await pseudonymizeDocument(basename(draft.file.relPath), data, mapping, masks, undefined, entityTypes);
|
||||
mapping = result.mapping;
|
||||
addHits(draft, documentHits(draft.file, result.hits));
|
||||
@@ -364,7 +365,7 @@ function HitReview(props: { root: string; rules: ProjectRule[]; whitelist: Proje
|
||||
let result;
|
||||
try {
|
||||
result = await pseudonymizeDocument(basename(draft.file.relPath), data, run.mapping,
|
||||
masks, docIds, props.preview.entityTypes);
|
||||
masks, docIds, props.preview.entityTypes, draft.analysisMapping);
|
||||
} catch (error) {
|
||||
if (!/\b409\b/.test((error as Error).message) || !/Treffer passen nicht mehr/.test((error as Error).message)) {
|
||||
throw error;
|
||||
@@ -375,7 +376,7 @@ function HitReview(props: { root: string; rules: ProjectRule[]; whitelist: Proje
|
||||
if (!ids) throw new Error(`${draft.file.relPath}: Erkennungen haben sich seit der Prüfung geändert. Bitte Treffer erneut prüfen.`);
|
||||
docIds = ids;
|
||||
result = await pseudonymizeDocument(basename(draft.file.relPath), data, run.mapping,
|
||||
masks, docIds, props.preview.entityTypes);
|
||||
masks, docIds, props.preview.entityTypes, run.mapping);
|
||||
}
|
||||
const selectedIds = new Set(docIds);
|
||||
const selectedHits = result.hits.filter((hit) => selectedIds.has(hit.id));
|
||||
|
||||
Reference in New Issue
Block a user