RED-7980 - removed pending option

This commit is contained in:
Valentin Mihai 2024-03-08 10:59:52 +02:00
parent aba65ffaf7
commit 2106a069a7
2 changed files with 15 additions and 20 deletions

@ -1 +1 @@
Subproject commit 3ea4e45b87b94868370492c475864390d984f65d
Subproject commit ecf9c8912e366fdcc0a454d112c0f3252245666a

View File

@ -14,25 +14,20 @@ export const SuperTypes = {
export type SuperType = ValuesOf<typeof SuperTypes>;
interface ResolveTypeOptions {
hint: boolean;
pending: boolean;
}
function wrongSuperTypeHandler(): never | undefined {
return undefined;
}
function resolveRedactionType(entry: IEntityLogEntry, options?: Partial<ResolveTypeOptions>) {
if (options?.pending && entry.oldState) {
function resolveRedactionType(entry: IEntityLogEntry, hint = false) {
if (entry.state === EntryStates.PENDING && entry.oldState) {
return SuperTypeMapper[entry.entryType][entry.oldState](entry);
}
const redaction = options?.hint ? SuperTypes.Hint : SuperTypes.Redaction;
const manualRedaction = options?.hint ? SuperTypes.ManualHint : SuperTypes.ManualRedaction;
const redaction = hint ? SuperTypes.Hint : SuperTypes.Redaction;
const manualRedaction = hint ? SuperTypes.ManualHint : SuperTypes.ManualRedaction;
if (!entry.engines.length) {
return options?.pending && entry.dictionaryEntry ? redaction : manualRedaction;
return entry.state === EntryStates.PENDING && entry.dictionaryEntry ? redaction : manualRedaction;
}
return redaction;
}
@ -46,56 +41,56 @@ export const SuperTypeMapper: Record<EntityType, Record<EntryState, (entry: IEnt
[EntryStates.SKIPPED]: () => SuperTypes.Skipped,
[EntryStates.IGNORED]: () => SuperTypes.Skipped,
[EntryStates.REMOVED]: wrongSuperTypeHandler,
[EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }),
[EntryStates.PENDING]: entry => resolveRedactionType(entry),
},
[EntityTypes.HINT]: {
[EntryStates.APPLIED]: wrongSuperTypeHandler,
[EntryStates.SKIPPED]: entry => resolveRedactionType(entry, { hint: true }),
[EntryStates.SKIPPED]: entry => resolveRedactionType(entry, true),
[EntryStates.IGNORED]: () => SuperTypes.IgnoredHint,
[EntryStates.REMOVED]: wrongSuperTypeHandler,
[EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }),
[EntryStates.PENDING]: entry => resolveRedactionType(entry),
},
[EntityTypes.FALSE_POSITIVE]: {
[EntryStates.APPLIED]: wrongSuperTypeHandler,
[EntryStates.SKIPPED]: wrongSuperTypeHandler,
[EntryStates.IGNORED]: wrongSuperTypeHandler,
[EntryStates.REMOVED]: wrongSuperTypeHandler,
[EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }),
[EntryStates.PENDING]: entry => resolveRedactionType(entry),
},
[EntityTypes.RECOMMENDATION]: {
[EntryStates.APPLIED]: wrongSuperTypeHandler,
[EntryStates.SKIPPED]: () => SuperTypes.Recommendation,
[EntryStates.IGNORED]: wrongSuperTypeHandler,
[EntryStates.REMOVED]: wrongSuperTypeHandler,
[EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }),
[EntryStates.PENDING]: entry => resolveRedactionType(entry),
},
[EntityTypes.FALSE_RECOMMENDATION]: {
[EntryStates.APPLIED]: wrongSuperTypeHandler,
[EntryStates.SKIPPED]: wrongSuperTypeHandler,
[EntryStates.IGNORED]: wrongSuperTypeHandler,
[EntryStates.REMOVED]: wrongSuperTypeHandler,
[EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }),
[EntryStates.PENDING]: entry => resolveRedactionType(entry),
},
[EntityTypes.AREA]: {
[EntryStates.APPLIED]: () => SuperTypes.Redaction,
[EntryStates.SKIPPED]: wrongSuperTypeHandler,
[EntryStates.IGNORED]: wrongSuperTypeHandler,
[EntryStates.REMOVED]: wrongSuperTypeHandler,
[EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }),
[EntryStates.PENDING]: entry => resolveRedactionType(entry),
},
[EntityTypes.IMAGE]: {
[EntryStates.APPLIED]: () => SuperTypes.Redaction,
[EntryStates.SKIPPED]: () => SuperTypes.Skipped,
[EntryStates.IGNORED]: () => SuperTypes.Skipped,
[EntryStates.REMOVED]: wrongSuperTypeHandler,
[EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }),
[EntryStates.PENDING]: entry => resolveRedactionType(entry),
},
[EntityTypes.IMAGE_HINT]: {
[EntryStates.APPLIED]: wrongSuperTypeHandler,
[EntryStates.SKIPPED]: () => SuperTypes.Hint,
[EntryStates.IGNORED]: () => SuperTypes.IgnoredHint,
[EntryStates.REMOVED]: wrongSuperTypeHandler,
[EntryStates.PENDING]: entry => resolveRedactionType(entry, { pending: true }),
[EntryStates.PENDING]: entry => resolveRedactionType(entry),
},
};