Skip to content

Commit 028dcb3

Browse files
Notion schema fix and Cron schedule change (#2793)
* feat: notion schema fix and Cron schedule change * feat: test fix
1 parent 5448ecd commit 028dcb3

File tree

8 files changed

+19
-10
lines changed

8 files changed

+19
-10
lines changed

packages/common/src/rule-engine/operators/enums.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const OPERATION = {
99
LAST_YEAR: 'LAST_YEAR',
1010
EXISTS: 'EXISTS',
1111
IN: 'IN',
12+
IN_CASE_INSENSITIVE: 'IN_CASE_INSENSITIVE',
1213
NOT_IN: 'NOT_IN',
1314
AML_CHECK: 'AML_CHECK',
1415
} as const;
@@ -24,6 +25,7 @@ export const OPERATIONS = [
2425
OPERATION.LAST_YEAR,
2526
OPERATION.EXISTS,
2627
OPERATION.IN,
28+
OPERATION.IN_CASE_INSENSITIVE,
2729
OPERATION.NOT_IN,
2830
OPERATION.AML_CHECK,
2931
];

packages/common/src/rule-engine/rules/schemas.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import { z } from 'zod';
22

3-
import { OPERATION, OPERATOR } from '../operators/enums';
43
import { RuleSet } from './types';
54
import {
5+
OPERATION,
6+
OPERATOR,
67
AmlCheckSchema,
78
BetweenSchema,
89
ExistsSchema,
910
LastYearsSchema,
1011
PrimitiveArraySchema,
1112
PrimitiveSchema,
12-
} from '../operators/schemas';
13+
} from '@/rule-engine';
1314

14-
export function getValues<T extends Record<string, unknown>>(obj: T) {
15+
export const getValues = <T extends Record<string, unknown>>(obj: T) => {
1516
return Object.values(obj) as [(typeof obj)[keyof T]];
16-
}
17+
};
1718

1819
export const RuleSchema = z.discriminatedUnion('operator', [
1920
z.object({
@@ -79,6 +80,11 @@ export const RuleSchema = z.discriminatedUnion('operator', [
7980
operator: z.literal(OPERATION.IN),
8081
value: PrimitiveArraySchema,
8182
}),
83+
z.object({
84+
key: z.string(),
85+
operator: z.literal(OPERATION.IN_CASE_INSENSITIVE),
86+
value: PrimitiveArraySchema,
87+
}),
8288
z.object({
8389
key: z.string(),
8490
operator: z.literal(OPERATION.NOT_IN),

packages/workflow-core/src/lib/plugins/common-plugin/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export interface RiskRulesPluginParams {
7575
id: string;
7676
domain: string;
7777
indicator: string;
78-
riskLevel: 'critical' | 'moderate' | 'positive';
78+
riskLevel: 'critical' | 'high' | 'moderate' | 'positive';
7979
baseRiskScore: number;
8080
additionalRiskScore: number;
8181
result: RuleResultSet;

services/workflows-service/src/rule-engine/core/test/rule-engine.unit.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,13 @@ describe('Rule Engine', () => {
119119
"LTE",
120120
"EXISTS",
121121
"IN",
122+
"IN_CASE_INSENSITIVE",
122123
"NOT_IN"
123124
],
124125
"path": [
125126
"operator"
126127
],
127-
"message": "Invalid discriminator value. Expected 'LAST_YEAR' | 'AML_CHECK' | 'EQUALS' | 'NOT_EQUALS' | 'BETWEEN' | 'GT' | 'LT' | 'GTE' | 'LTE' | 'EXISTS' | 'IN' | 'NOT_IN'"
128+
"message": "Invalid discriminator value. Expected 'LAST_YEAR' | 'AML_CHECK' | 'EQUALS' | 'NOT_EQUALS' | 'BETWEEN' | 'GT' | 'LT' | 'GTE' | 'LTE' | 'EXISTS' | 'IN' | 'IN_CASE_INSENSITIVE' | 'NOT_IN'"
128129
}
129130
],
130131
"name": "ZodError"

services/workflows-service/src/rule-engine/risk-rule.service.intg.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { fetchServiceFromModule } from '@/test/helpers/nest-app-helper';
2-
import { NotionService } from './../notion/notion.service';
2+
import { NotionService } from '../notion/notion.service';
33
import { RiskRuleService } from './risk-rule.service';
44

55
// We should inject notion api key in order to run it during CI pipeline

services/workflows-service/src/rule-engine/risk-rule.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const NotionRiskRuleRecordSchema = z
2525
.pipe(RuleSetSchema),
2626
Domain: z.string().min(1),
2727
Indicator: z.string().min(1),
28-
'Risk level': z.enum(['positive', 'moderate', 'critical']),
28+
'Risk level': z.enum(['positive', 'moderate', 'high', 'critical']),
2929
'Base risk score': z.number().min(0).max(100),
3030
'Additional risk score': z.number().min(0).max(100),
3131
'Min risk score': z.number().min(0).max(100),

services/workflows-service/src/workflow/cron/ongoing-monitoring.cron.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class OngoingMonitoringCron {
3030
protected readonly businessReportService: BusinessReportService,
3131
) {}
3232

33-
@Cron(CronExpression.EVERY_MINUTE)
33+
@Cron(CronExpression.EVERY_HOUR)
3434
async handleCron() {
3535
this.logger.log('Ongoing monitoring cron started');
3636

0 commit comments

Comments
 (0)