Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Pencil } from '../../atoms/Pencil/Pencil';
import { COLLECTION_FLOW_PROCESS_NAME } from './trackers/collection-flow/consts';
import { UBO_FLOW_PROCESS_NAME } from './trackers/ubo-flows/consts';
import { THIRD_PARTY_PROCESS_NAME } from './trackers/third-party/consts';
import { EndUserIndividualVerificationChecksStatus } from '@/domains/individuals/fetchers';

export const tagToAccordionCardItem = {
[StateTag.COLLECTION_FLOW]: 'Collection flow',
Expand Down Expand Up @@ -111,6 +112,13 @@ export const tagToIcon = {
[StateTag.REVISION]: Icon.REFRESH,
} as const;

export const endUserFlowStatusToIcon = {
[EndUserIndividualVerificationChecksStatus.IN_PROGRESS]: Icon.CLOCK,
[EndUserIndividualVerificationChecksStatus.COMPLETED]: Icon.CHECK,
[EndUserIndividualVerificationChecksStatus.FAILED]: Icon.X,
DEFAULT: Icon.INDICATOR,
} as const;

export const DEFAULT_PROCESS_TRACKER_PROCESSES = [
COLLECTION_FLOW_PROCESS_NAME,
THIRD_PARTY_PROCESS_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { UBO_FLOW_PROCESS_NAME } from './consts';
import { useUBOFlowsTrackerItems } from './hooks/useUBOFlowsTrackerItems';

export const UBOFlowsTracker = ({ workflow, plugins, processes }: TTrackerComponentProps) => {
const items = useUBOFlowsTrackerItems(workflow?.childWorkflows);
const items = useUBOFlowsTrackerItems(workflow?.endUsers || []);

return (
<Tracker workflow={workflow} plugins={plugins} processes={processes}>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { endUserFlowStatusToIcon } from '@/common/components/molecules/ProcessTracker/constants';
import { TWorkflowById } from '@/domains/workflows/fetchers';

export const getEndUserFlowStatus = (
status: NonNullable<TWorkflowById['endUsers'][number]['individualVerificationsChecks']>['status'],
) => {
return (
endUserFlowStatusToIcon[status as keyof typeof endUserFlowStatusToIcon] ??
endUserFlowStatusToIcon.DEFAULT
);
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { TWorkflowById } from '@/domains/workflows/fetchers';
import { useMemo } from 'react';
import { getUBOFlowStatusByTags } from './helpers/get-ubo-flow-status-by-tags';
import { valueOrNA } from '@ballerine/common';
import { getEndUserFlowStatus } from './helpers/get-end-user-flow-status';

export const useUBOFlowsTrackerItems = (childWorkflows: TWorkflowById['childWorkflows']) => {
export const useUBOFlowsTrackerItems = (endUsers: TWorkflowById['endUsers']) => {
const items = useMemo(
() =>
childWorkflows?.map(({ context, tags }) => {
endUsers?.map(endUser => {
return {
text: `${valueOrNA(context?.entity?.data?.firstName)} ${valueOrNA(
context?.entity?.data?.lastName,
)}`,
leftIcon: getUBOFlowStatusByTags(tags),
text: `${valueOrNA(endUser.firstName)} ${valueOrNA(endUser.lastName)}`,
leftIcon: getEndUserFlowStatus(endUser.individualVerificationsChecks?.status),
};
}) || [],
[childWorkflows],
[endUsers],
);

return items;
Expand Down
14 changes: 13 additions & 1 deletion apps/backoffice-v2/src/domains/individuals/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export const EntityType = {

export const EndUserVariantSchema = z.enum([EntityType.UBO, EntityType.DIRECTOR]);

export const EndUserIndividualVerificationChecksStatus = {
IN_PROGRESS: 'in-progress',
COMPLETED: 'completed',
FAILED: 'failed',
} as const;

export const EndUserSchema = z.object({
id: z.string(),
firstName: z.string(),
Expand All @@ -30,7 +36,13 @@ export const EndUserSchema = z.object({
amlHits: z.array(HitSchema.extend({ vendor: z.string().optional() })).optional(),
individualVerificationsChecks: z
.object({
status: z.string(),
status: z
.union([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.union([
.enum(

z.literal(EndUserIndividualVerificationChecksStatus.IN_PROGRESS),
z.literal(EndUserIndividualVerificationChecksStatus.COMPLETED),
z.literal(EndUserIndividualVerificationChecksStatus.FAILED),
])
.optional(),
data: z.object({
kyc_session_1: z.object({
vendor: z.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const Checkbox = React.forwardRef<
<Root
ref={ref}
className={ctw(
'border-slate-900 ring-offset-background focus-visible:ring-ring data-[state=checked]:bg-white data-[state=checked]:text-slate-900 peer h-4 w-4 shrink-0 rounded-sm border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
'ring-offset-background focus-visible:ring-ring peer h-4 w-4 shrink-0 rounded-sm border border-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-white data-[state=checked]:text-slate-900',
className,
)}
{...props}
Expand Down
2 changes: 2 additions & 0 deletions packages/workflow-core/src/lib/create-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const createWorkflow: TCreateWorkflow = ({
invokeChildWorkflowAction,
invokeWorkflowTokenAction,
secretsManager,
projectId,
}) =>
new WorkflowRunner({
config,
Expand All @@ -26,4 +27,5 @@ export const createWorkflow: TCreateWorkflow = ({
invokeChildWorkflowAction,
invokeWorkflowTokenAction,
secretsManager,
projectId,
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class ApiPlugin {
memoizedSecrets: Record<string, string> | undefined;
whitelistedInputProperties: string[] | undefined;
includeInvokedAt: boolean;
projectId?: string;

constructor(pluginParams: IApiPluginParams) {
this.name = pluginParams.name;
Expand All @@ -60,6 +61,7 @@ export class ApiPlugin {
this.displayName = pluginParams.displayName;
this.whitelistedInputProperties = pluginParams.whitelistedInputProperties;
this.includeInvokedAt = pluginParams.includeInvokedAt ?? true;
this.projectId = pluginParams.projectId;
}

async invoke(context: TContext, additionalContext?: AnyRecord) {
Expand Down Expand Up @@ -95,7 +97,10 @@ export class ApiPlugin {
const apiResponse = await this.makeApiRequest(
_url,
this.method,
requestPayload,
{
...requestPayload,
projectId: this.projectId,
},
await this.composeRequestHeaders(this.headers!, {
...context,
...additionalContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface IApiPluginParams {
secretsManager?: SecretsManager;
whitelistedInputProperties?: string[];
includeInvokedAt?: boolean;
projectId?: string;
invoke?(...args: any[]): any;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,7 @@ export const BALLERINE_API_PLUGIN_FACTORY = {
endUserId: join('__',[entity.ballerineEntityId || entity.data.id || entity.data.identityNumber, pluginsOutput.kyc_session.kyc_session_1.result.metadata.id || '']),
firstName: entity.data.firstName,
lastName: entity.data.lastName,
workflowRuntimeDataId: workflowRuntimeId,
callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/KYC_RESPONSE_RECEIVED','?resultDestination=pluginsOutput.kyc_session.kyc_session_1.result']),
vendor: 'veriff',
withAml: ${options.withAml ?? false ? 'true' : 'false'}
Expand Down
2 changes: 2 additions & 0 deletions packages/workflow-core/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export interface WorkflowOptions {
invokeWorkflowTokenAction?: WorkflowTokenPluginParams['action'];
secretsManager?: SecretsManager;
helpers?: TWorkflowHelpers;
projectId?: string;
}

export interface WorkflowRunnerArgs {
Expand All @@ -102,6 +103,7 @@ export interface WorkflowRunnerArgs {
secretsManager?: SecretsManager;
enableLogging?: boolean;
helpers?: TWorkflowHelpers;
projectId?: string;
}

export type WorkflowEventWithoutState = Omit<WorkflowEvent, 'state'>;
Expand Down
6 changes: 6 additions & 0 deletions packages/workflow-core/src/lib/workflow-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class WorkflowRunner {
#__secretsManager: SecretsManager | undefined;
#__enableLogging: boolean;
#__auditLogs: WorkflowLogEntry[] = [];
#__projectId: string | undefined;

public get workflow() {
return this.#__workflow;
Expand All @@ -113,6 +114,7 @@ export class WorkflowRunner {
invokeWorkflowTokenAction,
secretsManager,
enableLogging = true,
projectId,
}: WorkflowRunnerArgs,
debugMode = false,
) {
Expand All @@ -137,6 +139,9 @@ export class WorkflowRunner {
invokeChildWorkflowAction,
);

// id of the project that the workflow is running in
this.#__projectId = projectId;

this.__extensions.apiPlugins = this.initiateApiPlugins(this.__extensions.apiPlugins ?? []);

this.__extensions.commonPlugins = this.initiateCommonPlugins(
Expand Down Expand Up @@ -215,6 +220,7 @@ export class WorkflowRunner {
errorAction: apiPluginSchema.errorAction,
persistResponseDestination: apiPluginSchema.persistResponseDestination,
secretsManager: this.#__secretsManager,
projectId: this.#__projectId,
});
});
}
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/workflows-service/prisma/data-migrations
6 changes: 4 additions & 2 deletions services/workflows-service/src/document/document.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ import {
EntitySchema,
TParsedDocuments,
} from './types';
import { defaultPrismaTransactionOptions } from '@/prisma/prisma.util';
import { beginTransactionIfNotExistCurry } from '@/prisma/prisma.util';
import {
defaultPrismaTransactionOptions,
beginTransactionIfNotExistCurry,
} from '@/prisma/prisma.util';
import { PrismaService } from '@/prisma/prisma.service';
import { assertIsValidProjectIds } from '@/project/project-scope.service';

Expand Down
2 changes: 2 additions & 0 deletions services/workflows-service/src/workflow/workflow.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ export class WorkflowService {
// @ts-expect-error - error from Prisma types fix
state: workflow.state ?? workflow.workflowDefinition.definition?.initial,
},
projectId: workflow.projectId,
});

nextEvents = service.getSnapshot().nextEvents;
Expand Down Expand Up @@ -2197,6 +2198,7 @@ export class WorkflowService {
state: workflowRuntimeData.state,
},
extensions: workflowDefinition.extensions,
projectId: currentProjectId,
helpers: {
getEndUserById: async (endUserId: string) => {
return await this.endUserService.getById(endUserId, {}, projectIds);
Expand Down