Skip to content

Commit 3dc144c

Browse files
authored
Store merchants in the Unified API DB (#2976)
* feat: sync businesses with unified api * fix: pr comments * fix: remove cron * fix: better seed * fix: data-migrations
1 parent 0980f70 commit 3dc144c

File tree

18 files changed

+253
-829
lines changed

18 files changed

+253
-829
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
websiteUrl,countryCode,lineOfBusiness,parentCompanyName,merchantName,correlationId
22
https://www.ballerine.com,,,,,
33
https://www.google.com,US,Search Engine,Alphabet Inc.,Google,1
4-
https://www.bbc.com,UK,Journalism,BBC Inc.,BBC,2
4+
https://www.bbc.com,GB,Journalism,BBC Inc.,BBC,2

services/workflows-service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"test:integration": "jest --testRegex '.*\\.intg\\.test\\.ts$'",
2424
"test:e2e": "jest --testRegex '.*\\.e2e\\.test\\.ts$'",
2525
"test:watch": "jest --verbose --watch",
26-
"seed": "tsx scripts/seed.ts",
26+
"seed": "nest start --entryFile scripts/seed",
2727
"db:migrate-dev": "prisma migrate dev",
2828
"db:migrate-up": "prisma migrate deploy",
2929
"db:clean": "tsx scripts/clean.ts",

services/workflows-service/scripts/run-filter.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export async function fliterQuery() {
1919
id: true,
2020
email: true,
2121
phone: true,
22-
jsonData: true,
2322
lastName: true,
2423
avatarUrl: true,
2524
createdAt: true,
@@ -31,7 +30,6 @@ export async function fliterQuery() {
3130
approvalState: true,
3231
correlationId: true,
3332
additionalInfo: true,
34-
verificationId: true,
3533
workflowRuntimeData: {
3634
select: {
3735
id: true,

services/workflows-service/scripts/seed.ts

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ import { generateKycManualReviewRuntimeAndToken } from './workflows/runtime/gene
3535
import { generateInitialCollectionFlowExample } from './workflows/runtime/generate-initial-collection-flow-example';
3636
import { uiKybParentWithAssociatedCompanies } from './workflows/ui-definition/kyb-with-associated-companies/ui-kyb-parent-dynamic-example';
3737
import { generateWebsiteMonitoringExample } from './workflows/website-monitoring-workflow';
38+
import { CustomerService } from '@/customer/customer.service';
39+
import { NestFactory } from '@nestjs/core';
40+
import { AppModule } from '@/app.module';
3841

3942
const BCRYPT_SALT: string | number = 10;
4043

@@ -69,14 +72,14 @@ function generateAvatarImageUri(imageTemplate: string, countOfBusiness: number,
6972
}
7073

7174
async function createCustomer(
72-
client: PrismaClient,
75+
customerService: CustomerService,
7376
id: string,
7477
apiKey: string,
7578
logoImageUri: string,
7679
faviconImageUri: string,
7780
webhookSharedSecret: string,
7881
) {
79-
return client.customer.create({
82+
return customerService.create({
8083
data: {
8184
id: `customer-${id}`,
8285
name: `customer-${id}`,
@@ -93,9 +96,28 @@ async function createCustomer(
9396
faviconImageUri,
9497
country: 'GB',
9598
language: 'en',
96-
config: {
97-
isMerchantMonitoringEnabled: true,
98-
isExample: true,
99+
config: { isDemo: true, withQualityControl: true, isMerchantMonitoringEnabled: true },
100+
features: {
101+
createBusinessReport: {
102+
enabled: true,
103+
options: { type: 'MERCHANT_REPORT_T1', version: '2' },
104+
},
105+
createBusinessReportBatch: {
106+
enabled: true,
107+
options: { type: 'MERCHANT_REPORT_T1', version: '2' },
108+
},
109+
ONGOING_MERCHANT_REPORT: {
110+
name: 'ONGOING_MERCHANT_REPORT',
111+
enabled: true,
112+
options: {
113+
reportType: 'ONGOING_MERCHANT_REPORT_T1',
114+
runByDefault: true,
115+
scheduleType: 'interval',
116+
intervalInDays: 30,
117+
proxyViaCountry: 'GB',
118+
workflowVersion: '2',
119+
},
120+
},
99121
},
100122
},
101123
});
@@ -120,10 +142,16 @@ const DEFAULT_TOKENS = {
120142

121143
async function seed() {
122144
console.info('Seeding database...');
145+
const app = await NestFactory.createApplicationContext(AppModule, { logger: false });
146+
147+
app.enableShutdownHooks();
148+
149+
const customerService = app.get(CustomerService);
150+
123151
const client = new PrismaClient();
124152
await generateDynamicDefinitionForE2eTest(client);
125153
const customer = (await createCustomer(
126-
client,
154+
customerService,
127155
'1',
128156
env.API_KEY,
129157
'https://cdn.ballerine.io/images/ballerine_logo.svg',
@@ -132,7 +160,7 @@ async function seed() {
132160
)) as Customer;
133161

134162
const customer2 = (await createCustomer(
135-
client,
163+
customerService,
136164
'2',
137165
`${env.API_KEY}2`,
138166
'https://cdn.ballerine.io/images/ballerine_logo.svg',
@@ -1044,6 +1072,8 @@ async function seed() {
10441072
token: DEFAULT_TOKENS.KYC,
10451073
});
10461074

1075+
await app.close();
1076+
10471077
console.info('Seeded database successfully');
10481078
}
10491079
async function createUsers({ project1, project2 }: any, client: PrismaClient) {

0 commit comments

Comments
 (0)