-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bal 1644 - report in case management #2343
Conversation
…:ballerine-io/ballerine into blokh/feat/add-business-report-report-id
# Conflicts: # services/workflows-service/prisma/data-migrations # services/workflows-service/src/business-report/business-report.repository.ts
# Conflicts: # services/workflows-service/prisma/data-migrations
# Conflicts: # services/workflows-service/prisma/data-migrations
PR Code Suggestions ✨
|
# Conflicts: # services/workflows-service/prisma/data-migrations # services/workflows-service/scripts/alerts/generate-alerts.ts # services/workflows-service/src/alert/alert.service.intg.test.ts # services/workflows-service/src/data-analytics/data-analytics.service.ts # services/workflows-service/src/data-analytics/types.ts
# Conflicts: # pnpm-lock.yaml # services/workflows-service/scripts/alerts/generate-alerts.ts # services/workflows-service/src/alert/alert.service.intg.test.ts # services/workflows-service/src/data-analytics/data-analytics.service.ts # services/workflows-service/src/data-analytics/types.ts
# Conflicts: # services/workflows-service/prisma/schema.prisma # services/workflows-service/scripts/alerts/generate-alerts.ts # services/workflows-service/scripts/seed.ts # services/workflows-service/src/alert/alert.controller.external.ts # services/workflows-service/src/alert/alert.service.intg.test.ts # services/workflows-service/src/alert/alert.service.ts # services/workflows-service/src/alert/consts.ts # services/workflows-service/src/business-report/business-report.controller.internal.ts # services/workflows-service/src/business-report/business-report.repository.ts # services/workflows-service/src/business-report/business-report.service.ts # services/workflows-service/src/data-analytics/data-analytics.service.ts # services/workflows-service/src/workflow/cron/ongoing-monitoring.cron.ts # services/workflows-service/src/workflow/hook-callback-handler.service.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 13
Outside diff range and nitpick comments (8)
apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/components/OngoingMonitoringRiskSheet/OngoingMonitoringRiskSheet.tsx (1)
24-28
: Ensure accessibility for dynamic content.The component dynamically inserts content which may affect users with disabilities. Consider adding appropriate ARIA roles and properties to enhance accessibility, especially for dynamic content like the ongoing monitoring risk changes.
apps/backoffice-v2/src/pages/TransactionMonitoringAlertsAnalysis/components/AlertAnalysisSheet/AlertAnalysisSheet.tsx (1)
3-3
: Validate prop types for enhanced reliability.The component uses several props like
transactions
,heading
, andsummary
. Consider using TypeScript'sPropTypes
or similar mechanisms to validate these props to ensure they meet expected types and structures, enhancing component reliability.Also applies to: 7-7
services/workflows-service/src/common/app-logger/app-logger.service.ts (1)
2-2
: Ensure proper dependency management in NestJS.The
AppLoggerService
class uses@Inject('LOGGER')
for dependency injection. Ensure that the 'LOGGER' token is correctly configured in the NestJS module to avoid runtime errors. Additionally, consider defining an interface or using a class for the logger to enhance type safety and maintainability.Also applies to: 4-4
apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/TransactionMonitoringAlerts.page.tsx (1)
2-2
: Optimize component imports for better maintainability.Consider using a barrel file for importing components from the same directory or module. This can simplify the import statements and make the code cleaner and easier to maintain.
Also applies to: 3-3, 6-6
apps/backoffice-v2/src/pages/BusinessesAlerts/BusinessesAlerts.page.tsx (1)
2-2
: Optimize component imports for better maintainability.Consider using a barrel file for importing components from the same directory or module. This can simplify the import statements and make the code cleaner and easier to maintain.
Also applies to: 3-3, 6-6
apps/backoffice-v2/src/common/components/atoms/MultiSelect/MultiSelect.tsx (1)
Line range hint
18-116
: Review theMultiSelect
component for proper state management and re-render optimizations. Consider usingReact.memo
oruseMemo
for performance improvements.- export const MultiSelect = < + export const MultiSelect = React.memo(<services/workflows-service/src/workflow/cron/ongoing-monitoring.cron.intg.test.ts (1)
[!TIP]
Codebase VerificationThe current test cases for
OngoingMonitoringCron
do not include scenarios for error handling or verifying that Sentry captures exceptions. To ensure comprehensive test coverage for the new Sentry integration, consider adding test cases that simulate error scenarios and verify that Sentry captures these exceptions.
- Add a test case to simulate an error occurring within the
handleCron
method and verify thatmockSentryService().captureException
is called.Analysis chain
Line range hint
17-38
: Ensure comprehensive test coverage for new Sentry integration.The integration of SentryService in the cron job should be accompanied by tests to verify that it captures exceptions as expected. Consider adding a test case to simulate a scenario where an error occurs, and verify that Sentry captures it.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify Sentry captures exceptions in cron job tests. # Test: Search for Sentry test cases. Expect: At least one test case for Sentry capturing exceptions. rg --type typescript $'mockSentryService().captureException'Length of output: 96
Script:
#!/bin/bash # Description: Verify Sentry captures exceptions in cron job tests. # Test: Search for Sentry test cases. Expect: At least one test case for Sentry capturing exceptions. rg --type ts $'mockSentryService().captureException'Length of output: 53
Script:
#!/bin/bash # Description: Verify error handling test cases in cron job tests. # Test: Search for error handling test cases. Expect: At least one test case for error handling. rg --type ts 'catch' services/workflows-service/src/workflow/cron/ongoing-monitoring.cron.intg.test.tsLength of output: 102
Script:
#!/bin/bash # Description: Verify test cases related to OngoingMonitoringCron class. # Test: Search for test cases related to OngoingMonitoringCron class. Expect: At least one test case for OngoingMonitoringCron. rg --type ts 'OngoingMonitoringCron' services/workflows-service/src/workflow/cron/ongoing-monitoring.cron.intg.test.tsLength of output: 368
Script:
#!/bin/bash # Description: Extract test cases from ongoing-monitoring.cron.intg.test.ts for manual inspection. # Extract test cases for manual inspection. sed -n '/describe/,/});/p' services/workflows-service/src/workflow/cron/ongoing-monitoring.cron.intg.test.tsLength of output: 1944
services/workflows-service/prisma/schema.prisma (1)
717-723
: Add documentation for theAlertDefinition
model.It would be beneficial to add comments describing the purpose and use of each field in the
AlertDefinition
model, especially for new fields likemonitoringType
anddefaultSeverity
. This will enhance maintainability and clarity for other developers.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (36)
- apps/backoffice-v2/src/Router/Router.tsx (2 hunks)
- apps/backoffice-v2/src/common/components/atoms/MultiSelect/MultiSelect.tsx (4 hunks)
- apps/backoffice-v2/src/common/hooks/useFilter/useFilter.tsx (2 hunks)
- apps/backoffice-v2/src/domains/alerts/fetchers.ts (3 hunks)
- apps/backoffice-v2/src/domains/alerts/helpers/get-alerts-search-schema.ts (2 hunks)
- apps/backoffice-v2/src/domains/business-alerts/fetchers.ts (1 hunks)
- apps/backoffice-v2/src/domains/business-alerts/query-keys.ts (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlerts/BusinessesAlerts.page.tsx (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/BusinessAlertsTable.tsx (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/columns.tsx (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/hooks/useBusinessAlertsTableLogic/useBusinessAlertsTableLogic.tsx (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/utils/get-severity-from-risk-score.ts (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlerts/hooks/useBusinessAlertsLogic/useBusinessAlertsLogic.tsx (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/BusinessesAlertsAnalysis.page.tsx (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/components/OngoingMonitoringRiskSheet/OngoingMonitoringRiskSheet.tsx (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/components/OngoingMonitoringTable/columns.tsx (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/hooks/useBusinessAlertsAnalysisLogic/useBusinessAlertsAnalysisLogic.tsx (1 hunks)
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/TransactionMonitoringAlerts.page.tsx (1 hunks)
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsFilters/AlertsFilters.tsx (2 hunks)
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsHeader/AlertsHeader.tsx (1 hunks)
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/AlertsTable.tsx (1 hunks)
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/interfaces.ts (1 hunks)
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/hooks/useTransactionMonitoringAlertsLogic/useTransactionMonitoringAlertsLogic.tsx (2 hunks)
- apps/backoffice-v2/src/pages/TransactionMonitoringAlertsAnalysis/components/AlertAnalysisSheet/AlertAnalysisSheet.tsx (1 hunks)
- services/workflows-service/prisma/schema.prisma (2 hunks)
- services/workflows-service/scripts/alerts/generate-alerts.ts (1 hunks)
- services/workflows-service/scripts/seed.ts (1 hunks)
- services/workflows-service/src/alert/alert.controller.external.ts (2 hunks)
- services/workflows-service/src/common/app-logger/app-logger.service.ts (1 hunks)
- services/workflows-service/src/data-analytics/data-analytics.service.ts (1 hunks)
- services/workflows-service/src/data-analytics/types.ts (1 hunks)
- services/workflows-service/src/prisma/prisma.service.ts (3 hunks)
- services/workflows-service/src/transaction/transaction.service.ts (2 hunks)
- services/workflows-service/src/workflow/cron/cron.module.ts (1 hunks)
- services/workflows-service/src/workflow/cron/ongoing-monitoring.cron.intg.test.ts (5 hunks)
- services/workflows-service/src/workflow/cron/ongoing-monitoring.cron.ts (2 hunks)
Files skipped from review due to trivial changes (5)
- apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/utils/get-severity-from-risk-score.ts
- apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/hooks/useBusinessAlertsAnalysisLogic/useBusinessAlertsAnalysisLogic.tsx
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/AlertsTable.tsx
- services/workflows-service/scripts/alerts/generate-alerts.ts
- services/workflows-service/src/workflow/cron/cron.module.ts
Additional comments not posted (27)
apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/interfaces.ts (1)
1-4
: LGTM! The update toIAlertsTableProps
aligns with the enhanced alert management features.apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/BusinessesAlertsAnalysis.page.tsx (1)
1-13
: Well implemented! The use ofuseBusinessAlertsAnalysisLogic
and the handling of potential undefined values with a fallback are both prudent choices.apps/backoffice-v2/src/common/hooks/useFilter/useFilter.tsx (1)
22-31
: The addition of theonClear
function is a valuable enhancement to the filter functionality, allowing users to reset specific filters easily.apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/BusinessAlertsTable.tsx (1)
1-22
: Well implemented! TheBusinessAlertsTable
component is correctly set up with dynamic sorting and initial state configuration, enhancing user interaction.apps/backoffice-v2/src/domains/alerts/helpers/get-alerts-search-schema.ts (1)
Line range hint
6-29
: The addition of thetype
parameter to the alert search schema is a thoughtful enhancement, allowing for more granular alert management.apps/backoffice-v2/src/domains/business-alerts/query-keys.ts (1)
1-43
: The structured approach to defining query keys for business alerts enhances maintainability and ensures efficient data fetching.apps/backoffice-v2/src/pages/BusinessesAlerts/hooks/useBusinessAlertsLogic/useBusinessAlertsLogic.tsx (1)
23-23
: LGTM! The entityType 'business' aligns with the PR objectives for business-specific alerts.apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsFilters/AlertsFilters.tsx (1)
53-56
: Ensure memoization dependencies are correctly specified to avoid unnecessary re-renders.services/workflows-service/src/transaction/transaction.service.ts (1)
53-53
: Good use of custom error handling for Prisma errors and integration with Sentry for error tracking.apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/components/OngoingMonitoringTable/columns.tsx (1)
34-66
: The columns for 'Date & Time' and 'Risk Score' are well-implemented with appropriate formatting and data representation.services/workflows-service/src/prisma/prisma.service.ts (1)
Line range hint
73-99
: Effective use of PostgreSQL advisory locks for managing database transactions and robust error handling.apps/backoffice-v2/src/domains/business-alerts/fetchers.ts (5)
11-26
: Ensure theBusinessAlertItem
schema is correctly defined and matches the expected data structure.
53-71
: Check the use ofapiClient
inassignAlertsByIds
. Ensure that the API endpoint and method are correctly configured.
73-91
: Validate the logic inupdateAlertsDecisionByIds
to ensure it correctly handles different alert decisions.
98-106
: Confirm thatfetchAlertDefinitionByAlertId
fetches the correct alert definition based on the alert ID.
110-118
: Ensure thatfetchAlertLabels
correctly retrieves alert labels and handles errors appropriately.services/workflows-service/src/data-analytics/types.ts (2)
7-7
: Ensure theInlineRule
type is correctly used throughout the codebase, especially in functions that accept this type.Verification successful
The
InlineRule
type is used consistently across the codebase, particularly in thedata-analytics.service.ts
andalert.service.ts
files. This confirms that the type is correctly utilized in various functions and imports.
services/workflows-service/src/data-analytics/data-analytics.service.ts
services/workflows-service/src/alert/alert.service.ts
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify usage of `InlineRule` type. # Test: Search for `InlineRule` usage. Expect: Consistent usage across the codebase. rg --type typescript 'InlineRule' 'services/workflows-service/src'Length of output: 99
Script:
#!/bin/bash # Description: Verify usage of `InlineRule` type. # Test: Search for `InlineRule` usage. Expect: Consistent usage across the codebase. rg --type ts 'InlineRule' 'services/workflows-service/src'Length of output: 1048
7-7
: Check if theid
field inInlineRule
should be strictly typed asstring
or if it can be more specific.Verification successful
The search results indicate that the
id
field is predominantly used as astring
across various files in the codebase. There are no indications that theid
field inInlineRule
should be more specific thanstring
.
- The
id
field is used in multiple contexts, including tests, services, controllers, and repositories, and it is consistently typed asstring
.- There are no specific types or enums being used for the
id
field that would suggest a more specific type is necessary.Based on this evidence, it is appropriate to conclude that the
id
field inInlineRule
should remain typed asstring
.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the type of `id` in `InlineRule`. # Test: Search for `id` field usage. Expect: Specific type usage where possible. rg --type typescript 'id:' 'services/workflows-service/src'Length of output: 92
Script:
#!/bin/bash # Description: Verify the type of `id` in `InlineRule`. # Test: Search for `id` field usage. Expect: Specific type usage where possible. rg --type ts 'id:' 'services/workflows-service/src'Length of output: 42391
apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsHeader/AlertsHeader.tsx (2)
2-2
: Ensure thatuseSelect
is used correctly and efficiently inAlertsHeader
.
10-10
: Check theAlertsHeader
component for accessibility features, especially in dropdowns and interactive elements.apps/backoffice-v2/src/domains/alerts/fetchers.ts (2)
75-96
: Review theAlertItemSchema
for correctness and ensure it matches the expected data structure.
Line range hint
100-118
: Check thefetchAlerts
function for proper error handling and performance optimizations.apps/backoffice-v2/src/Router/Router.tsx (1)
128-145
: Ensure that the routing configuration for/locale/businesses
is correctly set up and matches the application's requirements.apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/columns.tsx (1)
72-82
: Ensure proper handling of unknown severity values.As previously suggested, adding error handling for unexpected severity values is crucial to prevent runtime errors. The existing solution should be implemented if not already done.
services/workflows-service/src/workflow/cron/ongoing-monitoring.cron.ts (1)
Line range hint
23-37
: Ensure proper initialization and usage of SentryService.The addition of SentryService for error tracking is a good practice, especially for background tasks like cron jobs where errors might not be immediately visible.
services/workflows-service/prisma/schema.prisma (1)
842-852
: Ensure consistency in the use of unique constraints.The
reportId
field in theBusinessReport
model is marked as unique, which is excellent for ensuring data integrity. However, consider adding a unique constraint that includes bothreportId
andprojectId
to prevent duplicate reports across different projects.- reportId String @unique + reportId String @unique([reportId, projectId])Likely invalid or redundant comment.
services/workflows-service/scripts/seed.ts (1)
37-37
: Validate the appropriateness of generated mock data.Ensure that the data generated by the
faker
library aligns with the business requirements and testing scenarios. This includes checking the realism and variability of the data, especially for fields that may affect the application's behavior during testing.
...ringAlerts/hooks/useTransactionMonitoringAlertsLogic/useTransactionMonitoringAlertsLogic.tsx
Outdated
Show resolved
Hide resolved
apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/columns.tsx
Show resolved
Hide resolved
services/workflows-service/src/alert/alert.controller.external.ts
Outdated
Show resolved
Hide resolved
services/workflows-service/src/alert/alert.controller.external.ts
Outdated
Show resolved
Hide resolved
...onents/BusinessAlertsTable/hooks/useBusinessAlertsTableLogic/useBusinessAlertsTableLogic.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range and nitpick comments (1)
services/workflows-service/src/workflow/hook-callback-handler.service.ts (1)
Line range hint
132-169
: Ensure robust error handling and data integrity inprepareWebsiteMonitoringContext
. Consider adding more specific error messages and validations for data operations, especially when dealing with external inputs and database interactions.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- services/workflows-service/prisma/data-migrations (1 hunks)
- services/workflows-service/src/business-report/business-report.repository.ts (1 hunks)
- services/workflows-service/src/business-report/business-report.service.ts (1 hunks)
- services/workflows-service/src/workflow/hook-callback-handler.service.ts (5 hunks)
Files skipped from review due to trivial changes (1)
- services/workflows-service/prisma/data-migrations
Additional comments not posted (2)
services/workflows-service/src/business-report/business-report.repository.ts (1)
39-46
: The addition of thefindFirst
method enhances the repository's capabilities by allowing specific queries for the first matching business report. Good use of scoped queries for multi-tenancy.services/workflows-service/src/business-report/business-report.service.ts (1)
51-56
: The addition of thefindFirst
method in the service layer correctly delegates to the repository, maintaining a clean separation of concerns. Good use of async/await for asynchronous operations.
services/workflows-service/src/workflow/hook-callback-handler.service.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- services/workflows-service/prisma/data-migrations (1 hunks)
- services/workflows-service/scripts/alerts/generate-alerts.ts (5 hunks)
Files skipped from review as they are similar to previous changes (2)
- services/workflows-service/prisma/data-migrations
- services/workflows-service/scripts/alerts/generate-alerts.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Outside diff range and nitpick comments (2)
apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/columns.tsx (1)
21-21
: Consider updating the TODO comment to reflect the current status of the decisions PR.If the decisions PR has been merged, update the type here accordingly. If not, consider adding a reference to the PR for easier tracking.
apps/backoffice-v2/src/common/components/organisms/DataTable/DataTable.tsx (1)
56-58
: Ensure the TypeScript types are correctly defined for theprops
object.The use of TypeScript for prop types adds robustness to the component. Consider adding more detailed comments or documentation on how these props affect the component's behavior, especially for complex objects like
scroll
.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (31)
- apps/backoffice-v2/src/common/components/atoms/MultiSelect/MultiSelect.tsx (4 hunks)
- apps/backoffice-v2/src/common/components/atoms/OpenUrlInNewTabButton/OpenUrlInNewTabButton.tsx (1 hunks)
- apps/backoffice-v2/src/common/components/organisms/DataTable/DataTable.tsx (2 hunks)
- apps/backoffice-v2/src/domains/alerts/fetchers.ts (2 hunks)
- apps/backoffice-v2/src/domains/alerts/helpers/get-alerts-search-schema.ts (2 hunks)
- apps/backoffice-v2/src/domains/alerts/hooks/queries/useAlertsQuery/useAlertsQuery.tsx (1 hunks)
- apps/backoffice-v2/src/domains/alerts/query-keys.ts (1 hunks)
- apps/backoffice-v2/src/domains/business-alerts/fetchers.ts (1 hunks)
- apps/backoffice-v2/src/domains/business-alerts/hooks/queries/useBusinessAlertsQuery/useBusinessAlertsQuery.tsx (1 hunks)
- apps/backoffice-v2/src/domains/business-alerts/query-keys.ts (1 hunks)
- apps/backoffice-v2/src/domains/business-reports/fetchers.ts (1 hunks)
- apps/backoffice-v2/src/domains/business-reports/hooks/queries/useBusinessReportsQuery/useBusinessReportsQuery.ts (1 hunks)
- apps/backoffice-v2/src/domains/business-reports/hooks/queries/useLatestBusinessReportQuery/useLatestBusinessReportQuery.tsx (1 hunks)
- apps/backoffice-v2/src/domains/business-reports/query-keys.ts (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/columns.tsx (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/hooks/useBusinessAlertsTableLogic/useBusinessAlertsTableLogic.tsx (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/interfaces.ts (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlerts/hooks/useBusinessAlertsLogic/useBusinessAlertsLogic.tsx (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/components/OngoingMonitoringTable/OngoingMonitoringTable.tsx (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/components/OngoingMonitoringTable/columns.tsx (1 hunks)
- apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/hooks/useBusinessAlertsAnalysisLogic/useBusinessAlertsAnalysisLogic.tsx (1 hunks)
- apps/backoffice-v2/src/pages/SignIn/SignIn.page.tsx (2 hunks)
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsFilters/AlertsFilters.tsx (2 hunks)
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/columns.tsx (2 hunks)
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/hooks/useAlertsTableLogic.tsx (1 hunks)
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/interfaces.ts (1 hunks)
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/severity-to-class-name.tsx (1 hunks)
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/hooks/useTransactionMonitoringAlertsLogic/useTransactionMonitoringAlertsLogic.tsx (1 hunks)
- services/workflows-service/scripts/alerts/generate-alerts.ts (6 hunks)
- services/workflows-service/scripts/seed.ts (2 hunks)
- services/workflows-service/src/alert/alert.controller.external.ts (2 hunks)
Files skipped from review due to trivial changes (2)
- apps/backoffice-v2/src/domains/alerts/hooks/queries/useAlertsQuery/useAlertsQuery.tsx
- apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/interfaces.ts
Files skipped from review as they are similar to previous changes (14)
- apps/backoffice-v2/src/common/components/atoms/MultiSelect/MultiSelect.tsx
- apps/backoffice-v2/src/domains/alerts/helpers/get-alerts-search-schema.ts
- apps/backoffice-v2/src/domains/business-alerts/fetchers.ts
- apps/backoffice-v2/src/domains/business-alerts/query-keys.ts
- apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/columns.tsx
- apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/hooks/useBusinessAlertsTableLogic/useBusinessAlertsTableLogic.tsx
- apps/backoffice-v2/src/pages/BusinessesAlerts/hooks/useBusinessAlertsLogic/useBusinessAlertsLogic.tsx
- apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/components/OngoingMonitoringTable/columns.tsx
- apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/hooks/useBusinessAlertsAnalysisLogic/useBusinessAlertsAnalysisLogic.tsx
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsFilters/AlertsFilters.tsx
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/interfaces.ts
- apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/hooks/useTransactionMonitoringAlertsLogic/useTransactionMonitoringAlertsLogic.tsx
- services/workflows-service/scripts/alerts/generate-alerts.ts
- services/workflows-service/src/alert/alert.controller.external.ts
Additional comments not posted (29)
apps/backoffice-v2/src/domains/business-reports/hooks/queries/useBusinessReportsQuery/useBusinessReportsQuery.ts (1)
6-19
: The implementation ofuseBusinessReportsQuery
looks solid and adheres to best practices for data fetching in React.apps/backoffice-v2/src/domains/business-reports/query-keys.ts (1)
3-20
: The query key generation usingcreateQueryKeys
is implemented correctly and efficiently. This approach enhances the maintainability and scalability of the code.apps/backoffice-v2/src/domains/business-reports/hooks/queries/useLatestBusinessReportQuery/useLatestBusinessReportQuery.tsx (1)
5-12
: The implementation ofuseLatestBusinessReportQuery
is robust, correctly handling authentication and parameter validation. This ensures that the query is only executed when appropriate, optimizing performance and resource usage.apps/backoffice-v2/src/common/components/atoms/OpenUrlInNewTabButton/OpenUrlInNewTabButton.tsx (1)
6-31
: TheOpenUrlInNewTabButton
component is well-implemented, with attention to security, accessibility, and styling. The use of conditional styling andaria-disabled
attributes enhances the user experience and accessibility.apps/backoffice-v2/src/domains/business-alerts/hooks/queries/useBusinessAlertsQuery/useBusinessAlertsQuery.tsx (1)
5-33
: The implementation ofuseBusinessAlertsQuery
is robust, efficiently handling authentication and parameter validation. This ensures that the query is only executed when all necessary conditions are met, optimizing performance and resource usage.apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/severity-to-class-name.tsx (1)
10-24
: The severity to class name mappings are correctly implemented and use TypeScript's type safety features effectively.apps/backoffice-v2/src/domains/alerts/query-keys.ts (1)
9-22
: The query keys for alerts are well-defined, incorporating necessary parameters for effective data fetching and sorting.apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/hooks/useAlertsTableLogic.tsx (1)
8-8
: The hookuseAlertsTableLogic
is well-implemented, correctly using React hooks for performance optimizations and session management.Also applies to: 10-10
apps/backoffice-v2/src/domains/business-reports/fetchers.ts (1)
22-51
: The fetch functions for business reports are correctly implemented using async/await and handle errors effectively withhandleZodError
.apps/backoffice-v2/src/pages/SignIn/SignIn.page.tsx (1)
Line range hint
21-58
: The sign-in form is well-implemented, using modern React practices and libraries for form handling and validation.apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/columns.tsx (11)
21-21
: The 'dataTimestamp' column implementation looks good and handles null values correctly.
21-21
: The 'updatedAt' column implementation is consistent and correct.
21-21
: The 'correlationId' column effectively uses the Badge component to display the ID, ensuring it fits within the UI constraints.
21-21
: The 'subject' column correctly handles potential null values and displays the subject's name.
21-21
: The 'subject.type' column correctly formats the subject type using the titleCase function.
21-21
: The 'subject.correlationId' column effectively uses a custom hook to manage text overflow, enhancing UI responsiveness and accessibility.
21-21
: The 'severity' column dynamically applies classes based on the alert's severity, which is a robust method for providing visual cues in the UI.
21-21
: The 'alertDetails' column implementation handles long text appropriately by setting a maximum width, ensuring the UI remains clean.
21-21
: The 'assignee' column effectively uses the Avatar component with a fallback mechanism, which is a good practice for handling missing images.
21-21
: The 'status' column correctly formats the status using the titleCase function.
21-21
: The 'decision' column implementation is complex but correctly handles the conversion to screaming snake case and applies dynamic styling based on the decision.apps/backoffice-v2/src/common/components/organisms/DataTable/DataTable.tsx (1)
191-197
: The DataTable component is well-implemented with a clear structure and efficient use of React hooks.services/workflows-service/scripts/seed.ts (7)
38-38
: Ensure secure handling of user passwords.
38-38
: Standardize workflow definition creation.
38-38
: Optimize file handling operations.
38-38
: Consider adding error handling for database operations.
991-998
: Ensure proper error handling for theseedOngoingMonitoringAlerts
function.#!/bin/bash # Description: Verify error handling in the `seedOngoingMonitoringAlerts` function. # Test: Search for error handling logic. Expect: Try-catch blocks or equivalent. rg --type typescript 'try {.*seedOngoingMonitoringAlerts.*} catch'
1000-1000
: Consider implementing error handling forseedBusinessReports
.#!/bin/bash # Description: Verify error handling in the `seedBusinessReports` function. # Test: Search for error handling logic. Expect: Try-catch blocks or equivalent. rg --type typescript 'try {.*seedBusinessReports.*} catch'
991-998
: Verify the filtering logic inseedOngoingMonitoringAlerts
to ensure it aligns with business requirements.#!/bin/bash # Description: Verify the filtering logic in `seedOngoingMonitoringAlerts`. # Test: Search for the function implementation and check the filtering conditions. ast-grep --lang typescript --pattern $'function seedOngoingMonitoringAlerts($_, $_) { $$$ }'
agentUserIds: agentUsers.map(({ id }) => id), | ||
}); | ||
|
||
await seedBusinessReports(client, { businessRiskIds, project: project1 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address the TODO comment regarding creating businesses with end users attached.
Would you like me to help implement this feature or should I open a GitHub issue to track this task?
export type TBusinessReportType = ('MERCHANT_REPORT_T1' | 'ONGOING_MERCHANT_REPORT_T1') & | ||
(string & {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider simplifying the type definition for TBusinessReportType
to enhance readability and maintainability.
- export type TBusinessReportType = ('MERCHANT_REPORT_T1' | 'ONGOING_MERCHANT_REPORT_T1') &
- (string & {});
+ export type TBusinessReportType = 'MERCHANT_REPORT_T1' | 'ONGOING_MERCHANT_REPORT_T1';
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
export type TBusinessReportType = ('MERCHANT_REPORT_T1' | 'ONGOING_MERCHANT_REPORT_T1') & | |
(string & {}); | |
export type TBusinessReportType = 'MERCHANT_REPORT_T1' | 'ONGOING_MERCHANT_REPORT_T1'; |
export const AlertSchema = ObjectWithIdSchema.extend({ | ||
dataTimestamp: z.string().datetime(), | ||
updatedAt: z.string().datetime(), | ||
subject: ObjectWithIdSchema.extend({ | ||
name: z.string(), | ||
correlationId: z.string(), | ||
alertDetails: z.string(), | ||
// amountOfTxs: z.number(), | ||
assignee: ObjectWithIdSchema.extend({ | ||
fullName: z.string(), | ||
avatarUrl: z.string().nullable().optional(), | ||
}) | ||
.nullable() | ||
.default(null), | ||
status: z.enum(AlertStatuses), | ||
decision: z.enum(AlertStates).nullable().default(null), | ||
counterpartyId: z.string().nullable().default(null), | ||
type: z.enum(['business', 'counterparty']), | ||
}), | ||
); | ||
severity: z.enum(AlertSeverities), | ||
correlationId: z.string(), | ||
alertDetails: z.string(), | ||
// amountOfTxs: z.number(), | ||
assignee: ObjectWithIdSchema.extend({ | ||
fullName: z.string(), | ||
avatarUrl: z.string().nullable().optional(), | ||
}) | ||
.nullable() | ||
.default(null), | ||
status: z.enum(AlertStatuses), | ||
decision: z.enum(AlertStates).nullable().default(null), | ||
counterpartyId: z.string().nullable().default(null), | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alert fetching functions are well-implemented, correctly using async/await and error handling. Consider breaking down fetchAlerts
into smaller functions for better maintainability.
export const OngoingMonitoringTable: FunctionComponent<{ | ||
businessReports: TBusinessReport[]; | ||
}> = ({ businessReports }) => { | ||
return ( | ||
<DataTable | ||
data={businessReports} | ||
columns={columns} | ||
props={{ | ||
container: { | ||
className: 'max-w-[411px]', | ||
}, | ||
scroll: { | ||
className: 'h-[47vh]', | ||
}, | ||
}} | ||
options={{ | ||
enableSorting: false, | ||
}} | ||
/> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider memoizing the DataTable
component or its props to prevent unnecessary re-renders, especially if the businessReports
data can be large or complex. Additionally, ensure that accessibility features such as ARIA labels are correctly implemented in the DataTable
component.
User description
Screenshots
Checklist
PR Type
enhancement, tests
Changes walkthrough 📝
58 files
Router.tsx
Add routes for Businesses and Businesses Alerts
apps/backoffice-v2/src/Router/Router.tsx
MultiSelect.tsx
Adjust icon sizes and import order
apps/backoffice-v2/src/common/components/atoms/MultiSelect/MultiSelect.tsx
useNavbarLogic.tsx
Add Ongoing Monitoring link to navbar
apps/backoffice-v2/src/common/components/organisms/Header/hooks/useNavbarLogic/useNavbarLogic.tsx
useFilter.tsx
Add onClear method to clear filters
apps/backoffice-v2/src/common/hooks/useFilter/useFilter.tsx
onClear
method to clear filters.save-base64-as-file.ts
Add utility to save base64 as file
apps/backoffice-v2/src/common/utils/save-base64-as-file/save-base64-as-file.ts
fetchers.ts
Add entityType parameter and refactor alert schemas
apps/backoffice-v2/src/domains/alerts/fetchers.ts
entityType
parameter tofetchAlerts
.get-alerts-search-schema.ts
Add type field to alert search schema
apps/backoffice-v2/src/domains/alerts/helpers/get-alerts-search-schema.ts
type
field to alert search schema.useAlertsQuery.tsx
Add entityType parameter to alerts query
apps/backoffice-v2/src/domains/alerts/hooks/queries/useAlertsQuery/useAlertsQuery.tsx
entityType
parameter to alerts query.fetchers.ts
Add fetchers for business alerts
apps/backoffice-v2/src/domains/business-alerts/fetchers.ts
useAlertsDecisionByIdsMutation.tsx
Add mutation hook for updating alert decisions
apps/backoffice-v2/src/domains/business-alerts/hooks/mutations/useAlertsDecisionByIdsMutation/useAlertsDecisionByIdsMutation.tsx
useAssignAlertsMutation.tsx
Add mutation hook for assigning alerts
apps/backoffice-v2/src/domains/business-alerts/hooks/mutations/useAssignAlertsMutation/useAssignAlertsMutation.tsx
useAlertDefinitionByAlertIdQuery.tsx
Add query hook for fetching alert definition by ID
apps/backoffice-v2/src/domains/business-alerts/hooks/queries/useAlertDefinitionByAlertIdQuery/useAlertDefinitionByAlertIdQuery.tsx
useAlertLabelsQuery.tsx
Add query hook for fetching alert labels
apps/backoffice-v2/src/domains/business-alerts/hooks/queries/useAlertLabelsQuery/useAlertLabelsQuery.tsx
useBusinessAlertsQuery.tsx
Add query hook for fetching business alerts
apps/backoffice-v2/src/domains/business-alerts/hooks/queries/useBusinessAlertsQuery/useBusinessAlertsQuery.tsx
query-keys.ts
Add query keys for business alerts
apps/backoffice-v2/src/domains/business-alerts/query-keys.ts
fetchers.ts
Add fetchers for business reports
apps/backoffice-v2/src/domains/business-reports/fetchers.ts
useGetBusinessReportsQuery.ts
Add query hook for fetching business reports
apps/backoffice-v2/src/domains/business-reports/hooks/queries/useGetBusinessReportsQuery/useGetBusinessReportsQuery.ts
query-keys.ts
Add query keys for business reports
apps/backoffice-v2/src/domains/business-reports/query-keys.ts
Businesses.tsx
Add Businesses page component
apps/backoffice-v2/src/pages/Businesses/Businesses.tsx
BusinessesAlerts.page.tsx
Add Businesses Alerts page component
apps/backoffice-v2/src/pages/BusinessesAlerts/BusinessesAlerts.page.tsx
BusinessAlertsTable.tsx
Add Business Alerts Table component
apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/BusinessAlertsTable.tsx
columns.tsx
Define columns for Business Alerts Table
apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/columns.tsx
useBusinessAlertsTableLogic.tsx
Add logic hook for Business Alerts Table
apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/hooks/useBusinessAlertsTableLogic/useBusinessAlertsTableLogic.tsx
index.ts
Export Business Alerts Table component
apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/index.ts
interfaces.ts
Add interfaces for Business Alerts Table
apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/interfaces.ts
get-severity-from-risk-score.ts
Add utility to get severity from risk score
apps/backoffice-v2/src/pages/BusinessesAlerts/components/BusinessAlertsTable/utils/get-severity-from-risk-score.ts
useBusinessAlertsLogic.tsx
Add logic hook for Business Alerts
apps/backoffice-v2/src/pages/BusinessesAlerts/hooks/useBusinessAlertsLogic/useBusinessAlertsLogic.tsx
BusinessesAlertsAnalysis.page.tsx
Add Businesses Alerts Analysis page component
apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/BusinessesAlertsAnalysis.page.tsx
OngoingMonitoringRiskSheet.tsx
Add Ongoing Monitoring Risk Sheet component
apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/components/OngoingMonitoringRiskSheet/OngoingMonitoringRiskSheet.tsx
index.ts
Export Ongoing Monitoring Risk Sheet component
apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/components/OngoingMonitoringRiskSheet/index.ts
OngoingMonitoringTable.tsx
Add Ongoing Monitoring Table component
apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/components/OngoingMonitoringTable/OngoingMonitoringTable.tsx
columns.tsx
Define columns for Ongoing Monitoring Table
apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/components/OngoingMonitoringTable/columns.tsx
DownloadReportButton.tsx
Add Download Report Button component
apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/components/OngoingMonitoringTable/components/DownloadReportButton/DownloadReportButton.tsx
useDownloadReportButtonLogic.ts
Add logic hook for Download Report Button
apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/components/OngoingMonitoringTable/components/DownloadReportButton/useDownloadReportButtonLogic.ts
index.ts
Export Ongoing Monitoring Table component
apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/components/OngoingMonitoringTable/index.ts
useBusinessAlertsAnalysisLogic.tsx
Add logic hook for Business Alerts Analysis
apps/backoffice-v2/src/pages/BusinessesAlertsAnalysis/hooks/useBusinessAlertsAnalysisLogic/useBusinessAlertsAnalysisLogic.tsx
SignIn.page.tsx
Reorganize imports and add console log
apps/backoffice-v2/src/pages/SignIn/SignIn.page.tsx
TransactionMonitoringAlerts.page.tsx
Reorganize imports and add NoAlerts component
apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/TransactionMonitoringAlerts.page.tsx
AlertsFilters.tsx
Adjust correlationIds mapping for undefined values
apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsFilters/AlertsFilters.tsx
AlertsHeader.tsx
Reorganize imports and adjust alert decision logic
apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsHeader/AlertsHeader.tsx
AlertsTable.tsx
Reorganize imports for AlertsTable component
apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/AlertsTable.tsx
interfaces.ts
Update interface to use TBusinessAlertsList
apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/interfaces.ts
severity-to-class-name.tsx
Add severityToTextClassName mapping
apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/components/AlertsTable/severity-to-class-name.tsx
useTransactionMonitoringAlertsLogic.tsx
Add entityType parameter to alerts query
apps/backoffice-v2/src/pages/TransactionMonitoringAlerts/hooks/useTransactionMonitoringAlertsLogic/useTransactionMonitoringAlertsLogic.tsx
AlertAnalysisSheet.tsx
Reorganize imports for AlertAnalysisSheet component
apps/backoffice-v2/src/pages/TransactionMonitoringAlertsAnalysis/components/AlertAnalysisSheet/AlertAnalysisSheet.tsx
generate-alerts.ts
Reorganize imports and constants
services/workflows-service/scripts/alerts/generate-alerts.ts
seed-business-reports.ts
Add script to seed business reports
services/workflows-service/scripts/business-reports/seed-business-reports.ts
seed.ts
Reorganize imports and add seeding for transactions alerts
services/workflows-service/scripts/seed.ts
alert.controller.external.ts
Reorganize imports for alert controller
services/workflows-service/src/alert/alert.controller.external.ts
alert.service.ts
Reorganize imports and add new methods for alert service
services/workflows-service/src/alert/alert.service.ts
business-report.controller.internal.ts
Reorganize imports for business report controller
services/workflows-service/src/business-report/business-report.controller.internal.ts
business-report.repository.ts
Add findFirst method to business report repository
services/workflows-service/src/business-report/business-report.repository.ts
findFirst
method to business report repository.business-report.service.ts
Add findFirst method to business report service
services/workflows-service/src/business-report/business-report.service.ts
findFirst
method to business report service.business.controller.external.ts
Reorganize imports and adjust authentication guards
services/workflows-service/src/business/business.controller.external.ts
app-logger.service.ts
Reorganize imports for app logger service
services/workflows-service/src/common/app-logger/app-logger.service.ts
data-analytics.service.ts
Reorganize imports for data analytics service
services/workflows-service/src/data-analytics/data-analytics.service.ts
types.ts
Adjust InlineRule type to include alert labels
services/workflows-service/src/data-analytics/types.ts
prisma.service.ts
Add transaction parameter to lock methods
services/workflows-service/src/prisma/prisma.service.ts
1 files
alert.service.intg.test.ts
Add integration tests for ongoing monitoring alerts
services/workflows-service/src/alert/alert.service.intg.test.ts
Summary by CodeRabbit
New Features
MonitoringType
for alerts and extendedAlertDefinition
to includemonitoringType
.businessId
toAlert
for associating alerts with businesses.reportId
andriskScore
added toBusinessReport
table.Bug Fixes
Enhancements
BusinessReportService
with new filtering and pagination capabilities.TransactionService
error handling and logging.Refactor
AlertService
withAlertDefinitionService
in controllers.Documentation
Chores