Skip to content

Commit

Permalink
Ongoing Monitoring support (#2347)
Browse files Browse the repository at this point in the history
* feat: ongoing monitoring support

* feat: ui changes
  • Loading branch information
tomer-shvadron committed May 6, 2024
1 parent 5f4cac1 commit a6bc032
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export const useAmlBlock = (data: Array<TWorkflowById['context']['aml']>) => {
.addCell({
id: 'header',
type: 'heading',
value: 'Compliance Check Results',
value: 'Sanctions Screening Results',
})
.build()
.concat(amlBlock)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { z } from 'zod';

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

const HitSchema = z.object({
matchedName: z.string().optional().nullable(),
Expand All @@ -26,11 +29,11 @@ export const AmlSchema = z.object({
export type TAml = z.output<typeof AmlSchema>;

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

return {
totalMatches: hits?.length ?? 0,
fullReport: rest,
fullReport: aml,
dateOfCheck: createdAt,
matches:
hits?.map(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FunctionComponent } from 'react';
import { ctw } from '../../../../common/utils/ctw/ctw';
import { IContainerProps } from './interfaces';

import { ctw } from '@/common/utils/ctw/ctw';
import { IContainerProps } from './interfaces';
import { cells } from '@/lib/blocks/create-blocks-typed/create-blocks-typed';

export const Container: FunctionComponent<IContainerProps> = ({ value, id, props }) => {
Expand All @@ -11,6 +11,7 @@ export const Container: FunctionComponent<IContainerProps> = ({ value, id, props
<div
className={ctw(
{
'mt-2 flex justify-between': id === 'title-with-actions',
'mt-6 flex justify-end space-x-4 rounded p-2 text-slate-50': id === 'actions',
rounded: id === 'alerts',
'col-span-full': id === 'alerts' || id === 'header',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { capitalize } from '../../../../../../common/utils/capitalize/capitalize
import { valueOrNA } from '../../../../../../common/utils/value-or-na/value-or-na';
import { useStorageFilesQuery } from '../../../../../../domains/storage/hooks/queries/useStorageFilesQuery/useStorageFilesQuery';
import { TWorkflowById } from '../../../../../../domains/workflows/fetchers';
import { Separator } from '@/common/components/atoms/Separator/Separator';

const motionBadgeProps = {
exit: { opacity: 0, transition: { duration: 0.2 } },
Expand Down Expand Up @@ -51,6 +52,7 @@ export const useKycBlock = ({
if (!results[docIndex]) {
results[docIndex] = [];
}

results[docIndex][pageIndex] = docsData?.shift()?.data;
});
});
Expand Down Expand Up @@ -327,11 +329,6 @@ export const useKycBlock = ({
childWorkflow?.context?.entity?.data?.lastName,
)}`,
})
.addCell({
id: 'actions',
type: 'container',
value: getDecisionStatusOrAction(childWorkflow?.tags),
})
.build()
.flat(1),
})
Expand All @@ -348,6 +345,31 @@ export const useKycBlock = ({
value: createBlocksTyped()
.addBlock()
.addCell(headerCell)
.addCell({
type: 'nodeCell',
value: <Separator className={`my-2`} />,
})
.addCell({
id: 'title-with-actions',
type: 'container',
props: { className: 'mt-2' },
value: createBlocksTyped()
.addBlock()
.addCell({
type: 'heading',
value: 'Identity Verification Results',
props: {
className: 'mt-0',
},
})
.addCell({
type: 'container',
props: { className: 'space-x-4' },
value: getDecisionStatusOrAction(childWorkflow?.tags),
})
.build()
.flat(1),
})
.addCell({
id: 'kyc-block',
type: 'container',
Expand Down Expand Up @@ -417,10 +439,6 @@ export const useKycBlock = ({
.build()
.flat(1),
})
.addCell({
type: 'container',
value: amlBlock,
})
.build()
.flat(1),
})
Expand All @@ -434,6 +452,14 @@ export const useKycBlock = ({
.build()
.flat(1),
})
.addCell({
type: 'nodeCell',
value: <Separator className={`my-2`} />,
})
.addCell({
type: 'container',
value: amlBlock,
})
.build()
.flat(1),
})
Expand Down
2 changes: 1 addition & 1 deletion services/workflows-service/prisma/data-migrations
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class AppLoggerService implements LoggerService, OnModuleDestroy {
if (typeof error === 'string') {
error = new Error(error);
}

this.logger.error(error, { ...this.getLogMetadata(), logData });
}

Expand Down
4 changes: 2 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 @@ -10,8 +10,8 @@ const ActiveMonitoringSchema = z.object({
export const EndUserActiveMonitoringsSchema = z.array(ActiveMonitoringSchema);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ export class IndividualAmlWebhookInput {
@IsNumber()
timestamp!: number;

@ApiProperty({
required: true,
type: String,
})
@IsString()
eventName!: string;

@ApiProperty({
required: false,
type: String,
Expand Down
16 changes: 4 additions & 12 deletions services/workflows-service/src/webhooks/webhooks.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import { BadRequestException } from '@nestjs/common';
import { isObject } from '@ballerine/common';
import { AppLoggerService } from '@/common/app-logger/app-logger.service';

const Webhook = {
AML_INDIVIDUAL_MONITORING_UPDATE: 'aml.individuals.monitoring.update',
} as const;

const EntityType = {
BUSINESS: 'business',
INDIVIDUAL: 'individual',
Expand All @@ -36,26 +32,22 @@ export class WebhooksController {
@VerifyUnifiedApiSignatureDecorator()
async amlHook(
@common.Param() { entityType }: AmlWebhookInput,
@common.Body() { eventName, data }: IndividualAmlWebhookInput,
@common.Body() { data }: IndividualAmlWebhookInput,
) {
if (!(isObject(data) && 'endUserId' in data && data.endUserId)) {
throw new BadRequestException('Missing endUserId');
}

try {
if (entityType === EntityType.INDIVIDUAL) {
if (eventName === Webhook.AML_INDIVIDUAL_MONITORING_UPDATE) {
await this.webhooksService.handleIndividualAmlHit({ endUserId: data.endUserId, data });
} else {
this.logger.error(`Unknown webhook event: ${eventName}`);
throw new BadRequestException('Unknown webhook event');
}
await this.webhooksService.handleIndividualAmlHit({ endUserId: data.endUserId, data });
} else {
this.logger.error(`Unknown entity type: ${entityType}`);

throw new BadRequestException('Unknown entity type');
}
} catch (error) {
this.logger.error('amlHook::', { entityType, eventName, data, error });
this.logger.error('amlHook::', { entityType, data, error });

throw error;
}
Expand Down

0 comments on commit a6bc032

Please sign in to comment.