Skip to content

Commit

Permalink
Bal 3035 (#2986)
Browse files Browse the repository at this point in the history
* feat: added request payload and plugins input

* feat: reorganized files

* feat: added rendering of merchant screening input to backoffice

* feat: implemented whitelist & updated tests

* feat: invokedAt is now can be disbabled

* feat: workflow-core bump

* fix: clean

* chore(*): updated workflow-core

---------

Co-authored-by: Omri Levy <[email protected]>
  • Loading branch information
chesterkmr and Omri-Levy authored Jan 23, 2025
1 parent aa53dd4 commit d02335d
Show file tree
Hide file tree
Showing 38 changed files with 781 additions and 120 deletions.
9 changes: 9 additions & 0 deletions apps/backoffice-v2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @ballerine/backoffice-v2

## 0.7.97

### Patch Changes

- Updated dependencies
- @ballerine/common@0.9.70
- @ballerine/workflow-browser-sdk@0.6.89
- @ballerine/workflow-node-sdk@0.6.89

## 0.7.96

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions apps/backoffice-v2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ballerine/backoffice-v2",
"version": "0.7.96",
"version": "0.7.97",
"description": "Ballerine - Backoffice",
"homepage": "https://github.com/ballerine-io/ballerine",
"type": "module",
Expand Down Expand Up @@ -53,9 +53,9 @@
},
"dependencies": {
"@ballerine/blocks": "0.2.34",
"@ballerine/common": "0.9.69",
"@ballerine/workflow-browser-sdk": "0.6.88",
"@ballerine/workflow-node-sdk": "0.6.88",
"@ballerine/common": "0.9.70",
"@ballerine/workflow-browser-sdk": "0.6.89",
"@ballerine/workflow-node-sdk": "0.6.89",
"@ballerine/react-pdf-toolkit": "^1.2.67",
"@ballerine/ui": "^0.5.67",
"@botpress/webchat": "^2.1.10",
Expand Down
11 changes: 11 additions & 0 deletions apps/backoffice-v2/src/domains/workflows/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@ export const BaseWorkflowByIdSchema = z.object({
})
.passthrough()
.optional(),
pluginsInput: z
.object({
merchantScreening: z
.object({
requestPayload: z.record(z.string(), z.unknown()).optional(),
})
.passthrough()
.optional(),
})
.passthrough()
.optional(),
metadata: z
.object({
collectionFlowUrl: z.string().url().optional(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const CallToActionLegacy: FunctionComponent<ICallToActionLegacyProps> = (
isLoadingReuploadNeeded,
onDialogClose,
id,
directorId,
workflow,
decision,
disabled,
Expand Down Expand Up @@ -263,6 +264,7 @@ export const CallToActionLegacy: FunctionComponent<ICallToActionLegacyProps> = (
)}
onClick={onReuploadNeeded({
workflowId: workflow?.id,
directorId,
documentId: id,
reason: comment ? `${reason} - ${comment}` : reason,
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface ICallToActionLegacyProps {
text: string;
props: {
id: string;
directorId?: string;
workflow: TWorkflowById;
disabled: boolean;
decision: 'reject' | 'approve' | 'revision' | 'revised';
Expand All @@ -15,10 +16,12 @@ export interface ICallToActionLegacyProps {
onReuploadReset?: () => void;
onReuploadNeeded: ({
workflowId,
directorId,
documentId,
reason,
}: {
workflowId: string;
directorId?: string;
documentId: string;
reason?: string;
}) => () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export const useDirectorBlock = ({
revisionReasons: getRevisionReasonsForDocument(document, revisionReasons),
disabled: (!isDoneWithRevision && Boolean(document.decision?.status)) || noAction,
decision: 'reject',
directorId: director.id,
id: document.id,
contextUpdateMethod: 'director',
workflow,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { createColumnHelper } from '@tanstack/react-table';
import { Button } from '@/common/components/atoms/Button/Button';
import { ChevronDown } from 'lucide-react';
import { ctw } from '@/common/utils/ctw/ctw';
import { JsonDialog, TextWithNAFallback, WarningFilledSvg } from '@ballerine/ui';
import { IndicatorCircle } from '@/common/components/atoms/IndicatorCircle/IndicatorCircle';
import React from 'react';
import { ctw } from '@/common/utils/ctw/ctw';
import { IMerchantScreening } from '@/lib/blocks/hooks/useMerchantScreeningBlock/interfaces';
import { isObject, MatchReasonCode } from '@ballerine/common';
import { JsonDialog, TextWithNAFallback, WarningFilledSvg } from '@ballerine/ui';
import { createColumnHelper } from '@tanstack/react-table';
import { ChevronDown } from 'lucide-react';

const columnHelper = createColumnHelper<IMerchantScreening>();

Expand All @@ -15,6 +14,7 @@ const summaryColumnHelper = createColumnHelper<{
numberOfInquiries: number;
checkDate: string;
fullJsonData: string;
merchantScreeningInput: Record<PropertyKey, unknown>;
}>();

export const terminatedMatchedMerchantsColumns = [
Expand Down Expand Up @@ -123,8 +123,28 @@ export const terminatedMatchedMerchantsSummaryColumns = [
return <TextWithNAFallback>{checkDate}</TextWithNAFallback>;
},
}),
summaryColumnHelper.accessor('merchantScreeningInput', {
header: 'Checked Properties',
cell: info => {
const fullJsonData = info.getValue();

return (
<div className={`flex items-end justify-start`}>
<JsonDialog
buttonProps={{
variant: 'link',
className: 'p-0 text-blue-500',
disabled: !isObject(fullJsonData) && !Array.isArray(fullJsonData),
}}
dialogButtonText={`View`}
json={JSON.stringify(fullJsonData)}
/>
</div>
);
},
}),
summaryColumnHelper.accessor('fullJsonData', {
header: 'Full JSON Data',
header: 'Results',
cell: info => {
const fullJsonData = info.getValue();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
import React, { useMemo } from 'react';
import { createBlocksTyped } from '@/lib/blocks/create-blocks-typed/create-blocks-typed';
import { IndicatorCircle } from '@/common/components/atoms/IndicatorCircle/IndicatorCircle';
import { ReadOnlyDetail } from '@/common/components/atoms/ReadOnlyDetail/ReadOnlyDetail';
import { createBlocksTyped } from '@/lib/blocks/create-blocks-typed/create-blocks-typed';
import { useMemo } from 'react';

import { IMerchantScreening } from '@/lib/blocks/hooks/useMerchantScreeningBlock/interfaces';
import { ctw } from '@/common/utils/ctw/ctw';
import {
inquiredMatchedMerchantsColumns,
terminatedMatchedMerchantsColumns,
terminatedMatchedMerchantsSummaryColumns,
} from '@/lib/blocks/hooks/useMerchantScreeningBlock/columns';
import { toTitleCase } from 'string-ts';
import { formatValue } from '@/lib/blocks/hooks/useMerchantScreeningBlock/format-value';
import { IMerchantScreening } from '@/lib/blocks/hooks/useMerchantScreeningBlock/interfaces';
import { isObject, safeEvery } from '@ballerine/common';
import { ctw } from '@/common/utils/ctw/ctw';
import { JsonDialog } from '@ballerine/ui';
import { toTitleCase } from 'string-ts';

export const useMerchantScreeningBlock = ({
terminatedMatchedMerchants,
inquiredMatchedMerchants,
merchantScreeningInput,
logoUrl = 'https://cdn.ballerine.io/logos/Mastercard%20logo.svg',
rawData,
checkDate,
}: {
terminatedMatchedMerchants: IMerchantScreening[];
inquiredMatchedMerchants: IMerchantScreening[];
merchantScreeningInput: Record<PropertyKey, unknown>;
logoUrl: string;
rawData: Record<PropertyKey, unknown>;
checkDate: string;
Expand Down Expand Up @@ -73,6 +75,7 @@ export const useMerchantScreeningBlock = ({
terminatedMatches: terminatedMatchedMerchants?.length ?? 0,
numberOfInquiries: inquiredMatchedMerchants?.length ?? 0,
checkDate,
merchantScreeningInput: merchantScreeningInput ?? {},
fullJsonData: rawData ?? {},
},
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import { MotionButton } from '@/common/components/molecules/MotionButton/MotionButton';
import { useSearchParamsByEntity } from '@/common/hooks/useSearchParamsByEntity/useSearchParamsByEntity';
import { ctw } from '@/common/utils/ctw/ctw';
import { omitPropsFromObjectWhitelist } from '@/common/utils/omit-props-from-object-whitelist/omit-props-from-object-whitelist';
import { useAuthenticatedUserQuery } from '@/domains/auth/hooks/queries/useAuthenticatedUserQuery/useAuthenticatedUserQuery';
import { useRevisionTaskByIdMutation } from '@/domains/entities/hooks/mutations/useRevisionTaskByIdMutation/useRevisionTaskByIdMutation';
import { useStorageFilesQuery } from '@/domains/storage/hooks/queries/useStorageFilesQuery/useStorageFilesQuery';
import { TWorkflowById } from '@/domains/workflows/fetchers';
import { useEventMutation } from '@/domains/workflows/hooks/mutations/useEventMutation/useEventMutation';
import { useAmlBlock } from '@/lib/blocks/components/AmlBlock/hooks/useAmlBlock/useAmlBlock';
import { createBlocksTyped } from '@/lib/blocks/create-blocks-typed/create-blocks-typed';
import { useAddressBlock } from '@/lib/blocks/hooks/useAddressBlock/useAddressBlock';
import { useAssociatedCompaniesInformationBlock } from '@/lib/blocks/hooks/useAssociatedCompaniesInformationBlock/useAssociatedCompaniesInformationBlock';
import { associatedCompanyAdapter } from '@/lib/blocks/hooks/useAssosciatedCompaniesBlock/associated-company-adapter';
import { associatedCompanyToWorkflowAdapter } from '@/lib/blocks/hooks/useAssosciatedCompaniesBlock/associated-company-to-workflow-adapter';
import {
motionButtonProps,
useAssociatedCompaniesBlock,
} from '@/lib/blocks/hooks/useAssosciatedCompaniesBlock/useAssociatedCompaniesBlock';
import { useBankingDetailsBlock } from '@/lib/blocks/hooks/useBankingDetailsBlock/useBankingDetailsBlock';
import { useCaseInfoBlock } from '@/lib/blocks/hooks/useCaseInfoBlock/useCaseInfoBlock';
import { useCaseOverviewBlock } from '@/lib/blocks/hooks/useCaseOverviewBlock/useCaseOverviewBlock';
import { useCompanySanctionsBlock } from '@/lib/blocks/hooks/useCompanySanctionsBlock/useCompanySanctionsBlock';
import { useDirectorsRegistryProvidedBlock } from '@/lib/blocks/hooks/useDirectorsRegistryProvidedBlock/useDirectorsRegistryProvidedBlock';
import { useDirectorsUserProvidedBlock } from '@/lib/blocks/hooks/useDirectorsUserProvidedBlock/useDirectorsUserProvidedBlock';
Expand All @@ -23,6 +31,8 @@ import { useKybRegistryInfoBlock } from '@/lib/blocks/hooks/useKybRegistryInfoBl
import { useMainContactBlock } from '@/lib/blocks/hooks/useMainContactBlock/useMainContactBlock';
import { useMainRepresentativeBlock } from '@/lib/blocks/hooks/useMainRepresentativeBlock/useMainRepresentativeBlock';
import { useMapBlock } from '@/lib/blocks/hooks/useMapBlock/useMapBlock';
import { useMerchantScreeningBlock } from '@/lib/blocks/hooks/useMerchantScreeningBlock/useMerchantScreeningBlock';
import { useObjectEntriesBlock } from '@/lib/blocks/hooks/useObjectEntriesBlock/useObjectEntriesBlock';
import { useProcessingDetailsBlock } from '@/lib/blocks/hooks/useProcessingDetailsBlock/useProcessingDetailsBlock';
import { useRegistryInfoBlock } from '@/lib/blocks/hooks/useRegistryInfoBlock/useRegistryInfoBlock';
import { useStoreInfoBlock } from '@/lib/blocks/hooks/useStoreInfoBlock/useStoreInfoBlock';
Expand All @@ -31,36 +41,24 @@ import { useUbosUserProvidedBlock } from '@/lib/blocks/hooks/useUbosUserProvided
import { useWebsiteBasicRequirementBlock } from '@/lib/blocks/hooks/useWebsiteBasicRequirementBlock/useWebsiteBasicRequirementBlock';
import { useWebsiteMonitoringBlock } from '@/lib/blocks/hooks/useWebsiteMonitoringBlock/useWebsiteMonitoringBlock';
import { useCaseBlocks } from '@/lib/blocks/variants/DefaultBlocks/hooks/useCaseBlocksLogic/useCaseBlocks';
import { useWebsiteMonitoringReportBlock } from '@/lib/blocks/variants/WebsiteMonitoringBlocks/hooks/useWebsiteMonitoringReportBlock/useWebsiteMonitoringReportBlock';
import { useCaseDecision } from '@/pages/Entity/components/Case/hooks/useCaseDecision/useCaseDecision';
import { useCaseState } from '@/pages/Entity/components/Case/hooks/useCaseState/useCaseState';
import { getAddressDeep } from '@/pages/Entity/hooks/useEntityLogic/utils/get-address-deep/get-address-deep';
import { selectDirectorsDocuments } from '@/pages/Entity/selectors/selectDirectorsDocuments';
import { Send } from 'lucide-react';
import { useMemo } from 'react';
import { useWebsiteMonitoringReportBlock } from '@/lib/blocks/variants/WebsiteMonitoringBlocks/hooks/useWebsiteMonitoringReportBlock/useWebsiteMonitoringReportBlock';
import { createBlocksTyped } from '@/lib/blocks/create-blocks-typed/create-blocks-typed';
import { useAddressBlock } from '@/lib/blocks/hooks/useAddressBlock/useAddressBlock';
import { getAddressDeep } from '@/pages/Entity/hooks/useEntityLogic/utils/get-address-deep/get-address-deep';
import { useCaseOverviewBlock } from '@/lib/blocks/hooks/useCaseOverviewBlock/useCaseOverviewBlock';
import { useSearchParamsByEntity } from '@/common/hooks/useSearchParamsByEntity/useSearchParamsByEntity';
import { useCallback, useMemo } from 'react';
import { useLocation } from 'react-router-dom';
import { omitPropsFromObjectWhitelist } from '@/common/utils/omit-props-from-object-whitelist/omit-props-from-object-whitelist';
import { useObjectEntriesBlock } from '@/lib/blocks/hooks/useObjectEntriesBlock/useObjectEntriesBlock';
import { useAmlBlock } from '@/lib/blocks/components/AmlBlock/hooks/useAmlBlock/useAmlBlock';
import { associatedCompanyToWorkflowAdapter } from '@/lib/blocks/hooks/useAssosciatedCompaniesBlock/associated-company-to-workflow-adapter';
import { useMerchantScreeningBlock } from '@/lib/blocks/hooks/useMerchantScreeningBlock/useMerchantScreeningBlock';
import { TWorkflowById } from '@/domains/workflows/fetchers';

const registryInfoWhitelist = ['open_corporates'] as const;

import { Button } from '@ballerine/ui';
import { useManageUbosBlock } from '@/lib/blocks/hooks/useManageUbosBlock/useManageUbosBlock';
import { useCurrentCaseQuery } from '@/pages/Entity/hooks/useCurrentCaseQuery/useCurrentCaseQuery';
import { Button } from '@ballerine/ui';
import { toast } from 'sonner';
import { useCallback } from 'react';
import { useManageUbosBlock } from '@/lib/blocks/hooks/useManageUbosBlock/useManageUbosBlock';
import { useRemoveDecisionTaskByIdMutation } from '@/domains/entities/hooks/mutations/useRemoveDecisionTaskByIdMutation/useRemoveDecisionTaskByIdMutation';
import { useApproveTaskByIdMutation } from '@/domains/entities/hooks/mutations/useApproveTaskByIdMutation/useApproveTaskByIdMutation';
import { createDirectorsBlocks } from '@/lib/blocks/components/DirectorBlock/hooks/useDirectorBlock/create-directors-blocks';
import { directorAdapter } from '@/lib/blocks/components/DirectorBlock/hooks/useDirectorBlock/helpers';
import { createDirectorsBlocks } from '@/lib/blocks/components/DirectorBlock/hooks/useDirectorBlock/create-directors-blocks';

const registryInfoWhitelist = ['open_corporates'] as const;

export const useDefaultBlocksLogic = () => {
const [{ activeTab }] = useSearchParamsByEntity();
Expand Down Expand Up @@ -505,6 +503,8 @@ export const useDefaultBlocksLogic = () => {
inquiredMatchedMerchants:
workflow?.context?.pluginsOutput?.merchantScreening?.processed?.inquiredMatchedMerchants ??
[],
merchantScreeningInput:
workflow?.context?.pluginsInput?.merchantScreening?.requestPayload || {},
logoUrl: workflow?.context?.pluginsOutput?.merchantScreening?.logoUrl,
rawData: workflow?.context?.pluginsOutput?.merchantScreening?.raw,
checkDate: workflow?.context?.pluginsOutput?.merchantScreening?.processed?.checkDate,
Expand Down
8 changes: 8 additions & 0 deletions apps/kyb-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# kyb-app

## 0.3.116

### Patch Changes

- Updated dependencies
- @ballerine/common@0.9.70
- @ballerine/workflow-browser-sdk@0.6.89

## 0.3.115

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions apps/kyb-app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/kyb-app",
"private": true,
"version": "0.3.115",
"version": "0.3.116",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -17,8 +17,8 @@
},
"dependencies": {
"@ballerine/blocks": "0.2.34",
"@ballerine/common": "^0.9.69",
"@ballerine/workflow-browser-sdk": "0.6.88",
"@ballerine/common": "^0.9.70",
"@ballerine/workflow-browser-sdk": "0.6.89",
"@ballerine/ui": "0.5.67",
"@lukemorales/query-key-factory": "^1.0.3",
"@radix-ui/react-icons": "^1.3.0",
Expand Down
8 changes: 8 additions & 0 deletions examples/headless-example/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @ballerine/headless-example

## 0.3.88

### Patch Changes

- Updated dependencies
- @ballerine/common@0.9.70
- @ballerine/workflow-browser-sdk@0.6.89

## 0.3.87

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions examples/headless-example/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/headless-example",
"private": true,
"version": "0.3.87",
"version": "0.3.88",
"type": "module",
"scripts": {
"spellcheck": "cspell \"*\"",
Expand Down Expand Up @@ -34,8 +34,8 @@
"vite": "^4.5.3"
},
"dependencies": {
"@ballerine/common": "0.9.69",
"@ballerine/workflow-browser-sdk": "0.6.88",
"@ballerine/common": "0.9.70",
"@ballerine/workflow-browser-sdk": "0.6.89",
"@felte/reporter-svelte": "^1.1.5",
"@felte/validator-zod": "^1.0.13",
"@fontsource/inter": "^4.5.15",
Expand Down
6 changes: 6 additions & 0 deletions packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @ballerine/common

## 0.9.70

### Patch Changes

- updated packages

## 0.9.69

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": false,
"name": "@ballerine/common",
"author": "Ballerine <[email protected]>",
"version": "0.9.69",
"version": "0.9.70",
"description": "common",
"module": "./dist/esm/index.js",
"main": "./dist/cjs/index.js",
Expand Down
8 changes: 8 additions & 0 deletions packages/workflow-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @ballerine/workflow-core

## 0.6.89

### Patch Changes

- updated packages
- Updated dependencies
- @ballerine/common@0.9.70

## 0.6.88

### Patch Changes
Expand Down
Loading

0 comments on commit d02335d

Please sign in to comment.