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