Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #78 from regulaforensics/stable
Browse files Browse the repository at this point in the history
Stable
  • Loading branch information
aliaksandr-drozd authored Jul 24, 2024
2 parents b1ac7a1 + 744c458 commit ac3b648
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.0.75",
"version": "0.0.76",
"author": "Regula Forensics, Inc.",
"name": "@regulaforensics/document-reader-recipes",
"description": "Document Reader Recipes",
Expand Down
1 change: 1 addition & 0 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './get-image-dimentions'
export * from './convert-generalized-date-to-local.helper'
export * from './merge-statuses.helper'
18 changes: 18 additions & 0 deletions src/helpers/merge-statuses.helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { eCheckResult } from '@regulaforensics/document-reader-typings'


export const mergeStatuses = (checks: eCheckResult[]): eCheckResult => {
let result: eCheckResult = eCheckResult.WAS_NOT_DONE

for (const check of checks) {
if (check === eCheckResult.ERROR) {
return eCheckResult.ERROR
}

if (result === eCheckResult.WAS_NOT_DONE && check === eCheckResult.OK) {
result = eCheckResult.OK
}
}

return result
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
RAuthenticitySecurityCheck,
RAuthenticityTextCheck
} from './models'
import { mergeStatuses } from '@/helpers'


const skipFeatures = [
Expand Down Expand Up @@ -242,14 +243,8 @@ export const getAuthenticityCheckList = (input: ProcessResponse): RAuthenticityC
current.groups[index].checkResult = eCheckResult.ERROR
})

if (current.groups.every(({ checkResult }) => checkResult === eCheckResult.OK)) {
current.checkResult = eCheckResult.OK
} else if (current.groups.some(({ checkResult }) => checkResult === eCheckResult.WAS_NOT_DONE)) {
current.checkResult = eCheckResult.WAS_NOT_DONE
return
} else {
current.checkResult = eCheckResult.ERROR
}
const checkResults = current.groups.map(({ checkResult }) => checkResult)
current.checkResult = mergeStatuses(checkResults)

current.groups.sort((a, b) => a.checkResult - b.checkResult)

Expand Down

0 comments on commit ac3b648

Please sign in to comment.