diff --git a/services/workflows-service/prisma/data-migrations/.github/workflows/CD.yml b/services/workflows-service/prisma/data-migrations/.github/workflows/CD.yml deleted file mode 100644 index dbc97cc545..0000000000 --- a/services/workflows-service/prisma/data-migrations/.github/workflows/CD.yml +++ /dev/null @@ -1,23 +0,0 @@ -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' - }); diff --git a/services/workflows-service/prisma/data-migrations/.gitignore b/services/workflows-service/prisma/data-migrations/.gitignore deleted file mode 100644 index e43b0f9889..0000000000 --- a/services/workflows-service/prisma/data-migrations/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.DS_Store diff --git a/services/workflows-service/prisma/data-migrations/.gitmodules b/services/workflows-service/prisma/data-migrations/.gitmodules deleted file mode 100644 index 777f55f8a9..0000000000 --- a/services/workflows-service/prisma/data-migrations/.gitmodules +++ /dev/null @@ -1,2 +0,0 @@ -[submodule "services/workflows-service/prisma/data-migrations"] - branch = main diff --git a/services/workflows-service/prisma/data-migrations/common/20231128125824_update_filter_query_as_defintion_id_array.ts b/services/workflows-service/prisma/data-migrations/common/20231128125824_update_filter_query_as_defintion_id_array.ts deleted file mode 100644 index 4233c99260..0000000000 --- a/services/workflows-service/prisma/data-migrations/common/20231128125824_update_filter_query_as_defintion_id_array.ts +++ /dev/null @@ -1,29 +0,0 @@ -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, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/common/20231129132123_add_document_schema_to_filters.ts b/services/workflows-service/prisma/data-migrations/common/20231129132123_add_document_schema_to_filters.ts deleted file mode 100644 index c8dcd4fd50..0000000000 --- a/services/workflows-service/prisma/data-migrations/common/20231129132123_add_document_schema_to_filters.ts +++ /dev/null @@ -1,36 +0,0 @@ -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 }; - }; - 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, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/common/20231203121600_document_pages_schema_csv.ts b/services/workflows-service/prisma/data-migrations/common/20231203121600_document_pages_schema_csv.ts deleted file mode 100644 index c5c73ed5b3..0000000000 --- a/services/workflows-service/prisma/data-migrations/common/20231203121600_document_pages_schema_csv.ts +++ /dev/null @@ -1,25 +0,0 @@ -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, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/common/20231217173250_update_clipspay_definition.ts b/services/workflows-service/prisma/data-migrations/common/20231217173250_update_clipspay_definition.ts deleted file mode 100644 index 4549674346..0000000000 --- a/services/workflows-service/prisma/data-migrations/common/20231217173250_update_clipspay_definition.ts +++ /dev/null @@ -1,80 +0,0 @@ -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, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/common/20231217173252_add_workflow_definition_version_to_filters.ts b/services/workflows-service/prisma/data-migrations/common/20231217173252_add_workflow_definition_version_to_filters.ts deleted file mode 100644 index 2240f42c80..0000000000 --- a/services/workflows-service/prisma/data-migrations/common/20231217173252_add_workflow_definition_version_to_filters.ts +++ /dev/null @@ -1,7 +0,0 @@ -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); -}; diff --git a/services/workflows-service/prisma/data-migrations/common/20240117151034_update_clipspay_workflow_with_unsupported_countries_rule.ts b/services/workflows-service/prisma/data-migrations/common/20240117151034_update_clipspay_workflow_with_unsupported_countries_rule.ts deleted file mode 100644 index a6ccf8ef73..0000000000 --- a/services/workflows-service/prisma/data-migrations/common/20240117151034_update_clipspay_workflow_with_unsupported_countries_rule.ts +++ /dev/null @@ -1,48 +0,0 @@ -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, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/common/20240129144339_update_clipspay_definitions.ts b/services/workflows-service/prisma/data-migrations/common/20240129144339_update_clipspay_definitions.ts deleted file mode 100644 index 5bdb242fef..0000000000 --- a/services/workflows-service/prisma/data-migrations/common/20240129144339_update_clipspay_definitions.ts +++ /dev/null @@ -1,52 +0,0 @@ -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, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/common/20240316204069_update_api_keys_for_customers.ts b/services/workflows-service/prisma/data-migrations/common/20240316204069_update_api_keys_for_customers.ts deleted file mode 100644 index 9e1462ed00..0000000000 --- a/services/workflows-service/prisma/data-migrations/common/20240316204069_update_api_keys_for_customers.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { AppLoggerService } from '@/common/app-logger/app-logger.service'; -import { TAuthenticationConfiguration } from '@/customer/types'; -import { generateHashedKey } from '@/customer/api-key/utils'; -import { inspect } from 'node:util'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - const logger = app.get(AppLoggerService); - - const customers = await client.customer.findMany({ - include: { - projects: true, - apiKeys: true, - }, - }); - - logger.log(`Found ${customers.length} customers`); - - for (const customer of customers) { - if (customer.apiKeys.length > 0) { - logger.log('Skip on customer which already have api key', { - customerId: customer.id, - name: customer.name, - }); - - continue; - } - - const { id, authenticationConfiguration } = customer; - - const apiKeyDetails = authenticationConfiguration as TAuthenticationConfiguration | null; - - if (apiKeyDetails?.apiType === 'API_KEY' && apiKeyDetails?.authValue) { - const { authValue } = apiKeyDetails; - - const { hashedKey, validUntil } = await generateHashedKey({ - key: authValue, - }); - - logger.log('Creating API key for customer', { - customerId: id, - authValue, - hashedKey, - }); - - try { - await client.apiKey.create({ - data: { - customerId: customer.id, - hashedKey, - validUntil, - }, - }); - } catch (err) { - logger.error('Error creating API key for customer', { - customerId: id, - authValue, - hashedKey, - error: inspect(err), - }); - } - } - } -}; diff --git a/services/workflows-service/prisma/data-migrations/common/20240425005708_update_alert_definitions.ts b/services/workflows-service/prisma/data-migrations/common/20240425005708_update_alert_definitions.ts deleted file mode 100644 index 52be6bbbb7..0000000000 --- a/services/workflows-service/prisma/data-migrations/common/20240425005708_update_alert_definitions.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { generateAlertDefinitions } from '../../../scripts/alerts/generate-alerts'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const projects = await transaction.project.findMany({ - where: { - OR: ['oxpay', 'customer', 'ballerine'].map(name => ({ - customer: { name: { startsWith: name } }, - })), - }, - include: { - customer: true, - }, - }); - - return await Promise.allSettled( - projects.map(async project => { - let crossEnvKeyPrefix = project.name - .toUpperCase() - .replace(' ', '_') - .replace(/[_-]?PROJECT[_-]?/g, 'P') - .replace(/[_-]?DEFAULT[_-]?/g, '') - .replace('-', '_') - .replace('__', '_'); - - if (crossEnvKeyPrefix.charAt(crossEnvKeyPrefix.length - 1) == '_') { - crossEnvKeyPrefix = crossEnvKeyPrefix.substring(0, crossEnvKeyPrefix.length - 1); - } - - return await generateAlertDefinitions( - transaction, - { - project, - }, - { - crossEnvKeyPrefix, - }, - ); - }), - ); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/common/20240501144701_enable_ubos_ongoing_monitoring_oxpay.ts b/services/workflows-service/prisma/data-migrations/common/20240501144701_enable_ubos_ongoing_monitoring_oxpay.ts deleted file mode 100644 index e5e5d06bf7..0000000000 --- a/services/workflows-service/prisma/data-migrations/common/20240501144701_enable_ubos_ongoing_monitoring_oxpay.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { isObject } from '@ballerine/common'; -import { ConfigSchema } from '@/workflow/schemas/zod-schemas'; -import { z } from 'zod'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const definitions = await transaction.workflowDefinition.findMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: { in: ['kyb_w_ubos_oxpay', 'oxpay_child_associated_company'] }, - }, - }); - - for (const definition of definitions) { - await transaction.workflowDefinition.update({ - where: { id: definition.id }, - data: { - config: { - ...(isObject(definition.config) ? definition.config : {}), - hasUboOngoingMonitoring: true, - } satisfies z.infer, - }, - }); - } - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20231128112305_create_demo_definition_and_ui_definition.ts b/services/workflows-service/prisma/data-migrations/dev/20231128112305_create_demo_definition_and_ui_definition.ts deleted file mode 100644 index ffb9994dc5..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20231128112305_create_demo_definition_and_ui_definition.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { DemoTemplate } from '../templates/creation/demo'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction(async transaction => { - const template = new DemoTemplate(app, transaction, { - customer: { - id: 'demo-customer', - displayName: 'Demo customer', - name: 'demo', - logoImageUrl: 'https://picsum.photos/200', - apiKey: 'demo_secret1', - }, - user: { - firstName: 'John', - lastName: 'Doe', - email: 'demo@mail.com', - password: 'demo', - }, - project: { - id: 'demo-project', - }, - filter: { - name: 'DEMO KYB', - }, - }); - - await template.generate(); - }); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20231204140137_generate_customer_with_associated_company_kyb.ts b/services/workflows-service/prisma/data-migrations/dev/20231204140137_generate_customer_with_associated_company_kyb.ts deleted file mode 100644 index b8f7fef26f..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20231204140137_generate_customer_with_associated_company_kyb.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { KybWithAssociatedCompaniesTemplate } from '../templates/creation/child-associated-company'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction(async transaction => { - const template = new KybWithAssociatedCompaniesTemplate(app, transaction, { - customer: { - name: 'paylink', - displayName: 'PayLink', - logoImageUrl: 'https://picsum.photos/300', - apiKey: 'associated_secret', - }, - user: { - firstName: 'asoJohn', - lastName: 'asoDoe', - email: 'paylink@gmail.com', - password: 'paylink1', - }, - project: { - id: 'aso-project', - }, - filter: { - name: 'Kyb & Associates', - }, - }); - - await template.generate(); - }); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20231213130258_add_variants_to_filters.ts b/services/workflows-service/prisma/data-migrations/dev/20231213130258_add_variants_to_filters.ts deleted file mode 100644 index 2c9e11865c..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20231213130258_add_variants_to_filters.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { baseFilterDefinitionSelect } from '../../../scripts/filters'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const fidoProject = await fetchCustomerProjectIds(transaction, 'fido'); - const clipspayProjects = await fetchCustomerProjectIds(transaction, 'clipspay'); - const yunheProjects = await fetchCustomerProjectIds(transaction, 'yunhe'); - - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: fidoProject } } }, - data: { variant: 'MANUAL_REVIEW' }, - }); - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: clipspayProjects } } }, - data: { - variant: 'DEFAULT', - }, - }); - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: yunheProjects } } }, - data: { variant: 'DEFAULT' }, - }); - - const allFilters = await transaction.filter.findMany({}); - - for (const filter of allFilters) { - const query = filter.query as { - select: { workflowDefinition: Record }; - }; - query.select.workflowDefinition = { - ...baseFilterDefinitionSelect['workflowDefinition'], - }; - - await transaction.filter.update({ - where: { id: filter.id }, - data: { query }, - }); - } - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20231217173250_update_clipspay_definition.ts b/services/workflows-service/prisma/data-migrations/dev/20231217173250_update_clipspay_definition.ts deleted file mode 100644 index 1a69295225..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20231217173250_update_clipspay_definition.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as clipspayMigration from '../common/20231217173250_update_clipspay_definition'; - -export const migrate = clipspayMigration.migrate; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240121144400_is_case_overview_enabled_config_clipspay.ts b/services/workflows-service/prisma/data-migrations/dev/20240121144400_is_case_overview_enabled_config_clipspay.ts deleted file mode 100644 index bb8c9de7a5..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240121144400_is_case_overview_enabled_config_clipspay.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as updateClipspayMigration from './20231217173250_update_clipspay_definition'; - -export const migrate = updateClipspayMigration.migrate; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240205104840_ballerine_qa_user.ts b/services/workflows-service/prisma/data-migrations/dev/20240205104840_ballerine_qa_user.ts deleted file mode 100644 index 8dc02e406b..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240205104840_ballerine_qa_user.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { BallerineQATemplate } from 'prisma/data-migrations/templates/creation/ballerine-qa'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new BallerineQATemplate(app, transaction, { - definition: { - id: 'kyb_w_ubos_ballerine', - name: 'kyb_w_ubos_ballerine', - }, - user: { - firstName: 'ballerine', - lastName: 'Admin', - email: 'admin@ballerine.com', - password: ' ', - }, - customer: { - name: 'ballerine', - displayName: 'ballerine', - apiKey: 'ballerine_secret', - logoImageUrl: '', - }, - project: { - id: 'ballerine_default', - }, - filter: { - name: 'Clipspay KYB', - }, - }); - - await template.generateClipspayProject(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240219231233_oxpay_init.ts b/services/workflows-service/prisma/data-migrations/dev/20240219231233_oxpay_init.ts deleted file mode 100644 index 36b8d47afe..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240219231233_oxpay_init.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { OxpayTemplate } from 'prisma/data-migrations/templates/creation/oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new OxpayTemplate(app, transaction, { - definition: { - id: 'kyb_w_ubos_oxpay', - name: 'kyb_w_ubos_oxpay', - }, - user: { - firstName: 'OxPay', - lastName: 'Admin', - email: 'admin@oxpayfinancial.com', - password: 'oxpaypass', - }, - customer: { - name: 'oxpay', - displayName: 'OxPay', - apiKey: 'oxpay_secret', - logoImageUrl: 'https://cdn.ballerine.io/images/oxpay_logo_opt.svg', - faviconImageUri: 'https://cdn.ballerine.io/images/oxpay_logo_xs.png', - }, - project: { - id: 'oxpay_default', - }, - filter: { - name: 'Merchants KYB', - }, - }); - - await template.generate(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240221170202_fido_context_schema_revision_reasons.ts b/services/workflows-service/prisma/data-migrations/dev/20240221170202_fido_context_schema_revision_reasons.ts deleted file mode 100644 index 4e58ad650f..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240221170202_fido_context_schema_revision_reasons.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { defaultContextSchema } from '@ballerine/common'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const customerOneProjectIds = await fetchCustomerProjectIds(transaction, 'customer-1'); - - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: customerOneProjectIds } } }, - data: { - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240221180007_dev_context_schema_customer_fix.ts b/services/workflows-service/prisma/data-migrations/dev/20240221180007_dev_context_schema_customer_fix.ts deleted file mode 100644 index c9310ab0b8..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240221180007_dev_context_schema_customer_fix.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as contextSchemaUpdate from './20240221170202_fido_context_schema_revision_reasons'; - -export const migrate = contextSchemaUpdate.migrate; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240222150821_update_oxpay_auth_details.ts b/services/workflows-service/prisma/data-migrations/dev/20240222150821_update_oxpay_auth_details.ts deleted file mode 100644 index 24836813cc..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240222150821_update_oxpay_auth_details.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { PrismaClient } from '@prisma/client'; - -export const migrate = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - const customer = await transaction.customer.findFirst({ - where: { - name: { - contains: 'oxpay', - }, - }, - select: { - id: true, - authenticationConfiguration: true, - }, - }); - - if ( - !customer?.authenticationConfiguration || - typeof customer.authenticationConfiguration !== 'object' - ) { - return; - } - - const newAuthenticationConfiguration = { - ...customer.authenticationConfiguration, - authValue: 'Oxpay-ZT7CJSiUsaFYq7xGQiSBk', - webhookSharedSecret: 'Oxpay-2LnkYwvYnm7MODlJDbTgi', - }; - - await transaction.customer.update({ - where: { - id: customer.id, - }, - data: { - authenticationConfiguration: newAuthenticationConfiguration, - }, - }); - }, - { - timeout: 25000, - maxWait: 25000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240222151321_axs_init.ts b/services/workflows-service/prisma/data-migrations/dev/20240222151321_axs_init.ts deleted file mode 100644 index 93019732e4..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240222151321_axs_init.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { KybTemplate } from '../templates/creation/kyb'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new KybTemplate(app, transaction, { - definition: { - id: 'kyb_w_ubos_axs', - name: 'kyb_w_ubos_axs', - }, - user: { - firstName: 'AXS', - lastName: 'Admin', - email: 'admin@axs.com.sg', - password: 'axspass', - }, - customer: { - name: 'axs', - displayName: 'AXS', - apiKey: 'axs_secret', - logoImageUrl: 'https://cdn.ballerine.io/images/axs_logo_l.png', - faviconImageUri: 'https://cdn.ballerine.io/images/axs_logo_xs.png', - }, - project: { - id: 'axs_default', - }, - filter: { - name: 'Merchants KYB', - }, - }); - - await template.generate(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240222190921_update_oxpay_ui_schema.ts b/services/workflows-service/prisma/data-migrations/dev/20240222190921_update_oxpay_ui_schema.ts deleted file mode 100644 index 43ae006c31..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240222190921_update_oxpay_ui_schema.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { composeUiDefinition } from '../templates/creation/oxpay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; - -export const migrate = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - const currentUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: 'kyb_w_ubos_oxpay', - }, - select: { - id: true, - }, - }); - - if (!currentUiDefinition) { - return; - } - - const updatedOxpayUiDefinition = composeUiDefinition( - 'kyb_w_ubos_oxpay', - generateDefinitionLogic('kyb_w_ubos_oxpay'), - ); - - return transaction.uiDefinition.update({ - where: { - id: currentUiDefinition.id, - }, - data: { - uiSchema: updatedOxpayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240225161500_update_oxpay_ui_schema_2.ts b/services/workflows-service/prisma/data-migrations/dev/20240225161500_update_oxpay_ui_schema_2.ts deleted file mode 100644 index 1419d0c71f..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240225161500_update_oxpay_ui_schema_2.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateOxPayUiSchema } from '../shared/update-oxpay-ui-schema'; - -export const migrate = updateOxPayUiSchema; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240226185638_oxpay_in_progress_plugins.ts b/services/workflows-service/prisma/data-migrations/dev/20240226185638_oxpay_in_progress_plugins.ts deleted file mode 100644 index fda4a5656d..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240226185638_oxpay_in_progress_plugins.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinition } from '../templates/creation/oxpay/workflow-definition/workflow-definition'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - const oxpayWorkflowDefinition = generateWorkflowDefinition( - oxpayDefinitionName, - oxpayDefinitionName, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - extensions: oxpayWorkflowDefinition.extensions, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240226185650_clipspay_in_progress_plugins.ts b/services/workflows-service/prisma/data-migrations/dev/20240226185650_clipspay_in_progress_plugins.ts deleted file mode 100644 index ed28b92a7f..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240226185650_clipspay_in_progress_plugins.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -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 clipspayProjectIds = await fetchCustomerProjectIds(transaction, 'clipspay'); - const clipspayWorkflowDefinition = generateWorkflowDefinition( - clipspayDefinitionName, - clipspayDefinitionName, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: clipspayProjectIds }, - name: clipspayDefinitionName, - }, - data: { - extensions: clipspayWorkflowDefinition.extensions, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240228120858_update_workflows_to_stop_relying_on_post_event_execution.ts b/services/workflows-service/prisma/data-migrations/dev/20240228120858_update_workflows_to_stop_relying_on_post_event_execution.ts deleted file mode 100644 index ff775beb6e..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240228120858_update_workflows_to_stop_relying_on_post_event_execution.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { PrismaClient, Prisma } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { createWorkflow } from '@ballerine/workflow-core'; - -type Definition = Parameters[0]['definition']; -const TASK_REVIEWED_EVENT = [ - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'approved']) == length(documents)", - }, - }, - target: 'approved', - }, - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'rejected']) > `0`", - }, - }, - target: 'rejected', - }, - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'revision']) > `0`", - }, - }, - target: 'revision', - }, -]; -const RETURN_TO_REVIEW_EVENT = { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: 'length(documents[?decision.status]) < length(documents)', - }, - }, -}; -const workflowDefinitionsToUpdate: { - [id: string]: Definition; -} = { - fido_biz_ghana: { - id: 'fido_biz_ghana', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - fido_biz_uganda: { - id: 'fido_biz_uganda', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'risk-score-improvement-uganda': { - id: 'risk-score-improvement-uganda', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { tags: ['revision'], type: 'final' }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'risk-score-improvement-dev': { - id: 'risk-score-improvement', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { tags: ['revision'], type: 'final' }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'fido-l16-business-ghana': { - id: 'fido-l16-business-ghana-v1', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, -}; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - for (const [id, definition] of Object.entries(workflowDefinitionsToUpdate)) { - await transaction.workflowDefinition.updateMany({ - where: { id }, - data: { - definition: definition as Prisma.InputJsonValue, - }, - }); - } - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240228160000_create_oxpay_ongoing_monitoring.ts b/services/workflows-service/prisma/data-migrations/dev/20240228160000_create_oxpay_ongoing_monitoring.ts deleted file mode 100644 index d038d91333..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240228160000_create_oxpay_ongoing_monitoring.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { createOngoingMonitoringFilter } from '../shared/create-ongoing-monitoring-filter'; -import { createOngoingMonitoringWorkflowDefinition } from '../shared/create-onging-monitoring-workflow-definition'; - -export const migrate = async (client: PrismaClient) => { - await createOngoingMonitoringWorkflowDefinition(client); - await createOngoingMonitoringFilter(client); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240304141000_update_oxpay_customer_config_with_ongoing_workflow.ts b/services/workflows-service/prisma/data-migrations/dev/20240304141000_update_oxpay_customer_config_with_ongoing_workflow.ts deleted file mode 100644 index fe8fc0a4f8..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240304141000_update_oxpay_customer_config_with_ongoing_workflow.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { generateOngoingWorkflowDefinition } from '../templates/creation/oxpay/workflow-definition/ongoing-workflow-definition'; -import { ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, OXPAY_PROJECT_ID } from '../shared/consts'; - -export const migrate = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - await transaction.customer.update({ - where: { name: 'oxpay' }, - data: { - config: { - ongoingWorkflowDefinitionId: 'ongoing_monitoring_oxpay', - }, - }, - }); - - const ongoingWorkflowDefinition = generateOngoingWorkflowDefinition( - ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - OXPAY_PROJECT_ID, - ); - - await transaction.workflowDefinition.update({ - where: { id: ONGOING_MONITORING_WORKFLOW_DEFINITION_ID }, - data: ongoingWorkflowDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240306124726_clipspay_child_omit_fix.ts b/services/workflows-service/prisma/data-migrations/dev/20240306124726_clipspay_child_omit_fix.ts deleted file mode 100644 index 2c43269f44..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240306124726_clipspay_child_omit_fix.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -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 clipspayProjectIds = await fetchCustomerProjectIds(transaction, 'clipspay'); - - const newClipspayWorkflow = generateWorkflowDefinition( - clipspayDefinitionName, - clipspayDefinitionName, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: clipspayProjectIds }, - name: clipspayDefinitionName, - }, - data: { - extensions: newClipspayWorkflow.extensions, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240306125810_oxpay_associated_definition.ts b/services/workflows-service/prisma/data-migrations/dev/20240306125810_oxpay_associated_definition.ts deleted file mode 100644 index 5f01d07010..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240306125810_oxpay_associated_definition.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { composeChildAssociatedCompanyDefinition } from '../templates/creation/child-associated-company/definition/compose-child-associated-company-definition'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - const childAssociatedCompanyDefinition = composeChildAssociatedCompanyDefinition({ - definitionId: `oxpay_child_associated_company`, - definitionName: `oxpay_child_associated_company`, - projectId: oxpayProjectIds[0]!, - }); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - childAssociatedCompanyDefinition.id, - ); - - await transaction.workflowDefinition.create({ - data: childAssociatedCompanyDefinition, - }); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: oxpayWorkflowDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240306130029_oxpay_is_associated_kyb_enabled.ts b/services/workflows-service/prisma/data-migrations/dev/20240306130029_oxpay_is_associated_kyb_enabled.ts deleted file mode 100644 index f2b92f1e32..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240306130029_oxpay_is_associated_kyb_enabled.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { isObject } from '@ballerine/common'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const workflowDefinition = await transaction.workflowDefinition.findFirstOrThrow({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - }); - const config = { - ...(isObject(workflowDefinition.config) ? workflowDefinition.config : {}), - isAssociatedCompanyKybEnabled: false, - } satisfies Parameters[0]['data']['config']; - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - config, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240307114453_oxpay_inprogress_process_fix.ts b/services/workflows-service/prisma/data-migrations/dev/20240307114453_oxpay_inprogress_process_fix.ts deleted file mode 100644 index c753826a20..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240307114453_oxpay_inprogress_process_fix.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { composeChildAssociatedCompanyDefinition } from '../templates/creation/child-associated-company/definition/compose-child-associated-company-definition'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const childAssociatedCompanyDefinition = composeChildAssociatedCompanyDefinition({ - definitionId: `oxpay_child_associated_company`, - definitionName: `oxpay_child_associated_company`, - projectId: oxpayProjectIds[0]!, - }); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - childAssociatedCompanyDefinition.id, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - extensions: oxpayWorkflowDefinition.extensions, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240310123348_fido_context_schema_update.ts b/services/workflows-service/prisma/data-migrations/dev/20240310123348_fido_context_schema_update.ts deleted file mode 100644 index 4e58ad650f..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240310123348_fido_context_schema_update.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { defaultContextSchema } from '@ballerine/common'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const customerOneProjectIds = await fetchCustomerProjectIds(transaction, 'customer-1'); - - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: customerOneProjectIds } } }, - data: { - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240310133821_update_oxpay_account_holder_name.ts b/services/workflows-service/prisma/data-migrations/dev/20240310133821_update_oxpay_account_holder_name.ts deleted file mode 100644 index 1419d0c71f..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240310133821_update_oxpay_account_holder_name.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateOxPayUiSchema } from '../shared/update-oxpay-ui-schema'; - -export const migrate = updateOxPayUiSchema; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240311104425_clipspay_business_type_length.ts b/services/workflows-service/prisma/data-migrations/dev/20240311104425_clipspay_business_type_length.ts deleted file mode 100644 index b1de738ccd..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240311104425_clipspay_business_type_length.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { composeUiDefinition } from '../templates/creation/clipspay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from '../templates/creation/clipspay/collection-flow/generate-definition-logic'; - -const WORKFLOW_DEFINITION_ID = 'kyb_dynamic_ui_session_example'; - -export const migrate = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - const currentUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: WORKFLOW_DEFINITION_ID, - }, - select: { - id: true, - }, - }); - - if (!currentUiDefinition) { - return; - } - - const updatedClipspayUiDefinition = composeUiDefinition( - WORKFLOW_DEFINITION_ID, - generateDefinitionLogic(WORKFLOW_DEFINITION_ID), - ); - - return transaction.uiDefinition.update({ - where: { - id: currentUiDefinition.id, - }, - data: { - uiSchema: updatedClipspayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240311112400_oxpay_associated_companies_docs_fix.ts b/services/workflows-service/prisma/data-migrations/dev/20240311112400_oxpay_associated_companies_docs_fix.ts deleted file mode 100644 index 8f1f905658..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240311112400_oxpay_associated_companies_docs_fix.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; -import { composeUiDefinition } from '../templates/creation/oxpay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const assosciatedCompanyWorkflowDefinition = await transaction.workflowDefinition.findFirst({ - where: { - projectId: { in: oxpayProjectIds }, - name: 'oxpay_child_associated_company', - }, - select: { - id: true, - }, - }); - - if (!assosciatedCompanyWorkflowDefinition) { - return; - } - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - assosciatedCompanyWorkflowDefinition.id, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - extensions: oxpayWorkflowDefinition.extensions, - }, - }); - - const updatedOxpayUiDefinition = composeUiDefinition( - oxpayDefinitionName, - generateDefinitionLogic(oxpayDefinitionName), - ); - - const currentUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: oxpayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentUiDefinition) { - return; - } - - await transaction.uiDefinition.update({ - where: { - id: currentUiDefinition.id, - }, - data: { - uiSchema: updatedOxpayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240311180000_definition_update_for_oxpay_and_clipspay.ts b/services/workflows-service/prisma/data-migrations/dev/20240311180000_definition_update_for_oxpay_and_clipspay.ts deleted file mode 100644 index b8e8ea5d46..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240311180000_definition_update_for_oxpay_and_clipspay.ts +++ /dev/null @@ -1,131 +0,0 @@ -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { composeUiDefinition as composeOxpayUiDefinition } from 'prisma/data-migrations/templates/creation/oxpay/collection-flow/compose-ui-definition'; -import { composeUiDefinition as composeClipspayUiDefinition } from '../templates/creation/clipspay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic as generateClipspayDefinitionLogic } from '../templates/creation/clipspay/collection-flow/generate-definition-logic'; -import { generateWorkflowDefinition } from '../templates/creation/clipspay/workflow-definition/workflow-definition'; -import { generateDefinitionLogic as generateOxpayDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; -const clipspayDefinitionName = 'kyb_dynamic_ui_session_example'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - // OxPay - - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const assosciatedCompanyWorkflowDefinition = await transaction.workflowDefinition.findFirst({ - where: { - projectId: { in: oxpayProjectIds }, - name: 'oxpay_child_associated_company', - }, - select: { - id: true, - }, - }); - - if (!assosciatedCompanyWorkflowDefinition) { - throw new Error('Associated Company Workflow Definition not found'); - } - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - assosciatedCompanyWorkflowDefinition.id, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - extensions: oxpayWorkflowDefinition.extensions, - }, - }); - - const currentOxpayUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: oxpayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentOxpayUiDefinition) { - throw new Error('Oxpay UI Definition not found'); - } - - const updatedOxpayUiDefinition = composeOxpayUiDefinition( - oxpayDefinitionName, - generateOxpayDefinitionLogic(oxpayDefinitionName), - ); - - await transaction.uiDefinition.update({ - where: { - id: currentOxpayUiDefinition.id, - }, - data: { - uiSchema: updatedOxpayUiDefinition.uiSchema, - }, - }); - - // ClipsPay - - const clipspayProjectIds = await fetchCustomerProjectIds(transaction, 'clipspay'); - - const clipspayWorkflowDefinition = generateWorkflowDefinition( - clipspayDefinitionName, - clipspayDefinitionName, - clipspayProjectIds[0]!, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: clipspayProjectIds }, - name: clipspayDefinitionName, - }, - data: { - extensions: clipspayWorkflowDefinition.extensions, - }, - }); - - const currentClipspayUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: clipspayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentClipspayUiDefinition) { - throw new Error('Clipspay UI Definition not found'); - } - - const updatedClipspayUiDefinition = composeClipspayUiDefinition( - clipspayDefinitionName, - generateClipspayDefinitionLogic(clipspayDefinitionName), - ); - - await transaction.uiDefinition.update({ - where: { - id: currentClipspayUiDefinition.id, - }, - data: { - uiSchema: updatedClipspayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240312124500_fix_oxpay_ui_definition.ts b/services/workflows-service/prisma/data-migrations/dev/20240312124500_fix_oxpay_ui_definition.ts deleted file mode 100644 index dc31a21a85..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240312124500_fix_oxpay_ui_definition.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { composeUiDefinition } from '../templates/creation/oxpay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const currentOxpayUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: oxpayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentOxpayUiDefinition) { - throw new Error('Oxpay UI Definition not found'); - } - - const updatedOxpayUiDefinition = composeUiDefinition( - oxpayDefinitionName, - generateDefinitionLogic(oxpayDefinitionName), - ); - - await transaction.uiDefinition.update({ - where: { - id: currentOxpayUiDefinition.id, - }, - data: { - uiSchema: updatedOxpayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240312142500_fix_oxpay_ui_definition.ts b/services/workflows-service/prisma/data-migrations/dev/20240312142500_fix_oxpay_ui_definition.ts deleted file mode 100644 index 1419d0c71f..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240312142500_fix_oxpay_ui_definition.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateOxPayUiSchema } from '../shared/update-oxpay-ui-schema'; - -export const migrate = updateOxPayUiSchema; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240313134332_oxpay_update_ui_definition.ts b/services/workflows-service/prisma/data-migrations/dev/20240313134332_oxpay_update_ui_definition.ts deleted file mode 100644 index 252e7c30ad..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240313134332_oxpay_update_ui_definition.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateOxpayUiDefinition } from '../shared/update-oxpay-ui-definition'; - -export const migrate = updateOxpayUiDefinition; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240313135707_clipspay_update_ui_definition.ts b/services/workflows-service/prisma/data-migrations/dev/20240313135707_clipspay_update_ui_definition.ts deleted file mode 100644 index e33b67f1f1..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240313135707_clipspay_update_ui_definition.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateClipspayUiDefinition } from 'prisma/data-migrations/shared/update-clipspay-ui-definition'; - -export const migrate = updateClipspayUiDefinition; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240314112305_create_demo_ballerine_definition_and_ui_definition.ts b/services/workflows-service/prisma/data-migrations/dev/20240314112305_create_demo_ballerine_definition_and_ui_definition.ts deleted file mode 100644 index 7a57a44f6f..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240314112305_create_demo_ballerine_definition_and_ui_definition.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { DemoTemplate } from '../templates/creation/ballerine-demo'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction(async transaction => { - const template = new DemoTemplate(app, transaction, { - customer: { - id: 'ballerinedemo', - displayName: 'Ballerine Demo', - name: 'ballerinedemo', - logoImageUrl: '', - apiKey: 'demo_secret', - }, - user: { - firstName: 'Noam', - lastName: 'Izhaki', - email: 'noam@ballerine.com', - password: 'noampass', - }, - project: { - id: 'ballerine-demo-project', - }, - filter: { - name: 'KYB', - }, - }); - - await template.generate(); - }); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240314113547_update_oxpay_and_clipspay_definition.ts b/services/workflows-service/prisma/data-migrations/dev/20240314113547_update_oxpay_and_clipspay_definition.ts deleted file mode 100644 index 645cd9eee8..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240314113547_update_oxpay_and_clipspay_definition.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { updateClipspayUiDefinition } from '../shared/update-clipspay-ui-definition'; -import { updateOxpayUiDefinition } from '../shared/update-oxpay-ui-definition'; -import { migrate as migrateCLipsAndOx } from './20240311180000_definition_update_for_oxpay_and_clipspay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - await migrateCLipsAndOx(client, app); - await updateClipspayUiDefinition(client); - await updateOxpayUiDefinition(client); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240314150705_clipspay_definition_display_name.ts b/services/workflows-service/prisma/data-migrations/dev/20240314150705_clipspay_definition_display_name.ts deleted file mode 100644 index ec45bae5e4..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240314150705_clipspay_definition_display_name.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; - -const clipspayDefinitionName = 'kyb_dynamic_ui_session_example'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const clipspayProjectIds = await fetchCustomerProjectIds(transaction, 'clipspay'); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: clipspayProjectIds }, - name: clipspayDefinitionName, - }, - data: { - displayName: 'KYB', - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240314150853_oxpay_definition_display_name.ts b/services/workflows-service/prisma/data-migrations/dev/20240314150853_oxpay_definition_display_name.ts deleted file mode 100644 index 2f9579ba30..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240314150853_oxpay_definition_display_name.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - displayName: 'KYB', - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240314190319_definition_update_fix.ts b/services/workflows-service/prisma/data-migrations/dev/20240314190319_definition_update_fix.ts deleted file mode 100644 index 157a4650fd..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240314190319_definition_update_fix.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { updateClipspayUiDefinition } from '../shared/update-clipspay-ui-definition'; -import { updateOxpayUiDefinition } from '../shared/update-oxpay-ui-definition'; -import { migrate as migrateCLipsAndOx } from './20240311180000_definition_update_for_oxpay_and_clipspay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - await migrateCLipsAndOx(client, app); - await updateClipspayUiDefinition(client); - await updateOxpayUiDefinition(client); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240316204058_oxpay_alert_definitions_v2.ts b/services/workflows-service/prisma/data-migrations/dev/20240316204058_oxpay_alert_definitions_v2.ts deleted file mode 100644 index d5432f610a..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240316204058_oxpay_alert_definitions_v2.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { generateAlertDefinitions } from '../../../scripts/alerts/generate-alerts'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const project = await transaction.project.findFirstOrThrow({ - where: { - customer: { - name: 'oxpay', - }, - }, - }); - - await generateAlertDefinitions(transaction, { - project, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240415104851_update_fido_workflow_definition_config.ts b/services/workflows-service/prisma/data-migrations/dev/20240415104851_update_fido_workflow_definition_config.ts deleted file mode 100644 index 9e94a4065c..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240415104851_update_fido_workflow_definition_config.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { getFidoWorkflowDefinition } from 'prisma/data-migrations/templates/creation/create-ln16-for-customer'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const customer = await transaction.customer.findFirstOrThrow({ - where: { - name: 'fido', - }, - select: { - id: true, - projects: true, - }, - }); - - const projectId = customer.projects.map(project => project.id)[0]!; - - await transaction.workflowDefinition.update({ - where: { - id: 'fido-l16-business-ghana', - }, - data: { - config: getFidoWorkflowDefinition(projectId).config, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240425170230_oxpay_definition_update.ts b/services/workflows-service/prisma/data-migrations/dev/20240425170230_oxpay_definition_update.ts deleted file mode 100644 index c0d71cf54a..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240425170230_oxpay_definition_update.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; -const associatedCompanyWorkflowDefinitionId = 'oxpay_child_associated_company'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - associatedCompanyWorkflowDefinitionId, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: oxpayWorkflowDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240430162030_oxpay_definition_update.ts b/services/workflows-service/prisma/data-migrations/dev/20240430162030_oxpay_definition_update.ts deleted file mode 100644 index c0d71cf54a..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240430162030_oxpay_definition_update.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; -const associatedCompanyWorkflowDefinitionId = 'oxpay_child_associated_company'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - associatedCompanyWorkflowDefinitionId, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: oxpayWorkflowDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240501144700_insert_oxpay_existing_ubos.ts b/services/workflows-service/prisma/data-migrations/dev/20240501144700_insert_oxpay_existing_ubos.ts deleted file mode 100644 index 255eb0170c..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240501144700_insert_oxpay_existing_ubos.ts +++ /dev/null @@ -1,141 +0,0 @@ -import { EndUser, PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { logger } from '@ballerine/workflow-core'; -import { env } from '@/env'; -import { z } from 'zod'; -import { EndUserActiveMonitoringsSchema } from '@/end-user/end-user.schema'; -import axios from 'axios'; -import { ApprovalState } from '@/business/dtos/business-create'; -import axiosRetry from 'axios-retry'; - -type Ubo = { - firstName: string; - lastName: string; - correlationId: string; -}; - -const ubos: Ubo[] = [ - { - firstName: 'MANSOUR', - lastName: 'AHMADI', - correlationId: '9abf7813-5dbf-4dcf-abf3-21a6af5ac839', - }, -]; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - const oxpayProjectId = 'oxpay_default'; - let endUsers: EndUser[] = []; - - await client.$transaction( - async transaction => { - await Promise.all( - ubos.map(async ubo => { - await transaction.endUser.create({ - data: { - firstName: ubo.firstName, - lastName: ubo.lastName, - correlationId: ubo.correlationId, - approvalState: ApprovalState.APPROVED, - project: { - connect: { - id: oxpayProjectId, - }, - }, - }, - }); - }), - ); - - endUsers = await transaction.endUser.findMany({ - where: { - projectId: oxpayProjectId, - correlationId: { - in: ubos.map(({ correlationId }) => correlationId), - }, - }, - }); - - logger.log( - 'Created end users: ', - endUsers.map(({ id }) => id), - ); - }, - { - timeout: 300_000, - maxWait: 300_000, - }, - ); - - const axiosClient = axios.create(); - axiosRetry(axiosClient, { - retries: 10, - retryDelay: axiosRetry.exponentialDelay, - }); - - const sleep = (time: number) => new Promise(resolve => setTimeout(resolve, time)); - - const amlSessions = await Promise.allSettled( - endUsers.map(async endUser => { - const response = await axiosClient.post( - `${env.UNIFIED_API_URL}/aml-sessions`, - { - endUserId: endUser.id, - firstName: endUser.firstName, - lastName: endUser.lastName, - callbackUrl: `${env.APP_API_URL}/api/v1/webhooks/individual/aml`, - ongoingMonitoring: true, - vendor: 'veriff', - }, - { - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${env.UNIFIED_API_TOKEN}`, - }, - }, - ); - - await sleep(100); - - return [response.data, endUser] as const; - }), - ); - - await client.$transaction( - async transaction => { - for (const result of amlSessions) { - if (result.status === 'rejected') { - logger.error('Failed to create AML session', { - reason: result.reason, - }); - - return; - } - - const [response, endUser] = result.value; - - await transaction.endUser.update({ - where: { - id: endUser.id, - }, - data: { - activeMonitorings: [ - ...(endUser.activeMonitorings as any[]), - { - type: 'aml', - vendor: 'veriff', - monitoredUntil: new Date( - new Date().setFullYear(new Date().getFullYear() + 3), - ).toISOString(), - sessionId: response.id, - }, - ] satisfies z.infer, - }, - }); - } - }, - { - timeout: 300_000, - maxWait: 300_000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240506202400_another_ongoing_monitoring_test.ts b/services/workflows-service/prisma/data-migrations/dev/20240506202400_another_ongoing_monitoring_test.ts deleted file mode 100644 index ce96c20b8f..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240506202400_another_ongoing_monitoring_test.ts +++ /dev/null @@ -1,141 +0,0 @@ -import { EndUser, PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { logger } from '@ballerine/workflow-core'; -import { env } from '@/env'; -import { z } from 'zod'; -import { EndUserActiveMonitoringsSchema } from '@/end-user/end-user.schema'; -import axios from 'axios'; -import { ApprovalState } from '@/business/dtos/business-create'; -import axiosRetry from 'axios-retry'; - -type Ubo = { - firstName: string; - lastName: string; - correlationId: string; -}; - -const ubos: Ubo[] = [ - { - firstName: 'ALEXIS', - lastName: 'FLORES', - correlationId: '9abf7813-5dbf-4dcf-abf3-21a6af5ac000', - }, -]; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - const oxpayProjectId = 'oxpay_default'; - let endUsers: EndUser[] = []; - - await client.$transaction( - async transaction => { - await Promise.all( - ubos.map(async ubo => { - await transaction.endUser.create({ - data: { - firstName: ubo.firstName, - lastName: ubo.lastName, - correlationId: ubo.correlationId, - approvalState: ApprovalState.APPROVED, - project: { - connect: { - id: oxpayProjectId, - }, - }, - }, - }); - }), - ); - - endUsers = await transaction.endUser.findMany({ - where: { - projectId: oxpayProjectId, - correlationId: { - in: ubos.map(({ correlationId }) => correlationId), - }, - }, - }); - - logger.log( - 'Created end users: ', - endUsers.map(({ id }) => id), - ); - }, - { - timeout: 300_000, - maxWait: 300_000, - }, - ); - - const axiosClient = axios.create(); - axiosRetry(axiosClient, { - retries: 10, - retryDelay: axiosRetry.exponentialDelay, - }); - - const sleep = (time: number) => new Promise(resolve => setTimeout(resolve, time)); - - const amlSessions = await Promise.allSettled( - endUsers.map(async endUser => { - const response = await axiosClient.post( - `${env.UNIFIED_API_URL}/aml-sessions`, - { - endUserId: endUser.id, - firstName: endUser.firstName, - lastName: endUser.lastName, - callbackUrl: `${env.APP_API_URL}/api/v1/webhooks/individual/aml`, - ongoingMonitoring: true, - vendor: 'veriff', - }, - { - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${env.UNIFIED_API_TOKEN}`, - }, - }, - ); - - await sleep(100); - - return [response.data, endUser] as const; - }), - ); - - await client.$transaction( - async transaction => { - for (const result of amlSessions) { - if (result.status === 'rejected') { - logger.error('Failed to create AML session', { - reason: result.reason, - }); - - return; - } - - const [response, endUser] = result.value; - - await transaction.endUser.update({ - where: { - id: endUser.id, - }, - data: { - activeMonitorings: [ - ...(endUser.activeMonitorings as any[]), - { - type: 'aml', - vendor: 'veriff', - monitoredUntil: new Date( - new Date().setFullYear(new Date().getFullYear() + 3), - ).toISOString(), - sessionId: response.id, - }, - ] satisfies z.infer, - }, - }); - } - }, - { - timeout: 300_000, - maxWait: 300_000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/dev/20240516095716_ongoing_monitoring_demo_init.ts b/services/workflows-service/prisma/data-migrations/dev/20240516095716_ongoing_monitoring_demo_init.ts deleted file mode 100644 index e3285b6618..0000000000 --- a/services/workflows-service/prisma/data-migrations/dev/20240516095716_ongoing_monitoring_demo_init.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { DemoOngoingMonitoringTemplate } from '../templates/creation/ballerine-ongoing-monitoring-demo'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new DemoOngoingMonitoringTemplate(app, transaction, { - customer: { - id: 'ballerinedemo_ongoing_monitoring', - displayName: 'Ballerine Demo', - name: 'ballerinedemo_ongoing_monitoring', - logoImageUrl: '', - apiKey: 'ballerinedemo_ongoing_monitoring_secret', - }, - user: { - firstName: 'Noam', - lastName: 'Izhaki', - email: 'noam-izhaki@ballerine.com', - password: 'noampass', - }, - project: { - id: 'ballerine_demo_ongoing_monitoring_project', - }, - // Not used in this template - filter: { - name: 'KYB', - }, - }); - - await template.generate(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20231128112305_create_demo_definition_and_ui_definition.ts b/services/workflows-service/prisma/data-migrations/local/20231128112305_create_demo_definition_and_ui_definition.ts deleted file mode 100644 index 72c9bfcc2e..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20231128112305_create_demo_definition_and_ui_definition.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { DemoTemplate } from '../templates/creation/demo'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction(async transaction => { - const template = new DemoTemplate(app, transaction, { - customer: { - id: 'demo', - displayName: 'Demo customer', - name: 'demo', - logoImageUrl: 'https://picsum.photos/200', - apiKey: 'demo_secret1', - }, - user: { - firstName: 'John', - lastName: 'Doe', - email: 'demo@mail.com', - password: 'demo', - }, - project: { - id: 'demo-project', - }, - filter: { - name: 'DEMO', - }, - }); - - await template.generate(); - }); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20231128180946_create_fido_ln16.ts b/services/workflows-service/prisma/data-migrations/local/20231128180946_create_fido_ln16.ts deleted file mode 100644 index d6fe0a5d8c..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20231128180946_create_fido_ln16.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { createLn16ForCustomer } from '../templates'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await createLn16ForCustomer(client, app, 'customer-1'); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20231204140137_generate_customer_with_associated_company_kyb.ts b/services/workflows-service/prisma/data-migrations/local/20231204140137_generate_customer_with_associated_company_kyb.ts deleted file mode 100644 index 9e9061f515..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20231204140137_generate_customer_with_associated_company_kyb.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { KybWithAssociatedCompaniesTemplate } from '../templates/creation/child-associated-company'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction(async transaction => { - const template = new KybWithAssociatedCompaniesTemplate(app, transaction, { - customer: { - name: 'associated', - displayName: 'Associated customer', - logoImageUrl: 'https://picsum.photos/300', - apiKey: 'associated_secret', - }, - user: { - firstName: 'asoJohn', - lastName: 'asoDoe', - email: 'aso@mail.com', - password: 'aso', - }, - project: { - id: 'aso-project', - }, - filter: { - name: 'ASSOCIATED', - }, - }); - - await template.generate(); - }); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20231211182144_generate_clipspay.ts b/services/workflows-service/prisma/data-migrations/local/20231211182144_generate_clipspay.ts deleted file mode 100644 index 50448f886c..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20231211182144_generate_clipspay.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { ClipspayTemplate } from 'prisma/data-migrations/templates/creation/clipspay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new ClipspayTemplate(app, transaction, { - definition: { - id: 'kyb_dynamic_ui_session_example', - name: 'kyb_dynamic_ui_session_example', - }, - user: { - firstName: 'Clips', - lastName: 'Pay', - email: 'clipspay@example.com', - password: 'clipspay', - }, - customer: { - name: 'clipspay', - displayName: 'Clipspay', - apiKey: 'clipspay_secret', - logoImageUrl: '', - }, - project: { - id: 'clipspay', - }, - filter: { - name: 'Clipspay', - }, - }); - - await template.generate(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20231213130258_add_variants_to_filters.ts b/services/workflows-service/prisma/data-migrations/local/20231213130258_add_variants_to_filters.ts deleted file mode 100644 index 46c235b461..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20231213130258_add_variants_to_filters.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { baseFilterDefinitionSelect } from '../../../scripts/filters'; -import { fetchCustomerProject } from '../shared/fetch-customer-project'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const fidoProject = await fetchCustomerProject(transaction, 'fido'); - const clipspayProjects = await fetchCustomerProject(transaction, 'clipspay'); - const yunheProjects = await fetchCustomerProject(transaction, 'yunhe'); - - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: fidoProject } } }, - data: { variant: 'MANUAL_REVIEW' }, - }); - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: clipspayProjects } } }, - data: { - variant: 'DEFAULT', - }, - }); - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: yunheProjects } } }, - data: { variant: 'DEFAULT' }, - }); - - const allFilters = await transaction.filter.findMany({}); - - for (const filter of allFilters) { - const query = filter.query as { - select: { workflowDefinition: Record }; - }; - query.select.workflowDefinition = { - ...baseFilterDefinitionSelect['workflowDefinition'], - }; - - await transaction.filter.update({ - where: { id: filter.id }, - data: { query }, - }); - } - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240125163250_is_case_overview_enabled_config_clipspay.ts b/services/workflows-service/prisma/data-migrations/local/20240125163250_is_case_overview_enabled_config_clipspay.ts deleted file mode 100644 index 86287c3004..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240125163250_is_case_overview_enabled_config_clipspay.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as updateClipspayMigration from '../common/20231217173250_update_clipspay_definition'; - -export const migrate = updateClipspayMigration.migrate; diff --git a/services/workflows-service/prisma/data-migrations/local/20240201162245_oxpay_initial.ts b/services/workflows-service/prisma/data-migrations/local/20240201162245_oxpay_initial.ts deleted file mode 100644 index 36b8d47afe..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240201162245_oxpay_initial.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { OxpayTemplate } from 'prisma/data-migrations/templates/creation/oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new OxpayTemplate(app, transaction, { - definition: { - id: 'kyb_w_ubos_oxpay', - name: 'kyb_w_ubos_oxpay', - }, - user: { - firstName: 'OxPay', - lastName: 'Admin', - email: 'admin@oxpayfinancial.com', - password: 'oxpaypass', - }, - customer: { - name: 'oxpay', - displayName: 'OxPay', - apiKey: 'oxpay_secret', - logoImageUrl: 'https://cdn.ballerine.io/images/oxpay_logo_opt.svg', - faviconImageUri: 'https://cdn.ballerine.io/images/oxpay_logo_xs.png', - }, - project: { - id: 'oxpay_default', - }, - filter: { - name: 'Merchants KYB', - }, - }); - - await template.generate(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240205104840_ballerine_qa_user.ts b/services/workflows-service/prisma/data-migrations/local/20240205104840_ballerine_qa_user.ts deleted file mode 100644 index 8dc02e406b..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240205104840_ballerine_qa_user.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { BallerineQATemplate } from 'prisma/data-migrations/templates/creation/ballerine-qa'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new BallerineQATemplate(app, transaction, { - definition: { - id: 'kyb_w_ubos_ballerine', - name: 'kyb_w_ubos_ballerine', - }, - user: { - firstName: 'ballerine', - lastName: 'Admin', - email: 'admin@ballerine.com', - password: ' ', - }, - customer: { - name: 'ballerine', - displayName: 'ballerine', - apiKey: 'ballerine_secret', - logoImageUrl: '', - }, - project: { - id: 'ballerine_default', - }, - filter: { - name: 'Clipspay KYB', - }, - }); - - await template.generateClipspayProject(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240222150821_update_oxpay_auth_details.ts b/services/workflows-service/prisma/data-migrations/local/20240222150821_update_oxpay_auth_details.ts deleted file mode 100644 index 24836813cc..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240222150821_update_oxpay_auth_details.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { PrismaClient } from '@prisma/client'; - -export const migrate = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - const customer = await transaction.customer.findFirst({ - where: { - name: { - contains: 'oxpay', - }, - }, - select: { - id: true, - authenticationConfiguration: true, - }, - }); - - if ( - !customer?.authenticationConfiguration || - typeof customer.authenticationConfiguration !== 'object' - ) { - return; - } - - const newAuthenticationConfiguration = { - ...customer.authenticationConfiguration, - authValue: 'Oxpay-ZT7CJSiUsaFYq7xGQiSBk', - webhookSharedSecret: 'Oxpay-2LnkYwvYnm7MODlJDbTgi', - }; - - await transaction.customer.update({ - where: { - id: customer.id, - }, - data: { - authenticationConfiguration: newAuthenticationConfiguration, - }, - }); - }, - { - timeout: 25000, - maxWait: 25000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240222154622_axs_init.ts b/services/workflows-service/prisma/data-migrations/local/20240222154622_axs_init.ts deleted file mode 100644 index 93019732e4..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240222154622_axs_init.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { KybTemplate } from '../templates/creation/kyb'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new KybTemplate(app, transaction, { - definition: { - id: 'kyb_w_ubos_axs', - name: 'kyb_w_ubos_axs', - }, - user: { - firstName: 'AXS', - lastName: 'Admin', - email: 'admin@axs.com.sg', - password: 'axspass', - }, - customer: { - name: 'axs', - displayName: 'AXS', - apiKey: 'axs_secret', - logoImageUrl: 'https://cdn.ballerine.io/images/axs_logo_l.png', - faviconImageUri: 'https://cdn.ballerine.io/images/axs_logo_xs.png', - }, - project: { - id: 'axs_default', - }, - filter: { - name: 'Merchants KYB', - }, - }); - - await template.generate(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240222190921_update_oxpay_ui_schema.ts b/services/workflows-service/prisma/data-migrations/local/20240222190921_update_oxpay_ui_schema.ts deleted file mode 100644 index 43ae006c31..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240222190921_update_oxpay_ui_schema.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { composeUiDefinition } from '../templates/creation/oxpay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; - -export const migrate = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - const currentUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: 'kyb_w_ubos_oxpay', - }, - select: { - id: true, - }, - }); - - if (!currentUiDefinition) { - return; - } - - const updatedOxpayUiDefinition = composeUiDefinition( - 'kyb_w_ubos_oxpay', - generateDefinitionLogic('kyb_w_ubos_oxpay'), - ); - - return transaction.uiDefinition.update({ - where: { - id: currentUiDefinition.id, - }, - data: { - uiSchema: updatedOxpayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240225161500_update_oxpay_ui_schema_2.ts b/services/workflows-service/prisma/data-migrations/local/20240225161500_update_oxpay_ui_schema_2.ts deleted file mode 100644 index 1419d0c71f..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240225161500_update_oxpay_ui_schema_2.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateOxPayUiSchema } from '../shared/update-oxpay-ui-schema'; - -export const migrate = updateOxPayUiSchema; diff --git a/services/workflows-service/prisma/data-migrations/local/20240228120858_update_workflows_to_stop_relying_on_post_event_execution.ts b/services/workflows-service/prisma/data-migrations/local/20240228120858_update_workflows_to_stop_relying_on_post_event_execution.ts deleted file mode 100644 index ff775beb6e..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240228120858_update_workflows_to_stop_relying_on_post_event_execution.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { PrismaClient, Prisma } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { createWorkflow } from '@ballerine/workflow-core'; - -type Definition = Parameters[0]['definition']; -const TASK_REVIEWED_EVENT = [ - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'approved']) == length(documents)", - }, - }, - target: 'approved', - }, - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'rejected']) > `0`", - }, - }, - target: 'rejected', - }, - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'revision']) > `0`", - }, - }, - target: 'revision', - }, -]; -const RETURN_TO_REVIEW_EVENT = { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: 'length(documents[?decision.status]) < length(documents)', - }, - }, -}; -const workflowDefinitionsToUpdate: { - [id: string]: Definition; -} = { - fido_biz_ghana: { - id: 'fido_biz_ghana', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - fido_biz_uganda: { - id: 'fido_biz_uganda', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'risk-score-improvement-uganda': { - id: 'risk-score-improvement-uganda', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { tags: ['revision'], type: 'final' }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'risk-score-improvement-dev': { - id: 'risk-score-improvement', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { tags: ['revision'], type: 'final' }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'fido-l16-business-ghana': { - id: 'fido-l16-business-ghana-v1', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, -}; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - for (const [id, definition] of Object.entries(workflowDefinitionsToUpdate)) { - await transaction.workflowDefinition.updateMany({ - where: { id }, - data: { - definition: definition as Prisma.InputJsonValue, - }, - }); - } - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240228160000_create_oxpay_ongoing_monitoring.ts b/services/workflows-service/prisma/data-migrations/local/20240228160000_create_oxpay_ongoing_monitoring.ts deleted file mode 100644 index d038d91333..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240228160000_create_oxpay_ongoing_monitoring.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { createOngoingMonitoringFilter } from '../shared/create-ongoing-monitoring-filter'; -import { createOngoingMonitoringWorkflowDefinition } from '../shared/create-onging-monitoring-workflow-definition'; - -export const migrate = async (client: PrismaClient) => { - await createOngoingMonitoringWorkflowDefinition(client); - await createOngoingMonitoringFilter(client); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240304141000_update_oxpay_customer_config_with_ongoing_workflow.ts b/services/workflows-service/prisma/data-migrations/local/20240304141000_update_oxpay_customer_config_with_ongoing_workflow.ts deleted file mode 100644 index fe8fc0a4f8..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240304141000_update_oxpay_customer_config_with_ongoing_workflow.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { generateOngoingWorkflowDefinition } from '../templates/creation/oxpay/workflow-definition/ongoing-workflow-definition'; -import { ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, OXPAY_PROJECT_ID } from '../shared/consts'; - -export const migrate = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - await transaction.customer.update({ - where: { name: 'oxpay' }, - data: { - config: { - ongoingWorkflowDefinitionId: 'ongoing_monitoring_oxpay', - }, - }, - }); - - const ongoingWorkflowDefinition = generateOngoingWorkflowDefinition( - ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - OXPAY_PROJECT_ID, - ); - - await transaction.workflowDefinition.update({ - where: { id: ONGOING_MONITORING_WORKFLOW_DEFINITION_ID }, - data: ongoingWorkflowDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240304150030_oxpay_associated_definition.ts b/services/workflows-service/prisma/data-migrations/local/20240304150030_oxpay_associated_definition.ts deleted file mode 100644 index 5f01d07010..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240304150030_oxpay_associated_definition.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { composeChildAssociatedCompanyDefinition } from '../templates/creation/child-associated-company/definition/compose-child-associated-company-definition'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - const childAssociatedCompanyDefinition = composeChildAssociatedCompanyDefinition({ - definitionId: `oxpay_child_associated_company`, - definitionName: `oxpay_child_associated_company`, - projectId: oxpayProjectIds[0]!, - }); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - childAssociatedCompanyDefinition.id, - ); - - await transaction.workflowDefinition.create({ - data: childAssociatedCompanyDefinition, - }); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: oxpayWorkflowDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240306114003_oxpay_is_associated_company_kyb_enabled.ts b/services/workflows-service/prisma/data-migrations/local/20240306114003_oxpay_is_associated_company_kyb_enabled.ts deleted file mode 100644 index f2b92f1e32..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240306114003_oxpay_is_associated_company_kyb_enabled.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { isObject } from '@ballerine/common'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const workflowDefinition = await transaction.workflowDefinition.findFirstOrThrow({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - }); - const config = { - ...(isObject(workflowDefinition.config) ? workflowDefinition.config : {}), - isAssociatedCompanyKybEnabled: false, - } satisfies Parameters[0]['data']['config']; - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - config, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240306122002_clipspay_child_omit_fix.ts b/services/workflows-service/prisma/data-migrations/local/20240306122002_clipspay_child_omit_fix.ts deleted file mode 100644 index 2c43269f44..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240306122002_clipspay_child_omit_fix.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -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 clipspayProjectIds = await fetchCustomerProjectIds(transaction, 'clipspay'); - - const newClipspayWorkflow = generateWorkflowDefinition( - clipspayDefinitionName, - clipspayDefinitionName, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: clipspayProjectIds }, - name: clipspayDefinitionName, - }, - data: { - extensions: newClipspayWorkflow.extensions, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240307114345_oxpay_inprogress_process_fix.ts b/services/workflows-service/prisma/data-migrations/local/20240307114345_oxpay_inprogress_process_fix.ts deleted file mode 100644 index c753826a20..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240307114345_oxpay_inprogress_process_fix.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { composeChildAssociatedCompanyDefinition } from '../templates/creation/child-associated-company/definition/compose-child-associated-company-definition'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const childAssociatedCompanyDefinition = composeChildAssociatedCompanyDefinition({ - definitionId: `oxpay_child_associated_company`, - definitionName: `oxpay_child_associated_company`, - projectId: oxpayProjectIds[0]!, - }); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - childAssociatedCompanyDefinition.id, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - extensions: oxpayWorkflowDefinition.extensions, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240311112400_oxpay_associated_companies_docs_fix.ts b/services/workflows-service/prisma/data-migrations/local/20240311112400_oxpay_associated_companies_docs_fix.ts deleted file mode 100644 index 8f1f905658..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240311112400_oxpay_associated_companies_docs_fix.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; -import { composeUiDefinition } from '../templates/creation/oxpay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const assosciatedCompanyWorkflowDefinition = await transaction.workflowDefinition.findFirst({ - where: { - projectId: { in: oxpayProjectIds }, - name: 'oxpay_child_associated_company', - }, - select: { - id: true, - }, - }); - - if (!assosciatedCompanyWorkflowDefinition) { - return; - } - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - assosciatedCompanyWorkflowDefinition.id, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - extensions: oxpayWorkflowDefinition.extensions, - }, - }); - - const updatedOxpayUiDefinition = composeUiDefinition( - oxpayDefinitionName, - generateDefinitionLogic(oxpayDefinitionName), - ); - - const currentUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: oxpayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentUiDefinition) { - return; - } - - await transaction.uiDefinition.update({ - where: { - id: currentUiDefinition.id, - }, - data: { - uiSchema: updatedOxpayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240311180000_definition_update_for_oxpay_and_clipspay.ts b/services/workflows-service/prisma/data-migrations/local/20240311180000_definition_update_for_oxpay_and_clipspay.ts deleted file mode 100644 index b8e8ea5d46..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240311180000_definition_update_for_oxpay_and_clipspay.ts +++ /dev/null @@ -1,131 +0,0 @@ -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { composeUiDefinition as composeOxpayUiDefinition } from 'prisma/data-migrations/templates/creation/oxpay/collection-flow/compose-ui-definition'; -import { composeUiDefinition as composeClipspayUiDefinition } from '../templates/creation/clipspay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic as generateClipspayDefinitionLogic } from '../templates/creation/clipspay/collection-flow/generate-definition-logic'; -import { generateWorkflowDefinition } from '../templates/creation/clipspay/workflow-definition/workflow-definition'; -import { generateDefinitionLogic as generateOxpayDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; -const clipspayDefinitionName = 'kyb_dynamic_ui_session_example'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - // OxPay - - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const assosciatedCompanyWorkflowDefinition = await transaction.workflowDefinition.findFirst({ - where: { - projectId: { in: oxpayProjectIds }, - name: 'oxpay_child_associated_company', - }, - select: { - id: true, - }, - }); - - if (!assosciatedCompanyWorkflowDefinition) { - throw new Error('Associated Company Workflow Definition not found'); - } - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - assosciatedCompanyWorkflowDefinition.id, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - extensions: oxpayWorkflowDefinition.extensions, - }, - }); - - const currentOxpayUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: oxpayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentOxpayUiDefinition) { - throw new Error('Oxpay UI Definition not found'); - } - - const updatedOxpayUiDefinition = composeOxpayUiDefinition( - oxpayDefinitionName, - generateOxpayDefinitionLogic(oxpayDefinitionName), - ); - - await transaction.uiDefinition.update({ - where: { - id: currentOxpayUiDefinition.id, - }, - data: { - uiSchema: updatedOxpayUiDefinition.uiSchema, - }, - }); - - // ClipsPay - - const clipspayProjectIds = await fetchCustomerProjectIds(transaction, 'clipspay'); - - const clipspayWorkflowDefinition = generateWorkflowDefinition( - clipspayDefinitionName, - clipspayDefinitionName, - clipspayProjectIds[0]!, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: clipspayProjectIds }, - name: clipspayDefinitionName, - }, - data: { - extensions: clipspayWorkflowDefinition.extensions, - }, - }); - - const currentClipspayUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: clipspayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentClipspayUiDefinition) { - throw new Error('Clipspay UI Definition not found'); - } - - const updatedClipspayUiDefinition = composeClipspayUiDefinition( - clipspayDefinitionName, - generateClipspayDefinitionLogic(clipspayDefinitionName), - ); - - await transaction.uiDefinition.update({ - where: { - id: currentClipspayUiDefinition.id, - }, - data: { - uiSchema: updatedClipspayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240312124500_fix_oxpay_ui_definition.ts b/services/workflows-service/prisma/data-migrations/local/20240312124500_fix_oxpay_ui_definition.ts deleted file mode 100644 index dc31a21a85..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240312124500_fix_oxpay_ui_definition.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { composeUiDefinition } from '../templates/creation/oxpay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const currentOxpayUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: oxpayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentOxpayUiDefinition) { - throw new Error('Oxpay UI Definition not found'); - } - - const updatedOxpayUiDefinition = composeUiDefinition( - oxpayDefinitionName, - generateDefinitionLogic(oxpayDefinitionName), - ); - - await transaction.uiDefinition.update({ - where: { - id: currentOxpayUiDefinition.id, - }, - data: { - uiSchema: updatedOxpayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240313134332_oxpay_update_ui_definition.ts b/services/workflows-service/prisma/data-migrations/local/20240313134332_oxpay_update_ui_definition.ts deleted file mode 100644 index 252e7c30ad..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240313134332_oxpay_update_ui_definition.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateOxpayUiDefinition } from '../shared/update-oxpay-ui-definition'; - -export const migrate = updateOxpayUiDefinition; diff --git a/services/workflows-service/prisma/data-migrations/local/20240313135707_clipspay_update_ui_definition.ts b/services/workflows-service/prisma/data-migrations/local/20240313135707_clipspay_update_ui_definition.ts deleted file mode 100644 index 7f8dc721df..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240313135707_clipspay_update_ui_definition.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateClipspayUiDefinition } from '../shared/update-clipspay-ui-definition'; - -export const migrate = updateClipspayUiDefinition; diff --git a/services/workflows-service/prisma/data-migrations/local/20240314112305_create_demo_ballerine_definition_and_ui_definition.ts b/services/workflows-service/prisma/data-migrations/local/20240314112305_create_demo_ballerine_definition_and_ui_definition.ts deleted file mode 100644 index 7a57a44f6f..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240314112305_create_demo_ballerine_definition_and_ui_definition.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { DemoTemplate } from '../templates/creation/ballerine-demo'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction(async transaction => { - const template = new DemoTemplate(app, transaction, { - customer: { - id: 'ballerinedemo', - displayName: 'Ballerine Demo', - name: 'ballerinedemo', - logoImageUrl: '', - apiKey: 'demo_secret', - }, - user: { - firstName: 'Noam', - lastName: 'Izhaki', - email: 'noam@ballerine.com', - password: 'noampass', - }, - project: { - id: 'ballerine-demo-project', - }, - filter: { - name: 'KYB', - }, - }); - - await template.generate(); - }); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240314113547_update_oxpay_and_clipspay_definition.ts b/services/workflows-service/prisma/data-migrations/local/20240314113547_update_oxpay_and_clipspay_definition.ts deleted file mode 100644 index 157a4650fd..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240314113547_update_oxpay_and_clipspay_definition.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { updateClipspayUiDefinition } from '../shared/update-clipspay-ui-definition'; -import { updateOxpayUiDefinition } from '../shared/update-oxpay-ui-definition'; -import { migrate as migrateCLipsAndOx } from './20240311180000_definition_update_for_oxpay_and_clipspay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - await migrateCLipsAndOx(client, app); - await updateClipspayUiDefinition(client); - await updateOxpayUiDefinition(client); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240314190319_definition_update_fix.ts b/services/workflows-service/prisma/data-migrations/local/20240314190319_definition_update_fix.ts deleted file mode 100644 index 157a4650fd..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240314190319_definition_update_fix.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { updateClipspayUiDefinition } from '../shared/update-clipspay-ui-definition'; -import { updateOxpayUiDefinition } from '../shared/update-oxpay-ui-definition'; -import { migrate as migrateCLipsAndOx } from './20240311180000_definition_update_for_oxpay_and_clipspay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - await migrateCLipsAndOx(client, app); - await updateClipspayUiDefinition(client); - await updateOxpayUiDefinition(client); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240320182549_create_ongoing_oxpay_definition_report.ts b/services/workflows-service/prisma/data-migrations/local/20240320182549_create_ongoing_oxpay_definition_report.ts deleted file mode 100644 index 86fa4b2e4a..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240320182549_create_ongoing_oxpay_definition_report.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { CustomerService } from '@/customer/customer.service'; -import { CustomerRepository } from '@/customer/customer.repository'; -import { CUSTOMER_FEATURES, FEATURE_LIST } from '@/customer/types'; -import { generateOngoingWorkflowDefinition } from '../templates/creation/oxpay/ongoing-report/workflow-definition'; -import { WorkflowDefinitionRepository } from '@/workflow-defintion/workflow-definition.repository'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxylabs = await app - .get(CustomerRepository) - .findByName('oxpay', { include: { projects: true } }); - const projectIds = oxylabs.projects[0].id; - - await app.get(CustomerService).updateById(oxylabs.id, { - data: { - features: { - [FEATURE_LIST.ONGOING_MERCHANT_REPORT_T1]: CUSTOMER_FEATURES.ONGOING_MERCHANT_REPORT_T1, - }, - }, - }); - - const definition = generateOngoingWorkflowDefinition({ - id: 'oxpay_ongoing_t1_report', - name: 'oxpay_ongoing_t1_report', - projectId: projectIds, - }); - - await app.get(WorkflowDefinitionRepository).create({ - data: { - ...definition, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240415104851_update_fido_workflow_definition_config.ts b/services/workflows-service/prisma/data-migrations/local/20240415104851_update_fido_workflow_definition_config.ts deleted file mode 100644 index 15d2ee089c..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240415104851_update_fido_workflow_definition_config.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { getFidoWorkflowDefinition } from 'prisma/data-migrations/templates/creation/create-ln16-for-customer'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const customer = await transaction.customer.findFirstOrThrow({ - where: { - name: 'customer-1', - }, - select: { - id: true, - projects: true, - }, - }); - - const projectId = customer.projects.map(project => project.id)[0]!; - - await transaction.workflowDefinition.update({ - where: { - id: 'fido-l16-business-ghana', - }, - data: { - config: getFidoWorkflowDefinition(projectId).config, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240425170230_oxpay_definition_update.ts b/services/workflows-service/prisma/data-migrations/local/20240425170230_oxpay_definition_update.ts deleted file mode 100644 index c0d71cf54a..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240425170230_oxpay_definition_update.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; -const associatedCompanyWorkflowDefinitionId = 'oxpay_child_associated_company'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - associatedCompanyWorkflowDefinitionId, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: oxpayWorkflowDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240430162030_oxpay_definition_update.ts b/services/workflows-service/prisma/data-migrations/local/20240430162030_oxpay_definition_update.ts deleted file mode 100644 index c0d71cf54a..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240430162030_oxpay_definition_update.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; -const associatedCompanyWorkflowDefinitionId = 'oxpay_child_associated_company'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - associatedCompanyWorkflowDefinitionId, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: oxpayWorkflowDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/local/20240508123559_ongoing_monitoring_demo_init.ts b/services/workflows-service/prisma/data-migrations/local/20240508123559_ongoing_monitoring_demo_init.ts deleted file mode 100644 index e3285b6618..0000000000 --- a/services/workflows-service/prisma/data-migrations/local/20240508123559_ongoing_monitoring_demo_init.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { DemoOngoingMonitoringTemplate } from '../templates/creation/ballerine-ongoing-monitoring-demo'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new DemoOngoingMonitoringTemplate(app, transaction, { - customer: { - id: 'ballerinedemo_ongoing_monitoring', - displayName: 'Ballerine Demo', - name: 'ballerinedemo_ongoing_monitoring', - logoImageUrl: '', - apiKey: 'ballerinedemo_ongoing_monitoring_secret', - }, - user: { - firstName: 'Noam', - lastName: 'Izhaki', - email: 'noam-izhaki@ballerine.com', - password: 'noampass', - }, - project: { - id: 'ballerine_demo_ongoing_monitoring_project', - }, - // Not used in this template - filter: { - name: 'KYB', - }, - }); - - await template.generate(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/migration-template.hbs b/services/workflows-service/prisma/data-migrations/migration-template.hbs deleted file mode 100644 index a6cfe95aab..0000000000 --- a/services/workflows-service/prisma/data-migrations/migration-template.hbs +++ /dev/null @@ -1,14 +0,0 @@ - -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from "@nestjs/common"; - -export const migrate = async(client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction(async (transaction) =>{ - // TRANSACTION is only available when using the transaction variable as the prisma client. - // Everything else in the scope is not in transaction scope - // put your migration code here - }, { -timeout: 15000, -maxWait: 15000 -}); -}; diff --git a/services/workflows-service/prisma/data-migrations/plopfile.js b/services/workflows-service/prisma/data-migrations/plopfile.js deleted file mode 100644 index e5b37b241e..0000000000 --- a/services/workflows-service/prisma/data-migrations/plopfile.js +++ /dev/null @@ -1,39 +0,0 @@ -module.exports = plop => { - // Data migration generator - plop.setGenerator('data-migration', { - description: 'Create a new data migration file', - prompts: [ - { - type: 'list', - name: 'env', - message: 'Select environment:', - choices: ['common', 'local', 'dev', 'sb', 'prod'], - default: 'local', - }, - { - type: 'input', - name: 'migrationName', - message: 'Enter the migration name:', - }, - ], - actions: [ - data => { - const now = new Date(); - const year = now.getFullYear(); - const month = (now.getMonth() + 1).toString().padStart(2, '0'); - const day = now.getDate().toString().padStart(2, '0'); - const hours = now.getHours().toString().padStart(2, '0'); - const minutes = now.getMinutes().toString().padStart(2, '0'); - const seconds = now.getSeconds().toString().padStart(2, '0'); - data.date = `${year}${month}${day}${hours}${minutes}${seconds}`; - - return ''; - }, - { - type: 'add', - path: 'prisma/data-migrations/{{env}}/{{date}}_{{snakeCase migrationName}}.ts', - templateFile: './migration-template.hbs', - }, - ], - }); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20231128180946_create_fido_ln16.ts b/services/workflows-service/prisma/data-migrations/prod/20231128180946_create_fido_ln16.ts deleted file mode 100644 index 870704ef2a..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20231128180946_create_fido_ln16.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { createLn16ForCustomer } from '../templates'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await createLn16ForCustomer(client, app, 'fido'); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20231213130258_add_variants_to_filters.ts b/services/workflows-service/prisma/data-migrations/prod/20231213130258_add_variants_to_filters.ts deleted file mode 100644 index 46c235b461..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20231213130258_add_variants_to_filters.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { baseFilterDefinitionSelect } from '../../../scripts/filters'; -import { fetchCustomerProject } from '../shared/fetch-customer-project'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const fidoProject = await fetchCustomerProject(transaction, 'fido'); - const clipspayProjects = await fetchCustomerProject(transaction, 'clipspay'); - const yunheProjects = await fetchCustomerProject(transaction, 'yunhe'); - - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: fidoProject } } }, - data: { variant: 'MANUAL_REVIEW' }, - }); - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: clipspayProjects } } }, - data: { - variant: 'DEFAULT', - }, - }); - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: yunheProjects } } }, - data: { variant: 'DEFAULT' }, - }); - - const allFilters = await transaction.filter.findMany({}); - - for (const filter of allFilters) { - const query = filter.query as { - select: { workflowDefinition: Record }; - }; - query.select.workflowDefinition = { - ...baseFilterDefinitionSelect['workflowDefinition'], - }; - - await transaction.filter.update({ - where: { id: filter.id }, - data: { query }, - }); - } - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240110121829_update_clipspay_workflow_definition.ts b/services/workflows-service/prisma/data-migrations/prod/20240110121829_update_clipspay_workflow_definition.ts deleted file mode 100644 index 1a69295225..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240110121829_update_clipspay_workflow_definition.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as clipspayMigration from '../common/20231217173250_update_clipspay_definition'; - -export const migrate = clipspayMigration.migrate; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240205104840_ballerine_qa_user.ts b/services/workflows-service/prisma/data-migrations/prod/20240205104840_ballerine_qa_user.ts deleted file mode 100644 index 8dc02e406b..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240205104840_ballerine_qa_user.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { BallerineQATemplate } from 'prisma/data-migrations/templates/creation/ballerine-qa'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new BallerineQATemplate(app, transaction, { - definition: { - id: 'kyb_w_ubos_ballerine', - name: 'kyb_w_ubos_ballerine', - }, - user: { - firstName: 'ballerine', - lastName: 'Admin', - email: 'admin@ballerine.com', - password: ' ', - }, - customer: { - name: 'ballerine', - displayName: 'ballerine', - apiKey: 'ballerine_secret', - logoImageUrl: '', - }, - project: { - id: 'ballerine_default', - }, - filter: { - name: 'Clipspay KYB', - }, - }); - - await template.generateClipspayProject(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240222112845_fido_context_schema_update.ts b/services/workflows-service/prisma/data-migrations/prod/20240222112845_fido_context_schema_update.ts deleted file mode 100644 index 9351eae3db..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240222112845_fido_context_schema_update.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { defaultContextSchema } from '@ballerine/common'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const fidoProjectIds = await fetchCustomerProjectIds(transaction, 'fido'); - - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: fidoProjectIds } } }, - data: { - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240228120858_update_workflows_to_stop_relying_on_post_event_execution.ts b/services/workflows-service/prisma/data-migrations/prod/20240228120858_update_workflows_to_stop_relying_on_post_event_execution.ts deleted file mode 100644 index ff775beb6e..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240228120858_update_workflows_to_stop_relying_on_post_event_execution.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { PrismaClient, Prisma } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { createWorkflow } from '@ballerine/workflow-core'; - -type Definition = Parameters[0]['definition']; -const TASK_REVIEWED_EVENT = [ - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'approved']) == length(documents)", - }, - }, - target: 'approved', - }, - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'rejected']) > `0`", - }, - }, - target: 'rejected', - }, - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'revision']) > `0`", - }, - }, - target: 'revision', - }, -]; -const RETURN_TO_REVIEW_EVENT = { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: 'length(documents[?decision.status]) < length(documents)', - }, - }, -}; -const workflowDefinitionsToUpdate: { - [id: string]: Definition; -} = { - fido_biz_ghana: { - id: 'fido_biz_ghana', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - fido_biz_uganda: { - id: 'fido_biz_uganda', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'risk-score-improvement-uganda': { - id: 'risk-score-improvement-uganda', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { tags: ['revision'], type: 'final' }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'risk-score-improvement-dev': { - id: 'risk-score-improvement', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { tags: ['revision'], type: 'final' }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'fido-l16-business-ghana': { - id: 'fido-l16-business-ghana-v1', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, -}; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - for (const [id, definition] of Object.entries(workflowDefinitionsToUpdate)) { - await transaction.workflowDefinition.updateMany({ - where: { id }, - data: { - definition: definition as Prisma.InputJsonValue, - }, - }); - } - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240310113945_clipspay_child_omit_fix.ts b/services/workflows-service/prisma/data-migrations/prod/20240310113945_clipspay_child_omit_fix.ts deleted file mode 100644 index 2c43269f44..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240310113945_clipspay_child_omit_fix.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -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 clipspayProjectIds = await fetchCustomerProjectIds(transaction, 'clipspay'); - - const newClipspayWorkflow = generateWorkflowDefinition( - clipspayDefinitionName, - clipspayDefinitionName, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: clipspayProjectIds }, - name: clipspayDefinitionName, - }, - data: { - extensions: newClipspayWorkflow.extensions, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240310125503_fido_context_schema_update.ts b/services/workflows-service/prisma/data-migrations/prod/20240310125503_fido_context_schema_update.ts deleted file mode 100644 index 9351eae3db..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240310125503_fido_context_schema_update.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { defaultContextSchema } from '@ballerine/common'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const fidoProjectIds = await fetchCustomerProjectIds(transaction, 'fido'); - - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: fidoProjectIds } } }, - data: { - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240311180000_definition_update_for_oxpay_and_clipspay.ts b/services/workflows-service/prisma/data-migrations/prod/20240311180000_definition_update_for_oxpay_and_clipspay.ts deleted file mode 100644 index b8e8ea5d46..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240311180000_definition_update_for_oxpay_and_clipspay.ts +++ /dev/null @@ -1,131 +0,0 @@ -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { composeUiDefinition as composeOxpayUiDefinition } from 'prisma/data-migrations/templates/creation/oxpay/collection-flow/compose-ui-definition'; -import { composeUiDefinition as composeClipspayUiDefinition } from '../templates/creation/clipspay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic as generateClipspayDefinitionLogic } from '../templates/creation/clipspay/collection-flow/generate-definition-logic'; -import { generateWorkflowDefinition } from '../templates/creation/clipspay/workflow-definition/workflow-definition'; -import { generateDefinitionLogic as generateOxpayDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; -const clipspayDefinitionName = 'kyb_dynamic_ui_session_example'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - // OxPay - - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const assosciatedCompanyWorkflowDefinition = await transaction.workflowDefinition.findFirst({ - where: { - projectId: { in: oxpayProjectIds }, - name: 'oxpay_child_associated_company', - }, - select: { - id: true, - }, - }); - - if (!assosciatedCompanyWorkflowDefinition) { - throw new Error('Associated Company Workflow Definition not found'); - } - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - assosciatedCompanyWorkflowDefinition.id, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - extensions: oxpayWorkflowDefinition.extensions, - }, - }); - - const currentOxpayUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: oxpayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentOxpayUiDefinition) { - throw new Error('Oxpay UI Definition not found'); - } - - const updatedOxpayUiDefinition = composeOxpayUiDefinition( - oxpayDefinitionName, - generateOxpayDefinitionLogic(oxpayDefinitionName), - ); - - await transaction.uiDefinition.update({ - where: { - id: currentOxpayUiDefinition.id, - }, - data: { - uiSchema: updatedOxpayUiDefinition.uiSchema, - }, - }); - - // ClipsPay - - const clipspayProjectIds = await fetchCustomerProjectIds(transaction, 'clipspay'); - - const clipspayWorkflowDefinition = generateWorkflowDefinition( - clipspayDefinitionName, - clipspayDefinitionName, - clipspayProjectIds[0]!, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: clipspayProjectIds }, - name: clipspayDefinitionName, - }, - data: { - extensions: clipspayWorkflowDefinition.extensions, - }, - }); - - const currentClipspayUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: clipspayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentClipspayUiDefinition) { - throw new Error('Clipspay UI Definition not found'); - } - - const updatedClipspayUiDefinition = composeClipspayUiDefinition( - clipspayDefinitionName, - generateClipspayDefinitionLogic(clipspayDefinitionName), - ); - - await transaction.uiDefinition.update({ - where: { - id: currentClipspayUiDefinition.id, - }, - data: { - uiSchema: updatedClipspayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240312114518_clipspay_business_type_length.ts b/services/workflows-service/prisma/data-migrations/prod/20240312114518_clipspay_business_type_length.ts deleted file mode 100644 index a5b95c33ab..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240312114518_clipspay_business_type_length.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateClipspayUiSchema } from '../shared/update-clipspay-ui-schema'; - -export const migrate = updateClipspayUiSchema; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240312173000_oxpay_initial_prod.ts b/services/workflows-service/prisma/data-migrations/prod/20240312173000_oxpay_initial_prod.ts deleted file mode 100644 index 80a03be28d..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240312173000_oxpay_initial_prod.ts +++ /dev/null @@ -1,119 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { generateIndividualsFilter } from '../templates/filters/generate-individuals-filter'; -import { - ONGOING_MONITORING_FILTER_NAME, - ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - OXPAY_PROJECT_ID, - OXPAY_WORKFLOW_DEFINITION_ID, -} from '../shared/consts'; -import { generateOngoingWorkflowDefinition } from '../templates/creation/oxpay/workflow-definition/ongoing-workflow-definition'; -import { composeChildAssociatedCompanyDefinition } from '../templates/creation/child-associated-company/definition/compose-child-associated-company-definition'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; -import { PasswordService } from '@/auth/password/password.service'; -import { generateBusinessesFilter } from '../templates'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const customer = await transaction.customer.create({ - data: { - name: 'oxpay', - displayName: 'OxPay', - logoImageUri: 'https://cdn.ballerine.io/images/oxpay_logo_opt.svg', - faviconImageUri: 'https://cdn.ballerine.io/images/oxpay_logo_xs.png', - config: { - ongoingWorkflowDefinition: ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - }, - authenticationConfiguration: { - apiType: 'API_KEY', - authValue: 'oxpay_secret', - webhookSharedSecret: 'oxpay_shared_secret', - validUntil: '', - isValid: '', - }, - }, - }); - - const passwordService = app.get(PasswordService); - - const user = await transaction.user.create({ - data: { - firstName: 'OxPay', - lastName: 'Admin', - email: 'admin@oxpayfinancial.com', - password: await passwordService.hash('oxpaypass'), - roles: ['user'], - }, - }); - - await transaction.project.create({ - data: { - id: OXPAY_PROJECT_ID, - name: OXPAY_PROJECT_ID, - customerId: customer.id, - userToProjects: { - create: { - userId: user.id, - }, - }, - }, - }); - - const childAssociatedCompanyDefinition = composeChildAssociatedCompanyDefinition({ - definitionId: `oxpay_child_associated_company`, - definitionName: `oxpay_child_associated_company`, - projectId: OXPAY_PROJECT_ID, - }); - - await transaction.workflowDefinition.create({ - data: childAssociatedCompanyDefinition, - }); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - OXPAY_WORKFLOW_DEFINITION_ID, - OXPAY_WORKFLOW_DEFINITION_ID, - OXPAY_PROJECT_ID, - childAssociatedCompanyDefinition.id, - ); - - await transaction.workflowDefinition.create({ - data: oxpayWorkflowDefinition, - }); - - const filter = generateBusinessesFilter({ - filterName: 'Merchants KYB', - definitionId: OXPAY_WORKFLOW_DEFINITION_ID, - projectId: OXPAY_PROJECT_ID, - }); - - await transaction.filter.create({ - data: filter, - }); - - const ongoingWorkflowDefinition = generateOngoingWorkflowDefinition( - ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - OXPAY_PROJECT_ID, - ); - - await transaction.workflowDefinition.create({ - data: ongoingWorkflowDefinition, - }); - - const ongoingFilter = generateIndividualsFilter({ - filterName: ONGOING_MONITORING_FILTER_NAME, - definitionId: ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - projectId: OXPAY_PROJECT_ID, - }); - - await transaction.filter.create({ - data: ongoingFilter, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240313134332_oxpay_update_ui_definition.ts b/services/workflows-service/prisma/data-migrations/prod/20240313134332_oxpay_update_ui_definition.ts deleted file mode 100644 index 252e7c30ad..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240313134332_oxpay_update_ui_definition.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateOxpayUiDefinition } from '../shared/update-oxpay-ui-definition'; - -export const migrate = updateOxpayUiDefinition; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240313135707_clipspay_update_ui_definition.ts b/services/workflows-service/prisma/data-migrations/prod/20240313135707_clipspay_update_ui_definition.ts deleted file mode 100644 index 7f8dc721df..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240313135707_clipspay_update_ui_definition.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateClipspayUiDefinition } from '../shared/update-clipspay-ui-definition'; - -export const migrate = updateClipspayUiDefinition; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240314113547_update_oxpay_and_clipspay_definition.ts b/services/workflows-service/prisma/data-migrations/prod/20240314113547_update_oxpay_and_clipspay_definition.ts deleted file mode 100644 index c4c15ee6bc..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240314113547_update_oxpay_and_clipspay_definition.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { updateClipspayUiDefinition } from '../shared/update-clipspay-ui-definition'; -import { updateOxpayUiDefinition } from '../shared/update-oxpay-ui-definition'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - await updateClipspayUiDefinition(client); - await updateOxpayUiDefinition(client); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240314150853_oxpay_definition_display_name.ts b/services/workflows-service/prisma/data-migrations/prod/20240314150853_oxpay_definition_display_name.ts deleted file mode 100644 index 2f9579ba30..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240314150853_oxpay_definition_display_name.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - displayName: 'KYB', - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240314181407_oxpay_definition_display_name.ts b/services/workflows-service/prisma/data-migrations/prod/20240314181407_oxpay_definition_display_name.ts deleted file mode 100644 index 2f9579ba30..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240314181407_oxpay_definition_display_name.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - displayName: 'KYB', - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240314181422_clipspay_definition_display_name.ts b/services/workflows-service/prisma/data-migrations/prod/20240314181422_clipspay_definition_display_name.ts deleted file mode 100644 index ec45bae5e4..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240314181422_clipspay_definition_display_name.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; - -const clipspayDefinitionName = 'kyb_dynamic_ui_session_example'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const clipspayProjectIds = await fetchCustomerProjectIds(transaction, 'clipspay'); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: clipspayProjectIds }, - name: clipspayDefinitionName, - }, - data: { - displayName: 'KYB', - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240314190319_definition_update_fix.ts b/services/workflows-service/prisma/data-migrations/prod/20240314190319_definition_update_fix.ts deleted file mode 100644 index 5842398ff5..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240314190319_definition_update_fix.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { migrate as migrateCLipsAndOx } from './20240311180000_definition_update_for_oxpay_and_clipspay'; -import { updateClipspayUiDefinition } from '../shared/update-clipspay-ui-definition'; -import { updateOxpayUiDefinition } from '../shared/update-oxpay-ui-definition'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - await migrateCLipsAndOx(client, app); - await updateClipspayUiDefinition(client); - await updateOxpayUiDefinition(client); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240316204058_oxpay_alert_definitions_v2.ts b/services/workflows-service/prisma/data-migrations/prod/20240316204058_oxpay_alert_definitions_v2.ts deleted file mode 100644 index d5432f610a..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240316204058_oxpay_alert_definitions_v2.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { generateAlertDefinitions } from '../../../scripts/alerts/generate-alerts'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const project = await transaction.project.findFirstOrThrow({ - where: { - customer: { - name: 'oxpay', - }, - }, - }); - - await generateAlertDefinitions(transaction, { - project, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240415104851_update_fido_workflow_definition_config.ts b/services/workflows-service/prisma/data-migrations/prod/20240415104851_update_fido_workflow_definition_config.ts deleted file mode 100644 index 9e94a4065c..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240415104851_update_fido_workflow_definition_config.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { getFidoWorkflowDefinition } from 'prisma/data-migrations/templates/creation/create-ln16-for-customer'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const customer = await transaction.customer.findFirstOrThrow({ - where: { - name: 'fido', - }, - select: { - id: true, - projects: true, - }, - }); - - const projectId = customer.projects.map(project => project.id)[0]!; - - await transaction.workflowDefinition.update({ - where: { - id: 'fido-l16-business-ghana', - }, - data: { - config: getFidoWorkflowDefinition(projectId).config, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240417162838_fido_remain_old_ui.ts b/services/workflows-service/prisma/data-migrations/prod/20240417162838_fido_remain_old_ui.ts deleted file mode 100644 index 22fe876aa4..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240417162838_fido_remain_old_ui.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { isObject } from '@ballerine/common'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const workflows = await transaction.workflowDefinition.findMany({ - where: { - id: { - in: [ - 'fido_biz_ghana', - 'fido_biz_uganda', - 'risk-score-improvement-uganda', - 'risk-score-improvement-dev', - 'fido-l16-business-ghana', - ], - }, - }, - }); - - for (const workflow of workflows) { - const existingConfig = isObject(workflow.config) ? workflow.config : {}; - - await transaction.workflowDefinition.update({ - where: { - id: workflow.id, - }, - data: { - config: { - ...existingConfig, - theme: { - type: 'documents-review', - }, - }, - }, - }); - } - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240425170230_oxpay_definition_update.ts b/services/workflows-service/prisma/data-migrations/prod/20240425170230_oxpay_definition_update.ts deleted file mode 100644 index c0d71cf54a..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240425170230_oxpay_definition_update.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; -const associatedCompanyWorkflowDefinitionId = 'oxpay_child_associated_company'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - associatedCompanyWorkflowDefinitionId, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: oxpayWorkflowDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240430162030_oxpay_definition_update.ts b/services/workflows-service/prisma/data-migrations/prod/20240430162030_oxpay_definition_update.ts deleted file mode 100644 index c0d71cf54a..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240430162030_oxpay_definition_update.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; -const associatedCompanyWorkflowDefinitionId = 'oxpay_child_associated_company'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - associatedCompanyWorkflowDefinitionId, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: oxpayWorkflowDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/prod/20240501144700_insert_oxpay_existing_ubos.ts b/services/workflows-service/prisma/data-migrations/prod/20240501144700_insert_oxpay_existing_ubos.ts deleted file mode 100644 index 86cb97947d..0000000000 --- a/services/workflows-service/prisma/data-migrations/prod/20240501144700_insert_oxpay_existing_ubos.ts +++ /dev/null @@ -1,4331 +0,0 @@ -import { EndUser, PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { logger } from '@ballerine/workflow-core'; -import { env } from '@/env'; -import { z } from 'zod'; -import { EndUserActiveMonitoringsSchema } from '@/end-user/end-user.schema'; -import axios from 'axios'; -import { ApprovalState } from '@/business/dtos/business-create'; -import axiosRetry from 'axios-retry'; - -type Ubo = { - firstName: string; - lastName: string; - correlationId: string; -}; - -const ubos: Ubo[] = [ - { - firstName: 'LIM', - lastName: 'YIN CHIAN', - correlationId: '9abf7813-5dbf-4dcf-abf3-21a6af5ac839', - }, - { - firstName: 'ONG', - lastName: 'BAN', - correlationId: 'b3ffca70-fde9-4b2d-9d8e-9f3b7d7c2073', - }, - { - firstName: 'REN', - lastName: 'JIANZHENG', - correlationId: 'da1c53b9-1b3d-4c95-a96b-6d0cef94c25a', - }, - { - firstName: 'ANG', - lastName: 'KWOI HUAT', - correlationId: '87fee203-78b2-4a09-987b-cf9312aa0d4c', - }, - { - firstName: 'KANG', - lastName: 'HAK KHIAM', - correlationId: '323a74b6-b044-4631-a2e8-005fd745dd8e', - }, - { - firstName: 'KHONG', - lastName: 'LAI FONG', - correlationId: '0fb00736-c446-44b6-b450-8919158f48f7', - }, - { - firstName: 'WONG', - lastName: 'CHI FAI', - correlationId: '08ff98ba-c317-4fc6-849b-2fb3b7104cf5', - }, - { - firstName: 'LOR', - lastName: 'MUI YHEE (LUO MEIYI)', - correlationId: '43b5f844-e25b-4f47-b44f-0763350ef562', - }, - { - firstName: 'NG', - lastName: 'KOON KEUNG RICKY', - correlationId: '710af0cf-62ff-44ef-bec1-54f441bc9ca1', - }, - { - firstName: 'YEUNG', - lastName: 'CINDY', - correlationId: 'cfa4c514-0fd2-408a-bc86-eeb331ae8308', - }, - { - firstName: 'PENG', - lastName: 'LI-WEN', - correlationId: '18c3a44a-8d62-4653-b0ea-931de61584ac', - }, - { - firstName: 'WONG', - lastName: 'SEN POH', - correlationId: '723007ab-6f64-4c21-9165-7f260a8e5354', - }, - { - firstName: 'CHIN', - lastName: 'TUNG POH', - correlationId: 'e6bc5954-947b-4494-9413-30a4da7e47b4', - }, - { - firstName: 'PENG', - lastName: 'LI WEN', - correlationId: 'b5071df8-63c9-44e1-aaf4-59786c9a81af', - }, - { - firstName: 'SEAH', - lastName: 'GEK HUANG SANDRA', - correlationId: '7fe29af0-22ba-4216-bc85-f94179cca5a5', - }, - { - firstName: 'CHEE', - lastName: 'THAI HEONG', - correlationId: '81060075-227c-44af-9cb7-f44a3576099a', - }, - { - firstName: 'CHEE', - lastName: 'CHIN CHAI', - correlationId: 'a8b4dadf-469e-4b91-885c-0d24bdb7e14e', - }, - { - firstName: 'CHEE', - lastName: 'TAI CHIEW', - correlationId: 'd1407354-2c6f-42db-8942-3e05063bf9ff', - }, - { - firstName: 'CHAN', - lastName: 'SIEW HOW', - correlationId: '8f970ca3-578f-4ef3-b4ef-6631c008308e', - }, - { - firstName: 'MICHAEL', - lastName: 'VINCENT GAPAS RAMOS', - correlationId: '35b0999d-e6f3-4576-8e3e-b412d29204cc', - }, - { - firstName: 'CHEW', - lastName: 'KAH LEONG', - correlationId: '1c780699-0c8c-444f-8491-96ba9eaee3d7', - }, - { - firstName: 'NG', - lastName: 'TONG CHIN FELIX (HUANG TONGQING)', - correlationId: '7b9c7f56-898f-4b6d-a317-42a159a24cca', - }, - { - firstName: 'TAN', - lastName: 'KEE KHIM', - correlationId: 'c031a882-3123-4a09-a64a-be08848d8de9', - }, - { - firstName: 'MAK', - lastName: 'WAI KHEONG', - correlationId: '23487386-7ac3-4ad7-87c7-5d0c646cc6d4', - }, - { - firstName: 'Ajit', - lastName: 'Manocha', - correlationId: 'f8a5ffdc-4dda-400a-b77b-344e2443af5d', - }, - { - firstName: 'LEE', - lastName: 'SHUN ZHI', - correlationId: '1a5ca86b-df38-4c2f-adf8-d555b626a888', - }, - { - firstName: 'LIM', - lastName: 'PEY WEN', - correlationId: 'e2f8d9a0-6e2e-4423-aaf4-0ad6e497700b', - }, - { - firstName: 'LIM', - lastName: 'HWEE KOON', - correlationId: '23b7c286-1ffd-41d9-8c4a-20f688b47a03', - }, - { - firstName: 'SUN', - lastName: 'YUJIAO', - correlationId: 'f102e5c9-641f-46b0-9a16-ffab8f4f23b5', - }, - { - firstName: 'YEO', - lastName: 'ADAM ZHI HOW', - correlationId: '39a5b8a0-c420-4f04-88e6-371a2fdbff5e', - }, - { - firstName: 'Suthrathip', - lastName: 'Ate', - correlationId: 'd743e0fb-e4ef-4203-9493-73ba2e468205', - }, - { - firstName: 'Pikrit', - lastName: 'Namwat', - correlationId: 'e656a688-5903-4aad-b68e-eb4223c4a0de', - }, - { - firstName: 'Sergio Enrique', - lastName: 'Kaplan', - correlationId: '5c608aec-fdc2-44de-9d83-3e4e5c9cc870', - }, - { - firstName: 'Nirapat', - lastName: 'Surayot', - correlationId: 'c0222dc3-98ee-4f91-b679-0ca9e12f5339', - }, - { - firstName: 'Tinnawat', - lastName: 'Booncharoen', - correlationId: '0338baee-e46d-41f6-b60c-fdf47be83503', - }, - { - firstName: 'Natima', - lastName: 'Urthampimult', - correlationId: 'a723bed8-94b8-4f72-813a-5e98bd4a9fff', - }, - { - firstName: 'Pongpitaya', - lastName: 'Smutrakalin', - correlationId: '541aa0ed-58e1-46f2-80f9-5b99853895e3', - }, - { - firstName: 'Kachorn', - lastName: 'Chialavanont', - correlationId: '8c1ac708-9424-4be6-8cd0-dc436791f947', - }, - { - firstName: 'SOMMAI', - lastName: 'JANCHAD', - correlationId: '3e041600-6c85-4197-b93b-88191b929c0e', - }, - { - firstName: 'SOMPORN', - lastName: 'SIRITANAKORN', - correlationId: 'd8d92c51-1b43-4e2c-b5ab-990057b53a38', - }, - { - firstName: 'MUHAMMAD', - lastName: 'SOLEHUDDIN BIN HJ SHAMSUDDIN', - correlationId: 'bc132e21-c4bf-4616-bd83-f5ac60d37f30', - }, - { - firstName: 'SOMPORN', - lastName: 'SIRITANAK', - correlationId: '610a4cc8-8b61-4637-b85c-ee1661afde9c', - }, - { - firstName: 'SOMMAI', - lastName: 'JANCHAD', - correlationId: '93f4ccb9-10b3-4f5a-8cf5-15f4e73e15a6', - }, - { - firstName: 'CHONG', - lastName: 'FOO KEE', - correlationId: 'a5a9332c-b0f4-4c66-b3aa-b3576527fafd', - }, - { - firstName: 'GOH', - lastName: 'CHIEN LOONG', - correlationId: '5c813197-a3a1-43b7-b8b0-c327083823a2', - }, - { - firstName: 'KEE', - lastName: 'LEE LING', - correlationId: '8c6a609a-f191-4426-916f-f71b5a25bfde', - }, - { - firstName: 'SER', - lastName: 'YIH SUH', - correlationId: '84d5d660-19bd-4f7e-bebe-41893655924c', - }, - { - firstName: 'TAY', - lastName: 'TENG HOCK', - correlationId: 'b66ced04-4d06-4f90-ac8e-6a9dd2a48976', - }, - { - firstName: 'TAY', - lastName: 'TENG GUAN ARTHUR', - correlationId: 'f1e7c08d-7586-424b-8e14-e5a220dcce50', - }, - { - firstName: 'MOHAMMAD ABDULAZIZ', - lastName: 'HASSAN BAKER', - correlationId: 'b0eb28be-b8af-4dce-ae0a-d85ab162dc70', - }, - { - firstName: 'ROSELEENI', - lastName: 'BINTE RAMLEE', - correlationId: '5c4a79ea-2a1c-4b1f-a53a-8b2a95fc542e', - }, - { - firstName: 'CHONG', - lastName: 'YOKE MUN', - correlationId: 'e70434b1-0f62-4c69-8dea-da69a34e87ea', - }, - { - firstName: 'PEH', - lastName: 'HUA SHENG', - correlationId: 'b6e5272f-af17-4353-a9d1-73c367b2ae1d', - }, - { - firstName: 'LIM', - lastName: 'HUI JUAN', - correlationId: '432bcc63-2da9-4a00-b048-4a60798800db', - }, - { - firstName: 'TEO', - lastName: 'HONG KIAT ANDY', - correlationId: '56633b3c-2d5b-4675-8646-54bd34bd7f9f', - }, - { - firstName: 'KOK', - lastName: 'JIN CHENG KENNETH', - correlationId: 'a1a600b9-fb9c-4fbd-b8fd-f2fbfcf3edf0', - }, - { - firstName: 'AMIRA ABDULAZIZ', - lastName: 'HASSAN ALI BAKER', - correlationId: '96e465c2-0642-4a85-8162-d40e2c2674f1', - }, - { - firstName: 'ROSELEENI', - lastName: 'BINTE RAMLEE', - correlationId: '2b047c48-66ef-45ff-bae5-0ec70e9d2b7a', - }, - { - firstName: 'MOHAMMAD ABDULAZIZ', - lastName: 'HASSAN BAKER', - correlationId: '07f6e412-744f-4c71-b792-0debf380ffa4', - }, - { - firstName: 'ZHANG', - lastName: 'YIWEI', - correlationId: '3aeab59f-7f40-4893-bbd4-a10751bed452', - }, - { - firstName: 'WAN', - lastName: 'NOOR HAKIMI BIN WAN ISA', - correlationId: '74d278ae-5d24-4ad7-8b2b-3b6c2ce5915e', - }, - { - firstName: 'HAFIZUDDIN', - lastName: 'BIN ABDUL RAHMAN', - correlationId: 'd8309a8c-899d-40aa-a607-79c027497bd2', - }, - { - firstName: 'MUHAMMAD HANAN', - lastName: 'BIN AZIZ', - correlationId: 'c0cf2b13-5829-4ba9-bed0-c901fbc6ee02', - }, - { - firstName: 'SENTHILVELAN', - lastName: 'PREMIAPPAN', - correlationId: 'dd54f32d-f637-4664-94c2-8ed6f3b2c3dd', - }, - { - firstName: 'TEH', - lastName: 'TEK ONG', - correlationId: 'e8fee263-1c58-43a2-ba13-0e09dca40d3a', - }, - { - firstName: 'CHEN', - lastName: 'YUHAI', - correlationId: '3b2e3837-72fd-447a-8af6-005f4b4aed80', - }, - { - firstName: 'HOU', - lastName: 'DONGSEN', - correlationId: '71ce88c8-d580-4889-b56e-b100815ceaae', - }, - { - firstName: 'TANG', - lastName: 'XIAOMING', - correlationId: '3f262d7d-93f7-483f-9afd-3e6f86a38ee7', - }, - { - firstName: 'CHOE', - lastName: 'PENG SUM', - correlationId: '4e05fc9f-1a07-4140-88df-87c392bbb525', - }, - { - firstName: 'NEO', - lastName: 'SOON HUP', - correlationId: 'e094baa0-def2-4670-a629-ca13c75a154e', - }, - { - firstName: 'WEE', - lastName: 'WEI LING', - correlationId: '4e198755-1ade-431e-b243-60949b6ba5b6', - }, - { - firstName: 'NORITA', - lastName: 'BINTE ABDUL KARIM', - correlationId: '3a750d61-03e1-4d7b-b246-d190bccac170', - }, - { - firstName: 'WILLIAM', - lastName: 'LEVY', - correlationId: '6a6cd071-dc0a-4003-8ed9-967ca04e96ac', - }, - { - firstName: 'DAVID EDWARD', - lastName: 'HOWARD', - correlationId: '063567c3-a97e-4d24-a23b-134826b44fb1', - }, - { - firstName: 'TIONG', - lastName: 'HIN WON ERIC', - correlationId: '9b60d175-b364-4ab8-8ba5-f62c732c16f7', - }, - { - firstName: 'YANN', - lastName: 'FABIEN BOZEC', - correlationId: 'f331dc6b-4edc-40df-aa81-65f30a987c94', - }, - { - firstName: 'LEONARD', - lastName: 'TODD KAHN', - correlationId: 'c8eddddb-536a-4c21-9f4d-fe4bb0cae948', - }, - { - firstName: 'NG', - lastName: 'YAN MING', - correlationId: '9ced6515-f237-4477-9397-55003c9e9885', - }, - { - firstName: 'HWANG', - lastName: 'YEE CHEAU', - correlationId: '6b0f1f2d-25fe-466a-b645-7e30efc340c8', - }, - { - firstName: 'CHIN', - lastName: 'YEE FATT', - correlationId: '05a2f318-251a-4b11-af4e-ce0d27b55a46', - }, - { - firstName: 'KOK', - lastName: 'FOOK YONG', - correlationId: '708ceb3e-eea0-4644-9ddf-39e1f2b8067b', - }, - { - firstName: 'CHONG', - lastName: 'TUCK FUNG', - correlationId: '6fac3a5d-3cbf-45c8-bf14-837037647907', - }, - { - firstName: 'MOK', - lastName: 'TONG BEE', - correlationId: 'adaeefa4-44a8-447e-8a0b-e21c1c1dab77', - }, - { - firstName: 'SEAH', - lastName: 'WAI YEW (XIE WEIYAO)', - correlationId: '2f84ff90-943f-4a44-9327-950f29d4905b', - }, - { - firstName: 'CHIN', - lastName: 'SIEW WOUN', - correlationId: 'b90a1258-37cc-4522-9ece-3a67ab8a06b9', - }, - { - firstName: 'THNG', - lastName: 'WEI LIANG JOVEN', - correlationId: '22f4c3a5-e240-44bd-9e5c-5868e6dda4b8', - }, - { - firstName: 'TAY ZHENG', - lastName: 'TIEN YONG, ALEX (ZHENG TIANYONG, ALEX)', - correlationId: '6f7291da-e799-40bc-935f-97d5c2ff1eaf', - }, - { - firstName: 'LEE', - lastName: 'SIEW KOK', - correlationId: '620404f4-8625-4655-8f60-265b1002ecbc', - }, - { - firstName: 'ROGER LESLIE FRAZER', - lastName: 'HARROLD', - correlationId: 'bbdfd0ea-43f9-47f1-983b-c4cb9bbcd5a1', - }, - { - firstName: 'NURUL NAJWA', - lastName: 'BINTI MOHAMED', - correlationId: '6a4757b6-a881-4495-864d-58278189b358', - }, - { - firstName: 'MUHAMMAD ZULHAQIM', - lastName: 'BIN MOHD YAZID', - correlationId: '8cf39a66-78f2-4a44-8280-585a88297111', - }, - { - firstName: 'LIM', - lastName: 'CHIN LEONG', - correlationId: 'a24b6bd4-3053-42c1-a671-d983d862edde', - }, - { - firstName: 'CHUE', - lastName: 'WAI YONG (CUI WEIYANG)', - correlationId: 'edf577d4-b487-438c-b41f-19f5a51dd03e', - }, - { - firstName: 'PARDEEP', - lastName: 'FOGAT', - correlationId: '7aaa16b1-a8a7-43ee-9a60-0e8935e43202', - }, - { - firstName: 'LOH', - lastName: 'SIEW LENG', - correlationId: '44284ad3-93d8-46ad-b225-f580e6ff3179', - }, - { - firstName: 'LUM', - lastName: 'YUET WAH', - correlationId: '71ae7075-1345-4b08-9385-9c455ef32e21', - }, - { - firstName: 'TEH', - lastName: 'KIAT SEONG', - correlationId: 'e52307fd-6d83-44c7-af45-a6813bb49664', - }, - { - firstName: 'TAN', - lastName: 'HWEE HIANG', - correlationId: '50e9fa07-6dc0-4530-ba69-8689ed5dd7d7', - }, - { - firstName: 'NG', - lastName: 'SOOK HWA', - correlationId: 'd3d13e2c-678d-4438-bcf1-3fb57f70583b', - }, - { - firstName: 'TAN', - lastName: 'ENG SOON', - correlationId: '3bd274f8-6da4-4653-afbe-8c4c733a07f4', - }, - { - firstName: 'TAN', - lastName: 'WEN LYN, GAYLE', - correlationId: '6e43b049-bce9-4da7-b451-00f3374d09d2', - }, - { - firstName: 'TAN', - lastName: 'TSUI LYN, GILLIAN', - correlationId: 'c06f1b42-c6fe-4989-b86d-ffad131ffbc8', - }, - { - firstName: 'TAN', - lastName: 'BAO LYN, GENNA (CHEN BAOLING)', - correlationId: 'c5c7a537-33d2-4eb7-b1f9-a1cce3799a4b', - }, - { - firstName: 'LOH', - lastName: 'VANIDA PAOPHIT', - correlationId: '436c99a2-da22-415f-9acf-0d06404f86f0', - }, - { - firstName: 'LOH', - lastName: 'WAN JING', - correlationId: '135e6781-0566-4f33-867d-1bc5623347b7', - }, - { - firstName: 'LOH', - lastName: 'WAN TING', - correlationId: '8de1f0a7-7f37-4994-a4ee-5ee1b940b7f7', - }, - { - firstName: 'YURENKOV', - lastName: 'YURENKOVA Igor Olegovich', - correlationId: 'eb4c0bfa-5a60-4094-94b6-8ad80bce9aaf', - }, - { - firstName: 'LIM', - lastName: 'WAI HONG', - correlationId: '25f9fd8c-cf28-4e3b-80d3-9097805a7c85', - }, - { - firstName: 'CHONG', - lastName: 'NGEN CHOO', - correlationId: 'c25fab09-31f3-4123-9e29-ac99072a6125', - }, - { - firstName: 'BEE', - lastName: 'LIAN CHOO', - correlationId: '4964dbe3-d877-4258-b95e-fc1ab9d54391', - }, - { - firstName: 'LI', - lastName: '', - correlationId: '0e1252c8-7a54-47f0-945c-490838b2812c', - }, - { - firstName: 'WEE', - lastName: '', - correlationId: '81ecc56b-67ca-43e7-8826-f2097cbe03b6', - }, - { - firstName: 'GEORGY', - lastName: 'ALEXANDROVICH LI', - correlationId: '6ba9e88b-bb6c-4f8d-9ea2-35a3962f9496', - }, - { - firstName: 'IP', - lastName: 'LIGA', - correlationId: '697c2099-00db-4cc2-a695-0d7ceb3df6ae', - }, - { - firstName: 'XUE', - lastName: 'DAN', - correlationId: 'a2ff506a-0fd9-441a-b9b3-843b4c0b40ca', - }, - { - firstName: 'NOOR JAHAN', - lastName: 'MYNUDEEN ABDUL', - correlationId: '8394b801-9986-4fb7-81dd-c1bf57aef4db', - }, - { - firstName: 'ROSELEENI', - lastName: 'BINTE RAMLEE', - correlationId: '44539724-4492-40e8-81da-a75eb0b420c9', - }, - { - firstName: 'AMIRA ABDULAZIZ', - lastName: 'HASSAN ALI BAKER', - correlationId: '6c7caec0-f50b-489f-b325-40f9194d3ce6', - }, - { - firstName: 'ABDULAZIZ', - lastName: 'HASSAN ALI BAKER', - correlationId: 'e3a7d793-78ea-4c13-89aa-df8eb137e50d', - }, - { - firstName: 'MOHAMMAD', - lastName: 'ABDULAZIZ HASSAN BAKER', - correlationId: 'e84b3022-7506-4317-9a69-996bfee4713b', - }, - { - firstName: 'HUAN', - lastName: 'WANG', - correlationId: '96595ace-9d65-4f09-87d2-b85847e1c364', - }, - { - firstName: 'MARKANDOO', - lastName: 'SIVAKUMARAN', - correlationId: 'cf8bbbcc-4291-4fc7-bba1-0ef1c482f76c', - }, - { - firstName: 'ANG', - lastName: 'EE PENG RAYMOND', - correlationId: '43c5892b-2581-4354-88db-179ae47bb655', - }, - { - firstName: 'FOO', - lastName: 'SIEW JIUAN', - correlationId: '3694f14d-8513-4921-9d16-ee7f58102a1f', - }, - { - firstName: 'TAN', - lastName: 'HOCK HEE', - correlationId: 'c7fea400-99e3-47c0-8348-96d9394ee975', - }, - { - firstName: 'TAN', - lastName: 'YU KANG', - correlationId: '5079bb78-b1be-43d8-88e9-aacfda23f207', - }, - { - firstName: 'YVONNE GEK', - lastName: 'CHER GOH', - correlationId: 'ad8ad8a4-9c6b-456e-ad40-47a1d4895378', - }, - { - firstName: 'TAN', - lastName: 'HUI SHI GRACE', - correlationId: '73000f35-f235-46e4-8c46-402f4590fdc2', - }, - { - firstName: 'LIP', - lastName: 'TUCK SING', - correlationId: 'a283f87a-7c25-49e5-9333-99bae566dbaf', - }, - { - firstName: 'ANG', - lastName: 'CHENG KUM', - correlationId: 'bdada0c8-185a-4126-b2b3-e578311a6dac', - }, - { - firstName: 'BEA', - lastName: 'PANG H', - correlationId: '882d445c-8dbe-4bb2-8811-574b8325039a', - }, - { - firstName: 'TEOH', - lastName: 'SHENG', - correlationId: '2838f56f-1645-4f34-93f9-d9849b73aabc', - }, - { - firstName: 'LUM', - lastName: 'JENG', - correlationId: 'db34d29e-d583-4639-afc3-f500b2c73076', - }, - { - firstName: 'ZHI', - lastName: 'QIANG TEAW', - correlationId: '71121104-b817-44b9-ae90-21ec6b77967d', - }, - { - firstName: 'LIN', - lastName: 'MINGLONG', - correlationId: 'c4cbaf69-1b4b-4fce-9b25-0b09a3f3668c', - }, - { - firstName: 'LEONG', - lastName: 'BINXUN, OLIVER', - correlationId: '23516c36-6e31-4a45-85ac-8746950ed50c', - }, - { - firstName: 'ERIC CHAN', - lastName: 'TZE CHOONG', - correlationId: '2ba088b6-f952-496b-8f4e-5e8904b61e76', - }, - { - firstName: 'CHEONG', - lastName: 'SIO KAM', - correlationId: '420d82ac-4c8b-41e7-99ea-6faf282b4a96', - }, - { - firstName: 'HARYATI', - lastName: 'BINTE HASSAN', - correlationId: '7878fa21-05c1-4b84-ad57-4bbe1606b8bf', - }, - { - firstName: 'ERIC TEO', - lastName: 'HONG KIAT', - correlationId: '596ed5cf-911f-47ce-a28f-b1c3ca30c386', - }, - { - firstName: 'MUNIR', - lastName: 'Hussain', - correlationId: 'cb27f5f5-aafe-448f-b116-b636e2aa3c7f', - }, - { - firstName: 'KADIR', - lastName: 'Maideen', - correlationId: '41fc4e2d-142f-4a87-981a-215821a17153', - }, - { - firstName: 'MURAT', - lastName: 'GOKPINAR', - correlationId: '75f4c08f-e189-48b8-906f-22884e2cddc4', - }, - { - firstName: 'TAY', - lastName: 'SHEH LEI', - correlationId: 'fd91b688-055c-49ee-8f56-8c0ce6f681d7', - }, - { - firstName: 'TEO', - lastName: 'SIANG LONG', - correlationId: 'ba40b856-0ddd-4503-b880-271f962e500e', - }, - { - firstName: 'KAREN KOK', - lastName: 'SHU MIN', - correlationId: '1fb30fca-0e9e-48c0-9965-01d49fbe4c50', - }, - { - firstName: 'JEAN ANG', - lastName: 'BEE LENG', - correlationId: '6f4c751c-c1b4-4dd2-ae11-582c945be590', - }, - { - firstName: 'LIM', - lastName: 'HUAY LING', - correlationId: 'e4d9f711-ec60-4ac2-96a8-6b6beb457348', - }, - { - firstName: 'TAN', - lastName: 'EWE KIN MELVIN', - correlationId: '8a784ec4-01f5-4fbd-af9e-20594ae6fc3b', - }, - { - firstName: 'ERIC TEO', - lastName: 'HONG KIAT', - correlationId: '2bb18e72-8dc2-48dd-877f-1d87368b95a0', - }, - { - firstName: 'WONG', - lastName: 'QINLEI', - correlationId: 'a363ed55-20ca-4b09-955a-618d23ffc759', - }, - { - firstName: 'KAREN TAN', - lastName: 'SOK HONG', - correlationId: 'b4f253d2-f9fa-4bf8-b598-8d79c2724e13', - }, - { - firstName: 'ASWIN', - lastName: 'WARIER', - correlationId: 'e40ae481-1a7f-4cb7-ba49-c091a1502775', - }, - { - firstName: 'JUNAIDAH', - lastName: 'BINTE BADRON', - correlationId: 'e0088cf8-e447-441a-9abf-d5d616092e13', - }, - { - firstName: 'RAMANAN', - lastName: 'RAMADOSS', - correlationId: '436a4821-20a0-40e3-816f-00fc37f6e3ba', - }, - { - firstName: 'ZHENG', - lastName: 'RENHAO', - correlationId: 'aa9995f2-3102-413f-9ded-185443e98e2f', - }, - { - firstName: 'SASHIKUMAR', - lastName: 'GANAPATHY', - correlationId: 'ec094918-a425-46ea-a1af-bf68d22fe592', - }, - { - firstName: 'YUKI', - lastName: 'SATO', - correlationId: '56ed5425-1765-45ab-b0f7-841fdd995402', - }, - { - firstName: 'BENSON YEO', - lastName: 'KOON WEE', - correlationId: '964a967c-625d-4db0-bbf6-019c6d1de09e', - }, - { - firstName: 'WONG', - lastName: 'CHEN SEONG', - correlationId: 'de4f52b1-6ce6-4d53-a5d7-37ecc5d7c85c', - }, - { - firstName: 'WOON', - lastName: 'SAC SAN SAXONE', - correlationId: '807eec05-980f-48cb-9758-1b3c78a3707f', - }, - { - firstName: 'OLEKSANDR', - lastName: 'KONDRACHUK', - correlationId: '1044b800-172d-4242-a558-6d22cb426804', - }, - { - firstName: 'CHRIS', - lastName: 'TRIKOMITIS', - correlationId: 'bb70a5be-150a-46f0-9563-b704eaf669d9', - }, - { - firstName: 'FOO', - lastName: 'SIEW JIUAN', - correlationId: '1b167d49-3f75-4f17-831d-60cc046b20ab', - }, - { - firstName: 'ANG', - lastName: 'EE PENG RAYMOND', - correlationId: '3f68a5a1-ae0a-44fc-95b9-6604d6598482', - }, - { - firstName: 'DALILA', - lastName: 'BINTE HASHIM', - correlationId: 'f7c740a4-b06b-4924-83e7-86783b24bdd3', - }, - { - firstName: 'JITEN', - lastName: 'PAUL', - correlationId: 'c3110db2-4cde-463d-b4da-b99669705a94', - }, - { - firstName: 'ANG', - lastName: 'EE PENG RAYMOND', - correlationId: '2f67df84-fabe-4c37-9d7a-e7ea8348e1d0', - }, - { - firstName: 'FOO', - lastName: 'SIEW JIUAN', - correlationId: '066189f6-72a3-4e12-b4a9-d9b56fd5b175', - }, - { - firstName: 'LEE', - lastName: 'WON YOUNG', - correlationId: 'e34b87bd-3fcd-437c-8938-2d510d03ca8e', - }, - { - firstName: 'TRACY THOMAS', - lastName: 'TRAVIS', - correlationId: '686cee0f-3ba3-4f50-a8a3-c7cf20652bde', - }, - { - firstName: 'ZHAKSYBEKOVA', - lastName: 'ALBINA SOVETOVNA', - correlationId: '30bcab31-4953-4615-87b9-0d88b2d5f66b', - }, - { - firstName: 'VOON', - lastName: 'TENG JING', - correlationId: 'c96bef17-997a-41dc-9cdb-05e15e930e18', - }, - { - firstName: 'YU', - lastName: 'JONATHAN', - correlationId: 'da30be1d-51a6-4e56-867d-9235d3c2598d', - }, - { - firstName: 'BEH', - lastName: 'CHOY PENG', - correlationId: 'b21bdaf3-1fdb-481f-8c13-928d14e2aef2', - }, - { - firstName: 'PHAM', - lastName: 'DUC THINH', - correlationId: 'a6930b65-c64f-4a7a-8de8-63e4c7808a4d', - }, - { - firstName: 'BYUNG', - lastName: 'DOO YOU', - correlationId: '3365f4b3-2e96-46d3-89b5-08d21680b4b7', - }, - { - firstName: 'SHAHRIZAL', - lastName: 'BIN SAMSUDIN', - correlationId: 'f4cd1355-c1e9-45e4-a5f4-33c7f83e2526', - }, - { - firstName: 'KARNAN', - lastName: 'ARJUNAN', - correlationId: '05792caf-7a06-4939-a3b1-17556e2e86f8', - }, - { - firstName: 'PALLAVI', - lastName: 'BALU', - correlationId: '5fced735-c512-42ef-b660-38582b1f46f3', - }, - { - firstName: 'YOW', - lastName: 'SU CHIN', - correlationId: '10cc799b-10e5-4eac-aaf4-9864e2d4428f', - }, - { - firstName: 'PHILLIP WONG', - lastName: 'YEE TENG WONG', - correlationId: 'fc4a95eb-d5ff-46d5-b922-8ea8f1a357c5', - }, - { - firstName: 'DENIZ', - lastName: 'TOPSAKAL', - correlationId: '8565afb5-0800-486d-8e0a-b25569463cb5', - }, - { - firstName: 'KWOK', - lastName: 'NGA KWOK', - correlationId: '1fe01e03-a269-45d8-a8d7-e0b635bdf6a5', - }, - { - firstName: 'WU', - lastName: 'QIANG', - correlationId: '4726df6f-a9f6-44b8-a0db-5f0374fb2fd7', - }, - { - firstName: 'WANG', - lastName: 'LANBING', - correlationId: '1986f1c2-637e-42d8-bab0-66b9d9220a83', - }, - { - firstName: 'ZHANG', - lastName: 'YONG', - correlationId: 'c61b6f8a-d920-4c63-abc7-8a820dd4a60b', - }, - { - firstName: 'SONG', - lastName: 'YU LI', - correlationId: '2e685ad3-f079-40b3-9784-65a671db84c1', - }, - { - firstName: 'ADAM', - lastName: 'BIN HASNI', - correlationId: '8aaaec48-05ad-4dc5-ac66-30da9222418b', - }, - { - firstName: 'HAE', - lastName: 'RANG SHIN', - correlationId: 'ee904fb2-1c76-437e-ab10-3f1145312264', - }, - { - firstName: 'YOO', - lastName: 'YOUNGJIN', - correlationId: '047b6058-fd7d-448f-b902-ee2eeeaaefd7', - }, - { - firstName: 'ZHEN', - lastName: 'WANG', - correlationId: '4560f8fa-d4a4-4acd-be22-e016992af324', - }, - { - firstName: 'QUN', - lastName: 'PAN', - correlationId: '83e4b77c-ada4-4179-a047-c6bc272fa191', - }, - { - firstName: 'ELIZABETH PENELOPE', - lastName: 'WESTHEAD', - correlationId: '506e80f8-f89b-41aa-ba2b-6c6ddda74d25', - }, - { - firstName: 'MD HAFIZUR', - lastName: 'RAHAMAN KHAN', - correlationId: '40496641-c84a-4a23-93bd-26e82615762e', - }, - { - firstName: 'LOH', - lastName: 'CHOY CHOO', - correlationId: '618baae5-6dd1-4c07-af75-9c528fe88145', - }, - { - firstName: 'LEE', - lastName: 'KING ING', - correlationId: '84a3c69f-51eb-4114-b39c-0c2f91b0be15', - }, - { - firstName: 'NGAU', - lastName: 'SIN LIONG', - correlationId: 'e429fc51-1800-4f20-9b7b-0b2695f9a3ee', - }, - { - firstName: 'LEE', - lastName: 'AH SAN', - correlationId: 'b3963eb3-9e1d-45da-992f-647b6b15c438', - }, - { - firstName: 'LAM', - lastName: 'KHOON YOU', - correlationId: 'cb8a3ea4-d109-4eb0-b217-ae635c85ba0c', - }, - { - firstName: 'VONG', - lastName: 'FUT SENG', - correlationId: 'a31c0304-75c9-47ac-be85-87349f81593d', - }, - { - firstName: 'QIU', - lastName: 'JUN', - correlationId: '8ae75078-82f0-4464-b4ef-64b6c47373ea', - }, - { - firstName: 'WANG', - lastName: 'HU', - correlationId: '87d23b3d-d3c6-4867-99dd-dfdcb00161d1', - }, - { - firstName: 'YAP', - lastName: 'KUM LOON', - correlationId: '0511da3d-d8ff-4276-9565-181d342c5a8d', - }, - { - firstName: 'YAP', - lastName: 'KONG', - correlationId: 'e57b4fe2-ab40-4051-98e4-80f040a315bf', - }, - { - firstName: 'CALVIN FU POR', - lastName: 'CHEE WEI', - correlationId: '37d70db2-dbda-410c-80d2-afe2cd27f722', - }, - { - firstName: 'LOH', - lastName: 'CHOY CHOO', - correlationId: '9b5750c8-6d3e-45b0-b131-fc23e4497103', - }, - { - firstName: 'LAM', - lastName: 'KHOON YOU', - correlationId: 'e583c9fc-30a1-4129-b486-989933e90264', - }, - { - firstName: 'LOW', - lastName: 'YEW HOCK @ LAU YEW HOCK', - correlationId: 'e1b3be1e-c33b-420c-8179-f857d16c847e', - }, - { - firstName: 'CHIN', - lastName: 'PIN KWONG', - correlationId: 'de988d8d-fa63-4505-9a22-cb593f5699de', - }, - { - firstName: 'NGAU', - lastName: 'SIN LIONG', - correlationId: 'aa4549b1-2e7a-4649-8e14-ebdaa15f58af', - }, - { - firstName: 'TEAW', - lastName: 'ZHI SHENG', - correlationId: '5fc474a6-eec6-4836-a558-ff37c7b19111', - }, - { - firstName: 'MOHAMED', - lastName: 'SIRAJ BIN KHAJA MOHAMED ALI', - correlationId: '76615498-e98d-4d0e-be79-855ce4836d61', - }, - { - firstName: 'WILLEM', - lastName: 'ZACHARIAS JOHANNES VAN STADEN', - correlationId: 'eeda5e09-c2d9-47a6-91bd-435b0c33115c', - }, - { - firstName: 'JACOBUS', - lastName: 'CONRAD KOTZE', - correlationId: '2fd7949e-fc87-48f1-b595-8c0e2285d303', - }, - { - firstName: 'MARIOS', - lastName: 'PAPAHARIDEMOU', - correlationId: '5823b843-84c3-44a2-8631-2b31fdc3c854', - }, - { - firstName: 'MD', - lastName: 'HAZLY BIN MD ISA', - correlationId: '63a49d22-9268-4959-9974-db81a8b6c38b', - }, - { - firstName: 'ZHANG', - lastName: 'YUGANG', - correlationId: 'f179fc00-5dee-45d9-9efc-77c8348d325b', - }, - { - firstName: 'WOO', - lastName: 'WING LEUNG', - correlationId: '51c31e2d-d9eb-4f5b-8ffe-12a45e81b624', - }, - { - firstName: 'TEO', - lastName: 'YEK MING', - correlationId: '4acedbc6-6b31-47d8-b722-d500132e7eb8', - }, - { - firstName: 'WOON', - lastName: 'KENG HUA', - correlationId: '3afdabfb-0ae4-459b-94d7-1828065b774b', - }, - { - firstName: 'ERIC', - lastName: 'EGER', - correlationId: '0ab5b994-ec0f-4f23-b112-02040d10410b', - }, - { - firstName: 'TAN', - lastName: 'WEI KENT', - correlationId: '3dbbec5e-94d5-4019-bda6-ec0ba70162b8', - }, - { - firstName: 'FOONG', - lastName: 'KIM WENG', - correlationId: '45773be4-c129-475a-905a-1584c8928210', - }, - { - firstName: 'WONG', - lastName: 'VENUS', - correlationId: 'bd59cd9f-ea78-42bc-a53d-96694ba17737', - }, - { - firstName: 'FOGAT', - lastName: 'PARDEEP', - correlationId: '8f54a3b2-90bc-4922-9d7e-4132475fc7fd', - }, - { - firstName: 'KARMA', - lastName: 'WANGCHUK', - correlationId: 'f64a8344-6c2c-4494-9c34-1c43ff824d62', - }, - { - firstName: 'KARMA', - lastName: 'THINLAY', - correlationId: '07a6ac99-cdda-4f15-9c73-5a0e531f8fcd', - }, - { - firstName: 'TANDI', - lastName: 'WANGCHUK', - correlationId: '2f62a752-c89f-49ee-ace7-a8a88a6ae70c', - }, - { - firstName: 'DORJI', - lastName: 'NIMA', - correlationId: 'f12d498f-d77a-4a82-8d44-f146e09775e2', - }, - { - firstName: 'DORJI', - lastName: 'DHRADHUL', - correlationId: 'f94af7b8-afcc-40c2-a40c-4d01b1af7c05', - }, - { - firstName: 'KARMA', - lastName: 'THINLEY', - correlationId: '562b9d32-690d-48af-aaad-7b4250e6efbe', - }, - { - firstName: 'KARMA', - lastName: 'LOTEY', - correlationId: '9999f320-d44a-4cea-93ab-88c69a63f0e5', - }, - { - firstName: 'PEMA', - lastName: 'CHODEN', - correlationId: '7f146071-c58f-4540-a6c4-597eb99fdd88', - }, - { - firstName: 'LAU', - lastName: 'KHOON YOU', - correlationId: 'a7c51897-605b-45e9-8be5-995d683aec83', - }, - { - firstName: 'LAM', - lastName: 'KHOON YOU', - correlationId: '4684cfa8-39e3-4ee3-81d1-feb8eb239da9', - }, - { - firstName: 'NORITA', - lastName: 'BINTE ABDUL KARIM', - correlationId: '54aacfa7-88cc-496a-9cfe-092f4cd63082', - }, - { - firstName: 'BHANDARI', - lastName: 'KARAN MANOJ', - correlationId: '3f4cf537-16a6-46c5-b5c8-f87ab09f5ad2', - }, - { - firstName: 'SOH', - lastName: 'GAK HEO', - correlationId: '102dc613-94d4-4a6d-b033-b7a3cd44f427', - }, - { - firstName: 'EDITH', - lastName: 'SHIH', - correlationId: '6afd478f-5024-4382-94cf-09148be1dcef', - }, - { - firstName: 'LAI', - lastName: 'KAI MING DOMINIC', - correlationId: 'f6e0e30a-67d3-4c11-83a0-604f725216f8', - }, - { - firstName: 'RODNEY', - lastName: 'WILLIAM ROUTLEY', - correlationId: 'fc6a4184-766e-4647-9d7b-8a4429980161', - }, - { - firstName: 'ROBIN SNG', - lastName: 'CHENG KHOONG', - correlationId: 'fa00fd7d-0dd9-4298-8f55-8661fc457a70', - }, - { - firstName: 'CHOE', - lastName: 'PENG SUM', - correlationId: '9948a16a-7cc2-4706-b5fb-541c804a48d2', - }, - { - firstName: 'KWA', - lastName: 'BING SENG', - correlationId: '1d7a0f40-73cb-44ef-8edc-d1dd5345e375', - }, - { - firstName: 'TAY', - lastName: 'JUN HAO', - correlationId: '0a533e8e-f1ea-46d3-8ffd-1aa3b4c62a1b', - }, - { - firstName: 'FOO', - lastName: 'WENQUAN', - correlationId: '21ce3747-7a52-4ba5-8000-313ceff1f781', - }, - { - firstName: 'WANG', - lastName: 'HU', - correlationId: '8c95f851-1ca3-460b-85a1-dd2d1e919aca', - }, - { - firstName: 'ZHANG', - lastName: 'LIANG', - correlationId: '147edf7e-12b8-4650-b17f-230a57168f09', - }, - { - firstName: 'LEE', - lastName: 'YI LIANG', - correlationId: '8bc92091-c508-489d-aef3-da2871f6ebac', - }, - { - firstName: 'CHICK', - lastName: 'CHEUY TONG', - correlationId: '52012538-1b3d-41e7-9768-60447e3f5d89', - }, - { - firstName: 'YEONG', - lastName: 'SIEN SEU', - correlationId: '8dce2007-c0fd-46f4-bd0b-9a7175e3b5b8', - }, - { - firstName: 'NEO', - lastName: 'SOON HUP', - correlationId: '4cbd301f-316b-4a36-af84-5e5d0a3503c4', - }, - { - firstName: 'FOO', - lastName: 'THIAM FONG WELLINGTON', - correlationId: 'd560fc15-3a24-44f1-9e2f-833847c3c123', - }, - { - firstName: 'FOO', - lastName: 'SEE JIN', - correlationId: '3a2ec2d0-80f4-4843-b1a1-c50e1cd9a0d8', - }, - { - firstName: 'TAN', - lastName: 'SIEW SAN', - correlationId: '3e8490d1-83ab-4467-9f6a-6f98ab5d4523', - }, - { - firstName: 'LAU', - lastName: 'PING SUM PEARCE', - correlationId: '97b9fadd-97e7-4abf-be42-732b81cd95e6', - }, - { - firstName: 'CHIN', - lastName: 'SEK PENG', - correlationId: 'c0e34906-1b15-45aa-84de-2ce59812ca93', - }, - { - firstName: 'CHUANG', - lastName: 'KENG CHIEW', - correlationId: 'c5021064-50c4-4499-9489-d037f35581b6', - }, - { - firstName: 'LEUNG', - lastName: 'CHI WAI', - correlationId: 'd0bf391d-31c6-4b6a-a861-36fefa39d984', - }, - { - firstName: 'NG', - lastName: 'YIN CHING', - correlationId: '32d1d920-39e2-4ca2-9fca-59b1c027f073', - }, - { - firstName: 'HEN', - lastName: 'YI XUAN', - correlationId: '5d5b4bcc-d281-426b-9545-5ffe890db0ff', - }, - { - firstName: 'LEUNG', - lastName: 'TAK SHUN', - correlationId: '14fa4536-f856-4e33-add6-af008d944ceb', - }, - { - firstName: 'WANG', - lastName: 'LUMING', - correlationId: '826bce35-b2b4-4ef3-856b-398b5c6462d6', - }, - { - firstName: 'RYAN', - lastName: "SYLVESTER QUITERIO D'SOUZA", - correlationId: '2073b3e6-6f60-4eb3-884e-b74ddb6b5996', - }, - { - firstName: 'SIMON', - lastName: 'NAGA SHOUKRY GUIRGUIS', - correlationId: '4f561c1d-49d7-49bf-836c-54a1d0b667c3', - }, - { - firstName: 'KO', - lastName: 'LEE MENG', - correlationId: 'b3ceedd2-fb94-4408-be6f-84e3142818ae', - }, - { - firstName: 'JIA', - lastName: 'KUNG LIU', - correlationId: '0f15fb70-9580-4c2e-9d65-277dac9d820d', - }, - { - firstName: 'WEE', - lastName: 'TYNG LIN PAURLINE', - correlationId: '20604569-d270-42ab-87d4-3dde5405d0e6', - }, - { - firstName: 'TAN', - lastName: 'CHENG SIONG', - correlationId: '4be75ec0-3a5e-4e5f-8a63-523cf5835087', - }, - { - firstName: 'MUHAMMAD ADAM', - lastName: 'BIN HAMDAN', - correlationId: 'dcd8652c-fabe-4095-bb66-7f3e1e6ee5a6', - }, - { - firstName: 'PANG', - lastName: 'PAK KIN', - correlationId: '884e2cde-12c1-4345-881c-e96e8dce59a2', - }, - { - firstName: 'SHI', - lastName: 'SHUBIAO', - correlationId: 'afa11579-6517-4230-a3a7-cb30f2e5600f', - }, - { - firstName: 'HONG', - lastName: 'LUQIANG ROGER', - correlationId: '6536e513-4f79-4188-abd6-19953132d33d', - }, - { - firstName: 'ANG', - lastName: 'JEOK KEONG ROGER', - correlationId: 'd1697d10-2239-4b56-9a00-5029d0d6da79', - }, - { - firstName: 'FU', - lastName: 'YUANSHU', - correlationId: '6820b783-ca18-405e-a60a-19820f5228b2', - }, - { - firstName: 'LIM', - lastName: "RAY'EN", - correlationId: '7d0a4890-740c-4235-ad5e-0c5606d6bfb2', - }, - { - firstName: 'ONG', - lastName: 'TIAN POH', - correlationId: '744a51e6-4b67-45ac-b2a9-a7fd9c8fc1c9', - }, - { - firstName: 'ZHU', - lastName: 'LUN', - correlationId: '5a014af1-c16c-423c-998e-18826a5cd829', - }, - { - firstName: 'GE', - lastName: 'HONGTAO', - correlationId: 'd5d94141-70f2-4063-bacd-e98b5d448a7d', - }, - { - firstName: 'CHENG', - lastName: 'YAN', - correlationId: 'e459b440-e3b3-470e-a68a-77713b3163b8', - }, - { - firstName: 'CHONG', - lastName: 'MENG CHAI', - correlationId: 'e2d1c3ac-13ca-4034-ab66-8b4ed082d2b3', - }, - { - firstName: 'DMITRIY', - lastName: 'ALEKSANDROVICH MITROFANOV', - correlationId: '521904c7-b2db-477d-aab2-9ff99e3ae5cb', - }, - { - firstName: 'KOH', - lastName: 'KIAN MENG', - correlationId: 'c8009dce-8a79-45da-84b8-ffc6a8fb008f', - }, - { - firstName: 'LIM', - lastName: 'CHING HONG', - correlationId: 'd7301fe0-bc2f-481d-9efe-a2217a50c589', - }, - { - firstName: 'LIM', - lastName: 'CHOON MENG VINCENT', - correlationId: '2572ea71-a97d-45ff-b90d-6a4390f8017b', - }, - { - firstName: 'GOH', - lastName: 'GEOK LIN', - correlationId: 'd844d281-410c-4778-84ce-16a4f9c64599', - }, - { - firstName: 'EDWARD LEONG', - lastName: 'YEW KONG', - correlationId: 'c29ac3ea-05cc-40b0-97aa-3b5c01044356', - }, - { - firstName: 'WONG', - lastName: 'YI LING', - correlationId: 'd45986e7-bc75-4fdb-a2bb-7f635e4b205f', - }, - { - firstName: 'BOK', - lastName: 'KOK SON', - correlationId: '0f207bd8-903f-4baf-bdac-bdad3c141eb3', - }, - { - firstName: 'MARNOCH', - lastName: 'HALDANE JAMES', - correlationId: 'c7a27b5d-d051-4cd3-a181-971ee57748f8', - }, - { - firstName: 'WILLIS', - lastName: 'DWIGHT DAVID', - correlationId: '512144cd-e384-4356-941c-2aefc3f19054', - }, - { - firstName: 'JULIUS CHUA', - lastName: 'CHUANG TECK', - correlationId: 'cc131a3a-b62c-40f6-afdd-8ad6c9f53d58', - }, - { - firstName: 'HO', - lastName: 'KWEN FOONG', - correlationId: '375b812f-79b2-4f5b-a531-121a690fbba6', - }, - { - firstName: 'HO', - lastName: 'SHUN FA', - correlationId: '9f76f4e5-cb98-4f31-baf9-0926900ba099', - }, - { - firstName: 'HO', - lastName: 'SHAN SHAN', - correlationId: 'e15706bb-97df-4919-9d75-c0d001735b7f', - }, - { - firstName: 'WONG', - lastName: 'AH NOY @ WONG WHY CHAN', - correlationId: '1c266e8f-4cb8-4332-9bd2-cbb9e8b32ea9', - }, - { - firstName: 'NG', - lastName: 'JING DA DAVIER', - correlationId: 'bca6e9bd-5394-44e5-8301-b64515daaf3a', - }, - { - firstName: 'CHUA', - lastName: 'JIE SHENG', - correlationId: '3fd32eea-4ab9-4200-b0ab-67da754e2dcd', - }, - { - firstName: 'YEO', - lastName: 'SOON SENG', - correlationId: '520976e5-003f-49b6-b8e0-47ce33a900b0', - }, - { - firstName: 'CHONG', - lastName: 'LU', - correlationId: '58b79fc7-3afa-4a5a-8e85-d63f98c09a61', - }, - { - firstName: 'LU', - lastName: 'WENJING', - correlationId: 'd2ca406b-9447-4825-850e-bb19da165109', - }, - { - firstName: 'WONG', - lastName: 'MEAU LIN', - correlationId: 'f4e8ee1a-760c-4144-949f-f1d6b1d0a7c8', - }, - { - firstName: 'LYE', - lastName: 'SHEN POW', - correlationId: '2fa7aa63-95df-44a2-8be9-900819b2f54e', - }, - { - firstName: 'LOH', - lastName: 'SIEW LENG', - correlationId: '581bc5af-0e36-4a17-bb01-e0c99c321890', - }, - { - firstName: 'TENG', - lastName: 'BOON HUAT', - correlationId: '4ab1a962-2d64-496a-aefb-b2bbf669874e', - }, - { - firstName: 'HUANG', - lastName: 'YOUYUAN', - correlationId: '1793dd14-dbd9-4944-8388-567bdfc7edb7', - }, - { - firstName: 'MOHAMED', - lastName: 'IMTIYYAZ S/O MOHAMED ARIFF', - correlationId: '08bfc3d1-3733-4bc8-bf6b-9641465a5e9d', - }, - { - firstName: 'NUR', - lastName: 'HISYAM BIN MOHD NOOR', - correlationId: '69c852ef-30bc-47f9-8d10-266b97f9b049', - }, - { - firstName: 'LOW', - lastName: 'WOEI HAU', - correlationId: '710ff6b0-34b5-49cd-8f8c-9759d904ac2c', - }, - { - firstName: 'GANDHI', - lastName: 'PANDIT', - correlationId: 'f1585701-e224-42a1-9015-f7c31f5bd60f', - }, - { - firstName: 'AIBEK', - lastName: 'DUESENBAI', - correlationId: '509266dd-5cbc-4aa3-850f-b2ddb3b3e568', - }, - { - firstName: 'ALVINA KHOO', - lastName: 'LEA ING', - correlationId: '8e8deede-3b91-4733-8a87-edbb605796c0', - }, - { - firstName: 'LEE', - lastName: 'PIN NG', - correlationId: '15254c07-f6b8-479d-bc0a-eaffd4248362', - }, - { - firstName: 'SYED AHMED', - lastName: 'BIN SYED ALWI', - correlationId: '93a9bbdb-77c9-499f-acee-a905fd2431f4', - }, - { - firstName: 'EVANS', - lastName: 'EDMUND SICHALWE', - correlationId: 'a23a856c-b3fb-4307-94ab-f0f2bc0d104a', - }, - { - firstName: 'JOE TANG', - lastName: 'BOON HWEE', - correlationId: 'c0f93307-059b-4122-89bb-6a6d83aa998e', - }, - { - firstName: 'GARRY HUANG', - lastName: 'ZHIWEI', - correlationId: '7f08feb6-2dfb-409a-be64-c8d3734b08e5', - }, - { - firstName: 'RAJ', - lastName: 'KAMAL', - correlationId: '11e84f06-c55c-4cfb-820e-29f64232e05a', - }, - { - firstName: 'WENG', - lastName: 'KONG CHOONG', - correlationId: '737322b6-369c-4b7b-83e9-e5d19ec2e3ad', - }, - { - firstName: 'JING', - lastName: 'YI PANG', - correlationId: '84149894-e420-410b-ad84-7f346e46c665', - }, - { - firstName: 'NUR AHMED ZAKI', - lastName: 'BIN MD MARDHI', - correlationId: '72e2bdf8-d50b-48a9-86ef-ef15b273b80f', - }, - { - firstName: 'YEAH', - lastName: 'HAR MA', - correlationId: '65aa22d7-6357-4df7-b821-73848bf2bc77', - }, - { - firstName: 'ANKITA', - lastName: 'PUROHIT', - correlationId: '6bc6b874-20a3-40ba-b93c-cf7bd092d777', - }, - { - firstName: 'SANJAY', - lastName: 'SINGH DEEPSINGH RAJPUROHIT', - correlationId: 'a138c87e-192c-4dc5-9e78-2695d26bc7ce', - }, - { - firstName: 'ZHOU', - lastName: 'FANG', - correlationId: '2e72fa0c-2771-4541-b9dd-bf79023838a0', - }, - { - firstName: 'KALAGHE', - lastName: 'SAFFIEL RASHID', - correlationId: 'db487224-404f-421c-9d95-4813ac3f7802', - }, - { - firstName: 'KENNEDY', - lastName: 'ALEX MGONGOLWA', - correlationId: '7fc47bbc-3f8a-4f19-ad38-c92aa299a30c', - }, - { - firstName: 'AMIR', - lastName: 'HAMZAH BIN ABDUL HALIM', - correlationId: 'c152b17f-cd21-4fea-812a-bd174db0bf10', - }, - { - firstName: 'AMIRJAFNI', - lastName: 'BIN SULAIMAN', - correlationId: '178b3cef-6725-4449-b5bf-245c15566b40', - }, - { - firstName: 'PRADEEPKUMAR', - lastName: 'KRISHNAMOORTHY', - correlationId: 'd5e2888d-f876-4e22-abcd-4efe01498462', - }, - { - firstName: 'WEE', - lastName: 'TYNG LIN PAURLINE', - correlationId: '8be707e5-cc16-4816-a035-f29ae47535cf', - }, - { - firstName: 'TAN', - lastName: 'CHENG SIONG', - correlationId: 'f5fd9f42-6a26-44af-ad1e-34de61765591', - }, - { - firstName: 'CHOW', - lastName: 'U-JIN', - correlationId: '0de92cf9-b9c3-4a90-8ccb-776448eb74e9', - }, - { - firstName: 'CHUEN', - lastName: 'YI LAU', - correlationId: 'ff5ec9bb-bc20-4aa1-b25c-62ba8a396e17', - }, - { - firstName: 'KEVIN CHEN', - lastName: 'XIN NGO', - correlationId: 'f2d0aca9-e5ce-4fbb-84b8-1c693e25a265', - }, - { - firstName: 'FAIS', - lastName: 'FALLANIE BIN ROZHAN', - correlationId: 'f33ce0de-872c-4fbf-bdf2-fec5c5c5f361', - }, - { - firstName: 'SHAZREEN', - lastName: 'ERZUAN BIN SHAHABUDDIN SHAH', - correlationId: '8d6347cd-02f1-408b-9113-c2abaa0fa274', - }, - { - firstName: 'LAKMAL', - lastName: 'MADUSHANKA HIMBUTUGODA', - correlationId: 'af7ea0aa-4038-4625-bc7f-98c1c300f606', - }, - { - firstName: 'BANDARANAYAKE', - lastName: 'SIWRATHNA MUDIYANSELAGE', - correlationId: '264f9323-317e-407b-9a1b-72ec8518b73e', - }, - { - firstName: 'WONG', - lastName: 'KEE SENG', - correlationId: '6196a1ff-d466-4020-9e4f-da03964b29bb', - }, - { - firstName: 'CHIN', - lastName: 'SENG LAU', - correlationId: '4fa494a7-645a-4a52-a5f8-7df29b8f9ef2', - }, - { - firstName: 'WAI', - lastName: 'SHENG TAN', - correlationId: 'e34835fc-65d9-4630-ac73-6272febd97c9', - }, - { - firstName: 'MUHAMMAD', - lastName: 'HAIKAL BIN ABD LATTIF', - correlationId: '66457b57-d57a-4658-acd1-dfac7740fcf6', - }, - { - firstName: 'WARNAKULA', - lastName: 'DASUN LAKSHITHA MENDIS', - correlationId: 'ebe02f57-7594-4ebc-8d85-e159cc730e67', - }, - { - firstName: 'JARYL SIM', - lastName: 'HUI JIE', - correlationId: 'c6b6ead1-ddb4-4967-b34c-51946bf25bb2', - }, - { - firstName: 'KEE', - lastName: 'LEE LING', - correlationId: 'c081a9d4-4e7c-4520-948e-72e35dafa633', - }, - { - firstName: 'GOH', - lastName: 'CHIEN LOONG', - correlationId: '2736819d-1c08-444c-8ba9-ccbcaad24efa', - }, - { - firstName: 'ZHAO', - lastName: 'HANG', - correlationId: '66a7f0fb-fc83-4528-b3af-680ba92b434a', - }, - { - firstName: 'XIAO', - lastName: 'YUE', - correlationId: '2eb9ce01-2b36-400a-be23-2b187ed45141', - }, - { - firstName: 'SABIROV', - lastName: 'MUKHAMADAZIZ', - correlationId: 'c1ad6f0c-0f4d-4e1a-9bc1-7d91e2f87bf3', - }, - { - firstName: 'ALEKSEJS', - lastName: 'SJARKI', - correlationId: '3b771c06-9737-4f3f-9a27-e687e1c78142', - }, - { - firstName: 'NG', - lastName: 'ENG LIAT', - correlationId: '4202f0b1-e770-4e84-aef5-3ed2ced5f3c6', - }, - { - firstName: 'AMANDA POH', - lastName: 'YUN SIEW POH', - correlationId: 'dcf926c3-e146-4189-811e-43f7277ffed6', - }, - { - firstName: 'MICHELLE CHIANG', - lastName: 'SUET YEE CHIANG', - correlationId: 'c2679c53-60e3-463a-991f-3cfa491b0e32', - }, - { - firstName: 'WU', - lastName: 'JIN', - correlationId: 'a8449a20-cf94-4cd6-84d1-d4cfd70c4a92', - }, - { - firstName: 'LI', - lastName: 'XUEMIN', - correlationId: '32d4c711-bd3e-46c3-9d04-5a3689e8ff95', - }, - { - firstName: 'LIN', - lastName: 'SHU FANG', - correlationId: 'b66d8dcb-9b8e-44dc-b0ae-c932272f07b8', - }, - { - firstName: 'KIM', - lastName: 'PEI XUAN', - correlationId: '2613ccd8-96cd-47e6-a83e-73cee0a7b9da', - }, - { - firstName: 'LIANG', - lastName: 'YEE KANG', - correlationId: 'e8f9018e-19ac-478e-ad02-262abf8dfa3b', - }, - { - firstName: 'LOH', - lastName: 'WOON KUEN', - correlationId: '8334060e-bc1c-47cf-a917-5e1be68d6459', - }, - { - firstName: 'LIANG', - lastName: 'SOOK SOOK', - correlationId: 'f04999e2-3d76-4df1-beb7-ba22ed5ef918', - }, - { - firstName: 'LIN', - lastName: 'WANG', - correlationId: '6cee3414-5138-4b37-a639-8dea9c7fccc4', - }, - { - firstName: 'HUI', - lastName: 'CHIN VOON', - correlationId: '5b2b3498-057c-47b8-bc89-1e057b5f6838', - }, - { - firstName: 'MUHAMMAD', - lastName: 'SUHAIMI BIN MUHAMMAD SHAWAL', - correlationId: '390f1acf-95e7-4ae1-8115-1d1ba697b3d5', - }, - { - firstName: 'WEN', - lastName: 'SIANG JEREMIAH ONG', - correlationId: 'c14da3c0-fd3b-4053-ba40-583a42b44d82', - }, - { - firstName: 'CHIN', - lastName: 'SIEW WOUN', - correlationId: '522d2613-818d-4c83-8ea5-a2876732b7db', - }, - { - firstName: 'NOOR', - lastName: 'AQIL BIN MOHAMAD ALI', - correlationId: 'efedfdff-7451-4fbc-8e3e-68d7c7f74efe', - }, - { - firstName: 'CHEN', - lastName: 'JI TENG', - correlationId: 'd3520d7e-ae29-42e3-a3fc-848eebbc3f62', - }, - { - firstName: 'CHEN', - lastName: 'TZONG-CHE', - correlationId: 'ae86a70b-86bb-45de-b860-bcf1c2498128', - }, - { - firstName: 'CHEN', - lastName: 'T C', - correlationId: 'a5e76a8d-3c6a-4447-ba3f-2fc0b19964c4', - }, - { - firstName: 'LEE', - lastName: 'MEE YING', - correlationId: '04569ac5-5684-409a-8283-f0f3e450e9e5', - }, - { - firstName: 'LEE', - lastName: 'MUN KHEONG', - correlationId: '2b983971-c5c3-4d87-a907-88b8c180b0ab', - }, - { - firstName: 'LEE', - lastName: 'MUN WAI', - correlationId: 'c2837d4b-0c8b-4c31-b10b-ba3165ce01ea', - }, - { - firstName: 'LEE', - lastName: 'LIN YENG', - correlationId: 'f877bb4b-e2b0-4cd8-a9ef-c72ad34f462b', - }, - { - firstName: 'ADAM', - lastName: 'SAKINAH BINTE NUR', - correlationId: '0107d756-0cbf-4725-84e0-3671347d3f87', - }, - { - firstName: 'FELICIA TEO', - lastName: 'YUEQING', - correlationId: '7bbbf123-0be9-4d34-9b7c-5419008a378c', - }, - { - firstName: 'KEVININDA TAN', - lastName: 'BEE THENG', - correlationId: 'b787a7a3-21c8-4ea5-a1ff-80b6e676f301', - }, - { - firstName: 'KEVIN', - lastName: 'SCOTT BAUER', - correlationId: '83f958ac-0e06-4888-a77d-a0e626e96260', - }, - { - firstName: 'PHOEBE WANG', - lastName: 'TING WEN', - correlationId: '61d25c22-6d3f-4005-86a8-3ff4c0c473c8', - }, - { - firstName: 'WANG', - lastName: 'TING WEN', - correlationId: 'd7238aed-a221-4f89-9895-df2f909b1de3', - }, - { - firstName: 'CHIU', - lastName: 'YEUNG', - correlationId: '813956af-0203-481f-afbc-92ead24b3bf3', - }, - { - firstName: 'CHEN', - lastName: 'GUOZHONG', - correlationId: '78aa528d-f7d1-4b17-93ea-b8a34e636a42', - }, - { - firstName: 'TAN', - lastName: 'TIONG', - correlationId: 'efb0e33d-546d-4ca0-aa35-67964ce4c3e5', - }, - { - firstName: 'ALFRED LIM', - lastName: 'SHEN WEE', - correlationId: 'ec14ee3a-be52-437d-a28d-0730694cac47', - }, - { - firstName: 'GRAHAM', - lastName: 'MOORE', - correlationId: '0e2e6a12-9b7b-4d49-8637-754d6cd44b0f', - }, - { - firstName: 'ARUN', - lastName: 'PRAKASH DIXIT', - correlationId: '966806b3-f29c-4e5b-84c8-7e34649e602f', - }, - { - firstName: 'CHATURVEDI', - lastName: 'NEERAJ', - correlationId: '0c154a0c-5bb9-4350-aff8-c637e77df6d3', - }, - { - firstName: 'ARCHANA', - lastName: 'DIXIT', - correlationId: 'b747c90a-3267-461a-bc53-efdbc3810afc', - }, - { - firstName: 'TAN', - lastName: 'TONG', - correlationId: '87ae4160-3f22-49f7-8565-597cbf6c1e09', - }, - { - firstName: 'HE', - lastName: 'JIANPENG', - correlationId: 'bd0287ff-7457-4e4b-981c-04ff38335cb9', - }, - { - firstName: 'ZHONG', - lastName: 'FENG', - correlationId: '2e7a81fc-98ae-48bb-8f78-2e432cc11145', - }, - { - firstName: 'TANG', - lastName: 'YE XIANG', - correlationId: '02bd4ddc-0e16-4b11-acd8-51865089dcf1', - }, - { - firstName: 'NOOR', - lastName: 'SITI FADHILAH BINTE ABDUL RAHMAN', - correlationId: 'fe21ecfe-229a-40ce-929a-1d5b8782977b', - }, - { - firstName: 'WANG', - lastName: 'ZIYIN', - correlationId: 'c080d936-bad4-49cd-8235-161a48c9b3c7', - }, - { - firstName: 'NEERAJ', - lastName: 'CHATURVEDI', - correlationId: '2d5e0bf4-4b45-47fd-b4a4-20b4ccfa0037', - }, - { - firstName: 'VINITA', - lastName: 'KUMARI', - correlationId: '74ac5196-9cef-47a8-b71d-0ccbd26b9fcd', - }, - { - firstName: 'SOH', - lastName: 'SAR', - correlationId: '66f0f09e-2999-4a07-be50-89220ee9c24c', - }, - { - firstName: 'JOHN LIM', - lastName: 'CHENG SIEW LIM', - correlationId: '9324d03f-1c06-4a1a-a445-8151e68e1749', - }, - { - firstName: 'LIM', - lastName: 'MENG LUNG', - correlationId: '314033bd-2e6e-4421-951f-a7a9958c1aad', - }, - { - firstName: 'SITI', - lastName: 'JULIANA BINTE MOHAMED RUSLAN HADI', - correlationId: '1647b9fc-62be-421c-85de-06d2b6dba031', - }, - { - firstName: 'CIPTO', - lastName: 'HANDOYO', - correlationId: '29925f51-cb3c-4bbc-8bb5-cf07070c7d50', - }, - { - firstName: 'JONI', - lastName: 'HERISON', - correlationId: '7624880f-c1e4-4169-84fe-f44010c64867', - }, - { - firstName: 'ALVINA KHOO', - lastName: 'LEA ING', - correlationId: '7e58ae1b-044f-443d-b798-ff2998edd272', - }, - { - firstName: 'ERIC TAY', - lastName: 'POH HUAT', - correlationId: '8c6cb1db-4b18-4c10-990e-a4a0632b59b1', - }, - { - firstName: 'LATTHAPORN', - lastName: 'SROYSOONTORN', - correlationId: 'ee060727-febe-48f9-8976-b70d8518f3c2', - }, - { - firstName: 'BAILEY', - lastName: 'SPITERI', - correlationId: '3393dd1e-c25b-4705-9a91-e138772dd735', - }, - { - firstName: 'CAI', - lastName: 'SHENG TOH', - correlationId: '4429764c-81a0-415f-b527-0795c9b78040', - }, - { - firstName: 'TANG', - lastName: 'JIAJUN', - correlationId: 'fe35dc45-faef-4cc3-ae9e-483b960dbcd9', - }, - { - firstName: 'GRACE JIA', - lastName: 'LIN YEO', - correlationId: '25a8b0f4-b01d-4ac3-bceb-21a1c489e2c5', - }, - { - firstName: 'AIVAR', - lastName: 'MOLDAGALIYEV', - correlationId: 'ffd0f7a5-a626-4027-8325-5096334f56b8', - }, - { - firstName: 'MUHAMMAD', - lastName: 'HASBULLAH BIN HASSAN', - correlationId: 'f2abbd17-bdc8-4d40-9540-a2864c3033f9', - }, - { - firstName: 'POH', - lastName: 'YOKE SHIM', - correlationId: '52e70ae8-0a3f-4120-9c67-ec408ac51e3d', - }, - { - firstName: 'DANIEL', - lastName: 'DYKES', - correlationId: '7a1c2aad-0274-4717-a8af-b639822dc2e2', - }, - { - firstName: 'NG', - lastName: 'JUN', - correlationId: 'eba73ec6-b775-40b9-adac-2a75be028957', - }, - { - firstName: 'NG', - lastName: 'KEAT', - correlationId: 'afca8b5d-d6a6-4d87-a3df-3cd974b5750d', - }, - { - firstName: 'Wichairat', - lastName: 'Ngaongam', - correlationId: '9ae77062-e357-4ade-b96e-571d7ac900f6', - }, - { - firstName: 'JAMES QIANG', - lastName: 'XIANG TEO', - correlationId: 'e6ff8e53-c9aa-47f8-8984-001375e22991', - }, - { - firstName: 'brendan', - lastName: 'hensel tay', - correlationId: 'd3ddbae3-6bf6-4e5a-9759-8906f9ed9b55', - }, - { - firstName: 'SEE', - lastName: 'LI LAM', - correlationId: 'e28db610-bd1d-4f20-9a9b-7cb1119cfc8e', - }, - { - firstName: 'ABDUL', - lastName: 'RAZAK BIN SALEH', - correlationId: '0f0cc142-38a4-4190-8061-b1fc0838fe43', - }, - { - firstName: 'XU', - lastName: 'RUDUO', - correlationId: 'f6c5fd7b-a4d1-44f2-ab77-78ed8175487d', - }, - { - firstName: 'YANG', - lastName: 'JITING', - correlationId: 'c5c9e835-b137-498c-b496-0402f52aeb8c', - }, - { - firstName: 'KANG', - lastName: 'YI', - correlationId: '40a90bcc-83ef-437c-a16f-043e75eb2af6', - }, - { - firstName: 'MUHAMMAD', - lastName: 'FIRDAUS BIN ABDULLAH', - correlationId: '70b15d45-efcf-47a3-aca1-cfd4900120e6', - }, - { - firstName: 'WONG', - lastName: 'SENG', - correlationId: 'c0f3075a-6956-4522-bbfd-ac2c23c6f638', - }, - { - firstName: 'CHEN', - lastName: 'PING', - correlationId: 'c13211e7-4714-4811-9770-30fbf02b79a2', - }, - { - firstName: 'TAN', - lastName: 'PING', - correlationId: '8c6baf95-2582-4267-8e7d-b66ede78bf3c', - }, - { - firstName: 'YAP', - lastName: 'HONG', - correlationId: '2be84d07-133a-4500-8f96-ef0c60dee943', - }, - { - firstName: 'DMITRIY', - lastName: 'VDOVIN', - correlationId: 'a94873b6-8827-4d94-ae8d-93ccfa87eb8c', - }, - { - firstName: 'TAN', - lastName: 'YING', - correlationId: '06929296-d1bb-40e1-8703-812e42e57db2', - }, - { - firstName: 'Tharnansakd', - lastName: 'Leenasiri', - correlationId: 'e71fc3f4-a7da-42f3-96fa-3d0bfc248b1d', - }, - { - firstName: 'JITEN', - lastName: 'PAUL', - correlationId: 'd76f3adb-b37b-4453-af75-8fbaa96baf29', - }, - { - firstName: 'RAJ', - lastName: 'KAMAL', - correlationId: '0e37ac05-6abf-4cbc-8b73-7d0ca4094e51', - }, - { - firstName: 'TAN', - lastName: 'CHUAN', - correlationId: 'a687571c-21a5-448b-80fb-c24685d3e964', - }, - { - firstName: 'Rathor', - lastName: 'Ruchi', - correlationId: '8a6a6333-beee-4b3f-9368-4df63640569e', - }, - { - firstName: 'foo', - lastName: 'wenquan', - correlationId: '952f7e36-1dd9-49a2-817d-1ae1023a9287', - }, - { - firstName: 'tay', - lastName: 'junhao', - correlationId: 'bb3100cb-90d9-4603-a620-a7ff20867827', - }, - { - firstName: 'TAN', - lastName: 'AH TENG', - correlationId: 'cbb77cff-cc27-43fb-9326-fe7408184e3f', - }, - { - firstName: 'TAN', - lastName: '', - correlationId: '0f07452d-60b3-4399-b91a-3de85e5d47ba', - }, - { - firstName: 'SURIYAH', - lastName: 'S/ O G SELVARAJAH', - correlationId: '06eaa93c-bb29-4a39-808f-f1491394b88f', - }, - { - firstName: 'CHOW', - lastName: 'WOUNG', - correlationId: '63ae7800-3aec-4a80-9214-3ff7e5518d17', - }, - { - firstName: 'CHUA', - lastName: 'HAU', - correlationId: 'd4685d0f-7183-4d03-a74b-feea6dbecf62', - }, - { - firstName: 'HAN', - lastName: 'SEONG', - correlationId: '404d104e-8d05-4ca7-930d-3ba225574de4', - }, - { - firstName: 'XU', - lastName: '', - correlationId: '81efb76a-c66a-4e35-b553-bb03c100b190', - }, - { - firstName: 'XING', - lastName: 'JUNSHENG', - correlationId: '6ef5d781-94c8-4fed-89b1-9216753fc8e8', - }, - { - firstName: 'TAN', - lastName: 'SHEN', - correlationId: '54aa3041-7ac1-412f-9d85-14a7e2384de3', - }, - { - firstName: 'ONG', - lastName: 'LIANG', - correlationId: 'db5026fb-b551-49ae-8084-1376dcaaa3b1', - }, - { - firstName: 'TAN', - lastName: 'SUK PHERN', - correlationId: 'bcc100b9-d7c7-465c-bfaf-af92142dd135', - }, - { - firstName: 'SONG', - lastName: 'HUARUI', - correlationId: 'c75d1f40-0600-4671-84a2-3f603b215fa8', - }, - { - firstName: 'ZHOU', - lastName: 'XUECHENG', - correlationId: '0685d154-859d-48ad-95eb-42f919a314de', - }, - { - firstName: 'LI', - lastName: 'SONGYAN', - correlationId: '9cd40406-70b7-4a68-ac79-32a19c53d200', - }, - { - firstName: 'TEO', - lastName: 'YI TING', - correlationId: '0a1e457a-36f7-492f-98c7-5ac392a963b3', - }, - { - firstName: 'SUNAFRI', - lastName: 'BIN SUANDI', - correlationId: '169fa91c-3b88-4fd8-8170-d9910de379dd', - }, - { - firstName: 'PATRICK', - lastName: 'OTTO EGER', - correlationId: '92d76370-23ff-47d5-91df-ec3d1b5703fe', - }, - { - firstName: 'ARMAN', - lastName: 'AKLYZHANOVICH SYBANBAYEV', - correlationId: 'c4cafb52-4754-4c7f-a3da-b628fe430b51', - }, - { - firstName: 'Warganegara', - lastName: 'Lelaki', - correlationId: '3b8958db-51b5-4ff4-89c4-21e9ad5c2440', - }, - { - firstName: 'JONATHAN YEO', - lastName: 'Kai Sheng', - correlationId: '1cde3194-c260-48de-8f52-4b8569c300a1', - }, - { - firstName: 'SIEW', - lastName: 'WEI SIANG', - correlationId: 'ed5360f4-a6c9-4c3a-a1d3-f6daf60bfee1', - }, - { - firstName: 'LIU', - lastName: 'YONGQING', - correlationId: '1e19862a-d1e7-4d37-91fb-06ae9b329ad8', - }, - { - firstName: 'Vicky', - lastName: 'Nor Ayesha Gannason', - correlationId: 'fc41b4df-c50a-4cd5-8a7b-882e636f742d', - }, - { - firstName: 'Zhang', - lastName: 'Liang', - correlationId: '0bfc9e45-66e9-44f6-b03a-9bd2eab58ef4', - }, - { - firstName: 'Wang', - lastName: 'Hu', - correlationId: 'dfbf7200-abf4-4f31-9ef9-25987359ef71', - }, - { - firstName: 'Evgeny', - lastName: 'Yurievich', - correlationId: '0a1bf573-dd37-40ae-9fb9-d35a67786773', - }, - { - firstName: 'Saltykov', - lastName: 'Stanislav', - correlationId: '5c7b83fe-d77e-47e5-9f81-20bec22bcc78', - }, - { - firstName: 'Evgenii', - lastName: 'Kalashnikov', - correlationId: 'e43b2c16-3945-4ea2-aa7a-c024229ded5f', - }, - { - firstName: 'YOKE', - lastName: 'THENG KOK', - correlationId: '1b5673eb-2a62-40f4-9997-71468f364304', - }, - { - firstName: 'CHEE', - lastName: 'KONG LEONG', - correlationId: 'ed80ef28-e335-43e6-9853-7f618f75e80d', - }, - { - firstName: 'LEI', - lastName: 'WANG', - correlationId: '7a499dae-85e7-4a2f-a12b-a041d7fea7a8', - }, - { - firstName: 'NGU', - lastName: 'TECK KONG', - correlationId: '52028c98-0618-40bb-875d-dec204e79118', - }, - { - firstName: 'LUO', - lastName: 'SHENZHU', - correlationId: 'f1d6ad5f-c59e-43c9-8f54-0b328e12f363', - }, - { - firstName: 'SENG', - lastName: 'TECK LOH', - correlationId: '3a934a25-d282-4cde-b35e-0ed384e7121c', - }, - { - firstName: 'CHEN', - lastName: 'GUOZHONG', - correlationId: 'bc9b85fe-ad44-4615-88ef-6c2acbeead65', - }, - { - firstName: 'TAN', - lastName: 'TIONG', - correlationId: '357baab8-4133-4b76-af50-ff769aa0af59', - }, - { - firstName: 'LIM', - lastName: 'SHEN WEE', - correlationId: '7c46e6bb-660a-47d2-9a53-de164d642f41', - }, - { - firstName: 'POH', - lastName: 'XHIN TAN', - correlationId: '9b0067c6-d5af-47c0-81a6-9dd0e3a6a3aa', - }, - { - firstName: 'Kamal', - lastName: 'Raj', - correlationId: '28cf53d1-dd95-4ceb-9db4-a73cdf3decc0', - }, - { - firstName: 'Kamal', - lastName: 'Raj', - correlationId: '2aa18af6-b862-44cf-ada9-bbc677061c9b', - }, - { - firstName: 'Leana', - lastName: 'Isgandar', - correlationId: '2949a4f6-53ca-4d75-983b-a22bcf5c0eaa', - }, - { - firstName: 'SHINGHAL', - lastName: 'RAHUL', - correlationId: '55a9895b-b635-4acc-9b01-f37606c87a20', - }, - { - firstName: 'SAROJA', - lastName: 'KUMAR MISHRA', - correlationId: 'f2361903-4482-4a4b-befc-6ba87f3cf2e4', - }, - { - firstName: 'ARUL', - lastName: 'MURUGAN KUMARAVEL', - correlationId: '6f65634c-e03f-4f12-8ef4-2bc2d1d4ddc7', - }, - { - firstName: 'SHERYL CHIA', - lastName: 'XIANG TING', - correlationId: '218fd4e3-ce5c-4830-b8f2-0c59a81a09c2', - }, - { - firstName: 'Norfaizal', - lastName: 'Bin Abdul Rahman', - correlationId: '8e46eb99-36fa-43b3-b2ef-273ce19c5ef3', - }, - { - firstName: 'Nitin', - lastName: 'Damodaran', - correlationId: '3c405b62-2838-499a-bbdc-0ccfbe678f5b', - }, - { - firstName: 'Jing Veronica', - lastName: 'Ante Andrino', - correlationId: '92a09f2b-bc40-4192-a323-b1f6a3a000eb', - }, - { - firstName: 'LEE', - lastName: 'Wen Bin', - correlationId: 'b6c5164b-b0e5-49fa-94ab-025ff12e9109', - }, - { - firstName: 'PRAFUL', - lastName: 'GOPAL MORAR', - correlationId: 'e3076241-c6b0-43e8-933b-b2e5b059b86a', - }, - { - firstName: 'YUVAL', - lastName: 'ZIV', - correlationId: '2b6cec30-f48d-46b7-890e-e9232ae03ad1', - }, - { - firstName: 'KWA', - lastName: 'LENG', - correlationId: '2ba8a215-69ab-4287-b65d-4cca0aa308ef', - }, - { - firstName: 'CHIA', - lastName: 'HOON', - correlationId: 'ab96a917-56b2-4e5a-8aaa-8c5307cabaa0', - }, - { - firstName: 'LEE', - lastName: 'HUI', - correlationId: '9bd27dce-cfbc-4cb6-a1a6-1055a5df2699', - }, - { - firstName: 'NGU', - lastName: 'TECK KONG', - correlationId: 'd80e5729-32b0-4e32-84c4-1210d14792ac', - }, - { - firstName: 'ZHUANG', - lastName: 'MONICA', - correlationId: '4f4b4bd8-7a19-4e37-a6d5-33d9409401a5', - }, - { - firstName: 'FOO', - lastName: 'WEE', - correlationId: '2197769b-b005-43e6-8585-0803fec55932', - }, - { - firstName: 'SOH', - lastName: 'SAR', - correlationId: 'e87d79ca-5292-4405-8dc7-b77237726221', - }, - { - firstName: 'JOHN LIM', - lastName: 'CHENG SIEW LIM', - correlationId: '81a28b9e-8f68-43b4-b783-1d281145a320', - }, - { - firstName: 'LEE', - lastName: 'SAN', - correlationId: '748c22ed-2503-44b0-9917-f0c626b0ab62', - }, - { - firstName: 'PARK', - lastName: 'YEONG', - correlationId: '38d58845-2fee-4847-a45c-d2b6fd960400', - }, - { - firstName: 'CIPTO', - lastName: 'HANDOYO', - correlationId: 'fb5b20e2-e376-478e-88fb-35fda9af4945', - }, - { - firstName: 'JONI', - lastName: 'HERISON', - correlationId: 'a8a9307b-c4c8-4592-9705-8653ba5ca2cb', - }, - { - firstName: 'Kao', - lastName: 'Ping', - correlationId: '980b4d2a-4a77-4edf-9ee6-78f0cc197599', - }, - { - firstName: 'Lee', - lastName: 'Chae Fong', - correlationId: '8ad589ff-c1dc-4e3a-b528-a21bc729c362', - }, - { - firstName: 'Supanun', - lastName: 'Meelarp', - correlationId: '9bca2c1a-59c5-40ea-8b33-8b70c93c5f81', - }, - { - firstName: 'Nawaporn', - lastName: 'Pakieatsakul', - correlationId: '31ea12ac-f6d6-4447-9209-075802f594d8', - }, - { - firstName: 'Assa', - lastName: 'Eliran', - correlationId: '4e3d194b-ffcc-4a1b-bfd0-b4ea563d01a3', - }, - { - firstName: 'WONG', - lastName: 'LEONG', - correlationId: 'b5e50a70-7433-4d3c-9914-c9a13682c453', - }, - { - firstName: 'DU', - lastName: 'YAXIN', - correlationId: 'c02d79a1-2d66-499e-ac29-e1f9a882d67b', - }, - { - firstName: 'TAKEFUMI', - lastName: 'ANDO', - correlationId: '8e53e4c1-553e-4e8c-84bd-b5bce1a99898', - }, - { - firstName: 'CHEN', - lastName: 'YONGLE', - correlationId: '11f2eb0c-7e90-4fdf-a795-dbb3b0743977', - }, - { - firstName: 'TAN', - lastName: 'LOK', - correlationId: '5f6ead7f-3aa8-4030-8f99-d1fdcfe7b703', - }, - { - firstName: 'CHONG', - lastName: 'Lewin You Wei', - correlationId: 'd1052b54-8466-4bc7-8273-0641b39f999f', - }, - { - firstName: 'Ng', - lastName: 'En Fu', - correlationId: '6e38a09e-9179-45f1-a463-0251aa4f77b5', - }, - { - firstName: 'Ng', - lastName: 'En Fu', - correlationId: '34b19363-5de8-41d9-a007-675fd8833c8f', - }, - { - firstName: 'RICHARD', - lastName: 'ANDREW HENDERSON', - correlationId: '8dae16b3-da6a-4bf3-b748-2199ace56e0a', - }, - { - firstName: 'Parizod', - lastName: 'Cross', - correlationId: '10c62d1c-738c-407e-aee4-5867fcae5c0f', - }, - { - firstName: 'Iliya', - lastName: 'Talman', - correlationId: '94b86ec1-9ff7-457d-8fa9-857a9371b3bf', - }, - { - firstName: 'ERNIE', - lastName: 'DONDON TAGGET VACAL', - correlationId: 'fec5f725-8178-4887-8b57-2b60800012e2', - }, - { - firstName: 'CHING', - lastName: 'WEI HUNG', - correlationId: '86786b7c-4285-4e00-bb1a-3fcc622e9162', - }, - { - firstName: 'CHEE', - lastName: 'HOCK ROTHSCHILD', - correlationId: '76d5c699-ed29-4b17-8403-16cbb475b621', - }, - { - firstName: 'CHIAT', - lastName: 'KWONG CHING', - correlationId: 'f3c1157d-c833-4eef-9790-889d78f379ca', - }, - { - firstName: 'NG', - lastName: 'SUI HARRY', - correlationId: '19cb4ccb-627e-4818-b643-55e921b3a5d0', - }, - { - firstName: 'CHEN', - lastName: 'KEONG CHIN', - correlationId: 'b3256fc2-ae40-4cbf-974e-8af5d4dce40b', - }, - { - firstName: 'KESAVAN', - lastName: 'NAIR', - correlationId: 'c60e8a0b-2c2c-409d-ad56-58d56c1858e2', - }, - { - firstName: 'THAMASELVAN', - lastName: 'RAMACHANDRAN', - correlationId: '634fba21-f64c-404d-91e0-5029bcffd656', - }, - { - firstName: 'YAN', - lastName: 'CHENG', - correlationId: '88b87839-4fef-4ead-9785-ee36855f1b82', - }, - { - firstName: 'LUN', - lastName: 'ZHU', - correlationId: 'cee02700-c96b-455a-b43c-4e61b6daefaf', - }, - { - firstName: 'REACHABLE', - lastName: 'GLOBAL', - correlationId: '37a75a3f-dd65-4f07-9b57-7294bd19f2cd', - }, - { - firstName: 'TIAN', - lastName: 'XIAOHUI', - correlationId: '0fd6a6c9-01f2-4927-a1f0-b10182bf697c', - }, - { - firstName: 'YU', - lastName: 'HIAN ONG', - correlationId: '66932cd7-37c2-4a0d-82c4-0b6a08c02090', - }, - { - firstName: 'TECK', - lastName: 'SENG HENG', - correlationId: 'd615b540-12e6-45d8-84c9-baf40e0a496d', - }, - { - firstName: 'KIM', - lastName: 'LEW HENG', - correlationId: '2cffdf0f-d69d-4f6e-8579-96ad88dacc2c', - }, - { - firstName: 'KIM', - lastName: 'LEW LOW', - correlationId: '5858a893-9b19-4343-9cf5-0a687e1858ba', - }, - { - firstName: 'CHEE', - lastName: 'KEAT LIU', - correlationId: '68bf2768-3bd8-4f82-9a30-3852bb035f4a', - }, - { - firstName: 'Phisit', - lastName: 'Lhikhikhitwattanakit', - correlationId: 'aaf7ea03-dd1e-4a42-9773-2e915e67ceab', - }, - { - firstName: 'NG', - lastName: 'SEEN', - correlationId: '91e4f3a1-aa7c-4357-9139-2ff7a2d43f11', - }, - { - firstName: 'LAY', - lastName: 'CHOON SYE', - correlationId: 'f489ec03-0608-4451-bedc-02864d41ffae', - }, - { - firstName: 'YEO', - lastName: 'YAN LI', - correlationId: 'd15c64fd-18c8-4533-b508-6ce9660d5997', - }, - { - firstName: 'DENG', - lastName: 'BOQIAN', - correlationId: 'a783213d-0100-4032-bd6b-a76046ef1722', - }, - { - firstName: 'PO', - lastName: 'CHIEN TANG', - correlationId: '90df7a02-8e9d-496d-a10b-95c8c9fc3c0b', - }, - { - firstName: 'LEE', - lastName: 'MENG KO', - correlationId: '49760f02-22dc-4c13-8fd7-0e8d34aac0ae', - }, - { - firstName: 'WEE', - lastName: 'SENG KOH', - correlationId: 'be8ea6f0-5523-4f52-84dc-91b8a31a3d3d', - }, - { - firstName: 'LEE', - lastName: 'HWEE KOH', - correlationId: 'abb82400-c557-4d15-8767-d8639b35a566', - }, - { - firstName: 'Tan', - lastName: 'Kee Nern John', - correlationId: '0dc0ce2b-dd26-4541-9008-fb7f96d733f4', - }, - { - firstName: 'Shubiao', - lastName: 'Jiangsu', - correlationId: '4973f9fa-fa9a-4ad1-b30a-5f9ab198876d', - }, - { - firstName: 'Jaynarainsingh', - lastName: 'Tatarah', - correlationId: '562c2d38-48bb-4748-9e6d-2b387b9d4030', - }, - { - firstName: 'Sharma', - lastName: 'Krishnanand Gopaul', - correlationId: 'c2a525c8-91af-401d-96b1-6dc95e94a134', - }, - { - firstName: 'SIU', - lastName: 'Man Kit', - correlationId: '44143ea8-46f6-4ef2-acf4-b113b7963019', - }, - { - firstName: 'LI', - lastName: 'Keung', - correlationId: 'a21b0b56-7cb8-4637-8fd2-a53d84c7b275', - }, - { - firstName: 'ARUN', - lastName: 'PRAKASH DIXIT', - correlationId: '0497e1b1-4ce6-4015-82d7-bff451bb3ec3', - }, - { - firstName: 'ARCHANA', - lastName: 'DIXIT', - correlationId: '3bb2bc6b-59ec-4f5d-89ca-bfb8584a03f1', - }, - { - firstName: 'CUBEK', - lastName: 'TECHNOLOGIES', - correlationId: '28512a7b-aa88-4a1e-a863-f4b41526ed8b', - }, - { - firstName: 'CHATURVEDI', - lastName: 'NEERAJ', - correlationId: '08b7020d-eed9-4185-9149-3c5eba2e523d', - }, - { - firstName: 'KUMARI', - lastName: 'VINITA', - correlationId: 'fc0b67ed-7a73-4113-a436-ece48c62768e', - }, - { - firstName: 'CHEE', - lastName: 'KEONG TAN', - correlationId: '98e73eb8-764c-4b29-ba02-2362b01d5b2d', - }, - { - firstName: 'YONG', - lastName: 'SENG CHEE', - correlationId: 'd89b2117-70c4-486e-8d2b-49317132b467', - }, - { - firstName: 'hubei', - lastName: 'jiangsu', - correlationId: '2b194aac-e66d-48da-b19d-d598353ad9d9', - }, - { - firstName: 'Michalis', - lastName: 'Christou', - correlationId: '0786a3f4-c8a9-469a-91b4-04433ed75775', - }, - { - firstName: 'CHAN', - lastName: 'CHEE WAI', - correlationId: 'b250faee-e27e-453a-9df9-db6f80e3095a', - }, - { - firstName: 'LEONG', - lastName: 'YU MING', - correlationId: 'a2c278f4-2016-4e95-8ec3-26aa900227de', - }, - { - firstName: 'Huang', - lastName: 'Xinghua', - correlationId: '2053c6ef-8b0c-467f-b04c-e71d861e903b', - }, - { - firstName: 'Nuttaphon', - lastName: 'Asavachompoonuch', - correlationId: '51375025-5ec2-44c2-b345-b85f6a71812c', - }, - { - firstName: 'Sumeth', - lastName: 'Damrongchaitham', - correlationId: 'f34ce873-84b4-4401-83a4-d3c91fb5fcb9', - }, - { - firstName: 'Woon', - lastName: 'Keng Hua', - correlationId: 'fef51784-a8bf-4944-b8b9-bb98ada3a8be', - }, - { - firstName: 'Tan', - lastName: 'Wei Kent', - correlationId: '02a49d92-b8d3-4e30-8e2b-463f649bd324', - }, - { - firstName: 'Foong', - lastName: 'Kim Weng', - correlationId: '1d8df0ab-8606-4cbb-833e-4998f3972885', - }, - { - firstName: 'Eric', - lastName: 'Eger', - correlationId: 'd0afde1b-c90b-48fb-b885-6351ee46501f', - }, - { - firstName: 'SHI', - lastName: 'QIANLI', - correlationId: '4e8e10b2-6a4c-4738-8651-a47f3b0a8de8', - }, - { - firstName: 'RALLYVILLE', - lastName: 'MARKETS GLOBAL', - correlationId: '75c870a0-0cb4-452e-bf26-48e2561cbe71', - }, - { - firstName: 'Somchai', - lastName: 'Boakkham', - correlationId: 'f234260a-0d84-4f48-85d0-cb86fcad877b', - }, - { - firstName: 'WANG', - lastName: 'Bosen', - correlationId: '2e064ae7-d6f7-4db0-8b81-8735c1331a3b', - }, - { - firstName: 'LUQMAN HELMI', - lastName: 'BIN SYED ABDUL AZIZ SYED', - correlationId: '6eeb8e93-4104-415e-8b4e-d66276103c2e', - }, - { - firstName: 'ONG', - lastName: 'SIEW KEE', - correlationId: '87016e8c-6447-4fa6-8e25-6157d9487c93', - }, - { - firstName: 'LIM', - lastName: 'SIEW KEE', - correlationId: '2ba82a1e-e748-435f-b85d-c82637f074db', - }, - { - firstName: 'LAi', - lastName: 'WAI KIT', - correlationId: '5f7cefeb-b26d-4ff8-9166-05d435d0a4fd', - }, - { - firstName: 'Mumuh', - lastName: 'muhidin', - correlationId: '5939e310-5c65-4085-8c84-91980577d4bd', - }, - { - firstName: 'Juniada', - lastName: 'Pagehgiri', - correlationId: '16d0161f-3ec0-4ae6-8999-9b61c6b6b46c', - }, - { - firstName: 'made', - lastName: 'suparta', - correlationId: 'ab4a882a-e58f-46ff-a7e9-466649af8f5a', - }, - { - firstName: 'Baram', - lastName: 'Ziv', - correlationId: '3441ea5e-f8c5-49f5-a0ef-f37309161a32', - }, - { - firstName: 'CHENG', - lastName: 'QINGXIONG', - correlationId: '3c2d4241-099d-48d4-94f3-6981d4c6913a', - }, - { - firstName: 'CHENG', - lastName: 'SIONG TAN', - correlationId: '86649380-f9b5-4609-a8f1-4016eb299275', - }, - { - firstName: 'TYNG', - lastName: 'LIN WEE', - correlationId: '7fe78738-99ec-4ced-b6f6-08588f88a5d4', - }, - { - firstName: 'GAO', - lastName: 'SHUAISHUAI', - correlationId: '973eb91e-8b5c-4c95-af28-9820266af898', - }, - { - firstName: 'Phisit', - lastName: 'Lhikhikhitwattanakit', - correlationId: 'ccef6afe-07d7-43e9-957c-41e11becbade', - }, - { - firstName: 'DENG', - lastName: 'quanbing', - correlationId: '297bc21f-3415-4586-8fa4-938e2a22ec7f', - }, - { - firstName: 'DONG', - lastName: 'LIU', - correlationId: 'f07e1a8e-4aaa-4c38-b6c7-965bec2487a8', - }, - { - firstName: 'LUN', - lastName: 'ZHU', - correlationId: 'ad8940d7-3985-4fdc-a746-05830f4ab1c5', - }, - { - firstName: 'SHAN', - lastName: 'YEE LIEW', - correlationId: 'e335e412-ff53-4b24-bab6-1185a3b24aee', - }, - { - firstName: 'YAN', - lastName: 'CHENG', - correlationId: '30ec5e62-8e76-4975-8a0f-7bf65feed104', - }, - { - firstName: 'ONG', - lastName: 'HONG', - correlationId: '5a2a6d6c-e4f9-45f5-a128-895b02b08bae', - }, - { - firstName: 'KANG', - lastName: 'TENG TENG', - correlationId: '9ba37ad4-c048-4589-b9bb-246706a9f827', - }, - { - firstName: 'CHEE', - lastName: 'SENG CHIONG', - correlationId: '86308ab5-4b81-4450-8c8b-1a79112ed734', - }, - { - firstName: 'LIU', - lastName: 'WENJUN', - correlationId: '48bcfff7-7202-4569-85f3-e10bd80d35bd', - }, - { - firstName: 'CHEN', - lastName: 'XIAOBO', - correlationId: 'b7f47f8e-6da0-4725-a6e8-cdc4fc690d6f', - }, - { - firstName: 'YAN', - lastName: 'ZENG', - correlationId: '0e7b09e9-43bd-43e3-9f50-e12c0b3cb868', - }, - { - firstName: 'TAN', - lastName: 'YEN', - correlationId: '5abf8830-edcc-4d83-bcc4-48820e4825cd', - }, - { - firstName: 'WENG', - lastName: 'JUNYAN', - correlationId: '304c02a3-ae73-4be0-9f62-49eff731f4f6', - }, - { - firstName: 'CHUA', - lastName: 'SENG HUA', - correlationId: 'ed2e5eea-b7ab-4531-9716-023e54aa575d', - }, - { - firstName: 'LIM', - lastName: 'SYLVESTER', - correlationId: '230c2430-a666-4d2e-9f36-5604bd116f72', - }, - { - firstName: 'NG', - lastName: 'SOOK HWA', - correlationId: '54b7ca98-38f2-4a8c-b3af-8456b6ebd213', - }, - { - firstName: 'CHUA', - lastName: 'SOON SENG', - correlationId: '642fca9e-d4da-4c7b-ab7a-c14d5db4e770', - }, - { - firstName: 'LIM', - lastName: 'YAW', - correlationId: 'e7274d41-bc38-475b-8709-e992d5b1d137', - }, - { - firstName: 'LIM', - lastName: 'MING', - correlationId: 'bebe4fd6-c9e7-46dd-ad92-3223c845f642', - }, - { - firstName: 'YU', - lastName: 'TEK', - correlationId: 'e366b449-6a33-4887-b3c6-3d6e348214f7', - }, - { - firstName: 'LIM', - lastName: 'MING', - correlationId: 'c238bb31-c927-41c3-a10a-4882de7f4173', - }, - { - firstName: 'YU', - lastName: 'TEK', - correlationId: 'e43eff83-d9ee-45c3-8f9b-1dc70ae038e2', - }, - { - firstName: 'LIM', - lastName: 'BAN', - correlationId: '917d76c1-90a5-48d7-9fab-d53a1f3b7da2', - }, - { - firstName: 'LIM', - lastName: 'YAW', - correlationId: '534829f8-b17d-4473-a373-152b36e2be32', - }, - { - firstName: 'LIM', - lastName: 'CHIAN', - correlationId: '890a56c1-68f9-4f87-8d80-df1897d31deb', - }, - { - firstName: 'LIM', - lastName: 'CHIAN', - correlationId: '242beccd-63d6-427c-9879-f3e3c2341061', - }, - { - firstName: 'RUI', - lastName: 'YUE', - correlationId: 'b993c9ea-75ab-4622-baf9-70aa96354744', - }, - { - firstName: 'RAJESH', - lastName: 'PAHWA', - correlationId: 'adaa798f-0957-4359-a977-cc16772feae4', - }, - { - firstName: 'CHEN', - lastName: 'KEZHEN', - correlationId: 'd50aaef7-4e9e-4d48-a3e6-51c0e976ef24', - }, - { - firstName: 'ADAM', - lastName: 'BIN HASNI', - correlationId: '6b3df990-61d8-4442-8332-de2f231930a5', - }, - { - firstName: 'SIMON', - lastName: 'BOLVIG MARK', - correlationId: '0bfade05-8f3a-47e7-911f-30aaa584455f', - }, - { - firstName: 'KATO', - lastName: 'PRIME BELIZE', - correlationId: 'b807d5ed-a10a-48ba-86b0-ec2de16b0380', - }, - { - firstName: 'OH', - lastName: 'JIAN WEI', - correlationId: '1c912a6b-ce27-42d9-92db-1ee859c71e0f', - }, - { - firstName: 'ZHOU', - lastName: 'JIAMENG', - correlationId: '5927b936-5b0a-4ea7-890f-f5fc5a125f9f', - }, - { - firstName: 'MELVIN LOO', - lastName: 'ZHI XIAN', - correlationId: '0eeab1c3-8b8b-44df-a4a6-88f612439d15', - }, - { - firstName: 'Benoit', - lastName: 'Boisset', - correlationId: '96a8cb09-8a32-46c9-83ef-42837d4382bd', - }, - { - firstName: 'Onur', - lastName: 'Sena Gunday', - correlationId: '1a5477cf-ffa4-44f0-9081-3e64808d2b6f', - }, - { - firstName: 'LEE', - lastName: 'SHIENG WEI', - correlationId: '13c51694-d5e1-4bd7-bac9-38c2e33152ca', - }, - { - firstName: 'LIM', - lastName: 'MING', - correlationId: '97d4abac-363a-4d57-8182-90e4873633f3', - }, - { - firstName: 'LIM', - lastName: 'BAN', - correlationId: 'e910191a-9e17-4dbc-96bf-3fdbce0b856e', - }, - { - firstName: 'LIM', - lastName: 'YAW', - correlationId: 'e21dfc39-b601-4a0f-89fd-d840f6aecd56', - }, - { - firstName: 'YU', - lastName: 'TEK', - correlationId: '604f84fb-3aa6-42ce-ab45-1414997e9aca', - }, - { - firstName: 'MA', - lastName: 'YANJUN', - correlationId: 'acbe03e2-e706-4afc-9060-5f0e3b38a20e', - }, - { - firstName: 'BAY', - lastName: 'KOON', - correlationId: '8c47deaf-d32c-422d-9676-f70dce58110c', - }, - { - firstName: 'NG', - lastName: 'SIONG', - correlationId: 'c520342c-1c1f-4cbc-8739-528c1a2b136e', - }, - { - firstName: 'NG', - lastName: 'YEW', - correlationId: '5015fe21-8be2-4ef0-8b00-3625d295e15e', - }, - { - firstName: 'SIM', - lastName: 'JIA AN', - correlationId: 'cec31178-d026-4912-a6aa-b172f2261305', - }, - { - firstName: 'LEOK', - lastName: 'JOO HWA', - correlationId: '60b4f773-c993-4d74-80aa-076b1ad3d608', - }, - { - firstName: 'LEE', - lastName: 'Yat Fan', - correlationId: 'dce9108f-6b5e-476e-bf07-85867b8cec80', - }, - { - firstName: 'SONG', - lastName: 'GAO', - correlationId: '7fd604a2-1b17-44f1-a248-d7da83f96d5e', - }, - { - firstName: 'SIONG', - lastName: 'KO', - correlationId: '98a4ffbd-b3ee-45f6-923a-6fae97dbc3ed', - }, - { - firstName: 'FU', - lastName: 'ZHIWEI', - correlationId: '2ae08a64-0485-495a-b882-30413610fa33', - }, - { - firstName: 'POR', - lastName: 'CHEE WEI CALVIN', - correlationId: '783da4bd-6699-40b8-acad-2d49ee5a4d32', - }, - { - firstName: 'CHEN', - lastName: 'JINGYU', - correlationId: '855f975f-c281-4ff5-ad9c-c41f86364eed', - }, - { - firstName: 'CHIN', - lastName: 'JING YU', - correlationId: '4d7094e4-e361-4e39-a1cb-de2e1611bb5a', - }, - { - firstName: 'KONG', - lastName: 'YAP', - correlationId: '083255ed-eec6-48e8-9cf7-e11de7254b33', - }, - { - firstName: 'CHIN', - lastName: 'PIN KWONG', - correlationId: 'a0bc8e72-44a8-44b3-9ad2-d2235dd2e5c6', - }, - { - firstName: 'TOSHIMITSU', - lastName: 'YAMAOKA', - correlationId: '1f5c57bd-232a-479b-9dd4-396b7f0043b3', - }, - { - firstName: 'TENG', - lastName: 'YU YU', - correlationId: 'd4c23e8f-cff5-4921-8ef4-27c83bbd4ca0', - }, - { - firstName: 'CHAN', - lastName: 'PING HUNG', - correlationId: '2ff9c468-fdbb-4040-8214-f2246a61fdb6', - }, - { - firstName: 'TENG-YU', - lastName: 'YU', - correlationId: 'b58c8a08-1f0a-4809-b47b-73d092955cee', - }, - { - firstName: 'CHAN', - lastName: 'PING-HUNG', - correlationId: '60ff95b9-d041-42db-b95a-23142327a2ec', - }, - { - firstName: 'CHEK', - lastName: 'KHAI JUAT', - correlationId: 'c6b6942a-110c-41f1-84e3-8a6c3df389dc', - }, - { - firstName: 'CAROLINE', - lastName: 'BAKER', - correlationId: '65c91f61-5dda-4e0e-8e65-33da3f26291b', - }, - { - firstName: 'NARITA', - lastName: 'YUKIHIRO', - correlationId: '14931632-1a81-4938-9a5b-e7faea9b60db', - }, - { - firstName: 'TAKUYA', - lastName: 'FURUMAKI', - correlationId: '9a2099b5-592d-445f-9bc8-3154d22a2c5d', - }, - { - firstName: 'SHINYA', - lastName: 'TANGE', - correlationId: 'c618fe5b-4461-470b-a76b-596c83529c8a', - }, - { - firstName: 'TANG', - lastName: 'EDMUND KOON KAY', - correlationId: 'eb3982c3-20ed-47dd-807b-cc1f81b0e106', - }, - { - firstName: 'ATSUSHI', - lastName: 'MINEOKA', - correlationId: 'cfb2c9f2-3d72-48b3-abbf-252e24712101', - }, - { - firstName: 'NAOKO', - lastName: 'MINEOKA', - correlationId: 'e1c6ce70-d68a-4b04-b041-07e075957985', - }, - { - firstName: 'PRIME', - lastName: 'VANTAGE', - correlationId: '19c8388b-5ac9-4c1a-9017-2716317dc57f', - }, - { - firstName: 'ARUN', - lastName: 'DIXIT', - correlationId: 'e5107a14-7521-4c3c-8d0b-cfb1f2e9a3cd', - }, - { - firstName: 'JIAN', - lastName: 'YONGLIANG', - correlationId: 'bf579b87-e2f4-4acd-8c9b-8177e9ff13fb', - }, - { - firstName: 'WENG', - lastName: 'LEONG KAM', - correlationId: '83e5b970-0ef0-45e5-8cef-2cea2848cb89', - }, - { - firstName: 'CHUA', - lastName: 'YI XUAN PATRIA', - correlationId: 'c8e82116-a46d-4ce1-ac87-ee74fdc03e75', - }, - { - firstName: 'MAIKO', - lastName: 'ARIKAWA', - correlationId: '5859f5af-4e13-4235-a72e-4741af4f0b0e', - }, - { - firstName: 'QUAH', - lastName: 'SIEW KIM', - correlationId: 'bca5ad82-b21e-491c-943f-4bfb77aef439', - }, - { - firstName: 'NARUMI', - lastName: 'KOBATA', - correlationId: 'a9dfa2ca-ea2f-404c-8be7-b07a3fa3ca70', - }, - { - firstName: 'MUHAMMAD', - lastName: 'HAIRUL BIN SHAHRON', - correlationId: '2fb30cbb-cb1d-4b68-9371-c162a3e10530', - }, - { - firstName: 'CATALIN', - lastName: 'COLCERU', - correlationId: '54715993-baad-4e6b-a2b2-6da507162c3f', - }, - { - firstName: 'TAN', - lastName: 'MENG KIAT', - correlationId: 'b47f08ae-c74a-46bf-927e-b1fa42586eb9', - }, - { - firstName: 'HAN', - lastName: 'MINLI', - correlationId: 'b08196ae-4f1e-4ba8-a2c6-71f34725394b', - }, - { - firstName: 'ONG', - lastName: 'CHEE WEE', - correlationId: '7cbb17a8-96f1-4598-b1e3-ea429d41faa8', - }, - { - firstName: 'WANG', - lastName: 'HU', - correlationId: 'c3abd20c-0553-4e5d-8834-6efff7b7bd72', - }, - { - firstName: 'LIANG', - lastName: 'ZHANG', - correlationId: '8d963cd1-946c-4af7-b25e-33ff83a9c04b', - }, - { - firstName: 'XU', - lastName: 'ZHANG', - correlationId: '8e08728e-21b7-4065-8876-d9f091c21754', - }, - { - firstName: 'HUANG', - lastName: 'TING-YI', - correlationId: '19125116-b732-426d-9e82-9e021a619bf7', - }, - { - firstName: 'MA', - lastName: 'YA FEN', - correlationId: 'efdf7fec-e5ca-46d4-91ab-bb12a0c3435d', - }, - { - firstName: 'YING', - lastName: 'KUANG', - correlationId: 'f5e23e10-b1e8-45fd-a52e-0889aaf712ef', - }, - { - firstName: 'PALUEHUS', - lastName: 'MESAN', - correlationId: '0c8589be-0d4b-4224-9dbd-b659af36f258', - }, - { - firstName: 'KAJON', - lastName: 'CHIOPIPAT', - correlationId: 'f0812fa8-1136-4b2e-9acf-941ff0f35423', - }, - { - firstName: 'KASIAN', - lastName: 'WATANACHOWAPISUT', - correlationId: '0fbfcae6-8508-4470-8c14-47b7e838dd9f', - }, - { - firstName: 'MOHD', - lastName: 'HAFIZILFARID BIN ROSLIZAN', - correlationId: '543e6bc2-dae3-4860-8a20-b4435c60fc0f', - }, - { - firstName: 'AHMAD', - lastName: 'KAMEEL BIN MOHAMAD YUSOF', - correlationId: '32d2a2dd-109b-42f5-aa5a-14d26036690a', - }, - { - firstName: 'ADAM', - lastName: 'BIN HASNI', - correlationId: 'b8969618-513a-40c7-ad18-a57e0ea8c737', - }, - { - firstName: 'MOHAMAD', - lastName: 'NAZMI BIN MOHAMAD YUSOF', - correlationId: 'a802d618-e426-41ec-b146-a010797804f9', - }, - { - firstName: 'YONG', - lastName: 'TYNG YEE', - correlationId: '8b23f071-a0e7-4650-a9ff-8e3168d00166', - }, - { - firstName: 'LEE', - lastName: 'HSIU-WEN', - correlationId: 'a5e2142a-320d-46ba-be4a-8d6096ec34a4', - }, - { - firstName: 'VINCENT OH', - lastName: 'BOON CHIN', - correlationId: '54a1358a-72ad-4190-89f4-6f5b0c87023a', - }, - { - firstName: 'JULIUS', - lastName: 'CHUANG TECK CHUA', - correlationId: 'a8a808d1-e9b3-4eca-9650-8ffe281f5466', - }, - { - firstName: 'ANG', - lastName: 'WEE CHYE', - correlationId: 'c2cf69b1-124d-40ec-ae65-db7e87b17778', - }, - { - firstName: 'DANIEL LEE', - lastName: 'HAN', - correlationId: 'bec94622-17ed-4bc8-a80e-4bbfe9e7368c', - }, - { - firstName: 'CHENG', - lastName: 'VINCENT KOK YONG', - correlationId: '51e6ee38-c6d6-457a-b25f-665028d18509', - }, - { - firstName: 'Aisares', - lastName: 'Photiwan', - correlationId: '0548ff9d-519b-4d7a-8382-eab84c944728', - }, - { - firstName: 'Nutthawut', - lastName: 'Thongkesorn', - correlationId: '1c9b016e-974b-49f5-848b-df2ac9af052c', - }, - { - firstName: 'Suthat', - lastName: 'Boonyaperm', - correlationId: '6b93df84-6b6a-456b-a671-32be9896a385', - }, - { - firstName: 'ADAM', - lastName: 'BIN HASNI', - correlationId: '2ff55879-126c-4f50-aa6d-9521f5ae1b47', - }, - { - firstName: 'MARIO', - lastName: 'SANT SINGH', - correlationId: 'e542d74e-2769-485f-9248-c3fc4c536f88', - }, - { - firstName: 'TEO', - lastName: 'SIANG LOONG', - correlationId: '2a667408-26f3-40cc-89d7-ae69c8e91a66', - }, - { - firstName: 'TAY', - lastName: 'SHEH LEI', - correlationId: 'd9608d0d-fcd2-438f-a98f-9c2170151e0a', - }, - { - firstName: 'WONG', - lastName: 'QINLEI', - correlationId: '12bbd996-86ba-4249-9c63-19085199d7e6', - }, - { - firstName: 'ASWIN', - lastName: 'WARIER', - correlationId: 'b9fc2ea0-9536-4397-a370-b4449317885c', - }, - { - firstName: 'KOK', - lastName: 'SHU MIN KAREN', - correlationId: '779f2608-2289-495b-8d63-7e4b71bfaada', - }, - { - firstName: 'ANG', - lastName: 'JEAN BEE LENG', - correlationId: 'adf92192-6edc-49dd-8dc0-0d82100ca737', - }, - { - firstName: 'ZHENG', - lastName: 'RENHAO', - correlationId: '8931c879-828b-4ead-8386-552770d732a9', - }, - { - firstName: 'TAN', - lastName: 'KAREN SOK HONG', - correlationId: 'f05abab1-e219-4d62-ab58-ea4278074d2f', - }, - { - firstName: 'JUNAIDAH', - lastName: 'BINTE BADRON', - correlationId: '7ca67a12-8aa4-4a03-a82e-534a1f2660db', - }, - { - firstName: 'SASHIKUMAR', - lastName: 'GANAPATHY', - correlationId: 'c059e40c-0dd9-4eed-99b7-e7f2cf4548ca', - }, - { - firstName: 'RAMANAN', - lastName: 'RAMADOSS', - correlationId: '22a496f9-ce8a-409d-b542-6068501d126e', - }, - { - firstName: 'ALBINA', - lastName: 'ZHAXYBEKOVA', - correlationId: '92699878-36da-49da-8744-e9902f874080', - }, - { - firstName: 'ROGEN HENG', - lastName: 'LEONG POON', - correlationId: '59bbc222-744d-40f2-906f-ccc7259fe2d1', - }, - { - firstName: 'CHAWENGSAK', - lastName: 'ASSAWINNIMIT', - correlationId: '76ac1c8b-297d-459f-a208-a0df864e94cc', - }, - { - firstName: 'KAVIN', - lastName: 'PHONGPANDECHA', - correlationId: '0dfef9a2-84f1-4bff-ae6a-114a0266647a', - }, - { - firstName: 'LIN', - lastName: 'TANG', - correlationId: 'f6ebbf9d-8851-4125-8d3b-34c189cbea9b', - }, - { - firstName: 'JIAO', - lastName: 'FANG', - correlationId: '18dc4079-ecd6-4aae-82fa-01f0d541b5ea', - }, - { - firstName: 'CHIN', - lastName: 'SOON', - correlationId: '6326e000-8c96-46db-b117-81d338e438e5', - }, - { - firstName: 'LEE', - lastName: 'MUN KHEONG', - correlationId: '67fd6c3a-8695-443c-b02c-698fae949b8f', - }, - { - firstName: 'LEE', - lastName: 'MEE YING', - correlationId: '4c8104d5-9883-401c-af3d-6d5ebab931ad', - }, - { - firstName: 'LEE', - lastName: 'MUN WAI', - correlationId: '3d056cfa-5b3d-4791-ae8b-87e054259400', - }, - { - firstName: 'LIN', - lastName: 'YENG', - correlationId: '02a44d15-6865-4f59-9493-d3b6dee87ced', - }, - { - firstName: 'RICHARD ONG', - lastName: 'CHONG FOO', - correlationId: '847dc0fc-056d-4fb8-b2f6-13028cb2fbf4', - }, - { - firstName: 'LI', - lastName: 'CHUNSEN', - correlationId: 'c9e7ee01-4236-400e-8a1b-49536fb941f8', - }, - { - firstName: 'CHEW', - lastName: 'YING SIONG', - correlationId: '13a1f215-5f6f-40c0-aa53-8664d295a591', - }, - { - firstName: 'LOH', - lastName: 'JIA SHERNG', - correlationId: '8add8ea0-966b-4893-84e4-153a4930ec36', - }, - { - firstName: 'LIM', - lastName: 'ELTON JIN HONG', - correlationId: 'c28ac69c-165c-4f15-8313-b8d8e1f79848', - }, - { - firstName: 'JASPER SHUI', - lastName: 'Xing', - correlationId: 'f026db19-f461-482d-bb5d-697be4698818', - }, - { - firstName: 'CHEAH', - lastName: 'Ui Keat', - correlationId: 'eb939e16-0f07-43a0-8112-c3e7197ae56e', - }, - { - firstName: 'YUN', - lastName: 'YIN', - correlationId: 'e675ab36-94bb-4ca6-92cb-73e26838cbe7', - }, - { - firstName: 'CLARENCE TAN', - lastName: 'Yoke Yew', - correlationId: 'd9e050cd-1012-4e1f-a3f6-9da0441a1087', - }, - { - firstName: 'Carl', - lastName: 'Victor Gregor Fredung Neschko', - correlationId: 'f1cbd04f-c998-4c7a-996a-41ec78e4bf36', - }, - { - firstName: 'ZACHARY ANG', - lastName: 'WEI LONG', - correlationId: '31ae44f6-11ca-44b3-9db0-2399333fd613', - }, - { - firstName: 'Philip LOH', - lastName: 'Boon Chuan', - correlationId: '859c7c73-309f-447c-a146-dbb75f102b13', - }, - { - firstName: 'TERENCE TAN', - lastName: 'TEOW BOO', - correlationId: 'ba215157-105f-4d3c-ad80-309f94077f00', - }, - { - firstName: 'NG', - lastName: 'CHANG YIN', - correlationId: '84cc99ea-a782-44ea-aedf-22e5cae08be0', - }, - { - firstName: 'LIM', - lastName: 'CHING HONG', - correlationId: '7b65ae7e-46bf-4196-99c8-c0edc92ca8d3', - }, - { - firstName: 'ZHEN', - lastName: 'WANG', - correlationId: 'f12bb1db-6836-4152-a6cc-4aba040a5977', - }, - { - firstName: 'AHMAD', - lastName: 'SHAH BIN HERMAN', - correlationId: '2601cd63-04b2-4c93-bdf8-2bf675800e90', - }, - { - firstName: 'KENNETH LIM', - lastName: 'BAO XIANG', - correlationId: '3e5a1bce-a539-4894-b850-d7a8d46844cc', - }, - { - firstName: 'LEONG', - lastName: 'WEI JIAN', - correlationId: '7b8f708c-ec40-4df1-9edc-8d66a98923dd', - }, - { - firstName: 'ONG', - lastName: 'JUN LI', - correlationId: 'a2d10b46-cafa-4970-9eb8-d448872f760a', - }, - { - firstName: 'LEE', - lastName: 'WEE SNG', - correlationId: '5aeeb3e2-cf39-4b70-b712-8238cd2a86e7', - }, - { - firstName: 'SERENE PEH', - lastName: 'Beng Yian', - correlationId: 'c77731a9-8e71-4f6c-a5e7-b5a7df99b064', - }, - { - firstName: 'Chau', - lastName: 'Min Chen', - correlationId: '1f4ee439-6cc3-4b76-9962-983695975b23', - }, - { - firstName: 'CLARA CHEW', - lastName: 'Min Ting', - correlationId: 'c14195c1-4c6b-4d78-8c41-29a5bdd9c289', - }, - { - firstName: 'LING', - lastName: 'ZHANG', - correlationId: 'c34b805d-9d2e-4944-9510-da8dd73460f7', - }, - { - firstName: 'SURAJ', - lastName: 'PRADEEP KUMAR RANASINGHE', - correlationId: '03a4d243-8a3f-452b-8bce-33f4abcca017', - }, - { - firstName: 'NITIN', - lastName: 'SHENOY MANJUNATH SHENOY', - correlationId: 'efa1b26c-3c3b-4e09-aabd-0bcc82d93187', - }, - { - firstName: 'ABDULLAH', - lastName: 'SALEH A ALSHAHRANI', - correlationId: 'bbfafac8-c6ec-4af0-980e-100bca18eabc', - }, - { - firstName: 'NAEEF', - lastName: 'RAHMATULLAH', - correlationId: '0f5b5cbc-9626-48b1-8541-7519c055c47b', - }, - { - firstName: 'CHONG', - lastName: 'KAI CHUAN', - correlationId: '91bbf905-605b-4b74-875a-72f79581ca62', - }, - { - firstName: 'SREENIVASAN', - lastName: 'NARAYANAN', - correlationId: '245653fe-9d19-4177-9e52-6884d494e3c4', - }, - { - firstName: 'HARRY NG', - lastName: 'WENG SUI', - correlationId: '3c6ea6c4-ed3a-4715-b992-4fcfed19a5ee', - }, - { - firstName: 'CHEE', - lastName: 'KEONG KUAN', - correlationId: '71815172-7ade-4bac-80fb-cbcc842fec60', - }, - { - firstName: 'TOH', - lastName: 'CHOOI GAIT', - correlationId: '659bb9c1-67a7-43cd-b842-323c5443b091', - }, - { - firstName: 'CHIK', - lastName: 'WAI CHIEW', - correlationId: 'a09d0669-77d1-4623-a92b-c3408ac083f2', - }, - { - firstName: 'NG', - lastName: 'CHIN SIAU', - correlationId: '88a0d941-fc86-480b-9e4d-a95f6f5ac88b', - }, - { - firstName: 'SIEW', - lastName: 'JIUAN FOO', - correlationId: 'a7605e30-1447-4275-ad0b-8907dc688b3d', - }, - { - firstName: 'RAYMOND ANG', - lastName: 'EE PENG', - correlationId: '3d44eb11-b578-47d3-8461-1ae9def09577', - }, - { - firstName: 'BAIGRUNOVA', - lastName: 'AINARA NURLANOVNA', - correlationId: 'eaec8039-cc21-49de-8b21-4016e6869149', - }, - { - firstName: 'PRIYA', - lastName: 'BHATTACHARJEE', - correlationId: '8def22da-802a-47bd-8565-854478862f40', - }, - { - firstName: 'KEDARISETTY', - lastName: 'MANIKANTA', - correlationId: 'e04a6199-c67c-4623-9761-5419a3e1d975', - }, - { - firstName: 'DILEEPKUMAR', - lastName: 'NALLURI', - correlationId: '07862613-e45d-4977-a75e-1389e7f19d7b', - }, - { - firstName: 'SIJI', - lastName: 'JOSEPH', - correlationId: '72a586a7-4eb6-4eb9-a92d-781ce20d1888', - }, - { - firstName: 'BUTHAINA', - lastName: 'MOHAMMED SALMEN BIN MAKHASHEN', - correlationId: '59b720e8-138d-4dfb-b1e7-59e72d6f6aa4', - }, - { - firstName: 'SYED', - lastName: 'ADNAN HUSSAIN SHAH KAZMI', - correlationId: '72ef85b0-a14a-42a3-96e7-6611f4ce6a1a', - }, - { - firstName: 'PANG', - lastName: 'PAK KIN', - correlationId: '38fc2d1a-07db-4da4-9d20-c2bf3ec1a538', - }, - { - firstName: 'DAVID LEE', - lastName: 'TAI WEE', - correlationId: '085607da-7bab-4c17-91fb-90d162bd7760', - }, - { - firstName: 'KEVIN', - lastName: 'SCOTT BAUER', - correlationId: 'f50d68c5-4f40-4482-a295-b09e4226adeb', - }, - { - firstName: 'YAP', - lastName: 'POH CHOO', - correlationId: 'fac24e39-48ac-4645-87cb-b3aea840713f', - }, - { - firstName: 'LIEW', - lastName: 'CHEE YONG', - correlationId: '9be17339-e47c-42fa-9e0b-5287a08ee9c8', - }, - { - firstName: 'PHAM', - lastName: 'DUC THINH', - correlationId: 'd1a4d8a6-9c01-48b4-b715-d792962befd4', - }, - { - firstName: 'NAGHAM', - lastName: 'BASSAM I AL BADAWI', - correlationId: 'dbefe6ce-4f40-457b-ad01-4df373ec8ff6', - }, - { - firstName: 'BARIRA', - lastName: 'ANAS', - correlationId: '6663cb67-de8a-4bbf-baf1-832ac10d051c', - }, - { - firstName: 'LEONG', - lastName: 'KIAT CHEE', - correlationId: '32f2eb9a-6bae-411b-b70e-706d6df4e7fb', - }, - { - firstName: 'YEE', - lastName: 'LIN CHEWNG', - correlationId: '91e14f84-9412-444a-a33c-be4c587d60a9', - }, - { - firstName: 'LIM', - lastName: 'MENG LUNG', - correlationId: 'e13fae22-d4f6-4d04-a2c5-04ff080f8960', - }, - { - firstName: 'TAN', - lastName: 'KIM CHENG', - correlationId: '13fe0674-b31d-4bb1-a81d-8435e430580c', - }, - { - firstName: 'ATAR', - lastName: 'SINGH MEENA PRITAM SINGH MEENA', - correlationId: 'a9760c39-1a7a-44ed-8826-d19ddde38fdf', - }, - { - firstName: 'MASTOUR', - lastName: 'RUBAYYI O ALOTAIBI', - correlationId: '9984297e-f672-4a57-a431-3454d0f1b578', - }, - { - firstName: 'AZIZ', - lastName: 'AHMED KHAN', - correlationId: 'abb2e8d8-e15d-41f8-990f-c915e8bbc997', - }, - { - firstName: 'KATERINA', - lastName: 'ANTONIOU', - correlationId: '85bed894-cd2d-4e6f-aef2-bf46210a0485', - }, - { - firstName: 'KURZENA', - lastName: 'LIMITED', - correlationId: 'f68f0556-2bc7-4c2f-b71f-1f85edd993dd', - }, - { - firstName: 'LEE', - lastName: 'ZHI YANG', - correlationId: '6f571bcc-83bc-4593-9e80-c4f1efaf9d1c', - }, - { - firstName: 'CHHAYA', - lastName: 'HARSHAL GAIKWAD', - correlationId: 'c56a3800-d1f9-4337-874d-2b3e5b353729', - }, - { - firstName: 'MIDHULAJ', - lastName: 'SENALI VEEDU PARAMBA', - correlationId: '8673ffc3-2218-44c2-9ecd-2d0f51420def', - }, - { - firstName: 'RAGHU', - lastName: 'MAURYA REDDY NIMMAKHAYALA', - correlationId: 'b9b77aaa-852d-4ca6-98cb-a562d3a5cc4a', - }, - { - firstName: 'YAMINI', - lastName: 'MIGLANI', - correlationId: '6018e57c-d351-408e-a45d-4e99236015d4', - }, - { - firstName: 'AMIT', - lastName: 'PRAVIN SONI', - correlationId: '6120f7ff-b561-480c-a8ff-5a1c1f7a6062', - }, - { - firstName: 'POOJA', - lastName: 'SAMEER VERAGIWALA', - correlationId: 'ca467ed8-d6e5-490b-88a8-dba5a299ee13', - }, - { - firstName: 'NADIR', - lastName: 'DENNAKA', - correlationId: '9d514596-1d19-474d-a4c8-0f26ecb24f48', - }, - { - firstName: 'DAN', - lastName: 'XUE', - correlationId: '815a5ed5-59c9-47dd-915f-25c045d29d07', - }, - { - firstName: 'ANDRE', - lastName: 'ABOUZEID', - correlationId: 'd524f534-277d-4648-bbf5-ee211a63b1c4', - }, - { - firstName: 'LEE', - lastName: 'CHONG HAN', - correlationId: '43038349-88b0-4b39-be80-71d924adf821', - }, - { - firstName: 'ALVINA KHOO', - lastName: 'LEA ING', - correlationId: 'c7053fe3-aa81-47ea-b83d-14ac3b30a25c', - }, - { - firstName: 'TAN', - lastName: 'SHU YI', - correlationId: '9848251a-35ae-4bba-b172-ddbcdddde264', - }, - { - firstName: 'HUNG', - lastName: 'CHI KWAN', - correlationId: '6faba1da-1755-4028-b936-a7f1d17fd652', - }, - { - firstName: 'ONG', - lastName: 'KHENG LEE', - correlationId: '8808685b-07c1-4d94-b52b-5fc9eb7561dd', - }, - { - firstName: 'RANJIT', - lastName: 'SINGH GURMAIJ SINGH', - correlationId: '5d9b0919-121d-47d5-8a42-b9c3e618f3eb', - }, - { - firstName: 'PADBIDRI', - lastName: 'ROSHAN', - correlationId: '237e4f23-3abb-45af-9d70-7de6d4b62b99', - }, - { - firstName: 'DANIEL LIM', - lastName: 'BIN SANI', - correlationId: 'cb06bacc-de2d-4066-8c4b-38496833f48b', - }, - { - firstName: 'CHANG', - lastName: 'GUANG HUI', - correlationId: '3d556dbd-b82c-451b-b929-cdd398f85d5a', - }, - { - firstName: 'MANISH', - lastName: 'GVALANI', - correlationId: 'aa3a0bad-e57b-44a8-a77a-5979f5a4d17b', - }, - { - firstName: 'SIBASISH', - lastName: 'MOHANTY', - correlationId: '9ace45fb-befb-4fb4-8b69-e2018fdc676a', - }, - { - firstName: 'SURENDER', - lastName: 'SINGH', - correlationId: '62ef56dc-2b55-45ef-a87c-87ebbcfbea17', - }, - { - firstName: 'UMITA', - lastName: 'DIGVIJAY SINGH', - correlationId: '19de73f2-460f-48bb-96b8-f70accb4c118', - }, - { - firstName: 'PURNA', - lastName: 'NAGA CHIRANJEEVI REDDY PADALA', - correlationId: '3f046e23-8e28-4ec5-acc3-589d50cabe3e', - }, - { - firstName: 'ZHANG', - lastName: 'YINGCHAO', - correlationId: 'ede352b7-6f1b-4d57-b5c3-d30c5798f708', - }, - { - firstName: 'WONG', - lastName: 'DERIC VALIANT TIEW HIANG', - correlationId: 'e95f8987-2642-457e-9c29-bdc0505a6f72', - }, - { - firstName: 'POH', - lastName: 'AMANDA YUN SIEW', - correlationId: 'c9a8ee35-6d29-4dda-8340-91ed766d6a35', - }, - { - firstName: 'CHIANG', - lastName: 'MICHELLE SUET YEE', - correlationId: '890cb4b4-1f67-4446-91ff-de59ad5f4513', - }, - { - firstName: 'Muhammad', - lastName: 'Nasir bin Johari', - correlationId: '31e6eccf-b177-44f5-aafb-de463c04fcf5', - }, - { - firstName: 'MADRASAH', - lastName: 'IRSYAD ZUHRI AL-ISLAMIAH', - correlationId: '7e88e219-43f4-4892-b119-7c95a899122b', - }, - { - firstName: 'HE', - lastName: 'ZuoZhou', - correlationId: '8b189ecb-9fe5-43ed-aa83-29caf7309ca4', - }, - { - firstName: 'CONNIE ANG', - lastName: 'KO LI', - correlationId: '9b71d837-afc5-4056-b080-86a735789d42', - }, - { - firstName: 'CHEW', - lastName: 'BOON CHUN', - correlationId: '54172f48-4f14-4f4d-84bf-72e450cf154f', - }, - { - firstName: 'LEON', - lastName: 'PAUL LUKE', - correlationId: '76467319-b7fd-4e32-8558-8ffe13190d54', - }, - { - firstName: 'ADAM', - lastName: 'SAKINAH BINTE NUR', - correlationId: '78e5137c-eab6-467a-a9e5-54cb44ff6e34', - }, - { - firstName: 'SITI', - lastName: 'JULIANA BINTE MOHAMED RUSLAN HADI', - correlationId: '0ac45782-17a7-4c69-82e6-c38bc5ff3864', - }, - { - firstName: 'FELICIA', - lastName: 'YUEQING TEO', - correlationId: '5706cc2d-77b9-4ed5-8ab2-7f51b41cfc69', - }, - { - firstName: 'GRAZ', - lastName: 'RENE HOFER', - correlationId: '368d6a97-30f2-4b1e-9e8d-4dd5d3090cb4', - }, - { - firstName: 'LUKAS', - lastName: 'HOCHTL', - correlationId: 'c056d79a-2047-45ce-b89e-b00422b0cf8b', - }, - { - firstName: 'VOLKAN', - lastName: 'SARPKAYA', - correlationId: 'f868b535-8e38-431e-8372-5482629e992c', - }, - { - firstName: 'WILFREDO', - lastName: 'NAVARRO MARTINEZ', - correlationId: '184ca76c-5739-4ece-aea4-f8431623b47d', - }, - { - firstName: 'ARJUN', - lastName: 'CHOUDHARY', - correlationId: '1216bc61-dce3-44e7-b937-47c839aa856e', - }, - { - firstName: 'EDWIN ONG', - lastName: 'YUGUI', - correlationId: '36366764-29c6-480d-ba5b-56837b53e489', - }, - { - firstName: 'ELIRAN', - lastName: 'ASSA', - correlationId: 'f2991617-a9f9-4e9e-9a76-afe0a809cc4c', - }, - { - firstName: 'MIKE TAN', - lastName: 'WEE HONG', - correlationId: '057461b8-e234-43f3-a3df-502eac4f1205', - }, - { - firstName: 'FONG', - lastName: 'KHONG LAI', - correlationId: 'ed468fb7-100c-46c2-93e0-6da61c0dc1cc', - }, - { - firstName: 'KANG', - lastName: 'HAK KHIAM', - correlationId: 'e6164151-3582-4c2b-874d-88c2735b6e8b', - }, - { - firstName: 'YEO', - lastName: 'Beng Chew', - correlationId: '24de5c68-d3f0-47da-8924-e4518f38001f', - }, - { - firstName: 'SOH', - lastName: 'JOSHUA', - correlationId: 'e064b7c0-a49f-4d08-aaa0-a6840511afe8', - }, - { - firstName: 'RUDIGER', - lastName: 'TRAUTMANN', - correlationId: '62f3ba8d-f730-4364-b3f1-40967488ae86', - }, - { - firstName: 'SARAVANAN', - lastName: 'PREETHI', - correlationId: 'b639e90e-9f9b-4228-957a-502c946bae48', - }, - { - firstName: 'Zhang', - lastName: 'Wan Yuan', - correlationId: '8701ef5b-aba6-40ac-93dc-ecc84f116eb0', - }, - { - firstName: 'ALKAN', - lastName: 'KARA', - correlationId: '55d7901d-1a76-4586-a9a4-7f0eef32cfc9', - }, - { - firstName: 'LEE', - lastName: 'SHU WENG', - correlationId: 'ec7346ec-f620-45dc-85c8-235f6002a1cb', - }, - { - firstName: 'WONG', - lastName: 'KWAN HUI', - correlationId: 'b401b9ef-1b3a-4235-b5d1-e2dd21339ba5', - }, - { - firstName: 'CHONG', - lastName: 'ZHENGLONG', - correlationId: '6c786a61-2a43-467f-8815-1356868b59e6', - }, - { - firstName: 'NESLIHAN', - lastName: 'KARAARSLAN', - correlationId: 'e7775d30-8b3e-48ab-9ccb-d117441b9262', - }, - { - firstName: 'CHOO', - lastName: 'VEHKEN', - correlationId: '94a20b01-9c54-41ed-a9a1-30f00c62a576', - }, - { - firstName: 'CHIN', - lastName: 'DEREK CHEESENG', - correlationId: '54091ee7-13d9-459a-8d69-2fd316052171', - }, - { - firstName: 'CARAMELLA', - lastName: 'DATUK MARCO RONALDO MARIO', - correlationId: 'e847841d-682f-42b6-a511-0547db62433c', - }, - { - firstName: 'STEVEN', - lastName: 'BORLEY', - correlationId: '52a2335d-2d8d-4b36-a73b-5dac7e143a57', - }, - { - firstName: 'BYUNGDOO', - lastName: 'YOU', - correlationId: '682cd85d-7db4-4243-b3fd-0df67c7e61bc', - }, - { - firstName: 'WANG', - lastName: 'QIBO', - correlationId: 'c9e157d3-8b64-478f-b747-0eff63c471f5', - }, -]; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - const oxpayProjectId = 'oxpay_default'; - let endUsers: EndUser[] = []; - - await client.$transaction( - async transaction => { - await Promise.all( - ubos.map(async ubo => { - await transaction.endUser.create({ - data: { - firstName: ubo.firstName, - lastName: ubo.lastName, - correlationId: ubo.correlationId, - approvalState: ApprovalState.APPROVED, - project: { - connect: { - id: oxpayProjectId, - }, - }, - }, - }); - }), - ); - - endUsers = await transaction.endUser.findMany({ - where: { - projectId: oxpayProjectId, - correlationId: { - in: ubos.map(({ correlationId }) => correlationId), - }, - }, - }); - - logger.log( - 'Created end users: ', - endUsers.map(({ id }) => id), - ); - }, - { - timeout: 300_000, - maxWait: 300_000, - }, - ); - - const axiosClient = axios.create(); - axiosRetry(axiosClient, { - retries: 10, - retryDelay: axiosRetry.exponentialDelay, - }); - - const sleep = (time: number) => new Promise(resolve => setTimeout(resolve, time)); - - const amlSessions = await Promise.allSettled( - endUsers.map(async endUser => { - const response = await axiosClient.post( - `${env.UNIFIED_API_URL}/aml-sessions`, - { - endUserId: endUser.id, - firstName: endUser.firstName, - lastName: endUser.lastName, - callbackUrl: `${env.APP_API_URL}/api/v1/webhooks/individual/aml`, - ongoingMonitoring: true, - vendor: 'veriff', - }, - { - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${env.UNIFIED_API_TOKEN}`, - }, - }, - ); - - await sleep(100); - - return [response.data, endUser] as const; - }), - ); - - await client.$transaction( - async transaction => { - for (const result of amlSessions) { - if (result.status === 'rejected') { - logger.error('Failed to create AML session', { - reason: result.reason, - }); - - return; - } - - const [response, endUser] = result.value; - - await transaction.endUser.update({ - where: { - id: endUser.id, - }, - data: { - activeMonitorings: [ - ...(endUser.activeMonitorings as any[]), - { - type: 'aml', - vendor: 'veriff', - monitoredUntil: new Date( - new Date().setFullYear(new Date().getFullYear() + 3), - ).toISOString(), - sessionId: response.id, - }, - ] satisfies z.infer, - }, - }); - } - }, - { - timeout: 300_000, - maxWait: 300_000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20231128180946_create_fido_ln16.ts b/services/workflows-service/prisma/data-migrations/sb/20231128180946_create_fido_ln16.ts deleted file mode 100644 index 870704ef2a..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20231128180946_create_fido_ln16.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { createLn16ForCustomer } from '../templates'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await createLn16ForCustomer(client, app, 'fido'); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20231213130258_add_variants_to_filters.ts b/services/workflows-service/prisma/data-migrations/sb/20231213130258_add_variants_to_filters.ts deleted file mode 100644 index 46c235b461..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20231213130258_add_variants_to_filters.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { baseFilterDefinitionSelect } from '../../../scripts/filters'; -import { fetchCustomerProject } from '../shared/fetch-customer-project'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const fidoProject = await fetchCustomerProject(transaction, 'fido'); - const clipspayProjects = await fetchCustomerProject(transaction, 'clipspay'); - const yunheProjects = await fetchCustomerProject(transaction, 'yunhe'); - - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: fidoProject } } }, - data: { variant: 'MANUAL_REVIEW' }, - }); - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: clipspayProjects } } }, - data: { - variant: 'DEFAULT', - }, - }); - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: yunheProjects } } }, - data: { variant: 'DEFAULT' }, - }); - - const allFilters = await transaction.filter.findMany({}); - - for (const filter of allFilters) { - const query = filter.query as { - select: { workflowDefinition: Record }; - }; - query.select.workflowDefinition = { - ...baseFilterDefinitionSelect['workflowDefinition'], - }; - - await transaction.filter.update({ - where: { id: filter.id }, - data: { query }, - }); - } - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240110121829_update_clipspay_workflow_definition.ts b/services/workflows-service/prisma/data-migrations/sb/20240110121829_update_clipspay_workflow_definition.ts deleted file mode 100644 index 1a69295225..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240110121829_update_clipspay_workflow_definition.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as clipspayMigration from '../common/20231217173250_update_clipspay_definition'; - -export const migrate = clipspayMigration.migrate; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240128173936_case_overview_enabled.ts b/services/workflows-service/prisma/data-migrations/sb/20240128173936_case_overview_enabled.ts deleted file mode 100644 index dde4653b43..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240128173936_case_overview_enabled.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as updateClipspayMigration from './20240110121829_update_clipspay_workflow_definition'; - -export const migrate = updateClipspayMigration.migrate; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240205104840_ballerine_qa_user.ts b/services/workflows-service/prisma/data-migrations/sb/20240205104840_ballerine_qa_user.ts deleted file mode 100644 index 8dc02e406b..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240205104840_ballerine_qa_user.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { BallerineQATemplate } from 'prisma/data-migrations/templates/creation/ballerine-qa'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new BallerineQATemplate(app, transaction, { - definition: { - id: 'kyb_w_ubos_ballerine', - name: 'kyb_w_ubos_ballerine', - }, - user: { - firstName: 'ballerine', - lastName: 'Admin', - email: 'admin@ballerine.com', - password: ' ', - }, - customer: { - name: 'ballerine', - displayName: 'ballerine', - apiKey: 'ballerine_secret', - logoImageUrl: '', - }, - project: { - id: 'ballerine_default', - }, - filter: { - name: 'Clipspay KYB', - }, - }); - - await template.generateClipspayProject(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240219165145_oxpay_initial.ts b/services/workflows-service/prisma/data-migrations/sb/20240219165145_oxpay_initial.ts deleted file mode 100644 index 36b8d47afe..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240219165145_oxpay_initial.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { OxpayTemplate } from 'prisma/data-migrations/templates/creation/oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new OxpayTemplate(app, transaction, { - definition: { - id: 'kyb_w_ubos_oxpay', - name: 'kyb_w_ubos_oxpay', - }, - user: { - firstName: 'OxPay', - lastName: 'Admin', - email: 'admin@oxpayfinancial.com', - password: 'oxpaypass', - }, - customer: { - name: 'oxpay', - displayName: 'OxPay', - apiKey: 'oxpay_secret', - logoImageUrl: 'https://cdn.ballerine.io/images/oxpay_logo_opt.svg', - faviconImageUri: 'https://cdn.ballerine.io/images/oxpay_logo_xs.png', - }, - project: { - id: 'oxpay_default', - }, - filter: { - name: 'Merchants KYB', - }, - }); - - await template.generate(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240222150821_update_oxpay_auth_details.ts b/services/workflows-service/prisma/data-migrations/sb/20240222150821_update_oxpay_auth_details.ts deleted file mode 100644 index 24836813cc..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240222150821_update_oxpay_auth_details.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { PrismaClient } from '@prisma/client'; - -export const migrate = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - const customer = await transaction.customer.findFirst({ - where: { - name: { - contains: 'oxpay', - }, - }, - select: { - id: true, - authenticationConfiguration: true, - }, - }); - - if ( - !customer?.authenticationConfiguration || - typeof customer.authenticationConfiguration !== 'object' - ) { - return; - } - - const newAuthenticationConfiguration = { - ...customer.authenticationConfiguration, - authValue: 'Oxpay-ZT7CJSiUsaFYq7xGQiSBk', - webhookSharedSecret: 'Oxpay-2LnkYwvYnm7MODlJDbTgi', - }; - - await transaction.customer.update({ - where: { - id: customer.id, - }, - data: { - authenticationConfiguration: newAuthenticationConfiguration, - }, - }); - }, - { - timeout: 25000, - maxWait: 25000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240222190921_update_oxpay_ui_schema.ts b/services/workflows-service/prisma/data-migrations/sb/20240222190921_update_oxpay_ui_schema.ts deleted file mode 100644 index 43ae006c31..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240222190921_update_oxpay_ui_schema.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { composeUiDefinition } from '../templates/creation/oxpay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; - -export const migrate = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - const currentUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: 'kyb_w_ubos_oxpay', - }, - select: { - id: true, - }, - }); - - if (!currentUiDefinition) { - return; - } - - const updatedOxpayUiDefinition = composeUiDefinition( - 'kyb_w_ubos_oxpay', - generateDefinitionLogic('kyb_w_ubos_oxpay'), - ); - - return transaction.uiDefinition.update({ - where: { - id: currentUiDefinition.id, - }, - data: { - uiSchema: updatedOxpayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240225161500_update_oxpay_ui_schema_2.ts b/services/workflows-service/prisma/data-migrations/sb/20240225161500_update_oxpay_ui_schema_2.ts deleted file mode 100644 index 1419d0c71f..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240225161500_update_oxpay_ui_schema_2.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateOxPayUiSchema } from '../shared/update-oxpay-ui-schema'; - -export const migrate = updateOxPayUiSchema; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240226185638_oxpay_in_progress_plugins.ts b/services/workflows-service/prisma/data-migrations/sb/20240226185638_oxpay_in_progress_plugins.ts deleted file mode 100644 index fda4a5656d..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240226185638_oxpay_in_progress_plugins.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinition } from '../templates/creation/oxpay/workflow-definition/workflow-definition'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - const oxpayWorkflowDefinition = generateWorkflowDefinition( - oxpayDefinitionName, - oxpayDefinitionName, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - extensions: oxpayWorkflowDefinition.extensions, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240226185650_clipspay_in_progress_plugins.ts b/services/workflows-service/prisma/data-migrations/sb/20240226185650_clipspay_in_progress_plugins.ts deleted file mode 100644 index ed28b92a7f..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240226185650_clipspay_in_progress_plugins.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -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 clipspayProjectIds = await fetchCustomerProjectIds(transaction, 'clipspay'); - const clipspayWorkflowDefinition = generateWorkflowDefinition( - clipspayDefinitionName, - clipspayDefinitionName, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: clipspayProjectIds }, - name: clipspayDefinitionName, - }, - data: { - extensions: clipspayWorkflowDefinition.extensions, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240228120858_update_workflows_to_stop_relying_on_post_event_execution.ts b/services/workflows-service/prisma/data-migrations/sb/20240228120858_update_workflows_to_stop_relying_on_post_event_execution.ts deleted file mode 100644 index ff775beb6e..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240228120858_update_workflows_to_stop_relying_on_post_event_execution.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { PrismaClient, Prisma } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { createWorkflow } from '@ballerine/workflow-core'; - -type Definition = Parameters[0]['definition']; -const TASK_REVIEWED_EVENT = [ - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'approved']) == length(documents)", - }, - }, - target: 'approved', - }, - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'rejected']) > `0`", - }, - }, - target: 'rejected', - }, - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'revision']) > `0`", - }, - }, - target: 'revision', - }, -]; -const RETURN_TO_REVIEW_EVENT = { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: 'length(documents[?decision.status]) < length(documents)', - }, - }, -}; -const workflowDefinitionsToUpdate: { - [id: string]: Definition; -} = { - fido_biz_ghana: { - id: 'fido_biz_ghana', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - fido_biz_uganda: { - id: 'fido_biz_uganda', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'risk-score-improvement-uganda': { - id: 'risk-score-improvement-uganda', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { tags: ['revision'], type: 'final' }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'risk-score-improvement-dev': { - id: 'risk-score-improvement', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { tags: ['revision'], type: 'final' }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'fido-l16-business-ghana': { - id: 'fido-l16-business-ghana-v1', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, -}; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - for (const [id, definition] of Object.entries(workflowDefinitionsToUpdate)) { - await transaction.workflowDefinition.updateMany({ - where: { id }, - data: { - definition: definition as Prisma.InputJsonValue, - }, - }); - } - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240229165135_fido_context_schema_update.ts b/services/workflows-service/prisma/data-migrations/sb/20240229165135_fido_context_schema_update.ts deleted file mode 100644 index 9351eae3db..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240229165135_fido_context_schema_update.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { defaultContextSchema } from '@ballerine/common'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const fidoProjectIds = await fetchCustomerProjectIds(transaction, 'fido'); - - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: fidoProjectIds } } }, - data: { - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240304130258_update_workflows_to_stop_relying_on_post_event_execution.ts b/services/workflows-service/prisma/data-migrations/sb/20240304130258_update_workflows_to_stop_relying_on_post_event_execution.ts deleted file mode 100644 index ff775beb6e..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240304130258_update_workflows_to_stop_relying_on_post_event_execution.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { PrismaClient, Prisma } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { createWorkflow } from '@ballerine/workflow-core'; - -type Definition = Parameters[0]['definition']; -const TASK_REVIEWED_EVENT = [ - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'approved']) == length(documents)", - }, - }, - target: 'approved', - }, - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'rejected']) > `0`", - }, - }, - target: 'rejected', - }, - { - cond: { - type: 'jmespath', - options: { - rule: "length(documents[?decision.status]) == length(documents) && length(documents) > `0` && length(documents[?decision.status == 'revision']) > `0`", - }, - }, - target: 'revision', - }, -]; -const RETURN_TO_REVIEW_EVENT = { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: 'length(documents[?decision.status]) < length(documents)', - }, - }, -}; -const workflowDefinitionsToUpdate: { - [id: string]: Definition; -} = { - fido_biz_ghana: { - id: 'fido_biz_ghana', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - fido_biz_uganda: { - id: 'fido_biz_uganda', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'risk-score-improvement-uganda': { - id: 'risk-score-improvement-uganda', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { tags: ['revision'], type: 'final' }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'risk-score-improvement-dev': { - id: 'risk-score-improvement', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { tags: ['revision'], type: 'final' }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, - 'fido-l16-business-ghana': { - id: 'fido-l16-business-ghana-v1', - states: { - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - resolved: { tags: ['resolved'], type: 'final' }, - revision: { - on: { - RETURN_TO_REVIEW: 'manual_review', - }, - always: RETURN_TO_REVIEW_EVENT, - tags: ['revision'], - }, - manual_review: { - on: { - TASK_REVIEWED: TASK_REVIEWED_EVENT, - }, - always: TASK_REVIEWED_EVENT, - tags: ['manual_review'], - }, - }, - initial: 'manual_review', - }, -}; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - for (const [id, definition] of Object.entries(workflowDefinitionsToUpdate)) { - await transaction.workflowDefinition.updateMany({ - where: { id }, - data: { - definition: definition as Prisma.InputJsonValue, - }, - }); - } - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240304141000_update_oxpay_customer_config_with_ongoing_workflow.ts b/services/workflows-service/prisma/data-migrations/sb/20240304141000_update_oxpay_customer_config_with_ongoing_workflow.ts deleted file mode 100644 index 3fcf794660..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240304141000_update_oxpay_customer_config_with_ongoing_workflow.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { generateOngoingWorkflowDefinition } from '../templates/creation/oxpay/workflow-definition/ongoing-workflow-definition'; -import { - ONGOING_MONITORING_FILTER_NAME, - ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - OXPAY_PROJECT_ID, -} from '../shared/consts'; -import { generateIndividualsFilter } from '../templates/filters/generate-individuals-filter'; - -export const migrate = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - await transaction.customer.update({ - where: { name: 'oxpay' }, - data: { - config: { - ongoingWorkflowDefinitionId: 'ongoing_monitoring_oxpay', - }, - }, - }); - - const ongoingWorkflowDefinition = generateOngoingWorkflowDefinition( - ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - OXPAY_PROJECT_ID, - ); - - await transaction.workflowDefinition.create({ - data: ongoingWorkflowDefinition, - }); - - const ongoingFilter = generateIndividualsFilter({ - filterName: ONGOING_MONITORING_FILTER_NAME, - definitionId: ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - projectId: OXPAY_PROJECT_ID, - }); - - await transaction.filter.create({ - data: ongoingFilter, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240305143700_clipspay_bad_translation_fix.ts b/services/workflows-service/prisma/data-migrations/sb/20240305143700_clipspay_bad_translation_fix.ts deleted file mode 100644 index 4544a069aa..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240305143700_clipspay_bad_translation_fix.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -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, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const clipspayProjectIds = await fetchCustomerProjectIds(transaction, 'clipspay'); - - const clipspayUiDefinition = composeUiDefinition( - clipspayDefinitionName, - generateDefinitionLogic(clipspayDefinitionName), - ); - - await transaction.uiDefinition.updateMany({ - where: { - projectId: { in: clipspayProjectIds }, - }, - data: clipspayUiDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240307144404_clipspay_child_omit_fix.ts b/services/workflows-service/prisma/data-migrations/sb/20240307144404_clipspay_child_omit_fix.ts deleted file mode 100644 index 2c43269f44..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240307144404_clipspay_child_omit_fix.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -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 clipspayProjectIds = await fetchCustomerProjectIds(transaction, 'clipspay'); - - const newClipspayWorkflow = generateWorkflowDefinition( - clipspayDefinitionName, - clipspayDefinitionName, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: clipspayProjectIds }, - name: clipspayDefinitionName, - }, - data: { - extensions: newClipspayWorkflow.extensions, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240307144535_oxpay_associated_definition.ts b/services/workflows-service/prisma/data-migrations/sb/20240307144535_oxpay_associated_definition.ts deleted file mode 100644 index 5f01d07010..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240307144535_oxpay_associated_definition.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { composeChildAssociatedCompanyDefinition } from '../templates/creation/child-associated-company/definition/compose-child-associated-company-definition'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - const childAssociatedCompanyDefinition = composeChildAssociatedCompanyDefinition({ - definitionId: `oxpay_child_associated_company`, - definitionName: `oxpay_child_associated_company`, - projectId: oxpayProjectIds[0]!, - }); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - childAssociatedCompanyDefinition.id, - ); - - await transaction.workflowDefinition.create({ - data: childAssociatedCompanyDefinition, - }); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: oxpayWorkflowDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240307144658_oxpay_is_associated_kyb_enabled.ts b/services/workflows-service/prisma/data-migrations/sb/20240307144658_oxpay_is_associated_kyb_enabled.ts deleted file mode 100644 index f2b92f1e32..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240307144658_oxpay_is_associated_kyb_enabled.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { isObject } from '@ballerine/common'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const workflowDefinition = await transaction.workflowDefinition.findFirstOrThrow({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - }); - const config = { - ...(isObject(workflowDefinition.config) ? workflowDefinition.config : {}), - isAssociatedCompanyKybEnabled: false, - } satisfies Parameters[0]['data']['config']; - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - config, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240307144724_oxpay_inprogress_process_fix.ts b/services/workflows-service/prisma/data-migrations/sb/20240307144724_oxpay_inprogress_process_fix.ts deleted file mode 100644 index c753826a20..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240307144724_oxpay_inprogress_process_fix.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { composeChildAssociatedCompanyDefinition } from '../templates/creation/child-associated-company/definition/compose-child-associated-company-definition'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const childAssociatedCompanyDefinition = composeChildAssociatedCompanyDefinition({ - definitionId: `oxpay_child_associated_company`, - definitionName: `oxpay_child_associated_company`, - projectId: oxpayProjectIds[0]!, - }); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - childAssociatedCompanyDefinition.id, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - extensions: oxpayWorkflowDefinition.extensions, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240310125143_fido_context_schema_update.ts b/services/workflows-service/prisma/data-migrations/sb/20240310125143_fido_context_schema_update.ts deleted file mode 100644 index 9351eae3db..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240310125143_fido_context_schema_update.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { defaultContextSchema } from '@ballerine/common'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const fidoProjectIds = await fetchCustomerProjectIds(transaction, 'fido'); - - await transaction.workflowDefinition.updateMany({ - where: { project: { id: { in: fidoProjectIds } } }, - data: { - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240311112400_oxpay_associated_companies_docs_fix.ts b/services/workflows-service/prisma/data-migrations/sb/20240311112400_oxpay_associated_companies_docs_fix.ts deleted file mode 100644 index 8f1f905658..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240311112400_oxpay_associated_companies_docs_fix.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; -import { composeUiDefinition } from '../templates/creation/oxpay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const assosciatedCompanyWorkflowDefinition = await transaction.workflowDefinition.findFirst({ - where: { - projectId: { in: oxpayProjectIds }, - name: 'oxpay_child_associated_company', - }, - select: { - id: true, - }, - }); - - if (!assosciatedCompanyWorkflowDefinition) { - return; - } - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - assosciatedCompanyWorkflowDefinition.id, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - extensions: oxpayWorkflowDefinition.extensions, - }, - }); - - const updatedOxpayUiDefinition = composeUiDefinition( - oxpayDefinitionName, - generateDefinitionLogic(oxpayDefinitionName), - ); - - const currentUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: oxpayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentUiDefinition) { - return; - } - - await transaction.uiDefinition.update({ - where: { - id: currentUiDefinition.id, - }, - data: { - uiSchema: updatedOxpayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240311154425_update_oxpay_account_holder.ts b/services/workflows-service/prisma/data-migrations/sb/20240311154425_update_oxpay_account_holder.ts deleted file mode 100644 index 1419d0c71f..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240311154425_update_oxpay_account_holder.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateOxPayUiSchema } from '../shared/update-oxpay-ui-schema'; - -export const migrate = updateOxPayUiSchema; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240311154711_clipspay_business_type_length.ts b/services/workflows-service/prisma/data-migrations/sb/20240311154711_clipspay_business_type_length.ts deleted file mode 100644 index a5b95c33ab..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240311154711_clipspay_business_type_length.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateClipspayUiSchema } from '../shared/update-clipspay-ui-schema'; - -export const migrate = updateClipspayUiSchema; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240311180000_definition_update_for_oxpay_and_clipspay.ts b/services/workflows-service/prisma/data-migrations/sb/20240311180000_definition_update_for_oxpay_and_clipspay.ts deleted file mode 100644 index b8e8ea5d46..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240311180000_definition_update_for_oxpay_and_clipspay.ts +++ /dev/null @@ -1,131 +0,0 @@ -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { composeUiDefinition as composeOxpayUiDefinition } from 'prisma/data-migrations/templates/creation/oxpay/collection-flow/compose-ui-definition'; -import { composeUiDefinition as composeClipspayUiDefinition } from '../templates/creation/clipspay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic as generateClipspayDefinitionLogic } from '../templates/creation/clipspay/collection-flow/generate-definition-logic'; -import { generateWorkflowDefinition } from '../templates/creation/clipspay/workflow-definition/workflow-definition'; -import { generateDefinitionLogic as generateOxpayDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; -const clipspayDefinitionName = 'kyb_dynamic_ui_session_example'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - // OxPay - - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const assosciatedCompanyWorkflowDefinition = await transaction.workflowDefinition.findFirst({ - where: { - projectId: { in: oxpayProjectIds }, - name: 'oxpay_child_associated_company', - }, - select: { - id: true, - }, - }); - - if (!assosciatedCompanyWorkflowDefinition) { - throw new Error('Associated Company Workflow Definition not found'); - } - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - assosciatedCompanyWorkflowDefinition.id, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - extensions: oxpayWorkflowDefinition.extensions, - }, - }); - - const currentOxpayUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: oxpayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentOxpayUiDefinition) { - throw new Error('Oxpay UI Definition not found'); - } - - const updatedOxpayUiDefinition = composeOxpayUiDefinition( - oxpayDefinitionName, - generateOxpayDefinitionLogic(oxpayDefinitionName), - ); - - await transaction.uiDefinition.update({ - where: { - id: currentOxpayUiDefinition.id, - }, - data: { - uiSchema: updatedOxpayUiDefinition.uiSchema, - }, - }); - - // ClipsPay - - const clipspayProjectIds = await fetchCustomerProjectIds(transaction, 'clipspay'); - - const clipspayWorkflowDefinition = generateWorkflowDefinition( - clipspayDefinitionName, - clipspayDefinitionName, - clipspayProjectIds[0]!, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: clipspayProjectIds }, - name: clipspayDefinitionName, - }, - data: { - extensions: clipspayWorkflowDefinition.extensions, - }, - }); - - const currentClipspayUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: clipspayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentClipspayUiDefinition) { - throw new Error('Clipspay UI Definition not found'); - } - - const updatedClipspayUiDefinition = composeClipspayUiDefinition( - clipspayDefinitionName, - generateClipspayDefinitionLogic(clipspayDefinitionName), - ); - - await transaction.uiDefinition.update({ - where: { - id: currentClipspayUiDefinition.id, - }, - data: { - uiSchema: updatedClipspayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240312124500_fix_oxpay_ui_definition.ts b/services/workflows-service/prisma/data-migrations/sb/20240312124500_fix_oxpay_ui_definition.ts deleted file mode 100644 index dc31a21a85..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240312124500_fix_oxpay_ui_definition.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { composeUiDefinition } from '../templates/creation/oxpay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const currentOxpayUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: oxpayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentOxpayUiDefinition) { - throw new Error('Oxpay UI Definition not found'); - } - - const updatedOxpayUiDefinition = composeUiDefinition( - oxpayDefinitionName, - generateDefinitionLogic(oxpayDefinitionName), - ); - - await transaction.uiDefinition.update({ - where: { - id: currentOxpayUiDefinition.id, - }, - data: { - uiSchema: updatedOxpayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240313134332_oxpay_update_ui_definition.ts b/services/workflows-service/prisma/data-migrations/sb/20240313134332_oxpay_update_ui_definition.ts deleted file mode 100644 index 252e7c30ad..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240313134332_oxpay_update_ui_definition.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateOxpayUiDefinition } from '../shared/update-oxpay-ui-definition'; - -export const migrate = updateOxpayUiDefinition; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240313135707_clipspay_update_ui_definition.ts b/services/workflows-service/prisma/data-migrations/sb/20240313135707_clipspay_update_ui_definition.ts deleted file mode 100644 index 7f8dc721df..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240313135707_clipspay_update_ui_definition.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { updateClipspayUiDefinition } from '../shared/update-clipspay-ui-definition'; - -export const migrate = updateClipspayUiDefinition; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240314112305_create_demo_ballerine_definition_and_ui_definition.ts b/services/workflows-service/prisma/data-migrations/sb/20240314112305_create_demo_ballerine_definition_and_ui_definition.ts deleted file mode 100644 index 7a57a44f6f..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240314112305_create_demo_ballerine_definition_and_ui_definition.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { DemoTemplate } from '../templates/creation/ballerine-demo'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction(async transaction => { - const template = new DemoTemplate(app, transaction, { - customer: { - id: 'ballerinedemo', - displayName: 'Ballerine Demo', - name: 'ballerinedemo', - logoImageUrl: '', - apiKey: 'demo_secret', - }, - user: { - firstName: 'Noam', - lastName: 'Izhaki', - email: 'noam@ballerine.com', - password: 'noampass', - }, - project: { - id: 'ballerine-demo-project', - }, - filter: { - name: 'KYB', - }, - }); - - await template.generate(); - }); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240314113547_update_oxpay_and_clipspay_definition.ts b/services/workflows-service/prisma/data-migrations/sb/20240314113547_update_oxpay_and_clipspay_definition.ts deleted file mode 100644 index 645cd9eee8..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240314113547_update_oxpay_and_clipspay_definition.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { updateClipspayUiDefinition } from '../shared/update-clipspay-ui-definition'; -import { updateOxpayUiDefinition } from '../shared/update-oxpay-ui-definition'; -import { migrate as migrateCLipsAndOx } from './20240311180000_definition_update_for_oxpay_and_clipspay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - await migrateCLipsAndOx(client, app); - await updateClipspayUiDefinition(client); - await updateOxpayUiDefinition(client); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240314181305_oxpay_definition_display_name.ts b/services/workflows-service/prisma/data-migrations/sb/20240314181305_oxpay_definition_display_name.ts deleted file mode 100644 index 2f9579ba30..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240314181305_oxpay_definition_display_name.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: { - displayName: 'KYB', - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240314181354_clipspay_definition_display_name.ts b/services/workflows-service/prisma/data-migrations/sb/20240314181354_clipspay_definition_display_name.ts deleted file mode 100644 index ec45bae5e4..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240314181354_clipspay_definition_display_name.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; - -const clipspayDefinitionName = 'kyb_dynamic_ui_session_example'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const clipspayProjectIds = await fetchCustomerProjectIds(transaction, 'clipspay'); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: clipspayProjectIds }, - name: clipspayDefinitionName, - }, - data: { - displayName: 'KYB', - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240314190319_definition_update_fix.ts b/services/workflows-service/prisma/data-migrations/sb/20240314190319_definition_update_fix.ts deleted file mode 100644 index 157a4650fd..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240314190319_definition_update_fix.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { updateClipspayUiDefinition } from '../shared/update-clipspay-ui-definition'; -import { updateOxpayUiDefinition } from '../shared/update-oxpay-ui-definition'; -import { migrate as migrateCLipsAndOx } from './20240311180000_definition_update_for_oxpay_and_clipspay'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - await migrateCLipsAndOx(client, app); - await updateClipspayUiDefinition(client); - await updateOxpayUiDefinition(client); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240316204058_oxpay_alert_definitions_v2.ts b/services/workflows-service/prisma/data-migrations/sb/20240316204058_oxpay_alert_definitions_v2.ts deleted file mode 100644 index d5432f610a..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240316204058_oxpay_alert_definitions_v2.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { generateAlertDefinitions } from '../../../scripts/alerts/generate-alerts'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const project = await transaction.project.findFirstOrThrow({ - where: { - customer: { - name: 'oxpay', - }, - }, - }); - - await generateAlertDefinitions(transaction, { - project, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240415104851_update_fido_workflow_definition_config.ts b/services/workflows-service/prisma/data-migrations/sb/20240415104851_update_fido_workflow_definition_config.ts deleted file mode 100644 index 9e94a4065c..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240415104851_update_fido_workflow_definition_config.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { getFidoWorkflowDefinition } from 'prisma/data-migrations/templates/creation/create-ln16-for-customer'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const customer = await transaction.customer.findFirstOrThrow({ - where: { - name: 'fido', - }, - select: { - id: true, - projects: true, - }, - }); - - const projectId = customer.projects.map(project => project.id)[0]!; - - await transaction.workflowDefinition.update({ - where: { - id: 'fido-l16-business-ghana', - }, - data: { - config: getFidoWorkflowDefinition(projectId).config, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240417162838_fido_remain_old_ui.ts b/services/workflows-service/prisma/data-migrations/sb/20240417162838_fido_remain_old_ui.ts deleted file mode 100644 index 22fe876aa4..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240417162838_fido_remain_old_ui.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { isObject } from '@ballerine/common'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const workflows = await transaction.workflowDefinition.findMany({ - where: { - id: { - in: [ - 'fido_biz_ghana', - 'fido_biz_uganda', - 'risk-score-improvement-uganda', - 'risk-score-improvement-dev', - 'fido-l16-business-ghana', - ], - }, - }, - }); - - for (const workflow of workflows) { - const existingConfig = isObject(workflow.config) ? workflow.config : {}; - - await transaction.workflowDefinition.update({ - where: { - id: workflow.id, - }, - data: { - config: { - ...existingConfig, - theme: { - type: 'documents-review', - }, - }, - }, - }); - } - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240425170230_oxpay_definition_update.ts b/services/workflows-service/prisma/data-migrations/sb/20240425170230_oxpay_definition_update.ts deleted file mode 100644 index c0d71cf54a..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240425170230_oxpay_definition_update.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; -const associatedCompanyWorkflowDefinitionId = 'oxpay_child_associated_company'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - associatedCompanyWorkflowDefinitionId, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: oxpayWorkflowDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240430162030_oxpay_definition_update.ts b/services/workflows-service/prisma/data-migrations/sb/20240430162030_oxpay_definition_update.ts deleted file mode 100644 index c0d71cf54a..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240430162030_oxpay_definition_update.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { fetchCustomerProjectIds } from '../utils/fetch-customer-project-ids'; -import { generateWorkflowDefinitionWithAssociated } from '../templates/creation/oxpay/workflow-definition/workflow-definition-with-associated'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; -const associatedCompanyWorkflowDefinitionId = 'oxpay_child_associated_company'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const oxpayProjectIds = await fetchCustomerProjectIds(transaction, 'oxpay'); - - const oxpayWorkflowDefinition = generateWorkflowDefinitionWithAssociated( - oxpayDefinitionName, - oxpayDefinitionName, - oxpayProjectIds[0]!, - associatedCompanyWorkflowDefinitionId, - ); - - await transaction.workflowDefinition.updateMany({ - where: { - projectId: { in: oxpayProjectIds }, - name: oxpayDefinitionName, - }, - data: oxpayWorkflowDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240519174200_ongoing_monitoring_demo_init.ts b/services/workflows-service/prisma/data-migrations/sb/20240519174200_ongoing_monitoring_demo_init.ts deleted file mode 100644 index e3285b6618..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240519174200_ongoing_monitoring_demo_init.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { DemoOngoingMonitoringTemplate } from '../templates/creation/ballerine-ongoing-monitoring-demo'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new DemoOngoingMonitoringTemplate(app, transaction, { - customer: { - id: 'ballerinedemo_ongoing_monitoring', - displayName: 'Ballerine Demo', - name: 'ballerinedemo_ongoing_monitoring', - logoImageUrl: '', - apiKey: 'ballerinedemo_ongoing_monitoring_secret', - }, - user: { - firstName: 'Noam', - lastName: 'Izhaki', - email: 'noam-izhaki@ballerine.com', - password: 'noampass', - }, - project: { - id: 'ballerine_demo_ongoing_monitoring_project', - }, - // Not used in this template - filter: { - name: 'KYB', - }, - }); - - await template.generate(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240519175055_ongoing_monitoring_demo_init_bridgecard.ts b/services/workflows-service/prisma/data-migrations/sb/20240519175055_ongoing_monitoring_demo_init_bridgecard.ts deleted file mode 100644 index cfff1232cf..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240519175055_ongoing_monitoring_demo_init_bridgecard.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { DemoOngoingMonitoringTemplate } from '../templates/creation/ballerine-ongoing-monitoring-demo'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new DemoOngoingMonitoringTemplate(app, transaction, { - customer: { - id: 'ballerinedemo_ongoing_monitoring_bridgecard', - displayName: 'Bridgecard Demo', - name: 'ballerinedemo_ongoing_monitoring_bridgecard', - logoImageUrl: '', - apiKey: 'ballerinedemo_ongoing_monitoring_bridgecard_secret', - }, - user: { - firstName: 'Festus', - lastName: 'Bridgecard', - email: 'festus@bridgecard.co', - password: 'kpq5cgb?GKM-cqb1cyj', - }, - project: { - id: 'ballerine_demo_ongoing_monitoring_bridgecard_project', - }, - // Not used in this template - filter: { - name: 'KYB', - }, - }); - - await template.generate(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/sb/20240519175121_ongoing_monitoring_demo_init_wolfpack.ts b/services/workflows-service/prisma/data-migrations/sb/20240519175121_ongoing_monitoring_demo_init_wolfpack.ts deleted file mode 100644 index 9e4a9455b6..0000000000 --- a/services/workflows-service/prisma/data-migrations/sb/20240519175121_ongoing_monitoring_demo_init_wolfpack.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { INestApplicationContext } from '@nestjs/common'; -import { DemoOngoingMonitoringTemplate } from '../templates/creation/ballerine-ongoing-monitoring-demo'; - -export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { - await client.$transaction( - async transaction => { - const template = new DemoOngoingMonitoringTemplate(app, transaction, { - customer: { - id: 'ballerinedemo_ongoing_monitoring_wolfpack', - displayName: 'Wolfpack Demo', - name: 'ballerinedemo_ongoing_monitoring_wolfpack', - logoImageUrl: '', - apiKey: 'ballerinedemo_ongoing_monitoring_wolfpack_secret', - }, - user: { - firstName: 'Benny', - lastName: 'Wolfpack', - email: 'benny@wolfpackdd.com', - password: 'qpk6cgb!GKM-cqb1cjy', - }, - project: { - id: 'ballerine_demo_ongoing_monitoring_wolfpack_project', - }, - // Not used in this template - filter: { - name: 'KYB', - }, - }); - - await template.generate(); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/shared/consts.ts b/services/workflows-service/prisma/data-migrations/shared/consts.ts deleted file mode 100644 index de1d9fce6e..0000000000 --- a/services/workflows-service/prisma/data-migrations/shared/consts.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const OXPAY_PROJECT_ID = 'oxpay_default'; - -export const OXPAY_WORKFLOW_DEFINITION_ID = 'kyb_w_ubos_oxpay'; - -export const ONGOING_MONITORING_FILTER_NAME = 'Ongoing Monitoring'; - -export const ONGOING_MONITORING_WORKFLOW_DEFINITION_ID = 'ongoing_monitoring_oxpay'; diff --git a/services/workflows-service/prisma/data-migrations/shared/create-onging-monitoring-workflow-definition.ts b/services/workflows-service/prisma/data-migrations/shared/create-onging-monitoring-workflow-definition.ts deleted file mode 100644 index 64638d16ed..0000000000 --- a/services/workflows-service/prisma/data-migrations/shared/create-onging-monitoring-workflow-definition.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { generateOngoingWorkflowDefinition } from '../templates/creation/oxpay/workflow-definition/ongoing-workflow-definition'; -import { ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, OXPAY_PROJECT_ID } from './consts'; - -export const createOngoingMonitoringWorkflowDefinition = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - const ongoingWorkflowDefinition = generateOngoingWorkflowDefinition( - ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - OXPAY_PROJECT_ID, - ); - - await transaction.workflowDefinition.create({ - data: ongoingWorkflowDefinition, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/shared/create-ongoing-monitoring-filter.ts b/services/workflows-service/prisma/data-migrations/shared/create-ongoing-monitoring-filter.ts deleted file mode 100644 index b0c699f3e6..0000000000 --- a/services/workflows-service/prisma/data-migrations/shared/create-ongoing-monitoring-filter.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { generateIndividualsFilter } from '../templates/filters/generate-individuals-filter'; -import { - ONGOING_MONITORING_FILTER_NAME, - ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - OXPAY_PROJECT_ID, -} from './consts'; - -export const createOngoingMonitoringFilter = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - const ongoingFilter = generateIndividualsFilter({ - filterName: ONGOING_MONITORING_FILTER_NAME, - definitionId: ONGOING_MONITORING_WORKFLOW_DEFINITION_ID, - projectId: OXPAY_PROJECT_ID, - }); - - await transaction.filter.create({ - data: ongoingFilter, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/shared/fetch-customer-project.ts b/services/workflows-service/prisma/data-migrations/shared/fetch-customer-project.ts deleted file mode 100644 index c5530dc6ed..0000000000 --- a/services/workflows-service/prisma/data-migrations/shared/fetch-customer-project.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { PrismaTransactionClient } from '@/types'; -import { PrismaClient } from '@prisma/client'; - -export const fetchCustomerProject = async ( - transaction: PrismaTransactionClient | PrismaClient, - customerName: string, -) => { - return ( - ( - await transaction.customer.findFirst({ - where: { name: customerName }, - select: { projects: true }, - }) - )?.projects?.map(project => project.id) || [] - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/shared/shared.idle.schema.ts b/services/workflows-service/prisma/data-migrations/shared/shared.idle.schema.ts deleted file mode 100644 index bd589ac6a7..0000000000 --- a/services/workflows-service/prisma/data-migrations/shared/shared.idle.schema.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { Type } from '@sinclair/typebox'; - -const sharedEntityUISchema = { - id: { - 'ui:title': 'Entity ID (As represented in your system)', - }, - type: { - hidden: true, - }, - data: { - 'ui:label': false, - companyName: { - 'ui:title': 'Company Name', - }, - additionalInfo: { - 'ui:label': false, - mainRepresentative: { - 'ui:label': false, - 'ui:order': ['email', 'firstName', 'lastName'], - email: { - 'ui:title': 'Email', - }, - firstName: { - 'ui:title': 'First Name', - }, - lastName: { - 'ui:title': 'Last Name', - }, - }, - }, - }, -}; - -export const sharedEntitySchema = Type.Object({ - id: Type.String(), - type: Type.String({ default: 'business' }), - data: Type.Object({ - companyName: Type.String(), - additionalInfo: Type.Object({ - mainRepresentative: Type.Object({ - firstName: Type.String(), - lastName: Type.String(), - email: Type.String({ format: 'email' }), - }), - }), - }), -}); - -export const sharedInputSchema = { - dataSchema: sharedEntitySchema, - uiSchema: sharedEntityUISchema, -}; diff --git a/services/workflows-service/prisma/data-migrations/shared/update-clipspay-ui-definition.ts b/services/workflows-service/prisma/data-migrations/shared/update-clipspay-ui-definition.ts deleted file mode 100644 index 0e9aa49b39..0000000000 --- a/services/workflows-service/prisma/data-migrations/shared/update-clipspay-ui-definition.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { generateDefinitionLogic } from '../templates/creation/clipspay/collection-flow/generate-definition-logic'; - -const clipspayDefinitionName = 'kyb_dynamic_ui_session_example'; - -export const updateClipspayUiDefinition = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - const currentClipspayUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: clipspayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentClipspayUiDefinition) { - throw new Error('Clipspay UI Definition not found'); - } - - await transaction.uiDefinition.update({ - where: { - id: currentClipspayUiDefinition.id, - }, - data: { - definition: generateDefinitionLogic(clipspayDefinitionName), - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/shared/update-clipspay-ui-schema.ts b/services/workflows-service/prisma/data-migrations/shared/update-clipspay-ui-schema.ts deleted file mode 100644 index c49230273f..0000000000 --- a/services/workflows-service/prisma/data-migrations/shared/update-clipspay-ui-schema.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { composeUiDefinition } from '../templates/creation/clipspay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from '../templates/creation/clipspay/collection-flow/generate-definition-logic'; - -const WORKFLOW_DEFINITION_ID = 'kyb_dynamic_ui_session_example'; - -export const updateClipspayUiSchema = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - const currentUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: WORKFLOW_DEFINITION_ID, - }, - select: { - id: true, - }, - }); - - if (!currentUiDefinition) { - return; - } - - const updatedClipspayUiDefinition = composeUiDefinition( - WORKFLOW_DEFINITION_ID, - generateDefinitionLogic(WORKFLOW_DEFINITION_ID), - ); - - return transaction.uiDefinition.update({ - where: { - id: currentUiDefinition.id, - }, - data: { - uiSchema: updatedClipspayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/shared/update-oxpay-ui-definition.ts b/services/workflows-service/prisma/data-migrations/shared/update-oxpay-ui-definition.ts deleted file mode 100644 index aa2f14efda..0000000000 --- a/services/workflows-service/prisma/data-migrations/shared/update-oxpay-ui-definition.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { generateDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; - -const oxpayDefinitionName = 'kyb_w_ubos_oxpay'; - -export const updateOxpayUiDefinition = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - const currentOxpayUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: oxpayDefinitionName, - }, - select: { - id: true, - }, - }); - - if (!currentOxpayUiDefinition) { - throw new Error('Oxpay UI Definition not found'); - } - - await transaction.uiDefinition.update({ - where: { - id: currentOxpayUiDefinition.id, - }, - data: { - definition: generateDefinitionLogic(oxpayDefinitionName), - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/shared/update-oxpay-ui-schema.ts b/services/workflows-service/prisma/data-migrations/shared/update-oxpay-ui-schema.ts deleted file mode 100644 index 0d96720c69..0000000000 --- a/services/workflows-service/prisma/data-migrations/shared/update-oxpay-ui-schema.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { composeUiDefinition } from '../templates/creation/oxpay/collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from '../templates/creation/oxpay/collection-flow/generate-definition-logic'; - -const WORKFLOW_DEFINITION_ID = 'kyb_w_ubos_oxpay'; - -export const updateOxPayUiSchema = async (client: PrismaClient) => { - await client.$transaction( - async transaction => { - const currentUiDefinition = await transaction.uiDefinition.findFirst({ - where: { - workflowDefinitionId: WORKFLOW_DEFINITION_ID, - }, - select: { - id: true, - }, - }); - - if (!currentUiDefinition) { - return; - } - - const updatedOxpayUiDefinition = composeUiDefinition( - WORKFLOW_DEFINITION_ID, - generateDefinitionLogic(WORKFLOW_DEFINITION_ID), - ); - - return transaction.uiDefinition.update({ - where: { - id: currentUiDefinition.id, - }, - data: { - uiSchema: updatedOxpayUiDefinition.uiSchema, - }, - }); - }, - { - timeout: 15000, - maxWait: 15000, - }, - ); -}; diff --git a/services/workflows-service/prisma/data-migrations/shared/workflow-definition-with-associated.ts b/services/workflows-service/prisma/data-migrations/shared/workflow-definition-with-associated.ts deleted file mode 100644 index 97c34d19c0..0000000000 --- a/services/workflows-service/prisma/data-migrations/shared/workflow-definition-with-associated.ts +++ /dev/null @@ -1,580 +0,0 @@ -import { env } from '@/env'; -import { defaultContextSchema, StateTag } from '@ballerine/common'; -import { kycEmailSessionDefinition } from 'prisma/data-migrations/templates/creation/common/generate-kyc-email-process'; -import { - BUSINESS_UBO_AND_SANCTIONS_DONE, - CHILD_KYB_DONE_RULE, - KYC_DONE_RULE, - kycAndVendorDone, -} from 'prisma/data-migrations/templates/utils/rules'; -import { sharedInputSchema } from './shared.idle.schema'; -import { - createPluginAsyncResponseTransform, - createPluginSyncOrAsyncResponseTransform, - createPluginSyncResponseTransform, -} from '../utils/create-plugin-response-mapping'; - -export const generateWorkflowDefinitionWithAssociated = ({ - id, - name, - kybChildWorkflowDefinitionId, - crossEnvKey, - projectId, -}: { - id: string; - name: string; - kybChildWorkflowDefinitionId: string; - crossEnvKey?: string; - projectId?: string; -}) => { - const noAssociatedCompaniesRule = `entity.data.additionalInfo.associatedCompanies == null || length(entity.data.additionalInfo.associatedCompanies) == \`0\``; - const noAssociatedCompaniesInProcessRule = `entity.childWorkflows.${kybChildWorkflowDefinitionId} == null || length(entity.data.additionalInfo.${kybChildWorkflowDefinitionId}) == \`0\``; - - return { - id, - name, - crossEnvKey, - version: 1, - definitionType: 'statechart-json', - definition: { - id: `${id}_v1`, - predictableActionArguments: true, - initial: 'idle', - context: { - documents: [], - }, - states: { - idle: { - on: { - START: 'collection_invite', - }, - meta: { - inputSchema: sharedInputSchema, - }, - }, - collection_invite: { - on: { - INVIATION_SENT: 'collection_flow', - INVIATION_FAILURE: 'failed', - }, - }, - collection_flow: { - tags: [StateTag.COLLECTION_FLOW], - on: { - COLLECTION_FLOW_FINISHED: [ - { - // target: 'run_merchant_monitoring', - target: 'run_ubos', - cond: { - type: 'jmespath', - options: { - rule: noAssociatedCompaniesRule, - }, - }, - }, - { target: 'generate_associated_companies' }, - ], - }, - }, - // run_merchant_monitoring: { - // tags: [StateTag.PENDING_PROCESS], - // on: { - // MERCHANT_MONITORING_SUCCESS: 'run_ubos', - // MERCHANT_MONITORING_FAILED: 'failed', - // }, - // }, - generate_associated_companies: { - tags: [StateTag.COLLECTION_FLOW], - on: { - ASSOCIATED_COMPANIES_GENERATED: [{ target: 'run_ubos' }], - ASSOCIATED_COMPANIES_FAILED: [{ target: 'failed' }], - }, - }, - run_ubos: { - tags: [StateTag.COLLECTION_FLOW], - on: { - EMAIL_SENT_TO_UBOS: [{ target: 'run_vendor_data' }], - FAILED_EMAIL_SENT_TO_UBOS: [{ target: 'failed' }], - }, - }, - run_vendor_data: { - tags: [StateTag.DATA_ENRICHMENT], - on: { - KYC_RESPONDED: [kycAndVendorDone], - VENDOR_DONE: [ - { - target: 'pending_kyc_response_to_finish', - cond: { - type: 'jmespath', - options: { - rule: `!(${KYC_DONE_RULE()}) && ${BUSINESS_UBO_AND_SANCTIONS_DONE}`, - }, - }, - }, - kycAndVendorDone, - ], - VENDOR_FAILED: 'failed', - }, - }, - pending_kyc_response_to_finish: { - tags: [StateTag.PENDING_PROCESS], - on: { - KYC_RESPONDED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE()} && - (${noAssociatedCompaniesRule} || ${noAssociatedCompaniesInProcessRule}) || - (${CHILD_KYB_DONE_RULE(kybChildWorkflowDefinitionId)})`, - }, - }, - }, - { - target: 'pending_kyb_response_to_finish', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE()} && - !(${noAssociatedCompaniesRule}) && !(${CHILD_KYB_DONE_RULE( - kybChildWorkflowDefinitionId, - )})`, - }, - }, - }, - ], - reject: 'rejected', - revision: 'pending_resubmission', - }, - }, - pending_kyb_response_to_finish: { - tags: [StateTag.COLLECTION_FLOW], - on: { - ASSOCIATED_COMPANY_KYB_FINISHED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: CHILD_KYB_DONE_RULE(kybChildWorkflowDefinitionId), - }, - }, - }, - ], - reject: 'rejected', - revision: 'pending_resubmission', - }, - }, - manual_review: { - tags: [StateTag.MANUAL_REVIEW], - on: { - approve: 'approved', - reject: 'rejected', - revision: 'pending_resubmission', - KYC_REVISION: 'pending_kyc_response_to_finish', - }, - }, - pending_resubmission: { - tags: [StateTag.REVISION], - on: { - EMAIL_SENT: 'revision', - EMAIL_FAILURE: 'failed', - }, - }, - failed: { - tags: [StateTag.FAILURE], - type: 'final' as const, - }, - approved: { - tags: [StateTag.APPROVED], - type: 'final' as const, - }, - revision: { - tags: [StateTag.REVISION], - on: { - COLLECTION_FLOW_FINISHED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE()} && - (${noAssociatedCompaniesRule} || ${noAssociatedCompaniesInProcessRule}) && - (${CHILD_KYB_DONE_RULE(kybChildWorkflowDefinitionId)})`, - }, - }, - }, - { - target: 'pending_kyc_response_to_finish', - cond: { - type: 'jmespath', - options: { - rule: `!${KYC_DONE_RULE()} && - (${noAssociatedCompaniesRule} || ${noAssociatedCompaniesInProcessRule}) && - (${CHILD_KYB_DONE_RULE(kybChildWorkflowDefinitionId)})`, - }, - }, - }, - ], - }, - }, - rejected: { - tags: [StateTag.REJECTED], - type: 'final' as const, - }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'collection_invite_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - successAction: 'INVIATION_SENT', - errorAction: 'INVIATION_FAILURE', - method: 'POST', - stateNames: ['collection_invite'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - customerName: metadata.customerName, - collectionFlowUrl: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token,'&lng=',workflowRuntimeConfig.language]), - from: 'no-reply@ballerine.com', - receivers: [entity.data.additionalInfo.mainRepresentative.email], - language: workflowRuntimeConfig.language, - templateId: 'd-8949519316074e03909042cfc5eb4f02', - adapter: '{secret.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - { - name: 'kyb', - displayName: 'Registry Verification', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies-v2/{entity.data.country}/{entity.data.registrationNumber}`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.businessInformation', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `merge( - { vendor: 'asia-verify' }, - entity.data.country == 'HK' && { - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.businessInformation.data&processName=kyb-unified-api']) - } - )`, // jmespath - }, - ], - }, - response: { - transform: createPluginSyncOrAsyncResponseTransform('kyb', "jurisdictionCode == 'HK'"), - }, - }, - { - name: 'company_sanctions', - displayName: 'Company Sanctions', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies/{entity.data.country}/{entity.data.companyName}/sanctions`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.companySanctions', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - vendor: 'asia-verify' - }`, // jmespath - }, - ], - }, - response: { - transform: createPluginSyncResponseTransform('company_sanctions'), - }, - }, - { - name: 'ubo', - displayName: 'UBO Check', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies/{entity.data.country}/{entity.data.registrationNumber}/ubo`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.ubo', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - vendor: 'asia-verify', - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.ubo.data&processName=ubo-unified-api']) - }`, // jmespath - }, - ], - }, - response: { - transform: createPluginAsyncResponseTransform('ubo'), - }, - }, - { - name: 'resubmission_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - method: 'POST', - successAction: 'EMAIL_SENT', - errorAction: 'EMAIL_FAILURE', - stateNames: ['pending_resubmission'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - // #TODO: create new token (new using old one) - mapping: `{ - kybCompanyName: entity.data.companyName, - customerCompanyName: metadata.customerName, - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - resubmissionLink: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token,'&lng=',workflowRuntimeConfig.language]), - supportEmail: join('',['support@',metadata.customerName,'.com']), - from: 'no-reply@ballerine.com', - name: join(' ',[metadata.customerName,'Team']), - receivers: [entity.data.additionalInfo.mainRepresentative.email], - templateId: 'd-7305991b3e5840f9a14feec767ea7301', - revisionReason: documents[].decision[].revisionReason | [0], - language: workflowRuntimeConfig.language, - adapter: '${env.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - // { - // name: 'merchant_monitoring', - // pluginKind: 'api', - // url: `{secret.UNIFIED_API_URL}/tld/reports`, - // method: 'POST', - // stateNames: ['run_merchant_monitoring'], - // successAction: 'MERCHANT_MONITORING_SUCCESS', - // errorAction: 'MERCHANT_MONITORING_FAILED', - // headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - // request: { - // transform: [ - // { - // transformer: 'jmespath', - // mapping: `{ - // websiteUrl: entity.data.additionalInfo.store.website.mainWebsite, - // companyName: entity.data.companyName, - // reportType: 'MERCHANT_REPORT_T1', - // callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=entity.report&processName=website-monitoring']) - // }`, // jmespath - // }, - // ], - // }, - // response: { - // transform: [ - // { - // transformer: 'jmespath', - // mapping: '@', // jmespath - // }, - // ], - // }, - // }, - ], - childWorkflowPlugins: [ - { - pluginKind: 'child', - name: 'veriff_kyc_child_plugin', - definitionId: kycEmailSessionDefinition().id, - transformers: [ - { - transformer: 'jmespath', - mapping: `{entity: {data: @, type: 'individual'}}`, - }, - { - transformer: 'helper', - mapping: [ - { - source: 'entity.data', - target: 'entity.data', - method: 'omit', - value: ['workflowRuntimeId', 'workflowRuntimeConfig'], - }, - ], - }, - ], - initEvent: 'start', - }, - { - pluginKind: 'child', - name: 'associated_company_child_plugin', - definitionId: kybChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: `{entity: {data: @, type: 'business'}, documents: documents}`, - }, - { - transformer: 'helper', - mapping: [ - { - source: 'entity.data', - target: 'entity.data', - method: 'omit', - value: ['workflowRuntimeId', 'workflowRuntimeConfig', 'documents'], - }, - ], - }, - ], - }, - ], - commonPlugins: [ - { - pluginKind: 'iterative', - name: 'ubos_iterative', - actionPluginName: 'veriff_kyc_child_plugin', - stateNames: ['run_ubos'], - iterateOn: [ - { - transformer: 'jmespath', - mapping: 'entity.data.additionalInfo.ubos', - }, - ], - successAction: 'EMAIL_SENT_TO_UBOS', - errorAction: 'FAILED_EMAIL_SENT_TO_UBOS', - }, - { - pluginKind: 'iterative', - name: 'associated_company_iterative', - actionPluginName: 'associated_company_child_plugin', - stateNames: ['generate_associated_companies'], - iterateOn: [ - { - transformer: 'helper', - mapping: [ - { - source: 'entity.data.additionalInfo.associatedCompanies', - target: 'entity.data.additionalInfo.associatedCompanies', - method: 'mergeArrayEachItemWithValue', - options: { - mapJmespath: 'entity.data.additionalInfo.associatedCompanies', - mergeWithJmespath: - '{ additionalInfo: { customerName: metadata.customerName, kybCompanyName: entity.data.companyName } }', - }, - }, - ], - }, - { - transformer: 'jmespath', - mapping: 'entity.data.additionalInfo.associatedCompanies', - }, - ], - successAction: 'ASSOCIATED_COMPANIES_GENERATED', - errorAction: 'ASSOCIATED_COMPANIES_FAILED', - }, - ], - }, - config: { - language: 'en', - supportedLanguages: ['en', 'cn'], - initialEvent: 'START', - createCollectionFlowToken: true, - childCallbackResults: [ - { - definitionId: kycEmailSessionDefinition().name, - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - persistenceStates: ['kyc_manual_review'], - deliverEvent: 'KYC_RESPONDED', - }, - { - definitionId: kycEmailSessionDefinition().name, - persistenceStates: ['revision_email_sent'], - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - deliverEvent: 'KYC_REVISION', - }, - { - definitionId: kybChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: '{childEntity: entity.data}', // jmespath - }, - ], - persistenceStates: ['manual_review'], - deliverEvent: 'ASSOCIATED_COMPANY_KYB_FINISHED', - }, - { - definitionId: kybChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: '{childEntity: entity.data}', // jmespath - }, - ], - persistenceStates: ['pending_associated_kyb_collection_flow'], - deliverEvent: 'ASSOCIATED_COMPANY_IN_KYB', - }, - { - definitionId: kybChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: '{childEntity: entity.data}', // jmespath - }, - ], - persistenceStates: ['revision'], - deliverEvent: 'revision', - }, - ], - workflowLevelResolution: true, - enableManualCreation: true, - isCaseOverviewEnabled: true, - isAssociatedCompanyKybEnabled: true, - }, - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - isPublic: !projectId, - ...(projectId && { projectId }), - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/synced-objects/index.ts b/services/workflows-service/prisma/data-migrations/synced-objects/index.ts deleted file mode 100644 index 4f0134e2ae..0000000000 --- a/services/workflows-service/prisma/data-migrations/synced-objects/index.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { oxpayAlertDefinitions } from './oxpay/alert-definitions'; - -export const getSyncedObjects: () => any = () => { - return [ - { - crossEnvKey: 'kyb_with_associated_companies_example', - tableName: 'WorkflowDefinition', - columns: { - definition: { - id: 'kyb_with_associated_companies_example_v1', - states: { - failed: { - tags: ['failure'], - type: 'final', - on: { REJECT: 'rejected' }, - }, - approved: { tags: ['approved'], type: 'final' }, - rejected: { tags: ['rejected'], type: 'final' }, - revision: { - on: { - reject: 'rejected', - KYC_RESPONDED: [{ target: 'manual_review' }], - COLLECTION_FLOW_FINISHED: [{ target: 'manual_review' }], - ASSOCIATED_COMPANY_KYB_FINISHED: [{ target: 'manual_review' }], - }, - tags: ['revision'], - }, - manual_review: { - on: { - reject: 'rejected', - approve: 'approved', - revision: 'revision', - KYC_IN_PROGRESS: 'pending_kyc_response', - KYC_IN_REVISION: 'revision', - ASSOCIATED_COMPANY_IN_PROGRESS: 'pending_kyb_response', - ASSOCIATED_COMPANY_IN_REVISION: 'revision', - }, - tags: ['manual_review'], - }, - collection_flow: { - on: { - COLLECTION_FLOW_FINISHED: [{ target: 'create_kyc_workflows' }], - }, - tags: ['collection_flow'], - }, - create_kyb_workflows: { - on: { - ASSOCIATED_COMPANIES_FAILED: [{ target: 'failed' }], - ASSOCIATED_COMPANIES_CREATED: [{ target: 'manual_review' }], - }, - }, - create_kyc_workflows: { - on: { - KYC_FAILED: [{ target: 'failed' }], - KYC_CREATED: [{ target: 'create_kyb_workflows' }], - }, - }, - pending_kyb_response: { - on: { ASSOCIATED_COMPANY_KYB_FINISHED: 'manual_review' }, - tags: ['collection_flow'], - }, - pending_kyc_response: { - on: { KYC_RESPONDED: 'manual_review' }, - tags: ['pending_process'], - }, - }, - context: { documents: ['ddd'] }, - initial: 'collection_flow', - predictableActionArguments: false, - }, - }, - syncConfig: { - strategy: 'update', - }, - syncedEnvironments: ['local'], - dryRunEnvironments: [], - }, - ...oxpayAlertDefinitions, - ]; -}; diff --git a/services/workflows-service/prisma/data-migrations/synced-objects/oxpay/alert-definitions/index.ts b/services/workflows-service/prisma/data-migrations/synced-objects/oxpay/alert-definitions/index.ts deleted file mode 100644 index 01b49d7d8e..0000000000 --- a/services/workflows-service/prisma/data-migrations/synced-objects/oxpay/alert-definitions/index.ts +++ /dev/null @@ -1,96 +0,0 @@ -import { - ALERT_DEFINITIONS, - getAlertDefinitionCreateData, -} from './../../../../../scripts/alerts/generate-alerts'; -import { SyncedObject } from '@/data-migration/scripts/sync/sync'; -import { Project } from '@prisma/client'; - -export const oxpayAlertDefinitions: SyncedObject[] = [ - { - crossEnvKey: 'OXPAY_PAY_HCA_CC', - tableName: 'AlertDefinition', - columns: ALERT_DEFINITIONS.PAY_HCA_CC, - }, - { - crossEnvKey: 'OXPAY_PAY_HCA_APM', - tableName: 'AlertDefinition', - columns: ALERT_DEFINITIONS.PAY_HCA_APM, - }, - { - crossEnvKey: 'OXPAY_STRUC_CC', - tableName: 'AlertDefinition', - columns: ALERT_DEFINITIONS.STRUC_CC, - }, - { - crossEnvKey: 'OXPAY_STRUC_APM', - tableName: 'AlertDefinition', - columns: ALERT_DEFINITIONS.STRUC_APM, - }, - { - crossEnvKey: 'OXPAY_HCAI_CC', - tableName: 'AlertDefinition', - columns: ALERT_DEFINITIONS.HCAI_CC, - }, - { - crossEnvKey: 'OXPAY_HCAI_APM', - tableName: 'AlertDefinition', - columns: ALERT_DEFINITIONS.HACI_APM, - }, - { - crossEnvKey: 'OXPAY_PAY_HCA_CC', - tableName: 'AlertDefinition', - columns: ALERT_DEFINITIONS.PAY_HCA_CC, - }, - { - crossEnvKey: 'OXPAY_CHVC_C', - tableName: 'AlertDefinition', - columns: ALERT_DEFINITIONS.CHVC_C, - }, - { - crossEnvKey: 'OXPAY_SHCAC_C', - tableName: 'AlertDefinition', - columns: ALERT_DEFINITIONS.SHCAC_C, - }, - { - crossEnvKey: 'OXPAY_CHCR_C', - tableName: 'AlertDefinition', - columns: ALERT_DEFINITIONS.CHCR_C, - }, - { - crossEnvKey: 'OXPAY_SHCAR_C', - tableName: 'AlertDefinition', - columns: ALERT_DEFINITIONS.SHCAR_C, - }, - { - crossEnvKey: 'OXPAY_HPC', - tableName: 'AlertDefinition', - columns: ALERT_DEFINITIONS.HPC, - }, - { - crossEnvKey: 'OXPAY_TLHAICC', - tableName: 'AlertDefinition', - columns: ALERT_DEFINITIONS.TLHAICC, - }, - { - crossEnvKey: 'OXPAY_TLHAIAPM', - tableName: 'AlertDefinition', - columns: ALERT_DEFINITIONS.TLHAIAPM, - }, -] - .filter(alertDefinition => alertDefinition.columns.enabled) - .map(alertDefinition => { - return { - ...alertDefinition, - columns: getAlertDefinitionCreateData( - alertDefinition.columns, - { id: 'oxpay_default' } as Project, - 'SYSTEM', - { crossEnvKey: alertDefinition.crossEnvKey }, - ), - syncConfig: { - strategy: 'upsert', - }, - syncedEnvironments: ['local'], - dryRunEnvironments: ['local'], - } as SyncedObject; - }); diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/demo.template.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/demo.template.ts deleted file mode 100644 index 7c3f7c84a4..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/demo.template.ts +++ /dev/null @@ -1,124 +0,0 @@ -import { Template } from '../../template'; -import { DemoTemplateParams } from './types'; -import { PasswordService } from '@/auth/password/password.service'; -import { validateDefinitionLogic } from '@ballerine/workflow-core'; -import { composeDemoChildKycDefinition } from './workflow-definition/compose-demo-child-kyc-definition'; -import { composeUiDefinition } from './ui-definition/compose-ui-definition'; -import { generateBusinessesFilter } from '../../filters/generate-businesses-filter'; -import { generateWorkflowDefinition } from '../clipspay/workflow-definition/workflow-definition'; -import { CustomerService } from '@/customer/customer.service'; - -export class DemoTemplate extends Template { - async generate() { - const customer = await this.createCustomer(); - const user = await this.createUser(); - - const project = await this.createProject(user.id, customer.id); - - const demoKycChildDefinition = composeDemoChildKycDefinition( - `${customer.name}_demo_kyc_email_session`, - `${customer.name}_demo_kyc_email_session`, - project.id, - ); - - const demoKybDefinition = generateWorkflowDefinition( - `${customer.name}_demo_kyb`, - `${customer.name}_demo_kyb`, - project.id, - ); - - validateDefinitionLogic(demoKycChildDefinition); - await this.prismaClient.workflowDefinition.create({ - data: { - ...demoKycChildDefinition, - }, - }); - - validateDefinitionLogic(demoKybDefinition); - const workflowDefinition = await this.prismaClient.workflowDefinition.create({ - data: { - ...demoKybDefinition, - }, - }); - - await this.createUIDefinition(workflowDefinition.id, project.id); - - await this.createFilter(project.id, workflowDefinition.id); - - return Promise.resolve(); - } - - private async createCustomer() { - const { customer } = this.params; - const customerService = this.app.get(CustomerService); - - return customerService.create({ - data: { - id: customer.id, - displayName: customer.displayName, - name: customer.name, - authenticationConfiguration: { - apiType: 'API_KEY', - authValue: customer.apiKey, - validUntil: '', - isValid: '', - }, - logoImageUri: customer.logoImageUrl, - }, - }); - } - - private async createUser() { - const { user } = this.params; - - const passwordService = this.app.get(PasswordService); - - return this.prismaClient.user.create({ - data: { - firstName: user.firstName, - lastName: user.lastName, - email: user.email, - password: await passwordService.hash(user.password), - roles: ['user'], - }, - }); - } - - private createProject(userId: string, customerId: string) { - const { project } = this.params; - - return this.prismaClient.project.create({ - data: { - id: project.id, - name: project.id, - customerId, - userToProjects: { - create: { - userId, - }, - }, - }, - }); - } - - private async createUIDefinition(workflowDefinitionId: string, projectId: string) { - return this.prismaClient.uiDefinition.create({ - data: { - ...composeUiDefinition(workflowDefinitionId), - projectId, - }, - }); - } - - private async createFilter(projectId: string, definitionId: string) { - const baseQuery = generateBusinessesFilter({ - filterName: 'KYB (UBOs & Associated Companies)', - definitionId, - projectId, - }); - - return this.prismaClient.filter.create({ - data: baseQuery, - }); - } -} diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/index.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/index.ts deleted file mode 100644 index 0f4293a884..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './demo.template'; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/types.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/types.ts deleted file mode 100644 index 1f0e9da6a6..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/types.ts +++ /dev/null @@ -1,44 +0,0 @@ -interface DemoCustomer { - id: string; - displayName: string; - name: string; - apiKey: string; - logoImageUrl: string; -} - -interface DemoUser { - firstName: string; - lastName: string; - email: string; - password: string; -} - -interface DemoProject { - id: string; -} - -interface DemoFilter { - name: string; -} -interface DefinitionWithChildrenConfig { - parentKybDefinitionId: string; - kybDefinitionName: string; - childKycDefinitionId: string; - childKycDefinitionName: string; -} - -export interface DemoTemplateParams { - // Customer - customer: DemoCustomer; - - // User - user: DemoUser; - - // Project - project: DemoProject; - - // Filter - filter: DemoFilter; - - definitionWithChildren?: DefinitionWithChildrenConfig; -} diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/1-personal-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/1-personal-info-page.ts deleted file mode 100644 index bd0afeda44..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/1-personal-info-page.ts +++ /dev/null @@ -1,290 +0,0 @@ -const validationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['mainRepresentative', 'iHaveSigningAuthority'], - default: {}, - errorMessage: { - required: { - iHaveSigningAuthority: 'This field is required.', - }, - }, - properties: { - mainRepresentative: { - type: 'object', - required: ['phone', 'dateOfBirth', 'firstName', 'lastName', 'additionalInfo'], - errorMessage: { - required: { - phone: 'errorMessage.required.phone', - dateOfBirth: 'errorMessage.required.dateOfBirth', - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - }, - }, - properties: { - phone: { - type: 'string', - pattern: '^[+]?[0-9]{10,15}$', - errorMessage: { - pattern: 'errorMessage.pattern.phone', - }, - }, - dateOfBirth: { - type: 'string', - errorMessage: { - type: 'errorMessage.type.dateOfBirth', - }, - }, - firstName: { - type: 'string', - minLength: 2, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 2, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - }, - }, - additionalInfo: { - type: 'object', - required: ['jobTitle'], - default: {}, - errorMessage: { - required: { - jobTitle: 'errorMessage.required.jobTitle', - }, - }, - properties: { - jobTitle: { - type: 'string', - minLength: 2, - errorMessage: { - minLength: 'errorMessage.minLength.jobTitle', - }, - }, - }, - }, - }, - }, - iHaveSigningAuthority: { - type: 'boolean', - enum: [true], - errorMessage: { - enum: 'errorMessage.error.requiredField', - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -export const PersonalInfoPage = { - type: 'page', - name: 'text.personalInformation', - number: 1, - stateName: 'personal_details', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.personalInformation', - }, - }, - ], - }, - { - type: 'json-form', - valueDestination: 'entity.data.additionalInfo.mainRepresentative', - name: 'json-form:personal-information', - options: { - jsonFormDefinition: { - required: [ - 'first-name-input', - 'last-name-input', - 'job-title-input', - 'date-of-birth-input', - 'phone-number-input', - ], - }, - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - name: 'first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.firstName', - options: { - label: 'Name', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.lastName', - options: { - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'job-title-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.mainRepresentative.additionalInfo.jobTitle', - options: { - label: 'text.jobTitle.label', - hint: 'text.jobTitle.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'date-of-birth-input', - type: 'json-form:date', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.dateOfBirth', - options: { - label: 'text.dateOfBirth.label', - hint: 'DD/MM/YYYY', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - }, - }, - { - name: 'phone-number-input', - type: 'international-phone-number', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.phone', - options: { - label: 'text.phoneNumber', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'PhoneInput', - 'ui:label': true, - }, - }, - }, - { - name: 'authority-checkbox', - type: 'authority-checkbox', - valueDestination: 'entity.data.additionalInfo.iHaveSigningAuthority', - options: { - label: 'text.iHaveSigningAuthority.label', - jsonFormDefinition: { - type: 'boolean', - }, - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionPlugin', - params: { - pluginName: 'update_end_user', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/2-company-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/2-company-info-page.ts deleted file mode 100644 index b630116fd0..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/2-company-info-page.ts +++ /dev/null @@ -1,476 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: [ - 'additionalInfo', - 'businessType', - 'taxIdentificationNumber', - 'companyName', - 'country', - 'registrationNumber', - ], - properties: { - businessType: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.businessType', - maxLength: 'errorMessage.maxLength.businessType', - required: 'errorMessage.required.businessType', - }, - }, - taxIdentificationNumber: { - type: 'string', - minLength: 8, - maxLength: 15, - pattern: '^[^\\s]*$', - errorMessage: { - minLength: 'errorMessage.minLength.taxIdentificationNumber', - maxLength: 'errorMessage.maxLength.taxIdentificationNumber', - pattern: 'errorMessage.pattern.taxIdentificationNumber', - required: 'errorMessage.equired.taxIdentificationNumber', - }, - }, - companyName: { - type: 'string', - minLength: 2, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.companyName', - maxLength: 'errorMessage.maxLength.companyName', - required: 'errorMessage.required.companyName', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength.country', - pattern: 'errorMessage.pattern.country', - required: 'errorMessage.required.country', - }, - }, - registrationNumber: { - type: 'string', - minLength: 4, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.registrationNumber', - maxLength: 'errorMessage.maxLength.registrationNumber', - required: 'errorMessage.required.registrationNumber', - }, - }, - additionalInfo: { - type: 'object', - required: ['dateOfEstablishment'], - properties: { - dateOfEstablishment: { - type: 'string', - }, - }, - errorMessage: { - required: { - dateOfEstablishment: 'errorMessage.error.requiredField', - }, - }, - }, - }, - errorMessage: { - required: { - businessType: 'errorMessage.required.businessType', - numberOfEmployees: 'errorMessage.required.numberOfEmployees', - taxIdentificationNumber: 'errorMessage.required.taxIdentificationNumber', - companyName: 'errorMessage.required.companyName', - country: 'errorMessage.required.country', - registrationNumber: 'errorMessage.required.registrationNumber', - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const dispatchOpenCorporateRule = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - default: {}, - properties: { - data: { - type: 'object', - required: ['registrationNumber', 'country'], - default: {}, - properties: { - registrationNumber: { - type: 'string', - minLength: 6, - maxLength: 20, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - }, - additionalInfo: { - type: 'object', - properties: { - state: { - type: 'string', - minLength: 1, - }, - }, - }, - }, - if: { - properties: { - country: { - enum: ['AE', 'US', 'CA'], - }, - }, - }, - then: { - required: ['additionalInfo'], - properties: { - additionalInfo: { - required: ['state'], - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const stateVisiblityRule = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['country'], - default: {}, - properties: { - country: { - type: 'string', - enum: ['AE', 'US', 'CA'], - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const CompanyInfoPage = { - type: 'page', - number: 2, // routing number of page - stateName: 'company_information', // this is the route from xstate - name: 'text.companyInformation', // page name ( in stepper ) - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyInformation', - }, - }, - ], - }, - { - type: 'json-form', - name: 'business_info_form_p1', - options: { - jsonFormDefinition: { - required: ['registration-number-input', 'country-picker-input'], - }, - }, - elements: [ - { - name: 'registration-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.registrationNumber', - options: { - label: 'text.registrationNumber.label', - hint: 'text.registrationNumber.hint', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - }, - }, - { - name: 'country-picker-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.country', - options: { - label: 'text.registeredCountry.label', - hint: 'text.registeredCountry.hint', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.registeredCountry.placeholder', - }, - }, - }, - ], - }, - { - name: 'business_info_form_p2', - type: 'json-form', - options: { - jsonFormDefinition: { - required: ['business_info_state_input'], - }, - }, - visibleOn: [ - { - type: 'json-schema', - value: stateVisiblityRule, - }, - ], - elements: [ - { - name: 'business_info_state_input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.state', - options: { - label: 'text.state.label', - hint: 'text.state.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'StatePicker', - }, - countryCodePath: 'entity.data.country', - }, - }, - ], - }, - { - name: 'business_info_form_p3', - type: 'json-form', - options: { - jsonFormDefinition: { - required: [ - 'company-name-input', - 'tax-identification-number-input', - 'number-of-employees-input', - 'business-type-input', - 'registered-capital-in-yuan-type-input', - 'date-of-establishment-input', - ], - }, - }, - elements: [ - { - name: 'company-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.companyName', - options: { - label: 'text.legalName', - hint: 'OpenAI Technologies, Inc.', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - }, - }, - { - name: 'tax-identification-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.taxIdentificationNumber', - options: { - label: 'text.taxIdentificationNumber.label', - hint: 'text.taxIdentificationNumber.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'business-type-input', - type: 'json-form:dropdown', - valueDestination: 'entity.data.businessType', - options: { - hint: 'text.businessType.hint', - label: 'text.businessType.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'AutocompleteInput', - 'ui:label': true, - options: [ - { - title: 'text.businessType.options.sole_proprietorship', - const: 'sole_proprietorship', - }, - { - title: 'text.businessType.options.partnership', - const: 'partnership', - }, - { - title: 'text.businessType.options.corporation', - const: 'corporation', - }, - { - title: 'text.businessType.options.limited_liability_company', - const: 'limited_liability_company_(llc)', - }, - { - title: 'text.businessType.options.limited_partnership', - const: 'limited_partnership_(lp)', - }, - { - title: 'text.businessType.options.limited_liability_partnership', - const: 'limited_liability_partnership_(llp)', - }, - { - title: 'text.businessType.options.public_limited_company', - const: 'public_limited_company_(plc)', - }, - { - title: 'text.businessType.options.private_limited_company', - const: 'private_limited_company_(ltd)', - }, - { - title: 'text.businessType.options.non_profit_organization', - const: 'non-profit_organization', - }, - { - title: 'text.businessType.options.cooperative', - const: 'cooperative', - }, - { - title: 'text.businessType.options.trust', - const: 'trust', - }, - { - title: 'text.businessType.options.government', - const: 'government', - }, - { - title: 'text.businessType.options.other', - const: 'other', - }, - ], - }, - }, - }, - { - name: 'date-of-establishment-input', - type: 'json-form:date', - valueDestination: 'entity.data.additionalInfo.dateOfEstablishment', - options: { - label: 'text.established.label', - hint: 'DD/MM/YYYY', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionPlugin', - params: { pluginName: 'fetch_company_information', debounce: 700 }, - dispatchOn: { - uiEvents: [ - { event: 'onChange', uiElementName: 'registration-number-input' }, - { event: 'onChange', uiElementName: 'country-picker-input' }, - { event: 'onChange', uiElementName: 'business_info_state_input' }, - ], - rules: [ - { - type: 'json-schema', - value: dispatchOpenCorporateRule, - }, - ], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/3-business-address-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/3-business-address-info-page.ts deleted file mode 100644 index fa98c42350..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/3-business-address-info-page.ts +++ /dev/null @@ -1,262 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['headquarters'], - default: {}, - properties: { - headquarters: { - type: 'object', - default: {}, - required: ['street', 'streetNumber', 'city', 'country', 'postalCode', 'phone'], - errorMessage: { - required: { - street: 'errorMessage.required.street', - streetNumber: 'errorMessage.required.streetNumber', - city: 'errorMessage.required.city', - country: 'errorMessage.required.country', - postalCode: 'errorMessage.error.requiredField', - phone: 'errorMessage.error.requiredField', - }, - }, - properties: { - street: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.street', - maxLength: 'errorMessage.maxLength.street', - }, - }, - streetNumber: { - type: 'number', - minLength: 1, - maxLength: 10, - errorMessage: { - minLength: 'errorMessage.minLength.streetNumber', - maxLength: 'errorMessage.maxLength.streetNumber', - }, - }, - postalCode: { - type: 'string', - }, - city: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.city', - maxLength: 'errorMessage.maxLength.city', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength.country', - pattern: 'errorMessage.pattern.country', - }, - }, - phone: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const BusinessAddressInfoPage = { - type: 'page', - number: 3, - stateName: 'business_address_information', - name: 'text.headquartersAddress', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.headquartersAddress', - }, - }, - { - type: 'h3', - options: { - text: 'text.registeredAddress', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'business-address-info-page-form', - options: { - jsonFormDefinition: { - required: [ - 'street-input', - 'street-number-input', - 'postal-code-input', - 'city-input', - 'country-input', - 'headquarters-phone-number-input', - ], - }, - }, - elements: [ - { - name: 'street-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.street', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.street.label', - hint: 'text.street.hint', - }, - }, - { - name: 'street-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.streetNumber', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.number', - hint: '10', - }, - }, - { - name: 'postal-code-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.postalCode', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.postalCode', - hint: '10', - }, - }, - { - name: 'city-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.city', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.city.label', - hint: 'text.city.hint', - }, - }, - { - name: 'country-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.additionalInfo.headquarters.country', - options: { - label: 'text.country', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.choose', - }, - }, - }, - { - name: 'headquarters-phone-number-input', - type: 'international-phone-number', - valueDestination: 'entity.data.additionalInfo.headquarters.phone', - options: { - label: 'text.headquartersPhoneNumber.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'PhoneInput', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/4-company-activity.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/4-company-activity.ts deleted file mode 100644 index 9064c67661..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/4-company-activity.ts +++ /dev/null @@ -1,215 +0,0 @@ -import { singleUrlPattern } from '../../../utils/schema-utils/regex'; - -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - default: {}, - required: [ - 'industry', - 'businessModel', - 'companyWebsite', - 'annualVolume', - 'transactionValue', - ], - properties: { - industry: { - type: 'string', - }, - businessModel: { - type: 'string', - }, - companyWebsite: { - type: 'string', - pattern: singleUrlPattern, - errorMessage: { - pattern: 'errorMessage.pattern.companyWebsite', - }, - }, - annualVolume: { - type: 'number', - }, - transactionValue: { - type: 'number', - }, - }, - errorMessage: { - required: { - industry: 'errorMessage.required.industry', - businessModel: 'errorMessage.required.businessModel', - companyWebsite: 'errorMessage.required.companyWebsite', - annualVolume: 'errorMessage.error.requiredField', - transactionValue: 'errorMessage.error.requiredField', - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; -export const CompanyActivityPage = { - type: 'page', - number: 4, - stateName: 'company_activity', - name: 'text.companyActivity', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyActivity', - }, - }, - ], - }, - { - name: 'company-activity-inputs-group', - type: 'json-form', - options: { - jsonFormDefinition: { - required: [ - 'industry-input', - 'business-model-input', - 'company-website-input', - 'annual-volume-amount-input', - 'transaction-value-input', - ], - }, - }, - elements: [ - { - name: 'industry-input', - type: 'dropdown', - valueDestination: 'entity.data.additionalInfo.industry', - options: { - label: 'text.industryInput.label', - hint: 'text.industryInput.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'IndustriesPicker', - }, - }, - }, - { - name: 'business-model-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.businessModel', - options: { - label: 'text.businessModelInput.label', - hint: 'text.businessModelInput.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:widget': 'textarea', - }, - }, - }, - { - name: 'company-website-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.companyWebsite', - options: { - label: 'text.companyWebsiteInput.label', - hint: 'text.companyWebsiteInput.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'annual-volume-amount-input', - type: 'number-field', - valueDestination: 'entity.data.additionalInfo.annualVolume', - options: { - label: 'text.annualVolumeAmountInput.label', - hint: 'text.annualVolumeAmountInput.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'transaction-value-input', - type: 'number-field', - valueDestination: 'entity.data.additionalInfo.transactionValue', - options: { - label: 'text.averageTransactionValueInput.label', - hint: 'text.averageTransactionValueInput.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/5-bank-information.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/5-bank-information.ts deleted file mode 100644 index 1ac5dec36b..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/5-bank-information.ts +++ /dev/null @@ -1,217 +0,0 @@ -import { currencyCodes } from '../../../utils/schema-utils/currency-codes'; - -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - default: {}, - required: ['data'], - properties: { - data: { - type: 'object', - default: {}, - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['bankInformation'], - default: {}, - properties: { - bankInformation: { - type: 'object', - default: {}, - errorMessage: { - required: { - country: 'errorMessage.required.bankCountry', - name: 'errorMessage.required.bankName', - holderName: 'errorMessage.required.holderName', - accountNumber: 'errorMessage.required.accountNumber', - currencyCode: 'errorMessage.required.currency', - }, - }, - required: ['country', 'name', 'holderName', 'accountNumber', 'currencyCode'], - properties: { - country: { - type: 'string', - }, - name: { - type: 'string', - }, - holderName: { - type: 'string', - }, - accountNumber: { - type: 'string', - }, - currencyCode: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const BankInformationPage = { - type: 'page', - number: 5, - stateName: 'bank_information', - name: 'text.bankInformation', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.bankInformation', - }, - }, - ], - }, - { - type: 'json-form', - name: 'bank-information-form', - options: { - jsonFormDefinition: { - required: [ - 'bank-country-input', - 'bank-name-input', - 'account-holder-name-input', - 'account-number-input', - 'account-currency-input', - ], - }, - }, - elements: [ - { - name: 'bank-country-input', - type: 'dropdown', - valueDestination: 'entity.data.additionalInfo.bankInformation.country', - options: { - label: 'text.bankCountry.label', - hint: 'text.bankCountry.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - }, - }, - }, - { - name: 'bank-name-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.bankInformation.name', - options: { - label: 'text.bankName.label', - hint: 'text.bankName.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'account-holder-name-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.bankInformation.holderName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.accountHolderName.label', - hint: 'text.accountHolderName.hint', - }, - }, - { - name: 'account-number-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.bankInformation.accountNumber', - options: { - label: 'text.accountNumber.label', - hint: 'text.accountNumber.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'account-currency-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.bankInformation.currencyCode', - options: { - label: 'text.currency.label', - hint: 'GBP', - jsonFormDefinition: { - type: 'string', - oneOf: currencyCodes.map(code => ({ - const: code.code, - title: code.code, - })), - }, - }, - }, - ], - }, - { - name: 'contact-controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/6-company-ownership.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/6-company-ownership.ts deleted file mode 100644 index 8622ae6f5e..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/6-company-ownership.ts +++ /dev/null @@ -1,582 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['ubos', 'directors'], - properties: { - ubos: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'errorMessage.required.ubos', - }, - items: { - type: 'object', - required: ['firstName', 'lastName', 'email'], - properties: { - firstName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['role', 'dateOfBirth'], - errorMessage: { - required: { - role: 'errorMessage.error.requiredField', - dateOfBirth: 'errorMessage.error.requiredField', - }, - }, - properties: { - role: { - type: 'string', - }, - dateOfBirth: { - type: 'string', - }, - }, - }, - }, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - email: 'errorMessage.required.email', - }, - }, - }, - }, - directors: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'errorMessage.required.ubos', - }, - items: { - type: 'object', - required: ['firstName', 'lastName', 'email'], - properties: { - firstName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['role', 'dateOfBirth'], - errorMessage: { - required: { - role: 'errorMessage.error.requiredField', - dateOfBirth: 'errorMessage.required.dateOfBirth', - }, - }, - properties: { - role: { - type: 'string', - }, - dateOfBirth: { - type: 'string', - }, - }, - }, - }, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - email: 'errorMessage.required.email', - }, - }, - }, - }, - }, - errorMessage: { - required: { - ubos: 'errorMessage.required.ubos', - directors: 'errorMessage.required.directors', - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const CompanyOwnershipPage = { - type: 'page', - number: 6, - stateName: 'company_ownership', - name: 'text.companyOwnership', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyOwnership', - }, - }, - { - type: 'h3', - options: { - text: 'text.shareholders', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'im-shareholder-checkbox-form', - options: { - jsonFormDefinition: { - required: ['im-shareholder-checkbox'], - }, - }, - elements: [ - { - type: 'checkbox', - name: 'im-shareholder-checkbox', - valueDestination: 'entity.data.additionalInfo.imShareholder', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.imShareholder', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'checkbox-description-1', - options: { - descriptionRaw: 'text.shareholdersDescription', - }, - }, - { - type: 'json-form', - name: 'ubos-form', - valueDestination: 'entity.data.additionalInfo.ubos', - options: { - description: 'text.shareholdersDescription', - jsonFormDefinition: { - title: 'text.shareholder', - type: 'array', - required: [ - 'ubos:first-name-input', - 'ubos:last-name-input', - 'ubos:title-input', - 'ubos:email-input', - 'ubos:date-of-birth-input', - ], - }, - uiSchema: { - titleTemplate: 'text.uboIndex', - }, - insertionParams: { - insertionStrategy: 'array', - destination: 'entity.data.additionalInfo.ubos', - schema: { - firstName: 'entity.data.additionalInfo.mainRepresentative.firstName', - lastName: 'entity.data.additionalInfo.mainRepresentative.lastName', - email: 'entity.data.additionalInfo.mainRepresentative.email', - }, - bindingAnchorDestination: 'additionalInfo.__isGeneratedAutomatically', - disableElements: [ - { - elementName: 'ubos:first-name-input', - atIndex: 0, - }, - { - elementName: 'ubos:last-name-input', - atIndex: 0, - }, - { - elementName: 'ubos:email-input', - atIndex: 0, - }, - ], - insertWhen: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.imShareholder' }, true], - }, - }, - ], - removeWhen: [ - { - type: 'json-logic', - value: { - if: [ - { - var: 'entity.data.additionalInfo.imShareholder', - }, - false, - true, - ], - }, - }, - ], - }, - }, - elements: [ - { - name: 'ubos:first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].firstName', //entity.data.additionalInfo.ubos[0].firstName - options: { - label: 'text.firstName', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].lastName', - options: { - label: 'text.lastName', - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:title-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.role', - options: { - label: 'text.jobTitle.label', - hint: 'text.jobTitle.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:date-of-birth-input', - type: 'json-form:date', - valueDestination: - 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.dateOfBirth', - options: { - label: 'text.dateOfBirth.label', - hint: 'DD/MM/YYYY', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - }, - }, - { - name: 'ubos:email-input', - type: 'json-form:email', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - ], - }, - { - type: 'divider', - }, - { - type: 'h3', - options: { - text: 'text.directors', - classNames: ['padding-top-10'], - }, - }, - { - type: 'description', - options: { - descriptionRaw: 'text.directorsDescription', - }, - }, - { - type: 'json-form', - name: 'im-director-checkbox-form', - elements: [ - { - type: 'checkbox', - name: 'im-director-checkbox', - valueDestination: 'entity.data.additionalInfo.imDirector', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.imDirector', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'directors-form', - valueDestination: 'entity.data.additionalInfo.directors', - options: { - description: 'text.directorsDescription', - jsonFormDefinition: { - title: 'text.shareholder', - type: 'array', - required: [ - 'directors:first-name-input', - 'directors:last-name-input', - 'directors:title-input', - 'directors:email-input', - 'directors:date-of-birth-input', - ], - }, - uiSchema: { - titleTemplate: 'text.directorIndex', - }, - insertionParams: { - insertionStrategy: 'array', - destination: 'entity.data.additionalInfo.directors', - schema: { - firstName: 'entity.data.additionalInfo.mainRepresentative.firstName', - lastName: 'entity.data.additionalInfo.mainRepresentative.lastName', - email: 'entity.data.additionalInfo.mainRepresentative.email', - }, - bindingAnchorDestination: 'additionalInfo.__isGeneratedAutomatically', - disableElements: [ - { - elementName: 'directors:first-name-input', - atIndex: 0, - }, - { - elementName: 'directors:last-name-input', - atIndex: 0, - }, - { - elementName: 'directors:email-input', - atIndex: 0, - }, - ], - insertWhen: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.imDirector' }, true], - }, - }, - ], - removeWhen: [ - { - type: 'json-logic', - value: { - if: [ - { - var: 'entity.data.additionalInfo.imDirector', - }, - false, - true, - ], - }, - }, - ], - }, - }, - elements: [ - { - name: 'directors:first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].firstName', //entity.data.additionalInfo.ubos[0].firstName - options: { - label: 'text.firstName', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'directors:last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].lastName', - options: { - label: 'text.lastName', - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'directors:title-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].additionalInfo.role', - options: { - label: 'text.jobTitle.label', - hint: 'text.jobTitle.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'directors:date-of-birth-input', - type: 'json-form:date', - valueDestination: - 'entity.data.additionalInfo.directors[{INDEX}].additionalInfo.dateOfBirth', - options: { - label: 'text.dateOfBirth.label', - hint: 'DD/MM/YYYY', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - }, - }, - { - name: 'directors:email-input', - type: 'json-form:email', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/7-company-documents.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/7-company-documents.ts deleted file mode 100644 index 0cb07e2c49..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/7-company-documents.ts +++ /dev/null @@ -1,269 +0,0 @@ -const validationSchema = [ - { - documentId: 'document-bank-statement', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-company-structure', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-certificate-of-registration', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-proof-of-address', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, -]; - -export const CompanyDocumentsPage = { - type: 'page', - number: 7, - stateName: 'company_documents', - name: 'text.companyDocuments', - pageValidation: [ - { - type: 'destination-engine', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyDocuments', - }, - }, - { - type: 'h3', - options: { - text: 'text.merchantCompanyDocuments', - }, - }, - ], - }, - { - type: 'json-form', - name: 'company-documents-form', - options: { - jsonFormDefinition: { - required: [ - 'document-bank-statement', - 'document-company-structure', - 'document-certificate-of-registration', - 'document-proof-of-address', - ], - }, - }, - elements: [ - { - name: 'document-bank-statement', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.documents.bankStatement.label', - description: 'text.documents.bankStatement.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-bank-statement', - category: 'proof_of_address', - type: 'bank_statement', - issuer: { - country: 'GH', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-company-structure', - type: 'document', - valueDestination: 'documents[1].pages[0].ballerineFileId', - options: { - label: 'text.documents.companyStructure.label', - description: 'text.documents.companyStructure.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-company-structure', - category: 'proof_of_employment', - type: 'payslip', - issuer: { - country: 'GH', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-certificate-of-registration', - type: 'document', - valueDestination: 'documents[2].pages[0].ballerineFileId', - options: { - label: 'text.documents.certificateOfRegistration.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-certificate-of-registration', - category: 'proof_of_registration', - type: 'certificate_of_registration', - issuer: { - country: 'GH', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-proof-of-address', - type: 'document', - valueDestination: 'documents[3].pages[0].ballerineFileId', - options: { - label: 'text.documents.utilityBill.label', - description: 'text.documents.utilityBill.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-proof-of-address', - category: 'proof_of_address', - type: 'water_bill', - issuer: { - country: 'GH', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'accuracy-description', - options: { - descriptionRaw: 'text.emailDescription', - }, - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.finish', - }, - availableOn: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'jmespath', - value: '!contains(uiState.elements.*.isLoading,`true`)', - }, - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.hasConfirmed' }, true, false], - }, - }, - { - type: 'json-logic', - value: { '!==': [{ var: 'uiState.isLoading' }, true, false] }, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'destination-engine', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionPlugin', - params: { pluginName: 'sync_workflow_runtime', debounce: 50 }, - dispatchOn: { - uiEvents: [ - { - event: 'onChange', - uiElementName: 'document-bank-statement', - }, - { - event: 'onChange', - uiElementName: 'document-company-structure', - }, - { - event: 'onChange', - uiElementName: 'document-certificate-of-registration', - }, - { - event: 'onChange', - uiElementName: 'document-proof-of-address', - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/compose-ui-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/compose-ui-definition.ts deleted file mode 100644 index 4a839f18ec..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/compose-ui-definition.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { definition } from './defintion-logic'; -import { PersonalInfoPage } from './1-personal-info-page'; -import { CompanyInfoPage } from './2-company-info-page'; -import { BusinessAddressInfoPage } from './3-business-address-info-page'; -import { CompanyActivityPage } from './4-company-activity'; -import { BankInformationPage } from './5-bank-information'; -import { CompanyOwnershipPage } from './6-company-ownership'; -import { CompanyDocumentsPage } from './7-company-documents'; -import { Prisma } from '@prisma/client'; - -export const composeUiDefinition = ( - workflowDefinitionId: string, -): Pick< - Prisma.UiDefinitionUncheckedCreateInput, - 'uiContext' | 'uiSchema' | 'definition' | 'workflowDefinitionId' -> => { - return { - uiContext: 'collection_flow', - uiSchema: { - elements: [ - PersonalInfoPage, - CompanyInfoPage, - BusinessAddressInfoPage, - CompanyActivityPage, - BankInformationPage, - CompanyOwnershipPage, - CompanyDocumentsPage, - ], - }, - definition: definition, - workflowDefinitionId: workflowDefinitionId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/defintion-logic.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/defintion-logic.ts deleted file mode 100644 index 9876852c8f..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/ui-definition/defintion-logic.ts +++ /dev/null @@ -1,166 +0,0 @@ -export const definition = { - definitionType: 'statechart-json', - definition: { - id: 'dynamic_collection_flow', - predictableActionArguments: true, - initial: 'personal_details', - context: {}, - states: { - personal_details: { - on: { - NEXT: 'company_information', - }, - }, - company_information: { - on: { - NEXT: 'business_address_information', - PREVIOUS: 'personal_details', - }, - }, - business_address_information: { - on: { - NEXT: 'company_activity', - PREVIOUS: 'company_information', - }, - }, - company_activity: { - on: { - NEXT: 'bank_information', - PREVIOUS: 'business_address_information', - }, - }, - bank_information: { - on: { - NEXT: 'company_ownership', - PREVIOUS: 'company_activity', - }, - }, - company_ownership: { - on: { - NEXT: 'company_documents', - PREVIOUS: 'bank_information', - }, - }, - company_documents: { - on: { - NEXT: 'finish', - PREVIOUS: 'company_ownership', - }, - }, - finish: { type: 'final' }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'update_end_user', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/end-user?token={flowConfig.tokenId}`, - method: 'POST', - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - stateNames: [], - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - lastName: entity.data.additionalInfo.mainRepresentative.lastName, - additionalInfo: {title: entity.data.additionalInfo.mainRepresentative.additionalInfo.jobTitle}, - phone: entity.data.additionalInfo.mainRepresentative.phone, - dateOfBirth: entity.data.additionalInfo.mainRepresentative.dateOfBirth - }`, - }, - ], - }, - }, - { - name: 'sync_workflow_runtime', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/sync/?token={flowConfig.tokenId}`, - method: 'PUT', - stateNames: [ - 'personal_details', - 'company_information', - 'business_address_information', - 'company_activity', - 'bank_information', - 'company_ownership', - 'company_documents', - 'finish', - ], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - data: { - context: @, - endUser: entity.data.additionalInfo.mainRepresentative, - business: entity.data, - ballerineEntityId: entity.ballerineEntityId - } - }`, - }, - ], - }, - }, - { - name: 'fetch_company_information', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/business/business-information`, - method: 'GET', - stateNames: [], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - token: flowConfig.tokenId, - registrationNumber: entity.data.registrationNumber, - countryCode: entity.data.country, - state: entity.data.additionalInfo.state || '', - vendor: 'open-corporates' - }`, - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - companyName: name, - taxIdentificationNumber: vat, - numberOfEmployees: numberOfEmployees, - businessType: companyType, - additionalInfo: {openCorporate: @} - }`, - }, - ], - }, - persistResponseDestination: 'entity.data', - successAction: 'company_information', - errorAction: 'company_information', - }, - { - name: 'send_collection_flow_finished', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/send-event/?token={flowConfig.tokenId}`, - method: 'POST', - stateNames: ['finish'], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{eventName: 'COLLECTION_FLOW_FINISHED'}`, - }, - ], - }, - }, - ], - }, -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/workflow-definition/compose-demo-child-kyc-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/workflow-definition/compose-demo-child-kyc-definition.ts deleted file mode 100644 index 7821cccfc4..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/workflow-definition/compose-demo-child-kyc-definition.ts +++ /dev/null @@ -1,172 +0,0 @@ -import { env } from '@/env'; -import { StateTag } from '@ballerine/common'; - -export const composeDemoChildKycDefinition = ( - id = 'demo_kyc_email_session_example', - name = 'demo_kyc_email_session_example', - projectId?: string, -) => { - return { - id: id, - name: name, - version: 1, - definitionType: 'statechart-json', - definition: { - id: `${name}_v1`, - predictableActionArguments: true, - initial: 'idle', - states: { - idle: { - tags: [StateTag.PENDING_PROCESS], - on: { - start: 'get_kyc_session', - }, - }, - get_kyc_session: { - tags: [StateTag.PENDING_PROCESS], - on: { - SEND_EMAIL: [{ target: 'email_sent' }], - API_CALL_ERROR: [{ target: 'kyc_auto_reject' }], - }, - }, - get_kyc_session_revision: { - tags: [StateTag.REVISION], - on: { - SEND_EMAIL: [{ target: 'revision_email_sent' }], - API_CALL_ERROR: [{ target: 'kyc_auto_reject' }], - }, - }, - email_sent: { - tags: [StateTag.PENDING_PROCESS], - on: { - KYC_HOOK_RESPONDED: [{ target: 'kyc_manual_review' }], - }, - }, - revision_email_sent: { - tags: [StateTag.REVISION], - on: { - KYC_HOOK_RESPONDED: [{ target: 'kyc_manual_review' }], - }, - }, - kyc_manual_review: { - tags: [StateTag.MANUAL_REVIEW], - on: { - approve: { - target: 'approved', - }, - reject: { - target: 'rejected', - }, - revision: { - target: 'revision', - }, - }, - }, - revision: { - tags: [StateTag.REVISION], - always: [ - { - target: 'get_kyc_session_revision', - }, - ], - }, - kyc_auto_reject: { - tags: [StateTag.REJECTED], - type: 'final' as const, - }, - rejected: { - tags: [StateTag.REJECTED], - type: 'final' as const, - }, - approved: { - tags: [StateTag.APPROVED], - type: 'final' as const, - }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'kyc_session', - pluginKind: 'kyc-session', - url: `{secret.UNIFIED_API_URL}/individual-verification-sessions`, - method: 'POST', - stateNames: ['get_kyc_session', 'get_kyc_session_revision'], - successAction: 'SEND_EMAIL', - errorAction: 'API_CALL_ERROR', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - 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, - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/KYC_HOOK_RESPONDED','?resultDestination=pluginsOutput.kyc_session.kyc_session_1.result']), - vendor: 'veriff' - }`, // jmespath - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: "{kyc_session_1: {vendor: 'veriff', type: 'kyc', result: {metadata: @}}}", // jmespath - }, - ], - }, - }, - { - name: 'session_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - method: 'POST', - stateNames: ['email_sent', 'revision_email_sent'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - kybCompanyName: entity.data.additionalInfo.companyName, - customerCompanyName: entity.data.additionalInfo.customerCompany, - firstName: entity.data.firstName, - kycLink: pluginsOutput.kyc_session.kyc_session_1.result.metadata.url, - from: 'no-reply@ballerine.com', - name: join(' ',[entity.data.additionalInfo.customerCompany,'Team']), - receivers: [entity.data.email], - subject: '{customerCompanyName} activation, Action needed.', - templateId: (documents[].decision[].revisionReason | [0])!=null && 'd-2c6ae291d9df4f4a8770d6a4e272d803' || 'd-61c568cfa5b145b5916ff89790fe2065', - revisionReason: documents[].decision[].revisionReason | [0], - supportEmail: join('',['support@',entity.data.additionalInfo.customerCompany,'.com']), - adapter: '${env.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - ], - }, - config: { - callbackResult: { - transformers: [ - { - transformer: 'jmespath', - mapping: '{data: @}', // jmespath - }, - ], - deliverEvent: 'KYC_DONE', - }, - }, - projectId: projectId, - isPublic: !projectId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/workflow-definition/compose-demo-kyb-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/workflow-definition/compose-demo-kyb-definition.ts deleted file mode 100644 index c0b08cfcec..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-demo/workflow-definition/compose-demo-kyb-definition.ts +++ /dev/null @@ -1,385 +0,0 @@ -import { env } from '@/env'; -import { defaultContextSchema, StateTag } from '@ballerine/common'; -import { - BUSINESS_UBO_AND_SANCTIONS_DONE, - KYC_DONE_RULE, - kycAndVendorDone, -} from '../../../utils/rules'; - -export const composeDemoKybDefinition = ( - id = 'demo_kyb_flow', - name = 'demo_kyb_flow', - kycChildWorkflowDefinitionId: string, - projectId?: string, -) => { - return { - id: id, - name: name, - version: 1, - definitionType: 'statechart-json', - definition: { - id: 'demo_kyb_dynamic_ui_v1', - predictableActionArguments: true, - initial: 'idle', - context: { - documents: [], - }, - states: { - idle: { - on: { - START: 'collection_invite', - }, - }, - collection_invite: { - on: { - INVIATION_SENT: 'collection_flow', - INVIATION_FAILURE: 'failed', - }, - }, - collection_flow: { - tags: [StateTag.COLLECTION_FLOW], - on: { - COLLECTION_FLOW_FINISHED: [{ target: 'run_ubos' }], - }, - }, - run_ubos: { - tags: [StateTag.COLLECTION_FLOW], - on: { - EMAIL_SENT_TO_UBOS: [{ target: 'run_vendor_data' }], - FAILED_EMAIL_SENT_TO_UBOS: [{ target: 'failed' }], - }, - }, - run_vendor_data: { - tags: [StateTag.DATA_ENRICHMENT], - on: { - KYC_RESPONDED: [kycAndVendorDone], - VENDOR_DONE: [ - { - target: 'pending_kyc_response_to_finish', - cond: { - type: 'jmespath', - options: { - rule: `!(${KYC_DONE_RULE( - kycChildWorkflowDefinitionId, - )}) && ${BUSINESS_UBO_AND_SANCTIONS_DONE}`, - }, - }, - }, - kycAndVendorDone, - ], - reject: 'rejected', - VENDOR_FAILED: 'rejected', - }, - }, - pending_kyc_response_to_finish: { - tags: [StateTag.PENDING_PROCESS], - on: { - KYC_RESPONDED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: KYC_DONE_RULE(kycChildWorkflowDefinitionId), - }, - }, - }, - ], - reject: 'rejected', - revision: 'pending_resubmission', - }, - }, - manual_review: { - tags: [StateTag.MANUAL_REVIEW], - on: { - approve: 'approved', - reject: 'rejected', - revision: 'pending_resubmission', - KYC_REVISION: 'pending_kyc_response_to_finish', - }, - }, - pending_resubmission: { - tags: [StateTag.REVISION], - on: { - EMAIL_SENT: 'revision', - EMAIL_FAILURE: 'failed', - }, - }, - failed: { - tags: [StateTag.FAILURE], - type: 'final' as const, - }, - approved: { - tags: [StateTag.APPROVED], - type: 'final' as const, - }, - revision: { - tags: [StateTag.REVISION], - on: { - COLLECTION_FLOW_FINISHED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE(kycChildWorkflowDefinitionId)}`, - }, - }, - }, - { target: 'pending_kyc_response_to_finish' }, - ], - }, - }, - rejected: { - tags: [StateTag.REJECTED], - type: 'final' as const, - }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'collection_invite_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - successAction: 'INVIATION_SENT', - errorAction: 'INVIATION_FAILURE', - method: 'POST', - stateNames: ['collection_invite'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - companyName: entity.data.companyName, - customerName: metadata.customerName, - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - collectionFlowUrl: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token]), - from: 'no-reply@ballerine.com', - receivers: [entity.data.additionalInfo.mainRepresentative.email], - templateId: 'd-8949519316074e03909042cfc5eb4f02', - adapter: '{secret.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - { - name: 'kyb', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies-v2/{entity.data.country}/{entity.data.registrationNumber}`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.businessInformation', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `merge( - { vendor: 'asia-verify' }, - entity.data.country == 'HK' && { - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.businessInformation.data&processName=kyb-unified-api']) - } - )`, // jmespath - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: '@', // jmespath - }, - ], - }, - }, - { - name: 'company_sanctions', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies/{entity.data.country}/{entity.data.companyName}/sanctions`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.companySanctions', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - vendor: 'asia-verify' - }`, // jmespath - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: '@', // jmespath - }, - ], - }, - }, - { - name: 'ubo', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies/{entity.data.country}/{entity.data.registrationNumber}/ubo`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.ubo.request', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - vendor: 'asia-verify', - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.ubo.data&processName=ubo-unified-api']) - }`, // jmespath - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: '{request: @}', // jmespath - }, - ], - }, - }, - { - name: 'resubmission_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - method: 'POST', - successAction: 'EMAIL_SENT', - errorAction: 'EMAIL_FAILURE', - stateNames: ['pending_resubmission'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - // #TODO: create new token (new using old one) - mapping: `{ - kybCompanyName: entity.data.companyName, - customerCompanyName: metadata.customerName, - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - resubmissionLink: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token]), - supportEmail: join('',['support@',metadata.customerName,'.com']), - from: 'no-reply@ballerine.com', - name: join(' ',[metadata.customerName,'Team']), - receivers: [entity.data.additionalInfo.mainRepresentative.email], - templateId: 'd-7305991b3e5840f9a14feec767ea7301', - revisionReason: documents[].decision[].revisionReason | [0], - adapter: '${env.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - ], - childWorkflowPlugins: [ - { - pluginKind: 'child', - name: 'veriff_kyc_child_plugin', - definitionId: kycChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: `{entity: {data: @, type: 'individual'}}`, - }, - { - transformer: 'helper', - mapping: [ - { - source: 'entity.data', - target: 'entity.data', - method: 'omit', - value: ['workflowRuntimeId', 'workflowRuntimeConfig'], - }, - ], - }, - ], - initEvent: 'start', - }, - ], - commonPlugins: [ - { - pluginKind: 'iterative', - name: 'ubos_iterative', - actionPluginName: 'veriff_kyc_child_plugin', - stateNames: ['run_ubos'], - iterateOn: [ - { - transformer: 'jmespath', - mapping: 'entity.data.additionalInfo.ubos', - }, - ], - successAction: 'EMAIL_SENT_TO_UBOS', - errorAction: 'FAILED_EMAIL_SENT_TO_UBOS', - }, - ], - }, - config: { - initialEvent: 'START', - createCollectionFlowToken: true, - workflowLevelResolution: true, - enableManualCreation: true, - isCaseOverviewEnabled: true, - childCallbackResults: [ - { - definitionId: kycChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - persistenceStates: ['kyc_manual_review'], - deliverEvent: 'KYC_RESPONDED', - }, - { - definitionId: kycChildWorkflowDefinitionId, - persistenceStates: ['revision_email_sent'], - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - deliverEvent: 'KYC_REVISION', - }, - ], - }, - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - projectId: projectId, - isPublic: !projectId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/demo-ongoing-monitoring.template.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/demo-ongoing-monitoring.template.ts deleted file mode 100644 index 3c8a546d49..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/demo-ongoing-monitoring.template.ts +++ /dev/null @@ -1,162 +0,0 @@ -import { Template } from '../../template'; -import { DemoOngoingMonitoringTemplateParams } from './types'; -import { PasswordService } from '@/auth/password/password.service'; -import { composeUiDefinition } from './ui-definition/compose-ui-definition'; -import { generateBusinessesFilter } from '../../filters/generate-businesses-filter'; -import { CustomerService } from '@/customer/customer.service'; -import { generateWorkflowDefinitionWithAssociated } from '../../../shared/workflow-definition-with-associated'; -import { ONGOING_MONITORING_FILTER_NAME } from '../../../shared/consts'; -import { composeChildAssociatedCompanyDefinition } from '../child-associated-company/definition/compose-child-associated-company-definition'; -import { generateOngoingWorkflowDefinition } from '../oxpay/workflow-definition/ongoing-workflow-definition'; -import { generateIndividualsFilter } from '../../filters/generate-individuals-filter'; - -export class DemoOngoingMonitoringTemplate extends Template { - async generate() { - const customer = await this.createCustomer(); - const user = await this.createUser(); - - const project = await this.createProject(user.id, customer.id); - - const demoOngoingMonitoringChildAssociatedCompanyDefinition = - composeChildAssociatedCompanyDefinition({ - definitionId: `${customer.name}_demo_ongoing_monitoring_child_associated_company`, - definitionName: `${customer.name}_demo_ongoing_monitoring_child_associated_company`, - projectId: project.id, - }); - - // Uncomment once validation can pass with no example payload as a second argument - // validateDefinitionLogic( - // demoOngoingMonitoringChildAssociatedCompanyDefinition, - // ); - await this.prismaClient.workflowDefinition.create({ - data: { - ...demoOngoingMonitoringChildAssociatedCompanyDefinition, - }, - }); - - const demoOngoingMonitoringKybDefinition = generateWorkflowDefinitionWithAssociated({ - id: `${customer.name}_demo_ongoing_monitoring_kyb`, - name: `${customer.name}_demo_ongoing_monitoring_kyb`, - projectId: project.id, - crossEnvKey: `${customer.name}_demo_kyb`, - kybChildWorkflowDefinitionId: demoOngoingMonitoringChildAssociatedCompanyDefinition.id, - }); - - // validateDefinitionLogic(demoOngoingMonitoringKybDefinition); - const demoKybWorkflowDefinition = await this.prismaClient.workflowDefinition.create({ - data: { - ...demoOngoingMonitoringKybDefinition, - }, - }); - - const demoOngoingMonitoringOngoingDefinition = generateOngoingWorkflowDefinition( - `${customer.name}_demo_ongoing_monitoring_ongoing`, - `${customer.name}_demo_ongoing_monitoring_ongoing`, - project.id, - ); - - // validateDefinitionLogic(demoOngoingMonitoringOngoingDefinition); - await this.prismaClient.workflowDefinition.create({ - data: { - ...demoOngoingMonitoringOngoingDefinition, - }, - }); - - await this.createUIDefinition(demoKybWorkflowDefinition.id, project.id); - - await this.createKybFilter(project.id, demoKybWorkflowDefinition.id); - - await this.createOngoingFilter(project.id, demoOngoingMonitoringOngoingDefinition.id); - - return Promise.resolve(); - } - - private async createCustomer() { - const { customer } = this.params; - const customerService = this.app.get(CustomerService); - - return customerService.create({ - data: { - id: customer.id, - displayName: customer.displayName, - name: customer.name, - authenticationConfiguration: { - apiType: 'API_KEY', - authValue: customer.apiKey, - validUntil: '', - isValid: '', - }, - logoImageUri: customer.logoImageUrl, - config: { - ongoingWorkflowDefinitionId: `${customer.name}_demo_ongoing_monitoring_ongoing`, - }, - }, - }); - } - - private async createUser() { - const { user } = this.params; - - const passwordService = this.app.get(PasswordService); - - return this.prismaClient.user.create({ - data: { - firstName: user.firstName, - lastName: user.lastName, - email: user.email, - password: await passwordService.hash(user.password), - roles: ['user'], - }, - }); - } - - private createProject(userId: string, customerId: string) { - const { project } = this.params; - - return this.prismaClient.project.create({ - data: { - id: project.id, - name: project.id, - customerId, - userToProjects: { - create: { - userId, - }, - }, - }, - }); - } - - private async createUIDefinition(workflowDefinitionId: string, projectId: string) { - return this.prismaClient.uiDefinition.create({ - data: { - ...composeUiDefinition(workflowDefinitionId), - projectId, - }, - }); - } - - private async createKybFilter(projectId: string, definitionId: string) { - const baseQuery = generateBusinessesFilter({ - filterName: 'Merchants KYB', - definitionId, - projectId, - }); - - return this.prismaClient.filter.create({ - data: baseQuery, - }); - } - - private async createOngoingFilter(projectId: string, definitionId: string) { - const baseQuery = generateIndividualsFilter({ - filterName: ONGOING_MONITORING_FILTER_NAME, - definitionId, - projectId, - }); - - return this.prismaClient.filter.create({ - data: baseQuery, - }); - } -} diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/index.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/index.ts deleted file mode 100644 index b382b3bbb8..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './demo-ongoing-monitoring.template'; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/types.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/types.ts deleted file mode 100644 index a14f8cfe28..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/types.ts +++ /dev/null @@ -1,44 +0,0 @@ -interface DemoOngoingMonitoringCustomer { - id: string; - displayName: string; - name: string; - apiKey: string; - logoImageUrl: string; -} - -interface DemoOngoingMonitoringUser { - firstName: string; - lastName: string; - email: string; - password: string; -} - -interface DemoOngoingMonitoringProject { - id: string; -} - -interface DemoOngoingMonitoringFilter { - name: string; -} -interface DefinitionWithChildrenConfig { - parentKybDefinitionId: string; - kybDefinitionName: string; - childKycDefinitionId: string; - childKycDefinitionName: string; -} - -export interface DemoOngoingMonitoringTemplateParams { - // Customer - customer: DemoOngoingMonitoringCustomer; - - // User - user: DemoOngoingMonitoringUser; - - // Project - project: DemoOngoingMonitoringProject; - - // Filter - filter: DemoOngoingMonitoringFilter; - - definitionWithChildren?: DefinitionWithChildrenConfig; -} diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/1-personal-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/1-personal-info-page.ts deleted file mode 100644 index bd0afeda44..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/1-personal-info-page.ts +++ /dev/null @@ -1,290 +0,0 @@ -const validationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['mainRepresentative', 'iHaveSigningAuthority'], - default: {}, - errorMessage: { - required: { - iHaveSigningAuthority: 'This field is required.', - }, - }, - properties: { - mainRepresentative: { - type: 'object', - required: ['phone', 'dateOfBirth', 'firstName', 'lastName', 'additionalInfo'], - errorMessage: { - required: { - phone: 'errorMessage.required.phone', - dateOfBirth: 'errorMessage.required.dateOfBirth', - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - }, - }, - properties: { - phone: { - type: 'string', - pattern: '^[+]?[0-9]{10,15}$', - errorMessage: { - pattern: 'errorMessage.pattern.phone', - }, - }, - dateOfBirth: { - type: 'string', - errorMessage: { - type: 'errorMessage.type.dateOfBirth', - }, - }, - firstName: { - type: 'string', - minLength: 2, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 2, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - }, - }, - additionalInfo: { - type: 'object', - required: ['jobTitle'], - default: {}, - errorMessage: { - required: { - jobTitle: 'errorMessage.required.jobTitle', - }, - }, - properties: { - jobTitle: { - type: 'string', - minLength: 2, - errorMessage: { - minLength: 'errorMessage.minLength.jobTitle', - }, - }, - }, - }, - }, - }, - iHaveSigningAuthority: { - type: 'boolean', - enum: [true], - errorMessage: { - enum: 'errorMessage.error.requiredField', - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -export const PersonalInfoPage = { - type: 'page', - name: 'text.personalInformation', - number: 1, - stateName: 'personal_details', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.personalInformation', - }, - }, - ], - }, - { - type: 'json-form', - valueDestination: 'entity.data.additionalInfo.mainRepresentative', - name: 'json-form:personal-information', - options: { - jsonFormDefinition: { - required: [ - 'first-name-input', - 'last-name-input', - 'job-title-input', - 'date-of-birth-input', - 'phone-number-input', - ], - }, - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - name: 'first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.firstName', - options: { - label: 'Name', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.lastName', - options: { - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'job-title-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.mainRepresentative.additionalInfo.jobTitle', - options: { - label: 'text.jobTitle.label', - hint: 'text.jobTitle.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'date-of-birth-input', - type: 'json-form:date', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.dateOfBirth', - options: { - label: 'text.dateOfBirth.label', - hint: 'DD/MM/YYYY', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - }, - }, - { - name: 'phone-number-input', - type: 'international-phone-number', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.phone', - options: { - label: 'text.phoneNumber', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'PhoneInput', - 'ui:label': true, - }, - }, - }, - { - name: 'authority-checkbox', - type: 'authority-checkbox', - valueDestination: 'entity.data.additionalInfo.iHaveSigningAuthority', - options: { - label: 'text.iHaveSigningAuthority.label', - jsonFormDefinition: { - type: 'boolean', - }, - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionPlugin', - params: { - pluginName: 'update_end_user', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/2-company-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/2-company-info-page.ts deleted file mode 100644 index b630116fd0..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/2-company-info-page.ts +++ /dev/null @@ -1,476 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: [ - 'additionalInfo', - 'businessType', - 'taxIdentificationNumber', - 'companyName', - 'country', - 'registrationNumber', - ], - properties: { - businessType: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.businessType', - maxLength: 'errorMessage.maxLength.businessType', - required: 'errorMessage.required.businessType', - }, - }, - taxIdentificationNumber: { - type: 'string', - minLength: 8, - maxLength: 15, - pattern: '^[^\\s]*$', - errorMessage: { - minLength: 'errorMessage.minLength.taxIdentificationNumber', - maxLength: 'errorMessage.maxLength.taxIdentificationNumber', - pattern: 'errorMessage.pattern.taxIdentificationNumber', - required: 'errorMessage.equired.taxIdentificationNumber', - }, - }, - companyName: { - type: 'string', - minLength: 2, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.companyName', - maxLength: 'errorMessage.maxLength.companyName', - required: 'errorMessage.required.companyName', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength.country', - pattern: 'errorMessage.pattern.country', - required: 'errorMessage.required.country', - }, - }, - registrationNumber: { - type: 'string', - minLength: 4, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.registrationNumber', - maxLength: 'errorMessage.maxLength.registrationNumber', - required: 'errorMessage.required.registrationNumber', - }, - }, - additionalInfo: { - type: 'object', - required: ['dateOfEstablishment'], - properties: { - dateOfEstablishment: { - type: 'string', - }, - }, - errorMessage: { - required: { - dateOfEstablishment: 'errorMessage.error.requiredField', - }, - }, - }, - }, - errorMessage: { - required: { - businessType: 'errorMessage.required.businessType', - numberOfEmployees: 'errorMessage.required.numberOfEmployees', - taxIdentificationNumber: 'errorMessage.required.taxIdentificationNumber', - companyName: 'errorMessage.required.companyName', - country: 'errorMessage.required.country', - registrationNumber: 'errorMessage.required.registrationNumber', - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const dispatchOpenCorporateRule = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - default: {}, - properties: { - data: { - type: 'object', - required: ['registrationNumber', 'country'], - default: {}, - properties: { - registrationNumber: { - type: 'string', - minLength: 6, - maxLength: 20, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - }, - additionalInfo: { - type: 'object', - properties: { - state: { - type: 'string', - minLength: 1, - }, - }, - }, - }, - if: { - properties: { - country: { - enum: ['AE', 'US', 'CA'], - }, - }, - }, - then: { - required: ['additionalInfo'], - properties: { - additionalInfo: { - required: ['state'], - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const stateVisiblityRule = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['country'], - default: {}, - properties: { - country: { - type: 'string', - enum: ['AE', 'US', 'CA'], - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const CompanyInfoPage = { - type: 'page', - number: 2, // routing number of page - stateName: 'company_information', // this is the route from xstate - name: 'text.companyInformation', // page name ( in stepper ) - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyInformation', - }, - }, - ], - }, - { - type: 'json-form', - name: 'business_info_form_p1', - options: { - jsonFormDefinition: { - required: ['registration-number-input', 'country-picker-input'], - }, - }, - elements: [ - { - name: 'registration-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.registrationNumber', - options: { - label: 'text.registrationNumber.label', - hint: 'text.registrationNumber.hint', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - }, - }, - { - name: 'country-picker-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.country', - options: { - label: 'text.registeredCountry.label', - hint: 'text.registeredCountry.hint', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.registeredCountry.placeholder', - }, - }, - }, - ], - }, - { - name: 'business_info_form_p2', - type: 'json-form', - options: { - jsonFormDefinition: { - required: ['business_info_state_input'], - }, - }, - visibleOn: [ - { - type: 'json-schema', - value: stateVisiblityRule, - }, - ], - elements: [ - { - name: 'business_info_state_input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.state', - options: { - label: 'text.state.label', - hint: 'text.state.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'StatePicker', - }, - countryCodePath: 'entity.data.country', - }, - }, - ], - }, - { - name: 'business_info_form_p3', - type: 'json-form', - options: { - jsonFormDefinition: { - required: [ - 'company-name-input', - 'tax-identification-number-input', - 'number-of-employees-input', - 'business-type-input', - 'registered-capital-in-yuan-type-input', - 'date-of-establishment-input', - ], - }, - }, - elements: [ - { - name: 'company-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.companyName', - options: { - label: 'text.legalName', - hint: 'OpenAI Technologies, Inc.', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - }, - }, - { - name: 'tax-identification-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.taxIdentificationNumber', - options: { - label: 'text.taxIdentificationNumber.label', - hint: 'text.taxIdentificationNumber.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'business-type-input', - type: 'json-form:dropdown', - valueDestination: 'entity.data.businessType', - options: { - hint: 'text.businessType.hint', - label: 'text.businessType.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'AutocompleteInput', - 'ui:label': true, - options: [ - { - title: 'text.businessType.options.sole_proprietorship', - const: 'sole_proprietorship', - }, - { - title: 'text.businessType.options.partnership', - const: 'partnership', - }, - { - title: 'text.businessType.options.corporation', - const: 'corporation', - }, - { - title: 'text.businessType.options.limited_liability_company', - const: 'limited_liability_company_(llc)', - }, - { - title: 'text.businessType.options.limited_partnership', - const: 'limited_partnership_(lp)', - }, - { - title: 'text.businessType.options.limited_liability_partnership', - const: 'limited_liability_partnership_(llp)', - }, - { - title: 'text.businessType.options.public_limited_company', - const: 'public_limited_company_(plc)', - }, - { - title: 'text.businessType.options.private_limited_company', - const: 'private_limited_company_(ltd)', - }, - { - title: 'text.businessType.options.non_profit_organization', - const: 'non-profit_organization', - }, - { - title: 'text.businessType.options.cooperative', - const: 'cooperative', - }, - { - title: 'text.businessType.options.trust', - const: 'trust', - }, - { - title: 'text.businessType.options.government', - const: 'government', - }, - { - title: 'text.businessType.options.other', - const: 'other', - }, - ], - }, - }, - }, - { - name: 'date-of-establishment-input', - type: 'json-form:date', - valueDestination: 'entity.data.additionalInfo.dateOfEstablishment', - options: { - label: 'text.established.label', - hint: 'DD/MM/YYYY', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionPlugin', - params: { pluginName: 'fetch_company_information', debounce: 700 }, - dispatchOn: { - uiEvents: [ - { event: 'onChange', uiElementName: 'registration-number-input' }, - { event: 'onChange', uiElementName: 'country-picker-input' }, - { event: 'onChange', uiElementName: 'business_info_state_input' }, - ], - rules: [ - { - type: 'json-schema', - value: dispatchOpenCorporateRule, - }, - ], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/3-business-address-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/3-business-address-info-page.ts deleted file mode 100644 index fa98c42350..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/3-business-address-info-page.ts +++ /dev/null @@ -1,262 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['headquarters'], - default: {}, - properties: { - headquarters: { - type: 'object', - default: {}, - required: ['street', 'streetNumber', 'city', 'country', 'postalCode', 'phone'], - errorMessage: { - required: { - street: 'errorMessage.required.street', - streetNumber: 'errorMessage.required.streetNumber', - city: 'errorMessage.required.city', - country: 'errorMessage.required.country', - postalCode: 'errorMessage.error.requiredField', - phone: 'errorMessage.error.requiredField', - }, - }, - properties: { - street: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.street', - maxLength: 'errorMessage.maxLength.street', - }, - }, - streetNumber: { - type: 'number', - minLength: 1, - maxLength: 10, - errorMessage: { - minLength: 'errorMessage.minLength.streetNumber', - maxLength: 'errorMessage.maxLength.streetNumber', - }, - }, - postalCode: { - type: 'string', - }, - city: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.city', - maxLength: 'errorMessage.maxLength.city', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength.country', - pattern: 'errorMessage.pattern.country', - }, - }, - phone: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const BusinessAddressInfoPage = { - type: 'page', - number: 3, - stateName: 'business_address_information', - name: 'text.headquartersAddress', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.headquartersAddress', - }, - }, - { - type: 'h3', - options: { - text: 'text.registeredAddress', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'business-address-info-page-form', - options: { - jsonFormDefinition: { - required: [ - 'street-input', - 'street-number-input', - 'postal-code-input', - 'city-input', - 'country-input', - 'headquarters-phone-number-input', - ], - }, - }, - elements: [ - { - name: 'street-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.street', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.street.label', - hint: 'text.street.hint', - }, - }, - { - name: 'street-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.streetNumber', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.number', - hint: '10', - }, - }, - { - name: 'postal-code-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.postalCode', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.postalCode', - hint: '10', - }, - }, - { - name: 'city-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.city', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.city.label', - hint: 'text.city.hint', - }, - }, - { - name: 'country-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.additionalInfo.headquarters.country', - options: { - label: 'text.country', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.choose', - }, - }, - }, - { - name: 'headquarters-phone-number-input', - type: 'international-phone-number', - valueDestination: 'entity.data.additionalInfo.headquarters.phone', - options: { - label: 'text.headquartersPhoneNumber.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'PhoneInput', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/4-company-activity.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/4-company-activity.ts deleted file mode 100644 index 9064c67661..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/4-company-activity.ts +++ /dev/null @@ -1,215 +0,0 @@ -import { singleUrlPattern } from '../../../utils/schema-utils/regex'; - -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - default: {}, - required: [ - 'industry', - 'businessModel', - 'companyWebsite', - 'annualVolume', - 'transactionValue', - ], - properties: { - industry: { - type: 'string', - }, - businessModel: { - type: 'string', - }, - companyWebsite: { - type: 'string', - pattern: singleUrlPattern, - errorMessage: { - pattern: 'errorMessage.pattern.companyWebsite', - }, - }, - annualVolume: { - type: 'number', - }, - transactionValue: { - type: 'number', - }, - }, - errorMessage: { - required: { - industry: 'errorMessage.required.industry', - businessModel: 'errorMessage.required.businessModel', - companyWebsite: 'errorMessage.required.companyWebsite', - annualVolume: 'errorMessage.error.requiredField', - transactionValue: 'errorMessage.error.requiredField', - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; -export const CompanyActivityPage = { - type: 'page', - number: 4, - stateName: 'company_activity', - name: 'text.companyActivity', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyActivity', - }, - }, - ], - }, - { - name: 'company-activity-inputs-group', - type: 'json-form', - options: { - jsonFormDefinition: { - required: [ - 'industry-input', - 'business-model-input', - 'company-website-input', - 'annual-volume-amount-input', - 'transaction-value-input', - ], - }, - }, - elements: [ - { - name: 'industry-input', - type: 'dropdown', - valueDestination: 'entity.data.additionalInfo.industry', - options: { - label: 'text.industryInput.label', - hint: 'text.industryInput.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'IndustriesPicker', - }, - }, - }, - { - name: 'business-model-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.businessModel', - options: { - label: 'text.businessModelInput.label', - hint: 'text.businessModelInput.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:widget': 'textarea', - }, - }, - }, - { - name: 'company-website-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.companyWebsite', - options: { - label: 'text.companyWebsiteInput.label', - hint: 'text.companyWebsiteInput.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'annual-volume-amount-input', - type: 'number-field', - valueDestination: 'entity.data.additionalInfo.annualVolume', - options: { - label: 'text.annualVolumeAmountInput.label', - hint: 'text.annualVolumeAmountInput.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'transaction-value-input', - type: 'number-field', - valueDestination: 'entity.data.additionalInfo.transactionValue', - options: { - label: 'text.averageTransactionValueInput.label', - hint: 'text.averageTransactionValueInput.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/5-bank-information.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/5-bank-information.ts deleted file mode 100644 index 1ac5dec36b..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/5-bank-information.ts +++ /dev/null @@ -1,217 +0,0 @@ -import { currencyCodes } from '../../../utils/schema-utils/currency-codes'; - -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - default: {}, - required: ['data'], - properties: { - data: { - type: 'object', - default: {}, - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['bankInformation'], - default: {}, - properties: { - bankInformation: { - type: 'object', - default: {}, - errorMessage: { - required: { - country: 'errorMessage.required.bankCountry', - name: 'errorMessage.required.bankName', - holderName: 'errorMessage.required.holderName', - accountNumber: 'errorMessage.required.accountNumber', - currencyCode: 'errorMessage.required.currency', - }, - }, - required: ['country', 'name', 'holderName', 'accountNumber', 'currencyCode'], - properties: { - country: { - type: 'string', - }, - name: { - type: 'string', - }, - holderName: { - type: 'string', - }, - accountNumber: { - type: 'string', - }, - currencyCode: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const BankInformationPage = { - type: 'page', - number: 5, - stateName: 'bank_information', - name: 'text.bankInformation', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.bankInformation', - }, - }, - ], - }, - { - type: 'json-form', - name: 'bank-information-form', - options: { - jsonFormDefinition: { - required: [ - 'bank-country-input', - 'bank-name-input', - 'account-holder-name-input', - 'account-number-input', - 'account-currency-input', - ], - }, - }, - elements: [ - { - name: 'bank-country-input', - type: 'dropdown', - valueDestination: 'entity.data.additionalInfo.bankInformation.country', - options: { - label: 'text.bankCountry.label', - hint: 'text.bankCountry.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - }, - }, - }, - { - name: 'bank-name-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.bankInformation.name', - options: { - label: 'text.bankName.label', - hint: 'text.bankName.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'account-holder-name-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.bankInformation.holderName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.accountHolderName.label', - hint: 'text.accountHolderName.hint', - }, - }, - { - name: 'account-number-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.bankInformation.accountNumber', - options: { - label: 'text.accountNumber.label', - hint: 'text.accountNumber.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'account-currency-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.bankInformation.currencyCode', - options: { - label: 'text.currency.label', - hint: 'GBP', - jsonFormDefinition: { - type: 'string', - oneOf: currencyCodes.map(code => ({ - const: code.code, - title: code.code, - })), - }, - }, - }, - ], - }, - { - name: 'contact-controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/6-company-ownership.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/6-company-ownership.ts deleted file mode 100644 index 8622ae6f5e..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/6-company-ownership.ts +++ /dev/null @@ -1,582 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['ubos', 'directors'], - properties: { - ubos: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'errorMessage.required.ubos', - }, - items: { - type: 'object', - required: ['firstName', 'lastName', 'email'], - properties: { - firstName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['role', 'dateOfBirth'], - errorMessage: { - required: { - role: 'errorMessage.error.requiredField', - dateOfBirth: 'errorMessage.error.requiredField', - }, - }, - properties: { - role: { - type: 'string', - }, - dateOfBirth: { - type: 'string', - }, - }, - }, - }, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - email: 'errorMessage.required.email', - }, - }, - }, - }, - directors: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'errorMessage.required.ubos', - }, - items: { - type: 'object', - required: ['firstName', 'lastName', 'email'], - properties: { - firstName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['role', 'dateOfBirth'], - errorMessage: { - required: { - role: 'errorMessage.error.requiredField', - dateOfBirth: 'errorMessage.required.dateOfBirth', - }, - }, - properties: { - role: { - type: 'string', - }, - dateOfBirth: { - type: 'string', - }, - }, - }, - }, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - email: 'errorMessage.required.email', - }, - }, - }, - }, - }, - errorMessage: { - required: { - ubos: 'errorMessage.required.ubos', - directors: 'errorMessage.required.directors', - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const CompanyOwnershipPage = { - type: 'page', - number: 6, - stateName: 'company_ownership', - name: 'text.companyOwnership', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyOwnership', - }, - }, - { - type: 'h3', - options: { - text: 'text.shareholders', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'im-shareholder-checkbox-form', - options: { - jsonFormDefinition: { - required: ['im-shareholder-checkbox'], - }, - }, - elements: [ - { - type: 'checkbox', - name: 'im-shareholder-checkbox', - valueDestination: 'entity.data.additionalInfo.imShareholder', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.imShareholder', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'checkbox-description-1', - options: { - descriptionRaw: 'text.shareholdersDescription', - }, - }, - { - type: 'json-form', - name: 'ubos-form', - valueDestination: 'entity.data.additionalInfo.ubos', - options: { - description: 'text.shareholdersDescription', - jsonFormDefinition: { - title: 'text.shareholder', - type: 'array', - required: [ - 'ubos:first-name-input', - 'ubos:last-name-input', - 'ubos:title-input', - 'ubos:email-input', - 'ubos:date-of-birth-input', - ], - }, - uiSchema: { - titleTemplate: 'text.uboIndex', - }, - insertionParams: { - insertionStrategy: 'array', - destination: 'entity.data.additionalInfo.ubos', - schema: { - firstName: 'entity.data.additionalInfo.mainRepresentative.firstName', - lastName: 'entity.data.additionalInfo.mainRepresentative.lastName', - email: 'entity.data.additionalInfo.mainRepresentative.email', - }, - bindingAnchorDestination: 'additionalInfo.__isGeneratedAutomatically', - disableElements: [ - { - elementName: 'ubos:first-name-input', - atIndex: 0, - }, - { - elementName: 'ubos:last-name-input', - atIndex: 0, - }, - { - elementName: 'ubos:email-input', - atIndex: 0, - }, - ], - insertWhen: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.imShareholder' }, true], - }, - }, - ], - removeWhen: [ - { - type: 'json-logic', - value: { - if: [ - { - var: 'entity.data.additionalInfo.imShareholder', - }, - false, - true, - ], - }, - }, - ], - }, - }, - elements: [ - { - name: 'ubos:first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].firstName', //entity.data.additionalInfo.ubos[0].firstName - options: { - label: 'text.firstName', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].lastName', - options: { - label: 'text.lastName', - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:title-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.role', - options: { - label: 'text.jobTitle.label', - hint: 'text.jobTitle.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:date-of-birth-input', - type: 'json-form:date', - valueDestination: - 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.dateOfBirth', - options: { - label: 'text.dateOfBirth.label', - hint: 'DD/MM/YYYY', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - }, - }, - { - name: 'ubos:email-input', - type: 'json-form:email', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - ], - }, - { - type: 'divider', - }, - { - type: 'h3', - options: { - text: 'text.directors', - classNames: ['padding-top-10'], - }, - }, - { - type: 'description', - options: { - descriptionRaw: 'text.directorsDescription', - }, - }, - { - type: 'json-form', - name: 'im-director-checkbox-form', - elements: [ - { - type: 'checkbox', - name: 'im-director-checkbox', - valueDestination: 'entity.data.additionalInfo.imDirector', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.imDirector', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'directors-form', - valueDestination: 'entity.data.additionalInfo.directors', - options: { - description: 'text.directorsDescription', - jsonFormDefinition: { - title: 'text.shareholder', - type: 'array', - required: [ - 'directors:first-name-input', - 'directors:last-name-input', - 'directors:title-input', - 'directors:email-input', - 'directors:date-of-birth-input', - ], - }, - uiSchema: { - titleTemplate: 'text.directorIndex', - }, - insertionParams: { - insertionStrategy: 'array', - destination: 'entity.data.additionalInfo.directors', - schema: { - firstName: 'entity.data.additionalInfo.mainRepresentative.firstName', - lastName: 'entity.data.additionalInfo.mainRepresentative.lastName', - email: 'entity.data.additionalInfo.mainRepresentative.email', - }, - bindingAnchorDestination: 'additionalInfo.__isGeneratedAutomatically', - disableElements: [ - { - elementName: 'directors:first-name-input', - atIndex: 0, - }, - { - elementName: 'directors:last-name-input', - atIndex: 0, - }, - { - elementName: 'directors:email-input', - atIndex: 0, - }, - ], - insertWhen: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.imDirector' }, true], - }, - }, - ], - removeWhen: [ - { - type: 'json-logic', - value: { - if: [ - { - var: 'entity.data.additionalInfo.imDirector', - }, - false, - true, - ], - }, - }, - ], - }, - }, - elements: [ - { - name: 'directors:first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].firstName', //entity.data.additionalInfo.ubos[0].firstName - options: { - label: 'text.firstName', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'directors:last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].lastName', - options: { - label: 'text.lastName', - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'directors:title-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].additionalInfo.role', - options: { - label: 'text.jobTitle.label', - hint: 'text.jobTitle.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'directors:date-of-birth-input', - type: 'json-form:date', - valueDestination: - 'entity.data.additionalInfo.directors[{INDEX}].additionalInfo.dateOfBirth', - options: { - label: 'text.dateOfBirth.label', - hint: 'DD/MM/YYYY', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - }, - }, - { - name: 'directors:email-input', - type: 'json-form:email', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/7-company-documents.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/7-company-documents.ts deleted file mode 100644 index 0cb07e2c49..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/7-company-documents.ts +++ /dev/null @@ -1,269 +0,0 @@ -const validationSchema = [ - { - documentId: 'document-bank-statement', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-company-structure', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-certificate-of-registration', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-proof-of-address', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, -]; - -export const CompanyDocumentsPage = { - type: 'page', - number: 7, - stateName: 'company_documents', - name: 'text.companyDocuments', - pageValidation: [ - { - type: 'destination-engine', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyDocuments', - }, - }, - { - type: 'h3', - options: { - text: 'text.merchantCompanyDocuments', - }, - }, - ], - }, - { - type: 'json-form', - name: 'company-documents-form', - options: { - jsonFormDefinition: { - required: [ - 'document-bank-statement', - 'document-company-structure', - 'document-certificate-of-registration', - 'document-proof-of-address', - ], - }, - }, - elements: [ - { - name: 'document-bank-statement', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.documents.bankStatement.label', - description: 'text.documents.bankStatement.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-bank-statement', - category: 'proof_of_address', - type: 'bank_statement', - issuer: { - country: 'GH', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-company-structure', - type: 'document', - valueDestination: 'documents[1].pages[0].ballerineFileId', - options: { - label: 'text.documents.companyStructure.label', - description: 'text.documents.companyStructure.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-company-structure', - category: 'proof_of_employment', - type: 'payslip', - issuer: { - country: 'GH', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-certificate-of-registration', - type: 'document', - valueDestination: 'documents[2].pages[0].ballerineFileId', - options: { - label: 'text.documents.certificateOfRegistration.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-certificate-of-registration', - category: 'proof_of_registration', - type: 'certificate_of_registration', - issuer: { - country: 'GH', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-proof-of-address', - type: 'document', - valueDestination: 'documents[3].pages[0].ballerineFileId', - options: { - label: 'text.documents.utilityBill.label', - description: 'text.documents.utilityBill.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-proof-of-address', - category: 'proof_of_address', - type: 'water_bill', - issuer: { - country: 'GH', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'accuracy-description', - options: { - descriptionRaw: 'text.emailDescription', - }, - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.finish', - }, - availableOn: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'jmespath', - value: '!contains(uiState.elements.*.isLoading,`true`)', - }, - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.hasConfirmed' }, true, false], - }, - }, - { - type: 'json-logic', - value: { '!==': [{ var: 'uiState.isLoading' }, true, false] }, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'destination-engine', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionPlugin', - params: { pluginName: 'sync_workflow_runtime', debounce: 50 }, - dispatchOn: { - uiEvents: [ - { - event: 'onChange', - uiElementName: 'document-bank-statement', - }, - { - event: 'onChange', - uiElementName: 'document-company-structure', - }, - { - event: 'onChange', - uiElementName: 'document-certificate-of-registration', - }, - { - event: 'onChange', - uiElementName: 'document-proof-of-address', - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/compose-ui-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/compose-ui-definition.ts deleted file mode 100644 index 4a839f18ec..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/compose-ui-definition.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { definition } from './defintion-logic'; -import { PersonalInfoPage } from './1-personal-info-page'; -import { CompanyInfoPage } from './2-company-info-page'; -import { BusinessAddressInfoPage } from './3-business-address-info-page'; -import { CompanyActivityPage } from './4-company-activity'; -import { BankInformationPage } from './5-bank-information'; -import { CompanyOwnershipPage } from './6-company-ownership'; -import { CompanyDocumentsPage } from './7-company-documents'; -import { Prisma } from '@prisma/client'; - -export const composeUiDefinition = ( - workflowDefinitionId: string, -): Pick< - Prisma.UiDefinitionUncheckedCreateInput, - 'uiContext' | 'uiSchema' | 'definition' | 'workflowDefinitionId' -> => { - return { - uiContext: 'collection_flow', - uiSchema: { - elements: [ - PersonalInfoPage, - CompanyInfoPage, - BusinessAddressInfoPage, - CompanyActivityPage, - BankInformationPage, - CompanyOwnershipPage, - CompanyDocumentsPage, - ], - }, - definition: definition, - workflowDefinitionId: workflowDefinitionId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/defintion-logic.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/defintion-logic.ts deleted file mode 100644 index 9876852c8f..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-ongoing-monitoring-demo/ui-definition/defintion-logic.ts +++ /dev/null @@ -1,166 +0,0 @@ -export const definition = { - definitionType: 'statechart-json', - definition: { - id: 'dynamic_collection_flow', - predictableActionArguments: true, - initial: 'personal_details', - context: {}, - states: { - personal_details: { - on: { - NEXT: 'company_information', - }, - }, - company_information: { - on: { - NEXT: 'business_address_information', - PREVIOUS: 'personal_details', - }, - }, - business_address_information: { - on: { - NEXT: 'company_activity', - PREVIOUS: 'company_information', - }, - }, - company_activity: { - on: { - NEXT: 'bank_information', - PREVIOUS: 'business_address_information', - }, - }, - bank_information: { - on: { - NEXT: 'company_ownership', - PREVIOUS: 'company_activity', - }, - }, - company_ownership: { - on: { - NEXT: 'company_documents', - PREVIOUS: 'bank_information', - }, - }, - company_documents: { - on: { - NEXT: 'finish', - PREVIOUS: 'company_ownership', - }, - }, - finish: { type: 'final' }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'update_end_user', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/end-user?token={flowConfig.tokenId}`, - method: 'POST', - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - stateNames: [], - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - lastName: entity.data.additionalInfo.mainRepresentative.lastName, - additionalInfo: {title: entity.data.additionalInfo.mainRepresentative.additionalInfo.jobTitle}, - phone: entity.data.additionalInfo.mainRepresentative.phone, - dateOfBirth: entity.data.additionalInfo.mainRepresentative.dateOfBirth - }`, - }, - ], - }, - }, - { - name: 'sync_workflow_runtime', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/sync/?token={flowConfig.tokenId}`, - method: 'PUT', - stateNames: [ - 'personal_details', - 'company_information', - 'business_address_information', - 'company_activity', - 'bank_information', - 'company_ownership', - 'company_documents', - 'finish', - ], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - data: { - context: @, - endUser: entity.data.additionalInfo.mainRepresentative, - business: entity.data, - ballerineEntityId: entity.ballerineEntityId - } - }`, - }, - ], - }, - }, - { - name: 'fetch_company_information', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/business/business-information`, - method: 'GET', - stateNames: [], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - token: flowConfig.tokenId, - registrationNumber: entity.data.registrationNumber, - countryCode: entity.data.country, - state: entity.data.additionalInfo.state || '', - vendor: 'open-corporates' - }`, - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - companyName: name, - taxIdentificationNumber: vat, - numberOfEmployees: numberOfEmployees, - businessType: companyType, - additionalInfo: {openCorporate: @} - }`, - }, - ], - }, - persistResponseDestination: 'entity.data', - successAction: 'company_information', - errorAction: 'company_information', - }, - { - name: 'send_collection_flow_finished', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/send-event/?token={flowConfig.tokenId}`, - method: 'POST', - stateNames: ['finish'], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{eventName: 'COLLECTION_FLOW_FINISHED'}`, - }, - ], - }, - }, - ], - }, -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-qa/ballerine-qa.template.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-qa/ballerine-qa.template.ts deleted file mode 100644 index eb5a84a350..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-qa/ballerine-qa.template.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { PasswordService } from '@/auth/password/password.service'; -import { generateBusinessesFilter } from 'prisma/data-migrations/templates'; -import { Template } from '../../template'; -import { generateWorkflowDefinition } from '../clipspay/workflow-definition/workflow-definition'; -import { generateDefinitionLogic } from '../clipspay/collection-flow/generate-definition-logic'; -import { composeUiDefinition } from '../clipspay/collection-flow/compose-ui-definition'; -import { ClipspayGenerationParams } from '../clipspay/types'; -import { generateKycSessionDefinition } from '../common/generate-kyc-email-process'; -import { CustomerService } from '@/customer/customer.service'; - -export class BallerineQATemplate extends Template { - async generate(): Promise { - console.log('not implemented'); - } - - async generateClipspayProject(): Promise { - const customer = await this.createCustomer(); - await this.createClipspayProject(customer.id); - } - - private async createClipspayProject(customerId: string) { - const { customer: customerParams } = this.params; - - const clipspayUser = await this.createUser(); - const project = await this.createProject(clipspayUser.id, customerId, 'clipspay-project'); - - // generate kyc - - const clipspayKycWorkflow = generateKycSessionDefinition( - this.prismaClient, - project.id, - customerParams.displayName, - ); - // generate kyb - const clipspayKybWorkflow = generateWorkflowDefinition( - this.params.definition.id, - this.params.definition.name, - project.id, - ); - - const kycWorkflowDefinition = await this.prismaClient.workflowDefinition.upsert({ - where: { id: clipspayKybWorkflow.id }, - create: clipspayKybWorkflow, - update: clipspayKybWorkflow, - }); - - const kybworkflowDefinition = await this.prismaClient.workflowDefinition.upsert({ - where: { id: clipspayKybWorkflow.id }, - create: clipspayKybWorkflow, - update: clipspayKybWorkflow, - }); - - await this.prismaClient.uiDefinition.create({ - data: { - ...composeUiDefinition( - kybworkflowDefinition.id, - generateDefinitionLogic(kybworkflowDefinition.id), - ), - projectId: project.id, - }, - }); - await this.createFilter(project.id, kybworkflowDefinition.id); - } - - private createCustomer() { - const { customer } = this.params; - - const customerService = this.app.get(CustomerService); - - return customerService.create({ - data: { - displayName: customer.displayName, - name: customer.name, - authenticationConfiguration: { - apiType: 'API_KEY', - authValue: customer.apiKey, - validUntil: '', - isValid: '', - }, - logoImageUri: customer.logoImageUrl, - }, - }); - } - - private async createUser() { - const { user } = this.params; - - const passwordService = this.app.get(PasswordService); - - return this.prismaClient.user.create({ - data: { - firstName: user.firstName, - lastName: user.lastName, - email: user.email, - password: await passwordService.hash(user.password), - roles: ['user'], - }, - }); - } - - private createProject(userId: string, customerId: string, clipspayProject: string) { - const { project } = this.params; - - return this.prismaClient.project.create({ - data: { - id: project.id, - name: clipspayProject, - customerId, - userToProjects: { - create: { - userId, - }, - }, - }, - }); - } - - private async createFilter(projectId: string, definitionId: string) { - const baseQuery = generateBusinessesFilter({ - filterName: this.params.filter.name, - definitionId, - projectId, - }); - - return this.prismaClient.filter.create({ - data: baseQuery, - }); - } -} diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-qa/index.ts b/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-qa/index.ts deleted file mode 100644 index 9d8ef1a2bf..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/ballerine-qa/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ballerine-qa.template'; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/definition/compose-child-associated-company-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/definition/compose-child-associated-company-definition.ts deleted file mode 100644 index 6451fbf190..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/definition/compose-child-associated-company-definition.ts +++ /dev/null @@ -1,153 +0,0 @@ -import { StateTag } from '@ballerine/common'; - -export const composeChildAssociatedCompanyDefinition = ({ - definitionId, - definitionName, - projectId, - crossEnvKey, -}: { - definitionId: string; - definitionName: string; - projectId?: string; - crossEnvKey?: string; -}) => { - return { - id: definitionId, - name: definitionName, - crossEnvKey, - version: 1, - definitionType: 'statechart-json', - definition: { - id: `${definitionId}_v1`, - predictableActionArguments: true, - initial: 'idle', - states: { - idle: { - on: { - START_ASSOCIATED_COMPANY_KYB: 'deliver_associated_company_email', - }, - }, - deliver_associated_company_email: { - tags: [StateTag.COLLECTION_FLOW], - on: { - EMAIL_SENT: [{ target: 'pending_associated_kyb_collection_flow' }], - EMAIL_FAILURE: [{ target: 'failed' }], - }, - }, - pending_associated_kyb_collection_flow: { - tags: [StateTag.COLLECTION_FLOW], - on: { - COLLECTION_FLOW_FINISHED: [{ target: 'manual_review' }], - }, - }, - manual_review: { - tags: [StateTag.MANUAL_REVIEW], - on: { - revision: 'deliver_associated_company_revision_email', - approve: 'approved', - }, - }, - approved: { - tags: [StateTag.APPROVED], - type: 'final' as const, - }, - failed: { - tags: [StateTag.FAILURE], - type: 'final' as const, - }, - deliver_associated_company_revision_email: { - tags: [StateTag.REVISION], - on: { - EMAIL_SENT: [{ target: 'revision' }], - EMAIL_FAILURE: [{ target: 'failed' }], - }, - }, - revision: { - tags: [StateTag.REVISION], - on: { - COLLECTION_FLOW_FINISHED: 'manual_review', - }, - }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'associated_company_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - method: 'POST', - stateNames: ['deliver_associated_company_email'], - successAction: 'EMAIL_SENT', - errorAction: 'EMAIL_FAILURE', - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - companyName: entity.data.companyName, - customerName: metadata.customerName, - kybCompanyName: entity.data.additionalInfo.kybCompanyName, - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - collectionFlowUrl: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token]), - supportEmail: join('',['support@',metadata.customerName]), - from: 'no-reply@ballerine.com', - receivers: [entity.data.additionalInfo.mainRepresentative.email], - templateId: 'd-706793b7bef041ee86bf12cf0359e76d', - adapter: '{secret.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - { - name: 'associated_company_revision_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - method: 'POST', - stateNames: ['deliver_associated_company_revision_email'], - successAction: 'EMAIL_SENT', - errorAction: 'EMAIL_FAILURE', - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - companyName: entity.data.companyName, - customerName: metadata.customerName, - kybCompanyName: entity.data.additionalInfo.kybCompanyName, - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - collectionFlowUrl: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token]), - supportEmail: join('',['support@',metadata.customerName]), - from: 'no-reply@ballerine.com', - receivers: [entity.data.additionalInfo.mainRepresentative.email], - templateId: 'd-90b00303f2654ea491a8e035fc4048c1', - adapter: '{secret.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - ], - }, - config: { - createCollectionFlowToken: true, - }, - isPublic: !projectId, - ...(projectId && { projectId }), - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/definition/compose-kyb-with-associated-companies.ts b/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/definition/compose-kyb-with-associated-companies.ts deleted file mode 100644 index 4a8e279756..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/definition/compose-kyb-with-associated-companies.ts +++ /dev/null @@ -1,425 +0,0 @@ -import { defaultContextSchema, StateTag } from '@ballerine/common'; -import { CHILD_KYB_DONE_RULE, KYC_DONE_RULE } from '../../../utils/rules'; - -export const composeKybWithAssociatedCompanies = ({ - projectId, - kybChildWorkflowDefinitionId, - kycChildWorkflowDefinitionId, - definitionName, - definitionId, -}: { - projectId: string; - definitionName: string; - definitionId: string; - kybChildWorkflowDefinitionId: string; - kycChildWorkflowDefinitionId: string; -}) => { - const noAssociatedCompaniesRule = `entity.data.additionalInfo.associatedCompanies == null || length(entity.data.additionalInfo.associatedCompanies) == \`0\``; - const noAssociatedCompaniesInProcessRule = `entity.childWorkflows.${kybChildWorkflowDefinitionId} == null || length(entity.data.additionalInfo.${kybChildWorkflowDefinitionId}) == \`0\``; - - return { - id: definitionId, - name: definitionName, - version: 1, - definitionType: 'statechart-json', - definition: { - id: `${definitionId}_v1`, - predictableActionArguments: true, - initial: 'idle', - context: { - documents: [], - }, - states: { - idle: { - on: { - START: 'deliver_collection_flow_email', - }, - }, - deliver_collection_flow_email: { - on: { - INVITATION_SENT: [{ target: 'pending_kyb_collection_flow' }], - INVITATION_FAILURE: [{ target: 'failed' }], - }, - }, - pending_kyb_collection_flow: { - tags: [StateTag.COLLECTION_FLOW], - on: { - COLLECTION_FLOW_FINISHED: [ - { - target: 'run_ubos', - cond: { - type: 'jmespath', - options: { - rule: noAssociatedCompaniesRule, - }, - }, - }, - { target: 'generate_associated_companies' }, - ], - }, - }, - generate_associated_companies: { - tags: [StateTag.COLLECTION_FLOW], - on: { - ASSOCIATED_COMPANIES_GENERATED: [{ target: 'run_ubos' }], - ASSOCIATED_COMPANIES_FAILED: [{ target: 'failed' }], - }, - }, - run_ubos: { - tags: [StateTag.COLLECTION_FLOW], - on: { - EMAIL_SENT_TO_UBOS: [{ target: 'pending_kyc_response_to_finish' }], - FAILED_EMAIL_SENT_TO_UBOS: [{ target: 'failed' }], - }, - }, - pending_kyc_response_to_finish: { - tags: [StateTag.PENDING_PROCESS], - on: { - KYC_RESPONDED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE(kycChildWorkflowDefinitionId)} && - (${noAssociatedCompaniesRule} || ${noAssociatedCompaniesInProcessRule}) || - (${CHILD_KYB_DONE_RULE(kybChildWorkflowDefinitionId)})`, - }, - }, - }, - { - target: 'pending_kyb_response_to_finish', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE(kycChildWorkflowDefinitionId)} && - !(${noAssociatedCompaniesRule}) && !(${CHILD_KYB_DONE_RULE( - kybChildWorkflowDefinitionId, - )})`, - }, - }, - }, - ], - reject: 'rejected', - revision: 'deliver_revision_email', - }, - }, - pending_kyb_response_to_finish: { - tags: [StateTag.COLLECTION_FLOW], - on: { - ASSOCIATED_COMPANY_KYB_FINISHED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: CHILD_KYB_DONE_RULE(kybChildWorkflowDefinitionId), - }, - }, - }, - ], - reject: 'rejected', - revision: 'deliver_revision_email', - }, - }, - manual_review: { - tags: [StateTag.MANUAL_REVIEW], - on: { - approve: 'approved', - reject: 'rejected', - revision: 'deliver_revision_email', - KYC_REVISION: 'revision', - ASSOCIATED_COMPANY_IN_REVISION: 'revision', - }, - }, - deliver_revision_email: { - tags: [StateTag.REVISION], - on: { - EMAIL_SENT: 'revision', - EMAIL_FAILURE: 'failed', - }, - }, - failed: { - tags: [StateTag.FAILURE], - type: 'final' as const, - }, - approved: { - tags: [StateTag.APPROVED], - type: 'final' as const, - }, - revision: { - tags: [StateTag.REVISION], - on: { - COLLECTION_FLOW_FINISHED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE(kycChildWorkflowDefinitionId)} && - (${noAssociatedCompaniesRule} || ${noAssociatedCompaniesInProcessRule}) || - (${CHILD_KYB_DONE_RULE(kybChildWorkflowDefinitionId)})`, - }, - }, - }, - ], - KYC_RESPONDED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE(kycChildWorkflowDefinitionId)} && - (${noAssociatedCompaniesRule} || ${noAssociatedCompaniesInProcessRule}) || - (${CHILD_KYB_DONE_RULE(kybChildWorkflowDefinitionId)})`, - }, - }, - }, - ], - reject: 'rejected', - }, - }, - rejected: { - tags: [StateTag.REJECTED], - type: 'final' as const, - }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'collection_invite_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - successAction: 'INVITATION_SENT', - errorAction: 'INVITATION_FAILURE', - method: 'POST', - stateNames: ['deliver_collection_flow_email'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - companyName: entity.data.companyName, - customerName: metadata.customerName, - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - collectionFlowUrl: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token]), - from: 'no-reply@ballerine.com', - receivers: [entity.data.additionalInfo.mainRepresentative.email], - templateId: 'd-8949519316074e03909042cfc5eb4f02', - adapter: '{secret.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - { - name: 'resubmission_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - method: 'POST', - successAction: 'EMAIL_SENT', - errorAction: 'EMAIL_FAILURE', - stateNames: ['deliver_revision_email'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - // #TODO: create new token (new using old one) - mapping: `{ - kybCompanyName: entity.data.companyName, - customerCompanyName: metadata.customerName, - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - resubmissionLink: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token]), - supportEmail: join('',['support@',metadata.customerName,'.com']), - from: 'no-reply@ballerine.com', - name: join(' ',[metadata.customerName,'Team']), - receivers: [entity.data.additionalInfo.mainRepresentative.email], - templateId: 'd-7305991b3e5840f9a14feec767ea7301', - revisionReason: documents[].decision[].revisionReason | [0], - adapter: '${process.env.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - ], - childWorkflowPlugins: [ - { - pluginKind: 'child', - name: 'veriff_kyc_child_plugin', - definitionId: kycChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: `{entity: {data: @, type: 'individual'}}`, - }, - { - transformer: 'helper', - mapping: [ - { - source: 'entity.data', - target: 'entity.data', - method: 'omit', - value: ['workflowRuntimeId', 'workflowRuntimeConfig'], - }, - ], - }, - ], - initEvent: 'start', - }, - { - pluginKind: 'child', - name: 'associated_company_child_plugin', - definitionId: kybChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: `{entity: {data: @, type: 'business'}}`, - }, - { - transformer: 'helper', - mapping: [ - { - source: 'entity.data', - target: 'entity.data', - method: 'omit', - value: ['workflowRuntimeId', 'workflowRuntimeConfig'], - }, - ], - }, - ], - }, - ], - commonPlugins: [ - { - pluginKind: 'iterative', - name: 'ubos_iterative', - actionPluginName: 'veriff_kyc_child_plugin', - stateNames: ['run_ubos'], - iterateOn: [ - { - transformer: 'jmespath', - mapping: 'entity.data.additionalInfo.ubos', - }, - ], - successAction: 'EMAIL_SENT_TO_UBOS', - errorAction: 'FAILED_EMAIL_SENT_TO_UBOS', - }, - { - pluginKind: 'iterative', - name: 'associated_company_iterative', - actionPluginName: 'associated_company_child_plugin', - stateNames: ['generate_associated_companies'], - iterateOn: [ - { - transformer: 'helper', - mapping: [ - { - source: 'entity.data.additionalInfo.associatedCompanies', - target: 'entity.data.additionalInfo.associatedCompanies', - method: 'mergeArrayEachItemWithValue', - options: { - mapJmespath: 'entity.data.additionalInfo.associatedCompanies', - mergeWithJmespath: - '{ additionalInfo: { customerName: metadata.customerName, kybCompanyName: entity.data.companyName } }', - }, - }, - ], - }, - { - transformer: 'jmespath', - mapping: 'entity.data.additionalInfo.associatedCompanies', - }, - ], - successAction: 'ASSOCIATED_COMPANIES_GENERATED', - errorAction: 'ASSOCIATED_COMPANIES_FAILED', - }, - ], - }, - config: { - isAssociatedCompanyKybEnabled: true, - initialEvent: 'START', - createCollectionFlowToken: true, - childCallbackResults: [ - { - definitionId: kybChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: '{childEntity: entity.data}', // jmespath - }, - ], - persistenceStates: ['manual_review'], - deliverEvent: 'ASSOCIATED_COMPANY_KYB_FINISHED', - }, - { - definitionId: kybChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: '{childEntity: entity.data}', // jmespath - }, - ], - persistenceStates: ['pending_associated_kyb_collection_flow'], - deliverEvent: 'ASSOCIATED_COMPANY_IN_KYB', - }, - { - definitionId: kybChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: '{childEntity: entity.data}', // jmespath - }, - ], - persistenceStates: ['revision'], - deliverEvent: 'revision', - }, - { - definitionId: kycChildWorkflowDefinitionId, - persistenceStates: ['kyc_manual_review'], - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - deliverEvent: 'KYC_RESPONDED', - }, - { - definitionId: kycChildWorkflowDefinitionId, - persistenceStates: ['revision_email_sent'], - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - deliverEvent: 'KYC_REVISION', - }, - ], - }, - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - isPublic: !projectId, - projectId: projectId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/index.ts b/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/index.ts deleted file mode 100644 index c5173d32d7..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './kyb-with-associated-companies.template'; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/kyb-with-associated-companies.template.ts b/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/kyb-with-associated-companies.template.ts deleted file mode 100644 index 868e97bf60..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/kyb-with-associated-companies.template.ts +++ /dev/null @@ -1,158 +0,0 @@ -import { Template } from '../../template'; -import { ChildAssociatedCompanyTemplateParams } from './types'; -import { PasswordService } from '@/auth/password/password.service'; -import { generateBusinessesFilter } from '../../filters/generate-businesses-filter'; -import { composeDemoChildKycDefinition } from '../demo/workflow-definition/compose-demo-child-kyc-definition'; -import { composeUiDefinition } from './ui-definition/compose-ui-definition'; -import { composeKybWithAssociatedCompanies } from './definition/compose-kyb-with-associated-companies'; -import { composeChildAssociatedCompanyDefinition } from './definition/compose-child-associated-company-definition'; -import { composeAssociatedUiDefinition } from './ui-definition/compose-associated-ui-definition'; -import { validateDefinitionLogic } from '@ballerine/workflow-core'; -import { CustomerService } from '@/customer/customer.service'; - -export class KybWithAssociatedCompaniesTemplate extends Template { - async generate() { - const customer = await this.createCustomer(); - const user = await this.createUser(); - - const project = await this.createProject(user.id, customer.id); - - const demoKycChildDefinition = composeDemoChildKycDefinition( - `${customer.name}_kyc_email_session`, - `${customer.name}_kyc_email_session`, - project.id, - ); - - const childAssociatedCompanyDefinition = composeChildAssociatedCompanyDefinition({ - definitionId: `${customer.name}_child_associated_company`, - definitionName: `${customer.name}_child_associated_company`, - projectId: project.id, - }); - - const parentKybDefinition = composeKybWithAssociatedCompanies({ - definitionId: `${customer.name}_kyb_with_associated_companies`, - definitionName: `${customer.name}_kyb_with_associated_companies`, - projectId: project.id, - kybChildWorkflowDefinitionId: childAssociatedCompanyDefinition.id, - kycChildWorkflowDefinitionId: demoKycChildDefinition.id, - }); - - validateDefinitionLogic(demoKycChildDefinition); - await this.prismaClient.workflowDefinition.create({ - data: { - ...demoKycChildDefinition, - }, - }); - - validateDefinitionLogic(childAssociatedCompanyDefinition); - await this.prismaClient.workflowDefinition.create({ - data: { - ...childAssociatedCompanyDefinition, - }, - }); - - validateDefinitionLogic(parentKybDefinition, { - [parentKybDefinition.id]: {}, - childWorkflows: { - [childAssociatedCompanyDefinition.id]: {}, - [demoKycChildDefinition.id]: {}, - }, - }); - - const workflowDefinition = await this.prismaClient.workflowDefinition.create({ - data: { - ...parentKybDefinition, - }, - }); - - await this.createMainKybUIDefinition(workflowDefinition.id, project.id); - await this.createAssociatedKybUIDefinition(childAssociatedCompanyDefinition.id, project.id); - - await this.createFilter(project.id, workflowDefinition.id, this.params.filter.name); - - return Promise.resolve(); - } - - private createCustomer() { - const { customer } = this.params; - - const customerService = this.app.get(CustomerService); - - return customerService.create({ - data: { - id: customer.id, - displayName: customer.displayName, - name: customer.name, - authenticationConfiguration: { - apiType: 'API_KEY', - authValue: customer.apiKey, - validUntil: '', - isValid: '', - }, - logoImageUri: customer.logoImageUrl, - }, - }); - } - - private async createUser() { - const { user } = this.params; - - const passwordService = this.app.get(PasswordService); - - return this.prismaClient.user.create({ - data: { - firstName: user.firstName, - lastName: user.lastName, - email: user.email, - password: await passwordService.hash(user.password), - roles: ['user'], - }, - }); - } - - private createProject(userId: string, customerId: string) { - const { project } = this.params; - - return this.prismaClient.project.create({ - data: { - id: project.id, - name: project.id, - customerId, - userToProjects: { - create: { - userId, - }, - }, - }, - }); - } - - private async createMainKybUIDefinition(workflowDefinitionId: string, projectId: string) { - return this.prismaClient.uiDefinition.create({ - data: { - ...composeUiDefinition(workflowDefinitionId), - projectId, - }, - }); - } - private async createAssociatedKybUIDefinition(workflowDefinitionId: string, projectId: string) { - return this.prismaClient.uiDefinition.create({ - data: { - ...composeAssociatedUiDefinition(workflowDefinitionId), - projectId, - }, - }); - } - - private async createFilter(projectId: string, definitionId: string, filterName: string) { - const baseQuery = generateBusinessesFilter({ - filterName: filterName, - definitionId, - projectId, - }); - - return this.prismaClient.filter.create({ - data: baseQuery, - }); - } -} diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/types.ts b/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/types.ts deleted file mode 100644 index ac1ccccbdb..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/types.ts +++ /dev/null @@ -1,46 +0,0 @@ -interface DemoCustomer { - id?: string; - displayName: string; - name: string; - apiKey: string; - logoImageUrl: string; -} - -interface DemoUser { - firstName: string; - lastName: string; - email: string; - password: string; -} - -interface DemoProject { - id: string; -} - -interface DemoFilter { - name: string; -} -interface DefinitionWithChildrenConfig { - parentKybDefinitionId: string; - kybDefinitionName: string; - childKycDefinitionId: string; - childKycDefinitionName: string; -} - -export interface DemoTemplateParams { - // Customer - customer: DemoCustomer; - - // User - user: DemoUser; - - // Project - project: DemoProject; - - // Filter - filter: DemoFilter; - - definitionWithChildren?: DefinitionWithChildrenConfig; -} - -export type ChildAssociatedCompanyTemplateParams = DemoTemplateParams; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/3-associated-company-documents.ts b/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/3-associated-company-documents.ts deleted file mode 100644 index f606c352fe..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/3-associated-company-documents.ts +++ /dev/null @@ -1,193 +0,0 @@ -const validationSchema = [ - { - documentId: 'certificate-of-incorporation', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'business-utility-bill', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, -]; - -export const AssociatedCompanyDocumentsPage = { - type: 'page', - number: 3, - stateName: 'company_documents', - name: 'text.companyDocuments', - pageValidation: [ - { - type: 'destination-engine', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyDocuments', - }, - }, - { - type: 'h3', - options: { - text: 'text.merchantCompanyDocuments', - }, - }, - ], - }, - { - type: 'json-form', - name: 'associated-company-documents-form', - options: { - jsonFormDefinition: { - required: ['document-certificate-of-incorporation', 'document-business-utility-bill'], - }, - }, - elements: [ - { - name: 'document-certificate-of-incorporation', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.documents.certificateOfIncorporation.label', - description: 'text.documents.certificateOfIncorporation.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'certificate-of-incorporation', - category: 'proof_of_registration', - type: 'certificate_of_incorporation', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-business-utility-bill', - type: 'document', - valueDestination: 'documents[1].pages[0].ballerineFileId', - options: { - label: 'text.documents.businessUtilityBill.label', - description: 'text.documents.businessUtilityBill.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'business-utility-bill', - category: 'proof_of_ownership', - type: 'business_utility_bill', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'accuracy-description', - options: { - descriptionRaw: 'text.emailDescription', - }, - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'Finish', - }, - availableOn: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'jmespath', - value: '!contains(uiState.elements.*.isLoading,`true`)', - }, - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.hasConfirmed' }, true, false], - }, - }, - { - type: 'json-logic', - value: { '!==': [{ var: 'uiState.isLoading' }, true, false] }, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'destination-engine', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionPlugin', - params: { pluginName: 'sync_workflow_runtime', debounce: 50 }, - dispatchOn: { - uiEvents: [ - { - event: 'onChange', - uiElementName: 'document-certificate-of-incorporation', - }, - { - event: 'onChange', - uiElementName: 'document-business-utility-bill', - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/6-company-ownership-with-associated.ts b/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/6-company-ownership-with-associated.ts deleted file mode 100644 index 2ad107f186..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/6-company-ownership-with-associated.ts +++ /dev/null @@ -1,668 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - default: {}, - if: { - properties: { - thereNoCompaniesWithMoreThan25: { - enum: [true], - }, - }, - }, - then: { - required: ['ubos'], - errorMessage: { - required: { - ubos: 'errorMessage.required.ubos', - }, - }, - }, - else: { - required: ['ubos', 'associatedCompanies'], - properties: { - associatedCompanies: { - minItems: 1, - }, - }, - errorMessage: { - required: { - ubos: 'errorMessage.required.ubos', - associatedCompanies: 'errorMessage.required.companies', - }, - }, - }, - properties: { - thereNoCompaniesWithMoreThan25: { - type: 'boolean', - default: false, - }, - ubos: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'errorMessage.required.ubos', - }, - items: { - type: 'object', - required: ['firstName', 'lastName', 'email'], - properties: { - firstName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['role', 'dateOfBirth'], - errorMessage: { - required: { - role: 'errorMessage.error.requiredField', - dateOfBirth: 'errorMessage.error.requiredField', - }, - }, - properties: { - role: { - type: 'string', - }, - dateOfBirth: { - type: 'string', - }, - }, - }, - }, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - email: 'errorMessage.required.email', - }, - }, - }, - }, - associatedCompanies: { - type: 'array', - errorMessage: { - minItems: 'errorMessage.required.companies', - }, - items: { - type: 'object', - required: ['registrationNumber', 'country', 'companyName'], - errorMessage: { - required: { - registrationNumber: 'errorMessage.required.companyRegistrationNumber', - country: 'errorMessage.required.country', - companyName: 'errorMessage.required.companyName', - }, - }, - properties: { - registrationNumber: { - type: 'string', - minLength: 4, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.companyRegistrationNumber', - maxLength: 'errorMessage.maxLength.companyRegistrationNumber', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength.country', - pattern: 'errorMessage.maxLength.pattern', - }, - }, - companyName: { - type: 'string', - minLength: 2, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.companyName', - maxLength: 'errorMessage.maxLength.companyName', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['associationRelationship', 'mainRepresentative'], - errorMessage: { - required: { - associationRelationship: 'errorMessage.error.requiredField', - mainRepresentative: 'errorMessage.error.requiredField', - }, - }, - properties: { - associationRelationship: { - type: 'string', - }, - mainRepresentative: { - type: 'object', - default: {}, - required: ['firstName', 'lastName', 'email'], - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - email: 'errorMessage.required.email', - }, - }, - properties: { - firstName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const CompanyOwnershipWithAssociatedCPage = { - type: 'page', - number: 6, - stateName: 'company_ownership', - name: 'text.companyOwnership', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyOwnership', - }, - }, - { - type: 'h3', - options: { - text: 'text.shareholders', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'im-shareholder-checkbox-form', - options: { - jsonFormDefinition: { - required: ['im-shareholder-checkbox'], - }, - }, - elements: [ - { - type: 'checkbox', - name: 'im-shareholder-checkbox', - valueDestination: 'entity.data.additionalInfo.imShareholder', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.imShareholder', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'checkbox-description-1', - options: { - descriptionRaw: 'text.shareholdersDescription', - }, - }, - { - type: 'json-form', - name: 'ubos-form', - valueDestination: 'entity.data.additionalInfo.ubos', - options: { - description: 'text.shareholdersDescription', - jsonFormDefinition: { - title: 'text.shareholder', - type: 'array', - required: [ - 'ubos:first-name-input', - 'ubos:last-name-input', - 'ubos:title-input', - 'ubos:email-input', - 'ubos:date-of-birth-input', - ], - }, - uiSchema: { - titleTemplate: 'text.uboIndex', - }, - insertionParams: { - insertionStrategy: 'array', - destination: 'entity.data.additionalInfo.ubos', - schema: { - firstName: 'entity.data.additionalInfo.mainRepresentative.firstName', - lastName: 'entity.data.additionalInfo.mainRepresentative.lastName', - email: 'entity.data.additionalInfo.mainRepresentative.email', - }, - bindingAnchorDestination: 'additionalInfo.__isGeneratedAutomatically', - disableElements: [ - { - elementName: 'ubos:first-name-input', - atIndex: 0, - }, - { - elementName: 'ubos:last-name-input', - atIndex: 0, - }, - { - elementName: 'ubos:email-input', - atIndex: 0, - }, - ], - insertWhen: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.imShareholder' }, true], - }, - }, - ], - removeWhen: [ - { - type: 'json-logic', - value: { - if: [ - { - var: 'entity.data.additionalInfo.imShareholder', - }, - false, - true, - ], - }, - }, - ], - }, - }, - elements: [ - { - name: 'ubos:first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].firstName', //entity.data.additionalInfo.ubos[0].firstName - options: { - label: 'text.firstName', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].lastName', - options: { - label: 'text.lastName', - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:title-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.role', - options: { - label: 'text.jobTitle.label', - hint: 'text.jobTitle.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:date-of-birth-input', - type: 'json-form:date', - valueDestination: - 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.dateOfBirth', - options: { - label: 'text.dateOfBirth.label', - hint: 'DD/MM/YYYY', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - }, - }, - { - name: 'ubos:email-input', - type: 'json-form:email', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - ], - }, - { - type: 'divider', - }, - { - type: 'h3', - options: { - text: 'text.associatedCompanies', - classNames: ['padding-top-10'], - }, - }, - { - type: 'description', - options: { - descriptionRaw: 'text.associatedCompaniesDescription', - }, - }, - { - type: 'json-form', - name: 'there-no-companies-with-more-than-25-form', - elements: [ - { - type: 'checkbox', - name: 'there-no-companies-with-more-than-25', - valueDestination: 'entity.data.additionalInfo.thereNoCompaniesWithMoreThan25', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.noCompaniesWithMoreThan', - uiSchema: { - 'ui:label': false, - }, - }, - availableOn: [ - { - type: 'json-logic', - value: { - if: [ - { - '>=': [ - { - var: 'entity.data.additionalInfo.associatedCompanies.length', - }, - 1, - ], - }, - false, - true, - ], - }, - }, - ], - }, - ], - }, - { - type: 'json-form', - name: 'companies-form', - valueDestination: 'entity.data.additionalInfo.associatedCompanies', - options: { - description: 'text.shareholdersDescription', - jsonFormDefinition: { - title: 'text.shareholder', - type: 'array', - required: [ - 'associatedCompanies:company-registration-number-input', - 'associatedCompanies:company-country-input', - 'associatedCompanies:company-legal-name-input', - 'associatedCompanies:company-association-relationship-input', - 'associatedCompanies:company-main-representative-first-name-input', - 'associatedCompanies:company-main-representative-last-name-input', - 'associatedCompanies:company-main-representative-email-input', - ], - }, - uiSchema: { - titleTemplate: 'text.associatedCompanyIndex', - }, - canAdd: [ - { - type: 'json-logic', - value: { - '!==': [ - { - var: 'entity.data.additionalInfo.thereNoCompaniesWithMoreThan25', - }, - true, - false, - ], - }, - }, - ], - }, - elements: [ - { - name: 'associatedCompanies:company-registration-number-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].registrationNumber', //entity.data.additionalInfo.ubos[0].firstName - options: { - label: 'text.companyRegistrationNumber.label', - hint: 'text.companyRegistrationNumber.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'associatedCompanies:company-country-input', - type: 'dropdown', - valueDestination: 'entity.data.additionalInfo.associatedCompanies[{INDEX}].country', - options: { - label: 'text.registeredCountry.label', - hint: 'text.registeredCountry.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - }, - }, - }, - { - name: 'associatedCompanies:company-legal-name-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].companyName', - options: { - label: 'text.companyLegalName.label', - hint: 'text.companyLegalName.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'associatedCompanies:company-association-relationship-input', - type: 'json-form:date', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].additionalInfo.associationRelationship', - options: { - label: 'text.relationship.label', - hint: 'text.relationship.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'RelationshipDropdown', - 'ui:label': true, - }, - companyNameDestination: 'entity.data.companyName', - }, - }, - { - name: 'associatedCompanies:company-main-representative-first-name-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].additionalInfo.mainRepresentative.firstName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.representativeFirstName.label', - hint: 'text.representativeFirstName.hint', - }, - }, - { - name: 'associatedCompanies:company-main-representative-last-name-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].additionalInfo.mainRepresentative.lastName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.representativeLastName.label', - hint: 'text.representativeLastName.hint', - }, - }, - { - name: 'associatedCompanies:company-main-representative-email-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].additionalInfo.mainRepresentative.email', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.representativeEmail.label', - hint: 'text.representativeEmail.hint', - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/associated-ui-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/associated-ui-definition.ts deleted file mode 100644 index 685a9c1cd4..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/associated-ui-definition.ts +++ /dev/null @@ -1,142 +0,0 @@ -export const definition = { - definitionType: 'statechart-json', - definition: { - id: 'dynamic_collection_flow', - predictableActionArguments: true, - initial: 'company_information', - context: {}, - states: { - company_information: { - on: { - NEXT: 'business_address_information', - }, - }, - business_address_information: { - on: { - NEXT: 'company_documents', - PREVIOUS: 'company_information', - }, - }, - company_documents: { - on: { - NEXT: 'finish', - PREVIOUS: 'business_address_information', - }, - }, - finish: { type: 'final' }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'update_end_user', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/end-user?token={flowConfig.tokenId}`, - method: 'POST', - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - stateNames: [], - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - lastName: entity.data.additionalInfo.mainRepresentative.lastName, - additionalInfo: {title: entity.data.additionalInfo.mainRepresentative.additionalInfo.jobTitle}, - phone: entity.data.additionalInfo.mainRepresentative.phone, - dateOfBirth: entity.data.additionalInfo.mainRepresentative.dateOfBirth - }`, - }, - ], - }, - }, - { - name: 'sync_workflow_runtime', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/sync/?token={flowConfig.tokenId}`, - method: 'PUT', - stateNames: [ - 'personal_details', - 'company_information', - 'business_address_information', - 'company_activity', - 'bank_information', - 'company_ownership', - 'company_documents', - 'finish', - ], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - data: { - context: @, - endUser: entity.data.additionalInfo.mainRepresentative, - business: entity.data, - ballerineEntityId: entity.ballerineEntityId - } - }`, - }, - ], - }, - }, - { - name: 'fetch_company_information', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/business/business-information`, - method: 'GET', - stateNames: [], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - token: flowConfig.tokenId, - registrationNumber: entity.data.registrationNumber, - countryCode: entity.data.country, - state: entity.data.additionalInfo.state || '', - vendor: 'open-corporates' - }`, - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - companyName: name, - taxIdentificationNumber: vat, - numberOfEmployees: numberOfEmployees, - businessType: companyType, - additionalInfo: {openCorporate: @} - }`, - }, - ], - }, - persistResponseDestination: 'entity.data', - successAction: 'company_information', - errorAction: 'company_information', - }, - { - name: 'send_collection_flow_finished', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/send-event/?token={flowConfig.tokenId}`, - method: 'POST', - stateNames: ['finish'], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{eventName: 'COLLECTION_FLOW_FINISHED'}`, - }, - ], - }, - }, - ], - }, -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/compose-associated-ui-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/compose-associated-ui-definition.ts deleted file mode 100644 index 22a02cc79e..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/compose-associated-ui-definition.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Prisma } from '@prisma/client'; -import { CompanyInfoPage } from '../../demo/ui-definition/2-company-info-page'; -import { BusinessAddressInfoPage } from '../../demo/ui-definition/3-business-address-info-page'; -import { AssociatedCompanyDocumentsPage } from './3-associated-company-documents'; -import { definition } from './associated-ui-definition'; - -export const composeAssociatedUiDefinition = ( - workflowDefinitionId: string, -): Pick< - Prisma.UiDefinitionUncheckedCreateInput, - 'uiContext' | 'uiSchema' | 'definition' | 'workflowDefinitionId' -> => { - return { - uiContext: 'collection_flow', - uiSchema: { - elements: [ - { ...CompanyInfoPage, number: 1 }, - { ...BusinessAddressInfoPage, number: 2 }, - AssociatedCompanyDocumentsPage, - ], - }, - definition: definition, - workflowDefinitionId: workflowDefinitionId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/compose-ui-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/compose-ui-definition.ts deleted file mode 100644 index 558d13dbf7..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/compose-ui-definition.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Prisma } from '@prisma/client'; -import { PersonalInfoPage } from '../../demo/ui-definition/1-personal-info-page'; -import { CompanyInfoPage } from '../../demo/ui-definition/2-company-info-page'; -import { BusinessAddressInfoPage } from '../../demo/ui-definition/3-business-address-info-page'; -import { CompanyActivityPage } from '../../demo/ui-definition/4-company-activity'; -import { BankInformationPage } from '../../demo/ui-definition/5-bank-information'; -import { CompanyDocumentsPage } from '../../demo/ui-definition/7-company-documents'; -import { CompanyOwnershipWithAssociatedCPage } from './6-company-ownership-with-associated'; -import { definition } from '../../demo/ui-definition/defintion-logic'; - -export const composeUiDefinition = ( - workflowDefinitionId: string, -): Pick< - Prisma.UiDefinitionUncheckedCreateInput, - 'uiContext' | 'uiSchema' | 'definition' | 'workflowDefinitionId' -> => { - return { - uiContext: 'collection_flow', - uiSchema: { - elements: [ - PersonalInfoPage, - CompanyInfoPage, - BusinessAddressInfoPage, - CompanyActivityPage, - BankInformationPage, - CompanyOwnershipWithAssociatedCPage, - CompanyDocumentsPage, - ], - }, - definition: definition, - workflowDefinitionId: workflowDefinitionId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/parent-kyb-ui-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/parent-kyb-ui-definition.ts deleted file mode 100644 index 9876852c8f..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/child-associated-company/ui-definition/parent-kyb-ui-definition.ts +++ /dev/null @@ -1,166 +0,0 @@ -export const definition = { - definitionType: 'statechart-json', - definition: { - id: 'dynamic_collection_flow', - predictableActionArguments: true, - initial: 'personal_details', - context: {}, - states: { - personal_details: { - on: { - NEXT: 'company_information', - }, - }, - company_information: { - on: { - NEXT: 'business_address_information', - PREVIOUS: 'personal_details', - }, - }, - business_address_information: { - on: { - NEXT: 'company_activity', - PREVIOUS: 'company_information', - }, - }, - company_activity: { - on: { - NEXT: 'bank_information', - PREVIOUS: 'business_address_information', - }, - }, - bank_information: { - on: { - NEXT: 'company_ownership', - PREVIOUS: 'company_activity', - }, - }, - company_ownership: { - on: { - NEXT: 'company_documents', - PREVIOUS: 'bank_information', - }, - }, - company_documents: { - on: { - NEXT: 'finish', - PREVIOUS: 'company_ownership', - }, - }, - finish: { type: 'final' }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'update_end_user', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/end-user?token={flowConfig.tokenId}`, - method: 'POST', - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - stateNames: [], - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - lastName: entity.data.additionalInfo.mainRepresentative.lastName, - additionalInfo: {title: entity.data.additionalInfo.mainRepresentative.additionalInfo.jobTitle}, - phone: entity.data.additionalInfo.mainRepresentative.phone, - dateOfBirth: entity.data.additionalInfo.mainRepresentative.dateOfBirth - }`, - }, - ], - }, - }, - { - name: 'sync_workflow_runtime', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/sync/?token={flowConfig.tokenId}`, - method: 'PUT', - stateNames: [ - 'personal_details', - 'company_information', - 'business_address_information', - 'company_activity', - 'bank_information', - 'company_ownership', - 'company_documents', - 'finish', - ], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - data: { - context: @, - endUser: entity.data.additionalInfo.mainRepresentative, - business: entity.data, - ballerineEntityId: entity.ballerineEntityId - } - }`, - }, - ], - }, - }, - { - name: 'fetch_company_information', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/business/business-information`, - method: 'GET', - stateNames: [], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - token: flowConfig.tokenId, - registrationNumber: entity.data.registrationNumber, - countryCode: entity.data.country, - state: entity.data.additionalInfo.state || '', - vendor: 'open-corporates' - }`, - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - companyName: name, - taxIdentificationNumber: vat, - numberOfEmployees: numberOfEmployees, - businessType: companyType, - additionalInfo: {openCorporate: @} - }`, - }, - ], - }, - persistResponseDestination: 'entity.data', - successAction: 'company_information', - errorAction: 'company_information', - }, - { - name: 'send_collection_flow_finished', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/send-event/?token={flowConfig.tokenId}`, - method: 'POST', - stateNames: ['finish'], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{eventName: 'COLLECTION_FLOW_FINISHED'}`, - }, - ], - }, - }, - ], - }, -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/clipspay.template.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/clipspay.template.ts deleted file mode 100644 index f1a858dd5b..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/clipspay.template.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { PasswordService } from '@/auth/password/password.service'; -import { generateBusinessesFilter } from 'prisma/data-migrations/templates'; -import { Template } from '../../template'; -import { composeUiDefinition } from './collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from './collection-flow/generate-definition-logic'; -import { ClipspayGenerationParams } from './types'; -import { generateWorkflowDefinition } from './workflow-definition/workflow-definition'; -import { CustomerService } from '@/customer/customer.service'; - -export class ClipspayTemplate extends Template { - async generate(): Promise { - const customer = await this.createCustomer(); - const user = await this.createUser(); - - const project = await this.createProject(user.id, customer.id); - - const clipspayWorkflow = generateWorkflowDefinition( - this.params.definition.id, - this.params.definition.name, - project.id, - ); - - const workflowDefinition = await this.prismaClient.workflowDefinition.upsert({ - where: { id: clipspayWorkflow.id }, - create: clipspayWorkflow, - update: clipspayWorkflow, - }); - - await this.createUIDefinition(workflowDefinition.id, project.id); - await this.createFilter(project.id, workflowDefinition.id); - } - - private createCustomer() { - const { customer } = this.params; - - const customerService = this.app.get(CustomerService); - - return customerService.create({ - data: { - displayName: customer.displayName, - name: customer.name, - authenticationConfiguration: { - apiType: 'API_KEY', - authValue: customer.apiKey, - validUntil: '', - isValid: '', - }, - logoImageUri: customer.logoImageUrl, - }, - }); - } - - private async createUser() { - const { user } = this.params; - - const passwordService = this.app.get(PasswordService); - - return this.prismaClient.user.create({ - data: { - firstName: user.firstName, - lastName: user.lastName, - email: user.email, - password: await passwordService.hash(user.password), - roles: ['user'], - }, - }); - } - - private createProject(userId: string, customerId: string) { - const { project } = this.params; - - return this.prismaClient.project.create({ - data: { - id: project.id, - name: project.id, - customerId, - userToProjects: { - create: { - userId, - }, - }, - }, - }); - } - - private async createUIDefinition(workflowDefinitionId: string, projectId: string) { - return this.prismaClient.uiDefinition.create({ - data: { - ...composeUiDefinition(workflowDefinitionId, generateDefinitionLogic(workflowDefinitionId)), - projectId, - }, - }); - } - - private async createFilter(projectId: string, definitionId: string) { - const baseQuery = generateBusinessesFilter({ - filterName: this.params.filter.name, - definitionId, - projectId, - }); - - return this.prismaClient.filter.create({ - data: baseQuery, - }); - } -} diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/1-personal-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/1-personal-info-page.ts deleted file mode 100644 index 1e83c8572b..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/1-personal-info-page.ts +++ /dev/null @@ -1,264 +0,0 @@ -const validationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['mainRepresentative'], - properties: { - mainRepresentative: { - type: 'object', - required: ['phone', 'dateOfBirth', 'firstName', 'lastName', 'additionalInfo'], - errorMessage: { - required: { - phone: 'errorMessage.required.phone', - dateOfBirth: 'errorMessage.required.dateOfBirth', - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - additionalInfo: 'errorMessage.required.additionalInfo', - }, - }, - properties: { - phone: { - type: 'string', - pattern: '^[+]?[0-9]{10,15}$', - errorMessage: { - pattern: 'errorMessage.pattern.phone', - }, - }, - dateOfBirth: { - type: 'string', - errorMessage: { - type: 'errorMessage.type.dateOfBirth', - }, - }, - firstName: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - }, - }, - additionalInfo: { - type: 'object', - required: ['jobTitle'], - default: {}, - errorMessage: { - required: { - jobTitle: 'errorMessage.required.jobTitle', - }, - }, - properties: { - jobTitle: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.jobTitle', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -export const PersonalInfoPage = { - type: 'page', - name: 'text.personalInformation', - number: 1, - stateName: 'personal_details', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.personalInformation', - }, - }, - ], - }, - { - type: 'json-form', - valueDestination: 'entity.data.additionalInfo.mainRepresentative', - name: 'json-form:personal-information', - options: { - jsonFormDefinition: { - required: [ - 'first-name-input', - 'last-name-input', - 'job-title-input', - 'date-of-birth-input', - 'phone-number-input', - ], - }, - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - name: 'first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.firstName', - options: { - label: 'text.name', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.lastName', - options: { - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'job-title-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.mainRepresentative.additionalInfo.jobTitle', - options: { - label: 'text.jobTitle.label', - hint: 'text.jobTitle.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'date-of-birth-input', - type: 'json-form:date', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.dateOfBirth', - options: { - label: 'text.dateOfBirth.label', - hint: 'text.dateHint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - }, - }, - { - name: 'phone-number-input', - type: 'international-phone-number', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.phone', - options: { - label: 'text.phoneNumber', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'PhoneInput', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionPlugin', - params: { - pluginName: 'update_end_user', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/10-company-documents.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/10-company-documents.ts deleted file mode 100644 index be7eddf1de..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/10-company-documents.ts +++ /dev/null @@ -1,774 +0,0 @@ -const validationSchema = [ - { - documentId: 'document-certificates-of-incorporation', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-business-registration-certificate', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-corporate-tax-certificate', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-certificate-of-good-standing', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-certificate-of-directors-and-shareholders', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-picture-of-company-seal', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-proof-of-bank-account', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-other-supplementary-information', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-website-pictures-domain-certificate', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-office-front-door-pictures-1', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-office-interior-pictures-2', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-office-interior-pictures-3', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-website-pictures-website-business', - destination: 'pages[0].ballerineFileId', - required: { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.store.hasActiveWebsite' }, false, true], - }, - }, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-transaction-data-last-months', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, -]; - -const jsonValidationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - required: ['data'], - default: {}, - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - default: {}, - properties: { - additionalInfo: { - type: 'object', - required: ['hasConfirmed'], - properties: { - hasConfirmed: { - type: 'boolean', - default: false, - const: true, - errorMessage: { - const: 'errorMessage.error.requiredField', - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -export const CompanyDocuments = { - type: 'page', - number: 10, - stateName: 'company_documents', - name: 'text.companyDocuments', - pageValidation: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'json-schema', - value: jsonValidationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyDocuments', - }, - }, - { - type: 'h3', - options: { - text: 'text.merchantCompanyDocuments', - }, - }, - ], - }, - { - type: 'json-form', - name: 'company-documents-p1-form', - options: { - jsonFormDefinition: { - required: [ - 'document-certificates-of-incorporation', - 'document-business-registration-certificate', - 'document-picture-of-company-seal', - ], - }, - }, - elements: [ - { - name: 'document-certificates-of-incorporation', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.certificateOfIncorporation.label', - description: 'text.certificateOfIncorporation.description.6months', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-certificates-of-incorporation', - category: 'proof_of_registration', - type: 'certificate_of_incorporation', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-business-registration-certificate', - type: 'document', - valueDestination: 'documents[1].pages[0].ballerineFileId', - options: { - label: 'text.businessRegistrationCertificate.label', - description: 'text.businessRegistrationCertificate.description.regular', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-business-registration-certificate', - category: 'proof_of_registration', - type: 'business_registration_certificate', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-corporate-tax-certificate', - type: 'document', - valueDestination: 'documents[2].pages[0].ballerineFileId', - options: { - label: 'text.corporateTaxCertificate.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-corporate-tax-certificate', - category: 'financial_information', - type: 'corporate_tax_certificate', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-certificate-of-good-standing', - type: 'document', - valueDestination: 'documents[3].pages[0].ballerineFileId', - options: { - label: 'text.certificateOfGoodStanding.label', - description: 'text.certificateOfGoodStanding.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-certificate-of-good-standing', - category: 'proof_of_good_standing', - type: 'certificate_of_good_standing', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-certificate-of-directors-and-shareholders', - type: 'document', - valueDestination: 'documents[4].pages[0].ballerineFileId', - options: { - label: 'text.certificateOfDirectorsAndShareholders.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-certificate-of-directors-and-shareholders', - category: 'proof_of_ownership', - type: 'certificate_of_directors_and_shareholders', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-picture-of-company-seal', - type: 'document', - valueDestination: 'documents[5].pages[0].ballerineFileId', - options: { - label: 'text.pictureOfCompanySeal.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-picture-of-company-seal', - category: 'proof_of_identity', - type: 'company_seal', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-proof-of-bank-account', - type: 'document', - valueDestination: 'documents[6].pages[0].ballerineFileId', - options: { - label: 'text.proofOfBankAccount.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-proof-of-bank-account', - category: 'financial_information', - type: 'proof_of_bank_account_ownership', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-other-supplementary-information', - type: 'document', - valueDestination: 'documents[7].pages[0].ballerineFileId', - options: { - label: 'text.otherSupplementaryInformation.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-other-supplementary-information', - category: 'general_documents', - type: 'supplementary_document', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'h3', - name: 'website-documents-title', - options: { - text: 'text.websiteDocuments', - }, - }, - { - type: 'json-form', - name: 'website-documents-form-p1', - options: { - jsonFormDefinition: { - required: ['document-website-pictures-domain-certificate'], - }, - }, - elements: [ - { - name: 'document-website-pictures-domain-certificate', - type: 'document', - valueDestination: 'documents[8].pages[0].ballerineFileId', - options: { - label: 'text.domainCertificate.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-website-pictures-domain-certificate', - category: 'proof_of_domain_ownership', - type: 'domain_purchase_record', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'website-documents-form-p2', - options: { - jsonFormDefinition: { - required: ['document-website-pictures-website-business'], - }, - }, - elements: [ - { - name: 'document-website-pictures-website-business', - type: 'document', - valueDestination: 'documents[9].pages[0].ballerineFileId', - options: { - label: 'text.permittedSalesLicense.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-website-pictures-website-business', - category: 'proof_of_business_compliance', - type: 'permitted_sales_license', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - visibleOn: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.store.hasActiveWebsite' }, false, true], - }, - }, - ], - }, - { - type: 'h3', - name: 'office-pictures-title', - options: { - text: 'text.officePictures', - }, - }, - { - type: 'json-form', - name: 'office-pictures-form', - options: { - jsonFormDefinition: { - required: [ - 'document-office-front-door-pictures-1', - 'document-office-interior-pictures-2', - 'document-office-interior-pictures-3', - ], - }, - }, - elements: [ - { - name: 'document-office-front-door-pictures-1', - type: 'document', - valueDestination: 'documents[10].pages[0].ballerineFileId', - options: { - label: 'text.frontDoorPhoto.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-office-front-door-pictures-1', - category: 'proof_of_location', - type: 'front_door_photo', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-office-interior-pictures-2', - type: 'document', - valueDestination: 'documents[11].pages[0].ballerineFileId', - options: { - label: 'text.officeInteriorPhoto1.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-office-interior-pictures-2', - category: 'proof_of_location', - type: 'interior_office_photo', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-office-interior-pictures-3', - type: 'document', - valueDestination: 'documents[12].pages[0].ballerineFileId', - options: { - label: 'text.officeInteriorPhoto2.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-office-interior-pictures-3', - category: 'proof_of_location', - type: 'interior_office_photo', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'h3', - name: 'financial-docs-title', - options: { - text: 'text.financialDocuments', - }, - }, - { - type: 'json-form', - name: 'docs-form-2', - options: { - jsonFormDefinition: { - required: ['document-transaction-data-last-months'], - }, - }, - elements: [ - { - name: 'document-transaction-data-last-months', - type: 'document', - valueDestination: 'documents[13].pages[0].ballerineFileId', - options: { - label: 'text.transactionData.label', - description: 'text.transactionData.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-transaction-data-last-months', - category: 'financial_information', - type: 'transaction_data_last_3_6_months', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'h3', - name: 'accuracy-title', - options: { - text: 'text.declarationOfAccuracy', - }, - }, - { - type: 'description', - name: 'accuracy-description', - options: { - descriptionRaw: 'text.declarationOfAccuracyDescription', - }, - }, - { - type: 'json-form', - name: 'confirmation-form', - options: {}, - elements: [ - { - type: 'checkbox', - name: 'documents-confirmation-checkbox', - valueDestination: 'entity.data.additionalInfo.hasConfirmed', - options: { - jsonFormDefinition: { - type: 'boolean', - default: false, - }, - label: 'text.iConfirm', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'divider', - }, - { - type: 'description', - options: { - descriptionRaw: 'text.emailDescription', - }, - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.finish', - }, - availableOn: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'jmespath', - value: '!contains(uiState.elements.*.isLoading,`true`)', - }, - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.hasConfirmed' }, true, false], - }, - }, - { - type: 'json-logic', - value: { '!==': [{ var: 'uiState.isLoading' }, true, false] }, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.hasConfirmed' }, true, false], - }, - }, - ], - }, - }, - { - type: 'definitionPlugin', - params: { pluginName: 'sync_workflow_runtime', debounce: 50 }, - dispatchOn: { - uiEvents: [ - { - event: 'onChange', - uiElementName: 'document-certificates-of-incorporation', - }, - { - event: 'onChange', - uiElementName: 'document-business-registration-certificate', - }, - { - event: 'onChange', - uiElementName: 'document-picture-of-company-seal', - }, - { - event: 'onChange', - uiElementName: 'document-corporate-tax-certificate', - }, - { - event: 'onChange', - uiElementName: 'document-certificate-of-good-standing', - }, - { - event: 'onChange', - uiElementName: 'document-certificate-of-directors-and-shareholders', - }, - { - event: 'onChange', - uiElementName: 'document-website-pictures-domain-certificate', - }, - { - event: 'onChange', - uiElementName: 'document-website-pictures-website-business', - }, - { - event: 'onChange', - uiElementName: 'document-office-front-door-pictures-1', - }, - { - event: 'onChange', - uiElementName: 'document-office-interior-pictures-2', - }, - { - event: 'onChange', - uiElementName: 'document-office-interior-pictures-3', - }, - { - event: 'onChange', - uiElementName: 'document-transaction-data-last-months', - }, - { - event: 'onChange', - uiElementName: 'document-proof-of-bank-account', - }, - { - event: 'onChange', - uiElementName: 'document-other-supplementary-information', - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/2-business-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/2-business-info-page.ts deleted file mode 100644 index cd5b010b52..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/2-business-info-page.ts +++ /dev/null @@ -1,516 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: [ - 'additionalInfo', - 'businessType', - 'numberOfEmployees', - 'taxIdentificationNumber', - 'companyName', - 'country', - 'registrationNumber', - ], - properties: { - additionalInfo: { - type: 'object', - required: ['registeredCapitalInUsd'], - properties: { - registeredCapitalInUsd: { - type: 'number', - minimum: 0, - errorMessage: { - required: 'errorMessage.required.registeredCapitalInUsd', - minimum: 'errorMessage.minimum.registeredCapitalInUsd', - }, - }, - }, - errorMessage: { - required: { - registeredCapitalInUsd: 'errorMessage.required.registeredCapitalInUsd', - }, - }, - }, - businessType: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.businessType', - maxLength: 'errorMessage.maxLength.businessType', - required: 'errorMessage.required.businessType', - }, - }, - numberOfEmployees: { - type: 'number', - minimum: 1, - maximum: 100000, - errorMessage: { - type: 'errorMessage.type.numberOfEmployees', - required: 'errorMessage.required.numberOfEmployees', - minimum: 'errorMessage.minimum.numberOfEmployees', - maximum: 'errorMessage.maximum.numberOfEmployees', - }, - }, - taxIdentificationNumber: { - type: 'string', - minLength: 8, - maxLength: 15, - pattern: '^[^\\s]*$', - errorMessage: { - minLength: 'errorMessage.minLength.taxIdentificationNumber', - maxLength: 'errorMessage.maxLength.taxIdentificationNumber', - pattern: 'errorMessage.pattern.taxIdentificationNumber', - required: 'errorMessage.required.taxIdentificationNumber', - }, - }, - companyName: { - type: 'string', - minLength: 1, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.companyName', - maxLength: 'errorMessage.maxLength.companyName', - required: 'errorMessage.required.companyName', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength.country', - pattern: 'errorMessage.pattern.country', - required: 'errorMessage.required.country', - }, - }, - registrationNumber: { - type: 'string', - minLength: 4, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.registrationNumber', - maxLength: 'errorMessage.maxLength.registrationNumber', - required: 'errorMessage.required.registrationNumber', - }, - }, - }, - errorMessage: { - required: { - additionalInfo: 'errorMessage.required.additionalInfo', - businessType: 'errorMessage.required.businessType', - numberOfEmployees: 'errorMessage.required.numberOfEmployees', - taxIdentificationNumber: 'errorMessage.required.taxIdentificationNumber', - companyName: 'errorMessage.required.companyName', - country: 'errorMessage.required.country', - registrationNumber: 'errorMessage.required.registrationNumber', - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const dispatchOpenCorporateRule = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - default: {}, - properties: { - data: { - type: 'object', - required: ['registrationNumber', 'country'], - default: {}, - properties: { - registrationNumber: { - type: 'string', - minLength: 6, - maxLength: 20, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - }, - additionalInfo: { - type: 'object', - properties: { - state: { - default: '', - type: 'string', - }, - }, - }, - }, - if: { - properties: { - country: { - enum: ['AE', 'US', 'CA'], - }, - }, - }, - then: { - required: ['additionalInfo'], - properties: { - additionalInfo: { - required: ['state'], - properties: { - state: { - minLength: 1, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const stateVisiblityRule = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['country'], - default: {}, - properties: { - country: { - type: 'string', - enum: ['AE', 'US', 'CA'], - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const BusinessInfoPage = { - type: 'page', - number: 2, // routing number of page - stateName: 'business_information', // this is the route from xstate - name: 'text.businessInformation', // page name ( in stepper ) - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.businessInformation', - }, - }, - ], - }, - { - type: 'json-form', - name: 'business_info_form_p1', - options: { - jsonFormDefinition: { - required: ['registration-number-input', 'country-picker-input'], - }, - }, - elements: [ - { - name: 'registration-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.registrationNumber', - options: { - label: 'text.registrationNumber.label', - hint: 'text.registrationNumber.hint', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - }, - }, - { - name: 'country-picker-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.country', - options: { - label: 'text.country', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.choose', - }, - }, - }, - ], - }, - { - name: 'business_info_form_p2', - type: 'json-form', - options: { - jsonFormDefinition: { - required: ['business_info_state_input'], - }, - }, - visibleOn: [ - { - type: 'json-schema', - value: stateVisiblityRule, - }, - ], - elements: [ - { - name: 'business_info_state_input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.state', - options: { - label: 'text.state.label', - hint: 'text.state.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'StatePicker', - }, - countryCodePath: 'entity.data.country', - }, - }, - ], - }, - { - name: 'business_info_form_p3', - type: 'json-form', - options: { - jsonFormDefinition: { - required: [ - 'company-name-input', - 'tax-identification-number-input', - 'number-of-employees-input', - 'business-type-input', - 'registered-capital-in-usd-type-input', - ], - }, - }, - elements: [ - { - name: 'company-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.companyName', - options: { - label: 'text.companyName.label', - hint: 'text.companyName.hint', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - }, - }, - { - name: 'tax-identification-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.taxIdentificationNumber', - options: { - label: 'text.taxIdentificationNumber.label', - hint: 'text.taxIdentificationNumber.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'number-of-employees-input', - type: 'json-form:text', - valueDestination: 'entity.data.numberOfEmployees', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.numberOfEmployees.label', - hint: 'text.numberOfEmployees.hint', - }, - }, - { - name: 'business-type-input', - type: 'json-form:dropdown', - valueDestination: 'entity.data.businessType', - options: { - label: 'text.businessType.label', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'AutocompleteInput', - 'ui:label': true, - options: [ - { - title: 'text.businessType.options.sole_proprietorship', - const: 'sole_proprietorship', - }, - { - title: 'text.businessType.options.partnership', - const: 'partnership', - }, - { - title: 'text.businessType.options.corporation', - const: 'corporation', - }, - { - title: 'text.businessType.options.limited_liability_company', - const: 'limited_liability_company_(llc)', - }, - { - title: 'text.businessType.options.limited_partnership', - const: 'limited_partnership_(lp)', - }, - { - title: 'text.businessType.options.limited_liability_partnership', - const: 'limited_liability_partnership_(llp)', - }, - { - title: 'text.businessType.options.public_limited_company', - const: 'public_limited_company_(plc)', - }, - { - title: 'text.businessType.options.private_limited_company', - const: 'private_limited_company_(ltd)', - }, - { - title: 'text.businessType.options.non_profit_organization', - const: 'non-profit_organization', - }, - { - title: 'text.businessType.options.cooperative', - const: 'cooperative', - }, - { - title: 'text.businessType.options.trust', - const: 'trust', - }, - { - title: 'text.businessType.options.government', - const: 'government', - }, - { - title: 'text.businessType.options.other', - const: 'other', - }, - ], - }, - }, - }, - { - name: 'registered-capital-in-usd-type-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.registeredCapitalInUsd', - options: { - jsonFormDefinition: { - type: 'integer', - }, - format: 'currency', - hint: 'text.registeredCapitalInUsd.hint', - label: 'text.registeredCapitalInUsd.label', - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionPlugin', - params: { pluginName: 'fetch_company_information', debounce: 700 }, - dispatchOn: { - uiEvents: [ - { event: 'onChange', uiElementName: 'registration-number-input' }, - { event: 'onChange', uiElementName: 'country-picker-input' }, - { event: 'onChange', uiElementName: 'business_info_state_input' }, - ], - rules: [ - { - type: 'json-schema', - value: dispatchOpenCorporateRule, - }, - ], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionPlugin', - params: { - pluginName: 'state_value_removal', - }, - dispatchOn: { - uiEvents: [{ event: 'onChange', uiElementName: 'country-picker-input' }], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/3-business-address-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/3-business-address-info-page.ts deleted file mode 100644 index 097d2bf669..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/3-business-address-info-page.ts +++ /dev/null @@ -1,431 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['headquarters'], - default: {}, - properties: { - headquarters: { - type: 'object', - default: {}, - required: ['street', 'streetNumber', 'city', 'country'], - errorMessage: { - required: { - street: 'errorMessage.required.street', - streetNumber: 'errorMessage.required.streetNumber', - city: 'errorMessage.required.city', - country: 'errorMessage.required.country', - isDifferentFromPhysical: 'errorMessage.required.requiredField', - }, - }, - if: { - properties: { - isDifferentFromPhysical: { const: true }, - }, - }, - then: { - required: ['physical'], - errorMessage: { - required: { - street: 'errorMessage.required.street', - streetNumber: 'errorMessage.required.streetNumber', - city: 'errorMessage.required.city', - country: 'errorMessage.required.country', - isDifferentFromPhysical: 'errorMessage.required.requiredField', - }, - }, - properties: { - physical: { - required: ['street', 'streetNumber', 'city', 'country'], - errorMessage: { - required: { - street: 'errorMessage.required.street', - streetNumber: 'errorMessage.required.streetNumber', - city: 'errorMessage.required.city', - country: 'errorMessage.required.country', - isDifferentFromPhysical: 'errorMessage.required.requiredField', - physical: 'errorMessage.required.physical', - }, - }, - }, - }, - }, - properties: { - isDifferentFromPhysical: { - type: 'boolean', - default: false, - }, - street: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.street', - maxLength: 'errorMessage.maxLength.street', - }, - }, - streetNumber: { - type: 'number', - minLength: 1, - maxLength: 10, - errorMessage: { - minLength: 'errorMessage.minLength.streetNumber', - maxLength: 'errorMessage.maxLength.streetNumber', - }, - }, - city: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.city', - maxLength: 'errorMessage.maxLength.city', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength,country', - pattern: 'errorMessage.pattern.country', - }, - }, - physical: { - type: 'object', - default: {}, - properties: { - street: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.street', - maxLength: 'errorMessage.maxLength.street', - }, - }, - streetNumber: { - type: 'number', - minLength: 1, - maxLength: 10, - errorMessage: { - minLength: 'errorMessage.minLength.streetNumber', - maxLength: 'errorMessage.maxLength.streetNumber', - }, - }, - city: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.city', - maxLength: 'errorMessage.maxLength.city', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength,country', - pattern: 'errorMessage.pattern.country', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const physicalAddressForm = { - '==': [{ var: 'entity.data.additionalInfo.headquarters.isDifferentFromPhysical' }, true], -}; - -export const BusinessAddressInfoPage = { - type: 'page', - number: 3, - stateName: 'business_address_information', - name: 'text.businessAddress', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.businessAddress', - }, - }, - { - type: 'h3', - options: { - text: 'text.registeredAddress', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'address-form', - options: { - jsonFormDefinition: { - required: [ - 'search-address-input', - 'street-input', - 'street-number-input', - 'city-input', - 'country-input', - ], - }, - }, - elements: [ - { - name: 'street-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.street', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.street.label', - hint: 'text.street.hint', - }, - }, - { - name: 'street-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.streetNumber', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.number', - hint: '10', - }, - }, - { - name: 'city-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.city', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.city.label', - hint: 'text.city.hint', - }, - }, - { - name: 'country-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.additionalInfo.headquarters.country', - options: { - label: 'text.country', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.choose', - }, - }, - }, - { - name: 'different-from-physical-checkbox', - type: 'checkbox', - valueDestination: 'entity.data.additionalInfo.headquarters.isDifferentFromPhysical', - options: { - label: 'text.differentFromPhysicalAddress', - jsonFormDefinition: { - type: 'boolean', - }, - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'physical-address-form', - options: { - jsonFormDefinition: { - required: [ - 'physical-search-address-input', - 'physical-street-input', - 'physical-street-number-input', - 'physical-city-input', - 'physical-country-input', - ], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: physicalAddressForm, - }, - ], - elements: [ - { - name: 'physical-street-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.physical.street', - options: { - label: 'text.street.label', - hint: 'text.street.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'physical-street-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.physical.streetNumber', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.number', - hint: '10', - }, - }, - { - name: 'physical-city-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.physical.city', - options: { - label: 'text.city.label', - hint: 'text.city.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'physical-country-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.additionalInfo.headquarters.physical.country', - options: { - label: 'text.country', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.choose', - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionPlugin', - params: { - pluginName: 'remove_physical_address', - }, - dispatchOn: { - uiEvents: [ - { - event: 'onChange', - uiElementName: 'different-from-physical-checkbox', - }, - ], - rules: [ - { - type: 'json-logic', - value: { - if: [ - { - '!': { - var: 'entity.data.additionalInfo.headquarters.isDifferentFromPhysical', - }, - }, - true, - false, - ], - }, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/4-directors-and-ubos.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/4-directors-and-ubos.ts deleted file mode 100644 index d4880b3900..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/4-directors-and-ubos.ts +++ /dev/null @@ -1,739 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['ubos', 'directors'], - properties: { - ubos: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'errorMessage.minItems.ubos', - }, - items: { - type: 'object', - required: ['firstName', 'lastName', 'nationalId', 'email'], - properties: { - firstName: { - type: 'string', - minLength: 1, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 1, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - nationalId: { - type: 'string', - minLength: 5, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.nationalId', - maxLength: 'errorMessage.maxLength.nationalId', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['nationality', 'fullAddress', 'percentageOfOwnership'], - errorMessage: { - required: { - nationality: 'errorMessage.required.nationality', - fullAddress: 'errorMessage.required.fullAddress', - percentageOfOwnership: 'errorMessage.required.percentageOfOwnership', - }, - }, - properties: { - nationality: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.nationality', - }, - }, - fullAddress: { - type: 'string', - minLength: 10, - maxLength: 200, - errorMessage: { - minLength: 'errorMessage.minLength.fullAddress', - maxLength: 'errorMessage.maxLength.fullAddress', - }, - }, - percentageOfOwnership: { - type: 'number', - minimum: 25, - maximum: 100, - errorMessage: { - minimum: 'errorMessage.minimum.percentageOfOwnership', - maximum: 'errorMessage.maximum.percentageOfOwnership', - }, - }, - }, - }, - }, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - nationalId: 'errorMessage.required.nationalId', - email: 'errorMessage.required.email', - }, - }, - }, - }, - directors: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'Directors are required.', - }, - items: { - type: 'object', - required: ['firstName', 'lastName', 'nationalId', 'email'], - properties: { - firstName: { - type: 'string', - minLength: 1, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 1, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - nationalId: { - type: 'string', - minLength: 5, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.nationalId', - maxLength: 'errorMessage.maxLength.nationalId', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['nationality', 'fullAddress'], - errorMessage: { - required: { - nationality: 'errorMessage.required.nationality', - fullAddress: 'errorMessage.required.fullAddress', - percentageOfOwnership: 'errorMessage.required.percentageOfOwnership', - }, - }, - properties: { - nationality: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.nationality', - }, - }, - fullAddress: { - type: 'string', - minLength: 10, - maxLength: 200, - errorMessage: { - minLength: 'errorMessage.minLength.fullAddress', - maxLength: 'errorMessage.maxLength.fullAddress', - }, - }, - }, - }, - }, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - nationalId: 'errorMessage.required.nationalId', - email: 'errorMessage.required.email', - }, - }, - }, - }, - }, - errorMessage: { - required: { - ubos: 'errorMessage.required.ubos', - directors: 'errorMessage.required.directors', - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const DirectorsAndUbosPage = { - type: 'page', - number: 4, - stateName: 'directors_and_ubos', - name: 'text.directorsAndUBOs', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.directorsAndUBOs', - }, - }, - { - type: 'h3', - options: { - text: 'text.ubos', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'im-shareholder-checkbox-form', - options: { - jsonFormDefinition: { - required: ['im-shareholder-checkbox'], - }, - }, - elements: [ - { - type: 'checkbox', - name: 'im-shareholder-checkbox', - valueDestination: 'entity.data.additionalInfo.imShareholder', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.imShareholder', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'checkbox-description-1', - options: { - descriptionRaw: 'text.shareholdersDescription', - }, - }, - { - type: 'json-form', - name: 'ubos-form', - valueDestination: 'entity.data.additionalInfo.ubos', - options: { - description: - '

add all the natural persons that own or control, Directly Or Indirectly more than 25% of the company.

', - jsonFormDefinition: { - title: 'text.shareholder', - type: 'array', - required: [ - 'ubos:first-name-input', - 'ubos:last-name-input', - 'ubos:nationality-input', - 'ubos:identity-number-input', - 'ubos:email-input', - 'ubos:ownership-percentage-input', - 'ubos:address-of-residence-input', - ], - }, - uiSchema: { - titleTemplate: 'text.uboIndex', - }, - insertionParams: { - insertionStrategy: 'array', - destination: 'entity.data.additionalInfo.ubos', - schema: { - firstName: 'entity.data.additionalInfo.mainRepresentative.firstName', - lastName: 'entity.data.additionalInfo.mainRepresentative.lastName', - email: 'entity.data.additionalInfo.mainRepresentative.email', - }, - bindingAnchorDestination: 'additionalInfo.__isGeneratedAutomatically', - disableElements: [ - { - elementName: 'ubos:first-name-input', - atIndex: 0, - }, - { - elementName: 'ubos:last-name-input', - atIndex: 0, - }, - { - elementName: 'ubos:email-input', - atIndex: 0, - }, - ], - insertWhen: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.imShareholder' }, true], - }, - }, - ], - removeWhen: [ - { - type: 'json-logic', - value: { - if: [ - { - var: 'entity.data.additionalInfo.imShareholder', - }, - false, - true, - ], - }, - }, - ], - }, - }, - elements: [ - { - name: 'ubos:first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].firstName', //entity.data.additionalInfo.ubos[0].firstName - options: { - label: 'text.firstName', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].lastName', - options: { - label: 'text.lastName', - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:nationality-input', - type: 'nationality-picker', - valueDestination: - 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.nationality', - options: { - label: 'text.nationality', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'NationalityPicker', - }, - }, - }, - { - name: 'ubos:identity-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].nationalId', - options: { - label: 'text.nationalId.label', - hint: 'text.nationalId.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:email-input', - type: 'json-form:email', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - { - name: 'ubos:address-of-residence-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.fullAddress', - options: { - label: 'text.addressOfResidence.label', - hint: 'text.addressOfResidence.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:ownership-percentage-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.percentageOfOwnership', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.ownershipPercentage.label', - hint: 'text.ownershipPercentage.hint', - }, - }, - ], - }, - { - type: 'divider', - }, - { - type: 'h3', - options: { - text: 'text.directors', - classNames: ['padding-top-10'], - }, - }, - { - type: 'container', - elements: [ - { - type: 'json-form', - name: 'im-director-checkbox-form', - options: { - jsonFormDefinition: { - required: ['im-director-checkbox'], - }, - }, - elements: [ - { - type: 'checkbox', - name: 'im-director-checkbox', - valueDestination: 'entity.data.additionalInfo.imDirector', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.imDirector', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'checkbox-description-2', - options: { - descriptionRaw: 'text.directorsDescription', - }, - }, - { - name: 'directors-component', - type: 'json-form', - valueDestination: 'entity.data.additionalInfo.directors', - options: { - description: '

Add all the directors of the company.

', - jsonFormDefinition: { - type: 'array', - required: [ - 'directors:first-name-input', - 'directors:last-name-input', - 'directors:nationality-input', - 'directors:identity-number-input', - 'directors:email-input', - 'directors:address-of-residence-input', - ], - }, - uiSchema: { - titleTemplate: 'text.directorIndex', - }, - insertionParams: { - insertionStrategy: 'array', - destination: 'entity.data.additionalInfo.directors', - schema: { - firstName: 'entity.data.additionalInfo.mainRepresentative.firstName', - lastName: 'entity.data.additionalInfo.mainRepresentative.lastName', - email: 'entity.data.additionalInfo.mainRepresentative.email', - }, - bindingAnchorDestination: 'additionalInfo.__isGeneratedAutomatically', - disableElements: [ - { - elementName: 'directors:first-name-input', - atIndex: 0, - }, - { - elementName: 'directors:last-name-input', - atIndex: 0, - }, - { - elementName: 'directors:email-input', - atIndex: 0, - }, - ], - insertWhen: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.imDirector' }, true], - }, - }, - ], - removeWhen: [ - { - type: 'json-logic', - value: { - if: [ - { - var: 'entity.data.additionalInfo.imDirector', - }, - false, - true, - ], - }, - }, - ], - }, - }, - elements: [ - { - name: 'directors:first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].firstName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.firstName', - hint: 'text.firstName', - }, - }, - { - name: 'directors:last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].lastName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.lastName', - hint: 'text.lastName', - }, - }, - { - name: 'directors:nationality-input', - type: 'nationality-picker', - valueDestination: - 'entity.data.additionalInfo.directors[{INDEX}].additionalInfo.nationality', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'NationalityPicker', - }, - label: 'text.nationality', - hint: 'text.choose', - }, - }, - { - name: 'directors:identity-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].nationalId', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.nationalId.label', - hint: 'text.nationalId.hint', - }, - }, - { - name: 'directors:address-of-residence-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.directors[{INDEX}].additionalInfo.fullAddress', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.addressOfResidence.label', - hint: 'text.addressOfResidence.hint', - }, - }, - { - name: 'directors:email-input', - type: 'json-form:email', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - { - name: 'directors:passport-document', - type: 'json-form:document', - valueDestination: - 'entity.data.additionalInfo.directors[{INDEX}].additionalInfo.documents[0].pages[0].ballerineFileId', - options: { - label: 'text.passportDocument.label', - description: 'text.passportDocument.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'directors:passport-document-[{INDEX}]', - category: 'proof_of_identity', - type: 'passport', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'directors:passport-selfie', - type: 'json-form:document', - valueDestination: - 'entity.data.additionalInfo.directors[{INDEX}].additionalInfo.documents[1].pages[0].ballerineFileId', - options: { - label: 'text.passportSelfie.label', - description: 'text.passportSelfie.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'directors:passport-selfie-[{INDEX}]', - category: 'proof_of_identity_ownership', - type: 'selfie', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'divider', - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/5-contacts-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/5-contacts-page.ts deleted file mode 100644 index 9056c0ed07..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/5-contacts-page.ts +++ /dev/null @@ -1,204 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['mainContact'], - properties: { - mainContact: { - type: 'object', - required: ['firstName', 'lastName', 'email', 'phone'], - default: {}, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - phone: 'errorMessage.required.phone', - email: 'errorMessage.required.email', - }, - }, - properties: { - firstName: { - type: 'string', - minLength: 1, - }, - lastName: { - type: 'string', - minLength: 1, - }, - phone: { - type: 'string', - pattern: '^[+]?[0-9]{10,15}$', - errorMessage: { - pattern: 'errorMessage.pattern.phone', - }, - }, - email: { - type: 'string', - format: 'email', - errorMessage: 'errorMessage.format.email', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const ContactsPage = { - type: 'page', - number: 5, - stateName: 'contacts_page', - name: 'text.contacts', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.contacts', - }, - }, - { - type: 'h4', - options: { - text: 'text.mainContact', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'contacts-form', - options: { - jsonFormDefinition: { - required: [ - 'contact-first-name-input', - 'contact-last-name-input', - 'contact-email-input', - 'contact-phone-number-input', - ], - }, - }, - elements: [ - { - name: 'contact-first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainContact.firstName', - options: { - label: 'text.legalName', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'contact-last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainContact.lastName', - options: { - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'contact-email-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainContact.email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - { - name: 'contact-phone-number-input', - type: 'international-phone-number', - valueDestination: 'entity.data.additionalInfo.mainContact.phone', - options: { - label: 'text.phoneNumber', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'PhoneInput', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'contact-controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/6-banking-details.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/6-banking-details.ts deleted file mode 100644 index 4112e27e8b..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/6-banking-details.ts +++ /dev/null @@ -1,501 +0,0 @@ -import { currencyCodes } from 'prisma/data-migrations/templates/utils/schema-utils/currency-codes'; - -const validationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - allOf: [ - { - if: { - properties: { - country: { - const: 'US', - }, - }, - }, - then: { - properties: { - additionalInfo: { - type: 'object', - properties: { - bank: { - required: [ - 'holderName', - 'holderFullAddress', - 'accountNumber', - 'swiftCode', - 'routeNumber', - 'bankName', - 'bankAddress', - 'currency', - ], - }, - }, - }, - }, - }, - else: { - properties: { - additionalInfo: { - type: 'object', - properties: { - bank: { - required: [ - 'holderName', - 'holderFullAddress', - 'accountNumber', - 'swiftCode', - 'bankName', - 'bankAddress', - 'currency', - ], - }, - }, - }, - }, - }, - }, - { - if: { - properties: { - country: { - const: 'HK', - }, - }, - }, - then: { - properties: { - additionalInfo: { - type: 'object', - properties: { - bank: { - required: [ - 'holderName', - 'holderFullAddress', - 'accountNumber', - 'swiftCode', - 'bankName', - 'bankCode', - 'subBranch', - 'bankAddress', - 'currency', - ], - }, - }, - }, - }, - }, - else: { - properties: { - additionalInfo: { - type: 'object', - properties: { - bank: { - required: [ - 'holderName', - 'holderFullAddress', - 'accountNumber', - 'swiftCode', - 'bankName', - 'bankAddress', - 'currency', - ], - }, - }, - }, - }, - }, - }, - ], - properties: { - country: { - type: 'string', - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['bank'], - properties: { - bank: { - type: 'object', - default: {}, - properties: { - iban: { - type: 'string', - maxLength: 34, - minLength: 15, - errorMessage: { - maxLength: 'errorMessage.maxLength.iban', - minLength: 'errorMessage.minLength.iban', - }, - }, - bankCode: { - type: 'string', - maxLength: 13, - minLength: 1, - errorMessage: { - maxLength: 'errorMessage.maxLength.bankCode', - minLength: 'errorMessage.minLength.bankCode', - }, - }, - bankName: { - type: 'string', - maxLength: 100, - minLength: 3, - errorMessage: { - maxLength: 'errorMessage.maxLength.bankName', - minLength: 'errorMessage.minLength.bankName', - }, - }, - currency: { - type: 'string', - errorMessage: { - minLength: 'errorMessage.minLength.currency', - }, - }, - subBranch: { - type: 'string', - pattern: '^[0-9]+$', - errorMessage: { - pattern: 'errorMessage.pattern.subBranch', - required: 'errorMessage.required.subBranch', - }, - }, - swiftCode: { - type: 'string', - maxLength: 11, - minLength: 8, - errorMessage: { - maxLength: 'errorMessage.maxLength.swiftCode', - minLength: 'errorMessage.minLength.swiftCode', - }, - }, - holderName: { - type: 'string', - maxLength: 50, - minLength: 5, - errorMessage: { - maxLength: 'errorMessage.maxLength.holderName', - minLength: 'errorMessage.minLength.holderName', - }, - }, - bankAddress: { - type: 'string', - maxLength: 200, - minLength: 10, - errorMessage: { - maxLength: 'errorMessage.maxLength.bankAddress', - minLength: 'errorMessage.minLength.bankAddress', - }, - }, - routeNumber: { - type: 'number', - maxLength: 10, - minLength: 8, - errorMessage: { - maxLength: 'errorMessage.maxLength.routeNumber', - minLength: 'errorMessage.minLength.routeNumber', - routeNumber: 'errorMessage.required.routeNumber', - }, - }, - accountNumber: { - type: 'string', - maxLength: 34, - minLength: 6, - errorMessage: { - maxLength: 'errorMessage.maxLength.accountNumber', - minLength: 'errorMessage.minLength.accountNumber', - }, - }, - holderFullAddress: { - type: 'string', - maxLength: 200, - minLength: 10, - errorMessage: { - maxLength: 'errorMessage.maxLength.holderFullAddress', - minLength: 'errorMessage.minLength.holderFullAddress', - }, - }, - }, - errorMessage: { - required: { - bankName: 'errorMessage.required.bankName', - currency: 'errorMessage.required.currency', - swiftCode: 'errorMessage.required.swiftCode', - holderName: 'errorMessage.required.holderName', - bankAddress: 'errorMessage.required.bankAddress', - accountNumber: 'errorMessage.required.accountNumber', - holderFullAddress: 'errorMessage.required.holderFullAddress', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -export const BankingDetailsPage = { - type: 'page', - number: 6, - stateName: 'banking_details', - name: 'text.bankingDetails', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.bankingDetails', - }, - }, - ], - }, - { - type: 'json-form', - name: 'banking-details-form', - options: { - jsonFormDefinition: { - required: [ - 'card-holder-name-input', - 'resident-address-input', - 'account-number-input', - 'swift-code-input', - 'bank-name-input', - 'bank-address-input', - 'account-currency-input', - ], - }, - }, - elements: [ - { - name: 'card-holder-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.holderName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.holderName.label', - hint: 'text.holderName.hint', - }, - }, - { - name: 'resident-address-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.holderFullAddress', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.holderFullAddress.label', - hint: 'text.holderFullAddress.hint', - }, - }, - { - name: 'account-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.accountNumber', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.accountNumber.label', - hint: 'text.accountNumber.hint', - }, - }, - { - name: 'iban-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.iban', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.iban.label', - hint: 'text.iban.hint', - }, - }, - { - name: 'swift-code-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.swiftCode', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.swiftCode.label', - hint: 'text.swiftCode.hint', - }, - }, - { - name: 'route-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.routeNumber', - requiredOn: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.country' }, 'US'], - }, - }, - ], - options: { - jsonFormDefinition: { - type: 'integer', - }, - label: 'text.routeNumber.label', - hint: 'text.routeNumber.hint', - }, - }, - { - name: 'bank-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.bankName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.bankName.label', - hint: 'text.bankName.hint', - }, - }, - { - name: 'bank-code-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.bankCode', - requiredOn: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.country' }, 'HK'], - }, - }, - ], - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.bankCode.label', - hint: 'text.bankCode.hint', - }, - }, - { - name: 'bank-address-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.bankAddress', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.bankAddress.label', - hint: 'text.bankAddress.hint', - }, - }, - { - name: 'bank-sub-branch-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.subBranch', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.subBranch.label', - hint: 'text.subBranch.hint', - }, - requiredOn: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.country' }, 'HK'], - }, - }, - ], - }, - { - name: 'account-currency-input', - type: 'currency-picker', - valueDestination: 'entity.data.additionalInfo.bank.currency', - options: { - jsonFormDefinition: { - type: 'string', - oneOf: [ - { title: '', const: '' }, - ...currencyCodes.map(code => ({ - title: code.code.toUpperCase(), - const: code.code, - })), - ], - }, - label: 'text.currency.label', - hint: 'text.choose', - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/7-store-info.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/7-store-info.ts deleted file mode 100644 index 245b4535d6..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/7-store-info.ts +++ /dev/null @@ -1,341 +0,0 @@ -import { multipleUrlsPattern } from '@/ui-definition/utils/schema-utils/regex'; - -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['store'], - default: {}, - properties: { - store: { - type: 'object', - default: {}, - if: { - properties: { - hasMobileApp: { - const: true, - }, - }, - }, - then: { - required: ['mobileAppName'], - errorMessage: { - required: { - mobileAppName: 'errorMessage.required.mobileAppName', - }, - }, - }, - properties: { - websiteUrls: { - type: 'string', - pattern: multipleUrlsPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.required.websiteUrls', - pattern: 'errorMessage.pattern.websiteUrls', - }, - }, - dba: { - type: 'string', - not: { enum: [''] }, - errorMessage: 'errorMessage.required.dba', - }, - products: { - type: 'string', - not: { enum: [''] }, - errorMessage: 'errorMessage.required.products', - }, - established: { - type: 'string', - errorMessage: 'errorMessage.required.established', - }, - hasMobileApp: { - type: 'boolean', - errorMessage: 'errorMessage.required.hasMobileApp', - default: false, - }, - mobileAppName: { - type: 'string', - }, - industry: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.industry', - }, - }, - }, - required: [ - 'websiteUrls', - 'dba', - 'products', - 'established', - 'hasMobileApp', - 'industry', - ], - errorMessage: { - required: { - websiteUrls: 'errorMessage.required.websiteUrls', - dba: 'errorMessage.required.dba', - products: 'errorMessage.required.products', - established: 'errorMessage.required.established', - hasMobileApp: 'errorMessage.required.hasMobileApp', - industry: 'errorMessage.required.industry', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const hasMobileAppVisibilityRule = { - '==': [{ var: 'entity.data.additionalInfo.store.hasMobileApp' }, true], -}; - -export const StoreInfoPage = { - type: 'page', - number: 7, - stateName: 'store_info', - name: 'text.storeInfo', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.storeInfo', - }, - }, - ], - }, - { - type: 'json-form', - name: 'store-info-form', - options: { - jsonFormDefinition: { - required: [ - 'store-website-urls-input', - 'store-dba-input', - 'store-industry-input', - 'store-products-input', - 'store-established-input', - 'store-has-mobile-checkbox', - ], - }, - }, - elements: [ - { - name: 'store-website-urls-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.websiteUrls', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.websiteUrls.label', - hint: 'text.websiteUrls.hint', - }, - }, - { - name: 'store-dba-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.dba', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.dba.label', - hint: 'text.dba.hint', - }, - }, - { - name: 'store-industry-input', - type: 'json-form:dropdown', - valueDestination: 'entity.data.additionalInfo.store.industry', - options: { - label: 'text.industry', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'IndustriesPicker', - }, - }, - }, - { - name: 'store-products-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.products', - options: { - jsonFormDefinition: { - type: 'string', - }, - classNames: ['min-width-40px'], - label: 'text.products.label', - hint: 'text.products.hint', - }, - }, - { - name: 'store-established-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.established', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - label: 'text.established.label', - hint: 'text.dateHint', - }, - }, - { - name: 'store-has-mobile-checkbox', - type: 'checkbox', - valueDestination: 'entity.data.additionalInfo.store.hasMobileApp', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.hasMobileApp.label', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'store-mobile-app-name-input-form', - options: { - jsonFormDefinition: { - required: ['store-mobile-app-name-input'], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: hasMobileAppVisibilityRule, - }, - ], - elements: [ - { - name: 'store-mobile-app-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.mobileAppName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.mobileAppName', - hint: 'text.mobileAppName', - }, - }, - ], - }, - { - type: 'json-form', - name: 'active-store-website-checkbox', - options: { - jsonFormDefinition: { - required: ['active-store-website-checkbox'], - }, - }, - elements: [ - { - name: 'active-store-website-checkbox', - type: 'checkbox', - valueDestination: 'entity.data.additionalInfo.store.hasActiveWebsite', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.hasActiveWebsite', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'description-1', - options: { - descriptionRaw: 'text.storeInfoDescription', - }, - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/8-website-basic-requirement.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/8-website-basic-requirement.ts deleted file mode 100644 index 58cd789b3d..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/8-website-basic-requirement.ts +++ /dev/null @@ -1,376 +0,0 @@ -import { singleUrlPattern } from '@/ui-definition/utils/schema-utils/regex'; - -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['store'], - properties: { - store: { - type: 'object', - required: ['website'], - default: {}, - properties: { - website: { - type: 'object', - default: {}, - required: [ - 'mainWebsite', - 'contactDetails', - 'productQuantity', - 'productDescription', - 'productPrice', - ], - properties: { - mainWebsite: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.mainWebsite', - pattern: 'errorMessage.pattern.mainWebsite', - }, - }, - contactDetails: { - type: 'string', - errorMessage: 'errorMessage.error.contactDetails', - }, - returnPolicyUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.returnPolicyUrl', - pattern: 'errorMessage.pattern.returnPolicyUrl', - }, - }, - shippingPolicyUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.shippingPolicyUrl', - pattern: 'errorMessage.pattern.shippingPolicyUrl', - }, - }, - aboutUsUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.aboutUsUrl', - pattern: 'errorMessage.pattern.aboutUsUrl', - }, - }, - termsOfUseUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.termsOfUseUrl', - pattern: 'errorMessage.pattern.termsOfUseUrl', - }, - }, - privacyPolicyUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.privacyPolicyUrl', - pattern: 'errorMessage.pattern.privacyPolicyUrl', - }, - }, - productQuantity: { - type: 'number', - errorMessage: 'errorMessage.error.productQuantity', - }, - productPrice: { - type: 'number', - errorMessage: 'errorMessage.error.productPrice', - }, - productDescription: { - type: 'string', - errorMessage: 'errorMessage.error.productDescription', - }, - websiteLanguage: { - type: 'string', - errorMessage: 'errorMessage.error.websiteLanguage', - }, - }, - errorMessage: { - required: { - mainWebsite: 'errorMessage.required.mainWebsite', - contactDetails: 'errorMessage.required.contactDetails', - productQuantity: 'errorMessage.required.productQuantity', - productDescription: 'errorMessage.required.productDescription', - productPrice: 'errorMessage.required.productPrice', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const WebsiteBasicRequirement = { - type: 'page', - number: 8, - stateName: 'website_basic_requirement', - name: 'text.websiteBasicRequirement', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.websiteBasicRequirement', - }, - }, - { - type: 'description', - name: 'heading-description', - options: { - descriptionRaw: 'text.websiteBasicRequirementDescription', - }, - }, - ], - }, - { - type: 'json-form', - name: 'website-basic-requirement-form', - options: { - jsonFormDefinition: { - required: [ - 'main-company-website-input', - 'contact-details-input', - 'operation-entities-name-input', - 'contact-details-input', - 'product-quantity-input', - 'product-description-input', - 'product-price-input', - ], - }, - }, - elements: [ - { - type: 'json-form:hint', - options: { - label: 'text.websiteBasicRequirementHint', - }, - }, - { - name: 'main-company-website-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.mainWebsite', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.mainWebsite.label', - hint: 'text.mainWebsite.hint', - description: 'text.mainWebsite.description', - }, - }, - { - name: 'contact-details-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.contactDetails', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.contactDetails.label', - hint: 'text.contactDetails.hint', - }, - }, - { - name: 'return-policy-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.returnPolicyUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.returnPolicyUrl.label', - hint: 'text.returnPolicyUrl.hint', - }, - }, - { - name: 'shipping-policy-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.shippingPolicyUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.shippingPolicyUrl.label', - hint: 'text.shippingPolicyUrl.hint', - }, - }, - { - name: 'about-us-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.aboutUsUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.aboutUsUrl.label', - hint: 'text.aboutUsUrl.hint', - }, - }, - { - name: 'terms-of-us-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.termsOfUseUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.termsOfUseUrl.label', - hint: 'text.termsOfUseUrl.hint', - }, - }, - { - name: 'privacy-policy-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.privacyPolicyUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.privacyPolicyUrl.label', - hint: 'text.privacyPolicyUrl.hint', - }, - }, - { - name: 'product-quantity-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.productQuantity', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.productQuantity.label', - hint: 'text.productQuantity.hint', - }, - }, - { - name: 'product-description-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.productDescription', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:widget': 'textarea', - }, - label: 'text.productDescription.label', - hint: 'text.productDescription.hint', - classNames: ['min-width-40px'], - }, - }, - { - name: 'product-price-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.productPrice', - options: { - label: 'text.productPrice.label', - hint: 'text.productPrice.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'website-language-input', - type: 'json-form:dropdown', - valueDestination: 'entity.data.additionalInfo.store.website.websiteLanguage', - options: { - hint: 'text.choose', - label: 'text.websiteLanguage.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:placeholder': 'text.choose', - 'ui:field': 'LocalePicker', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/9-process-details.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/9-process-details.ts deleted file mode 100644 index e853a615e6..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/9-process-details.ts +++ /dev/null @@ -1,558 +0,0 @@ -const validationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['store'], - properties: { - store: { - type: 'object', - required: ['processingDetails'], - default: {}, - properties: { - processingDetails: { - type: 'object', - default: {}, - required: [ - 'monthlySalesVolume', - 'monthlyTransactions', - 'averageTicketAmount', - 'mainCategory', - 'businessModel', - ], - errorMessage: { - required: { - monthlySalesVolume: 'errorMessage.required.monthlySalesVolume', - monthlyTransactions: 'errorMessage.required.monthlyTransactions', - averageTicketAmount: 'errorMessage.required.averageTicketAmount', - mainCategory: 'errorMessage.required.mainCategory', - businessModel: 'errorMessage.required.businessModel', - }, - }, - properties: { - monthlySalesVolume: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.monthlySalesVolume', - }, - monthlyTransactions: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.monthlyTransactions', - }, - averageTicketAmount: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.averageTicketAmount', - }, - mainCategory: { - type: 'array', - items: { type: 'string' }, - minItems: 1, - errorMessage: 'errorMessage.error.mainCategory', - }, - businessModel: { - type: 'array', - items: { type: 'string' }, - minItems: 1, - errorMessage: 'errorMessage.error.businessModel', - }, - isSpikeInSales: { type: 'boolean', default: false }, - spikeSalesAverageVolume: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.spikeSalesAverageVolume', - }, - spikeTransactionNumber: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.spikeTransactionNumber', - }, - }, - if: { - properties: { - isSpikeInSales: { - const: true, - }, - }, - }, - then: { - required: [ - 'monthlySalesVolume', - 'monthlyTransactions', - 'averageTicketAmount', - 'isSpikeInSales', - 'volumeInRegion', - 'spikeTransactionNumber', - 'mainCategory', - 'businessModel', - 'spikeSalesAverageVolume', - ], - errorMessage: { - required: { - monthlySalesVolume: 'errorMessage.required.monthlySalesVolume', - monthlyTransactions: 'errorMessage.required.monthlyTransactions', - averageTicketAmount: 'errorMessage.required.averageTicketAmount', - spikeSalesAverageVolume: - 'errorMessage.required.spikeSalesAverageVolume', - spikeTransactionNumber: 'errorMessage.required.spikeTransactionNumber', - mainCategory: 'errorMessage.required.mainCategory', - businessModel: 'errorMessage.required.businessModel', - volumeInRegion: 'errorMessage.required.volumeInRegion', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -const isSpikeInSaleVisibility = { - '==': [ - { - var: 'entity.data.additionalInfo.store.processingDetails.isSpikeInSales', - }, - true, - ], -}; - -const isCustomBusinessModel = { - in: ['Other', { var: `entity.data.additionalInfo.store.processingDetails.businessModel` }], -}; -const isCustomMainCateogry = { - in: ['Other', { var: 'entity.data.additionalInfo.store.processingDetails.mainCategory' }], -}; - -export const ProcessingDetails = { - type: 'page', - number: 9, - stateName: 'processing_details', - name: 'text.processingDetails', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.processingDetails', - }, - }, - ], - }, - { - type: 'json-form', - name: 'sales-form', - options: { - jsonFormDefinition: { - required: [ - 'monthly-sales-volume-input', - 'monthly-number-transactions-input', - 'average-ticket-sales-input', - ], - }, - }, - elements: [ - { - name: 'monthly-sales-volume-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.monthlySalesVolume', - options: { - label: 'text.monthlySalesVolume.label', - hint: 'text.monthlySalesVolume.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'monthly-number-transactions-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.monthlyTransactions', - options: { - label: 'text.monthlyTransactions.label', - hint: 'text.monthlyTransactions.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'est-monthly-sales-volume-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.estimatedMonthlySales', - options: { - label: 'text.estimatedMonthlySales.label', - labelVariables: { customerName: 'metadata.customerName' }, - hint: 'text.estimatedMonthlySales.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'est-monthly-transactions-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.estimatedMonthlyTransactions', - options: { - label: 'text.estimatedMonthlyTransactions.label', - labelVariables: { customerName: 'metadata.customerName' }, - hint: 'text.estimatedMonthlyTransactions.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'average-ticket-sales-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.averageTicketAmount', - options: { - label: 'text.averageTicketAmount.label', - hint: 'text.averageTicketAmount.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'minimum-ticket-sales-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.minimumTicketAmount', - options: { - label: 'text.minimumTicketAmount.label', - hint: 'text.minimumTicketAmount.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'maximum-ticket-sales-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.maximumTicketAmount', - options: { - label: 'text.maximumTicketAmount.label', - hint: 'text.maximumTicketAmount.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'spike-in-transactions-input', - type: 'checkbox', - valueDestination: 'entity.data.additionalInfo.store.processingDetails.isSpikeInSales', - options: { - label: 'text.isSpikeInSales.label', - jsonFormDefinition: { - type: 'boolean', - }, - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'spike-sales-form', - options: { - jsonFormDefinition: { - required: ['spike-sales-volume-input', 'spike-sales-transaction-number-input'], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: isSpikeInSaleVisibility, - }, - ], - elements: [ - { - name: 'spike-sales-volume-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.spikeSalesAverageVolume', - options: { - label: 'text.spikeSalesAverageVolume.label', - hint: 'text.spikeSalesAverageVolume.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'spike-sales-transaction-number-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.spikeTransactionNumber', - options: { - label: 'text.spikeTransactionNumber.label', - hint: 'text.spikeTransactionNumber.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'volume-in-region-form', - options: { - jsonFormDefinition: { - required: ['volume-in-region'], - }, - }, - elements: [ - { - name: 'volume-in-region', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.processingDetails.volumeInRegion', - options: { - label: 'text.volumeInRegion.label', - hint: 'text.volumeInRegion.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - ], - }, - { - type: 'h3', - options: { - text: 'text.customerCategory', - }, - }, - { - type: 'json-form', - options: {}, - name: 'main-category-input-form', - elements: [ - { - name: 'main-category-input', - type: 'json-form:select', - valueDestination: 'entity.data.additionalInfo.store.processingDetails.mainCategory', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'Multiselect', - options: [ - { - title: 'text.b2c', - value: 'B2C', - }, - { - title: 'text.b2b', - value: 'B2B', - }, - { - title: 'text.c2c', - value: 'C2C', - }, - { - title: 'text.other', - value: 'Other', - }, - ], - }, - variants: { - chip: { - wrapper: 'secondary', - label: 'primary', - }, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'other-main-category-input-form', - options: { - jsonFormDefinition: { - required: ['other-main-category-input'], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: isCustomMainCateogry, - }, - ], - elements: [ - { - name: 'other-main-category-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.otherMainCategory', - options: { - label: 'text.mainCategory', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - ], - }, - { - type: 'h3', - options: { - text: 'text.websiteBusinessModel', - }, - }, - { - type: 'json-form', - name: 'business-model-input-form', - options: {}, - elements: [ - { - name: 'business-model-input', - type: 'json-form:select', - valueDestination: 'entity.data.additionalInfo.store.processingDetails.businessModel', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CheckboxList', - options: [ - { - title: 'text.membership', - value: 'Membership', - }, - { - title: 'text.directPurchase', - value: 'Direct Purchase', - }, - { - title: 'text.other', - value: 'Other', - }, - ], - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'other-business-model-input-form', - options: { - jsonFormDefinition: { - required: ['other-business-model-input'], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: isCustomBusinessModel, - }, - ], - elements: [ - { - name: 'other-business-model-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.otherBusinessModel', - options: { - label: 'text.businessModel', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'PREVIOUS', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'previous-page-button' }], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/compose-ui-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/compose-ui-definition.ts deleted file mode 100644 index c5edfb755c..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/compose-ui-definition.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Prisma } from '@prisma/client'; - -import { PersonalInfoPage } from 'prisma/data-migrations/templates/creation/clipspay/collection-flow/1-personal-info-page'; -import { CompanyDocuments } from 'prisma/data-migrations/templates/creation/clipspay/collection-flow/10-company-documents'; -import { BusinessInfoPage } from 'prisma/data-migrations/templates/creation/clipspay/collection-flow/2-business-info-page'; -import { BusinessAddressInfoPage } from 'prisma/data-migrations/templates/creation/clipspay/collection-flow/3-business-address-info-page'; -import { DirectorsAndUbosPage } from 'prisma/data-migrations/templates/creation/clipspay/collection-flow/4-directors-and-ubos'; -import { ContactsPage } from 'prisma/data-migrations/templates/creation/clipspay/collection-flow/5-contacts-page'; -import { BankingDetailsPage } from 'prisma/data-migrations/templates/creation/clipspay/collection-flow/6-banking-details'; -import { StoreInfoPage } from 'prisma/data-migrations/templates/creation/clipspay/collection-flow/7-store-info'; -import { WebsiteBasicRequirement } from 'prisma/data-migrations/templates/creation/clipspay/collection-flow/8-website-basic-requirement'; -import { ProcessingDetails } from 'prisma/data-migrations/templates/creation/clipspay/collection-flow/9-process-details'; - -export const composeUiDefinition = ( - workflowDefinitionId: string, - definition: any, -): Pick< - Prisma.UiDefinitionUncheckedCreateInput, - 'uiContext' | 'uiSchema' | 'definition' | 'workflowDefinitionId' -> => { - return { - uiContext: 'collection_flow', - uiSchema: { - elements: [ - PersonalInfoPage, - BusinessInfoPage, - BusinessAddressInfoPage, - DirectorsAndUbosPage, - ContactsPage, - BankingDetailsPage, - StoreInfoPage, - WebsiteBasicRequirement, - ProcessingDetails, - CompanyDocuments, - ], - }, - definition, - workflowDefinitionId: workflowDefinitionId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/generate-definition-logic.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/generate-definition-logic.ts deleted file mode 100644 index 3914792ac3..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/collection-flow/generate-definition-logic.ts +++ /dev/null @@ -1,226 +0,0 @@ -export const generateDefinitionLogic = (id: string) => { - return { - definitionType: 'statechart-json', - definition: { - id, - predictableActionArguments: true, - initial: 'personal_details', - context: {}, - states: { - personal_details: { - on: { - NEXT: 'business_information', - }, - }, - business_information: { - on: { - NEXT: 'business_address_information', - PREVIOUS: 'personal_details', - }, - }, - business_address_information: { - on: { - NEXT: 'directors_and_ubos', - PREVIOUS: 'business_information', - }, - }, - directors_and_ubos: { - on: { - NEXT: 'contacts_page', - PREVIOUS: 'business_address_information', - }, - }, - contacts_page: { - on: { - NEXT: 'banking_details', - PREVIOUS: 'directors_and_ubos', - }, - }, - banking_details: { - on: { - NEXT: 'store_info', - PREVIOUS: 'contacts_page', - }, - }, - store_info: { - on: { - NEXT: 'website_basic_requirement', - PREVIOUS: 'banking_details', - }, - }, - website_basic_requirement: { - on: { - NEXT: 'processing_details', - PREVIOUS: 'store_info', - }, - }, - processing_details: { - on: { - NEXT: 'company_documents', - PREVIOUS: 'website_basic_requirement', - }, - }, - company_documents: { - on: { - NEXT: 'finish', - PREVIOUS: 'processing_details', - }, - }, - finish: { type: 'final' }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'update_end_user', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/end-user?token={flowConfig.tokenId}`, - method: 'POST', - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - stateNames: [], - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - lastName: entity.data.additionalInfo.mainRepresentative.lastName, - additionalInfo: {title: entity.data.additionalInfo.mainRepresentative.additionalInfo.jobTitle}, - phone: entity.data.additionalInfo.mainRepresentative.phone, - dateOfBirth: entity.data.additionalInfo.mainRepresentative.dateOfBirth - }`, - }, - ], - }, - }, - { - name: 'sync_workflow_runtime', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/sync/?token={flowConfig.tokenId}`, - method: 'PUT', - // stateNames: ['personal_details', 'business_information', 'business_address_information', 'directors_and_ubos', 'contacts_page', 'banking_details', 'store_info', 'website_basic_requirement', 'processing_details', 'company_documents'], - stateNames: [ - 'personal_details', - 'business_information', - 'business_address_information', - 'directors_and_ubos', - 'contacts_page', - 'banking_details', - 'store_info', - 'website_basic_requirement', - 'processing_details', - 'company_documents', - 'finish', - ], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - data: { - context: @, - endUser: entity.data.additionalInfo.mainRepresentative, - business: entity.data, - ballerineEntityId: entity.ballerineEntityId - } - }`, - }, - ], - }, - }, - { - name: 'fetch_company_information', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/business/business-information`, - method: 'GET', - stateNames: [], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - token: flowConfig.tokenId, - registrationNumber: entity.data.registrationNumber, - countryCode: entity.data.country, - state: entity.data.additionalInfo.state || '', - vendor: 'open-corporates' - }`, - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - companyName: name, - taxIdentificationNumber: vat, - numberOfEmployees: numberOfEmployees, - businessType: companyType, - additionalInfo: {openCorporate: @} - }`, - }, - ], - }, - persistResponseDestination: 'entity.data', - successAction: 'business_information', - errorAction: 'business_information', - }, - { - name: 'send_collection_flow_finished', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/send-event/?token={flowConfig.tokenId}`, - method: 'POST', - stateNames: ['finish'], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{eventName: 'COLLECTION_FLOW_FINISHED'}`, - }, - ], - }, - }, - ], - commonPlugins: [ - { - name: 'state_value_removal', - pluginKind: 'transformer', - transformers: [ - { - transformer: 'helpers', - mapping: [ - { - method: 'remove', - source: 'entity.data.additionalInfo.state', - target: 'entity.data.additionalInfo.state', - }, - ], - }, - ], - stateNames: ['business_information'], - }, - { - name: 'remove_physical_address', - pluginKind: 'transformer', - transformers: [ - { - transformer: 'helpers', - mapping: [ - { - method: 'remove', - source: 'entity.data.additionalInfo.headquarters.physical', - target: 'entity.data.additionalInfo.headquarters.physical', - }, - ], - }, - ], - stateNames: ['business_address_information'], - }, - ], - }, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/index.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/index.ts deleted file mode 100644 index b4e2bf592b..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './clipspay.template'; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/types.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/types.ts deleted file mode 100644 index 15e6ec20e7..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/types.ts +++ /dev/null @@ -1,29 +0,0 @@ -interface DemoCustomer { - displayName: string; - name: string; - apiKey: string; - logoImageUrl: string; -} - -interface ClipspayUser { - firstName: string; - lastName: string; - email: string; - password: string; -} - -interface ClipspayProject { - id: string; -} - -interface ClipspayFilter { - name: string; -} - -export interface ClipspayGenerationParams { - definition: { id: string; name: string }; - customer: DemoCustomer; - user: ClipspayUser; - project: ClipspayProject; - filter: ClipspayFilter; -} diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/workflow-definition/state-schemas/idle/clipspay.idle.schema.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/workflow-definition/state-schemas/idle/clipspay.idle.schema.ts deleted file mode 100644 index 03c0b9652d..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/workflow-definition/state-schemas/idle/clipspay.idle.schema.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { Type } from '@sinclair/typebox'; - -const clipspayEntityUISchema = { - id: { - 'ui:title': 'Entity ID (As represented in your system)', - }, - type: { - hidden: true, - }, - data: { - 'ui:label': false, - companyName: { - 'ui:title': 'Company Name', - }, - additionalInfo: { - 'ui:label': false, - mainRepresentative: { - 'ui:label': false, - 'ui:order': ['email', 'firstName', 'lastName'], - email: { - 'ui:title': 'Email', - }, - firstName: { - 'ui:title': 'First Name', - }, - lastName: { - 'ui:title': 'Last Name', - }, - }, - }, - }, -}; - -export const ClipspayEntitySchema = Type.Object({ - id: Type.String(), - type: Type.String({ default: 'business' }), - data: Type.Object({ - companyName: Type.String(), - additionalInfo: Type.Object({ - mainRepresentative: Type.Object({ - firstName: Type.String(), - lastName: Type.String(), - email: Type.String({ format: 'email' }), - }), - }), - }), -}); - -export const clipspayInputSchema = { - dataSchema: ClipspayEntitySchema, - uiSchema: clipspayEntityUISchema, -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/workflow-definition/workflow-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/workflow-definition/workflow-definition.ts deleted file mode 100644 index cfd44f17bc..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/clipspay/workflow-definition/workflow-definition.ts +++ /dev/null @@ -1,380 +0,0 @@ -import { env } from '@/env'; -import { defaultContextSchema, StateTag } from '@ballerine/common'; -import { clipspayInputSchema } from 'prisma/data-migrations/templates/creation/clipspay/workflow-definition/state-schemas/idle/clipspay.idle.schema'; -import { kycEmailSessionDefinition } from 'prisma/data-migrations/templates/creation/common/generate-kyc-email-process'; -import { - BUSINESS_UBO_AND_SANCTIONS_DONE, - KYC_DONE_RULE, - kycAndVendorDone, -} from 'prisma/data-migrations/templates/utils/rules'; -import { - createPluginAsyncResponseTransform, - createPluginSyncOrAsyncResponseTransform, - createPluginSyncResponseTransform, -} from '../../../../utils/create-plugin-response-mapping'; - -export const generateWorkflowDefinition = (id: string, name: string, projectId?: string) => { - return { - id, - name, - displayName: 'KYB', - version: 1, - definitionType: 'statechart-json', - definition: { - id: `${id}_v1`, - predictableActionArguments: true, - initial: 'idle', - context: { - documents: [], - }, - states: { - idle: { - on: { - START: 'collection_invite', - }, - meta: { - inputSchema: clipspayInputSchema, - }, - }, - collection_invite: { - on: { - INVIATION_SENT: 'collection_flow', - INVIATION_FAILURE: 'failed', - }, - }, - collection_flow: { - tags: [StateTag.COLLECTION_FLOW], - on: { - COLLECTION_FLOW_FINISHED: [{ target: 'run_ubos' }], - }, - }, - run_ubos: { - tags: [StateTag.COLLECTION_FLOW], - on: { - EMAIL_SENT_TO_UBOS: [{ target: 'run_vendor_data' }], - FAILED_EMAIL_SENT_TO_UBOS: [{ target: 'failed' }], - }, - }, - run_vendor_data: { - tags: [StateTag.DATA_ENRICHMENT], - on: { - KYC_RESPONDED: [kycAndVendorDone], - VENDOR_DONE: [ - { - target: 'pending_kyc_response_to_finish', - cond: { - type: 'jmespath', - options: { - rule: `!(${KYC_DONE_RULE()}) && ${BUSINESS_UBO_AND_SANCTIONS_DONE}`, - }, - }, - }, - kycAndVendorDone, - ], - VENDOR_FAILED: 'failed', - }, - }, - pending_kyc_response_to_finish: { - tags: [StateTag.PENDING_PROCESS], - on: { - KYC_RESPONDED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: KYC_DONE_RULE(), - }, - }, - }, - ], - reject: 'rejected', - revision: 'pending_resubmission', - }, - }, - manual_review: { - tags: [StateTag.MANUAL_REVIEW], - on: { - approve: 'approved', - reject: 'rejected', - revision: 'pending_resubmission', - KYC_REVISION: 'pending_kyc_response_to_finish', - }, - }, - pending_resubmission: { - tags: [StateTag.REVISION], - on: { - EMAIL_SENT: 'revision', - EMAIL_FAILURE: 'failed', - }, - }, - failed: { - tags: [StateTag.FAILURE], - type: 'final' as const, - }, - approved: { - tags: [StateTag.APPROVED], - type: 'final' as const, - }, - revision: { - tags: [StateTag.REVISION], - on: { - COLLECTION_FLOW_FINISHED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE()}`, - }, - }, - }, - { target: 'pending_kyc_response_to_finish' }, - ], - }, - }, - rejected: { - tags: [StateTag.REJECTED], - type: 'final' as const, - }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'collection_invite_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - successAction: 'INVIATION_SENT', - errorAction: 'INVIATION_FAILURE', - method: 'POST', - stateNames: ['collection_invite'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - customerName: metadata.customerName, - collectionFlowUrl: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token,'&lng=',workflowRuntimeConfig.language]), - from: 'no-reply@ballerine.com', - receivers: [entity.data.additionalInfo.mainRepresentative.email], - language: workflowRuntimeConfig.language, - templateId: 'd-8949519316074e03909042cfc5eb4f02', - adapter: '{secret.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - { - name: 'kyb', - displayName: 'Registry Verification', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies-v2/{entity.data.country}/{entity.data.registrationNumber}`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.businessInformation', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `merge( - { vendor: 'asia-verify' }, - entity.data.country == 'HK' && { - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.businessInformation.data&processName=kyb-unified-api']) - } - )`, // jmespath - }, - ], - }, - response: { - transform: createPluginSyncOrAsyncResponseTransform('kyb', "jurisdictionCode == 'HK'"), - }, - }, - { - name: 'company_sanctions', - displayName: 'Company Sanctions', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies/{entity.data.country}/{entity.data.companyName}/sanctions`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.companySanctions', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - vendor: 'asia-verify' - }`, // jmespath - }, - ], - }, - response: { - transform: createPluginSyncResponseTransform('company_sanctions'), - }, - }, - { - name: 'ubo', - displayName: 'UBO Check', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies/{entity.data.country}/{entity.data.registrationNumber}/ubo`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.ubo', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - vendor: 'asia-verify', - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.ubo.data&processName=ubo-unified-api']) - }`, // jmespath - }, - ], - }, - response: { - transform: createPluginAsyncResponseTransform('ubo'), - }, - }, - { - name: 'resubmission_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - method: 'POST', - successAction: 'EMAIL_SENT', - errorAction: 'EMAIL_FAILURE', - stateNames: ['pending_resubmission'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - // #TODO: create new token (new using old one) - mapping: `{ - kybCompanyName: entity.data.companyName, - customerCompanyName: metadata.customerName, - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - resubmissionLink: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token,'&lng=',workflowRuntimeConfig.language]), - supportEmail: join('',['support@',metadata.customerName,'.com']), - from: 'no-reply@ballerine.com', - name: join(' ',[metadata.customerName,'Team']), - receivers: [entity.data.additionalInfo.mainRepresentative.email], - templateId: 'd-7305991b3e5840f9a14feec767ea7301', - revisionReason: documents[].decision[].revisionReason | [0], - language: workflowRuntimeConfig.language, - adapter: '${env.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - ], - childWorkflowPlugins: [ - { - pluginKind: 'child', - name: 'veriff_kyc_child_plugin', - definitionId: kycEmailSessionDefinition().id, - transformers: [ - { - transformer: 'jmespath', - mapping: `{entity: {data: @, type: 'individual'}}`, - }, - { - transformer: 'helper', - mapping: [ - { - source: 'entity.data', - target: 'entity.data', - method: 'omit', - value: ['workflowRuntimeId', 'workflowRuntimeConfig'], - }, - ], - }, - ], - initEvent: 'start', - }, - ], - commonPlugins: [ - { - pluginKind: 'iterative', - name: 'ubos_iterative', - actionPluginName: 'veriff_kyc_child_plugin', - stateNames: ['run_ubos'], - iterateOn: [ - { - transformer: 'jmespath', - mapping: 'entity.data.additionalInfo.ubos', - }, - ], - successAction: 'EMAIL_SENT_TO_UBOS', - errorAction: 'FAILED_EMAIL_SENT_TO_UBOS', - }, - ], - }, - config: { - language: 'en', - supportedLanguages: ['en', 'cn'], - initialEvent: 'START', - createCollectionFlowToken: true, - childCallbackResults: [ - { - definitionId: kycEmailSessionDefinition().name, - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - persistenceStates: ['kyc_manual_review'], - deliverEvent: 'KYC_RESPONDED', - }, - { - definitionId: kycEmailSessionDefinition().name, - persistenceStates: ['revision_email_sent'], - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - deliverEvent: 'KYC_REVISION', - }, - ], - workflowLevelResolution: true, - enableManualCreation: true, - isCaseOverviewEnabled: true, - // 'send-event' or 'redirect-to-customer-portal' - kybOnExitAction: 'send-event', - }, - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - isPublic: !projectId, - ...(projectId && { projectId }), - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/common/generate-kyc-email-process.ts b/services/workflows-service/prisma/data-migrations/templates/creation/common/generate-kyc-email-process.ts deleted file mode 100644 index 56da9351ba..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/common/generate-kyc-email-process.ts +++ /dev/null @@ -1,181 +0,0 @@ -import { PrismaClient } from '@prisma/client'; -import { StateTag } from '@ballerine/common'; -import { PrismaTransactionClient } from '@/types'; - -export const kycEmailSessionDefinition = (customerName?: string) => ({ - id: customerName - ? `kyc_email_session_example_${customerName.toLowerCase()}` - : 'kyc_email_session_example', - name: 'kyc_email_session_example', - version: 1, - definitionType: 'statechart-json', - definition: { - id: 'kyc_email_session_example_v1', - predictableActionArguments: true, - initial: 'idle', - states: { - idle: { - tags: [StateTag.PENDING_PROCESS], - on: { - start: 'get_kyc_session', - }, - }, - get_kyc_session: { - tags: [StateTag.PENDING_PROCESS], - on: { - SEND_EMAIL: [{ target: 'email_sent' }], - API_CALL_ERROR: [{ target: 'kyc_auto_reject' }], - }, - }, - get_kyc_session_revision: { - tags: [StateTag.REVISION], - on: { - SEND_EMAIL: [{ target: 'revision_email_sent' }], - API_CALL_ERROR: [{ target: 'kyc_auto_reject' }], - }, - }, - email_sent: { - tags: [StateTag.PENDING_PROCESS], - on: { - KYC_HOOK_RESPONDED: [{ target: 'kyc_manual_review' }], - }, - }, - revision_email_sent: { - tags: [StateTag.REVISION], - on: { - KYC_HOOK_RESPONDED: [{ target: 'kyc_manual_review' }], - }, - }, - kyc_manual_review: { - tags: [StateTag.MANUAL_REVIEW], - on: { - approve: { - target: 'approved', - }, - reject: { - target: 'rejected', - }, - revision: { - target: 'revision', - }, - }, - }, - revision: { - tags: [StateTag.REVISION], - always: [ - { - target: 'get_kyc_session_revision', - }, - ], - }, - kyc_auto_reject: { - tags: [StateTag.REJECTED], - type: 'final' as const, - }, - rejected: { - tags: [StateTag.REJECTED], - type: 'final' as const, - }, - approved: { - tags: [StateTag.APPROVED], - type: 'final' as const, - }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'kyc_session', - pluginKind: 'kyc-session', - url: `{secret.UNIFIED_API_URL}/individual-verification-sessions`, - method: 'POST', - stateNames: ['get_kyc_session', 'get_kyc_session_revision'], - successAction: 'SEND_EMAIL', - errorAction: 'API_CALL_ERROR', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - 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, - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/KYC_HOOK_RESPONDED','?resultDestination=pluginsOutput.kyc_session.kyc_session_1.result']), - vendor: 'veriff' - }`, // jmespath - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: "{kyc_session_1: {vendor: 'veriff', type: 'kyc', result: {metadata: @}}}", // jmespath - }, - ], - }, - }, - { - name: 'session_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - method: 'POST', - stateNames: ['email_sent', 'revision_email_sent'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - kybCompanyName: entity.data.additionalInfo.companyName, - customerCompanyName: entity.data.additionalInfo.customerCompany, - firstName: entity.data.firstName, - kycLink: pluginsOutput.kyc_session.kyc_session_1.result.metadata.url, - from: 'no-reply@ballerine.com', - name: join(' ',[entity.data.additionalInfo.customerCompany,'Team']), - receivers: [entity.data.email], - subject: '{customerCompanyName} activation, Action needed.', - templateId: (documents[].decision[].revisionReason | [0])!=null && 'd-2c6ae291d9df4f4a8770d6a4e272d803' || 'd-61c568cfa5b145b5916ff89790fe2065', - revisionReason: documents[].decision[].revisionReason | [0], - language: workflowRuntimeConfig.language, - supportEmail: join('',['support@',entity.data.additionalInfo.customerCompany,'.com']), - adapter: '{secret.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - ], - }, - config: { - callbackResult: { - transformers: [ - { - transformer: 'jmespath', - mapping: '{data: @}', // jmespath - }, - ], - deliverEvent: 'KYC_DONE', - }, - }, -}); - -export const generateKycSessionDefinition = async ( - prismaClient: PrismaTransactionClient | PrismaClient, - projectId?: string, - customerName?: string, -) => { - return await prismaClient.workflowDefinition.create({ - data: { - ...kycEmailSessionDefinition(customerName), - isPublic: true, - }, - }); -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/create-ln16-for-customer.ts b/services/workflows-service/prisma/data-migrations/templates/creation/create-ln16-for-customer.ts deleted file mode 100644 index b8e683d87a..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/create-ln16-for-customer.ts +++ /dev/null @@ -1,178 +0,0 @@ -import { WorkflowDefinitionRepository } from '@/workflow-defintion/workflow-definition.repository'; -import { defaultContextSchema, StateTag } from '@ballerine/common'; -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { Type } from '@sinclair/typebox'; -import { generateBaseTaskLevelStates } from '../../../../scripts/workflows/generate-base-task-level-states'; -import { generateBusinessesFilter } from '../filters/generate-businesses-filter'; - -const getDocumentsSchema = () => [ - { - category: 'proof_of_ownership', - type: 'form_a', - issuer: { country: 'GH' }, - issuingVersion: 1, - version: 1, - propertiesSchema: Type.Object({ - businessRegistrationNumber: Type.String(), - businessName: Type.String(), - taxIdNumber: Type.String(), - startDate: Type.String({ format: 'date' }), - natureOfBusiness: Type.String(), - addressOfBusiness: Type.String(), - firstName: Type.String(), - middleName: Type.Optional(Type.String()), - familyName: Type.String(), - dateOfBirth: Type.String({ format: 'date' }), - }), - }, - { - category: 'proof_of_ownership', - type: 'certificate_of_registration', - issuer: { country: 'GH' }, - issuingVersion: 1, - version: 1, - propertiesSchema: Type.Object({ - nameOfBusiness: Type.String(), - taxIdNumber: Type.String({ pattern: '^[a-zA-Z0-9]*$' }), - registrationNumber: Type.String({ pattern: '^[a-zA-Z0-9]*$' }), - issueDate: Type.String({ - format: 'date', - formatMaximum: new Date().toISOString().split('T')[0], - }), - }), - }, - { - category: 'proof_of_ownership', - type: 'operating_permit', - issuer: { country: 'GH' }, - issuingVersion: 1, - version: 1, - propertiesSchema: Type.Object({ - nameOfBusinessOrOwner: Type.String({ pattern: '^[a-zA-Z0-9]*$' }), - issueDate: Type.String({ - format: 'date', - formatMaximum: new Date().toISOString().split('T')[0], - }), - businessRegistrationNo: Type.Optional(Type.String()), - dateOfExpiry: Type.String({ - format: 'date', - formatMinimum: new Date().toISOString().split('T')[0], - }), - }), - }, - { - category: 'proof_of_ownership', - type: 'form_3', - issuer: { country: 'GH' }, - issuingVersion: 1, - version: 1, - propertiesSchema: Type.Object({ - companyRegistrationNumber: Type.String(), - companyType: Type.String(), - companyName: Type.String(), - tin: Type.String(), - dateOfIncorporation: Type.String({ format: 'date' }), - natureOfTheBusiness: Type.String(), - businessAddress: Type.String(), - businessOwnerName: Type.String(), - additionalOwners: Type.Optional(Type.String()), - }), - }, - { - category: 'proof_of_ownership', - type: 'certificate_of_incorporation', - issuer: { country: 'GH' }, - issuingVersion: 1, - version: 1, - propertiesSchema: Type.Object({ - registrationNumber: Type.String(), - businessName: Type.String(), - tinNumber: Type.String(), - }), - }, -]; - -export const getFidoWorkflowDefinition = (projectId: string) => { - return { - id: 'fido-l16-business-ghana', - name: 'fido-l16-business-ghana', - version: 1, - definitionType: 'statechart-json', - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - definition: { - id: 'fido-l16-business-ghana-v1', - initial: StateTag.MANUAL_REVIEW, - states: generateBaseTaskLevelStates(), - }, - config: { - completedWhenTasksResolved: true, - workflowLevelResolution: false, - isLegacyReject: true, - isLockedDocumentCategoryAndType: true, - availableDocuments: [ - { - category: 'proof_of_ownership', - type: 'form_a', - }, - { - category: 'proof_of_ownership', - type: 'certificate_of_registration', - }, - { - category: 'proof_of_ownership', - type: 'operating_permit', - }, - { - category: 'proof_of_ownership', - type: 'form_3', - }, - { - category: 'proof_of_ownership', - type: 'certificate_of_incorporation', - }, - ], - theme: { - type: 'documents-review', - }, - }, - documentsSchema: getDocumentsSchema(), - projectId: projectId, - }; -}; - -export const createLn16ForCustomer = async ( - client: PrismaClient, - app: INestApplicationContext, - customerName: string, -) => { - await client.$transaction(async transaction => { - const customer = await transaction.customer.findFirstOrThrow({ - where: { - name: customerName, - }, - select: { - id: true, - projects: true, - }, - }); - const projectId = customer.projects.map(project => project.id)[0]!; - - const definitionData = getFidoWorkflowDefinition(projectId); - - const definition = await app.get(WorkflowDefinitionRepository).create({ - data: definitionData, - }); - - await transaction.filter.create({ - data: generateBusinessesFilter({ - filterName: 'L16 Business - Ghana', - definitionId: definition.id, - projectId, - }), - }); - }); -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/demo/demo.template.ts b/services/workflows-service/prisma/data-migrations/templates/creation/demo/demo.template.ts deleted file mode 100644 index 45715e695f..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/demo/demo.template.ts +++ /dev/null @@ -1,126 +0,0 @@ -import { Template } from '../../template'; -import { DemoTemplateParams } from './types'; -import { PasswordService } from '@/auth/password/password.service'; -import { validateDefinitionLogic } from '@ballerine/workflow-core'; -import { composeDemoChildKycDefinition } from './workflow-definition/compose-demo-child-kyc-definition'; -import { composeDemoKybDefinition } from './workflow-definition/compose-demo-kyb-definition'; -import { composeUiDefinition } from './ui-definition/compose-ui-definition'; -import { generateBusinessesFilter } from '../../filters/generate-businesses-filter'; -import { CustomerService } from '@/customer/customer.service'; - -export class DemoTemplate extends Template { - async generate() { - const customer = await this.createCustomer(); - const user = await this.createUser(); - - const project = await this.createProject(user.id, customer.id); - - const demoKycChildDefinition = composeDemoChildKycDefinition( - `${customer.name}_demo_kyc_email_session`, - `${customer.name}_demo_kyc_email_session`, - project.id, - ); - - const demoKybDefinition = composeDemoKybDefinition( - `${customer.name}_demo_kyb`, - `${customer.name}_demo_kyb`, - demoKycChildDefinition.id, - project.id, - ); - - validateDefinitionLogic(demoKycChildDefinition); - await this.prismaClient.workflowDefinition.create({ - data: { - ...demoKycChildDefinition, - }, - }); - - validateDefinitionLogic(demoKybDefinition); - const workflowDefinition = await this.prismaClient.workflowDefinition.create({ - data: { - ...demoKybDefinition, - }, - }); - - await this.createUIDefinition(workflowDefinition.id, project.id); - - await this.createFilter(project.id, workflowDefinition.id); - - return Promise.resolve(); - } - - private createCustomer() { - const { customer } = this.params; - - const customerService = this.app.get(CustomerService); - - return customerService.create({ - data: { - id: customer.id, - displayName: customer.displayName, - name: customer.name, - authenticationConfiguration: { - apiType: 'API_KEY', - authValue: customer.apiKey, - validUntil: '', - isValid: '', - }, - logoImageUri: customer.logoImageUrl, - }, - }); - } - - private async createUser() { - const { user } = this.params; - - const passwordService = this.app.get(PasswordService); - - return this.prismaClient.user.create({ - data: { - firstName: user.firstName, - lastName: user.lastName, - email: user.email, - password: await passwordService.hash(user.password), - roles: ['user'], - }, - }); - } - - private createProject(userId: string, customerId: string) { - const { project } = this.params; - - return this.prismaClient.project.create({ - data: { - id: project.id, - name: project.id, - customerId, - userToProjects: { - create: { - userId, - }, - }, - }, - }); - } - - private async createUIDefinition(workflowDefinitionId: string, projectId: string) { - return this.prismaClient.uiDefinition.create({ - data: { - ...composeUiDefinition(workflowDefinitionId), - projectId, - }, - }); - } - - private async createFilter(projectId: string, definitionId: string) { - const baseQuery = generateBusinessesFilter({ - filterName: 'KYB (UBOs & Associated Companies)', - definitionId, - projectId, - }); - - return this.prismaClient.filter.create({ - data: baseQuery, - }); - } -} diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/demo/index.ts b/services/workflows-service/prisma/data-migrations/templates/creation/demo/index.ts deleted file mode 100644 index 0f4293a884..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/demo/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './demo.template'; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/demo/types.ts b/services/workflows-service/prisma/data-migrations/templates/creation/demo/types.ts deleted file mode 100644 index 1f0e9da6a6..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/demo/types.ts +++ /dev/null @@ -1,44 +0,0 @@ -interface DemoCustomer { - id: string; - displayName: string; - name: string; - apiKey: string; - logoImageUrl: string; -} - -interface DemoUser { - firstName: string; - lastName: string; - email: string; - password: string; -} - -interface DemoProject { - id: string; -} - -interface DemoFilter { - name: string; -} -interface DefinitionWithChildrenConfig { - parentKybDefinitionId: string; - kybDefinitionName: string; - childKycDefinitionId: string; - childKycDefinitionName: string; -} - -export interface DemoTemplateParams { - // Customer - customer: DemoCustomer; - - // User - user: DemoUser; - - // Project - project: DemoProject; - - // Filter - filter: DemoFilter; - - definitionWithChildren?: DefinitionWithChildrenConfig; -} diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/1-personal-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/1-personal-info-page.ts deleted file mode 100644 index bd0afeda44..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/1-personal-info-page.ts +++ /dev/null @@ -1,290 +0,0 @@ -const validationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['mainRepresentative', 'iHaveSigningAuthority'], - default: {}, - errorMessage: { - required: { - iHaveSigningAuthority: 'This field is required.', - }, - }, - properties: { - mainRepresentative: { - type: 'object', - required: ['phone', 'dateOfBirth', 'firstName', 'lastName', 'additionalInfo'], - errorMessage: { - required: { - phone: 'errorMessage.required.phone', - dateOfBirth: 'errorMessage.required.dateOfBirth', - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - }, - }, - properties: { - phone: { - type: 'string', - pattern: '^[+]?[0-9]{10,15}$', - errorMessage: { - pattern: 'errorMessage.pattern.phone', - }, - }, - dateOfBirth: { - type: 'string', - errorMessage: { - type: 'errorMessage.type.dateOfBirth', - }, - }, - firstName: { - type: 'string', - minLength: 2, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 2, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - }, - }, - additionalInfo: { - type: 'object', - required: ['jobTitle'], - default: {}, - errorMessage: { - required: { - jobTitle: 'errorMessage.required.jobTitle', - }, - }, - properties: { - jobTitle: { - type: 'string', - minLength: 2, - errorMessage: { - minLength: 'errorMessage.minLength.jobTitle', - }, - }, - }, - }, - }, - }, - iHaveSigningAuthority: { - type: 'boolean', - enum: [true], - errorMessage: { - enum: 'errorMessage.error.requiredField', - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -export const PersonalInfoPage = { - type: 'page', - name: 'text.personalInformation', - number: 1, - stateName: 'personal_details', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.personalInformation', - }, - }, - ], - }, - { - type: 'json-form', - valueDestination: 'entity.data.additionalInfo.mainRepresentative', - name: 'json-form:personal-information', - options: { - jsonFormDefinition: { - required: [ - 'first-name-input', - 'last-name-input', - 'job-title-input', - 'date-of-birth-input', - 'phone-number-input', - ], - }, - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - name: 'first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.firstName', - options: { - label: 'Name', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.lastName', - options: { - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'job-title-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.mainRepresentative.additionalInfo.jobTitle', - options: { - label: 'text.jobTitle.label', - hint: 'text.jobTitle.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'date-of-birth-input', - type: 'json-form:date', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.dateOfBirth', - options: { - label: 'text.dateOfBirth.label', - hint: 'DD/MM/YYYY', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - }, - }, - { - name: 'phone-number-input', - type: 'international-phone-number', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.phone', - options: { - label: 'text.phoneNumber', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'PhoneInput', - 'ui:label': true, - }, - }, - }, - { - name: 'authority-checkbox', - type: 'authority-checkbox', - valueDestination: 'entity.data.additionalInfo.iHaveSigningAuthority', - options: { - label: 'text.iHaveSigningAuthority.label', - jsonFormDefinition: { - type: 'boolean', - }, - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionPlugin', - params: { - pluginName: 'update_end_user', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/2-company-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/2-company-info-page.ts deleted file mode 100644 index b630116fd0..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/2-company-info-page.ts +++ /dev/null @@ -1,476 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: [ - 'additionalInfo', - 'businessType', - 'taxIdentificationNumber', - 'companyName', - 'country', - 'registrationNumber', - ], - properties: { - businessType: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.businessType', - maxLength: 'errorMessage.maxLength.businessType', - required: 'errorMessage.required.businessType', - }, - }, - taxIdentificationNumber: { - type: 'string', - minLength: 8, - maxLength: 15, - pattern: '^[^\\s]*$', - errorMessage: { - minLength: 'errorMessage.minLength.taxIdentificationNumber', - maxLength: 'errorMessage.maxLength.taxIdentificationNumber', - pattern: 'errorMessage.pattern.taxIdentificationNumber', - required: 'errorMessage.equired.taxIdentificationNumber', - }, - }, - companyName: { - type: 'string', - minLength: 2, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.companyName', - maxLength: 'errorMessage.maxLength.companyName', - required: 'errorMessage.required.companyName', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength.country', - pattern: 'errorMessage.pattern.country', - required: 'errorMessage.required.country', - }, - }, - registrationNumber: { - type: 'string', - minLength: 4, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.registrationNumber', - maxLength: 'errorMessage.maxLength.registrationNumber', - required: 'errorMessage.required.registrationNumber', - }, - }, - additionalInfo: { - type: 'object', - required: ['dateOfEstablishment'], - properties: { - dateOfEstablishment: { - type: 'string', - }, - }, - errorMessage: { - required: { - dateOfEstablishment: 'errorMessage.error.requiredField', - }, - }, - }, - }, - errorMessage: { - required: { - businessType: 'errorMessage.required.businessType', - numberOfEmployees: 'errorMessage.required.numberOfEmployees', - taxIdentificationNumber: 'errorMessage.required.taxIdentificationNumber', - companyName: 'errorMessage.required.companyName', - country: 'errorMessage.required.country', - registrationNumber: 'errorMessage.required.registrationNumber', - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const dispatchOpenCorporateRule = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - default: {}, - properties: { - data: { - type: 'object', - required: ['registrationNumber', 'country'], - default: {}, - properties: { - registrationNumber: { - type: 'string', - minLength: 6, - maxLength: 20, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - }, - additionalInfo: { - type: 'object', - properties: { - state: { - type: 'string', - minLength: 1, - }, - }, - }, - }, - if: { - properties: { - country: { - enum: ['AE', 'US', 'CA'], - }, - }, - }, - then: { - required: ['additionalInfo'], - properties: { - additionalInfo: { - required: ['state'], - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const stateVisiblityRule = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['country'], - default: {}, - properties: { - country: { - type: 'string', - enum: ['AE', 'US', 'CA'], - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const CompanyInfoPage = { - type: 'page', - number: 2, // routing number of page - stateName: 'company_information', // this is the route from xstate - name: 'text.companyInformation', // page name ( in stepper ) - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyInformation', - }, - }, - ], - }, - { - type: 'json-form', - name: 'business_info_form_p1', - options: { - jsonFormDefinition: { - required: ['registration-number-input', 'country-picker-input'], - }, - }, - elements: [ - { - name: 'registration-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.registrationNumber', - options: { - label: 'text.registrationNumber.label', - hint: 'text.registrationNumber.hint', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - }, - }, - { - name: 'country-picker-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.country', - options: { - label: 'text.registeredCountry.label', - hint: 'text.registeredCountry.hint', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.registeredCountry.placeholder', - }, - }, - }, - ], - }, - { - name: 'business_info_form_p2', - type: 'json-form', - options: { - jsonFormDefinition: { - required: ['business_info_state_input'], - }, - }, - visibleOn: [ - { - type: 'json-schema', - value: stateVisiblityRule, - }, - ], - elements: [ - { - name: 'business_info_state_input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.state', - options: { - label: 'text.state.label', - hint: 'text.state.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'StatePicker', - }, - countryCodePath: 'entity.data.country', - }, - }, - ], - }, - { - name: 'business_info_form_p3', - type: 'json-form', - options: { - jsonFormDefinition: { - required: [ - 'company-name-input', - 'tax-identification-number-input', - 'number-of-employees-input', - 'business-type-input', - 'registered-capital-in-yuan-type-input', - 'date-of-establishment-input', - ], - }, - }, - elements: [ - { - name: 'company-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.companyName', - options: { - label: 'text.legalName', - hint: 'OpenAI Technologies, Inc.', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - }, - }, - { - name: 'tax-identification-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.taxIdentificationNumber', - options: { - label: 'text.taxIdentificationNumber.label', - hint: 'text.taxIdentificationNumber.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'business-type-input', - type: 'json-form:dropdown', - valueDestination: 'entity.data.businessType', - options: { - hint: 'text.businessType.hint', - label: 'text.businessType.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'AutocompleteInput', - 'ui:label': true, - options: [ - { - title: 'text.businessType.options.sole_proprietorship', - const: 'sole_proprietorship', - }, - { - title: 'text.businessType.options.partnership', - const: 'partnership', - }, - { - title: 'text.businessType.options.corporation', - const: 'corporation', - }, - { - title: 'text.businessType.options.limited_liability_company', - const: 'limited_liability_company_(llc)', - }, - { - title: 'text.businessType.options.limited_partnership', - const: 'limited_partnership_(lp)', - }, - { - title: 'text.businessType.options.limited_liability_partnership', - const: 'limited_liability_partnership_(llp)', - }, - { - title: 'text.businessType.options.public_limited_company', - const: 'public_limited_company_(plc)', - }, - { - title: 'text.businessType.options.private_limited_company', - const: 'private_limited_company_(ltd)', - }, - { - title: 'text.businessType.options.non_profit_organization', - const: 'non-profit_organization', - }, - { - title: 'text.businessType.options.cooperative', - const: 'cooperative', - }, - { - title: 'text.businessType.options.trust', - const: 'trust', - }, - { - title: 'text.businessType.options.government', - const: 'government', - }, - { - title: 'text.businessType.options.other', - const: 'other', - }, - ], - }, - }, - }, - { - name: 'date-of-establishment-input', - type: 'json-form:date', - valueDestination: 'entity.data.additionalInfo.dateOfEstablishment', - options: { - label: 'text.established.label', - hint: 'DD/MM/YYYY', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionPlugin', - params: { pluginName: 'fetch_company_information', debounce: 700 }, - dispatchOn: { - uiEvents: [ - { event: 'onChange', uiElementName: 'registration-number-input' }, - { event: 'onChange', uiElementName: 'country-picker-input' }, - { event: 'onChange', uiElementName: 'business_info_state_input' }, - ], - rules: [ - { - type: 'json-schema', - value: dispatchOpenCorporateRule, - }, - ], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/3-business-address-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/3-business-address-info-page.ts deleted file mode 100644 index 17f52351ff..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/3-business-address-info-page.ts +++ /dev/null @@ -1,262 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['headquarters'], - default: {}, - properties: { - headquarters: { - type: 'object', - default: {}, - required: ['street', 'streetNumber', 'city', 'country', 'postalCode', 'phone'], - errorMessage: { - required: { - street: 'errorMessage.required.street', - streetNumber: 'errorMessage.required.streetNumber', - city: 'errorMessage.required.city', - country: 'errorMessage.required.country', - postalCode: 'errorMessage.error.requiredField', - phone: 'errorMessage.error.requiredField', - }, - }, - properties: { - street: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.street', - maxLength: 'errorMessage.maxLength.street', - }, - }, - streetNumber: { - type: 'number', - minLength: 1, - maxLength: 10, - errorMessage: { - minLength: 'errorMessage.minLength.streetNumber', - maxLength: 'errorMessage.maxLength.streetNumber', - }, - }, - postalCode: { - type: 'string', - }, - city: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.city', - maxLength: 'errorMessage.maxLength.city', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength.country', - pattern: 'errorMessage.pattern.country', - }, - }, - phone: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const BusinessAddressInfoPage = { - type: 'page', - number: 3, - stateName: 'business_address_information', - name: 'text.headquartersAddress', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.headquartersAddress', - }, - }, - { - type: 'h3', - options: { - text: 'text.registeredAddress', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'business-address-form', - options: { - jsonFormDefinition: { - required: [ - 'street-input', - 'street-number-input', - 'postal-code-input', - 'city-input', - 'country-input', - 'headquarters-phone-number-input', - ], - }, - }, - elements: [ - { - name: 'street-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.street', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.street.label', - hint: 'text.street.hint', - }, - }, - { - name: 'street-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.streetNumber', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.number', - hint: '10', - }, - }, - { - name: 'postal-code-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.postalCode', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.postalCode', - hint: '10', - }, - }, - { - name: 'city-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.city', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.city.label', - hint: 'text.city.hint', - }, - }, - { - name: 'country-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.additionalInfo.headquarters.country', - options: { - label: 'text.country', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.choose', - }, - }, - }, - { - name: 'headquarters-phone-number-input', - type: 'international-phone-number', - valueDestination: 'entity.data.additionalInfo.headquarters.phone', - options: { - label: 'text.headquartersPhoneNumber.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'PhoneInput', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/4-company-activity.ts b/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/4-company-activity.ts deleted file mode 100644 index 9064c67661..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/4-company-activity.ts +++ /dev/null @@ -1,215 +0,0 @@ -import { singleUrlPattern } from '../../../utils/schema-utils/regex'; - -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - default: {}, - required: [ - 'industry', - 'businessModel', - 'companyWebsite', - 'annualVolume', - 'transactionValue', - ], - properties: { - industry: { - type: 'string', - }, - businessModel: { - type: 'string', - }, - companyWebsite: { - type: 'string', - pattern: singleUrlPattern, - errorMessage: { - pattern: 'errorMessage.pattern.companyWebsite', - }, - }, - annualVolume: { - type: 'number', - }, - transactionValue: { - type: 'number', - }, - }, - errorMessage: { - required: { - industry: 'errorMessage.required.industry', - businessModel: 'errorMessage.required.businessModel', - companyWebsite: 'errorMessage.required.companyWebsite', - annualVolume: 'errorMessage.error.requiredField', - transactionValue: 'errorMessage.error.requiredField', - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; -export const CompanyActivityPage = { - type: 'page', - number: 4, - stateName: 'company_activity', - name: 'text.companyActivity', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyActivity', - }, - }, - ], - }, - { - name: 'company-activity-inputs-group', - type: 'json-form', - options: { - jsonFormDefinition: { - required: [ - 'industry-input', - 'business-model-input', - 'company-website-input', - 'annual-volume-amount-input', - 'transaction-value-input', - ], - }, - }, - elements: [ - { - name: 'industry-input', - type: 'dropdown', - valueDestination: 'entity.data.additionalInfo.industry', - options: { - label: 'text.industryInput.label', - hint: 'text.industryInput.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'IndustriesPicker', - }, - }, - }, - { - name: 'business-model-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.businessModel', - options: { - label: 'text.businessModelInput.label', - hint: 'text.businessModelInput.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:widget': 'textarea', - }, - }, - }, - { - name: 'company-website-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.companyWebsite', - options: { - label: 'text.companyWebsiteInput.label', - hint: 'text.companyWebsiteInput.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'annual-volume-amount-input', - type: 'number-field', - valueDestination: 'entity.data.additionalInfo.annualVolume', - options: { - label: 'text.annualVolumeAmountInput.label', - hint: 'text.annualVolumeAmountInput.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'transaction-value-input', - type: 'number-field', - valueDestination: 'entity.data.additionalInfo.transactionValue', - options: { - label: 'text.averageTransactionValueInput.label', - hint: 'text.averageTransactionValueInput.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/5-bank-information.ts b/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/5-bank-information.ts deleted file mode 100644 index 1ac5dec36b..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/5-bank-information.ts +++ /dev/null @@ -1,217 +0,0 @@ -import { currencyCodes } from '../../../utils/schema-utils/currency-codes'; - -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - default: {}, - required: ['data'], - properties: { - data: { - type: 'object', - default: {}, - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['bankInformation'], - default: {}, - properties: { - bankInformation: { - type: 'object', - default: {}, - errorMessage: { - required: { - country: 'errorMessage.required.bankCountry', - name: 'errorMessage.required.bankName', - holderName: 'errorMessage.required.holderName', - accountNumber: 'errorMessage.required.accountNumber', - currencyCode: 'errorMessage.required.currency', - }, - }, - required: ['country', 'name', 'holderName', 'accountNumber', 'currencyCode'], - properties: { - country: { - type: 'string', - }, - name: { - type: 'string', - }, - holderName: { - type: 'string', - }, - accountNumber: { - type: 'string', - }, - currencyCode: { - type: 'string', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const BankInformationPage = { - type: 'page', - number: 5, - stateName: 'bank_information', - name: 'text.bankInformation', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.bankInformation', - }, - }, - ], - }, - { - type: 'json-form', - name: 'bank-information-form', - options: { - jsonFormDefinition: { - required: [ - 'bank-country-input', - 'bank-name-input', - 'account-holder-name-input', - 'account-number-input', - 'account-currency-input', - ], - }, - }, - elements: [ - { - name: 'bank-country-input', - type: 'dropdown', - valueDestination: 'entity.data.additionalInfo.bankInformation.country', - options: { - label: 'text.bankCountry.label', - hint: 'text.bankCountry.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - }, - }, - }, - { - name: 'bank-name-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.bankInformation.name', - options: { - label: 'text.bankName.label', - hint: 'text.bankName.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'account-holder-name-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.bankInformation.holderName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.accountHolderName.label', - hint: 'text.accountHolderName.hint', - }, - }, - { - name: 'account-number-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.bankInformation.accountNumber', - options: { - label: 'text.accountNumber.label', - hint: 'text.accountNumber.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'account-currency-input', - type: 'text-field', - valueDestination: 'entity.data.additionalInfo.bankInformation.currencyCode', - options: { - label: 'text.currency.label', - hint: 'GBP', - jsonFormDefinition: { - type: 'string', - oneOf: currencyCodes.map(code => ({ - const: code.code, - title: code.code, - })), - }, - }, - }, - ], - }, - { - name: 'contact-controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/6-company-ownership.ts b/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/6-company-ownership.ts deleted file mode 100644 index 8622ae6f5e..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/6-company-ownership.ts +++ /dev/null @@ -1,582 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['ubos', 'directors'], - properties: { - ubos: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'errorMessage.required.ubos', - }, - items: { - type: 'object', - required: ['firstName', 'lastName', 'email'], - properties: { - firstName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['role', 'dateOfBirth'], - errorMessage: { - required: { - role: 'errorMessage.error.requiredField', - dateOfBirth: 'errorMessage.error.requiredField', - }, - }, - properties: { - role: { - type: 'string', - }, - dateOfBirth: { - type: 'string', - }, - }, - }, - }, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - email: 'errorMessage.required.email', - }, - }, - }, - }, - directors: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'errorMessage.required.ubos', - }, - items: { - type: 'object', - required: ['firstName', 'lastName', 'email'], - properties: { - firstName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['role', 'dateOfBirth'], - errorMessage: { - required: { - role: 'errorMessage.error.requiredField', - dateOfBirth: 'errorMessage.required.dateOfBirth', - }, - }, - properties: { - role: { - type: 'string', - }, - dateOfBirth: { - type: 'string', - }, - }, - }, - }, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - email: 'errorMessage.required.email', - }, - }, - }, - }, - }, - errorMessage: { - required: { - ubos: 'errorMessage.required.ubos', - directors: 'errorMessage.required.directors', - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const CompanyOwnershipPage = { - type: 'page', - number: 6, - stateName: 'company_ownership', - name: 'text.companyOwnership', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyOwnership', - }, - }, - { - type: 'h3', - options: { - text: 'text.shareholders', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'im-shareholder-checkbox-form', - options: { - jsonFormDefinition: { - required: ['im-shareholder-checkbox'], - }, - }, - elements: [ - { - type: 'checkbox', - name: 'im-shareholder-checkbox', - valueDestination: 'entity.data.additionalInfo.imShareholder', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.imShareholder', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'checkbox-description-1', - options: { - descriptionRaw: 'text.shareholdersDescription', - }, - }, - { - type: 'json-form', - name: 'ubos-form', - valueDestination: 'entity.data.additionalInfo.ubos', - options: { - description: 'text.shareholdersDescription', - jsonFormDefinition: { - title: 'text.shareholder', - type: 'array', - required: [ - 'ubos:first-name-input', - 'ubos:last-name-input', - 'ubos:title-input', - 'ubos:email-input', - 'ubos:date-of-birth-input', - ], - }, - uiSchema: { - titleTemplate: 'text.uboIndex', - }, - insertionParams: { - insertionStrategy: 'array', - destination: 'entity.data.additionalInfo.ubos', - schema: { - firstName: 'entity.data.additionalInfo.mainRepresentative.firstName', - lastName: 'entity.data.additionalInfo.mainRepresentative.lastName', - email: 'entity.data.additionalInfo.mainRepresentative.email', - }, - bindingAnchorDestination: 'additionalInfo.__isGeneratedAutomatically', - disableElements: [ - { - elementName: 'ubos:first-name-input', - atIndex: 0, - }, - { - elementName: 'ubos:last-name-input', - atIndex: 0, - }, - { - elementName: 'ubos:email-input', - atIndex: 0, - }, - ], - insertWhen: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.imShareholder' }, true], - }, - }, - ], - removeWhen: [ - { - type: 'json-logic', - value: { - if: [ - { - var: 'entity.data.additionalInfo.imShareholder', - }, - false, - true, - ], - }, - }, - ], - }, - }, - elements: [ - { - name: 'ubos:first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].firstName', //entity.data.additionalInfo.ubos[0].firstName - options: { - label: 'text.firstName', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].lastName', - options: { - label: 'text.lastName', - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:title-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.role', - options: { - label: 'text.jobTitle.label', - hint: 'text.jobTitle.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:date-of-birth-input', - type: 'json-form:date', - valueDestination: - 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.dateOfBirth', - options: { - label: 'text.dateOfBirth.label', - hint: 'DD/MM/YYYY', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - }, - }, - { - name: 'ubos:email-input', - type: 'json-form:email', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - ], - }, - { - type: 'divider', - }, - { - type: 'h3', - options: { - text: 'text.directors', - classNames: ['padding-top-10'], - }, - }, - { - type: 'description', - options: { - descriptionRaw: 'text.directorsDescription', - }, - }, - { - type: 'json-form', - name: 'im-director-checkbox-form', - elements: [ - { - type: 'checkbox', - name: 'im-director-checkbox', - valueDestination: 'entity.data.additionalInfo.imDirector', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.imDirector', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'directors-form', - valueDestination: 'entity.data.additionalInfo.directors', - options: { - description: 'text.directorsDescription', - jsonFormDefinition: { - title: 'text.shareholder', - type: 'array', - required: [ - 'directors:first-name-input', - 'directors:last-name-input', - 'directors:title-input', - 'directors:email-input', - 'directors:date-of-birth-input', - ], - }, - uiSchema: { - titleTemplate: 'text.directorIndex', - }, - insertionParams: { - insertionStrategy: 'array', - destination: 'entity.data.additionalInfo.directors', - schema: { - firstName: 'entity.data.additionalInfo.mainRepresentative.firstName', - lastName: 'entity.data.additionalInfo.mainRepresentative.lastName', - email: 'entity.data.additionalInfo.mainRepresentative.email', - }, - bindingAnchorDestination: 'additionalInfo.__isGeneratedAutomatically', - disableElements: [ - { - elementName: 'directors:first-name-input', - atIndex: 0, - }, - { - elementName: 'directors:last-name-input', - atIndex: 0, - }, - { - elementName: 'directors:email-input', - atIndex: 0, - }, - ], - insertWhen: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.imDirector' }, true], - }, - }, - ], - removeWhen: [ - { - type: 'json-logic', - value: { - if: [ - { - var: 'entity.data.additionalInfo.imDirector', - }, - false, - true, - ], - }, - }, - ], - }, - }, - elements: [ - { - name: 'directors:first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].firstName', //entity.data.additionalInfo.ubos[0].firstName - options: { - label: 'text.firstName', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'directors:last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].lastName', - options: { - label: 'text.lastName', - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'directors:title-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].additionalInfo.role', - options: { - label: 'text.jobTitle.label', - hint: 'text.jobTitle.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'directors:date-of-birth-input', - type: 'json-form:date', - valueDestination: - 'entity.data.additionalInfo.directors[{INDEX}].additionalInfo.dateOfBirth', - options: { - label: 'text.dateOfBirth.label', - hint: 'DD/MM/YYYY', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - }, - }, - { - name: 'directors:email-input', - type: 'json-form:email', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/7-company-documents.ts b/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/7-company-documents.ts deleted file mode 100644 index 0cb07e2c49..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/7-company-documents.ts +++ /dev/null @@ -1,269 +0,0 @@ -const validationSchema = [ - { - documentId: 'document-bank-statement', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-company-structure', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-certificate-of-registration', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-proof-of-address', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, -]; - -export const CompanyDocumentsPage = { - type: 'page', - number: 7, - stateName: 'company_documents', - name: 'text.companyDocuments', - pageValidation: [ - { - type: 'destination-engine', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyDocuments', - }, - }, - { - type: 'h3', - options: { - text: 'text.merchantCompanyDocuments', - }, - }, - ], - }, - { - type: 'json-form', - name: 'company-documents-form', - options: { - jsonFormDefinition: { - required: [ - 'document-bank-statement', - 'document-company-structure', - 'document-certificate-of-registration', - 'document-proof-of-address', - ], - }, - }, - elements: [ - { - name: 'document-bank-statement', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.documents.bankStatement.label', - description: 'text.documents.bankStatement.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-bank-statement', - category: 'proof_of_address', - type: 'bank_statement', - issuer: { - country: 'GH', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-company-structure', - type: 'document', - valueDestination: 'documents[1].pages[0].ballerineFileId', - options: { - label: 'text.documents.companyStructure.label', - description: 'text.documents.companyStructure.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-company-structure', - category: 'proof_of_employment', - type: 'payslip', - issuer: { - country: 'GH', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-certificate-of-registration', - type: 'document', - valueDestination: 'documents[2].pages[0].ballerineFileId', - options: { - label: 'text.documents.certificateOfRegistration.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-certificate-of-registration', - category: 'proof_of_registration', - type: 'certificate_of_registration', - issuer: { - country: 'GH', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-proof-of-address', - type: 'document', - valueDestination: 'documents[3].pages[0].ballerineFileId', - options: { - label: 'text.documents.utilityBill.label', - description: 'text.documents.utilityBill.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-proof-of-address', - category: 'proof_of_address', - type: 'water_bill', - issuer: { - country: 'GH', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'accuracy-description', - options: { - descriptionRaw: 'text.emailDescription', - }, - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.finish', - }, - availableOn: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'jmespath', - value: '!contains(uiState.elements.*.isLoading,`true`)', - }, - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.hasConfirmed' }, true, false], - }, - }, - { - type: 'json-logic', - value: { '!==': [{ var: 'uiState.isLoading' }, true, false] }, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'destination-engine', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionPlugin', - params: { pluginName: 'sync_workflow_runtime', debounce: 50 }, - dispatchOn: { - uiEvents: [ - { - event: 'onChange', - uiElementName: 'document-bank-statement', - }, - { - event: 'onChange', - uiElementName: 'document-company-structure', - }, - { - event: 'onChange', - uiElementName: 'document-certificate-of-registration', - }, - { - event: 'onChange', - uiElementName: 'document-proof-of-address', - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/compose-ui-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/compose-ui-definition.ts deleted file mode 100644 index 4a839f18ec..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/compose-ui-definition.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { definition } from './defintion-logic'; -import { PersonalInfoPage } from './1-personal-info-page'; -import { CompanyInfoPage } from './2-company-info-page'; -import { BusinessAddressInfoPage } from './3-business-address-info-page'; -import { CompanyActivityPage } from './4-company-activity'; -import { BankInformationPage } from './5-bank-information'; -import { CompanyOwnershipPage } from './6-company-ownership'; -import { CompanyDocumentsPage } from './7-company-documents'; -import { Prisma } from '@prisma/client'; - -export const composeUiDefinition = ( - workflowDefinitionId: string, -): Pick< - Prisma.UiDefinitionUncheckedCreateInput, - 'uiContext' | 'uiSchema' | 'definition' | 'workflowDefinitionId' -> => { - return { - uiContext: 'collection_flow', - uiSchema: { - elements: [ - PersonalInfoPage, - CompanyInfoPage, - BusinessAddressInfoPage, - CompanyActivityPage, - BankInformationPage, - CompanyOwnershipPage, - CompanyDocumentsPage, - ], - }, - definition: definition, - workflowDefinitionId: workflowDefinitionId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/defintion-logic.ts b/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/defintion-logic.ts deleted file mode 100644 index 9876852c8f..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/demo/ui-definition/defintion-logic.ts +++ /dev/null @@ -1,166 +0,0 @@ -export const definition = { - definitionType: 'statechart-json', - definition: { - id: 'dynamic_collection_flow', - predictableActionArguments: true, - initial: 'personal_details', - context: {}, - states: { - personal_details: { - on: { - NEXT: 'company_information', - }, - }, - company_information: { - on: { - NEXT: 'business_address_information', - PREVIOUS: 'personal_details', - }, - }, - business_address_information: { - on: { - NEXT: 'company_activity', - PREVIOUS: 'company_information', - }, - }, - company_activity: { - on: { - NEXT: 'bank_information', - PREVIOUS: 'business_address_information', - }, - }, - bank_information: { - on: { - NEXT: 'company_ownership', - PREVIOUS: 'company_activity', - }, - }, - company_ownership: { - on: { - NEXT: 'company_documents', - PREVIOUS: 'bank_information', - }, - }, - company_documents: { - on: { - NEXT: 'finish', - PREVIOUS: 'company_ownership', - }, - }, - finish: { type: 'final' }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'update_end_user', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/end-user?token={flowConfig.tokenId}`, - method: 'POST', - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - stateNames: [], - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - lastName: entity.data.additionalInfo.mainRepresentative.lastName, - additionalInfo: {title: entity.data.additionalInfo.mainRepresentative.additionalInfo.jobTitle}, - phone: entity.data.additionalInfo.mainRepresentative.phone, - dateOfBirth: entity.data.additionalInfo.mainRepresentative.dateOfBirth - }`, - }, - ], - }, - }, - { - name: 'sync_workflow_runtime', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/sync/?token={flowConfig.tokenId}`, - method: 'PUT', - stateNames: [ - 'personal_details', - 'company_information', - 'business_address_information', - 'company_activity', - 'bank_information', - 'company_ownership', - 'company_documents', - 'finish', - ], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - data: { - context: @, - endUser: entity.data.additionalInfo.mainRepresentative, - business: entity.data, - ballerineEntityId: entity.ballerineEntityId - } - }`, - }, - ], - }, - }, - { - name: 'fetch_company_information', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/business/business-information`, - method: 'GET', - stateNames: [], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - token: flowConfig.tokenId, - registrationNumber: entity.data.registrationNumber, - countryCode: entity.data.country, - state: entity.data.additionalInfo.state || '', - vendor: 'open-corporates' - }`, - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - companyName: name, - taxIdentificationNumber: vat, - numberOfEmployees: numberOfEmployees, - businessType: companyType, - additionalInfo: {openCorporate: @} - }`, - }, - ], - }, - persistResponseDestination: 'entity.data', - successAction: 'company_information', - errorAction: 'company_information', - }, - { - name: 'send_collection_flow_finished', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/send-event/?token={flowConfig.tokenId}`, - method: 'POST', - stateNames: ['finish'], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{eventName: 'COLLECTION_FLOW_FINISHED'}`, - }, - ], - }, - }, - ], - }, -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/demo/workflow-definition/compose-demo-child-kyc-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/demo/workflow-definition/compose-demo-child-kyc-definition.ts deleted file mode 100644 index 7821cccfc4..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/demo/workflow-definition/compose-demo-child-kyc-definition.ts +++ /dev/null @@ -1,172 +0,0 @@ -import { env } from '@/env'; -import { StateTag } from '@ballerine/common'; - -export const composeDemoChildKycDefinition = ( - id = 'demo_kyc_email_session_example', - name = 'demo_kyc_email_session_example', - projectId?: string, -) => { - return { - id: id, - name: name, - version: 1, - definitionType: 'statechart-json', - definition: { - id: `${name}_v1`, - predictableActionArguments: true, - initial: 'idle', - states: { - idle: { - tags: [StateTag.PENDING_PROCESS], - on: { - start: 'get_kyc_session', - }, - }, - get_kyc_session: { - tags: [StateTag.PENDING_PROCESS], - on: { - SEND_EMAIL: [{ target: 'email_sent' }], - API_CALL_ERROR: [{ target: 'kyc_auto_reject' }], - }, - }, - get_kyc_session_revision: { - tags: [StateTag.REVISION], - on: { - SEND_EMAIL: [{ target: 'revision_email_sent' }], - API_CALL_ERROR: [{ target: 'kyc_auto_reject' }], - }, - }, - email_sent: { - tags: [StateTag.PENDING_PROCESS], - on: { - KYC_HOOK_RESPONDED: [{ target: 'kyc_manual_review' }], - }, - }, - revision_email_sent: { - tags: [StateTag.REVISION], - on: { - KYC_HOOK_RESPONDED: [{ target: 'kyc_manual_review' }], - }, - }, - kyc_manual_review: { - tags: [StateTag.MANUAL_REVIEW], - on: { - approve: { - target: 'approved', - }, - reject: { - target: 'rejected', - }, - revision: { - target: 'revision', - }, - }, - }, - revision: { - tags: [StateTag.REVISION], - always: [ - { - target: 'get_kyc_session_revision', - }, - ], - }, - kyc_auto_reject: { - tags: [StateTag.REJECTED], - type: 'final' as const, - }, - rejected: { - tags: [StateTag.REJECTED], - type: 'final' as const, - }, - approved: { - tags: [StateTag.APPROVED], - type: 'final' as const, - }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'kyc_session', - pluginKind: 'kyc-session', - url: `{secret.UNIFIED_API_URL}/individual-verification-sessions`, - method: 'POST', - stateNames: ['get_kyc_session', 'get_kyc_session_revision'], - successAction: 'SEND_EMAIL', - errorAction: 'API_CALL_ERROR', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - 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, - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/KYC_HOOK_RESPONDED','?resultDestination=pluginsOutput.kyc_session.kyc_session_1.result']), - vendor: 'veriff' - }`, // jmespath - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: "{kyc_session_1: {vendor: 'veriff', type: 'kyc', result: {metadata: @}}}", // jmespath - }, - ], - }, - }, - { - name: 'session_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - method: 'POST', - stateNames: ['email_sent', 'revision_email_sent'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - kybCompanyName: entity.data.additionalInfo.companyName, - customerCompanyName: entity.data.additionalInfo.customerCompany, - firstName: entity.data.firstName, - kycLink: pluginsOutput.kyc_session.kyc_session_1.result.metadata.url, - from: 'no-reply@ballerine.com', - name: join(' ',[entity.data.additionalInfo.customerCompany,'Team']), - receivers: [entity.data.email], - subject: '{customerCompanyName} activation, Action needed.', - templateId: (documents[].decision[].revisionReason | [0])!=null && 'd-2c6ae291d9df4f4a8770d6a4e272d803' || 'd-61c568cfa5b145b5916ff89790fe2065', - revisionReason: documents[].decision[].revisionReason | [0], - supportEmail: join('',['support@',entity.data.additionalInfo.customerCompany,'.com']), - adapter: '${env.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - ], - }, - config: { - callbackResult: { - transformers: [ - { - transformer: 'jmespath', - mapping: '{data: @}', // jmespath - }, - ], - deliverEvent: 'KYC_DONE', - }, - }, - projectId: projectId, - isPublic: !projectId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/demo/workflow-definition/compose-demo-kyb-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/demo/workflow-definition/compose-demo-kyb-definition.ts deleted file mode 100644 index 39b08e9bec..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/demo/workflow-definition/compose-demo-kyb-definition.ts +++ /dev/null @@ -1,382 +0,0 @@ -import { env } from '@/env'; -import { defaultContextSchema, StateTag } from '@ballerine/common'; -import { - BUSINESS_UBO_AND_SANCTIONS_DONE, - KYC_DONE_RULE, - kycAndVendorDone, -} from '../../../utils/rules'; - -export const composeDemoKybDefinition = ( - id = 'demo_kyb_flow', - name = 'demo_kyb_flow', - kycChildWorkflowDefinitionId: string, - projectId?: string, -) => { - return { - id: id, - name: name, - version: 1, - definitionType: 'statechart-json', - definition: { - id: 'demo_kyb_dynamic_ui_v1', - predictableActionArguments: true, - initial: 'idle', - context: { - documents: [], - }, - states: { - idle: { - on: { - START: 'collection_invite', - }, - }, - collection_invite: { - on: { - INVIATION_SENT: 'collection_flow', - INVIATION_FAILURE: 'failed', - }, - }, - collection_flow: { - tags: [StateTag.COLLECTION_FLOW], - on: { - COLLECTION_FLOW_FINISHED: [{ target: 'run_ubos' }], - }, - }, - run_ubos: { - tags: [StateTag.COLLECTION_FLOW], - on: { - EMAIL_SENT_TO_UBOS: [{ target: 'run_vendor_data' }], - FAILED_EMAIL_SENT_TO_UBOS: [{ target: 'failed' }], - }, - }, - run_vendor_data: { - tags: [StateTag.DATA_ENRICHMENT], - on: { - KYC_RESPONDED: [kycAndVendorDone], - VENDOR_DONE: [ - { - target: 'pending_kyc_response_to_finish', - cond: { - type: 'jmespath', - options: { - rule: `!(${KYC_DONE_RULE( - kycChildWorkflowDefinitionId, - )}) && ${BUSINESS_UBO_AND_SANCTIONS_DONE}`, - }, - }, - }, - kycAndVendorDone, - ], - reject: 'rejected', - VENDOR_FAILED: 'rejected', - }, - }, - pending_kyc_response_to_finish: { - tags: [StateTag.PENDING_PROCESS], - on: { - KYC_RESPONDED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: KYC_DONE_RULE(kycChildWorkflowDefinitionId), - }, - }, - }, - ], - reject: 'rejected', - revision: 'pending_resubmission', - }, - }, - manual_review: { - tags: [StateTag.MANUAL_REVIEW], - on: { - approve: 'approved', - reject: 'rejected', - revision: 'pending_resubmission', - KYC_REVISION: 'pending_kyc_response_to_finish', - }, - }, - pending_resubmission: { - tags: [StateTag.REVISION], - on: { - EMAIL_SENT: 'revision', - EMAIL_FAILURE: 'failed', - }, - }, - failed: { - tags: [StateTag.FAILURE], - type: 'final' as const, - }, - approved: { - tags: [StateTag.APPROVED], - type: 'final' as const, - }, - revision: { - tags: [StateTag.REVISION], - on: { - COLLECTION_FLOW_FINISHED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE(kycChildWorkflowDefinitionId)}`, - }, - }, - }, - { target: 'pending_kyc_response_to_finish' }, - ], - }, - }, - rejected: { - tags: [StateTag.REJECTED], - type: 'final' as const, - }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'collection_invite_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - successAction: 'INVIATION_SENT', - errorAction: 'INVIATION_FAILURE', - method: 'POST', - stateNames: ['collection_invite'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - companyName: entity.data.companyName, - customerName: metadata.customerName, - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - collectionFlowUrl: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token]), - from: 'no-reply@ballerine.com', - receivers: [entity.data.additionalInfo.mainRepresentative.email], - templateId: 'd-8949519316074e03909042cfc5eb4f02', - adapter: '{secret.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - { - name: 'kyb', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies-v2/{entity.data.country}/{entity.data.registrationNumber}`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.businessInformation', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `merge( - { vendor: 'asia-verify' }, - entity.data.country == 'HK' && { - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.businessInformation.data&processName=kyb-unified-api']) - } - )`, // jmespath - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: '@', // jmespath - }, - ], - }, - }, - { - name: 'company_sanctions', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies/{entity.data.country}/{entity.data.companyName}/sanctions`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.companySanctions', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - vendor: 'asia-verify' - }`, // jmespath - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: '@', // jmespath - }, - ], - }, - }, - { - name: 'ubo', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies/{entity.data.country}/{entity.data.registrationNumber}/ubo`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.ubo.request', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - vendor: 'asia-verify', - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.ubo.data&processName=ubo-unified-api']) - }`, // jmespath - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: '{request: @}', // jmespath - }, - ], - }, - }, - { - name: 'resubmission_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - method: 'POST', - successAction: 'EMAIL_SENT', - errorAction: 'EMAIL_FAILURE', - stateNames: ['pending_resubmission'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - // #TODO: create new token (new using old one) - mapping: `{ - kybCompanyName: entity.data.companyName, - customerCompanyName: metadata.customerName, - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - resubmissionLink: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token]), - supportEmail: join('',['support@',metadata.customerName,'.com']), - from: 'no-reply@ballerine.com', - name: join(' ',[metadata.customerName,'Team']), - receivers: [entity.data.additionalInfo.mainRepresentative.email], - templateId: 'd-7305991b3e5840f9a14feec767ea7301', - revisionReason: documents[].decision[].revisionReason | [0], - adapter: '${env.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - ], - childWorkflowPlugins: [ - { - pluginKind: 'child', - name: 'veriff_kyc_child_plugin', - definitionId: kycChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: `{entity: {data: @, type: 'individual'}}`, - }, - { - transformer: 'helper', - mapping: [ - { - source: 'entity.data', - target: 'entity.data', - method: 'omit', - value: ['workflowRuntimeId', 'workflowRuntimeConfig'], - }, - ], - }, - ], - initEvent: 'start', - }, - ], - commonPlugins: [ - { - pluginKind: 'iterative', - name: 'ubos_iterative', - actionPluginName: 'veriff_kyc_child_plugin', - stateNames: ['run_ubos'], - iterateOn: [ - { - transformer: 'jmespath', - mapping: 'entity.data.additionalInfo.ubos', - }, - ], - successAction: 'EMAIL_SENT_TO_UBOS', - errorAction: 'FAILED_EMAIL_SENT_TO_UBOS', - }, - ], - }, - config: { - initialEvent: 'START', - createCollectionFlowToken: true, - childCallbackResults: [ - { - definitionId: kycChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - persistenceStates: ['kyc_manual_review'], - deliverEvent: 'KYC_RESPONDED', - }, - { - definitionId: kycChildWorkflowDefinitionId, - persistenceStates: ['revision_email_sent'], - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - deliverEvent: 'KYC_REVISION', - }, - ], - }, - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - projectId: projectId, - isPublic: !projectId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/1-personal-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/1-personal-info-page.ts deleted file mode 100644 index 1e83c8572b..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/1-personal-info-page.ts +++ /dev/null @@ -1,264 +0,0 @@ -const validationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['mainRepresentative'], - properties: { - mainRepresentative: { - type: 'object', - required: ['phone', 'dateOfBirth', 'firstName', 'lastName', 'additionalInfo'], - errorMessage: { - required: { - phone: 'errorMessage.required.phone', - dateOfBirth: 'errorMessage.required.dateOfBirth', - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - additionalInfo: 'errorMessage.required.additionalInfo', - }, - }, - properties: { - phone: { - type: 'string', - pattern: '^[+]?[0-9]{10,15}$', - errorMessage: { - pattern: 'errorMessage.pattern.phone', - }, - }, - dateOfBirth: { - type: 'string', - errorMessage: { - type: 'errorMessage.type.dateOfBirth', - }, - }, - firstName: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - }, - }, - additionalInfo: { - type: 'object', - required: ['jobTitle'], - default: {}, - errorMessage: { - required: { - jobTitle: 'errorMessage.required.jobTitle', - }, - }, - properties: { - jobTitle: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.jobTitle', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -export const PersonalInfoPage = { - type: 'page', - name: 'text.personalInformation', - number: 1, - stateName: 'personal_details', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.personalInformation', - }, - }, - ], - }, - { - type: 'json-form', - valueDestination: 'entity.data.additionalInfo.mainRepresentative', - name: 'json-form:personal-information', - options: { - jsonFormDefinition: { - required: [ - 'first-name-input', - 'last-name-input', - 'job-title-input', - 'date-of-birth-input', - 'phone-number-input', - ], - }, - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - name: 'first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.firstName', - options: { - label: 'text.name', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.lastName', - options: { - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'job-title-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.mainRepresentative.additionalInfo.jobTitle', - options: { - label: 'text.jobTitle.label', - hint: 'text.jobTitle.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'date-of-birth-input', - type: 'json-form:date', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.dateOfBirth', - options: { - label: 'text.dateOfBirth.label', - hint: 'text.dateHint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - }, - }, - { - name: 'phone-number-input', - type: 'international-phone-number', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.phone', - options: { - label: 'text.phoneNumber', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'PhoneInput', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionPlugin', - params: { - pluginName: 'update_end_user', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/10-company-documents.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/10-company-documents.ts deleted file mode 100644 index e709716e7d..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/10-company-documents.ts +++ /dev/null @@ -1,739 +0,0 @@ -const validationSchema = [ - { - documentId: 'document-certificate-of-incorporation', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-business-registration-certificate', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-proof-of-address', - destination: 'pages[0].ballerineFileId', - required: { - type: 'json-logic', - value: { - '==': [ - { - var: 'entity.data.additionalInfo.headquarters.isDifferentFromPhysical', - }, - true, - false, - ], - }, - }, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-copy-of-business-license', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-memorandum-of-article', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-business-ownership-structure-chart', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-tenancy-agreement', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-tax-return', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-settlement-bank-account-statement', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-financial-statements', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-latest-3-months-processing-statements', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-transaction-information', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-pci-dss-documents', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-mailing-acknowledgement-or-form-sample', - destination: 'pages[0].ballerineFileId', - }, -]; - -const jsonValidationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - required: ['data'], - default: {}, - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - default: {}, - properties: { - additionalInfo: { - type: 'object', - required: ['hasConfirmed'], - properties: { - hasConfirmed: { - type: 'boolean', - default: false, - const: true, - errorMessage: { - const: 'errorMessage.error.requiredField', - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -export const CompanyDocuments = { - type: 'page', - number: 10, - stateName: 'company_documents', - name: 'text.companyDocuments', - pageValidation: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'json-schema', - value: jsonValidationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyDocuments', - }, - }, - ], - }, - { - type: 'json-form', - name: 'company-documents-form-p1', - options: { - jsonFormDefinition: { - required: [ - 'document-certificate-of-incorporation', - 'document-business-registration-certificate', - ], - }, - }, - elements: [ - { - name: 'document-certificate-of-incorporation', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.certificateOfIncorporation.label', - description: 'text.certificateOfIncorporation.description.3months', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-certificate-of-incorporation', - category: 'proof_of_registration', - type: 'certificate_of_incorporation', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-business-registration-certificate', - type: 'document', - valueDestination: 'documents[1].pages[0].ballerineFileId', - options: { - label: 'text.businessRegistrationCertificate.label', - description: 'text.businessRegistrationCertificate.description.3months', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-business-registration-certificate', - category: 'proof_of_registration', - type: 'business_registration_certificate', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-proof-of-address', - type: 'document', - valueDestination: 'documents[2].pages[0].ballerineFileId', - requiredOn: [ - { - type: 'json-logic', - value: { - '==': [ - { - var: 'entity.data.additionalInfo.headquarters.isDifferentFromPhysical', - }, - true, - false, - ], - }, - }, - ], - options: { - label: 'text.proofOfAddress.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-proof-of-address', - category: 'proof_of_address', - type: 'general_document', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-copy-of-business-license', - type: 'document', - valueDestination: 'documents[3].pages[0].ballerineFileId', - options: { - label: 'text.copyOfBusinessLicense.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-copy-of-business-license', - category: 'proof_of_registration', - type: 'business_license', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-memorandum-of-article', - type: 'document', - valueDestination: 'documents[4].pages[0].ballerineFileId', - options: { - label: 'text.memorandumOfArticle.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-memorandum-of-article', - category: 'proof_of_registration', - type: 'memorandum_of_article', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-business-ownership-structure-chart', - type: 'document', - valueDestination: 'documents[5].pages[0].ballerineFileId', - options: { - label: 'text.businessOwnershipStructureChart.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-business-ownership-structure-chart', - category: 'proof_of_ownership', - type: 'ownership_structure_chart', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-tenancy-agreement', - type: 'document', - valueDestination: 'documents[6].pages[0].ballerineFileId', - options: { - label: 'text.tenancyAgreement.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-tenancy-agreement', - category: 'proof_of_location', - type: 'tenancy_agreement', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-tax-return', - type: 'document', - valueDestination: 'documents[7].pages[0].ballerineFileId', - options: { - label: 'text.taxReturn.label', - description: 'text.taxReturn.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-tax-return', - category: 'financial_information', - type: 'tax_return', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'h3', - name: 'financial-documents-title', - options: { - text: 'text.financialDocuments', - }, - }, - { - type: 'json-form', - name: 'company-documents-form-p2', - elements: [ - { - name: 'document-settlement-bank-account-statement', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.settlementBankAccountStatement.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-settlement-bank-account-statement', - category: 'proof_of_bank_account_ownership', - type: 'bank_statement', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-financial-statements', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.financialStatements.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-financial-statements', - category: 'financial_information', - type: 'general_document', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-latest-3-months-processing-statements', - type: 'document', - valueDestination: 'documents[8].pages[0].ballerineFileId', - options: { - label: 'text.latest3MonthsCardProcessingStatements.label', - description: 'text.latest3MonthsCardProcessingStatements.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-latest-3-months-processing-statements', - category: 'financial_information', - type: 'card_processing_statements', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-transaction-information', - type: 'document', - valueDestination: 'documents[8].pages[0].ballerineFileId', - options: { - label: 'text.transactionInformation.label', - description: 'text.transactionInformation.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-transaction-information', - category: 'financial_information', - type: 'transaction_records', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'h3', - name: 'policies-and-compliance-documents-title', - options: { - text: 'text.policiesAndComplianceDocuments', - }, - }, - { - type: 'json-form', - name: 'company-documents-form-p3', - elements: [ - { - name: 'document-psi-dss-documents', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.psiDssDocuments.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-psi-dss-documents', - category: 'compliance_documents', - type: 'pci_dss_certification', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'h3', - name: 'additional-requirements-title', - options: { - text: 'text.additionalRequirements', - }, - }, - { - type: 'json-form', - name: 'company-documents-form-p4', - elements: [ - { - name: 'document-mailing-acknowledgement-or-form-sample', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.mailingAcknowledgementOrFormSample.label', - description: 'text.mailingAcknowledgementOrFormSample.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-mailing-acknowledgement-or-form-sample', - category: 'general_documents', - type: 'mailing_or_acknowledgement_sample', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'h3', - name: 'accuracy-title', - options: { - text: 'text.declarationOfAccuracy', - }, - }, - { - type: 'description', - name: 'accuracy-description', - options: { - descriptionRaw: 'text.declarationOfAccuracyDescription', - }, - }, - { - type: 'json-form', - name: 'confirmation-form', - options: {}, - elements: [ - { - type: 'checkbox', - name: 'documents-confirmation-checkbox', - valueDestination: 'entity.data.additionalInfo.hasConfirmed', - options: { - jsonFormDefinition: { - type: 'boolean', - default: false, - }, - label: 'text.iConfirm', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'divider', - }, - { - type: 'description', - options: { - descriptionRaw: 'text.emailDescription', - }, - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.finish', - }, - availableOn: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'jmespath', - value: '!contains(uiState.elements.*.isLoading,`true`)', - }, - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.hasConfirmed' }, true, false], - }, - }, - { - type: 'json-logic', - value: { '!==': [{ var: 'uiState.isLoading' }, true, false] }, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.hasConfirmed' }, true, false], - }, - }, - ], - }, - }, - { - type: 'definitionPlugin', - params: { pluginName: 'sync_workflow_runtime', debounce: 50 }, - dispatchOn: { - uiEvents: [ - { - event: 'onChange', - uiElementName: 'document-certificate-of-incorporation', - }, - { - event: 'onChange', - uiElementName: 'document-business-registration-certificate', - }, - { - event: 'onChange', - uiElementName: 'document-proof-of-address', - }, - { - event: 'onChange', - uiElementName: 'document-copy-of-business-license', - }, - { - event: 'onChange', - uiElementName: 'document-memorandum-of-article', - }, - { - event: 'onChange', - uiElementName: 'document-business-ownership-structure-chart', - }, - { - event: 'onChange', - uiElementName: 'document-tenancy-agreement', - }, - { - event: 'onChange', - uiElementName: 'document-tax-return', - }, - { - event: 'onChange', - uiElementName: 'document-settlement-bank-account-statement', - }, - { - event: 'onChange', - uiElementName: 'document-financial-statements', - }, - { - event: 'onChange', - uiElementName: 'document-latest-3-months-processing-statements', - }, - { - event: 'onChange', - uiElementName: 'document-transaction-information', - }, - { - event: 'onChange', - uiElementName: 'document-pci-dss-documentst', - }, - { - event: 'onChange', - uiElementName: 'document-mailing-acknowledgement-or-form-sample', - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/2-business-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/2-business-info-page.ts deleted file mode 100644 index cd5b010b52..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/2-business-info-page.ts +++ /dev/null @@ -1,516 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: [ - 'additionalInfo', - 'businessType', - 'numberOfEmployees', - 'taxIdentificationNumber', - 'companyName', - 'country', - 'registrationNumber', - ], - properties: { - additionalInfo: { - type: 'object', - required: ['registeredCapitalInUsd'], - properties: { - registeredCapitalInUsd: { - type: 'number', - minimum: 0, - errorMessage: { - required: 'errorMessage.required.registeredCapitalInUsd', - minimum: 'errorMessage.minimum.registeredCapitalInUsd', - }, - }, - }, - errorMessage: { - required: { - registeredCapitalInUsd: 'errorMessage.required.registeredCapitalInUsd', - }, - }, - }, - businessType: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.businessType', - maxLength: 'errorMessage.maxLength.businessType', - required: 'errorMessage.required.businessType', - }, - }, - numberOfEmployees: { - type: 'number', - minimum: 1, - maximum: 100000, - errorMessage: { - type: 'errorMessage.type.numberOfEmployees', - required: 'errorMessage.required.numberOfEmployees', - minimum: 'errorMessage.minimum.numberOfEmployees', - maximum: 'errorMessage.maximum.numberOfEmployees', - }, - }, - taxIdentificationNumber: { - type: 'string', - minLength: 8, - maxLength: 15, - pattern: '^[^\\s]*$', - errorMessage: { - minLength: 'errorMessage.minLength.taxIdentificationNumber', - maxLength: 'errorMessage.maxLength.taxIdentificationNumber', - pattern: 'errorMessage.pattern.taxIdentificationNumber', - required: 'errorMessage.required.taxIdentificationNumber', - }, - }, - companyName: { - type: 'string', - minLength: 1, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.companyName', - maxLength: 'errorMessage.maxLength.companyName', - required: 'errorMessage.required.companyName', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength.country', - pattern: 'errorMessage.pattern.country', - required: 'errorMessage.required.country', - }, - }, - registrationNumber: { - type: 'string', - minLength: 4, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.registrationNumber', - maxLength: 'errorMessage.maxLength.registrationNumber', - required: 'errorMessage.required.registrationNumber', - }, - }, - }, - errorMessage: { - required: { - additionalInfo: 'errorMessage.required.additionalInfo', - businessType: 'errorMessage.required.businessType', - numberOfEmployees: 'errorMessage.required.numberOfEmployees', - taxIdentificationNumber: 'errorMessage.required.taxIdentificationNumber', - companyName: 'errorMessage.required.companyName', - country: 'errorMessage.required.country', - registrationNumber: 'errorMessage.required.registrationNumber', - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const dispatchOpenCorporateRule = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - default: {}, - properties: { - data: { - type: 'object', - required: ['registrationNumber', 'country'], - default: {}, - properties: { - registrationNumber: { - type: 'string', - minLength: 6, - maxLength: 20, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - }, - additionalInfo: { - type: 'object', - properties: { - state: { - default: '', - type: 'string', - }, - }, - }, - }, - if: { - properties: { - country: { - enum: ['AE', 'US', 'CA'], - }, - }, - }, - then: { - required: ['additionalInfo'], - properties: { - additionalInfo: { - required: ['state'], - properties: { - state: { - minLength: 1, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const stateVisiblityRule = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['country'], - default: {}, - properties: { - country: { - type: 'string', - enum: ['AE', 'US', 'CA'], - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const BusinessInfoPage = { - type: 'page', - number: 2, // routing number of page - stateName: 'business_information', // this is the route from xstate - name: 'text.businessInformation', // page name ( in stepper ) - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.businessInformation', - }, - }, - ], - }, - { - type: 'json-form', - name: 'business_info_form_p1', - options: { - jsonFormDefinition: { - required: ['registration-number-input', 'country-picker-input'], - }, - }, - elements: [ - { - name: 'registration-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.registrationNumber', - options: { - label: 'text.registrationNumber.label', - hint: 'text.registrationNumber.hint', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - }, - }, - { - name: 'country-picker-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.country', - options: { - label: 'text.country', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.choose', - }, - }, - }, - ], - }, - { - name: 'business_info_form_p2', - type: 'json-form', - options: { - jsonFormDefinition: { - required: ['business_info_state_input'], - }, - }, - visibleOn: [ - { - type: 'json-schema', - value: stateVisiblityRule, - }, - ], - elements: [ - { - name: 'business_info_state_input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.state', - options: { - label: 'text.state.label', - hint: 'text.state.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'StatePicker', - }, - countryCodePath: 'entity.data.country', - }, - }, - ], - }, - { - name: 'business_info_form_p3', - type: 'json-form', - options: { - jsonFormDefinition: { - required: [ - 'company-name-input', - 'tax-identification-number-input', - 'number-of-employees-input', - 'business-type-input', - 'registered-capital-in-usd-type-input', - ], - }, - }, - elements: [ - { - name: 'company-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.companyName', - options: { - label: 'text.companyName.label', - hint: 'text.companyName.hint', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - }, - }, - { - name: 'tax-identification-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.taxIdentificationNumber', - options: { - label: 'text.taxIdentificationNumber.label', - hint: 'text.taxIdentificationNumber.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'number-of-employees-input', - type: 'json-form:text', - valueDestination: 'entity.data.numberOfEmployees', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.numberOfEmployees.label', - hint: 'text.numberOfEmployees.hint', - }, - }, - { - name: 'business-type-input', - type: 'json-form:dropdown', - valueDestination: 'entity.data.businessType', - options: { - label: 'text.businessType.label', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'AutocompleteInput', - 'ui:label': true, - options: [ - { - title: 'text.businessType.options.sole_proprietorship', - const: 'sole_proprietorship', - }, - { - title: 'text.businessType.options.partnership', - const: 'partnership', - }, - { - title: 'text.businessType.options.corporation', - const: 'corporation', - }, - { - title: 'text.businessType.options.limited_liability_company', - const: 'limited_liability_company_(llc)', - }, - { - title: 'text.businessType.options.limited_partnership', - const: 'limited_partnership_(lp)', - }, - { - title: 'text.businessType.options.limited_liability_partnership', - const: 'limited_liability_partnership_(llp)', - }, - { - title: 'text.businessType.options.public_limited_company', - const: 'public_limited_company_(plc)', - }, - { - title: 'text.businessType.options.private_limited_company', - const: 'private_limited_company_(ltd)', - }, - { - title: 'text.businessType.options.non_profit_organization', - const: 'non-profit_organization', - }, - { - title: 'text.businessType.options.cooperative', - const: 'cooperative', - }, - { - title: 'text.businessType.options.trust', - const: 'trust', - }, - { - title: 'text.businessType.options.government', - const: 'government', - }, - { - title: 'text.businessType.options.other', - const: 'other', - }, - ], - }, - }, - }, - { - name: 'registered-capital-in-usd-type-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.registeredCapitalInUsd', - options: { - jsonFormDefinition: { - type: 'integer', - }, - format: 'currency', - hint: 'text.registeredCapitalInUsd.hint', - label: 'text.registeredCapitalInUsd.label', - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionPlugin', - params: { pluginName: 'fetch_company_information', debounce: 700 }, - dispatchOn: { - uiEvents: [ - { event: 'onChange', uiElementName: 'registration-number-input' }, - { event: 'onChange', uiElementName: 'country-picker-input' }, - { event: 'onChange', uiElementName: 'business_info_state_input' }, - ], - rules: [ - { - type: 'json-schema', - value: dispatchOpenCorporateRule, - }, - ], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionPlugin', - params: { - pluginName: 'state_value_removal', - }, - dispatchOn: { - uiEvents: [{ event: 'onChange', uiElementName: 'country-picker-input' }], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/3-business-address-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/3-business-address-info-page.ts deleted file mode 100644 index 1d82436a13..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/3-business-address-info-page.ts +++ /dev/null @@ -1,431 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['headquarters'], - default: {}, - properties: { - headquarters: { - type: 'object', - default: {}, - required: ['street', 'streetNumber', 'city', 'country'], - errorMessage: { - required: { - street: 'errorMessage.required.street', - streetNumber: 'errorMessage.required.streetNumber', - city: 'errorMessage.required.city', - country: 'errorMessage.required.country', - isDifferentFromPhysical: 'errorMessage.required.requiredField', - }, - }, - if: { - properties: { - isDifferentFromPhysical: { const: true }, - }, - }, - then: { - required: ['physical'], - errorMessage: { - required: { - street: 'errorMessage.required.street', - streetNumber: 'errorMessage.required.streetNumber', - city: 'errorMessage.required.city', - country: 'errorMessage.required.country', - isDifferentFromPhysical: 'errorMessage.required.requiredField', - }, - }, - properties: { - physical: { - required: ['street', 'streetNumber', 'city', 'country'], - errorMessage: { - required: { - street: 'errorMessage.required.street', - streetNumber: 'errorMessage.required.streetNumber', - city: 'errorMessage.required.city', - country: 'errorMessage.required.country', - isDifferentFromPhysical: 'errorMessage.required.requiredField', - physical: 'errorMessage.required.physical', - }, - }, - }, - }, - }, - properties: { - isDifferentFromPhysical: { - type: 'boolean', - default: false, - }, - street: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.street', - maxLength: 'errorMessage.maxLength.street', - }, - }, - streetNumber: { - type: 'number', - minLength: 1, - maxLength: 10, - errorMessage: { - minLength: 'errorMessage.minLength.streetNumber', - maxLength: 'errorMessage.maxLength.streetNumber', - }, - }, - city: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.city', - maxLength: 'errorMessage.maxLength.city', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength,country', - pattern: 'errorMessage.pattern.country', - }, - }, - physical: { - type: 'object', - default: {}, - properties: { - street: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.street', - maxLength: 'errorMessage.maxLength.street', - }, - }, - streetNumber: { - type: 'number', - minLength: 1, - maxLength: 10, - errorMessage: { - minLength: 'errorMessage.minLength.streetNumber', - maxLength: 'errorMessage.maxLength.streetNumber', - }, - }, - city: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.city', - maxLength: 'errorMessage.maxLength.city', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength,country', - pattern: 'errorMessage.pattern.country', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const physicalAddressForm = { - '==': [{ var: 'entity.data.additionalInfo.headquarters.isDifferentFromPhysical' }, true], -}; - -export const BusinessAddressInfoPage = { - type: 'page', - number: 3, - stateName: 'business_address_information', - name: 'text.businessAddress', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.businessAddress', - }, - }, - { - type: 'h3', - options: { - text: 'text.registeredAddress', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'business-address-form', - options: { - jsonFormDefinition: { - required: [ - 'search-address-input', - 'street-input', - 'street-number-input', - 'city-input', - 'country-input', - ], - }, - }, - elements: [ - { - name: 'street-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.street', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.street.label', - hint: 'text.street.hint', - }, - }, - { - name: 'street-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.streetNumber', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.number', - hint: '10', - }, - }, - { - name: 'city-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.city', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.city.label', - hint: 'text.city.hint', - }, - }, - { - name: 'country-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.additionalInfo.headquarters.country', - options: { - label: 'text.country', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.choose', - }, - }, - }, - { - name: 'different-from-physical-checkbox', - type: 'checkbox', - valueDestination: 'entity.data.additionalInfo.headquarters.isDifferentFromPhysical', - options: { - label: 'text.differentFromPhysicalAddress', - jsonFormDefinition: { - type: 'boolean', - }, - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'physical-business-address-form', - options: { - jsonFormDefinition: { - required: [ - 'physical-search-address-input', - 'physical-street-input', - 'physical-street-number-input', - 'physical-city-input', - 'physical-country-input', - ], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: physicalAddressForm, - }, - ], - elements: [ - { - name: 'physical-street-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.physical.street', - options: { - label: 'text.street.label', - hint: 'text.street.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'physical-street-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.physical.streetNumber', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.number', - hint: '10', - }, - }, - { - name: 'physical-city-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.physical.city', - options: { - label: 'text.city.label', - hint: 'text.city.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'physical-country-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.additionalInfo.headquarters.physical.country', - options: { - label: 'text.country', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.choose', - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionPlugin', - params: { - pluginName: 'remove_physical_address', - }, - dispatchOn: { - uiEvents: [ - { - event: 'onChange', - uiElementName: 'different-from-physical-checkbox', - }, - ], - rules: [ - { - type: 'json-logic', - value: { - if: [ - { - '!': { - var: 'entity.data.additionalInfo.headquarters.isDifferentFromPhysical', - }, - }, - true, - false, - ], - }, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/4-company-ownership.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/4-company-ownership.ts deleted file mode 100644 index ae47eff3a9..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/4-company-ownership.ts +++ /dev/null @@ -1,1072 +0,0 @@ -const validationSchema = [ - { - documentId: 'associatedCompanies:document-certificate-of-incorporation', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'associatedCompanies:document-business-registration-certificate', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, -]; - -const jsonValidationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - default: {}, - if: { - properties: { - thereNoCompaniesWithMoreThan25: { - enum: [true], - }, - }, - }, - then: { - required: ['ubos', 'directors'], - }, - else: { - required: ['ubos', 'directors', 'associatedCompanies'], - }, - properties: { - thereNoCompaniesWithMoreThan25: { - type: 'boolean', - default: false, - }, - ubos: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'errorMessage.required.ubos', - }, - items: { - type: 'object', - required: ['firstName', 'lastName', 'nationalId', 'email'], - properties: { - firstName: { - type: 'string', - minLength: 1, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 1, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - nationalId: { - type: 'string', - minLength: 5, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.nationalId', - maxLength: 'errorMessage.maxLength.nationalId', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['nationality', 'fullAddress', 'percentageOfOwnership'], - errorMessage: { - required: { - nationality: 'errorMessage.required.nationality', - fullAddress: 'errorMessage.required.fullAddress', - percentageOfOwnership: 'errorMessage.required.percentageOfOwnership', - }, - }, - properties: { - nationality: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.nationality', - }, - }, - fullAddress: { - type: 'string', - minLength: 10, - maxLength: 200, - errorMessage: { - minLength: 'errorMessage.minLength.fullAddress', - maxLength: 'errorMessage.maxLength.fullAddress', - }, - }, - percentageOfOwnership: { - type: 'number', - minimum: 25, - maximum: 100, - errorMessage: { - minimum: 'errorMessage.minimum.percentageOfOwnership', - maximum: 'errorMessage.maximum.percentageOfOwnership', - }, - }, - }, - }, - }, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - nationalId: 'errorMessage.required.nationalId', - email: 'errorMessage.required.email', - }, - }, - }, - }, - directors: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'Directors are required.', - }, - items: { - type: 'object', - required: ['firstName', 'lastName', 'nationalId', 'email'], - properties: { - firstName: { - type: 'string', - minLength: 1, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 1, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - nationalId: { - type: 'string', - minLength: 5, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.nationalId', - maxLength: 'errorMessage.maxLength.nationalId', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['nationality', 'fullAddress'], - errorMessage: { - required: { - nationality: 'errorMessage.required.nationality', - fullAddress: 'errorMessage.required.fullAddress', - percentageOfOwnership: 'errorMessage.required.percentageOfOwnership', - }, - }, - properties: { - nationality: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.nationality', - }, - }, - fullAddress: { - type: 'string', - minLength: 10, - maxLength: 200, - errorMessage: { - minLength: 'errorMessage.minLength.fullAddress', - maxLength: 'errorMessage.maxLength.fullAddress', - }, - }, - }, - }, - }, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - nationalId: 'errorMessage.required.nationalId', - email: 'errorMessage.required.email', - }, - }, - }, - }, - associatedCompanies: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'errorMessage.required.companies', - }, - items: { - type: 'object', - required: ['registrationNumber', 'country', 'companyName'], - errorMessage: { - required: { - registrationNumber: 'errorMessage.required.companyRegistrationNumber', - country: 'errorMessage.required.country', - companyName: 'errorMessage.required.companyName', - associationRelationship: 'errorMessage.required.relationship', - }, - }, - properties: { - registrationNumber: { - type: 'string', - minLength: 4, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.companyRegistrationNumber', - maxLength: 'errorMessage.maxLength.companyRegistrationNumber', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength.country', - pattern: 'errorMessage.maxLength.pattern', - }, - }, - companyName: { - type: 'string', - minLength: 2, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.companyName', - maxLength: 'errorMessage.maxLength.companyName', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['associationRelationship', 'mainRepresentative'], - errorMessage: { - required: { - associationRelationship: 'errorMessage.error.requiredField', - mainRepresentative: 'errorMessage.error.requiredField', - }, - }, - properties: { - associationRelationship: { - type: 'string', - }, - mainRepresentative: { - type: 'object', - default: {}, - required: ['firstName', 'lastName', 'email'], - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - email: 'errorMessage.required.email', - }, - }, - properties: { - firstName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - errorMessage: { - required: { - ubos: 'errorMessage.required.ubos', - directors: 'errorMessage.required.directors', - associatedCompanies: 'errorMessage.required.companies', - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const CompanyOwnershipPage = { - type: 'page', - number: 4, - stateName: 'company_ownership', - name: 'text.companyOwnership', - pageValidation: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'json-schema', - value: jsonValidationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyOwnership', - }, - }, - { - type: 'h3', - options: { - text: 'text.ubos', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'im-shareholder-checkbox-form', - options: { - jsonFormDefinition: { - required: ['im-shareholder-checkbox'], - }, - }, - elements: [ - { - type: 'checkbox', - name: 'im-shareholder-checkbox', - valueDestination: 'entity.data.additionalInfo.imShareholder', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.imShareholder', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'checkbox-description-1', - options: { - descriptionRaw: 'text.shareholdersDescription', - }, - }, - { - type: 'json-form', - name: 'ubos-form', - valueDestination: 'entity.data.additionalInfo.ubos', - options: { - description: 'text.shareholdersDescription', - jsonFormDefinition: { - title: 'text.shareholder', - type: 'array', - required: [ - 'ubos:first-name-input', - 'ubos:last-name-input', - 'ubos:nationality-input', - 'ubos:identity-number-input', - 'ubos:email-input', - 'ubos:ownership-percentage-input', - 'ubos:address-of-residence-input', - ], - }, - uiSchema: { - titleTemplate: 'text.uboIndex', - }, - insertionParams: { - insertionStrategy: 'array', - destination: 'entity.data.additionalInfo.ubos', - schema: { - firstName: 'entity.data.additionalInfo.mainRepresentative.firstName', - lastName: 'entity.data.additionalInfo.mainRepresentative.lastName', - email: 'entity.data.additionalInfo.mainRepresentative.email', - }, - bindingAnchorDestination: 'additionalInfo.__isGeneratedAutomatically', - disableElements: [ - { - elementName: 'ubos:first-name-input', - atIndex: 0, - }, - { - elementName: 'ubos:last-name-input', - atIndex: 0, - }, - { - elementName: 'ubos:email-input', - atIndex: 0, - }, - ], - insertWhen: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.imShareholder' }, true], - }, - }, - ], - removeWhen: [ - { - type: 'json-logic', - value: { - if: [ - { - var: 'entity.data.additionalInfo.imShareholder', - }, - false, - true, - ], - }, - }, - ], - }, - }, - elements: [ - { - name: 'ubos:first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].firstName', //entity.data.additionalInfo.ubos[0].firstName - options: { - label: 'text.firstName', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].lastName', - options: { - label: 'text.lastName', - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:nationality-input', - type: 'nationality-picker', - valueDestination: - 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.nationality', - options: { - label: 'text.nationality', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'NationalityPicker', - }, - }, - }, - { - name: 'ubos:identity-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].nationalId', - options: { - label: 'text.nationalId.label', - hint: 'text.nationalId.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:email-input', - type: 'json-form:email', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - { - name: 'ubos:address-of-residence-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.fullAddress', - options: { - label: 'text.addressOfResidence.label', - hint: 'text.addressOfResidence.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:ownership-percentage-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.percentageOfOwnership', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.ownershipPercentage.label', - hint: 'text.ownershipPercentage.hint', - }, - }, - ], - }, - { - type: 'divider', - }, - { - type: 'h3', - options: { - text: 'text.directors', - classNames: ['padding-top-10'], - }, - }, - { - type: 'container', - elements: [ - { - type: 'json-form', - name: 'im-director-checkbox-form', - options: { - jsonFormDefinition: { - required: ['im-director-checkbox'], - }, - }, - elements: [ - { - type: 'checkbox', - name: 'im-director-checkbox', - valueDestination: 'entity.data.additionalInfo.imDirector', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.imDirector', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'checkbox-description-2', - options: { - descriptionRaw: 'text.directorsDescription', - }, - }, - { - name: 'directors-component', - type: 'json-form', - valueDestination: 'entity.data.additionalInfo.directors', - options: { - description: 'text.directorsDescription', - jsonFormDefinition: { - type: 'array', - required: [ - 'directors:first-name-input', - 'directors:last-name-input', - 'directors:nationality-input', - 'directors:identity-number-input', - 'directors:email-input', - 'directors:address-of-residence-input', - ], - }, - uiSchema: { - titleTemplate: 'text.directorIndex', - }, - insertionParams: { - insertionStrategy: 'array', - destination: 'entity.data.additionalInfo.directors', - schema: { - firstName: 'entity.data.additionalInfo.mainRepresentative.firstName', - lastName: 'entity.data.additionalInfo.mainRepresentative.lastName', - email: 'entity.data.additionalInfo.mainRepresentative.email', - }, - bindingAnchorDestination: 'additionalInfo.__isGeneratedAutomatically', - disableElements: [ - { - elementName: 'directors:first-name-input', - atIndex: 0, - }, - { - elementName: 'directors:last-name-input', - atIndex: 0, - }, - { - elementName: 'directors:email-input', - atIndex: 0, - }, - ], - insertWhen: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.imDirector' }, true], - }, - }, - ], - removeWhen: [ - { - type: 'json-logic', - value: { - if: [ - { - var: 'entity.data.additionalInfo.imDirector', - }, - false, - true, - ], - }, - }, - ], - }, - }, - elements: [ - { - name: 'directors:first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].firstName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.firstName', - hint: 'text.firstName', - }, - }, - { - name: 'directors:last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].lastName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.lastName', - hint: 'text.lastName', - }, - }, - { - name: 'directors:nationality-input', - type: 'nationality-picker', - valueDestination: - 'entity.data.additionalInfo.directors[{INDEX}].additionalInfo.nationality', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'NationalityPicker', - }, - label: 'text.nationality', - hint: 'text.choose', - }, - }, - { - name: 'directors:identity-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].nationalId', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.nationalId.label', - hint: 'text.nationalId.hint', - }, - }, - { - name: 'directors:address-of-residence-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.directors[{INDEX}].additionalInfo.fullAddress', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.addressOfResidence.label', - hint: 'text.addressOfResidence.hint', - }, - }, - { - name: 'directors:email-input', - type: 'json-form:email', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - ], - }, - ], - }, - { - type: 'divider', - }, - { - type: 'h3', - options: { - text: 'text.associatedCompanies', - classNames: ['padding-top-10'], - }, - }, - { - type: 'description', - options: { - descriptionRaw: 'text.associatedCompaniesDescription', - }, - }, - { - type: 'json-form', - name: 'there-no-companies-with-more-than-25-form', - elements: [ - { - type: 'checkbox', - name: 'there-no-companies-with-more-than-25', - valueDestination: 'entity.data.additionalInfo.thereNoCompaniesWithMoreThan25', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.noCompaniesWithMoreThan', - uiSchema: { - 'ui:label': false, - }, - }, - availableOn: [ - { - type: 'json-logic', - value: { - if: [ - { - '>=': [ - { - var: 'entity.data.additionalInfo.associatedCompanies.length', - }, - 1, - ], - }, - false, - true, - ], - }, - }, - ], - }, - ], - }, - { - type: 'json-form', - name: 'companies-form', - valueDestination: 'entity.data.additionalInfo.associatedCompanies', - options: { - description: 'text.shareholdersDescription', - jsonFormDefinition: { - title: 'text.shareholder', - type: 'array', - required: [ - 'associatedCompanies:company-registration-number-input', - 'associatedCompanies:company-country-input', - 'associatedCompanies:company-legal-name-input', - 'associatedCompanies:company-association-relationship-input', - 'associatedCompanies:company-main-representative-first-name-input', - 'associatedCompanies:company-main-representative-last-name-input', - 'associatedCompanies:company-main-representative-email-input', - 'associatedCompanies:document-certificate-of-incorporation', - 'associatedCompanies:document-business-registration-certificate', - ], - }, - uiSchema: { - titleTemplate: 'text.associatedCompanyIndex', - }, - canAdd: [ - { - type: 'json-logic', - value: { - '!==': [ - { - var: 'entity.data.additionalInfo.thereNoCompaniesWithMoreThan25', - }, - true, - false, - ], - }, - }, - ], - }, - elements: [ - { - name: 'associatedCompanies:company-registration-number-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].registrationNumber', //entity.data.additionalInfo.ubos[0].firstName - options: { - label: 'text.companyRegistrationNumber.label', - hint: 'text.companyRegistrationNumber.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'associatedCompanies:company-country-input', - type: 'dropdown', - valueDestination: 'entity.data.additionalInfo.associatedCompanies[{INDEX}].country', - options: { - label: 'text.registeredCountry.label', - hint: 'text.registeredCountry.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - }, - }, - }, - { - name: 'associatedCompanies:company-legal-name-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].companyName', - options: { - label: 'text.companyLegalName.label', - hint: 'text.companyLegalName.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'associatedCompanies:company-association-relationship-input', - type: 'json-form:date', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].additionalInfo.associationRelationship', - options: { - label: 'text.relationship.label', - hint: 'text.relationship.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'RelationshipDropdown', - 'ui:label': true, - }, - companyNameDestination: 'entity.data.companyName', - }, - }, - { - name: 'associatedCompanies:company-main-representative-first-name-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].additionalInfo.mainRepresentative.firstName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.representativeFirstName.label', - hint: 'text.representativeFirstName.hint', - }, - }, - { - name: 'associatedCompanies:company-main-representative-last-name-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].additionalInfo.mainRepresentative.lastName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.representativeLastName.label', - hint: 'text.representativeLastName.hint', - }, - }, - { - name: 'associatedCompanies:company-main-representative-email-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].additionalInfo.mainRepresentative.email', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.representativeEmail.label', - hint: 'text.representativeEmail.hint', - }, - }, - { - name: 'associatedCompanies:document-certificate-of-incorporation', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.certificateOfIncorporation.label', - description: 'text.certificateOfIncorporation.description.3months', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'associatedCompanies:document-certificate-of-incorporation', - category: 'proof_of_registration', - type: 'certificate_of_incorporation', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'associatedCompanies:document-business-registration-certificate', - type: 'document', - valueDestination: 'documents[1].pages[0].ballerineFileId', - options: { - label: 'text.businessRegistrationCertificate.label', - description: 'text.businessRegistrationCertificate.description.3months', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'associatedCompanies:document-business-registration-certificate', - category: 'proof_of_registration', - type: 'business_registration_certificate', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: jsonValidationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: jsonValidationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/5-contacts-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/5-contacts-page.ts deleted file mode 100644 index 9056c0ed07..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/5-contacts-page.ts +++ /dev/null @@ -1,204 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['mainContact'], - properties: { - mainContact: { - type: 'object', - required: ['firstName', 'lastName', 'email', 'phone'], - default: {}, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - phone: 'errorMessage.required.phone', - email: 'errorMessage.required.email', - }, - }, - properties: { - firstName: { - type: 'string', - minLength: 1, - }, - lastName: { - type: 'string', - minLength: 1, - }, - phone: { - type: 'string', - pattern: '^[+]?[0-9]{10,15}$', - errorMessage: { - pattern: 'errorMessage.pattern.phone', - }, - }, - email: { - type: 'string', - format: 'email', - errorMessage: 'errorMessage.format.email', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const ContactsPage = { - type: 'page', - number: 5, - stateName: 'contacts_page', - name: 'text.contacts', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.contacts', - }, - }, - { - type: 'h4', - options: { - text: 'text.mainContact', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'contacts-form', - options: { - jsonFormDefinition: { - required: [ - 'contact-first-name-input', - 'contact-last-name-input', - 'contact-email-input', - 'contact-phone-number-input', - ], - }, - }, - elements: [ - { - name: 'contact-first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainContact.firstName', - options: { - label: 'text.legalName', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'contact-last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainContact.lastName', - options: { - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'contact-email-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainContact.email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - { - name: 'contact-phone-number-input', - type: 'international-phone-number', - valueDestination: 'entity.data.additionalInfo.mainContact.phone', - options: { - label: 'text.phoneNumber', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'PhoneInput', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'contact-controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/6-banking-details.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/6-banking-details.ts deleted file mode 100644 index 4112e27e8b..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/6-banking-details.ts +++ /dev/null @@ -1,501 +0,0 @@ -import { currencyCodes } from 'prisma/data-migrations/templates/utils/schema-utils/currency-codes'; - -const validationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - allOf: [ - { - if: { - properties: { - country: { - const: 'US', - }, - }, - }, - then: { - properties: { - additionalInfo: { - type: 'object', - properties: { - bank: { - required: [ - 'holderName', - 'holderFullAddress', - 'accountNumber', - 'swiftCode', - 'routeNumber', - 'bankName', - 'bankAddress', - 'currency', - ], - }, - }, - }, - }, - }, - else: { - properties: { - additionalInfo: { - type: 'object', - properties: { - bank: { - required: [ - 'holderName', - 'holderFullAddress', - 'accountNumber', - 'swiftCode', - 'bankName', - 'bankAddress', - 'currency', - ], - }, - }, - }, - }, - }, - }, - { - if: { - properties: { - country: { - const: 'HK', - }, - }, - }, - then: { - properties: { - additionalInfo: { - type: 'object', - properties: { - bank: { - required: [ - 'holderName', - 'holderFullAddress', - 'accountNumber', - 'swiftCode', - 'bankName', - 'bankCode', - 'subBranch', - 'bankAddress', - 'currency', - ], - }, - }, - }, - }, - }, - else: { - properties: { - additionalInfo: { - type: 'object', - properties: { - bank: { - required: [ - 'holderName', - 'holderFullAddress', - 'accountNumber', - 'swiftCode', - 'bankName', - 'bankAddress', - 'currency', - ], - }, - }, - }, - }, - }, - }, - ], - properties: { - country: { - type: 'string', - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['bank'], - properties: { - bank: { - type: 'object', - default: {}, - properties: { - iban: { - type: 'string', - maxLength: 34, - minLength: 15, - errorMessage: { - maxLength: 'errorMessage.maxLength.iban', - minLength: 'errorMessage.minLength.iban', - }, - }, - bankCode: { - type: 'string', - maxLength: 13, - minLength: 1, - errorMessage: { - maxLength: 'errorMessage.maxLength.bankCode', - minLength: 'errorMessage.minLength.bankCode', - }, - }, - bankName: { - type: 'string', - maxLength: 100, - minLength: 3, - errorMessage: { - maxLength: 'errorMessage.maxLength.bankName', - minLength: 'errorMessage.minLength.bankName', - }, - }, - currency: { - type: 'string', - errorMessage: { - minLength: 'errorMessage.minLength.currency', - }, - }, - subBranch: { - type: 'string', - pattern: '^[0-9]+$', - errorMessage: { - pattern: 'errorMessage.pattern.subBranch', - required: 'errorMessage.required.subBranch', - }, - }, - swiftCode: { - type: 'string', - maxLength: 11, - minLength: 8, - errorMessage: { - maxLength: 'errorMessage.maxLength.swiftCode', - minLength: 'errorMessage.minLength.swiftCode', - }, - }, - holderName: { - type: 'string', - maxLength: 50, - minLength: 5, - errorMessage: { - maxLength: 'errorMessage.maxLength.holderName', - minLength: 'errorMessage.minLength.holderName', - }, - }, - bankAddress: { - type: 'string', - maxLength: 200, - minLength: 10, - errorMessage: { - maxLength: 'errorMessage.maxLength.bankAddress', - minLength: 'errorMessage.minLength.bankAddress', - }, - }, - routeNumber: { - type: 'number', - maxLength: 10, - minLength: 8, - errorMessage: { - maxLength: 'errorMessage.maxLength.routeNumber', - minLength: 'errorMessage.minLength.routeNumber', - routeNumber: 'errorMessage.required.routeNumber', - }, - }, - accountNumber: { - type: 'string', - maxLength: 34, - minLength: 6, - errorMessage: { - maxLength: 'errorMessage.maxLength.accountNumber', - minLength: 'errorMessage.minLength.accountNumber', - }, - }, - holderFullAddress: { - type: 'string', - maxLength: 200, - minLength: 10, - errorMessage: { - maxLength: 'errorMessage.maxLength.holderFullAddress', - minLength: 'errorMessage.minLength.holderFullAddress', - }, - }, - }, - errorMessage: { - required: { - bankName: 'errorMessage.required.bankName', - currency: 'errorMessage.required.currency', - swiftCode: 'errorMessage.required.swiftCode', - holderName: 'errorMessage.required.holderName', - bankAddress: 'errorMessage.required.bankAddress', - accountNumber: 'errorMessage.required.accountNumber', - holderFullAddress: 'errorMessage.required.holderFullAddress', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -export const BankingDetailsPage = { - type: 'page', - number: 6, - stateName: 'banking_details', - name: 'text.bankingDetails', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.bankingDetails', - }, - }, - ], - }, - { - type: 'json-form', - name: 'banking-details-form', - options: { - jsonFormDefinition: { - required: [ - 'card-holder-name-input', - 'resident-address-input', - 'account-number-input', - 'swift-code-input', - 'bank-name-input', - 'bank-address-input', - 'account-currency-input', - ], - }, - }, - elements: [ - { - name: 'card-holder-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.holderName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.holderName.label', - hint: 'text.holderName.hint', - }, - }, - { - name: 'resident-address-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.holderFullAddress', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.holderFullAddress.label', - hint: 'text.holderFullAddress.hint', - }, - }, - { - name: 'account-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.accountNumber', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.accountNumber.label', - hint: 'text.accountNumber.hint', - }, - }, - { - name: 'iban-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.iban', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.iban.label', - hint: 'text.iban.hint', - }, - }, - { - name: 'swift-code-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.swiftCode', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.swiftCode.label', - hint: 'text.swiftCode.hint', - }, - }, - { - name: 'route-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.routeNumber', - requiredOn: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.country' }, 'US'], - }, - }, - ], - options: { - jsonFormDefinition: { - type: 'integer', - }, - label: 'text.routeNumber.label', - hint: 'text.routeNumber.hint', - }, - }, - { - name: 'bank-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.bankName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.bankName.label', - hint: 'text.bankName.hint', - }, - }, - { - name: 'bank-code-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.bankCode', - requiredOn: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.country' }, 'HK'], - }, - }, - ], - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.bankCode.label', - hint: 'text.bankCode.hint', - }, - }, - { - name: 'bank-address-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.bankAddress', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.bankAddress.label', - hint: 'text.bankAddress.hint', - }, - }, - { - name: 'bank-sub-branch-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.subBranch', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.subBranch.label', - hint: 'text.subBranch.hint', - }, - requiredOn: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.country' }, 'HK'], - }, - }, - ], - }, - { - name: 'account-currency-input', - type: 'currency-picker', - valueDestination: 'entity.data.additionalInfo.bank.currency', - options: { - jsonFormDefinition: { - type: 'string', - oneOf: [ - { title: '', const: '' }, - ...currencyCodes.map(code => ({ - title: code.code.toUpperCase(), - const: code.code, - })), - ], - }, - label: 'text.currency.label', - hint: 'text.choose', - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/7-store-info.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/7-store-info.ts deleted file mode 100644 index b3a1e8521c..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/7-store-info.ts +++ /dev/null @@ -1,341 +0,0 @@ -import { multipleUrlsPattern } from '@/ui-definition/utils/schema-utils/regex'; - -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['store'], - default: {}, - properties: { - store: { - type: 'object', - default: {}, - if: { - properties: { - hasMobileApp: { - const: true, - }, - }, - }, - then: { - required: ['mobileAppName'], - errorMessage: { - required: { - mobileAppName: 'errorMessage.required.mobileAppName', - }, - }, - }, - properties: { - websiteUrls: { - type: 'string', - pattern: multipleUrlsPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.required.websiteUrls', - pattern: 'errorMessage.pattern.websiteUrls', - }, - }, - dba: { - type: 'string', - not: { enum: [''] }, - errorMessage: 'errorMessage.required.dba', - }, - products: { - type: 'string', - not: { enum: [''] }, - errorMessage: 'errorMessage.required.products', - }, - established: { - type: 'string', - errorMessage: 'errorMessage.required.established', - }, - hasMobileApp: { - type: 'boolean', - errorMessage: 'errorMessage.required.hasMobileApp', - default: false, - }, - mobileAppName: { - type: 'string', - }, - industry: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.industry', - }, - }, - }, - required: [ - 'websiteUrls', - 'dba', - 'products', - 'established', - 'hasMobileApp', - 'industry', - ], - errorMessage: { - required: { - websiteUrls: 'errorMessage.required.websiteUrls', - dba: 'errorMessage.required.dba', - products: 'errorMessage.required.products', - established: 'errorMessage.required.established', - hasMobileApp: 'errorMessage.required.hasMobileApp', - industry: 'errorMessage.required.industry', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const hasMobileAppVisibilityRule = { - '==': [{ var: 'entity.data.additionalInfo.store.hasMobileApp' }, true], -}; - -export const StoreInfoPage = { - type: 'page', - number: 7, - stateName: 'store_info', - name: 'text.storeInfo', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.storeInfo', - }, - }, - ], - }, - { - type: 'json-form', - name: 'store-info-form', - options: { - jsonFormDefinition: { - required: [ - 'store-website-urls-input', - 'store-dba-input', - 'store-industry-input', - 'store-products-input', - 'store-established-input', - 'store-has-mobile-checkbox', - ], - }, - }, - elements: [ - { - name: 'store-website-urls-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.websiteUrls', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.websiteUrls.label', - hint: 'text.websiteUrls.hint', - }, - }, - { - name: 'store-dba-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.dba', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.dba.label', - hint: 'text.dba.hint', - }, - }, - { - name: 'store-industry-input', - type: 'json-form:dropdown', - valueDestination: 'entity.data.additionalInfo.store.industry', - options: { - label: 'text.industry', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'IndustriesPicker', - }, - }, - }, - { - name: 'store-products-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.products', - options: { - jsonFormDefinition: { - type: 'string', - }, - classNames: ['min-width-40px'], - label: 'text.products.label', - hint: 'text.products.hint', - }, - }, - { - name: 'store-established-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.established', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - label: 'text.established.label', - hint: 'text.dateHint', - }, - }, - { - name: 'store-has-mobile-checkbox', - type: 'checkbox', - valueDestination: 'entity.data.additionalInfo.store.hasMobileApp', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.hasMobileApp.label', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'store-mobile-app-name-input-form', - options: { - jsonFormDefinition: { - required: ['store-mobile-app-name-input'], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: hasMobileAppVisibilityRule, - }, - ], - elements: [ - { - name: 'store-mobile-app-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.mobileAppName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.mobileAppName', - hint: 'text.mobileAppName', - }, - }, - ], - }, - { - type: 'json-form', - name: 'active-store-website-checkbox-form', - options: { - jsonFormDefinition: { - required: ['active-store-website-checkbox'], - }, - }, - elements: [ - { - name: 'active-store-website-checkbox', - type: 'checkbox', - valueDestination: 'entity.data.additionalInfo.store.hasActiveWebsite', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.hasActiveWebsite', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'description-1', - options: { - descriptionRaw: 'text.storeInfoDescription', - }, - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/8-website-basic-requirement.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/8-website-basic-requirement.ts deleted file mode 100644 index 58cd789b3d..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/8-website-basic-requirement.ts +++ /dev/null @@ -1,376 +0,0 @@ -import { singleUrlPattern } from '@/ui-definition/utils/schema-utils/regex'; - -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['store'], - properties: { - store: { - type: 'object', - required: ['website'], - default: {}, - properties: { - website: { - type: 'object', - default: {}, - required: [ - 'mainWebsite', - 'contactDetails', - 'productQuantity', - 'productDescription', - 'productPrice', - ], - properties: { - mainWebsite: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.mainWebsite', - pattern: 'errorMessage.pattern.mainWebsite', - }, - }, - contactDetails: { - type: 'string', - errorMessage: 'errorMessage.error.contactDetails', - }, - returnPolicyUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.returnPolicyUrl', - pattern: 'errorMessage.pattern.returnPolicyUrl', - }, - }, - shippingPolicyUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.shippingPolicyUrl', - pattern: 'errorMessage.pattern.shippingPolicyUrl', - }, - }, - aboutUsUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.aboutUsUrl', - pattern: 'errorMessage.pattern.aboutUsUrl', - }, - }, - termsOfUseUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.termsOfUseUrl', - pattern: 'errorMessage.pattern.termsOfUseUrl', - }, - }, - privacyPolicyUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.privacyPolicyUrl', - pattern: 'errorMessage.pattern.privacyPolicyUrl', - }, - }, - productQuantity: { - type: 'number', - errorMessage: 'errorMessage.error.productQuantity', - }, - productPrice: { - type: 'number', - errorMessage: 'errorMessage.error.productPrice', - }, - productDescription: { - type: 'string', - errorMessage: 'errorMessage.error.productDescription', - }, - websiteLanguage: { - type: 'string', - errorMessage: 'errorMessage.error.websiteLanguage', - }, - }, - errorMessage: { - required: { - mainWebsite: 'errorMessage.required.mainWebsite', - contactDetails: 'errorMessage.required.contactDetails', - productQuantity: 'errorMessage.required.productQuantity', - productDescription: 'errorMessage.required.productDescription', - productPrice: 'errorMessage.required.productPrice', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const WebsiteBasicRequirement = { - type: 'page', - number: 8, - stateName: 'website_basic_requirement', - name: 'text.websiteBasicRequirement', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.websiteBasicRequirement', - }, - }, - { - type: 'description', - name: 'heading-description', - options: { - descriptionRaw: 'text.websiteBasicRequirementDescription', - }, - }, - ], - }, - { - type: 'json-form', - name: 'website-basic-requirement-form', - options: { - jsonFormDefinition: { - required: [ - 'main-company-website-input', - 'contact-details-input', - 'operation-entities-name-input', - 'contact-details-input', - 'product-quantity-input', - 'product-description-input', - 'product-price-input', - ], - }, - }, - elements: [ - { - type: 'json-form:hint', - options: { - label: 'text.websiteBasicRequirementHint', - }, - }, - { - name: 'main-company-website-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.mainWebsite', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.mainWebsite.label', - hint: 'text.mainWebsite.hint', - description: 'text.mainWebsite.description', - }, - }, - { - name: 'contact-details-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.contactDetails', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.contactDetails.label', - hint: 'text.contactDetails.hint', - }, - }, - { - name: 'return-policy-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.returnPolicyUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.returnPolicyUrl.label', - hint: 'text.returnPolicyUrl.hint', - }, - }, - { - name: 'shipping-policy-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.shippingPolicyUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.shippingPolicyUrl.label', - hint: 'text.shippingPolicyUrl.hint', - }, - }, - { - name: 'about-us-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.aboutUsUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.aboutUsUrl.label', - hint: 'text.aboutUsUrl.hint', - }, - }, - { - name: 'terms-of-us-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.termsOfUseUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.termsOfUseUrl.label', - hint: 'text.termsOfUseUrl.hint', - }, - }, - { - name: 'privacy-policy-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.privacyPolicyUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.privacyPolicyUrl.label', - hint: 'text.privacyPolicyUrl.hint', - }, - }, - { - name: 'product-quantity-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.productQuantity', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.productQuantity.label', - hint: 'text.productQuantity.hint', - }, - }, - { - name: 'product-description-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.productDescription', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:widget': 'textarea', - }, - label: 'text.productDescription.label', - hint: 'text.productDescription.hint', - classNames: ['min-width-40px'], - }, - }, - { - name: 'product-price-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.productPrice', - options: { - label: 'text.productPrice.label', - hint: 'text.productPrice.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'website-language-input', - type: 'json-form:dropdown', - valueDestination: 'entity.data.additionalInfo.store.website.websiteLanguage', - options: { - hint: 'text.choose', - label: 'text.websiteLanguage.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:placeholder': 'text.choose', - 'ui:field': 'LocalePicker', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/9-process-details.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/9-process-details.ts deleted file mode 100644 index e853a615e6..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/9-process-details.ts +++ /dev/null @@ -1,558 +0,0 @@ -const validationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['store'], - properties: { - store: { - type: 'object', - required: ['processingDetails'], - default: {}, - properties: { - processingDetails: { - type: 'object', - default: {}, - required: [ - 'monthlySalesVolume', - 'monthlyTransactions', - 'averageTicketAmount', - 'mainCategory', - 'businessModel', - ], - errorMessage: { - required: { - monthlySalesVolume: 'errorMessage.required.monthlySalesVolume', - monthlyTransactions: 'errorMessage.required.monthlyTransactions', - averageTicketAmount: 'errorMessage.required.averageTicketAmount', - mainCategory: 'errorMessage.required.mainCategory', - businessModel: 'errorMessage.required.businessModel', - }, - }, - properties: { - monthlySalesVolume: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.monthlySalesVolume', - }, - monthlyTransactions: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.monthlyTransactions', - }, - averageTicketAmount: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.averageTicketAmount', - }, - mainCategory: { - type: 'array', - items: { type: 'string' }, - minItems: 1, - errorMessage: 'errorMessage.error.mainCategory', - }, - businessModel: { - type: 'array', - items: { type: 'string' }, - minItems: 1, - errorMessage: 'errorMessage.error.businessModel', - }, - isSpikeInSales: { type: 'boolean', default: false }, - spikeSalesAverageVolume: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.spikeSalesAverageVolume', - }, - spikeTransactionNumber: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.spikeTransactionNumber', - }, - }, - if: { - properties: { - isSpikeInSales: { - const: true, - }, - }, - }, - then: { - required: [ - 'monthlySalesVolume', - 'monthlyTransactions', - 'averageTicketAmount', - 'isSpikeInSales', - 'volumeInRegion', - 'spikeTransactionNumber', - 'mainCategory', - 'businessModel', - 'spikeSalesAverageVolume', - ], - errorMessage: { - required: { - monthlySalesVolume: 'errorMessage.required.monthlySalesVolume', - monthlyTransactions: 'errorMessage.required.monthlyTransactions', - averageTicketAmount: 'errorMessage.required.averageTicketAmount', - spikeSalesAverageVolume: - 'errorMessage.required.spikeSalesAverageVolume', - spikeTransactionNumber: 'errorMessage.required.spikeTransactionNumber', - mainCategory: 'errorMessage.required.mainCategory', - businessModel: 'errorMessage.required.businessModel', - volumeInRegion: 'errorMessage.required.volumeInRegion', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -const isSpikeInSaleVisibility = { - '==': [ - { - var: 'entity.data.additionalInfo.store.processingDetails.isSpikeInSales', - }, - true, - ], -}; - -const isCustomBusinessModel = { - in: ['Other', { var: `entity.data.additionalInfo.store.processingDetails.businessModel` }], -}; -const isCustomMainCateogry = { - in: ['Other', { var: 'entity.data.additionalInfo.store.processingDetails.mainCategory' }], -}; - -export const ProcessingDetails = { - type: 'page', - number: 9, - stateName: 'processing_details', - name: 'text.processingDetails', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.processingDetails', - }, - }, - ], - }, - { - type: 'json-form', - name: 'sales-form', - options: { - jsonFormDefinition: { - required: [ - 'monthly-sales-volume-input', - 'monthly-number-transactions-input', - 'average-ticket-sales-input', - ], - }, - }, - elements: [ - { - name: 'monthly-sales-volume-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.monthlySalesVolume', - options: { - label: 'text.monthlySalesVolume.label', - hint: 'text.monthlySalesVolume.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'monthly-number-transactions-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.monthlyTransactions', - options: { - label: 'text.monthlyTransactions.label', - hint: 'text.monthlyTransactions.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'est-monthly-sales-volume-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.estimatedMonthlySales', - options: { - label: 'text.estimatedMonthlySales.label', - labelVariables: { customerName: 'metadata.customerName' }, - hint: 'text.estimatedMonthlySales.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'est-monthly-transactions-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.estimatedMonthlyTransactions', - options: { - label: 'text.estimatedMonthlyTransactions.label', - labelVariables: { customerName: 'metadata.customerName' }, - hint: 'text.estimatedMonthlyTransactions.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'average-ticket-sales-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.averageTicketAmount', - options: { - label: 'text.averageTicketAmount.label', - hint: 'text.averageTicketAmount.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'minimum-ticket-sales-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.minimumTicketAmount', - options: { - label: 'text.minimumTicketAmount.label', - hint: 'text.minimumTicketAmount.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'maximum-ticket-sales-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.maximumTicketAmount', - options: { - label: 'text.maximumTicketAmount.label', - hint: 'text.maximumTicketAmount.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'spike-in-transactions-input', - type: 'checkbox', - valueDestination: 'entity.data.additionalInfo.store.processingDetails.isSpikeInSales', - options: { - label: 'text.isSpikeInSales.label', - jsonFormDefinition: { - type: 'boolean', - }, - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'spike-sales-form', - options: { - jsonFormDefinition: { - required: ['spike-sales-volume-input', 'spike-sales-transaction-number-input'], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: isSpikeInSaleVisibility, - }, - ], - elements: [ - { - name: 'spike-sales-volume-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.spikeSalesAverageVolume', - options: { - label: 'text.spikeSalesAverageVolume.label', - hint: 'text.spikeSalesAverageVolume.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'spike-sales-transaction-number-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.spikeTransactionNumber', - options: { - label: 'text.spikeTransactionNumber.label', - hint: 'text.spikeTransactionNumber.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'volume-in-region-form', - options: { - jsonFormDefinition: { - required: ['volume-in-region'], - }, - }, - elements: [ - { - name: 'volume-in-region', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.processingDetails.volumeInRegion', - options: { - label: 'text.volumeInRegion.label', - hint: 'text.volumeInRegion.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - ], - }, - { - type: 'h3', - options: { - text: 'text.customerCategory', - }, - }, - { - type: 'json-form', - options: {}, - name: 'main-category-input-form', - elements: [ - { - name: 'main-category-input', - type: 'json-form:select', - valueDestination: 'entity.data.additionalInfo.store.processingDetails.mainCategory', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'Multiselect', - options: [ - { - title: 'text.b2c', - value: 'B2C', - }, - { - title: 'text.b2b', - value: 'B2B', - }, - { - title: 'text.c2c', - value: 'C2C', - }, - { - title: 'text.other', - value: 'Other', - }, - ], - }, - variants: { - chip: { - wrapper: 'secondary', - label: 'primary', - }, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'other-main-category-input-form', - options: { - jsonFormDefinition: { - required: ['other-main-category-input'], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: isCustomMainCateogry, - }, - ], - elements: [ - { - name: 'other-main-category-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.otherMainCategory', - options: { - label: 'text.mainCategory', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - ], - }, - { - type: 'h3', - options: { - text: 'text.websiteBusinessModel', - }, - }, - { - type: 'json-form', - name: 'business-model-input-form', - options: {}, - elements: [ - { - name: 'business-model-input', - type: 'json-form:select', - valueDestination: 'entity.data.additionalInfo.store.processingDetails.businessModel', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CheckboxList', - options: [ - { - title: 'text.membership', - value: 'Membership', - }, - { - title: 'text.directPurchase', - value: 'Direct Purchase', - }, - { - title: 'text.other', - value: 'Other', - }, - ], - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'other-business-model-input-form', - options: { - jsonFormDefinition: { - required: ['other-business-model-input'], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: isCustomBusinessModel, - }, - ], - elements: [ - { - name: 'other-business-model-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.otherBusinessModel', - options: { - label: 'text.businessModel', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'PREVIOUS', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'previous-page-button' }], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/compose-ui-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/compose-ui-definition.ts deleted file mode 100644 index 45ec67df37..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/compose-ui-definition.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Prisma } from '@prisma/client'; - -import { PersonalInfoPage } from 'prisma/data-migrations/templates/creation/kyb/collection-flow/1-personal-info-page'; -import { CompanyDocuments } from 'prisma/data-migrations/templates/creation/kyb/collection-flow/10-company-documents'; -import { BusinessInfoPage } from 'prisma/data-migrations/templates/creation/kyb/collection-flow/2-business-info-page'; -import { BusinessAddressInfoPage } from 'prisma/data-migrations/templates/creation/kyb/collection-flow/3-business-address-info-page'; -import { CompanyOwnershipPage } from 'prisma/data-migrations/templates/creation/kyb/collection-flow/4-company-ownership'; -import { ContactsPage } from 'prisma/data-migrations/templates/creation/kyb/collection-flow/5-contacts-page'; -import { BankingDetailsPage } from 'prisma/data-migrations/templates/creation/kyb/collection-flow/6-banking-details'; -import { StoreInfoPage } from 'prisma/data-migrations/templates/creation/kyb/collection-flow/7-store-info'; -import { WebsiteBasicRequirement } from 'prisma/data-migrations/templates/creation/kyb/collection-flow/8-website-basic-requirement'; -import { ProcessingDetails } from 'prisma/data-migrations/templates/creation/kyb/collection-flow/9-process-details'; - -export const composeUiDefinition = ( - workflowDefinitionId: string, - definition: any, -): Pick< - Prisma.UiDefinitionUncheckedCreateInput, - 'uiContext' | 'uiSchema' | 'definition' | 'workflowDefinitionId' -> => { - return { - uiContext: 'collection_flow', - uiSchema: { - elements: [ - PersonalInfoPage, - BusinessInfoPage, - BusinessAddressInfoPage, - CompanyOwnershipPage, - ContactsPage, - BankingDetailsPage, - StoreInfoPage, - WebsiteBasicRequirement, - ProcessingDetails, - CompanyDocuments, - ], - }, - definition, - workflowDefinitionId: workflowDefinitionId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/generate-definition-logic.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/generate-definition-logic.ts deleted file mode 100644 index 9b65be2453..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/collection-flow/generate-definition-logic.ts +++ /dev/null @@ -1,225 +0,0 @@ -export const generateDefinitionLogic = (id: string) => { - return { - definitionType: 'statechart-json', - definition: { - id, - predictableActionArguments: true, - initial: 'personal_details', - context: {}, - states: { - personal_details: { - on: { - NEXT: 'business_information', - }, - }, - business_information: { - on: { - NEXT: 'business_address_information', - PREVIOUS: 'personal_details', - }, - }, - business_address_information: { - on: { - NEXT: 'company_ownership', - PREVIOUS: 'business_information', - }, - }, - company_ownership: { - on: { - NEXT: 'contacts_page', - PREVIOUS: 'business_address_information', - }, - }, - contacts_page: { - on: { - NEXT: 'banking_details', - PREVIOUS: 'company_ownership', - }, - }, - banking_details: { - on: { - NEXT: 'store_info', - PREVIOUS: 'contacts_page', - }, - }, - store_info: { - on: { - NEXT: 'website_basic_requirement', - PREVIOUS: 'banking_details', - }, - }, - website_basic_requirement: { - on: { - NEXT: 'processing_details', - PREVIOUS: 'store_info', - }, - }, - processing_details: { - on: { - NEXT: 'company_documents', - PREVIOUS: 'website_basic_requirement', - }, - }, - company_documents: { - on: { - NEXT: 'finish', - PREVIOUS: 'processing_details', - }, - }, - finish: { type: 'final' }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'update_end_user', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/end-user?token={flowConfig.tokenId}`, - method: 'POST', - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - stateNames: [], - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - lastName: entity.data.additionalInfo.mainRepresentative.lastName, - additionalInfo: {title: entity.data.additionalInfo.mainRepresentative.additionalInfo.jobTitle}, - phone: entity.data.additionalInfo.mainRepresentative.phone, - dateOfBirth: entity.data.additionalInfo.mainRepresentative.dateOfBirth - }`, - }, - ], - }, - }, - { - name: 'sync_workflow_runtime', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/sync/?token={flowConfig.tokenId}`, - method: 'PUT', - stateNames: [ - 'personal_details', - 'business_information', - 'business_address_information', - 'company_ownership', - 'contacts_page', - 'banking_details', - 'store_info', - 'website_basic_requirement', - 'processing_details', - 'company_documents', - 'finish', - ], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - data: { - context: @, - endUser: entity.data.additionalInfo.mainRepresentative, - business: entity.data, - ballerineEntityId: entity.ballerineEntityId - } - }`, - }, - ], - }, - }, - { - name: 'fetch_company_information', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/business/business-information`, - method: 'GET', - stateNames: [], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - token: flowConfig.tokenId, - registrationNumber: entity.data.registrationNumber, - countryCode: entity.data.country, - state: entity.data.additionalInfo.state || '', - vendor: 'open-corporates' - }`, - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - companyName: name, - taxIdentificationNumber: vat, - numberOfEmployees: numberOfEmployees, - businessType: companyType, - additionalInfo: {openCorporate: @} - }`, - }, - ], - }, - persistResponseDestination: 'entity.data', - successAction: 'business_information', - errorAction: 'business_information', - }, - { - name: 'send_collection_flow_finished', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/send-event/?token={flowConfig.tokenId}`, - method: 'POST', - stateNames: ['finish'], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{eventName: 'COLLECTION_FLOW_FINISHED'}`, - }, - ], - }, - }, - ], - commonPlugins: [ - { - name: 'state_value_removal', - pluginKind: 'transformer', - transformers: [ - { - transformer: 'helpers', - mapping: [ - { - method: 'remove', - source: 'entity.data.additionalInfo.state', - target: 'entity.data.additionalInfo.state', - }, - ], - }, - ], - stateNames: ['business_information'], - }, - { - name: 'remove_physical_address', - pluginKind: 'transformer', - transformers: [ - { - transformer: 'helpers', - mapping: [ - { - method: 'remove', - source: 'entity.data.additionalInfo.headquarters.physical', - target: 'entity.data.additionalInfo.headquarters.physical', - }, - ], - }, - ], - stateNames: ['business_address_information'], - }, - ], - }, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/index.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/index.ts deleted file mode 100644 index c422aea6ea..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './kyb.template'; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/kyb.template.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/kyb.template.ts deleted file mode 100644 index a1c79147b4..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/kyb.template.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { PasswordService } from '@/auth/password/password.service'; -import { generateBusinessesFilter } from 'prisma/data-migrations/templates'; -import { Template } from '../../template'; -import { composeUiDefinition } from './collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from './collection-flow/generate-definition-logic'; -import { KybGenerationParams } from './types'; -import { generateWorkflowDefinition } from './workflow-definition/workflow-definition'; -import { CustomerService } from '@/customer/customer.service'; - -export class KybTemplate extends Template { - async generate(): Promise { - const customer = await this.createCustomer(); - const user = await this.createUser(); - - const project = await this.createProject(user.id, customer.id); - - const kybWorkflow = generateWorkflowDefinition( - this.params.definition.id, - this.params.definition.name, - project.id, - ); - - const workflowDefinition = await this.prismaClient.workflowDefinition.upsert({ - where: { id: kybWorkflow.id }, - create: kybWorkflow, - update: kybWorkflow, - }); - - await this.createUIDefinition(workflowDefinition.id, project.id); - await this.createFilter(project.id, workflowDefinition.id); - } - - private createCustomer() { - const { customer } = this.params; - - const customerService = this.app.get(CustomerService); - - return customerService.create({ - data: { - displayName: customer.displayName, - name: customer.name, - authenticationConfiguration: { - apiType: 'API_KEY', - authValue: customer.apiKey, - validUntil: '', - isValid: '', - }, - logoImageUri: customer.logoImageUrl, - faviconImageUri: customer.faviconImageUri, - }, - }); - } - - private async createUser() { - const { user } = this.params; - - const passwordService = this.app.get(PasswordService); - - return this.prismaClient.user.create({ - data: { - firstName: user.firstName, - lastName: user.lastName, - email: user.email, - password: await passwordService.hash(user.password), - roles: ['user'], - }, - }); - } - - private createProject(userId: string, customerId: string) { - const { project } = this.params; - - return this.prismaClient.project.create({ - data: { - id: project.id, - name: project.id, - customerId, - userToProjects: { - create: { - userId, - }, - }, - }, - }); - } - - private async createUIDefinition(workflowDefinitionId: string, projectId: string) { - return this.prismaClient.uiDefinition.create({ - data: { - ...composeUiDefinition(workflowDefinitionId, generateDefinitionLogic(workflowDefinitionId)), - projectId, - }, - }); - } - - private async createFilter(projectId: string, definitionId: string) { - const baseQuery = generateBusinessesFilter({ - filterName: this.params.filter.name, - definitionId, - projectId, - }); - - return this.prismaClient.filter.create({ - data: baseQuery, - }); - } -} diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/types.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/types.ts deleted file mode 100644 index e55d5672a0..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/types.ts +++ /dev/null @@ -1,30 +0,0 @@ -interface KybCustomer { - displayName: string; - name: string; - apiKey: string; - logoImageUrl: string; - faviconImageUri: string; -} - -interface KybUser { - firstName: string; - lastName: string; - email: string; - password: string; -} - -interface KybProject { - id: string; -} - -interface KybFilter { - name: string; -} - -export interface KybGenerationParams { - definition: { id: string; name: string }; - customer: KybCustomer; - user: KybUser; - project: KybProject; - filter: KybFilter; -} diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/workflow-definition/state-schemas/idle/kyb.idle.schema.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/workflow-definition/state-schemas/idle/kyb.idle.schema.ts deleted file mode 100644 index f1f8fdde0f..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/workflow-definition/state-schemas/idle/kyb.idle.schema.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { Type } from '@sinclair/typebox'; - -const kybEntityUISchema = { - id: { - 'ui:title': 'Entity ID (As represented in your system)', - }, - type: { - hidden: true, - }, - data: { - 'ui:label': false, - companyName: { - 'ui:title': 'Company Name', - }, - additionalInfo: { - 'ui:label': false, - mainRepresentative: { - 'ui:label': false, - 'ui:order': ['email', 'firstName', 'lastName'], - email: { - 'ui:title': 'Email', - }, - firstName: { - 'ui:title': 'First Name', - }, - lastName: { - 'ui:title': 'Last Name', - }, - }, - }, - }, -}; - -export const kybEntitySchema = Type.Object({ - id: Type.String(), - type: Type.String({ default: 'business' }), - data: Type.Object({ - companyName: Type.String(), - additionalInfo: Type.Object({ - mainRepresentative: Type.Object({ - firstName: Type.String(), - lastName: Type.String(), - email: Type.String({ format: 'email' }), - }), - }), - }), -}); - -export const kybInputSchema = { - dataSchema: kybEntitySchema, - uiSchema: kybEntityUISchema, -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/workflow-definition/workflow-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/kyb/workflow-definition/workflow-definition.ts deleted file mode 100644 index a8212da2d5..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/kyb/workflow-definition/workflow-definition.ts +++ /dev/null @@ -1,377 +0,0 @@ -import { env } from '@/env'; -import { defaultContextSchema, StateTag } from '@ballerine/common'; -import { kybInputSchema } from 'prisma/data-migrations/templates/creation/kyb/workflow-definition/state-schemas/idle/kyb.idle.schema'; -import { kycEmailSessionDefinition } from 'prisma/data-migrations/templates/creation/common/generate-kyc-email-process'; -import { - BUSINESS_UBO_AND_SANCTIONS_DONE, - KYC_DONE_RULE, - kycAndVendorDone, -} from 'prisma/data-migrations/templates/utils/rules'; -import { - createPluginAsyncResponseTransform, - createPluginSyncOrAsyncResponseTransform, - createPluginSyncResponseTransform, -} from '../../../../utils/create-plugin-response-mapping'; - -export const generateWorkflowDefinition = (id: string, name: string, projectId?: string) => { - return { - id, - name, - version: 1, - definitionType: 'statechart-json', - definition: { - id: `${id}_v1`, - predictableActionArguments: true, - initial: 'idle', - context: { - documents: [], - }, - states: { - idle: { - on: { - START: 'collection_invite', - }, - meta: { - inputSchema: kybInputSchema, - }, - }, - collection_invite: { - on: { - INVIATION_SENT: 'collection_flow', - INVIATION_FAILURE: 'failed', - }, - }, - collection_flow: { - tags: [StateTag.COLLECTION_FLOW], - on: { - COLLECTION_FLOW_FINISHED: [{ target: 'run_ubos' }], - }, - }, - run_ubos: { - tags: [StateTag.COLLECTION_FLOW], - on: { - EMAIL_SENT_TO_UBOS: [{ target: 'run_vendor_data' }], - FAILED_EMAIL_SENT_TO_UBOS: [{ target: 'failed' }], - }, - }, - run_vendor_data: { - tags: [StateTag.DATA_ENRICHMENT], - on: { - KYC_RESPONDED: [kycAndVendorDone], - VENDOR_DONE: [ - { - target: 'pending_kyc_response_to_finish', - cond: { - type: 'jmespath', - options: { - rule: `!(${KYC_DONE_RULE()}) && ${BUSINESS_UBO_AND_SANCTIONS_DONE}`, - }, - }, - }, - kycAndVendorDone, - ], - VENDOR_FAILED: 'failed', - }, - }, - pending_kyc_response_to_finish: { - tags: [StateTag.PENDING_PROCESS], - on: { - KYC_RESPONDED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: KYC_DONE_RULE(), - }, - }, - }, - ], - reject: 'rejected', - revision: 'pending_resubmission', - }, - }, - manual_review: { - tags: [StateTag.MANUAL_REVIEW], - on: { - approve: 'approved', - reject: 'rejected', - revision: 'pending_resubmission', - KYC_REVISION: 'pending_kyc_response_to_finish', - }, - }, - pending_resubmission: { - tags: [StateTag.REVISION], - on: { - EMAIL_SENT: 'revision', - EMAIL_FAILURE: 'failed', - }, - }, - failed: { - tags: [StateTag.FAILURE], - type: 'final' as const, - }, - approved: { - tags: [StateTag.APPROVED], - type: 'final' as const, - }, - revision: { - tags: [StateTag.REVISION], - on: { - COLLECTION_FLOW_FINISHED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE()}`, - }, - }, - }, - { target: 'pending_kyc_response_to_finish' }, - ], - }, - }, - rejected: { - tags: [StateTag.REJECTED], - type: 'final' as const, - }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'collection_invite_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - successAction: 'INVIATION_SENT', - errorAction: 'INVIATION_FAILURE', - method: 'POST', - stateNames: ['collection_invite'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - customerName: metadata.customerName, - collectionFlowUrl: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token,'&lng=',workflowRuntimeConfig.language]), - from: 'no-reply@ballerine.com', - receivers: [entity.data.additionalInfo.mainRepresentative.email], - language: workflowRuntimeConfig.language, - templateId: 'd-8949519316074e03909042cfc5eb4f02', - adapter: '{secret.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - { - name: 'kyb', - displayName: 'Registry Verification', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies-v2/{entity.data.country}/{entity.data.registrationNumber}`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.businessInformation', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `merge( - { vendor: 'asia-verify' }, - entity.data.country == 'HK' && { - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.businessInformation.data&processName=kyb-unified-api']) - } - )`, // jmespath - }, - ], - }, - response: { - transform: createPluginSyncOrAsyncResponseTransform('kyb', "jurisdictionCode == 'HK'"), - }, - }, - { - name: 'company_sanctions', - displayName: 'Company Sanctions', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies/{entity.data.country}/{entity.data.companyName}/sanctions`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.companySanctions', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - vendor: 'asia-verify' - }`, // jmespath - }, - ], - }, - response: { - transform: createPluginSyncResponseTransform('company_sanctions'), - }, - }, - { - name: 'ubo', - displayName: 'UBO Check', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies/{entity.data.country}/{entity.data.registrationNumber}/ubo`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.ubo', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - vendor: 'asia-verify', - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.ubo.data&processName=ubo-unified-api']) - }`, // jmespath - }, - ], - }, - response: { - transform: createPluginAsyncResponseTransform('ubo'), - }, - }, - { - name: 'resubmission_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - method: 'POST', - successAction: 'EMAIL_SENT', - errorAction: 'EMAIL_FAILURE', - stateNames: ['pending_resubmission'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - // #TODO: create new token (new using old one) - mapping: `{ - kybCompanyName: entity.data.companyName, - customerCompanyName: metadata.customerName, - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - resubmissionLink: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token,'&lng=',workflowRuntimeConfig.language]), - supportEmail: join('',['support@',metadata.customerName,'.com']), - from: 'no-reply@ballerine.com', - name: join(' ',[metadata.customerName,'Team']), - receivers: [entity.data.additionalInfo.mainRepresentative.email], - templateId: 'd-7305991b3e5840f9a14feec767ea7301', - revisionReason: documents[].decision[].revisionReason | [0], - language: workflowRuntimeConfig.language, - adapter: '${env.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - ], - childWorkflowPlugins: [ - { - pluginKind: 'child', - name: 'veriff_kyc_child_plugin', - definitionId: kycEmailSessionDefinition().id, - transformers: [ - { - transformer: 'jmespath', - mapping: `{entity: {data: @, type: 'individual'}}`, - }, - { - transformer: 'helper', - mapping: [ - { - source: 'entity.data', - target: 'entity.data', - method: 'omit', - value: ['workflowRuntimeId', 'workflowRuntimeConfig'], - }, - ], - }, - ], - initEvent: 'start', - }, - ], - commonPlugins: [ - { - pluginKind: 'iterative', - name: 'ubos_iterative', - actionPluginName: 'veriff_kyc_child_plugin', - stateNames: ['run_ubos'], - iterateOn: [ - { - transformer: 'jmespath', - mapping: 'entity.data.additionalInfo.ubos', - }, - ], - successAction: 'EMAIL_SENT_TO_UBOS', - errorAction: 'FAILED_EMAIL_SENT_TO_UBOS', - }, - ], - }, - config: { - language: 'en', - supportedLanguages: ['en', 'cn'], - initialEvent: 'START', - createCollectionFlowToken: true, - childCallbackResults: [ - { - definitionId: kycEmailSessionDefinition().name, - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - persistenceStates: ['kyc_manual_review'], - deliverEvent: 'KYC_RESPONDED', - }, - { - definitionId: kycEmailSessionDefinition().name, - persistenceStates: ['revision_email_sent'], - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - deliverEvent: 'KYC_REVISION', - }, - ], - workflowLevelResolution: true, - enableManualCreation: true, - isCaseOverviewEnabled: true, - }, - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - isPublic: !projectId, - ...(projectId && { projectId }), - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/1-personal-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/1-personal-info-page.ts deleted file mode 100644 index 1e83c8572b..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/1-personal-info-page.ts +++ /dev/null @@ -1,264 +0,0 @@ -const validationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['mainRepresentative'], - properties: { - mainRepresentative: { - type: 'object', - required: ['phone', 'dateOfBirth', 'firstName', 'lastName', 'additionalInfo'], - errorMessage: { - required: { - phone: 'errorMessage.required.phone', - dateOfBirth: 'errorMessage.required.dateOfBirth', - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - additionalInfo: 'errorMessage.required.additionalInfo', - }, - }, - properties: { - phone: { - type: 'string', - pattern: '^[+]?[0-9]{10,15}$', - errorMessage: { - pattern: 'errorMessage.pattern.phone', - }, - }, - dateOfBirth: { - type: 'string', - errorMessage: { - type: 'errorMessage.type.dateOfBirth', - }, - }, - firstName: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - }, - }, - additionalInfo: { - type: 'object', - required: ['jobTitle'], - default: {}, - errorMessage: { - required: { - jobTitle: 'errorMessage.required.jobTitle', - }, - }, - properties: { - jobTitle: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.jobTitle', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -export const PersonalInfoPage = { - type: 'page', - name: 'text.personalInformation', - number: 1, - stateName: 'personal_details', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.personalInformation', - }, - }, - ], - }, - { - type: 'json-form', - valueDestination: 'entity.data.additionalInfo.mainRepresentative', - name: 'json-form:personal-information', - options: { - jsonFormDefinition: { - required: [ - 'first-name-input', - 'last-name-input', - 'job-title-input', - 'date-of-birth-input', - 'phone-number-input', - ], - }, - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - name: 'first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.firstName', - options: { - label: 'text.name', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.lastName', - options: { - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'job-title-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.mainRepresentative.additionalInfo.jobTitle', - options: { - label: 'text.jobTitle.label', - hint: 'text.jobTitle.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'date-of-birth-input', - type: 'json-form:date', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.dateOfBirth', - options: { - label: 'text.dateOfBirth.label', - hint: 'text.dateHint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - }, - }, - { - name: 'phone-number-input', - type: 'international-phone-number', - valueDestination: 'entity.data.additionalInfo.mainRepresentative.phone', - options: { - label: 'text.phoneNumber', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'PhoneInput', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionPlugin', - params: { - pluginName: 'update_end_user', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/10-company-documents.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/10-company-documents.ts deleted file mode 100644 index e709716e7d..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/10-company-documents.ts +++ /dev/null @@ -1,739 +0,0 @@ -const validationSchema = [ - { - documentId: 'document-certificate-of-incorporation', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-business-registration-certificate', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-proof-of-address', - destination: 'pages[0].ballerineFileId', - required: { - type: 'json-logic', - value: { - '==': [ - { - var: 'entity.data.additionalInfo.headquarters.isDifferentFromPhysical', - }, - true, - false, - ], - }, - }, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'document-copy-of-business-license', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-memorandum-of-article', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-business-ownership-structure-chart', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-tenancy-agreement', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-tax-return', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-settlement-bank-account-statement', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-financial-statements', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-latest-3-months-processing-statements', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-transaction-information', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-pci-dss-documents', - destination: 'pages[0].ballerineFileId', - }, - { - documentId: 'document-mailing-acknowledgement-or-form-sample', - destination: 'pages[0].ballerineFileId', - }, -]; - -const jsonValidationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - required: ['data'], - default: {}, - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - default: {}, - properties: { - additionalInfo: { - type: 'object', - required: ['hasConfirmed'], - properties: { - hasConfirmed: { - type: 'boolean', - default: false, - const: true, - errorMessage: { - const: 'errorMessage.error.requiredField', - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -export const CompanyDocuments = { - type: 'page', - number: 10, - stateName: 'company_documents', - name: 'text.companyDocuments', - pageValidation: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'json-schema', - value: jsonValidationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyDocuments', - }, - }, - ], - }, - { - type: 'json-form', - name: 'company-documents-form-p1', - options: { - jsonFormDefinition: { - required: [ - 'document-certificate-of-incorporation', - 'document-business-registration-certificate', - ], - }, - }, - elements: [ - { - name: 'document-certificate-of-incorporation', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.certificateOfIncorporation.label', - description: 'text.certificateOfIncorporation.description.3months', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-certificate-of-incorporation', - category: 'proof_of_registration', - type: 'certificate_of_incorporation', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-business-registration-certificate', - type: 'document', - valueDestination: 'documents[1].pages[0].ballerineFileId', - options: { - label: 'text.businessRegistrationCertificate.label', - description: 'text.businessRegistrationCertificate.description.3months', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-business-registration-certificate', - category: 'proof_of_registration', - type: 'business_registration_certificate', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-proof-of-address', - type: 'document', - valueDestination: 'documents[2].pages[0].ballerineFileId', - requiredOn: [ - { - type: 'json-logic', - value: { - '==': [ - { - var: 'entity.data.additionalInfo.headquarters.isDifferentFromPhysical', - }, - true, - false, - ], - }, - }, - ], - options: { - label: 'text.proofOfAddress.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-proof-of-address', - category: 'proof_of_address', - type: 'general_document', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-copy-of-business-license', - type: 'document', - valueDestination: 'documents[3].pages[0].ballerineFileId', - options: { - label: 'text.copyOfBusinessLicense.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-copy-of-business-license', - category: 'proof_of_registration', - type: 'business_license', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-memorandum-of-article', - type: 'document', - valueDestination: 'documents[4].pages[0].ballerineFileId', - options: { - label: 'text.memorandumOfArticle.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-memorandum-of-article', - category: 'proof_of_registration', - type: 'memorandum_of_article', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-business-ownership-structure-chart', - type: 'document', - valueDestination: 'documents[5].pages[0].ballerineFileId', - options: { - label: 'text.businessOwnershipStructureChart.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-business-ownership-structure-chart', - category: 'proof_of_ownership', - type: 'ownership_structure_chart', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-tenancy-agreement', - type: 'document', - valueDestination: 'documents[6].pages[0].ballerineFileId', - options: { - label: 'text.tenancyAgreement.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-tenancy-agreement', - category: 'proof_of_location', - type: 'tenancy_agreement', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-tax-return', - type: 'document', - valueDestination: 'documents[7].pages[0].ballerineFileId', - options: { - label: 'text.taxReturn.label', - description: 'text.taxReturn.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-tax-return', - category: 'financial_information', - type: 'tax_return', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'h3', - name: 'financial-documents-title', - options: { - text: 'text.financialDocuments', - }, - }, - { - type: 'json-form', - name: 'company-documents-form-p2', - elements: [ - { - name: 'document-settlement-bank-account-statement', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.settlementBankAccountStatement.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-settlement-bank-account-statement', - category: 'proof_of_bank_account_ownership', - type: 'bank_statement', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-financial-statements', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.financialStatements.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-financial-statements', - category: 'financial_information', - type: 'general_document', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-latest-3-months-processing-statements', - type: 'document', - valueDestination: 'documents[8].pages[0].ballerineFileId', - options: { - label: 'text.latest3MonthsCardProcessingStatements.label', - description: 'text.latest3MonthsCardProcessingStatements.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-latest-3-months-processing-statements', - category: 'financial_information', - type: 'card_processing_statements', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'document-transaction-information', - type: 'document', - valueDestination: 'documents[8].pages[0].ballerineFileId', - options: { - label: 'text.transactionInformation.label', - description: 'text.transactionInformation.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-transaction-information', - category: 'financial_information', - type: 'transaction_records', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'h3', - name: 'policies-and-compliance-documents-title', - options: { - text: 'text.policiesAndComplianceDocuments', - }, - }, - { - type: 'json-form', - name: 'company-documents-form-p3', - elements: [ - { - name: 'document-psi-dss-documents', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.psiDssDocuments.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-psi-dss-documents', - category: 'compliance_documents', - type: 'pci_dss_certification', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'h3', - name: 'additional-requirements-title', - options: { - text: 'text.additionalRequirements', - }, - }, - { - type: 'json-form', - name: 'company-documents-form-p4', - elements: [ - { - name: 'document-mailing-acknowledgement-or-form-sample', - type: 'document', - valueDestination: 'documents[0].pages[0].ballerineFileId', - options: { - label: 'text.mailingAcknowledgementOrFormSample.label', - description: 'text.mailingAcknowledgementOrFormSample.description', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'document-mailing-acknowledgement-or-form-sample', - category: 'general_documents', - type: 'mailing_or_acknowledgement_sample', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - type: 'h3', - name: 'accuracy-title', - options: { - text: 'text.declarationOfAccuracy', - }, - }, - { - type: 'description', - name: 'accuracy-description', - options: { - descriptionRaw: 'text.declarationOfAccuracyDescription', - }, - }, - { - type: 'json-form', - name: 'confirmation-form', - options: {}, - elements: [ - { - type: 'checkbox', - name: 'documents-confirmation-checkbox', - valueDestination: 'entity.data.additionalInfo.hasConfirmed', - options: { - jsonFormDefinition: { - type: 'boolean', - default: false, - }, - label: 'text.iConfirm', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'divider', - }, - { - type: 'description', - options: { - descriptionRaw: 'text.emailDescription', - }, - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.finish', - }, - availableOn: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'jmespath', - value: '!contains(uiState.elements.*.isLoading,`true`)', - }, - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.hasConfirmed' }, true, false], - }, - }, - { - type: 'json-logic', - value: { '!==': [{ var: 'uiState.isLoading' }, true, false] }, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.hasConfirmed' }, true, false], - }, - }, - ], - }, - }, - { - type: 'definitionPlugin', - params: { pluginName: 'sync_workflow_runtime', debounce: 50 }, - dispatchOn: { - uiEvents: [ - { - event: 'onChange', - uiElementName: 'document-certificate-of-incorporation', - }, - { - event: 'onChange', - uiElementName: 'document-business-registration-certificate', - }, - { - event: 'onChange', - uiElementName: 'document-proof-of-address', - }, - { - event: 'onChange', - uiElementName: 'document-copy-of-business-license', - }, - { - event: 'onChange', - uiElementName: 'document-memorandum-of-article', - }, - { - event: 'onChange', - uiElementName: 'document-business-ownership-structure-chart', - }, - { - event: 'onChange', - uiElementName: 'document-tenancy-agreement', - }, - { - event: 'onChange', - uiElementName: 'document-tax-return', - }, - { - event: 'onChange', - uiElementName: 'document-settlement-bank-account-statement', - }, - { - event: 'onChange', - uiElementName: 'document-financial-statements', - }, - { - event: 'onChange', - uiElementName: 'document-latest-3-months-processing-statements', - }, - { - event: 'onChange', - uiElementName: 'document-transaction-information', - }, - { - event: 'onChange', - uiElementName: 'document-pci-dss-documentst', - }, - { - event: 'onChange', - uiElementName: 'document-mailing-acknowledgement-or-form-sample', - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/2-business-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/2-business-info-page.ts deleted file mode 100644 index cd5b010b52..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/2-business-info-page.ts +++ /dev/null @@ -1,516 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: [ - 'additionalInfo', - 'businessType', - 'numberOfEmployees', - 'taxIdentificationNumber', - 'companyName', - 'country', - 'registrationNumber', - ], - properties: { - additionalInfo: { - type: 'object', - required: ['registeredCapitalInUsd'], - properties: { - registeredCapitalInUsd: { - type: 'number', - minimum: 0, - errorMessage: { - required: 'errorMessage.required.registeredCapitalInUsd', - minimum: 'errorMessage.minimum.registeredCapitalInUsd', - }, - }, - }, - errorMessage: { - required: { - registeredCapitalInUsd: 'errorMessage.required.registeredCapitalInUsd', - }, - }, - }, - businessType: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.businessType', - maxLength: 'errorMessage.maxLength.businessType', - required: 'errorMessage.required.businessType', - }, - }, - numberOfEmployees: { - type: 'number', - minimum: 1, - maximum: 100000, - errorMessage: { - type: 'errorMessage.type.numberOfEmployees', - required: 'errorMessage.required.numberOfEmployees', - minimum: 'errorMessage.minimum.numberOfEmployees', - maximum: 'errorMessage.maximum.numberOfEmployees', - }, - }, - taxIdentificationNumber: { - type: 'string', - minLength: 8, - maxLength: 15, - pattern: '^[^\\s]*$', - errorMessage: { - minLength: 'errorMessage.minLength.taxIdentificationNumber', - maxLength: 'errorMessage.maxLength.taxIdentificationNumber', - pattern: 'errorMessage.pattern.taxIdentificationNumber', - required: 'errorMessage.required.taxIdentificationNumber', - }, - }, - companyName: { - type: 'string', - minLength: 1, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.companyName', - maxLength: 'errorMessage.maxLength.companyName', - required: 'errorMessage.required.companyName', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength.country', - pattern: 'errorMessage.pattern.country', - required: 'errorMessage.required.country', - }, - }, - registrationNumber: { - type: 'string', - minLength: 4, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.registrationNumber', - maxLength: 'errorMessage.maxLength.registrationNumber', - required: 'errorMessage.required.registrationNumber', - }, - }, - }, - errorMessage: { - required: { - additionalInfo: 'errorMessage.required.additionalInfo', - businessType: 'errorMessage.required.businessType', - numberOfEmployees: 'errorMessage.required.numberOfEmployees', - taxIdentificationNumber: 'errorMessage.required.taxIdentificationNumber', - companyName: 'errorMessage.required.companyName', - country: 'errorMessage.required.country', - registrationNumber: 'errorMessage.required.registrationNumber', - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const dispatchOpenCorporateRule = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - default: {}, - properties: { - data: { - type: 'object', - required: ['registrationNumber', 'country'], - default: {}, - properties: { - registrationNumber: { - type: 'string', - minLength: 6, - maxLength: 20, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - }, - additionalInfo: { - type: 'object', - properties: { - state: { - default: '', - type: 'string', - }, - }, - }, - }, - if: { - properties: { - country: { - enum: ['AE', 'US', 'CA'], - }, - }, - }, - then: { - required: ['additionalInfo'], - properties: { - additionalInfo: { - required: ['state'], - properties: { - state: { - minLength: 1, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const stateVisiblityRule = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['country'], - default: {}, - properties: { - country: { - type: 'string', - enum: ['AE', 'US', 'CA'], - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const BusinessInfoPage = { - type: 'page', - number: 2, // routing number of page - stateName: 'business_information', // this is the route from xstate - name: 'text.businessInformation', // page name ( in stepper ) - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.businessInformation', - }, - }, - ], - }, - { - type: 'json-form', - name: 'business_info_form_p1', - options: { - jsonFormDefinition: { - required: ['registration-number-input', 'country-picker-input'], - }, - }, - elements: [ - { - name: 'registration-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.registrationNumber', - options: { - label: 'text.registrationNumber.label', - hint: 'text.registrationNumber.hint', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - }, - }, - { - name: 'country-picker-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.country', - options: { - label: 'text.country', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.choose', - }, - }, - }, - ], - }, - { - name: 'business_info_form_p2', - type: 'json-form', - options: { - jsonFormDefinition: { - required: ['business_info_state_input'], - }, - }, - visibleOn: [ - { - type: 'json-schema', - value: stateVisiblityRule, - }, - ], - elements: [ - { - name: 'business_info_state_input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.state', - options: { - label: 'text.state.label', - hint: 'text.state.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'StatePicker', - }, - countryCodePath: 'entity.data.country', - }, - }, - ], - }, - { - name: 'business_info_form_p3', - type: 'json-form', - options: { - jsonFormDefinition: { - required: [ - 'company-name-input', - 'tax-identification-number-input', - 'number-of-employees-input', - 'business-type-input', - 'registered-capital-in-usd-type-input', - ], - }, - }, - elements: [ - { - name: 'company-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.companyName', - options: { - label: 'text.companyName.label', - hint: 'text.companyName.hint', - jsonFormDefinition: { - type: 'string', - minLength: 1, - }, - }, - }, - { - name: 'tax-identification-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.taxIdentificationNumber', - options: { - label: 'text.taxIdentificationNumber.label', - hint: 'text.taxIdentificationNumber.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'number-of-employees-input', - type: 'json-form:text', - valueDestination: 'entity.data.numberOfEmployees', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.numberOfEmployees.label', - hint: 'text.numberOfEmployees.hint', - }, - }, - { - name: 'business-type-input', - type: 'json-form:dropdown', - valueDestination: 'entity.data.businessType', - options: { - label: 'text.businessType.label', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'AutocompleteInput', - 'ui:label': true, - options: [ - { - title: 'text.businessType.options.sole_proprietorship', - const: 'sole_proprietorship', - }, - { - title: 'text.businessType.options.partnership', - const: 'partnership', - }, - { - title: 'text.businessType.options.corporation', - const: 'corporation', - }, - { - title: 'text.businessType.options.limited_liability_company', - const: 'limited_liability_company_(llc)', - }, - { - title: 'text.businessType.options.limited_partnership', - const: 'limited_partnership_(lp)', - }, - { - title: 'text.businessType.options.limited_liability_partnership', - const: 'limited_liability_partnership_(llp)', - }, - { - title: 'text.businessType.options.public_limited_company', - const: 'public_limited_company_(plc)', - }, - { - title: 'text.businessType.options.private_limited_company', - const: 'private_limited_company_(ltd)', - }, - { - title: 'text.businessType.options.non_profit_organization', - const: 'non-profit_organization', - }, - { - title: 'text.businessType.options.cooperative', - const: 'cooperative', - }, - { - title: 'text.businessType.options.trust', - const: 'trust', - }, - { - title: 'text.businessType.options.government', - const: 'government', - }, - { - title: 'text.businessType.options.other', - const: 'other', - }, - ], - }, - }, - }, - { - name: 'registered-capital-in-usd-type-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.registeredCapitalInUsd', - options: { - jsonFormDefinition: { - type: 'integer', - }, - format: 'currency', - hint: 'text.registeredCapitalInUsd.hint', - label: 'text.registeredCapitalInUsd.label', - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionPlugin', - params: { pluginName: 'fetch_company_information', debounce: 700 }, - dispatchOn: { - uiEvents: [ - { event: 'onChange', uiElementName: 'registration-number-input' }, - { event: 'onChange', uiElementName: 'country-picker-input' }, - { event: 'onChange', uiElementName: 'business_info_state_input' }, - ], - rules: [ - { - type: 'json-schema', - value: dispatchOpenCorporateRule, - }, - ], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionPlugin', - params: { - pluginName: 'state_value_removal', - }, - dispatchOn: { - uiEvents: [{ event: 'onChange', uiElementName: 'country-picker-input' }], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/3-business-address-info-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/3-business-address-info-page.ts deleted file mode 100644 index fb1c8c6af8..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/3-business-address-info-page.ts +++ /dev/null @@ -1,431 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['headquarters'], - default: {}, - properties: { - headquarters: { - type: 'object', - default: {}, - required: ['street', 'streetNumber', 'city', 'country'], - errorMessage: { - required: { - street: 'errorMessage.required.street', - streetNumber: 'errorMessage.required.streetNumber', - city: 'errorMessage.required.city', - country: 'errorMessage.required.country', - isDifferentFromPhysical: 'errorMessage.required.requiredField', - }, - }, - if: { - properties: { - isDifferentFromPhysical: { const: true }, - }, - }, - then: { - required: ['physical'], - errorMessage: { - required: { - street: 'errorMessage.required.street', - streetNumber: 'errorMessage.required.streetNumber', - city: 'errorMessage.required.city', - country: 'errorMessage.required.country', - isDifferentFromPhysical: 'errorMessage.required.requiredField', - }, - }, - properties: { - physical: { - required: ['street', 'streetNumber', 'city', 'country'], - errorMessage: { - required: { - street: 'errorMessage.required.street', - streetNumber: 'errorMessage.required.streetNumber', - city: 'errorMessage.required.city', - country: 'errorMessage.required.country', - isDifferentFromPhysical: 'errorMessage.required.requiredField', - physical: 'errorMessage.required.physical', - }, - }, - }, - }, - }, - properties: { - isDifferentFromPhysical: { - type: 'boolean', - default: false, - }, - street: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.street', - maxLength: 'errorMessage.maxLength.street', - }, - }, - streetNumber: { - type: 'number', - minLength: 1, - maxLength: 10, - errorMessage: { - minLength: 'errorMessage.minLength.streetNumber', - maxLength: 'errorMessage.maxLength.streetNumber', - }, - }, - city: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.city', - maxLength: 'errorMessage.maxLength.city', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength,country', - pattern: 'errorMessage.pattern.country', - }, - }, - physical: { - type: 'object', - default: {}, - properties: { - street: { - type: 'string', - minLength: 3, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.street', - maxLength: 'errorMessage.maxLength.street', - }, - }, - streetNumber: { - type: 'number', - minLength: 1, - maxLength: 10, - errorMessage: { - minLength: 'errorMessage.minLength.streetNumber', - maxLength: 'errorMessage.maxLength.streetNumber', - }, - }, - city: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.city', - maxLength: 'errorMessage.maxLength.city', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength,country', - pattern: 'errorMessage.pattern.country', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const physicalAddressForm = { - '==': [{ var: 'entity.data.additionalInfo.headquarters.isDifferentFromPhysical' }, true], -}; - -export const BusinessAddressInfoPage = { - type: 'page', - number: 3, - stateName: 'business_address_information', - name: 'text.businessAddress', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.businessAddress', - }, - }, - { - type: 'h3', - options: { - text: 'text.registeredAddress', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'business-address-info-form', - options: { - jsonFormDefinition: { - required: [ - 'search-address-input', - 'street-input', - 'street-number-input', - 'city-input', - 'country-input', - ], - }, - }, - elements: [ - { - name: 'street-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.street', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.street.label', - hint: 'text.street.hint', - }, - }, - { - name: 'street-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.streetNumber', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.number', - hint: '10', - }, - }, - { - name: 'city-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.city', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.city.label', - hint: 'text.city.hint', - }, - }, - { - name: 'country-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.additionalInfo.headquarters.country', - options: { - label: 'text.country', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.choose', - }, - }, - }, - { - name: 'different-from-physical-checkbox', - type: 'checkbox', - valueDestination: 'entity.data.additionalInfo.headquarters.isDifferentFromPhysical', - options: { - label: 'text.differentFromPhysicalAddress', - jsonFormDefinition: { - type: 'boolean', - }, - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'physical-business-address-form', - options: { - jsonFormDefinition: { - required: [ - 'physical-search-address-input', - 'physical-street-input', - 'physical-street-number-input', - 'physical-city-input', - 'physical-country-input', - ], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: physicalAddressForm, - }, - ], - elements: [ - { - name: 'physical-street-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.physical.street', - options: { - label: 'text.street.label', - hint: 'text.street.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'physical-street-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.physical.streetNumber', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.number', - hint: '10', - }, - }, - { - name: 'physical-city-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.headquarters.physical.city', - options: { - label: 'text.city.label', - hint: 'text.city.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'physical-country-input', - type: 'json-form:country-picker', - valueDestination: 'entity.data.additionalInfo.headquarters.physical.country', - options: { - label: 'text.country', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - 'ui:label': true, - 'ui:placeholder': 'text.choose', - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - { - type: 'definitionPlugin', - params: { - pluginName: 'remove_physical_address', - }, - dispatchOn: { - uiEvents: [ - { - event: 'onChange', - uiElementName: 'different-from-physical-checkbox', - }, - ], - rules: [ - { - type: 'json-logic', - value: { - if: [ - { - '!': { - var: 'entity.data.additionalInfo.headquarters.isDifferentFromPhysical', - }, - }, - true, - false, - ], - }, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/4-company-ownership.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/4-company-ownership.ts deleted file mode 100644 index aeb38a3767..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/4-company-ownership.ts +++ /dev/null @@ -1,1107 +0,0 @@ -const validationSchema = [ - { - documentId: 'associatedCompanies:document-certificate-of-incorporation', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, - { - documentId: 'associatedCompanies:document-business-registration-certificate', - destination: 'pages[0].ballerineFileId', - required: true, - errorMessage: 'errorMessage.error.requiredField', - }, -]; - -const jsonValidationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - default: {}, - if: { - properties: { - thereNoCompaniesWithMoreThan25: { - enum: [true], - }, - }, - }, - then: { - required: ['ubos', 'directors'], - }, - else: { - required: ['ubos', 'directors', 'associatedCompanies'], - }, - properties: { - thereNoCompaniesWithMoreThan25: { - type: 'boolean', - default: false, - }, - ubos: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'errorMessage.required.ubos', - }, - items: { - type: 'object', - required: ['firstName', 'lastName', 'nationalId', 'email'], - properties: { - firstName: { - type: 'string', - minLength: 1, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 1, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - nationalId: { - type: 'string', - minLength: 5, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.nationalId', - maxLength: 'errorMessage.maxLength.nationalId', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['nationality', 'fullAddress', 'percentageOfOwnership'], - errorMessage: { - required: { - nationality: 'errorMessage.required.nationality', - fullAddress: 'errorMessage.required.fullAddress', - percentageOfOwnership: 'errorMessage.required.percentageOfOwnership', - }, - }, - properties: { - nationality: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.nationality', - }, - }, - fullAddress: { - type: 'string', - minLength: 10, - maxLength: 200, - errorMessage: { - minLength: 'errorMessage.minLength.fullAddress', - maxLength: 'errorMessage.maxLength.fullAddress', - }, - }, - percentageOfOwnership: { - type: 'number', - minimum: 25, - maximum: 100, - errorMessage: { - minimum: 'errorMessage.minimum.percentageOfOwnership', - maximum: 'errorMessage.maximum.percentageOfOwnership', - }, - }, - }, - }, - }, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - nationalId: 'errorMessage.required.nationalId', - email: 'errorMessage.required.email', - }, - }, - }, - }, - directors: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'Directors are required.', - }, - items: { - type: 'object', - required: ['firstName', 'lastName', 'nationalId', 'email'], - properties: { - firstName: { - type: 'string', - minLength: 1, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 1, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - nationalId: { - type: 'string', - minLength: 5, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.nationalId', - maxLength: 'errorMessage.maxLength.nationalId', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['nationality', 'fullAddress'], - errorMessage: { - required: { - nationality: 'errorMessage.required.nationality', - fullAddress: 'errorMessage.required.fullAddress', - percentageOfOwnership: 'errorMessage.required.percentageOfOwnership', - }, - }, - properties: { - nationality: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.nationality', - }, - }, - fullAddress: { - type: 'string', - minLength: 10, - maxLength: 200, - errorMessage: { - minLength: 'errorMessage.minLength.fullAddress', - maxLength: 'errorMessage.maxLength.fullAddress', - }, - }, - }, - }, - }, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - nationalId: 'errorMessage.required.nationalId', - email: 'errorMessage.required.email', - }, - }, - }, - }, - associatedCompanies: { - type: 'array', - minItems: 1, - errorMessage: { - minItems: 'errorMessage.required.companies', - }, - items: { - type: 'object', - required: ['registrationNumber', 'country', 'companyName'], - errorMessage: { - required: { - registrationNumber: 'errorMessage.required.companyRegistrationNumber', - country: 'errorMessage.required.country', - companyName: 'errorMessage.required.companyName', - associationRelationship: 'errorMessage.required.relationship', - }, - }, - properties: { - registrationNumber: { - type: 'string', - minLength: 4, - maxLength: 20, - errorMessage: { - minLength: 'errorMessage.minLength.companyRegistrationNumber', - maxLength: 'errorMessage.maxLength.companyRegistrationNumber', - }, - }, - country: { - type: 'string', - minLength: 2, - maxLength: 2, - pattern: '^[A-Z]{2}$', - errorMessage: { - minLength: 'errorMessage.minLength.country', - maxLength: 'errorMessage.maxLength.country', - pattern: 'errorMessage.maxLength.pattern', - }, - }, - companyName: { - type: 'string', - minLength: 2, - maxLength: 100, - errorMessage: { - minLength: 'errorMessage.minLength.companyName', - maxLength: 'errorMessage.maxLength.companyName', - }, - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['associationRelationship', 'mainRepresentative'], - errorMessage: { - required: { - associationRelationship: 'errorMessage.error.requiredField', - mainRepresentative: 'errorMessage.error.requiredField', - }, - }, - properties: { - associationRelationship: { - type: 'string', - }, - mainRepresentative: { - type: 'object', - default: {}, - required: ['firstName', 'lastName', 'email'], - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - email: 'errorMessage.required.email', - }, - }, - properties: { - firstName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.firstName', - maxLength: 'errorMessage.maxLength.firstName', - }, - }, - lastName: { - type: 'string', - minLength: 2, - maxLength: 50, - errorMessage: { - minLength: 'errorMessage.minLength.lastName', - maxLength: 'errorMessage.maxLength.lastName', - }, - }, - email: { - type: 'string', - format: 'email', - maxLength: 100, - errorMessage: { - format: 'errorMessage.format.email', - maxLength: 'errorMessage.maxLength.email', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - errorMessage: { - required: { - ubos: 'errorMessage.required.ubos', - directors: 'errorMessage.required.directors', - associatedCompanies: 'errorMessage.required.companies', - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const CompanyOwnershipPage = { - type: 'page', - number: 4, - stateName: 'company_ownership', - name: 'text.companyOwnership', - pageValidation: [ - { - type: 'destination-engine', - value: validationSchema, - }, - { - type: 'json-schema', - value: jsonValidationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.companyOwnership', - }, - }, - { - type: 'h3', - options: { - text: 'text.ubos', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'im-shareholder-checkbox-form', - options: { - jsonFormDefinition: { - required: ['im-shareholder-checkbox'], - }, - }, - elements: [ - { - type: 'checkbox', - name: 'im-shareholder-checkbox', - valueDestination: 'entity.data.additionalInfo.imShareholder', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.imShareholder', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'checkbox-description-1', - options: { - descriptionRaw: 'text.shareholdersDescription', - }, - }, - { - type: 'json-form', - name: 'ubos-form', - valueDestination: 'entity.data.additionalInfo.ubos', - options: { - description: 'text.shareholdersDescription', - jsonFormDefinition: { - title: 'text.shareholder', - type: 'array', - required: [ - 'ubos:first-name-input', - 'ubos:last-name-input', - 'ubos:nationality-input', - 'ubos:identity-number-input', - 'ubos:email-input', - 'ubos:ownership-percentage-input', - 'ubos:address-of-residence-input', - ], - }, - uiSchema: { - titleTemplate: 'text.uboIndex', - }, - insertionParams: { - insertionStrategy: 'array', - destination: 'entity.data.additionalInfo.ubos', - schema: { - firstName: 'entity.data.additionalInfo.mainRepresentative.firstName', - lastName: 'entity.data.additionalInfo.mainRepresentative.lastName', - email: 'entity.data.additionalInfo.mainRepresentative.email', - }, - bindingAnchorDestination: 'additionalInfo.__isGeneratedAutomatically', - disableElements: [ - { - elementName: 'ubos:first-name-input', - atIndex: 0, - }, - { - elementName: 'ubos:last-name-input', - atIndex: 0, - }, - { - elementName: 'ubos:email-input', - atIndex: 0, - }, - ], - insertWhen: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.imShareholder' }, true], - }, - }, - ], - removeWhen: [ - { - type: 'json-logic', - value: { - if: [ - { - var: 'entity.data.additionalInfo.imShareholder', - }, - false, - true, - ], - }, - }, - ], - }, - }, - elements: [ - { - name: 'ubos:first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].firstName', //entity.data.additionalInfo.ubos[0].firstName - options: { - label: 'text.firstName', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].lastName', - options: { - label: 'text.lastName', - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:nationality-input', - type: 'nationality-picker', - valueDestination: - 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.nationality', - options: { - label: 'text.nationality', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'NationalityPicker', - }, - }, - }, - { - name: 'ubos:identity-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].nationalId', - options: { - label: 'text.nationalId.label', - hint: 'text.nationalId.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:email-input', - type: 'json-form:email', - valueDestination: 'entity.data.additionalInfo.ubos[{INDEX}].email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - { - name: 'ubos:address-of-residence-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.fullAddress', - options: { - label: 'text.addressOfResidence.label', - hint: 'text.addressOfResidence.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'ubos:ownership-percentage-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.ubos[{INDEX}].additionalInfo.percentageOfOwnership', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.ownershipPercentage.label', - hint: 'text.ownershipPercentage.hint', - }, - }, - ], - }, - { - type: 'divider', - }, - { - type: 'h3', - options: { - text: 'text.directors', - classNames: ['padding-top-10'], - }, - }, - { - type: 'container', - elements: [ - { - type: 'json-form', - name: 'im-director-checkbox-form', - options: { - jsonFormDefinition: { - required: ['im-director-checkbox'], - }, - }, - elements: [ - { - type: 'checkbox', - name: 'im-director-checkbox', - valueDestination: 'entity.data.additionalInfo.imDirector', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.imDirector', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'checkbox-description-2', - options: { - descriptionRaw: 'text.directorsDescription', - }, - }, - { - name: 'directors-component', - type: 'json-form', - valueDestination: 'entity.data.additionalInfo.directors', - options: { - description: 'text.directorsDescription', - jsonFormDefinition: { - type: 'array', - required: [ - 'directors:first-name-input', - 'directors:last-name-input', - 'directors:nationality-input', - 'directors:identity-number-input', - 'directors:email-input', - 'directors:address-of-residence-input', - ], - }, - uiSchema: { - titleTemplate: 'text.directorIndex', - }, - insertionParams: { - insertionStrategy: 'array', - destination: 'entity.data.additionalInfo.directors', - schema: { - firstName: 'entity.data.additionalInfo.mainRepresentative.firstName', - lastName: 'entity.data.additionalInfo.mainRepresentative.lastName', - email: 'entity.data.additionalInfo.mainRepresentative.email', - }, - bindingAnchorDestination: 'additionalInfo.__isGeneratedAutomatically', - disableElements: [ - { - elementName: 'directors:first-name-input', - atIndex: 0, - }, - { - elementName: 'directors:last-name-input', - atIndex: 0, - }, - { - elementName: 'directors:email-input', - atIndex: 0, - }, - ], - insertWhen: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.additionalInfo.imDirector' }, true], - }, - }, - ], - removeWhen: [ - { - type: 'json-logic', - value: { - if: [ - { - var: 'entity.data.additionalInfo.imDirector', - }, - false, - true, - ], - }, - }, - ], - }, - }, - elements: [ - { - name: 'directors:first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].firstName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.firstName', - hint: 'text.firstName', - }, - }, - { - name: 'directors:last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].lastName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.lastName', - hint: 'text.lastName', - }, - }, - { - name: 'directors:nationality-input', - type: 'nationality-picker', - valueDestination: - 'entity.data.additionalInfo.directors[{INDEX}].additionalInfo.nationality', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'NationalityPicker', - }, - label: 'text.nationality', - hint: 'text.choose', - }, - }, - { - name: 'directors:identity-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].nationalId', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.nationalId.label', - hint: 'text.nationalId.hint', - }, - }, - { - name: 'directors:address-of-residence-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.directors[{INDEX}].additionalInfo.fullAddress', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.addressOfResidence.label', - hint: 'text.addressOfResidence.hint', - }, - }, - { - name: 'directors:email-input', - type: 'json-form:email', - valueDestination: 'entity.data.additionalInfo.directors[{INDEX}].email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - ], - }, - ], - }, - { - type: 'divider', - }, - { - type: 'h3', - options: { - text: 'text.associatedCompanies', - classNames: ['padding-top-10'], - }, - }, - { - type: 'description', - options: { - descriptionRaw: 'text.associatedCompaniesDescription', - }, - }, - { - type: 'json-form', - name: 'there-no-companies-with-more-than-25-form', - elements: [ - { - type: 'checkbox', - name: 'there-no-companies-with-more-than-25', - valueDestination: 'entity.data.additionalInfo.thereNoCompaniesWithMoreThan25', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.noCompaniesWithMoreThan', - uiSchema: { - 'ui:label': false, - }, - }, - availableOn: [ - { - type: 'json-logic', - value: { - if: [ - { - '>=': [ - { - var: 'entity.data.additionalInfo.associatedCompanies.length', - }, - 1, - ], - }, - false, - true, - ], - }, - }, - ], - }, - ], - }, - { - type: 'json-form', - name: 'companies-form', - valueDestination: 'entity.data.additionalInfo.associatedCompanies', - options: { - description: 'text.shareholdersDescription', - jsonFormDefinition: { - title: 'text.shareholder', - type: 'array', - required: [ - 'associatedCompanies:company-registration-number-input', - 'associatedCompanies:company-country-input', - 'associatedCompanies:company-legal-name-input', - 'associatedCompanies:company-association-relationship-input', - 'associatedCompanies:company-main-representative-first-name-input', - 'associatedCompanies:company-main-representative-last-name-input', - 'associatedCompanies:company-main-representative-email-input', - 'associatedCompanies:document-certificate-of-incorporation', - 'associatedCompanies:document-business-registration-certificate', - ], - }, - uiSchema: { - titleTemplate: 'text.associatedCompanyIndex', - }, - canAdd: [ - { - type: 'json-logic', - value: { - '!==': [ - { - var: 'entity.data.additionalInfo.thereNoCompaniesWithMoreThan25', - }, - true, - false, - ], - }, - }, - ], - }, - elements: [ - { - name: 'associatedCompanies:company-registration-number-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].registrationNumber', //entity.data.additionalInfo.ubos[0].firstName - options: { - label: 'text.companyRegistrationNumber.label', - hint: 'text.companyRegistrationNumber.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'associatedCompanies:company-country-input', - type: 'dropdown', - valueDestination: 'entity.data.additionalInfo.associatedCompanies[{INDEX}].country', - options: { - label: 'text.registeredCountry.label', - hint: 'text.registeredCountry.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CountryPicker', - }, - }, - }, - { - name: 'associatedCompanies:company-legal-name-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].companyName', - options: { - label: 'text.companyLegalName.label', - hint: 'text.companyLegalName.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'associatedCompanies:company-association-relationship-input', - type: 'json-form:date', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].additionalInfo.associationRelationship', - options: { - label: 'text.relationship.label', - hint: 'text.relationship.hint', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'RelationshipDropdown', - 'ui:label': true, - }, - companyNameDestination: 'entity.data.companyName', - }, - }, - { - name: 'associatedCompanies:company-main-representative-first-name-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].additionalInfo.mainRepresentative.firstName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.representativeFirstName.label', - hint: 'text.representativeFirstName.hint', - }, - }, - { - name: 'associatedCompanies:company-main-representative-last-name-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].additionalInfo.mainRepresentative.lastName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.representativeLastName.label', - hint: 'text.representativeLastName.hint', - }, - }, - { - name: 'associatedCompanies:company-main-representative-email-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].additionalInfo.mainRepresentative.email', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.representativeEmail.label', - hint: 'text.representativeEmail.hint', - }, - }, - { - name: 'associatedCompanies:document-certificate-of-incorporation', - type: 'document', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].documents[0].pages[0].ballerineFileId', - options: { - label: 'text.certificateOfIncorporation.label', - description: 'text.certificateOfIncorporation.description.3months', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'associatedCompanies:document-certificate-of-incorporation', - category: 'proof_of_registration', - type: 'certificate_of_incorporation', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - { - name: 'associatedCompanies:document-business-registration-certificate', - type: 'document', - valueDestination: - 'entity.data.additionalInfo.associatedCompanies[{INDEX}].documents[1].pages[0].ballerineFileId', - options: { - label: 'text.businessRegistrationCertificate.label', - description: 'text.businessRegistrationCertificate.description.3months', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DocumentInput', - }, - documentData: { - id: 'associatedCompanies:document-business-registration-certificate', - category: 'proof_of_registration', - type: 'business_registration_certificate', - issuer: { - country: 'ZZ', - }, - version: '1', - issuingVersion: 1, - properties: {}, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: jsonValidationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionPlugin', - params: { - pluginName: 'remove_associated_companies', - }, - dispatchOn: { - uiEvents: [ - { - event: 'onChange', - uiElementName: 'companies-form', - }, - ], - rules: [ - { - type: 'json-logic', - value: { - if: [ - { - '===': [ - { - var: 'entity.data.additionalInfo.associatedCompanies.length', - }, - 0, - ], - }, - true, - false, - ], - }, - }, - ], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: jsonValidationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/5-contacts-page.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/5-contacts-page.ts deleted file mode 100644 index 9056c0ed07..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/5-contacts-page.ts +++ /dev/null @@ -1,204 +0,0 @@ -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['mainContact'], - properties: { - mainContact: { - type: 'object', - required: ['firstName', 'lastName', 'email', 'phone'], - default: {}, - errorMessage: { - required: { - firstName: 'errorMessage.required.firstName', - lastName: 'errorMessage.required.lastName', - phone: 'errorMessage.required.phone', - email: 'errorMessage.required.email', - }, - }, - properties: { - firstName: { - type: 'string', - minLength: 1, - }, - lastName: { - type: 'string', - minLength: 1, - }, - phone: { - type: 'string', - pattern: '^[+]?[0-9]{10,15}$', - errorMessage: { - pattern: 'errorMessage.pattern.phone', - }, - }, - email: { - type: 'string', - format: 'email', - errorMessage: 'errorMessage.format.email', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const ContactsPage = { - type: 'page', - number: 5, - stateName: 'contacts_page', - name: 'text.contacts', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.contacts', - }, - }, - { - type: 'h4', - options: { - text: 'text.mainContact', - classNames: ['padding-top-10'], - }, - }, - ], - }, - { - type: 'json-form', - name: 'contacts-form', - options: { - jsonFormDefinition: { - required: [ - 'contact-first-name-input', - 'contact-last-name-input', - 'contact-email-input', - 'contact-phone-number-input', - ], - }, - }, - elements: [ - { - name: 'contact-first-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainContact.firstName', - options: { - label: 'text.legalName', - hint: 'text.firstName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'contact-last-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainContact.lastName', - options: { - hint: 'text.lastName', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - { - name: 'contact-email-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.mainContact.email', - options: { - jsonFormDefinition: { - type: 'string', - format: 'email', - }, - label: 'text.email.label', - hint: 'text.email.hint', - }, - }, - { - name: 'contact-phone-number-input', - type: 'international-phone-number', - valueDestination: 'entity.data.additionalInfo.mainContact.phone', - options: { - label: 'text.phoneNumber', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'PhoneInput', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'contact-controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/6-banking-details.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/6-banking-details.ts deleted file mode 100644 index 40bc35e775..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/6-banking-details.ts +++ /dev/null @@ -1,501 +0,0 @@ -import { currencyCodes } from 'prisma/data-migrations/templates/utils/schema-utils/currency-codes'; - -const validationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - allOf: [ - { - if: { - properties: { - country: { - const: 'US', - }, - }, - }, - then: { - properties: { - additionalInfo: { - type: 'object', - properties: { - bank: { - required: [ - 'companyAccountHolderName', - 'holderFullAddress', - 'accountNumber', - 'swiftCode', - 'routeNumber', - 'bankName', - 'bankAddress', - 'currency', - ], - }, - }, - }, - }, - }, - else: { - properties: { - additionalInfo: { - type: 'object', - properties: { - bank: { - required: [ - 'companyAccountHolderName', - 'holderFullAddress', - 'accountNumber', - 'swiftCode', - 'bankName', - 'bankAddress', - 'currency', - ], - }, - }, - }, - }, - }, - }, - { - if: { - properties: { - country: { - const: 'HK', - }, - }, - }, - then: { - properties: { - additionalInfo: { - type: 'object', - properties: { - bank: { - required: [ - 'companyAccountHolderName', - 'holderFullAddress', - 'accountNumber', - 'swiftCode', - 'bankName', - 'bankCode', - 'subBranch', - 'bankAddress', - 'currency', - ], - }, - }, - }, - }, - }, - else: { - properties: { - additionalInfo: { - type: 'object', - properties: { - bank: { - required: [ - 'companyAccountHolderName', - 'holderFullAddress', - 'accountNumber', - 'swiftCode', - 'bankName', - 'bankAddress', - 'currency', - ], - }, - }, - }, - }, - }, - }, - ], - properties: { - country: { - type: 'string', - }, - additionalInfo: { - type: 'object', - default: {}, - required: ['bank'], - properties: { - bank: { - type: 'object', - default: {}, - properties: { - iban: { - type: 'string', - maxLength: 34, - minLength: 15, - errorMessage: { - maxLength: 'errorMessage.maxLength.iban', - minLength: 'errorMessage.minLength.iban', - }, - }, - bankCode: { - type: 'string', - maxLength: 13, - minLength: 1, - errorMessage: { - maxLength: 'errorMessage.maxLength.bankCode', - minLength: 'errorMessage.minLength.bankCode', - }, - }, - bankName: { - type: 'string', - maxLength: 100, - minLength: 3, - errorMessage: { - maxLength: 'errorMessage.maxLength.bankName', - minLength: 'errorMessage.minLength.bankName', - }, - }, - currency: { - type: 'string', - errorMessage: { - minLength: 'errorMessage.minLength.currency', - }, - }, - subBranch: { - type: 'string', - pattern: '^[0-9]+$', - errorMessage: { - pattern: 'errorMessage.pattern.subBranch', - required: 'errorMessage.required.subBranch', - }, - }, - swiftCode: { - type: 'string', - maxLength: 11, - minLength: 8, - errorMessage: { - maxLength: 'errorMessage.maxLength.swiftCode', - minLength: 'errorMessage.minLength.swiftCode', - }, - }, - companyAccountHolderName: { - type: 'string', - maxLength: 50, - minLength: 5, - errorMessage: { - maxLength: 'errorMessage.maxLength.companyAccountHolderName', - minLength: 'errorMessage.minLength.companyAccountHolderName', - }, - }, - bankAddress: { - type: 'string', - maxLength: 200, - minLength: 10, - errorMessage: { - maxLength: 'errorMessage.maxLength.bankAddress', - minLength: 'errorMessage.minLength.bankAddress', - }, - }, - routeNumber: { - type: 'number', - maxLength: 10, - minLength: 8, - errorMessage: { - maxLength: 'errorMessage.maxLength.routeNumber', - minLength: 'errorMessage.minLength.routeNumber', - routeNumber: 'errorMessage.required.routeNumber', - }, - }, - accountNumber: { - type: 'string', - maxLength: 34, - minLength: 6, - errorMessage: { - maxLength: 'errorMessage.maxLength.accountNumber', - minLength: 'errorMessage.minLength.accountNumber', - }, - }, - holderFullAddress: { - type: 'string', - maxLength: 200, - minLength: 10, - errorMessage: { - maxLength: 'errorMessage.maxLength.holderFullAddress', - minLength: 'errorMessage.minLength.holderFullAddress', - }, - }, - }, - errorMessage: { - required: { - companyAccountHolderName: 'errorMessage.required.companyAccountHolderName', - bankName: 'errorMessage.required.bankName', - currency: 'errorMessage.required.currency', - swiftCode: 'errorMessage.required.swiftCode', - bankAddress: 'errorMessage.required.bankAddress', - accountNumber: 'errorMessage.required.accountNumber', - holderFullAddress: 'errorMessage.required.holderFullAddress', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -export const BankingDetailsPage = { - type: 'page', - number: 6, - stateName: 'banking_details', - name: 'text.bankingDetails', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.bankingDetails', - }, - }, - ], - }, - { - type: 'json-form', - name: 'banking-details-form', - options: { - jsonFormDefinition: { - required: [ - 'card-holder-name-input', - 'resident-address-input', - 'account-number-input', - 'swift-code-input', - 'bank-name-input', - 'bank-address-input', - 'account-currency-input', - ], - }, - }, - elements: [ - { - name: 'company-account-holder-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.companyAccountHolderName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.companyAccountHolderName.label', - hint: 'text.companyAccountHolderName.hint', - }, - }, - { - name: 'resident-address-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.holderFullAddress', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.holderFullAddress.label', - hint: 'text.holderFullAddress.hint', - }, - }, - { - name: 'account-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.accountNumber', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.accountNumber.label', - hint: 'text.accountNumber.hint', - }, - }, - { - name: 'iban-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.iban', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.iban.label', - hint: 'text.iban.hint', - }, - }, - { - name: 'swift-code-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.swiftCode', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.swiftCode.label', - hint: 'text.swiftCode.hint', - }, - }, - { - name: 'route-number-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.routeNumber', - requiredOn: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.country' }, 'US'], - }, - }, - ], - options: { - jsonFormDefinition: { - type: 'integer', - }, - label: 'text.routeNumber.label', - hint: 'text.routeNumber.hint', - }, - }, - { - name: 'bank-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.bankName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.bankName.label', - hint: 'text.bankName.hint', - }, - }, - { - name: 'bank-code-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.bankCode', - requiredOn: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.country' }, 'HK'], - }, - }, - ], - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.bankCode.label', - hint: 'text.bankCode.hint', - }, - }, - { - name: 'bank-address-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.bankAddress', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.bankAddress.label', - hint: 'text.bankAddress.hint', - }, - }, - { - name: 'bank-sub-branch-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.bank.subBranch', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.subBranch.label', - hint: 'text.subBranch.hint', - }, - requiredOn: [ - { - type: 'json-logic', - value: { - '==': [{ var: 'entity.data.country' }, 'HK'], - }, - }, - ], - }, - { - name: 'account-currency-input', - type: 'currency-picker', - valueDestination: 'entity.data.additionalInfo.bank.currency', - options: { - jsonFormDefinition: { - type: 'string', - oneOf: [ - { title: '', const: '' }, - ...currencyCodes.map(code => ({ - title: code.code.toUpperCase(), - const: code.code, - })), - ], - }, - label: 'text.currency.label', - hint: 'text.choose', - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/7-store-info.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/7-store-info.ts deleted file mode 100644 index b3a1e8521c..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/7-store-info.ts +++ /dev/null @@ -1,341 +0,0 @@ -import { multipleUrlsPattern } from '@/ui-definition/utils/schema-utils/regex'; - -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - properties: { - data: { - type: 'object', - properties: { - additionalInfo: { - type: 'object', - required: ['store'], - default: {}, - properties: { - store: { - type: 'object', - default: {}, - if: { - properties: { - hasMobileApp: { - const: true, - }, - }, - }, - then: { - required: ['mobileAppName'], - errorMessage: { - required: { - mobileAppName: 'errorMessage.required.mobileAppName', - }, - }, - }, - properties: { - websiteUrls: { - type: 'string', - pattern: multipleUrlsPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.required.websiteUrls', - pattern: 'errorMessage.pattern.websiteUrls', - }, - }, - dba: { - type: 'string', - not: { enum: [''] }, - errorMessage: 'errorMessage.required.dba', - }, - products: { - type: 'string', - not: { enum: [''] }, - errorMessage: 'errorMessage.required.products', - }, - established: { - type: 'string', - errorMessage: 'errorMessage.required.established', - }, - hasMobileApp: { - type: 'boolean', - errorMessage: 'errorMessage.required.hasMobileApp', - default: false, - }, - mobileAppName: { - type: 'string', - }, - industry: { - type: 'string', - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.industry', - }, - }, - }, - required: [ - 'websiteUrls', - 'dba', - 'products', - 'established', - 'hasMobileApp', - 'industry', - ], - errorMessage: { - required: { - websiteUrls: 'errorMessage.required.websiteUrls', - dba: 'errorMessage.required.dba', - products: 'errorMessage.required.products', - established: 'errorMessage.required.established', - hasMobileApp: 'errorMessage.required.hasMobileApp', - industry: 'errorMessage.required.industry', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -const hasMobileAppVisibilityRule = { - '==': [{ var: 'entity.data.additionalInfo.store.hasMobileApp' }, true], -}; - -export const StoreInfoPage = { - type: 'page', - number: 7, - stateName: 'store_info', - name: 'text.storeInfo', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.storeInfo', - }, - }, - ], - }, - { - type: 'json-form', - name: 'store-info-form', - options: { - jsonFormDefinition: { - required: [ - 'store-website-urls-input', - 'store-dba-input', - 'store-industry-input', - 'store-products-input', - 'store-established-input', - 'store-has-mobile-checkbox', - ], - }, - }, - elements: [ - { - name: 'store-website-urls-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.websiteUrls', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.websiteUrls.label', - hint: 'text.websiteUrls.hint', - }, - }, - { - name: 'store-dba-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.dba', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.dba.label', - hint: 'text.dba.hint', - }, - }, - { - name: 'store-industry-input', - type: 'json-form:dropdown', - valueDestination: 'entity.data.additionalInfo.store.industry', - options: { - label: 'text.industry', - hint: 'text.choose', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'IndustriesPicker', - }, - }, - }, - { - name: 'store-products-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.products', - options: { - jsonFormDefinition: { - type: 'string', - }, - classNames: ['min-width-40px'], - label: 'text.products.label', - hint: 'text.products.hint', - }, - }, - { - name: 'store-established-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.established', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'DateInput', - 'ui:label': true, - disableFutureDate: true, - }, - label: 'text.established.label', - hint: 'text.dateHint', - }, - }, - { - name: 'store-has-mobile-checkbox', - type: 'checkbox', - valueDestination: 'entity.data.additionalInfo.store.hasMobileApp', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.hasMobileApp.label', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'store-mobile-app-name-input-form', - options: { - jsonFormDefinition: { - required: ['store-mobile-app-name-input'], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: hasMobileAppVisibilityRule, - }, - ], - elements: [ - { - name: 'store-mobile-app-name-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.mobileAppName', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.mobileAppName', - hint: 'text.mobileAppName', - }, - }, - ], - }, - { - type: 'json-form', - name: 'active-store-website-checkbox-form', - options: { - jsonFormDefinition: { - required: ['active-store-website-checkbox'], - }, - }, - elements: [ - { - name: 'active-store-website-checkbox', - type: 'checkbox', - valueDestination: 'entity.data.additionalInfo.store.hasActiveWebsite', - options: { - jsonFormDefinition: { - type: 'boolean', - }, - label: 'text.hasActiveWebsite', - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'description', - name: 'description-1', - options: { - descriptionRaw: 'text.storeInfoDescription', - }, - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/8-website-basic-requirement.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/8-website-basic-requirement.ts deleted file mode 100644 index 58cd789b3d..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/8-website-basic-requirement.ts +++ /dev/null @@ -1,376 +0,0 @@ -import { singleUrlPattern } from '@/ui-definition/utils/schema-utils/regex'; - -const validationSchema = { - type: 'object', - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['store'], - properties: { - store: { - type: 'object', - required: ['website'], - default: {}, - properties: { - website: { - type: 'object', - default: {}, - required: [ - 'mainWebsite', - 'contactDetails', - 'productQuantity', - 'productDescription', - 'productPrice', - ], - properties: { - mainWebsite: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.mainWebsite', - pattern: 'errorMessage.pattern.mainWebsite', - }, - }, - contactDetails: { - type: 'string', - errorMessage: 'errorMessage.error.contactDetails', - }, - returnPolicyUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.returnPolicyUrl', - pattern: 'errorMessage.pattern.returnPolicyUrl', - }, - }, - shippingPolicyUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.shippingPolicyUrl', - pattern: 'errorMessage.pattern.shippingPolicyUrl', - }, - }, - aboutUsUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.aboutUsUrl', - pattern: 'errorMessage.pattern.aboutUsUrl', - }, - }, - termsOfUseUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.termsOfUseUrl', - pattern: 'errorMessage.pattern.termsOfUseUrl', - }, - }, - privacyPolicyUrl: { - type: 'string', - pattern: singleUrlPattern, - minLength: 1, - errorMessage: { - minLength: 'errorMessage.minLength.privacyPolicyUrl', - pattern: 'errorMessage.pattern.privacyPolicyUrl', - }, - }, - productQuantity: { - type: 'number', - errorMessage: 'errorMessage.error.productQuantity', - }, - productPrice: { - type: 'number', - errorMessage: 'errorMessage.error.productPrice', - }, - productDescription: { - type: 'string', - errorMessage: 'errorMessage.error.productDescription', - }, - websiteLanguage: { - type: 'string', - errorMessage: 'errorMessage.error.websiteLanguage', - }, - }, - errorMessage: { - required: { - mainWebsite: 'errorMessage.required.mainWebsite', - contactDetails: 'errorMessage.required.contactDetails', - productQuantity: 'errorMessage.required.productQuantity', - productDescription: 'errorMessage.required.productDescription', - productPrice: 'errorMessage.required.productPrice', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - required: ['entity'], -}; - -export const WebsiteBasicRequirement = { - type: 'page', - number: 8, - stateName: 'website_basic_requirement', - name: 'text.websiteBasicRequirement', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.websiteBasicRequirement', - }, - }, - { - type: 'description', - name: 'heading-description', - options: { - descriptionRaw: 'text.websiteBasicRequirementDescription', - }, - }, - ], - }, - { - type: 'json-form', - name: 'website-basic-requirement-form', - options: { - jsonFormDefinition: { - required: [ - 'main-company-website-input', - 'contact-details-input', - 'operation-entities-name-input', - 'contact-details-input', - 'product-quantity-input', - 'product-description-input', - 'product-price-input', - ], - }, - }, - elements: [ - { - type: 'json-form:hint', - options: { - label: 'text.websiteBasicRequirementHint', - }, - }, - { - name: 'main-company-website-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.mainWebsite', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.mainWebsite.label', - hint: 'text.mainWebsite.hint', - description: 'text.mainWebsite.description', - }, - }, - { - name: 'contact-details-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.contactDetails', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.contactDetails.label', - hint: 'text.contactDetails.hint', - }, - }, - { - name: 'return-policy-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.returnPolicyUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.returnPolicyUrl.label', - hint: 'text.returnPolicyUrl.hint', - }, - }, - { - name: 'shipping-policy-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.shippingPolicyUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.shippingPolicyUrl.label', - hint: 'text.shippingPolicyUrl.hint', - }, - }, - { - name: 'about-us-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.aboutUsUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.aboutUsUrl.label', - hint: 'text.aboutUsUrl.hint', - }, - }, - { - name: 'terms-of-us-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.termsOfUseUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.termsOfUseUrl.label', - hint: 'text.termsOfUseUrl.hint', - }, - }, - { - name: 'privacy-policy-url-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.privacyPolicyUrl', - options: { - jsonFormDefinition: { - type: 'string', - }, - label: 'text.privacyPolicyUrl.label', - hint: 'text.privacyPolicyUrl.hint', - }, - }, - { - name: 'product-quantity-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.productQuantity', - options: { - jsonFormDefinition: { - type: 'number', - }, - label: 'text.productQuantity.label', - hint: 'text.productQuantity.hint', - }, - }, - { - name: 'product-description-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.productDescription', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:widget': 'textarea', - }, - label: 'text.productDescription.label', - hint: 'text.productDescription.hint', - classNames: ['min-width-40px'], - }, - }, - { - name: 'product-price-input', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.website.productPrice', - options: { - label: 'text.productPrice.label', - hint: 'text.productPrice.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'website-language-input', - type: 'json-form:dropdown', - valueDestination: 'entity.data.additionalInfo.store.website.websiteLanguage', - options: { - hint: 'text.choose', - label: 'text.websiteLanguage.label', - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:placeholder': 'text.choose', - 'ui:field': 'LocalePicker', - 'ui:label': true, - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/9-process-details.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/9-process-details.ts deleted file mode 100644 index 97d4737393..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/9-process-details.ts +++ /dev/null @@ -1,558 +0,0 @@ -const validationSchema = { - type: 'object', - required: ['entity'], - properties: { - entity: { - type: 'object', - required: ['data'], - properties: { - data: { - type: 'object', - required: ['additionalInfo'], - properties: { - additionalInfo: { - type: 'object', - required: ['store'], - properties: { - store: { - type: 'object', - required: ['processingDetails'], - default: {}, - properties: { - processingDetails: { - type: 'object', - default: {}, - required: [ - 'monthlySalesVolume', - 'monthlyTransactions', - 'averageTicketAmount', - 'mainCategory', - 'businessModel', - ], - errorMessage: { - required: { - monthlySalesVolume: 'errorMessage.required.monthlySalesVolume', - monthlyTransactions: 'errorMessage.required.monthlyTransactions', - averageTicketAmount: 'errorMessage.required.averageTicketAmount', - mainCategory: 'errorMessage.required.mainCategory', - businessModel: 'errorMessage.required.businessModel', - }, - }, - properties: { - monthlySalesVolume: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.monthlySalesVolume', - }, - monthlyTransactions: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.monthlyTransactions', - }, - averageTicketAmount: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.averageTicketAmount', - }, - mainCategory: { - type: 'array', - items: { type: 'string' }, - minItems: 1, - errorMessage: 'errorMessage.error.mainCategory', - }, - businessModel: { - type: 'array', - items: { type: 'string' }, - minItems: 1, - errorMessage: 'errorMessage.error.businessModel', - }, - isSpikeInSales: { type: 'boolean', default: false }, - spikeSalesAverageVolume: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.spikeSalesAverageVolume', - }, - spikeTransactionNumber: { - type: 'number', - minimum: 1, - errorMessage: 'errorMessage.error.spikeTransactionNumber', - }, - }, - if: { - properties: { - isSpikeInSales: { - const: true, - }, - }, - }, - then: { - required: [ - 'monthlySalesVolume', - 'monthlyTransactions', - 'averageTicketAmount', - 'isSpikeInSales', - 'volumeInRegion', - 'spikeTransactionNumber', - 'mainCategory', - 'businessModel', - 'spikeSalesAverageVolume', - ], - errorMessage: { - required: { - monthlySalesVolume: 'errorMessage.required.monthlySalesVolume', - monthlyTransactions: 'errorMessage.required.monthlyTransactions', - averageTicketAmount: 'errorMessage.required.averageTicketAmount', - spikeSalesAverageVolume: - 'errorMessage.required.spikeSalesAverageVolume', - spikeTransactionNumber: 'errorMessage.required.spikeTransactionNumber', - mainCategory: 'errorMessage.required.mainCategory', - businessModel: 'errorMessage.required.businessModel', - volumeInRegion: 'errorMessage.required.volumeInRegion', - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, -}; - -const isSpikeInSaleVisibility = { - '==': [ - { - var: 'entity.data.additionalInfo.store.processingDetails.isSpikeInSales', - }, - true, - ], -}; - -const isCustomBusinessModel = { - in: ['Other', { var: `entity.data.additionalInfo.store.processingDetails.businessModel` }], -}; -const isCustomMainCateogry = { - in: ['Other', { var: 'entity.data.additionalInfo.store.processingDetails.mainCategory' }], -}; - -export const ProcessingDetails = { - type: 'page', - number: 9, - stateName: 'processing_details', - name: 'text.processingDetails', - pageValidation: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - elements: [ - { - type: 'mainContainer', - elements: [ - { - type: 'container', - elements: [ - { - type: 'h1', - options: { - text: 'text.processingDetails', - }, - }, - ], - }, - { - type: 'json-form', - name: 'sales-form', - options: { - jsonFormDefinition: { - required: [ - 'monthly-sales-volume-input', - 'monthly-number-transactions-input', - 'average-ticket-sales-input', - ], - }, - }, - elements: [ - { - name: 'monthly-sales-volume-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.monthlySalesVolume', - options: { - label: 'text.monthlySalesVolume.label', - hint: 'text.monthlySalesVolume.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'monthly-number-transactions-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.monthlyTransactions', - options: { - label: 'text.monthlyTransactions.label', - hint: 'text.monthlyTransactions.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'est-monthly-sales-volume-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.estimatedMonthlySales', - options: { - label: 'text.estimatedMonthlySales.label', - labelVariables: { customerName: 'metadata.customerName' }, - hint: 'text.estimatedMonthlySales.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'est-monthly-transactions-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.estimatedMonthlyTransactions', - options: { - label: 'text.estimatedMonthlyTransactions.label', - labelVariables: { customerName: 'metadata.customerName' }, - hint: 'text.estimatedMonthlyTransactions.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'average-ticket-sales-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.averageTicketAmount', - options: { - label: 'text.averageTicketAmount.label', - hint: 'text.averageTicketAmount.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'minimum-ticket-sales-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.minimumTicketAmount', - options: { - label: 'text.minimumTicketAmount.label', - hint: 'text.minimumTicketAmount.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'maximum-ticket-sales-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.maximumTicketAmount', - options: { - label: 'text.maximumTicketAmount.label', - hint: 'text.maximumTicketAmount.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'spike-in-transactions-input', - type: 'checkbox', - valueDestination: 'entity.data.additionalInfo.store.processingDetails.isSpikeInSales', - options: { - label: 'text.isSpikeInSales.label', - jsonFormDefinition: { - type: 'boolean', - }, - uiSchema: { - 'ui:label': false, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'spike-sales-form', - options: { - jsonFormDefinition: { - required: ['spike-sales-volume-input', 'spike-sales-transaction-number-input'], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: isSpikeInSaleVisibility, - }, - ], - elements: [ - { - name: 'spike-sales-volume-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.spikeSalesAverageVolume', - options: { - label: 'text.spikeSalesAverageVolume.label', - hint: 'text.spikeSalesAverageVolume.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - { - name: 'spike-sales-transaction-number-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.spikeTransactionNumber', - options: { - label: 'text.spikeTransactionNumber.label', - hint: 'text.spikeTransactionNumber.hint', - jsonFormDefinition: { - type: 'number', - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'volume-in-region-form', - options: { - jsonFormDefinition: { - required: ['volume-in-region'], - }, - }, - elements: [ - { - name: 'volume-in-region', - type: 'json-form:text', - valueDestination: 'entity.data.additionalInfo.store.processingDetails.volumeInRegion', - options: { - label: 'text.volumeInRegion.label', - hint: 'text.volumeInRegion.hint', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - ], - }, - { - type: 'h3', - options: { - text: 'text.customerCategory', - }, - }, - { - type: 'json-form', - name: 'main-category-form', - options: {}, - elements: [ - { - name: 'main-category-input', - type: 'json-form:select', - valueDestination: 'entity.data.additionalInfo.store.processingDetails.mainCategory', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'Multiselect', - options: [ - { - title: 'text.b2c', - value: 'B2C', - }, - { - title: 'text.b2b', - value: 'B2B', - }, - { - title: 'text.c2c', - value: 'C2C', - }, - { - title: 'text.other', - value: 'Other', - }, - ], - }, - variants: { - chip: { - wrapper: 'secondary', - label: 'primary', - }, - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'other-main-category-form', - options: { - jsonFormDefinition: { - required: ['other-main-category-input'], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: isCustomMainCateogry, - }, - ], - elements: [ - { - name: 'other-main-category-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.otherMainCategory', - options: { - label: 'text.mainCategory', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - ], - }, - { - type: 'h3', - options: { - text: 'text.websiteBusinessModel', - }, - }, - { - type: 'json-form', - name: 'business-model-input-form', - options: {}, - elements: [ - { - name: 'business-model-input', - type: 'json-form:select', - valueDestination: 'entity.data.additionalInfo.store.processingDetails.businessModel', - options: { - jsonFormDefinition: { - type: 'string', - }, - uiSchema: { - 'ui:field': 'CheckboxList', - options: [ - { - title: 'text.membership', - value: 'Membership', - }, - { - title: 'text.directPurchase', - value: 'Direct Purchase', - }, - { - title: 'text.other', - value: 'Other', - }, - ], - }, - }, - }, - ], - }, - { - type: 'json-form', - name: 'other-business-model-input', - options: { - jsonFormDefinition: { - required: ['other-business-model-input'], - }, - }, - visibleOn: [ - { - type: 'json-logic', - value: isCustomBusinessModel, - }, - ], - elements: [ - { - name: 'other-business-model-input', - type: 'json-form:text', - valueDestination: - 'entity.data.additionalInfo.store.processingDetails.otherBusinessModel', - options: { - label: 'text.businessModel', - jsonFormDefinition: { - type: 'string', - }, - }, - }, - ], - }, - { - name: 'controls-container', - type: 'container', - options: { - align: 'right', - }, - elements: [ - { - name: 'next-page-button', - type: 'submit-button', - options: { - uiDefinition: { - classNames: ['align-right', 'padding-top-10'], - }, - text: 'text.continue', - }, - availableOn: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - ], - }, - ], - }, - ], - actions: [ - { - type: 'definitionEvent', - params: { - eventName: 'PREVIOUS', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'previous-page-button' }], - }, - }, - { - type: 'definitionEvent', - params: { - eventName: 'NEXT', - }, - dispatchOn: { - uiEvents: [{ event: 'onClick', uiElementName: 'next-page-button' }], - rules: [ - { - type: 'json-schema', - value: validationSchema, - }, - ], - }, - }, - ], -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/compose-ui-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/compose-ui-definition.ts deleted file mode 100644 index d025808029..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/compose-ui-definition.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Prisma } from '@prisma/client'; - -import { PersonalInfoPage } from 'prisma/data-migrations/templates/creation/oxpay/collection-flow/1-personal-info-page'; -import { CompanyDocuments } from 'prisma/data-migrations/templates/creation/oxpay/collection-flow/10-company-documents'; -import { BusinessInfoPage } from 'prisma/data-migrations/templates/creation/oxpay/collection-flow/2-business-info-page'; -import { BusinessAddressInfoPage } from 'prisma/data-migrations/templates/creation/oxpay/collection-flow/3-business-address-info-page'; -import { CompanyOwnershipPage } from 'prisma/data-migrations/templates/creation/oxpay/collection-flow/4-company-ownership'; -import { ContactsPage } from 'prisma/data-migrations/templates/creation/oxpay/collection-flow/5-contacts-page'; -import { BankingDetailsPage } from 'prisma/data-migrations/templates/creation/oxpay/collection-flow/6-banking-details'; -import { StoreInfoPage } from 'prisma/data-migrations/templates/creation/oxpay/collection-flow/7-store-info'; -import { WebsiteBasicRequirement } from 'prisma/data-migrations/templates/creation/oxpay/collection-flow/8-website-basic-requirement'; -import { ProcessingDetails } from 'prisma/data-migrations/templates/creation/oxpay/collection-flow/9-process-details'; - -export const composeUiDefinition = ( - workflowDefinitionId: string, - definition: any, -): Pick< - Prisma.UiDefinitionUncheckedCreateInput, - 'uiContext' | 'uiSchema' | 'definition' | 'workflowDefinitionId' -> => { - return { - uiContext: 'collection_flow', - uiSchema: { - elements: [ - PersonalInfoPage, - BusinessInfoPage, - BusinessAddressInfoPage, - CompanyOwnershipPage, - ContactsPage, - BankingDetailsPage, - StoreInfoPage, - WebsiteBasicRequirement, - ProcessingDetails, - CompanyDocuments, - ], - }, - definition, - workflowDefinitionId: workflowDefinitionId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/generate-definition-logic.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/generate-definition-logic.ts deleted file mode 100644 index d7389b3675..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/collection-flow/generate-definition-logic.ts +++ /dev/null @@ -1,242 +0,0 @@ -export const generateDefinitionLogic = (id: string) => { - return { - definitionType: 'statechart-json', - definition: { - id, - predictableActionArguments: true, - initial: 'personal_details', - context: {}, - states: { - personal_details: { - on: { - NEXT: 'business_information', - }, - }, - business_information: { - on: { - NEXT: 'business_address_information', - PREVIOUS: 'personal_details', - }, - }, - business_address_information: { - on: { - NEXT: 'company_ownership', - PREVIOUS: 'business_information', - }, - }, - company_ownership: { - on: { - NEXT: 'contacts_page', - PREVIOUS: 'business_address_information', - }, - }, - contacts_page: { - on: { - NEXT: 'banking_details', - PREVIOUS: 'company_ownership', - }, - }, - banking_details: { - on: { - NEXT: 'store_info', - PREVIOUS: 'contacts_page', - }, - }, - store_info: { - on: { - NEXT: 'website_basic_requirement', - PREVIOUS: 'banking_details', - }, - }, - website_basic_requirement: { - on: { - NEXT: 'processing_details', - PREVIOUS: 'store_info', - }, - }, - processing_details: { - on: { - NEXT: 'company_documents', - PREVIOUS: 'website_basic_requirement', - }, - }, - company_documents: { - on: { - NEXT: 'finish', - PREVIOUS: 'processing_details', - }, - }, - finish: { type: 'final' }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'update_end_user', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/end-user?token={flowConfig.tokenId}`, - method: 'POST', - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - stateNames: [], - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - lastName: entity.data.additionalInfo.mainRepresentative.lastName, - additionalInfo: {title: entity.data.additionalInfo.mainRepresentative.additionalInfo.jobTitle}, - phone: entity.data.additionalInfo.mainRepresentative.phone, - dateOfBirth: entity.data.additionalInfo.mainRepresentative.dateOfBirth - }`, - }, - ], - }, - }, - { - name: 'sync_workflow_runtime', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/sync/?token={flowConfig.tokenId}`, - method: 'PUT', - stateNames: [ - 'personal_details', - 'business_information', - 'business_address_information', - 'company_ownership', - 'contacts_page', - 'banking_details', - 'store_info', - 'website_basic_requirement', - 'processing_details', - 'company_documents', - 'finish', - ], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - data: { - context: @, - endUser: entity.data.additionalInfo.mainRepresentative, - business: entity.data, - ballerineEntityId: entity.ballerineEntityId - } - }`, - }, - ], - }, - }, - { - name: 'fetch_company_information', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/business/business-information`, - method: 'GET', - stateNames: [], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - token: flowConfig.tokenId, - registrationNumber: entity.data.registrationNumber, - countryCode: entity.data.country, - state: entity.data.additionalInfo.state || '', - vendor: 'open-corporates' - }`, - }, - ], - }, - response: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - companyName: name, - taxIdentificationNumber: vat, - numberOfEmployees: numberOfEmployees, - businessType: companyType, - additionalInfo: {openCorporate: @} - }`, - }, - ], - }, - persistResponseDestination: 'entity.data', - successAction: 'business_information', - errorAction: 'business_information', - }, - { - name: 'send_collection_flow_finished', - pluginKind: 'api', - url: `{flowConfig.apiUrl}/api/v1/collection-flow/send-event/?token={flowConfig.tokenId}`, - method: 'POST', - stateNames: ['finish'], - headers: { Authorization: 'Bearer {flowConfig.tokenId}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{eventName: 'COLLECTION_FLOW_FINISHED'}`, - }, - ], - }, - }, - ], - commonPlugins: [ - { - name: 'state_value_removal', - pluginKind: 'transformer', - transformers: [ - { - transformer: 'helpers', - mapping: [ - { - method: 'remove', - source: 'entity.data.additionalInfo.state', - target: 'entity.data.additionalInfo.state', - }, - ], - }, - ], - stateNames: ['business_information'], - }, - { - name: 'remove_physical_address', - pluginKind: 'transformer', - transformers: [ - { - transformer: 'helpers', - mapping: [ - { - method: 'remove', - source: 'entity.data.additionalInfo.headquarters.physical', - target: 'entity.data.additionalInfo.headquarters.physical', - }, - ], - }, - ], - stateNames: ['business_address_information'], - }, - { - name: 'remove_associated_companies', - pluginKind: 'transformer', - transformers: [ - { - transformer: 'helpers', - mapping: [ - { - method: 'remove', - source: 'entity.data.additionalInfo.associatedCompanies', - target: 'entity.data.additionalInfo.associatedCompanies', - }, - ], - }, - ], - stateNames: ['company_ownership'], - }, - ], - }, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/index.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/index.ts deleted file mode 100644 index ce35285272..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './oxpay.template'; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/ongoing-report/workflow-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/ongoing-report/workflow-definition.ts deleted file mode 100644 index 33e312a958..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/ongoing-report/workflow-definition.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { defaultContextSchema, StateTag } from '@ballerine/common'; - -export const generateOngoingWorkflowDefinition = ({ - id, - name, - projectId, -}: { - name: string; - id?: string; - projectId?: string; -}) => { - return { - id, - name, - displayName: 'ongoing_report_workflow', - version: 1, - definitionType: 'statechart-json', - variant: 'ongoing_merchant_audit_t1', - definition: { - id: `${id}_v1`, - predictableActionArguments: true, - initial: 'idle', - states: { - idle: { - on: { - START: 'run_ongoing_report', - }, - }, - run_ongoing_report: { - on: { - REPORT_RESPONSE_OK: 'pending_ongoing_report_response', - REPORT_RESPONSE_FAILED: 'failed', - }, - }, - pending_ongoing_report_response: { - tags: [StateTag.PENDING_PROCESS], - on: { - ONGOING_RESPONSE_RECEIVED: [{ target: 'finished' }], - }, - }, - finished: { - type: 'final', - }, - failed: { - type: 'final', - }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'run_ongoing_report', - displayName: 'Registry Verification', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/tld/reports`, - method: 'POST', - stateNames: ['run_ongoing_report'], - successAction: 'REPORT_RESPONSE_OK', - errorAction: 'REPORT_RESPONSE_FAILED', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - websiteUrl: entity.data.website, - companyName: entity.data.companyName, - proxyViaCountry: entity.data.additionalInfo.report.proxyViaCountry, - compareToReportId: entity.data.additionalInfo.report.previousReportId, - checkTypes: entity.data.additionalInfo.report.checkTypes, - reportType: entity.data.additionalInfo.report.reportType, - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/ONGOING_RESPONSE_RECEIVED','?processName=merchant-audit-report']) - }`, // jmespath - }, - ], - }, - response: { - transform: { - transformer: 'jmespath', - mapping: `@`, - }, - }, - }, - ], - }, - config: { - initialEvent: 'START', - allowMultipleActiveWorkflows: true, - }, - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - isPublic: !projectId, - ...(projectId && { projectId }), - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/oxpay.template.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/oxpay.template.ts deleted file mode 100644 index 4536528d57..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/oxpay.template.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { PasswordService } from '@/auth/password/password.service'; -import { generateBusinessesFilter } from 'prisma/data-migrations/templates'; -import { Template } from '../../template'; -import { composeUiDefinition } from './collection-flow/compose-ui-definition'; -import { generateDefinitionLogic } from './collection-flow/generate-definition-logic'; -import { OxpayGenerationParams } from './types'; -import { generateWorkflowDefinition } from './workflow-definition/workflow-definition'; -import { CustomerService } from '@/customer/customer.service'; - -export class OxpayTemplate extends Template { - async generate(): Promise { - const customer = await this.createCustomer(); - const user = await this.createUser(); - - const project = await this.createProject(user.id, customer.id); - - const oxpayWorkflow = generateWorkflowDefinition( - this.params.definition.id, - this.params.definition.name, - project.id, - ); - - const workflowDefinition = await this.prismaClient.workflowDefinition.upsert({ - where: { id: oxpayWorkflow.id }, - create: oxpayWorkflow, - update: oxpayWorkflow, - }); - - await this.createUIDefinition(workflowDefinition.id, project.id); - await this.createFilter(project.id, workflowDefinition.id); - } - - private createCustomer() { - const { customer } = this.params; - - const customerService = this.app.get(CustomerService); - - return customerService.create({ - data: { - displayName: customer.displayName, - name: customer.name, - authenticationConfiguration: { - apiType: 'API_KEY', - authValue: customer.apiKey, - validUntil: '', - isValid: '', - }, - logoImageUri: customer.logoImageUrl, - faviconImageUri: customer.faviconImageUri, - }, - }); - } - - private async createUser() { - const { user } = this.params; - - const passwordService = this.app.get(PasswordService); - - return this.prismaClient.user.create({ - data: { - firstName: user.firstName, - lastName: user.lastName, - email: user.email, - password: await passwordService.hash(user.password), - roles: ['user'], - }, - }); - } - - private createProject(userId: string, customerId: string) { - const { project } = this.params; - - return this.prismaClient.project.create({ - data: { - id: project.id, - name: project.id, - customerId, - userToProjects: { - create: { - userId, - }, - }, - }, - }); - } - - private async createUIDefinition(workflowDefinitionId: string, projectId: string) { - return this.prismaClient.uiDefinition.create({ - data: { - ...composeUiDefinition(workflowDefinitionId, generateDefinitionLogic(workflowDefinitionId)), - projectId, - }, - }); - } - - private async createFilter(projectId: string, definitionId: string) { - const baseQuery = generateBusinessesFilter({ - filterName: this.params.filter.name, - definitionId, - projectId, - }); - - return this.prismaClient.filter.create({ - data: baseQuery, - }); - } -} diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/types.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/types.ts deleted file mode 100644 index 555b798211..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/types.ts +++ /dev/null @@ -1,30 +0,0 @@ -interface DemoCustomer { - displayName: string; - name: string; - apiKey: string; - logoImageUrl: string; - faviconImageUri: string; -} - -interface OxpayUser { - firstName: string; - lastName: string; - email: string; - password: string; -} - -interface OxpayProject { - id: string; -} - -interface OxpayFilter { - name: string; -} - -export interface OxpayGenerationParams { - definition: { id: string; name: string }; - customer: DemoCustomer; - user: OxpayUser; - project: OxpayProject; - filter: OxpayFilter; -} diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/workflow-definition/ongoing-workflow-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/workflow-definition/ongoing-workflow-definition.ts deleted file mode 100644 index e19fe89516..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/workflow-definition/ongoing-workflow-definition.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { - CommonWorkflowEvent, - CommonWorkflowStates, - defaultContextSchema, - StateTag, - WorkflowDefinitionVariant, -} from '@ballerine/common'; - -export const generateOngoingWorkflowDefinition = (id: string, name: string, projectId?: string) => { - return { - id, - name, - version: 1, - definitionType: 'statechart-json', - variant: WorkflowDefinitionVariant.ONGOING, - definition: { - id: `${id}_v1`, - predictableActionArguments: true, - initial: CommonWorkflowStates.MANUAL_REVIEW, - context: { - documents: [], - }, - states: { - [CommonWorkflowStates.MANUAL_REVIEW]: { - tags: [StateTag.MANUAL_REVIEW], - on: { - [CommonWorkflowEvent.DISMISS]: [CommonWorkflowStates.DISMISSED], - [CommonWorkflowEvent.FLAG]: [CommonWorkflowStates.FLAGGED], - }, - }, - [CommonWorkflowStates.DISMISSED]: { - tags: [StateTag.DISMISSED], - type: 'final' as const, - }, - [CommonWorkflowStates.FLAGGED]: { - tags: [StateTag.FLAGGED], - type: 'final' as const, - }, - }, - }, - extensions: { - apiPlugins: [], - childWorkflowPlugins: [], - commonPlugins: [], - }, - config: { - language: 'en', - supportedLanguages: ['en', 'cn'], - createCollectionFlowToken: true, - childCallbackResults: [], - workflowLevelResolution: true, - completedWhenTasksResolved: false, - }, - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - isPublic: !projectId, - ...(projectId && { projectId }), - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/workflow-definition/state-schemas/idle/oxpay.idle.schema.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/workflow-definition/state-schemas/idle/oxpay.idle.schema.ts deleted file mode 100644 index 20236f44b6..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/workflow-definition/state-schemas/idle/oxpay.idle.schema.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { Type } from '@sinclair/typebox'; - -const oxpayEntityUISchema = { - id: { - 'ui:title': 'Entity ID (As represented in your system)', - }, - type: { - hidden: true, - }, - data: { - 'ui:label': false, - companyName: { - 'ui:title': 'Company Name', - }, - additionalInfo: { - 'ui:label': false, - mainRepresentative: { - 'ui:label': false, - 'ui:order': ['email', 'firstName', 'lastName'], - email: { - 'ui:title': 'Email', - }, - firstName: { - 'ui:title': 'First Name', - }, - lastName: { - 'ui:title': 'Last Name', - }, - }, - }, - }, -}; - -export const oxpayEntitySchema = Type.Object({ - id: Type.String(), - type: Type.String({ default: 'business' }), - data: Type.Object({ - companyName: Type.String(), - additionalInfo: Type.Object({ - mainRepresentative: Type.Object({ - firstName: Type.String(), - lastName: Type.String(), - email: Type.String({ format: 'email' }), - }), - }), - }), -}); - -export const oxpayInputSchema = { - dataSchema: oxpayEntitySchema, - uiSchema: oxpayEntityUISchema, -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/workflow-definition/workflow-definition-with-associated.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/workflow-definition/workflow-definition-with-associated.ts deleted file mode 100644 index 00cca8a447..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/workflow-definition/workflow-definition-with-associated.ts +++ /dev/null @@ -1,572 +0,0 @@ -import { env } from '@/env'; -import { defaultContextSchema, StateTag } from '@ballerine/common'; -import { kycEmailSessionDefinition } from 'prisma/data-migrations/templates/creation/common/generate-kyc-email-process'; -import { oxpayInputSchema } from 'prisma/data-migrations/templates/creation/oxpay/workflow-definition/state-schemas/idle/oxpay.idle.schema'; -import { - BUSINESS_UBO_AND_SANCTIONS_DONE, - CHILD_KYB_DONE_RULE, - KYC_DONE_RULE, - kycAndVendorDone, -} from 'prisma/data-migrations/templates/utils/rules'; -import { - createPluginAsyncResponseTransform, - createPluginSyncOrAsyncResponseTransform, - createPluginSyncResponseTransform, -} from '../../../../utils/create-plugin-response-mapping'; - -export const generateWorkflowDefinitionWithAssociated = ( - id: string, - name: string, - projectId: string, - kybChildWorkflowDefinitionId: string, -) => { - const noAssociatedCompaniesRule = `entity.data.additionalInfo.associatedCompanies == null || length(entity.data.additionalInfo.associatedCompanies) == \`0\``; - const noAssociatedCompaniesInProcessRule = `entity.childWorkflows.${kybChildWorkflowDefinitionId} == null || length(entity.data.additionalInfo.${kybChildWorkflowDefinitionId}) == \`0\``; - - return { - id, - name, - version: 1, - definitionType: 'statechart-json', - definition: { - id: `${id}_v1`, - predictableActionArguments: true, - initial: 'idle', - context: { - documents: [], - }, - states: { - idle: { - on: { - START: 'collection_invite', - }, - meta: { - inputSchema: oxpayInputSchema, - }, - }, - collection_invite: { - on: { - INVIATION_SENT: 'collection_flow', - INVIATION_FAILURE: 'failed', - }, - }, - collection_flow: { - tags: [StateTag.COLLECTION_FLOW], - on: { - COLLECTION_FLOW_FINISHED: [ - { - // target: 'run_merchant_monitoring', - target: 'run_ubos', - cond: { - type: 'jmespath', - options: { - rule: noAssociatedCompaniesRule, - }, - }, - }, - { target: 'generate_associated_companies' }, - ], - }, - }, - // run_merchant_monitoring: { - // tags: [StateTag.PENDING_PROCESS], - // on: { - // MERCHANT_MONITORING_SUCCESS: 'run_ubos', - // MERCHANT_MONITORING_FAILED: 'failed', - // }, - // }, - generate_associated_companies: { - tags: [StateTag.COLLECTION_FLOW], - on: { - ASSOCIATED_COMPANIES_GENERATED: [{ target: 'run_ubos' }], - ASSOCIATED_COMPANIES_FAILED: [{ target: 'failed' }], - }, - }, - run_ubos: { - tags: [StateTag.COLLECTION_FLOW], - on: { - EMAIL_SENT_TO_UBOS: [{ target: 'run_vendor_data' }], - FAILED_EMAIL_SENT_TO_UBOS: [{ target: 'failed' }], - }, - }, - run_vendor_data: { - tags: [StateTag.DATA_ENRICHMENT], - on: { - KYC_RESPONDED: [kycAndVendorDone], - VENDOR_DONE: [ - { - target: 'pending_kyc_response_to_finish', - cond: { - type: 'jmespath', - options: { - rule: `!(${KYC_DONE_RULE()}) && ${BUSINESS_UBO_AND_SANCTIONS_DONE}`, - }, - }, - }, - kycAndVendorDone, - ], - VENDOR_FAILED: 'failed', - }, - }, - pending_kyc_response_to_finish: { - tags: [StateTag.PENDING_PROCESS], - on: { - KYC_RESPONDED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE()} && - (${noAssociatedCompaniesRule} || ${noAssociatedCompaniesInProcessRule}) || - (${CHILD_KYB_DONE_RULE(kybChildWorkflowDefinitionId)})`, - }, - }, - }, - { - target: 'pending_kyb_response_to_finish', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE()} && - !(${noAssociatedCompaniesRule}) && !(${CHILD_KYB_DONE_RULE( - kybChildWorkflowDefinitionId, - )})`, - }, - }, - }, - ], - reject: 'rejected', - revision: 'pending_resubmission', - }, - }, - pending_kyb_response_to_finish: { - tags: [StateTag.COLLECTION_FLOW], - on: { - ASSOCIATED_COMPANY_KYB_FINISHED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: CHILD_KYB_DONE_RULE(kybChildWorkflowDefinitionId), - }, - }, - }, - ], - reject: 'rejected', - revision: 'pending_resubmission', - }, - }, - manual_review: { - tags: [StateTag.MANUAL_REVIEW], - on: { - approve: 'approved', - reject: 'rejected', - revision: 'pending_resubmission', - KYC_REVISION: 'pending_kyc_response_to_finish', - }, - }, - pending_resubmission: { - tags: [StateTag.REVISION], - on: { - EMAIL_SENT: 'revision', - EMAIL_FAILURE: 'failed', - }, - }, - failed: { - tags: [StateTag.FAILURE], - type: 'final' as const, - }, - approved: { - tags: [StateTag.APPROVED], - type: 'final' as const, - }, - revision: { - tags: [StateTag.REVISION], - on: { - COLLECTION_FLOW_FINISHED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE()} && - (${noAssociatedCompaniesRule} || ${noAssociatedCompaniesInProcessRule}) && - (${CHILD_KYB_DONE_RULE(kybChildWorkflowDefinitionId)})`, - }, - }, - }, - { - target: 'pending_kyc_response_to_finish', - cond: { - type: 'jmespath', - options: { - rule: `!${KYC_DONE_RULE()} && - (${noAssociatedCompaniesRule} || ${noAssociatedCompaniesInProcessRule}) && - (${CHILD_KYB_DONE_RULE(kybChildWorkflowDefinitionId)})`, - }, - }, - }, - ], - }, - }, - rejected: { - tags: [StateTag.REJECTED], - type: 'final' as const, - }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'collection_invite_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - successAction: 'INVIATION_SENT', - errorAction: 'INVIATION_FAILURE', - method: 'POST', - stateNames: ['collection_invite'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - customerName: metadata.customerName, - collectionFlowUrl: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token,'&lng=',workflowRuntimeConfig.language]), - from: 'no-reply@ballerine.com', - receivers: [entity.data.additionalInfo.mainRepresentative.email], - language: workflowRuntimeConfig.language, - templateId: 'd-8949519316074e03909042cfc5eb4f02', - adapter: '{secret.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - { - name: 'kyb', - displayName: 'Registry Verification', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies-v2/{entity.data.country}/{entity.data.registrationNumber}`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.businessInformation', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `merge( - { vendor: 'asia-verify' }, - entity.data.country == 'HK' && { - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.businessInformation.data&processName=kyb-unified-api']) - } - )`, // jmespath - }, - ], - }, - response: { - transform: createPluginSyncOrAsyncResponseTransform('kyb', "jurisdictionCode == 'HK'"), - }, - }, - { - name: 'company_sanctions', - displayName: 'Company Sanctions', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies/{entity.data.country}/{entity.data.companyName}/sanctions`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.companySanctions', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - vendor: 'asia-verify' - }`, // jmespath - }, - ], - }, - response: { - transform: createPluginSyncResponseTransform('company_sanctions'), - }, - }, - { - name: 'ubo', - displayName: 'UBO Check', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies/{entity.data.country}/{entity.data.registrationNumber}/ubo`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.ubo', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - vendor: 'asia-verify', - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.ubo.data&processName=ubo-unified-api']) - }`, // jmespath - }, - ], - }, - response: { - transform: createPluginAsyncResponseTransform('ubo'), - }, - }, - { - name: 'resubmission_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - method: 'POST', - successAction: 'EMAIL_SENT', - errorAction: 'EMAIL_FAILURE', - stateNames: ['pending_resubmission'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - // #TODO: create new token (new using old one) - mapping: `{ - kybCompanyName: entity.data.companyName, - customerCompanyName: metadata.customerName, - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - resubmissionLink: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token,'&lng=',workflowRuntimeConfig.language]), - supportEmail: join('',['support@',metadata.customerName,'.com']), - from: 'no-reply@ballerine.com', - name: join(' ',[metadata.customerName,'Team']), - receivers: [entity.data.additionalInfo.mainRepresentative.email], - templateId: 'd-7305991b3e5840f9a14feec767ea7301', - revisionReason: documents[].decision[].revisionReason | [0], - language: workflowRuntimeConfig.language, - adapter: '${env.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - // { - // name: 'merchant_monitoring', - // pluginKind: 'api', - // url: `{secret.UNIFIED_API_URL}/tld/reports`, - // method: 'POST', - // stateNames: ['run_merchant_monitoring'], - // successAction: 'MERCHANT_MONITORING_SUCCESS', - // errorAction: 'MERCHANT_MONITORING_FAILED', - // headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - // request: { - // transform: [ - // { - // transformer: 'jmespath', - // mapping: `{ - // websiteUrl: entity.data.additionalInfo.store.website.mainWebsite, - // companyName: entity.data.companyName, - // reportType: 'MERCHANT_REPORT_T1', - // callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=entity.report&processName=website-monitoring']) - // }`, // jmespath - // }, - // ], - // }, - // response: { - // transform: [ - // { - // transformer: 'jmespath', - // mapping: '@', // jmespath - // }, - // ], - // }, - // }, - ], - childWorkflowPlugins: [ - { - pluginKind: 'child', - name: 'veriff_kyc_child_plugin', - definitionId: kycEmailSessionDefinition().id, - transformers: [ - { - transformer: 'jmespath', - mapping: `{entity: {data: @, type: 'individual'}}`, - }, - { - transformer: 'helper', - mapping: [ - { - source: 'entity.data', - target: 'entity.data', - method: 'omit', - value: ['workflowRuntimeId', 'workflowRuntimeConfig'], - }, - ], - }, - ], - initEvent: 'start', - }, - { - pluginKind: 'child', - name: 'associated_company_child_plugin', - definitionId: kybChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: `{entity: {data: @, type: 'business'}, documents: documents}`, - }, - { - transformer: 'helper', - mapping: [ - { - source: 'entity.data', - target: 'entity.data', - method: 'omit', - value: ['workflowRuntimeId', 'workflowRuntimeConfig', 'documents'], - }, - ], - }, - ], - }, - ], - commonPlugins: [ - { - pluginKind: 'iterative', - name: 'ubos_iterative', - actionPluginName: 'veriff_kyc_child_plugin', - stateNames: ['run_ubos'], - iterateOn: [ - { - transformer: 'jmespath', - mapping: 'entity.data.additionalInfo.ubos', - }, - ], - successAction: 'EMAIL_SENT_TO_UBOS', - errorAction: 'FAILED_EMAIL_SENT_TO_UBOS', - }, - { - pluginKind: 'iterative', - name: 'associated_company_iterative', - actionPluginName: 'associated_company_child_plugin', - stateNames: ['generate_associated_companies'], - iterateOn: [ - { - transformer: 'helper', - mapping: [ - { - source: 'entity.data.additionalInfo.associatedCompanies', - target: 'entity.data.additionalInfo.associatedCompanies', - method: 'mergeArrayEachItemWithValue', - options: { - mapJmespath: 'entity.data.additionalInfo.associatedCompanies', - mergeWithJmespath: - '{ additionalInfo: { customerName: metadata.customerName, kybCompanyName: entity.data.companyName } }', - }, - }, - ], - }, - { - transformer: 'jmespath', - mapping: 'entity.data.additionalInfo.associatedCompanies', - }, - ], - successAction: 'ASSOCIATED_COMPANIES_GENERATED', - errorAction: 'ASSOCIATED_COMPANIES_FAILED', - }, - ], - }, - config: { - language: 'en', - supportedLanguages: ['en', 'cn'], - initialEvent: 'START', - createCollectionFlowToken: true, - childCallbackResults: [ - { - definitionId: kycEmailSessionDefinition().name, - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - persistenceStates: ['kyc_manual_review'], - deliverEvent: 'KYC_RESPONDED', - }, - { - definitionId: kycEmailSessionDefinition().name, - persistenceStates: ['revision_email_sent'], - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - deliverEvent: 'KYC_REVISION', - }, - { - definitionId: kybChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: '{childEntity: entity.data}', // jmespath - }, - ], - persistenceStates: ['manual_review'], - deliverEvent: 'ASSOCIATED_COMPANY_KYB_FINISHED', - }, - { - definitionId: kybChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: '{childEntity: entity.data}', // jmespath - }, - ], - persistenceStates: ['pending_associated_kyb_collection_flow'], - deliverEvent: 'ASSOCIATED_COMPANY_IN_KYB', - }, - { - definitionId: kybChildWorkflowDefinitionId, - transformers: [ - { - transformer: 'jmespath', - mapping: '{childEntity: entity.data}', // jmespath - }, - ], - persistenceStates: ['revision'], - deliverEvent: 'revision', - }, - ], - workflowLevelResolution: true, - enableManualCreation: true, - isCaseOverviewEnabled: true, - isAssociatedCompanyKybEnabled: false, - }, - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - isPublic: !projectId, - ...(projectId && { projectId }), - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/workflow-definition/workflow-definition.ts b/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/workflow-definition/workflow-definition.ts deleted file mode 100644 index ef7611a9b1..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/creation/oxpay/workflow-definition/workflow-definition.ts +++ /dev/null @@ -1,417 +0,0 @@ -import { env } from '@/env'; -import { defaultContextSchema, StateTag } from '@ballerine/common'; -import { kycEmailSessionDefinition } from 'prisma/data-migrations/templates/creation/common/generate-kyc-email-process'; -import { oxpayInputSchema } from 'prisma/data-migrations/templates/creation/oxpay/workflow-definition/state-schemas/idle/oxpay.idle.schema'; -import { - BUSINESS_UBO_AND_SANCTIONS_DONE, - KYC_DONE_RULE, - kycAndVendorDone, -} from 'prisma/data-migrations/templates/utils/rules'; -import { - createPluginAsyncResponseTransform, - createPluginSyncOrAsyncResponseTransform, - createPluginSyncResponseTransform, -} from '../../../../utils/create-plugin-response-mapping'; - -export const generateWorkflowDefinition = (id: string, name: string, projectId?: string) => { - return { - id, - name, - displayName: 'KYB', - version: 1, - definitionType: 'statechart-json', - definition: { - id: `${id}_v1`, - predictableActionArguments: true, - initial: 'idle', - context: { - documents: [], - }, - states: { - idle: { - on: { - START: 'collection_invite', - }, - meta: { - inputSchema: oxpayInputSchema, - }, - }, - collection_invite: { - on: { - INVIATION_SENT: 'collection_flow', - INVIATION_FAILURE: 'failed', - }, - }, - collection_flow: { - tags: [StateTag.COLLECTION_FLOW], - on: { - // COLLECTION_FLOW_FINISHED: [{ target: 'run_merchant_monitoring' }], - COLLECTION_FLOW_FINISHED: [{ target: 'run_ubos' }], - }, - }, - // run_merchant_monitoring: { - // tags: [StateTag.PENDING_PROCESS], - // on: { - // MERCHANT_MONITORING_SUCCESS: 'run_ubos', - // MERCHANT_MONITORING_FAILED: 'failed', - // }, - // }, - run_ubos: { - tags: [StateTag.COLLECTION_FLOW], - on: { - EMAIL_SENT_TO_UBOS: [{ target: 'run_vendor_data' }], - FAILED_EMAIL_SENT_TO_UBOS: [{ target: 'failed' }], - }, - }, - run_vendor_data: { - tags: [StateTag.DATA_ENRICHMENT], - on: { - KYC_RESPONDED: [kycAndVendorDone], - VENDOR_DONE: [ - { - target: 'pending_kyc_response_to_finish', - cond: { - type: 'jmespath', - options: { - rule: `!(${KYC_DONE_RULE()}) && ${BUSINESS_UBO_AND_SANCTIONS_DONE}`, - }, - }, - }, - kycAndVendorDone, - ], - VENDOR_FAILED: 'failed', - }, - }, - pending_kyc_response_to_finish: { - tags: [StateTag.PENDING_PROCESS], - on: { - KYC_RESPONDED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: KYC_DONE_RULE(), - }, - }, - }, - ], - reject: 'rejected', - revision: 'pending_resubmission', - }, - }, - manual_review: { - tags: [StateTag.MANUAL_REVIEW], - on: { - approve: 'approved', - reject: 'rejected', - revision: 'pending_resubmission', - KYC_REVISION: 'pending_kyc_response_to_finish', - }, - }, - pending_resubmission: { - tags: [StateTag.REVISION], - on: { - EMAIL_SENT: 'revision', - EMAIL_FAILURE: 'failed', - }, - }, - failed: { - tags: [StateTag.FAILURE], - type: 'final' as const, - }, - approved: { - tags: [StateTag.APPROVED], - type: 'final' as const, - }, - revision: { - tags: [StateTag.REVISION], - on: { - COLLECTION_FLOW_FINISHED: [ - { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE()}`, - }, - }, - }, - { target: 'pending_kyc_response_to_finish' }, - ], - }, - }, - rejected: { - tags: [StateTag.REJECTED], - type: 'final' as const, - }, - }, - }, - extensions: { - apiPlugins: [ - { - name: 'collection_invite_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - successAction: 'INVIATION_SENT', - errorAction: 'INVIATION_FAILURE', - method: 'POST', - stateNames: ['collection_invite'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - customerName: metadata.customerName, - collectionFlowUrl: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token,'&lng=',workflowRuntimeConfig.language]), - from: 'no-reply@ballerine.com', - receivers: [entity.data.additionalInfo.mainRepresentative.email], - language: workflowRuntimeConfig.language, - templateId: 'd-8949519316074e03909042cfc5eb4f02', - adapter: '{secret.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - { - name: 'kyb', - displayName: 'Registry Verification', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies-v2/{entity.data.country}/{entity.data.registrationNumber}`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.businessInformation', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `merge( - { vendor: 'asia-verify' }, - entity.data.country == 'HK' && { - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.businessInformation.data&processName=kyb-unified-api']) - } - )`, // jmespath - }, - ], - }, - response: { - transform: createPluginSyncOrAsyncResponseTransform('kyb', "jurisdictionCode == 'HK'"), - }, - }, - { - name: 'company_sanctions', - displayName: 'Company Sanctions', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies/{entity.data.country}/{entity.data.companyName}/sanctions`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.companySanctions', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - vendor: 'asia-verify' - }`, // jmespath - }, - ], - }, - response: { - transform: createPluginSyncResponseTransform('company_sanctions'), - }, - }, - { - name: 'ubo', - displayName: 'UBO Check', - pluginKind: 'api', - url: `{secret.UNIFIED_API_URL}/companies/{entity.data.country}/{entity.data.registrationNumber}/ubo`, - method: 'GET', - stateNames: ['run_vendor_data'], - successAction: 'VENDOR_DONE', - errorAction: 'VENDOR_FAILED', - persistResponseDestination: 'pluginsOutput.ubo', - headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - request: { - transform: [ - { - transformer: 'jmespath', - mapping: `{ - vendor: 'asia-verify', - callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=pluginsOutput.ubo.data&processName=ubo-unified-api']) - }`, // jmespath - }, - ], - }, - response: { - transform: createPluginAsyncResponseTransform('ubo'), - }, - }, - // { - // name: 'merchant_monitoring', - // pluginKind: 'api', - // url: `{secret.UNIFIED_API_URL}/tld/reports`, - // method: 'POST', - // stateNames: ['run_merchant_monitoring'], - // successAction: 'MERCHANT_MONITORING_SUCCESS', - // errorAction: 'MERCHANT_MONITORING_FAILED', - // headers: { Authorization: 'Bearer {secret.UNIFIED_API_TOKEN}' }, - // request: { - // transform: [ - // { - // transformer: 'jmespath', - // mapping: `{ - // websiteUrl: entity.data.additionalInfo.store.website.mainWebsite, - // companyName: entity.data.companyName, - // reportType: 'MERCHANT_REPORT_T1', - // callbackUrl: join('',['{secret.APP_API_URL}/api/v1/external/workflows/',workflowRuntimeId,'/hook/VENDOR_DONE','?resultDestination=entity.report&processName=website-monitoring']) - // }`, // jmespath - // }, - // ], - // }, - // response: { - // transform: [ - // { - // transformer: 'jmespath', - // mapping: '@', // jmespath - // }, - // ], - // }, - // }, - { - name: 'resubmission_email', - pluginKind: 'email', - url: `{secret.EMAIL_API_URL}`, - method: 'POST', - successAction: 'EMAIL_SENT', - errorAction: 'EMAIL_FAILURE', - stateNames: ['pending_resubmission'], - headers: { - Authorization: 'Bearer {secret.EMAIL_API_TOKEN}', - 'Content-Type': 'application/json', - }, - request: { - transform: [ - { - transformer: 'jmespath', - // #TODO: create new token (new using old one) - mapping: `{ - kybCompanyName: entity.data.companyName, - customerCompanyName: metadata.customerName, - firstName: entity.data.additionalInfo.mainRepresentative.firstName, - resubmissionLink: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token,'&lng=',workflowRuntimeConfig.language]), - supportEmail: join('',['support@',metadata.customerName,'.com']), - from: 'no-reply@ballerine.com', - name: join(' ',[metadata.customerName,'Team']), - receivers: [entity.data.additionalInfo.mainRepresentative.email], - templateId: 'd-7305991b3e5840f9a14feec767ea7301', - revisionReason: documents[].decision[].revisionReason | [0], - language: workflowRuntimeConfig.language, - adapter: '${env.MAIL_ADAPTER}' - }`, // jmespath - }, - ], - }, - response: { - transform: [], - }, - }, - ], - childWorkflowPlugins: [ - { - pluginKind: 'child', - name: 'veriff_kyc_child_plugin', - definitionId: kycEmailSessionDefinition().id, - transformers: [ - { - transformer: 'jmespath', - mapping: `{entity: {data: @, type: 'individual'}}`, - }, - { - transformer: 'helper', - mapping: [ - { - source: 'entity.data', - target: 'entity.data', - method: 'omit', - value: ['workflowRuntimeId', 'workflowRuntimeConfig'], - }, - ], - }, - ], - initEvent: 'start', - }, - ], - commonPlugins: [ - { - pluginKind: 'iterative', - name: 'ubos_iterative', - actionPluginName: 'veriff_kyc_child_plugin', - stateNames: ['run_ubos'], - iterateOn: [ - { - transformer: 'jmespath', - mapping: 'entity.data.additionalInfo.ubos', - }, - ], - successAction: 'EMAIL_SENT_TO_UBOS', - errorAction: 'FAILED_EMAIL_SENT_TO_UBOS', - }, - ], - }, - config: { - language: 'en', - supportedLanguages: ['en', 'cn'], - initialEvent: 'START', - createCollectionFlowToken: true, - childCallbackResults: [ - { - definitionId: kycEmailSessionDefinition().name, - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - persistenceStates: ['kyc_manual_review'], - deliverEvent: 'KYC_RESPONDED', - }, - { - definitionId: kycEmailSessionDefinition().name, - persistenceStates: ['revision_email_sent'], - transformers: [ - { - transformer: 'jmespath', - mapping: - '{childEntity: entity.data, vendorResult: pluginsOutput.kyc_session.kyc_session_1.result}', // jmespath - }, - ], - deliverEvent: 'KYC_REVISION', - }, - ], - workflowLevelResolution: true, - enableManualCreation: true, - isCaseOverviewEnabled: true, - }, - contextSchema: { - type: 'json-schema', - schema: defaultContextSchema, - }, - isPublic: !projectId, - ...(projectId && { projectId }), - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/definitions/generate-default-case-level-states.ts b/services/workflows-service/prisma/data-migrations/templates/definitions/generate-default-case-level-states.ts deleted file mode 100644 index 4470e37f8b..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/definitions/generate-default-case-level-states.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { CommonWorkflowEvent, CommonWorkflowStates, StateTag } from '@ballerine/common'; - -export const generateDefaultCaseLevelStates = () => ({ - [CommonWorkflowStates.MANUAL_REVIEW]: { - tags: [StateTag.MANUAL_REVIEW], - on: { - [CommonWorkflowEvent.REJECT]: { target: CommonWorkflowStates.REJECTED }, - [CommonWorkflowEvent.APPROVE]: { target: CommonWorkflowStates.APPROVED }, - [CommonWorkflowEvent.REVISION]: { target: CommonWorkflowStates.REVISION }, - }, - }, - [CommonWorkflowStates.REJECTED]: { - tags: [StateTag.REJECTED], - type: 'final', - }, - [CommonWorkflowStates.APPROVED]: { - tags: [StateTag.APPROVED], - type: 'final', - }, - [CommonWorkflowStates.RESOLVED]: { - tags: [StateTag.RESOLVED], - type: 'final', - }, - [CommonWorkflowStates.REVISION]: { - tags: [StateTag.REVISION], - on: { - [CommonWorkflowEvent.RETURN_TO_REVIEW]: CommonWorkflowStates.MANUAL_REVIEW, - }, - always: { - target: CommonWorkflowStates.MANUAL_REVIEW, - cond: { - type: 'jmespath', - options: { - rule: 'length(documents[?decision.status]) < length(documents)', - }, - }, - }, - }, -}); diff --git a/services/workflows-service/prisma/data-migrations/templates/filters/generate-businesses-filter.ts b/services/workflows-service/prisma/data-migrations/templates/filters/generate-businesses-filter.ts deleted file mode 100644 index 63adc101cb..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/filters/generate-businesses-filter.ts +++ /dev/null @@ -1,74 +0,0 @@ -export const generateBusinessesFilter = ({ - filterName, - definitionId, - projectId, -}: { - filterName: string; - definitionId: string; - projectId: string; -}) => { - return { - name: filterName, - entity: 'businesses', - query: { - select: { - id: true, - status: true, - assigneeId: true, - createdAt: true, - context: true, - state: true, - tags: true, - workflowDefinition: { - select: { - id: true, - name: true, - contextSchema: true, - documentsSchema: true, - config: true, - definition: true, - version: true, - }, - }, - business: { - select: { - id: true, - companyName: true, - registrationNumber: true, - legalForm: true, - countryOfIncorporation: true, - dateOfIncorporation: true, - address: true, - phoneNumber: true, - email: true, - website: true, - industry: true, - taxIdentificationNumber: true, - vatNumber: true, - shareholderStructure: true, - numberOfEmployees: true, - businessPurpose: true, - documents: true, - approvalState: true, - createdAt: true, - updatedAt: true, - }, - }, - assignee: { - select: { - id: true, - firstName: true, - lastName: true, - avatarUrl: true, - }, - }, - childWorkflowsRuntimeData: true, - }, - where: { - workflowDefinitionId: { in: [definitionId] }, - businessId: { not: null }, - }, - }, - projectId: projectId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/filters/generate-individuals-filter.ts b/services/workflows-service/prisma/data-migrations/templates/filters/generate-individuals-filter.ts deleted file mode 100644 index b276edd3cb..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/filters/generate-individuals-filter.ts +++ /dev/null @@ -1,68 +0,0 @@ -export const generateIndividualsFilter = ({ - filterName, - definitionId, - projectId, -}: { - filterName: string; - definitionId: string; - projectId: string; -}) => { - return { - name: filterName, - entity: 'individuals', - query: { - select: { - id: true, - status: true, - assigneeId: true, - createdAt: true, - context: true, - state: true, - tags: true, - workflowDefinition: { - select: { - id: true, - name: true, - contextSchema: true, - documentsSchema: true, - config: true, - definition: true, - version: true, - variant: true, - }, - }, - endUser: { - select: { - id: true, - correlationId: true, - endUserType: true, - approvalState: true, - stateReason: true, - firstName: true, - lastName: true, - email: true, - phone: true, - dateOfBirth: true, - avatarUrl: true, - additionalInfo: true, - createdAt: true, - updatedAt: true, - }, - }, - assignee: { - select: { - id: true, - firstName: true, - lastName: true, - avatarUrl: true, - }, - }, - }, - where: { - workflowDefinitionId: { in: [definitionId] }, - endUserId: { not: null }, - }, - }, - projectId: projectId, - }; -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/index.ts b/services/workflows-service/prisma/data-migrations/templates/index.ts deleted file mode 100644 index 3f18149bbd..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { generateDefaultCaseLevelStates } from './definitions/generate-default-case-level-states'; -export { generateBusinessesFilter } from './filters/generate-businesses-filter'; -export { createLn16ForCustomer } from './creation/create-ln16-for-customer'; - -export * from './template'; diff --git a/services/workflows-service/prisma/data-migrations/templates/template.ts b/services/workflows-service/prisma/data-migrations/templates/template.ts deleted file mode 100644 index 55d5eba47a..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/template.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { INestApplicationContext } from '@nestjs/common'; -import { PrismaClient } from '@prisma/client'; -import { PrismaTransactionClient } from '@/types'; - -export abstract class Template { - constructor( - readonly app: INestApplicationContext, - readonly prismaClient: PrismaTransactionClient | PrismaClient, - readonly params: TParams, - ) {} - - abstract generate(): Promise; -} diff --git a/services/workflows-service/prisma/data-migrations/templates/utils/rules/KYC_DONE_RULE.unit.test.ts b/services/workflows-service/prisma/data-migrations/templates/utils/rules/KYC_DONE_RULE.unit.test.ts deleted file mode 100644 index 33f1d0ef1c..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/utils/rules/KYC_DONE_RULE.unit.test.ts +++ /dev/null @@ -1,191 +0,0 @@ -import { KYC_DONE_RULE } from './index'; -import { search } from 'jmespath'; - -describe('KYC_DONE_RULE #rule #unit', () => { - describe('when there is no data', () => { - it('returns false', () => { - // Arrange - const context = {}; - - // Act - const result = search(context, KYC_DONE_RULE()); - - // Assert - expect(result).toEqual(false); - }); - }); - - describe('when there are no child workflows', () => { - it('returns false', () => { - // Arrange - const context = { - childWorkflows: {}, - }; - - // Act - const result = search(context, KYC_DONE_RULE()); - - // Assert - expect(result).toEqual(false); - }); - }); - - describe('when there are no child workflows with an id of "kyc_email_session_example"', () => { - it('returns false', () => { - // Arrange - const childWorkflows = { - childWorkflows: { - kyb_phone_session_example: {}, - }, - }; - - // Act - const result = search(childWorkflows, KYC_DONE_RULE()); - - // Assert - expect(result).toEqual(false); - }); - }); - - describe('when there are child workflows with an id of "kyc_email_session_example" but no results', () => { - it.each([ - { - context: { - childWorkflows: { - kyc_email_session_example: { - 'd4e9c9b7-0f6b-4c2b-8b4e-8e3e3c3a0b9b': {}, - }, - }, - }, - expected: false, - }, - { - context: { - childWorkflows: { - kyc_email_session_example: { - 'd4e9c9b7-0f6b-4c2b-8b4e-8e3e3c3a0b9b': { - result: {}, - }, - }, - }, - }, - expected: false, - }, - { - context: { - childWorkflows: { - kyc_email_session_example: { - 'd4e9c9b7-0f6b-4c2b-8b4e-8e3e3c3a0b9b': { - result: { - vendorResult: {}, - }, - }, - }, - }, - }, - expected: false, - }, - ])('$context returns false', ({ context, expected }) => { - // Act - const result = search(context, KYC_DONE_RULE()); - - // Assert - expect(result).toEqual(expected); - }); - }); - - describe('when not all child workflows have a decision', () => { - it('returns false', () => { - // Arrange - const context = { - childWorkflows: { - kyc_email_session_example: { - 'd4e9c9b7-0f6b-4c2b-8b4e-8e3e3c3a0b9b': { - result: { - vendorResult: { - decision: 'approved', - }, - }, - }, - 'd4e9c9b7-0f6b-4c2b-8b4e-8e3e3c3a0b9c': { - result: { - vendorResult: {}, - }, - }, - }, - }, - }; - - // Act - const result = search(context, KYC_DONE_RULE()); - - // Assert - expect(result).toEqual(false); - }); - }); - - describe('when all child workflows have a decision and no revision', () => { - it('returns true', () => { - // Arrange - const context = { - childWorkflows: { - kyc_email_session_example: { - 'd4e9c9b7-0f6b-4c2b-8b4e-8e3e3c3a0b9b': { - result: { - vendorResult: { - decision: 'approved', - }, - }, - }, - 'd4e9c9b7-0f6b-4c2b-8b4e-8e3e3c3a0b9c': { - result: { - vendorResult: { - decision: 'rejected', - }, - }, - }, - }, - }, - }; - - // Act - const result = search(context, KYC_DONE_RULE()); - - // Assert - expect(result).toEqual(true); - }); - }); - - describe('when all child workflows have a decision and some are in revision', () => { - it('returns false', () => { - // Arrange - const context = { - childWorkflows: { - kyc_email_session_example: { - 'd4e9c9b7-0f6b-4c2b-8b4e-8e3e3c3a0b9b': { - result: { - vendorResult: { - decision: 'approved', - }, - }, - }, - 'd4e9c9b7-0f6b-4c2b-8b4e-8e3e3c3a0b9c': { - result: { - vendorResult: { - decision: 'rejected', - }, - }, - state: 'revision', - }, - }, - }, - }; - - // Act - const result = search(context, KYC_DONE_RULE()); - - // Assert - expect(result).toEqual(false); - }); - }); -}); diff --git a/services/workflows-service/prisma/data-migrations/templates/utils/rules/index.ts b/services/workflows-service/prisma/data-migrations/templates/utils/rules/index.ts deleted file mode 100644 index 10930dc60d..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/utils/rules/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { UnifiedApiReason } from '@ballerine/common'; - -export const KYC_DONE_RULE = (definitionId = 'kyc_email_session_example') => { - return `(childWorkflows.${definitionId}.*.[result.vendorResult.decision] != null && length(childWorkflows.${definitionId}.*.[result.vendorResult.decision][]) == length(childWorkflows.${definitionId}.*[]) && length(childWorkflows.${definitionId}.* | [?state == 'revision']) == \`0\`)`; -}; - -export const CHILD_KYB_DONE_RULE = (definitionId: string): string => { - return `(childWorkflows.${definitionId} == null || length(childWorkflows.${definitionId}) == \`0\` || length(childWorkflows.${definitionId}.*.state[?@ == 'idle' || @ == 'manual_review']) == length(childWorkflows.${definitionId}.*))`; -}; - -export const BUSINESS_UBO_AND_SANCTIONS_DONE = `(pluginsOutput.businessInformation.data || pluginsOutput.businessInformation.reason == '${UnifiedApiReason.NOT_IMPLEMENTED}') && (pluginsOutput.ubo.data || pluginsOutput.ubo.reason == '${UnifiedApiReason.NOT_IMPLEMENTED}') && pluginsOutput.companySanctions.data`; - -export const kycAndVendorDone = { - target: 'manual_review', - cond: { - type: 'jmespath', - options: { - rule: `${KYC_DONE_RULE()} && ${BUSINESS_UBO_AND_SANCTIONS_DONE}`, - }, - }, -}; diff --git a/services/workflows-service/prisma/data-migrations/templates/utils/schema-utils/currency-codes.ts b/services/workflows-service/prisma/data-migrations/templates/utils/schema-utils/currency-codes.ts deleted file mode 100644 index 415bbc7fd8..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/utils/schema-utils/currency-codes.ts +++ /dev/null @@ -1,1350 +0,0 @@ -export const currencyCodes = [ - { - code: 'AED', - number: '784', - digits: 2, - currency: 'UAE Dirham', - countries: ['United Arab Emirates (The)'], - }, - { - code: 'AFN', - number: '971', - digits: 2, - currency: 'Afghani', - countries: ['Afghanistan'], - }, - { - code: 'ALL', - number: '008', - digits: 2, - currency: 'Lek', - countries: ['Albania'], - }, - { - code: 'AMD', - number: '051', - digits: 2, - currency: 'Armenian Dram', - countries: ['Armenia'], - }, - { - code: 'ANG', - number: '532', - digits: 2, - currency: 'Netherlands Antillean Guilder', - countries: ['Curaçao', 'Sint Maarten (Dutch Part)'], - }, - { - code: 'AOA', - number: '973', - digits: 2, - currency: 'Kwanza', - countries: ['Angola'], - }, - { - code: 'ARS', - number: '032', - digits: 2, - currency: 'Argentine Peso', - countries: ['Argentina'], - }, - { - code: 'AUD', - number: '036', - digits: 2, - currency: 'Australian Dollar', - countries: [ - 'Australia', - 'Christmas Island', - 'Cocos (Keeling) Islands (The)', - 'Heard Island and Mcdonald Islands', - 'Kiribati', - 'Nauru', - 'Norfolk Island', - 'Tuvalu', - ], - }, - { - code: 'AWG', - number: '533', - digits: 2, - currency: 'Aruban Florin', - countries: ['Aruba'], - }, - { - code: 'AZN', - number: '944', - digits: 2, - currency: 'Azerbaijan Manat', - countries: ['Azerbaijan'], - }, - { - code: 'BAM', - number: '977', - digits: 2, - currency: 'Convertible Mark', - countries: ['Bosnia and Herzegovina'], - }, - { - code: 'BBD', - number: '052', - digits: 2, - currency: 'Barbados Dollar', - countries: ['Barbados'], - }, - { - code: 'BDT', - number: '050', - digits: 2, - currency: 'Taka', - countries: ['Bangladesh'], - }, - { - code: 'BGN', - number: '975', - digits: 2, - currency: 'Bulgarian Lev', - countries: ['Bulgaria'], - }, - { - code: 'BHD', - number: '048', - digits: 3, - currency: 'Bahraini Dinar', - countries: ['Bahrain'], - }, - { - code: 'BIF', - number: '108', - digits: 0, - currency: 'Burundi Franc', - countries: ['Burundi'], - }, - { - code: 'BMD', - number: '060', - digits: 2, - currency: 'Bermudian Dollar', - countries: ['Bermuda'], - }, - { - code: 'BND', - number: '096', - digits: 2, - currency: 'Brunei Dollar', - countries: ['Brunei Darussalam'], - }, - { - code: 'BOB', - number: '068', - digits: 2, - currency: 'Boliviano', - countries: ['Bolivia (Plurinational State Of)'], - }, - { - code: 'BOV', - number: '984', - digits: 2, - currency: 'Mvdol', - countries: ['Bolivia (Plurinational State Of)'], - }, - { - code: 'BRL', - number: '986', - digits: 2, - currency: 'Brazilian Real', - countries: ['Brazil'], - }, - { - code: 'BSD', - number: '044', - digits: 2, - currency: 'Bahamian Dollar', - countries: ['Bahamas (The)'], - }, - { - code: 'BTN', - number: '064', - digits: 2, - currency: 'Ngultrum', - countries: ['Bhutan'], - }, - { - code: 'BWP', - number: '072', - digits: 2, - currency: 'Pula', - countries: ['Botswana'], - }, - { - code: 'BYN', - number: '933', - digits: 2, - currency: 'Belarusian Ruble', - countries: ['Belarus'], - }, - { - code: 'BZD', - number: '084', - digits: 2, - currency: 'Belize Dollar', - countries: ['Belize'], - }, - { - code: 'CAD', - number: '124', - digits: 2, - currency: 'Canadian Dollar', - countries: ['Canada'], - }, - { - code: 'CDF', - number: '976', - digits: 2, - currency: 'Congolese Franc', - countries: ['Congo (The Democratic Republic of The)'], - }, - { - code: 'CHE', - number: '947', - digits: 2, - currency: 'WIR Euro', - countries: ['Switzerland'], - }, - { - code: 'CHF', - number: '756', - digits: 2, - currency: 'Swiss Franc', - countries: ['Liechtenstein', 'Switzerland'], - }, - { - code: 'CHW', - number: '948', - digits: 2, - currency: 'WIR Franc', - countries: ['Switzerland'], - }, - { - code: 'CLF', - number: '990', - digits: 4, - currency: 'Unidad de Fomento', - countries: ['Chile'], - }, - { - code: 'CLP', - number: '152', - digits: 0, - currency: 'Chilean Peso', - countries: ['Chile'], - }, - { - code: 'CNY', - number: '156', - digits: 2, - currency: 'Yuan Renminbi', - countries: ['China'], - }, - { - code: 'COP', - number: '170', - digits: 2, - currency: 'Colombian Peso', - countries: ['Colombia'], - }, - { - code: 'COU', - number: '970', - digits: 2, - currency: 'Unidad de Valor Real', - countries: ['Colombia'], - }, - { - code: 'CRC', - number: '188', - digits: 2, - currency: 'Costa Rican Colon', - countries: ['Costa Rica'], - }, - { - code: 'CUC', - number: '931', - digits: 2, - currency: 'Peso Convertible', - countries: ['Cuba'], - }, - { - code: 'CUP', - number: '192', - digits: 2, - currency: 'Cuban Peso', - countries: ['Cuba'], - }, - { - code: 'CVE', - number: '132', - digits: 2, - currency: 'Cabo Verde Escudo', - countries: ['Cabo Verde'], - }, - { - code: 'CZK', - number: '203', - digits: 2, - currency: 'Czech Koruna', - countries: ['Czechia'], - }, - { - code: 'DJF', - number: '262', - digits: 0, - currency: 'Djibouti Franc', - countries: ['Djibouti'], - }, - { - code: 'DKK', - number: '208', - digits: 2, - currency: 'Danish Krone', - countries: ['Denmark', 'Faroe Islands (The)', 'Greenland'], - }, - { - code: 'DOP', - number: '214', - digits: 2, - currency: 'Dominican Peso', - countries: ['Dominican Republic (The)'], - }, - { - code: 'DZD', - number: '012', - digits: 2, - currency: 'Algerian Dinar', - countries: ['Algeria'], - }, - { - code: 'EGP', - number: '818', - digits: 2, - currency: 'Egyptian Pound', - countries: ['Egypt'], - }, - { - code: 'ERN', - number: '232', - digits: 2, - currency: 'Nakfa', - countries: ['Eritrea'], - }, - { - code: 'ETB', - number: '230', - digits: 2, - currency: 'Ethiopian Birr', - countries: ['Ethiopia'], - }, - { - code: 'EUR', - number: '978', - digits: 2, - currency: 'Euro', - countries: [ - 'Åland Islands', - 'Andorra', - 'Austria', - 'Belgium', - 'Cyprus', - 'Estonia', - 'European Union', - 'Finland', - 'France', - 'French Guiana', - 'French Southern Territories (The)', - 'Germany', - 'Greece', - 'Guadeloupe', - 'Holy See (The)', - 'Ireland', - 'Italy', - 'Latvia', - 'Lithuania', - 'Luxembourg', - 'Malta', - 'Martinique', - 'Mayotte', - 'Monaco', - 'Montenegro', - 'Netherlands (The)', - 'Portugal', - 'Réunion', - 'Saint Barthélemy', - 'Saint Martin (French Part)', - 'Saint Pierre and Miquelon', - 'San Marino', - 'Slovakia', - 'Slovenia', - 'Spain', - ], - }, - { - code: 'FJD', - number: '242', - digits: 2, - currency: 'Fiji Dollar', - countries: ['Fiji'], - }, - { - code: 'FKP', - number: '238', - digits: 2, - currency: 'Falkland Islands Pound', - countries: ['Falkland Islands (The) [Malvinas]'], - }, - { - code: 'GBP', - number: '826', - digits: 2, - currency: 'Pound Sterling', - countries: [ - 'Guernsey', - 'Isle of Man', - 'Jersey', - 'United Kingdom of Great Britain and Northern Ireland (The)', - ], - }, - { - code: 'GEL', - number: '981', - digits: 2, - currency: 'Lari', - countries: ['Georgia'], - }, - { - code: 'GHS', - number: '936', - digits: 2, - currency: 'Ghana Cedi', - countries: ['Ghana'], - }, - { - code: 'GIP', - number: '292', - digits: 2, - currency: 'Gibraltar Pound', - countries: ['Gibraltar'], - }, - { - code: 'GMD', - number: '270', - digits: 2, - currency: 'Dalasi', - countries: ['Gambia (The)'], - }, - { - code: 'GNF', - number: '324', - digits: 0, - currency: 'Guinean Franc', - countries: ['Guinea'], - }, - { - code: 'GTQ', - number: '320', - digits: 2, - currency: 'Quetzal', - countries: ['Guatemala'], - }, - { - code: 'GYD', - number: '328', - digits: 2, - currency: 'Guyana Dollar', - countries: ['Guyana'], - }, - { - code: 'HKD', - number: '344', - digits: 2, - currency: 'Hong Kong Dollar', - countries: ['Hong Kong'], - }, - { - code: 'HNL', - number: '340', - digits: 2, - currency: 'Lempira', - countries: ['Honduras'], - }, - { - code: 'HRK', - number: '191', - digits: 2, - currency: 'Kuna', - countries: ['Croatia'], - }, - { - code: 'HTG', - number: '332', - digits: 2, - currency: 'Gourde', - countries: ['Haiti'], - }, - { - code: 'HUF', - number: '348', - digits: 2, - currency: 'Forint', - countries: ['Hungary'], - }, - { - code: 'IDR', - number: '360', - digits: 2, - currency: 'Rupiah', - countries: ['Indonesia'], - }, - { - code: 'ILS', - number: '376', - digits: 2, - currency: 'New Israeli Sheqel', - countries: ['Israel'], - }, - { - code: 'INR', - number: '356', - digits: 2, - currency: 'Indian Rupee', - countries: ['Bhutan', 'India'], - }, - { - code: 'IQD', - number: '368', - digits: 3, - currency: 'Iraqi Dinar', - countries: ['Iraq'], - }, - { - code: 'IRR', - number: '364', - digits: 2, - currency: 'Iranian Rial', - countries: ['Iran (Islamic Republic Of)'], - }, - { - code: 'ISK', - number: '352', - digits: 0, - currency: 'Iceland Krona', - countries: ['Iceland'], - }, - { - code: 'JMD', - number: '388', - digits: 2, - currency: 'Jamaican Dollar', - countries: ['Jamaica'], - }, - { - code: 'JOD', - number: '400', - digits: 3, - currency: 'Jordanian Dinar', - countries: ['Jordan'], - }, - { - code: 'JPY', - number: '392', - digits: 0, - currency: 'Yen', - countries: ['Japan'], - }, - { - code: 'KES', - number: '404', - digits: 2, - currency: 'Kenyan Shilling', - countries: ['Kenya'], - }, - { - code: 'KGS', - number: '417', - digits: 2, - currency: 'Som', - countries: ['Kyrgyzstan'], - }, - { - code: 'KHR', - number: '116', - digits: 2, - currency: 'Riel', - countries: ['Cambodia'], - }, - { - code: 'KMF', - number: '174', - digits: 0, - currency: 'Comorian Franc ', - countries: ['Comoros (The)'], - }, - { - code: 'KPW', - number: '408', - digits: 2, - currency: 'North Korean Won', - countries: ['Korea (The Democratic People’s Republic Of)'], - }, - { - code: 'KRW', - number: '410', - digits: 0, - currency: 'Won', - countries: ['Korea (The Republic Of)'], - }, - { - code: 'KWD', - number: '414', - digits: 3, - currency: 'Kuwaiti Dinar', - countries: ['Kuwait'], - }, - { - code: 'KYD', - number: '136', - digits: 2, - currency: 'Cayman Islands Dollar', - countries: ['Cayman Islands (The)'], - }, - { - code: 'KZT', - number: '398', - digits: 2, - currency: 'Tenge', - countries: ['Kazakhstan'], - }, - { - code: 'LAK', - number: '418', - digits: 2, - currency: 'Lao Kip', - countries: ['Lao People’s Democratic Republic (The)'], - }, - { - code: 'LBP', - number: '422', - digits: 2, - currency: 'Lebanese Pound', - countries: ['Lebanon'], - }, - { - code: 'LKR', - number: '144', - digits: 2, - currency: 'Sri Lanka Rupee', - countries: ['Sri Lanka'], - }, - { - code: 'LRD', - number: '430', - digits: 2, - currency: 'Liberian Dollar', - countries: ['Liberia'], - }, - { - code: 'LSL', - number: '426', - digits: 2, - currency: 'Loti', - countries: ['Lesotho'], - }, - { - code: 'LYD', - number: '434', - digits: 3, - currency: 'Libyan Dinar', - countries: ['Libya'], - }, - { - code: 'MAD', - number: '504', - digits: 2, - currency: 'Moroccan Dirham', - countries: ['Morocco', 'Western Sahara'], - }, - { - code: 'MDL', - number: '498', - digits: 2, - currency: 'Moldovan Leu', - countries: ['Moldova (The Republic Of)'], - }, - { - code: 'MGA', - number: '969', - digits: 2, - currency: 'Malagasy Ariary', - countries: ['Madagascar'], - }, - { - code: 'MKD', - number: '807', - digits: 2, - currency: 'Denar', - countries: ['Macedonia (The Former Yugoslav Republic Of)'], - }, - { - code: 'MMK', - number: '104', - digits: 2, - currency: 'Kyat', - countries: ['Myanmar'], - }, - { - code: 'MNT', - number: '496', - digits: 2, - currency: 'Tugrik', - countries: ['Mongolia'], - }, - { - code: 'MOP', - number: '446', - digits: 2, - currency: 'Pataca', - countries: ['Macao'], - }, - { - code: 'MRU', - number: '929', - digits: 2, - currency: 'Ouguiya', - countries: ['Mauritania'], - }, - { - code: 'MUR', - number: '480', - digits: 2, - currency: 'Mauritius Rupee', - countries: ['Mauritius'], - }, - { - code: 'MVR', - number: '462', - digits: 2, - currency: 'Rufiyaa', - countries: ['Maldives'], - }, - { - code: 'MWK', - number: '454', - digits: 2, - currency: 'Malawi Kwacha', - countries: ['Malawi'], - }, - { - code: 'MXN', - number: '484', - digits: 2, - currency: 'Mexican Peso', - countries: ['Mexico'], - }, - { - code: 'MXV', - number: '979', - digits: 2, - currency: 'Mexican Unidad de Inversion (UDI)', - countries: ['Mexico'], - }, - { - code: 'MYR', - number: '458', - digits: 2, - currency: 'Malaysian Ringgit', - countries: ['Malaysia'], - }, - { - code: 'MZN', - number: '943', - digits: 2, - currency: 'Mozambique Metical', - countries: ['Mozambique'], - }, - { - code: 'NAD', - number: '516', - digits: 2, - currency: 'Namibia Dollar', - countries: ['Namibia'], - }, - { - code: 'NGN', - number: '566', - digits: 2, - currency: 'Naira', - countries: ['Nigeria'], - }, - { - code: 'NIO', - number: '558', - digits: 2, - currency: 'Cordoba Oro', - countries: ['Nicaragua'], - }, - { - code: 'NOK', - number: '578', - digits: 2, - currency: 'Norwegian Krone', - countries: ['Bouvet Island', 'Norway', 'Svalbard and Jan Mayen'], - }, - { - code: 'NPR', - number: '524', - digits: 2, - currency: 'Nepalese Rupee', - countries: ['Nepal'], - }, - { - code: 'NZD', - number: '554', - digits: 2, - currency: 'New Zealand Dollar', - countries: ['Cook Islands (The)', 'New Zealand', 'Niue', 'Pitcairn', 'Tokelau'], - }, - { - code: 'OMR', - number: '512', - digits: 3, - currency: 'Rial Omani', - countries: ['Oman'], - }, - { - code: 'PAB', - number: '590', - digits: 2, - currency: 'Balboa', - countries: ['Panama'], - }, - { - code: 'PEN', - number: '604', - digits: 2, - currency: 'Sol', - countries: ['Peru'], - }, - { - code: 'PGK', - number: '598', - digits: 2, - currency: 'Kina', - countries: ['Papua New Guinea'], - }, - { - code: 'PHP', - number: '608', - digits: 2, - currency: 'Philippine Peso', - countries: ['Philippines (The)'], - }, - { - code: 'PKR', - number: '586', - digits: 2, - currency: 'Pakistan Rupee', - countries: ['Pakistan'], - }, - { - code: 'PLN', - number: '985', - digits: 2, - currency: 'Zloty', - countries: ['Poland'], - }, - { - code: 'PYG', - number: '600', - digits: 0, - currency: 'Guarani', - countries: ['Paraguay'], - }, - { - code: 'QAR', - number: '634', - digits: 2, - currency: 'Qatari Rial', - countries: ['Qatar'], - }, - { - code: 'RON', - number: '946', - digits: 2, - currency: 'Romanian Leu', - countries: ['Romania'], - }, - { - code: 'RSD', - number: '941', - digits: 2, - currency: 'Serbian Dinar', - countries: ['Serbia'], - }, - { - code: 'RUB', - number: '643', - digits: 2, - currency: 'Russian Ruble', - countries: ['Russian Federation (The)'], - }, - { - code: 'RWF', - number: '646', - digits: 0, - currency: 'Rwanda Franc', - countries: ['Rwanda'], - }, - { - code: 'SAR', - number: '682', - digits: 2, - currency: 'Saudi Riyal', - countries: ['Saudi Arabia'], - }, - { - code: 'SBD', - number: '090', - digits: 2, - currency: 'Solomon Islands Dollar', - countries: ['Solomon Islands'], - }, - { - code: 'SCR', - number: '690', - digits: 2, - currency: 'Seychelles Rupee', - countries: ['Seychelles'], - }, - { - code: 'SDG', - number: '938', - digits: 2, - currency: 'Sudanese Pound', - countries: ['Sudan (The)'], - }, - { - code: 'SEK', - number: '752', - digits: 2, - currency: 'Swedish Krona', - countries: ['Sweden'], - }, - { - code: 'SGD', - number: '702', - digits: 2, - currency: 'Singapore Dollar', - countries: ['Singapore'], - }, - { - code: 'SHP', - number: '654', - digits: 2, - currency: 'Saint Helena Pound', - countries: ['Saint Helena, Ascension and Tristan Da Cunha'], - }, - { - code: 'SLL', - number: '694', - digits: 2, - currency: 'Leone', - countries: ['Sierra Leone'], - }, - { - code: 'SOS', - number: '706', - digits: 2, - currency: 'Somali Shilling', - countries: ['Somalia'], - }, - { - code: 'SRD', - number: '968', - digits: 2, - currency: 'Surinam Dollar', - countries: ['Suriname'], - }, - { - code: 'SSP', - number: '728', - digits: 2, - currency: 'South Sudanese Pound', - countries: ['South Sudan'], - }, - { - code: 'STN', - number: '930', - digits: 2, - currency: 'Dobra', - countries: ['Sao Tome and Principe'], - }, - { - code: 'SVC', - number: '222', - digits: 2, - currency: 'El Salvador Colon', - countries: ['El Salvador'], - }, - { - code: 'SYP', - number: '760', - digits: 2, - currency: 'Syrian Pound', - countries: ['Syrian Arab Republic'], - }, - { - code: 'SZL', - number: '748', - digits: 2, - currency: 'Lilangeni', - countries: ['Eswatini'], - }, - { - code: 'THB', - number: '764', - digits: 2, - currency: 'Baht', - countries: ['Thailand'], - }, - { - code: 'TJS', - number: '972', - digits: 2, - currency: 'Somoni', - countries: ['Tajikistan'], - }, - { - code: 'TMT', - number: '934', - digits: 2, - currency: 'Turkmenistan New Manat', - countries: ['Turkmenistan'], - }, - { - code: 'TND', - number: '788', - digits: 3, - currency: 'Tunisian Dinar', - countries: ['Tunisia'], - }, - { - code: 'TOP', - number: '776', - digits: 2, - currency: 'Pa’anga', - countries: ['Tonga'], - }, - { - code: 'TRY', - number: '949', - digits: 2, - currency: 'Turkish Lira', - countries: ['Turkey'], - }, - { - code: 'TTD', - number: '780', - digits: 2, - currency: 'Trinidad and Tobago Dollar', - countries: ['Trinidad and Tobago'], - }, - { - code: 'TWD', - number: '901', - digits: 2, - currency: 'New Taiwan Dollar', - countries: ['Taiwan (Province of China)'], - }, - { - code: 'TZS', - number: '834', - digits: 2, - currency: 'Tanzanian Shilling', - countries: ['Tanzania, United Republic Of'], - }, - { - code: 'UAH', - number: '980', - digits: 2, - currency: 'Hryvnia', - countries: ['Ukraine'], - }, - { - code: 'UGX', - number: '800', - digits: 0, - currency: 'Uganda Shilling', - countries: ['Uganda'], - }, - { - code: 'USD', - number: '840', - digits: 2, - currency: 'US Dollar', - countries: [ - 'American Samoa', - 'Bonaire, Sint Eustatius and Saba', - 'British Indian Ocean Territory (The)', - 'Ecuador', - 'El Salvador', - 'Guam', - 'Haiti', - 'Marshall Islands (The)', - 'Micronesia (Federated States Of)', - 'Northern Mariana Islands (The)', - 'Palau', - 'Panama', - 'Puerto Rico', - 'Timor-Leste', - 'Turks and Caicos Islands (The)', - 'United States Minor Outlying Islands (The)', - 'United States of America (The)', - 'Virgin Islands (British)', - 'Virgin Islands (U.S.)', - ], - }, - { - code: 'USN', - number: '997', - digits: 2, - currency: 'US Dollar (Next day)', - countries: ['United States of America (The)'], - }, - { - code: 'UYI', - number: '940', - digits: 0, - currency: 'Uruguay Peso en Unidades Indexadas (UI)', - countries: ['Uruguay'], - }, - { - code: 'UYU', - number: '858', - digits: 2, - currency: 'Peso Uruguayo', - countries: ['Uruguay'], - }, - { - code: 'UYW', - number: '927', - digits: 4, - currency: 'Unidad Previsional', - countries: ['Uruguay'], - }, - { - code: 'UZS', - number: '860', - digits: 2, - currency: 'Uzbekistan Sum', - countries: ['Uzbekistan'], - }, - { - code: 'VES', - number: '928', - digits: 2, - currency: 'Bolívar Soberano', - countries: ['Venezuela (Bolivarian Republic Of)'], - }, - { - code: 'VND', - number: '704', - digits: 0, - currency: 'Dong', - countries: ['Viet Nam'], - }, - { - code: 'VUV', - number: '548', - digits: 0, - currency: 'Vatu', - countries: ['Vanuatu'], - }, - { - code: 'WST', - number: '882', - digits: 2, - currency: 'Tala', - countries: ['Samoa'], - }, - { - code: 'XAF', - number: '950', - digits: 0, - currency: 'CFA Franc BEAC', - countries: [ - 'Cameroon', - 'Central African Republic (The)', - 'Chad', - 'Congo (The)', - 'Equatorial Guinea', - 'Gabon', - ], - }, - { - code: 'XAG', - number: '961', - digits: 0, - currency: 'Silver', - countries: ['Zz11_silver'], - }, - { - code: 'XAU', - number: '959', - digits: 0, - currency: 'Gold', - countries: ['Zz08_gold'], - }, - { - code: 'XBA', - number: '955', - digits: 0, - currency: 'Bond Markets Unit European Composite Unit (EURCO)', - countries: ['Zz01_bond Markets Unit European_eurco'], - }, - { - code: 'XBB', - number: '956', - digits: 0, - currency: 'Bond Markets Unit European Monetary Unit (E.M.U.-6)', - countries: ['Zz02_bond Markets Unit European_emu-6'], - }, - { - code: 'XBC', - number: '957', - digits: 0, - currency: 'Bond Markets Unit European Unit of Account 9 (E.U.A.-9)', - countries: ['Zz03_bond Markets Unit European_eua-9'], - }, - { - code: 'XBD', - number: '958', - digits: 0, - currency: 'Bond Markets Unit European Unit of Account 17 (E.U.A.-17)', - countries: ['Zz04_bond Markets Unit European_eua-17'], - }, - { - code: 'XCD', - number: '951', - digits: 2, - currency: 'East Caribbean Dollar', - countries: [ - 'Anguilla', - 'Antigua and Barbuda', - 'Dominica', - 'Grenada', - 'Montserrat', - 'Saint Kitts and Nevis', - 'Saint Lucia', - 'Saint Vincent and the Grenadines', - ], - }, - { - code: 'XDR', - number: '960', - digits: 0, - currency: 'SDR (Special Drawing Right)', - countries: ['International Monetary Fund (Imf) '], - }, - { - code: 'XOF', - number: '952', - digits: 0, - currency: 'CFA Franc BCEAO', - countries: [ - 'Benin', - 'Burkina Faso', - "Côte d'Ivoire", - 'Guinea-Bissau', - 'Mali', - 'Niger (The)', - 'Senegal', - 'Togo', - ], - }, - { - code: 'XPD', - number: '964', - digits: 0, - currency: 'Palladium', - countries: ['Zz09_palladium'], - }, - { - code: 'XPF', - number: '953', - digits: 0, - currency: 'CFP Franc', - countries: ['French Polynesia', 'New Caledonia', 'Wallis and Futuna'], - }, - { - code: 'XPT', - number: '962', - digits: 0, - currency: 'Platinum', - countries: ['Zz10_platinum'], - }, - { - code: 'XSU', - number: '994', - digits: 0, - currency: 'Sucre', - countries: ['Sistema Unitario De Compensacion Regional De Pagos "Sucre"'], - }, - { - code: 'XTS', - number: '963', - digits: 0, - currency: 'Codes specifically reserved for testing purposes', - countries: ['Zz06_testing_code'], - }, - { - code: 'XUA', - number: '965', - digits: 0, - currency: 'ADB Unit of Account', - countries: ['Member Countries of the African Development Bank Group'], - }, - { - code: 'XXX', - number: '999', - digits: 0, - currency: 'The codes assigned for transactions where no currency is involved', - countries: ['Zz07_no_currency'], - }, - { - code: 'YER', - number: '886', - digits: 2, - currency: 'Yemeni Rial', - countries: ['Yemen'], - }, - { - code: 'ZAR', - number: '710', - digits: 2, - currency: 'Rand', - countries: ['Lesotho', 'Namibia', 'South Africa'], - }, - { - code: 'ZMW', - number: '967', - digits: 2, - currency: 'Zambian Kwacha', - countries: ['Zambia'], - }, - { - code: 'ZWL', - number: '932', - digits: 2, - currency: 'Zimbabwe Dollar', - countries: ['Zimbabwe'], - }, -]; diff --git a/services/workflows-service/prisma/data-migrations/templates/utils/schema-utils/regex.ts b/services/workflows-service/prisma/data-migrations/templates/utils/schema-utils/regex.ts deleted file mode 100644 index 3614e1fde0..0000000000 --- a/services/workflows-service/prisma/data-migrations/templates/utils/schema-utils/regex.ts +++ /dev/null @@ -1,6 +0,0 @@ -const urlPattern = - '((https?):\\/\\/)?([a-zA-Z0-9-_]+\\.)+[a-zA-Z0-9]+(\\.[a-z]{2})?(\\/[a-zA-Z0-9_#-]+)*(\\/)?(\\?[a-zA-Z0-9_-]+=[a-zA-Z0-9_-]+(&[a-zA-Z0-9_-]+=[a-zA-Z0-9_-]+)*)?(#[a-zA-Z0-9_-]+)?'; - -export const singleUrlPattern = `^${urlPattern}$`; - -export const multipleUrlsPattern = `^${urlPattern}(, *${urlPattern})*$`; diff --git a/services/workflows-service/prisma/data-migrations/utils/create-plugin-response-mapping.ts b/services/workflows-service/prisma/data-migrations/utils/create-plugin-response-mapping.ts deleted file mode 100644 index c78e24f3ad..0000000000 --- a/services/workflows-service/prisma/data-migrations/utils/create-plugin-response-mapping.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { ProcessStatus, UnifiedApiReason } from '@ballerine/common'; - -const invokedAtTransformer = { - transformer: 'helper', - mapping: [ - { - source: 'invokedAt', - target: 'invokedAt', - method: 'setTimeToRecordUTC', - }, - ], -}; - -export const createPluginAsyncResponseTransform = (action: string) => [ - { - transformer: 'jmespath', - mapping: `merge({ name: '${action}', status: reason == '${UnifiedApiReason.NOT_IMPLEMENTED}' && '${ProcessStatus.CANCELED}' || error != \`null\` && '${ProcessStatus.ERROR}' || '${ProcessStatus.IN_PROGRESS}' }, @)`, // jmespath - }, - invokedAtTransformer, -]; - -export const createPluginSyncResponseTransform = (action: string) => [ - { - transformer: 'jmespath', - mapping: `merge({ name: '${action}', status: reason == '${UnifiedApiReason.NOT_IMPLEMENTED}' && '${ProcessStatus.CANCELED}' || error != \`null\` && '${ProcessStatus.ERROR}' || '${ProcessStatus.SUCCESS}' }, @)`, // jmespath - }, - invokedAtTransformer, -]; - -export const createPluginSyncOrAsyncResponseTransform = (action: string, isAsync: string) => [ - { - transformer: 'jmespath', - mapping: `merge({ name: '${action}', status: reason == '${UnifiedApiReason.NOT_IMPLEMENTED}' && '${ProcessStatus.CANCELED}' || error != \`null\` && '${ProcessStatus.ERROR}' || ${isAsync} && '${ProcessStatus.IN_PROGRESS}' || '${ProcessStatus.SUCCESS}' }, @)`, - }, - invokedAtTransformer, -]; diff --git a/services/workflows-service/prisma/data-migrations/utils/fetch-customer-project-ids.ts b/services/workflows-service/prisma/data-migrations/utils/fetch-customer-project-ids.ts deleted file mode 100644 index 522e803ab7..0000000000 --- a/services/workflows-service/prisma/data-migrations/utils/fetch-customer-project-ids.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { PrismaTransactionClient } from '@/types'; - -export const fetchCustomerProjectIds = async ( - transaction: PrismaTransactionClient, - customerName: string, -) => { - const customer = await transaction.customer.findFirst({ - where: { name: customerName }, - select: { projects: true }, - }); - const projectIds = customer?.projects?.map(project => project.id); - - return projectIds ?? []; -};