Skip to content

Commit

Permalink
Integrate with Dow Jones (#2483)
Browse files Browse the repository at this point in the history
* feat: support for dow-jones

* fix: pr comments
  • Loading branch information
MatanYadaev committed Jul 15, 2024
1 parent 156fc0d commit 5c2eafc
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 40 deletions.
18 changes: 10 additions & 8 deletions apps/backoffice-v2/src/lib/blocks/components/AmlBlock/AmlMatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ interface IAmlMatchProps {
sanctions: THit['sanctions'];
adverseMedia: THit['adverseMedia'];
fitnessProbity: THit['fitnessProbity'];
other: THit['other'];
};
}

export const AmlMatch = ({ match }: IAmlMatchProps) => {
const orderedTypes = useMemo(
() => [
{ key: 'pep', accessor: 'person', header: 'PEP' },
{ key: 'warnings', accessor: 'warning', header: 'Warnings' },
{ key: 'sanctions', accessor: 'sanction', header: 'Sanctions' },
{ key: 'adverseMedia', accessor: 'entry', header: 'Adverse Media' },
{ key: 'fitnessProbity', accessor: 'entry', header: 'Fitness Probity' },
{ key: 'pep', header: 'PEP' },
{ key: 'warnings', header: 'Warnings' },
{ key: 'sanctions', header: 'Sanctions' },
{ key: 'adverseMedia', header: 'Adverse Media' },
{ key: 'fitnessProbity', header: 'Fitness Probity' },
{ key: 'other', header: 'Other' },
],
[],
);
Expand All @@ -39,18 +41,18 @@ export const AmlMatch = ({ match }: IAmlMatchProps) => {
<div key={`${type.key}-${index}`} className={`flex gap-x-10 px-4`}>
<span className={`w-[150px] text-left`}>{type.header}</span>
<TextWithNAFallback className={`w-full text-left`}>
{item[type.accessor]}
{item.sourceName}
</TextWithNAFallback>
<TextWithNAFallback className={`w-[150px] text-left`}>
{item.source && (
{item.sourceUrl && (
<a
className={buttonVariants({
variant: 'link',
className: 'h-[unset] cursor-pointer !p-0 !text-blue-500',
})}
target={'_blank'}
rel={'noopener noreferrer'}
href={item.source}
href={item.sourceUrl}
>
Link
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ export const useAmlBlock = (data: Array<TWorkflowById['context']['aml']>) => {
},
header: 'Fitness Probity',
}),
columnHelper.accessor('other', {
cell: info => {
return <TextWithNAFallback>{info.getValue().length}</TextWithNAFallback>;
},
header: 'Other',
}),
],
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { z } from 'zod';

const SourceInfoSchema = z
.object({
type: z.string().optional().nullable(),
sourceName: z.string().optional().nullable(),
sourceUrl: z.string().optional().nullable(),
date: z.string().optional().nullable(),
Expand All @@ -20,6 +21,7 @@ export const HitSchema = z.object({
pep: z.array(SourceInfoSchema).optional().nullable(),
adverseMedia: z.array(SourceInfoSchema).optional().nullable(),
fitnessProbity: z.array(SourceInfoSchema).optional().nullable(),
other: z.array(SourceInfoSchema).optional().nullable(),
});

export type THit = z.infer<typeof HitSchema>;
Expand All @@ -31,6 +33,14 @@ export const AmlSchema = z.object({

export type TAml = z.infer<typeof AmlSchema>;

const getEntryFromSource = (sourceInfo: z.infer<typeof SourceInfoSchema>) => {
return {
date: sourceInfo?.date,
sourceName: [sourceInfo?.sourceName, sourceInfo?.type].filter(Boolean).join(' - '),
sourceUrl: sourceInfo?.sourceUrl,
};
};

export const amlAdapter = (aml: TAml) => {
const { hits, createdAt } = aml;

Expand All @@ -51,42 +61,20 @@ export const amlAdapter = (aml: TAml) => {
pep,
adverseMedia,
fitnessProbity,
other,
}) => ({
matchedName,
dateOfBirth,
countries: countries?.join(', ') ?? '',
matchTypes: matchTypes?.join(', ') ?? '',
aka: aka?.join(', ') ?? '',
sanctions:
sanctions?.filter(Boolean).map(sanction => ({
sanction: sanction?.sourceName,
date: sanction?.date,
source: sanction?.sourceUrl,
})) ?? [],
warnings:
warnings?.filter(Boolean).map(warning => ({
warning: warning?.sourceName,
date: warning?.date,
source: warning?.sourceUrl,
})) ?? [],
pep:
pep?.filter(Boolean).map(pepItem => ({
person: pepItem?.sourceName,
date: pepItem?.date,
source: pepItem?.sourceUrl,
})) ?? [],
adverseMedia:
adverseMedia?.filter(Boolean).map(adverseMediaItem => ({
entry: adverseMediaItem?.sourceName,
date: adverseMediaItem?.date,
source: adverseMediaItem?.sourceUrl,
})) ?? [],
sanctions: sanctions?.filter(Boolean).map(item => getEntryFromSource(item)) ?? [],
warnings: warnings?.filter(Boolean).map(item => getEntryFromSource(item)) ?? [],
pep: pep?.filter(Boolean).map(item => getEntryFromSource(item)) ?? [],
adverseMedia: adverseMedia?.filter(Boolean).map(item => getEntryFromSource(item)) ?? [],
fitnessProbity:
fitnessProbity?.filter(Boolean).map(fitnessProbityItem => ({
entry: fitnessProbityItem?.sourceName,
date: fitnessProbityItem?.date,
source: fitnessProbityItem?.sourceUrl,
})) ?? [],
fitnessProbity?.filter(Boolean).map(item => getEntryFromSource(item)) ?? [],
other: other?.filter(Boolean).map(item => getEntryFromSource(item)) ?? [],
}),
) ?? [],
};
Expand Down
2 changes: 1 addition & 1 deletion services/workflows-service/prisma/data-migrations
7 changes: 7 additions & 0 deletions services/workflows-service/scripts/generate-end-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ export const generateEndUser = ({
sourceUrl: faker.internet.url(),
},
],
other: [
{
date: faker.date.recent(2).toISOString(),
sourceName: faker.company.name(),
sourceUrl: faker.internet.url(),
},
],
matchTypes: ['PEP'],
} satisfies z.infer<typeof EndUserAmlHitsSchema>[number]),
),
Expand Down
6 changes: 4 additions & 2 deletions services/workflows-service/src/end-user/end-user.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@ import { z } from 'zod';

const ActiveMonitoringSchema = z.object({
type: z.literal('aml'),
vendor: z.enum(['veriff', 'test']),
vendor: z.enum(['veriff', 'test', 'dow-jones']),
monitoredUntil: z.string().datetime(),
sessionId: z.string(),
});

export const EndUserActiveMonitoringsSchema = z.array(ActiveMonitoringSchema);

const SourceSchema = z.object({
type: z.string().nullable().optional(),
sourceName: z.string().nullable().optional(),
sourceUrl: z.string().url().nullable().optional(),
date: z.string().nullable().optional(),
});

const AmlHitSchema = z.object({
vendor: z.enum(['veriff', 'test']),
vendor: z.enum(['veriff', 'test', 'dow-jones']),
matchedName: z.string(),
countries: z.array(z.string()),
matchTypes: z.array(z.string()),
Expand All @@ -25,6 +26,7 @@ const AmlHitSchema = z.object({
fitnessProbity: z.array(SourceSchema),
pep: z.array(SourceSchema),
adverseMedia: z.array(SourceSchema),
other: z.array(SourceSchema).optional(),
});

export const EndUserAmlHitsSchema = z.array(AmlHitSchema);

0 comments on commit 5c2eafc

Please sign in to comment.