Skip to content

Commit

Permalink
fix(*): small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Omri-Levy committed May 23, 2024
1 parent 6aaceaf commit 0243b66
Show file tree
Hide file tree
Showing 290 changed files with 42,842 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TextWithNAFallback } from '@/common/components/atoms/TextWithNAFallback
import { createInitials } from '@/common/utils/create-initials/create-initials';
import { ctw } from '@/common/utils/ctw/ctw';
import { valueOrNA } from '@/common/utils/value-or-na/value-or-na';
import { TBusinessAlerts } from '@/domains/business-alerts/fetchers';
import { TBusinessAlert } from '@/domains/business-alerts/fetchers';
import { getSeverityFromRiskScore } from '@/pages/BusinessesAlerts/components/BusinessAlertsTable/utils/get-severity-from-risk-score';
import {
severityToClassName,
Expand All @@ -20,7 +20,7 @@ import { ComponentProps } from 'react';
import { titleCase } from 'string-ts';

const columnHelper = createColumnHelper<
TBusinessAlerts[number] & {
TBusinessAlert & {
decision: string;
}
>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createColumnHelper } from '@tanstack/react-table';
import { TAlerts, TAlertState } from '@/domains/alerts/fetchers';
import { TAlert, TAlertState } from '@/domains/alerts/fetchers';
import { TextWithNAFallback } from '@/common/components/atoms/TextWithNAFallback/TextWithNAFallback';
import dayjs from 'dayjs';
import { Badge } from '@ballerine/ui';
Expand All @@ -18,7 +18,7 @@ import { useEllipsesWithTitle } from '@/common/hooks/useEllipsesWithTitle/useEll
import { buttonVariants } from '@/common/components/atoms/Button/Button';

const columnHelper = createColumnHelper<
TAlerts[number] & {
TAlert & {
// TODO: Change type once decisions PR is merged
// Computed from `alert.state`
decision: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CD

on:
push:
branches:
- dev
- prod
- sb

jobs:
trigger:
runs-on: ubuntu-latest
steps:
- name: Trigger workflow in another repo
uses: actions/github-script@v6
with:
github-token: ${{ secrets.REPO_ACCESS_TOKEN }}
script: |
await github.rest.repos.createDispatchEvent({
owner: 'ballerine-io',
repo: 'ballerine',
event_type: 'trigger-cd-event'
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
2 changes: 2 additions & 0 deletions services/workflows-service/prisma/data-migrations/.gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[submodule "services/workflows-service/prisma/data-migrations"]
branch = main
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { PrismaClient } from '@prisma/client';
import { INestApplicationContext } from '@nestjs/common';

export const migrate = async (client: PrismaClient, app: INestApplicationContext) => {
await client.$transaction(
async transaction => {
const filters = await transaction.filter.findMany({});

for (const filter of filters) {
const { where: whereQuery, ...rest } = filter.query as any;

if (whereQuery.workflowDefinitionId && !whereQuery.workflowDefinitionId.in) {
whereQuery.workflowDefinitionId = {
in: [whereQuery.workflowDefinitionId],
};

await transaction.filter.update({
where: { id: filter.id },
data: { query: { ...rest, where: whereQuery } },
});
}
}
},
{
timeout: 25000,
maxWait: 25000,
},
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { PrismaClient } from '@prisma/client';
import { INestApplicationContext } from '@nestjs/common';

export const migrate = async (client: PrismaClient, app: INestApplicationContext) => {
await client.$transaction(
async transaction => {
const allFilters = await transaction.filter.findMany({});

for (const filter of allFilters) {
const query = filter.query as {
select: { workflowDefinition: Record<string, any> };
};
query.select.workflowDefinition = {
select: {
id: true,
name: true,
contextSchema: true,
documentsSchema: true,
config: true,
definition: true,
version: true,
},
};

await transaction.filter.update({
where: { id: filter.id },
data: { query },
});
}
},
{
timeout: 15000,
maxWait: 15000,
},
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { PrismaClient } from '@prisma/client';
import { INestApplicationContext } from '@nestjs/common';
import { defaultContextSchema } from '@ballerine/common';

export const migrate = async (client: PrismaClient, app: INestApplicationContext) => {
await client.$transaction(
async transaction => {
await transaction.workflowDefinition.updateMany({
where: {
id: 'kyb_dynamic_ui_session_example',
},
data: {
contextSchema: {
type: 'json-schema',
schema: defaultContextSchema,
},
},
});
},
{
timeout: 15000,
maxWait: 15000,
},
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { PrismaClient } from '@prisma/client';

import { kycEmailSessionDefinition } from '../templates/creation/common/generate-kyc-email-process';
import { generateWorkflowDefinition } from '../templates/creation/clipspay/workflow-definition/workflow-definition';
import { composeUiDefinition } from '../templates/creation/clipspay/collection-flow/compose-ui-definition';
import { generateDefinitionLogic } from '../templates/creation/clipspay/collection-flow/generate-definition-logic';

const emailDefinitionName = 'kyc_email_session_example';
const clipspayDefinitionName = 'kyb_dynamic_ui_session_example';

export const migrate = async (client: PrismaClient) => {
await client.$transaction(
async transaction => {
const kycEmailDefinition = kycEmailSessionDefinition();
await transaction.workflowDefinition.updateMany({
where: {
name: emailDefinitionName,
},
data: {
definition: kycEmailDefinition.definition,
config: kycEmailDefinition.config,
extensions: kycEmailDefinition.extensions,
},
});

const newClipspayWorkflow = generateWorkflowDefinition(
clipspayDefinitionName,
clipspayDefinitionName,
);

const customers = await transaction.customer.findMany({
where: {
name: {
contains: 'clipspay',
},
},
select: {
projects: true,
},
});

const projects = customers
?.map(customer => customer.projects.map(project => project.id))
.flat();

await transaction.workflowDefinition.updateMany({
where: {
name: newClipspayWorkflow.name,
projectId: {
in: projects,
},
},
data: {
definition: newClipspayWorkflow.definition,
config: newClipspayWorkflow.config,
extensions: newClipspayWorkflow.extensions,
},
});

const newUiDefinition = composeUiDefinition(
newClipspayWorkflow.id,
generateDefinitionLogic(newClipspayWorkflow.id),
);

await transaction.uiDefinition.updateMany({
where: {
workflowDefinitionId: newClipspayWorkflow.id,
projectId: {
in: projects,
},
},
data: newUiDefinition,
});
},
{
timeout: 25000,
maxWait: 25000,
},
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { PrismaClient } from '@prisma/client';
import { INestApplicationContext } from '@nestjs/common';
import { migrate as filtersMigration } from './20231129132123_add_document_schema_to_filters';

export const migrate = async (client: PrismaClient, app: INestApplicationContext) => {
await filtersMigration(client, app);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { PrismaClient } from '@prisma/client';
import { INestApplicationContext } from '@nestjs/common';
import { generateWorkflowDefinition } from '../templates/creation/clipspay/workflow-definition/workflow-definition';

const clipspayDefinitionName = 'kyb_dynamic_ui_session_example';

export const migrate = async (client: PrismaClient, app: INestApplicationContext) => {
await client.$transaction(
async transaction => {
const newClipspayWorkflow = generateWorkflowDefinition(
clipspayDefinitionName,
clipspayDefinitionName,
);

const customers = await transaction.customer.findMany({
where: {
name: {
contains: 'clipspay',
},
},
select: {
projects: true,
},
});

const projects = customers
?.map(customer => customer.projects.map(project => project.id))
.flat();

await transaction.workflowDefinition.updateMany({
where: {
name: clipspayDefinitionName,
projectId: {
in: projects,
},
},
data: {
definition: newClipspayWorkflow.definition,
extensions: newClipspayWorkflow.extensions,
},
});
},
{
timeout: 15000,
maxWait: 15000,
},
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { PrismaClient } from '@prisma/client';

import { generateWorkflowDefinition } from '../templates/creation/clipspay/workflow-definition/workflow-definition';
import { composeUiDefinition } from '../templates/creation/clipspay/collection-flow/compose-ui-definition';
import { generateDefinitionLogic } from '../templates/creation/clipspay/collection-flow/generate-definition-logic';

const clipspayDefinitionName = 'kyb_dynamic_ui_session_example';

export const migrate = async (client: PrismaClient) => {
await client.$transaction(
async transaction => {
const newClipspayWorkflow = generateWorkflowDefinition(
clipspayDefinitionName,
clipspayDefinitionName,
);

const customers = await transaction.customer.findMany({
where: {
name: {
contains: 'clipspay',
},
},
select: {
projects: true,
},
});

const projects = customers
?.map(customer => customer.projects.map(project => project.id))
.flat();

const newUiDefinition = composeUiDefinition(
newClipspayWorkflow.id,
generateDefinitionLogic(newClipspayWorkflow.id),
);

await transaction.uiDefinition.updateMany({
where: {
workflowDefinitionId: newClipspayWorkflow.id,
projectId: {
in: projects,
},
},
data: newUiDefinition,
});
},
{
timeout: 25000,
maxWait: 25000,
},
);
};
Loading

0 comments on commit 0243b66

Please sign in to comment.