-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
290 changed files
with
42,842 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
services/workflows-service/prisma/data-migrations/.github/workflows/CD.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: CD | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
- prod | ||
- sb | ||
|
||
jobs: | ||
trigger: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Trigger workflow in another repo | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.REPO_ACCESS_TOKEN }} | ||
script: | | ||
await github.rest.repos.createDispatchEvent({ | ||
owner: 'ballerine-io', | ||
repo: 'ballerine', | ||
event_type: 'trigger-cd-event' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
2 changes: 2 additions & 0 deletions
2
services/workflows-service/prisma/data-migrations/.gitmodules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[submodule "services/workflows-service/prisma/data-migrations"] | ||
branch = main |
29 changes: 29 additions & 0 deletions
29
...prisma/data-migrations/common/20231128125824_update_filter_query_as_defintion_id_array.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
import { INestApplicationContext } from '@nestjs/common'; | ||
|
||
export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { | ||
await client.$transaction( | ||
async transaction => { | ||
const filters = await transaction.filter.findMany({}); | ||
|
||
for (const filter of filters) { | ||
const { where: whereQuery, ...rest } = filter.query as any; | ||
|
||
if (whereQuery.workflowDefinitionId && !whereQuery.workflowDefinitionId.in) { | ||
whereQuery.workflowDefinitionId = { | ||
in: [whereQuery.workflowDefinitionId], | ||
}; | ||
|
||
await transaction.filter.update({ | ||
where: { id: filter.id }, | ||
data: { query: { ...rest, where: whereQuery } }, | ||
}); | ||
} | ||
} | ||
}, | ||
{ | ||
timeout: 25000, | ||
maxWait: 25000, | ||
}, | ||
); | ||
}; |
36 changes: 36 additions & 0 deletions
36
...ws-service/prisma/data-migrations/common/20231129132123_add_document_schema_to_filters.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
import { INestApplicationContext } from '@nestjs/common'; | ||
|
||
export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { | ||
await client.$transaction( | ||
async transaction => { | ||
const allFilters = await transaction.filter.findMany({}); | ||
|
||
for (const filter of allFilters) { | ||
const query = filter.query as { | ||
select: { workflowDefinition: Record<string, any> }; | ||
}; | ||
query.select.workflowDefinition = { | ||
select: { | ||
id: true, | ||
name: true, | ||
contextSchema: true, | ||
documentsSchema: true, | ||
config: true, | ||
definition: true, | ||
version: true, | ||
}, | ||
}; | ||
|
||
await transaction.filter.update({ | ||
where: { id: filter.id }, | ||
data: { query }, | ||
}); | ||
} | ||
}, | ||
{ | ||
timeout: 15000, | ||
maxWait: 15000, | ||
}, | ||
); | ||
}; |
25 changes: 25 additions & 0 deletions
25
...rkflows-service/prisma/data-migrations/common/20231203121600_document_pages_schema_csv.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
import { INestApplicationContext } from '@nestjs/common'; | ||
import { defaultContextSchema } from '@ballerine/common'; | ||
|
||
export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { | ||
await client.$transaction( | ||
async transaction => { | ||
await transaction.workflowDefinition.updateMany({ | ||
where: { | ||
id: 'kyb_dynamic_ui_session_example', | ||
}, | ||
data: { | ||
contextSchema: { | ||
type: 'json-schema', | ||
schema: defaultContextSchema, | ||
}, | ||
}, | ||
}); | ||
}, | ||
{ | ||
timeout: 15000, | ||
maxWait: 15000, | ||
}, | ||
); | ||
}; |
80 changes: 80 additions & 0 deletions
80
...kflows-service/prisma/data-migrations/common/20231217173250_update_clipspay_definition.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
|
||
import { kycEmailSessionDefinition } from '../templates/creation/common/generate-kyc-email-process'; | ||
import { generateWorkflowDefinition } from '../templates/creation/clipspay/workflow-definition/workflow-definition'; | ||
import { composeUiDefinition } from '../templates/creation/clipspay/collection-flow/compose-ui-definition'; | ||
import { generateDefinitionLogic } from '../templates/creation/clipspay/collection-flow/generate-definition-logic'; | ||
|
||
const emailDefinitionName = 'kyc_email_session_example'; | ||
const clipspayDefinitionName = 'kyb_dynamic_ui_session_example'; | ||
|
||
export const migrate = async (client: PrismaClient) => { | ||
await client.$transaction( | ||
async transaction => { | ||
const kycEmailDefinition = kycEmailSessionDefinition(); | ||
await transaction.workflowDefinition.updateMany({ | ||
where: { | ||
name: emailDefinitionName, | ||
}, | ||
data: { | ||
definition: kycEmailDefinition.definition, | ||
config: kycEmailDefinition.config, | ||
extensions: kycEmailDefinition.extensions, | ||
}, | ||
}); | ||
|
||
const newClipspayWorkflow = generateWorkflowDefinition( | ||
clipspayDefinitionName, | ||
clipspayDefinitionName, | ||
); | ||
|
||
const customers = await transaction.customer.findMany({ | ||
where: { | ||
name: { | ||
contains: 'clipspay', | ||
}, | ||
}, | ||
select: { | ||
projects: true, | ||
}, | ||
}); | ||
|
||
const projects = customers | ||
?.map(customer => customer.projects.map(project => project.id)) | ||
.flat(); | ||
|
||
await transaction.workflowDefinition.updateMany({ | ||
where: { | ||
name: newClipspayWorkflow.name, | ||
projectId: { | ||
in: projects, | ||
}, | ||
}, | ||
data: { | ||
definition: newClipspayWorkflow.definition, | ||
config: newClipspayWorkflow.config, | ||
extensions: newClipspayWorkflow.extensions, | ||
}, | ||
}); | ||
|
||
const newUiDefinition = composeUiDefinition( | ||
newClipspayWorkflow.id, | ||
generateDefinitionLogic(newClipspayWorkflow.id), | ||
); | ||
|
||
await transaction.uiDefinition.updateMany({ | ||
where: { | ||
workflowDefinitionId: newClipspayWorkflow.id, | ||
projectId: { | ||
in: projects, | ||
}, | ||
}, | ||
data: newUiDefinition, | ||
}); | ||
}, | ||
{ | ||
timeout: 25000, | ||
maxWait: 25000, | ||
}, | ||
); | ||
}; |
7 changes: 7 additions & 0 deletions
7
...risma/data-migrations/common/20231217173252_add_workflow_definition_version_to_filters.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
import { INestApplicationContext } from '@nestjs/common'; | ||
import { migrate as filtersMigration } from './20231129132123_add_document_schema_to_filters'; | ||
|
||
export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { | ||
await filtersMigration(client, app); | ||
}; |
48 changes: 48 additions & 0 deletions
48
...rations/common/20240117151034_update_clipspay_workflow_with_unsupported_countries_rule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
import { INestApplicationContext } from '@nestjs/common'; | ||
import { generateWorkflowDefinition } from '../templates/creation/clipspay/workflow-definition/workflow-definition'; | ||
|
||
const clipspayDefinitionName = 'kyb_dynamic_ui_session_example'; | ||
|
||
export const migrate = async (client: PrismaClient, app: INestApplicationContext) => { | ||
await client.$transaction( | ||
async transaction => { | ||
const newClipspayWorkflow = generateWorkflowDefinition( | ||
clipspayDefinitionName, | ||
clipspayDefinitionName, | ||
); | ||
|
||
const customers = await transaction.customer.findMany({ | ||
where: { | ||
name: { | ||
contains: 'clipspay', | ||
}, | ||
}, | ||
select: { | ||
projects: true, | ||
}, | ||
}); | ||
|
||
const projects = customers | ||
?.map(customer => customer.projects.map(project => project.id)) | ||
.flat(); | ||
|
||
await transaction.workflowDefinition.updateMany({ | ||
where: { | ||
name: clipspayDefinitionName, | ||
projectId: { | ||
in: projects, | ||
}, | ||
}, | ||
data: { | ||
definition: newClipspayWorkflow.definition, | ||
extensions: newClipspayWorkflow.extensions, | ||
}, | ||
}); | ||
}, | ||
{ | ||
timeout: 15000, | ||
maxWait: 15000, | ||
}, | ||
); | ||
}; |
52 changes: 52 additions & 0 deletions
52
...flows-service/prisma/data-migrations/common/20240129144339_update_clipspay_definitions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
|
||
import { generateWorkflowDefinition } from '../templates/creation/clipspay/workflow-definition/workflow-definition'; | ||
import { composeUiDefinition } from '../templates/creation/clipspay/collection-flow/compose-ui-definition'; | ||
import { generateDefinitionLogic } from '../templates/creation/clipspay/collection-flow/generate-definition-logic'; | ||
|
||
const clipspayDefinitionName = 'kyb_dynamic_ui_session_example'; | ||
|
||
export const migrate = async (client: PrismaClient) => { | ||
await client.$transaction( | ||
async transaction => { | ||
const newClipspayWorkflow = generateWorkflowDefinition( | ||
clipspayDefinitionName, | ||
clipspayDefinitionName, | ||
); | ||
|
||
const customers = await transaction.customer.findMany({ | ||
where: { | ||
name: { | ||
contains: 'clipspay', | ||
}, | ||
}, | ||
select: { | ||
projects: true, | ||
}, | ||
}); | ||
|
||
const projects = customers | ||
?.map(customer => customer.projects.map(project => project.id)) | ||
.flat(); | ||
|
||
const newUiDefinition = composeUiDefinition( | ||
newClipspayWorkflow.id, | ||
generateDefinitionLogic(newClipspayWorkflow.id), | ||
); | ||
|
||
await transaction.uiDefinition.updateMany({ | ||
where: { | ||
workflowDefinitionId: newClipspayWorkflow.id, | ||
projectId: { | ||
in: projects, | ||
}, | ||
}, | ||
data: newUiDefinition, | ||
}); | ||
}, | ||
{ | ||
timeout: 25000, | ||
maxWait: 25000, | ||
}, | ||
); | ||
}; |
Oops, something went wrong.