Skip to content
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 1620 schema changes from branch #2180

Closed
wants to merge 14 commits into from

Conversation

liorzam
Copy link
Collaborator

@liorzam liorzam commented Mar 10, 2024

No description provided.

…grations submodule to 'all' for consistency

chore(workflows-service): update data-migrations submodule to latest commit e2be2ce2e82641da25de172577c6835678dd2182
…configurable IDs

feat(alerts): add support for generating fake alert definitions with configurable severity and IDs
feat(alerts): add support for generating fake alert definitions with configurable execution details
feat(alerts): add support for generating fake transactions with configurable business and end user IDs
fix(schema.prisma): remove unique constraint on correlationId in EndUser and Business models
fix(schema.prisma): remove unique constraint on transactionCorrelationId in TransactionRecord model
fix(schema.prisma): remove unnecessary CounterpartyType enum
fix(migration.sql): remove unique constraint on correlationId in TransactionRecord model
fix(migration.sql): add unique index on projectId and correlationId in Business model
fix(migration.sql): add unique index on projectId and correlationId in EndUser model
fix(migration.sql): remove unnecessary Counterparty type and column in Counterparty model

feat(end-user): add support for creating end users with associated business

- Added `correlationId` field to the `generateBusiness` function in the `generate-end-user.ts` script to generate a correlation ID for each business.
- Modified the `generateBusiness` function in the `generate-end-user.ts` script to include the `correlationId` parameter in the function signature and assign it to the `correlationId` field of the generated business.
- Modified the `generateEndUser` function in the `generate-end-user.ts` script to include the `correlationId` parameter in the function signature and assign it to the `correlationId` field of the generated end user.
- Modified the `generateEndUser` function in the `generate-end-user.ts` script to make the `workflow` parameter optional.
- Modified the `generateEndUser` function in the `generate-end-user.ts` script to check if `workflowDefinitionId` is present before creating `workflowRuntimeData`.
- Modified the `seed` function in the `seed.ts` script to create two additional end users with associated transactions.
- Created a new file `end-user-create-with-business.ts` in the `end-user/dtos` directory to define the `EndUserCreateWithBusinessDto` class, which extends the `EndUserCreateDto` class and includes the `companyName` field.
- Modified the `EndUserControllerExternal` class in the `end-user.controller.external.ts` file to import and use the `EndUserCreateWithBusinessDto` class for the `createWithBusiness` endpoint.
- Removed the `findByCorrelationIdUnscoped` method from the `EndUserRepository` class in the `end-user.repository.ts` file as it is no longer used.
- Modified the `EndUserService` class in the `end-user.service.ts` file to remove the `correlationId` field from the `endUser` parameter in the `createWithBusiness` method.
…ests for TransactionControllerExternal

This commit adds integration tests for the TransactionControllerExternal in the transaction module. The tests cover the following scenarios:

1. Creating a transaction with a business originator and an end user beneficiary.
2. Creating a transaction and reusing an existing business as the originator and an existing end user as the beneficiary.
3. Returning a 400 status code when validation fails.

The tests use the supertest library to send HTTP requests to the server and assert the responses. The tests also use the faker-js library to generate random data for the transactions.

The tests are organized into the following sections:
1. Setup: This section sets up the necessary dependencies and initializes the Nest application.
2. POST /: This section tests the creation of a single transaction.
3. POST /bulk: This section tests the creation of multiple transactions.

The tests assert the status code and the response body of the HTTP requests. They also assert the data stored in the database after the transactions are created.
… name

fix(data-analytics.service.intg.test.ts): remove unused import and CounterpartyType usage
fix(end-user-create.ts): remove unused properties and add required decorator to 'correlationId' property
feat(bulk-transactions-created.dto.ts): create new file for BulkTransactionsCreatedDto class
fix(get-transactions.dto.ts): remove unused 'businessId' property
fix(transaction-create.dto.ts): change 'date' property type to string and remove unused properties
feat(transaction-created.dto.ts): create new file for TransactionCreatedDto class

fix(transaction.controller.external.ts): fix import statements to improve readability and maintainability
feat(transaction.controller.external.ts): add validation pipe to validate request body in create method
feat(transaction.controller.external.ts): add support for bulk transaction creation in createBulk method
feat(transaction.controller.external.ts): handle creation responses and return appropriate status codes and response bodies in create and createBulk methods
refactor(transaction.controller.external.ts): remove unnecessary include in getTransactions method

feat(transaction): refactor transaction.mapper.ts to improve code readability and maintainability
fix(transaction.repository): remove unused code and simplify create method

feat(transaction.service.ts): add support for bulk transaction creation

- Add `createBulk` method to `TransactionService` to handle bulk creation of transactions.
- Update `create` method to use `TransactionEntityMapper` to map payload to entity.
- Remove unused imports and variables.

fix(transaction.service.ts): fix typo in import statement

- Fix typo in import statement for `TransactionCreatedDto`.

refactor(transaction.service.ts): improve error handling in bulk transaction creation

- Update `createBulk` method to handle errors during transaction creation.
- Return an array of `TransactionCreatedDto` or an object with `error` and `correlationId` properties for each transaction.

refactor(transaction.service.ts): remove unused import and file

- Remove unused import for `TProjectId`.
- Remove unused file `create-transaction.validator.ts`.
- Generate transactions for a project using the `generateTransactions` function.
- Create counterparties and collect their IDs.
- For each counterparty, create a counterparty record with a correlation ID and connect it to the project.
- For each counterparty, create a business or end user record with a correlation ID and connect it to the counterparty.
- Update the number of iterations for creating counterparty records from 200 to 100.
- Update the number of iterations for generating transactions from 4 to 2.
- Update the `generateFakeAlertDefinitions` function to use the counterparty originator IDs from the generated transactions.

feat(seed): remove unnecessary business and end user creation

- Remove the creation of unnecessary business and end user records in the `seed` function.
…seTransactionsQuery

The `businessId` field was removed from the `fetchers.ts` file in the `TransactionsListSchema` and `fetchTransactions` functions. This field was not being used and was causing unnecessary complexity.

In addition, the `businessId` field was also removed from the `useTransactionsQuery` function in the `useTransactionsQuery.tsx` file. This field was not being used and was unnecessary for the functionality of the query.

These changes were made to simplify the code and remove unused variables.
…esponse

fix(alert.controller.external.ts): fix import statement for express
fix(alert.controller.external.ts): fix import statement for @nestjs/common Res decorator
fix(alert.controller.external.ts): fix import statement for @nestjs/common
fix(alert.controller.external.ts): fix import statement for @nestjs/common UseGuards decorator
fix(alert.controller.external.ts): fix import statement for @nestjs/swagger ApiBearerAuth decorator
fix(alert.controller.external.ts): fix import statement for @nestjs/swagger ApiTags decorator
fix(alert.controller.external.ts): fix import statement for @nestjs/swagger ApiOkResponse decorator
fix(alert.controller.external.ts): fix import statement for @nestjs/swagger ApiResponse decorator
fix(alert.controller.external.ts): fix import statement for @nestjs/swagger ApiNotFoundResponse decorator
fix(alert.controller.external.ts): fix import statement for @nestjs/swagger ApiForbiddenResponse decorator
fix(alert.controller.external.ts): fix import statement for @prisma/client Alert and AlertDefinition types
fix(alert.controller.external.ts): fix import statement for ../errors NotFoundException and ForbiddenException types
fix(alert.controller.external.ts): fix import statement for ./dtos/assign-alert.dto AlertAssigneeUniqueDto and AlertUpdateResponse types
fix(alert.controller.external.ts): fix import statement for ./dtos/create-alert-definition.dto CreateAlertDefinitionDto type
fix(alert.controller.external.ts): fix import statement for ./dtos/get-alerts.dto FindAlertsDto and FindAlertsSchema types
fix(alert.controller.external.ts): fix import statement for ./types BulkStatus, TBulkAssignAlertsResponse, and TAlertResponse types
fix(assign-alert.dto.ts): fix import statement for class-validator IsEnum decorator
fix(assign-alert.dto.ts): fix import statement for class-validator IsArray decorator
fix(assign-alert.dto.ts): fix import statement for class-validator IsString decorator
fix(assign-alert.dto.ts): fix import statement for class-validator MinLength decorator
fix(assign-alert.dto.ts): fix import statement for class-validator ArrayMinSize decorator
fix(assign-alert.dto.ts): fix import statement for ../types BulkStatus type
fix(assign-alert.dto.ts): fix import statement for @nestjs/swagger ApiProperty decorator
fix(assign-alert.dto.ts): fix import statement for @nestjs/common IsNullable decorator
fix(assign-alert.dto.ts): fix import statement for @nestjs/common Type decorator
fix(assign-alert.dto.ts): fix import statement for @nestjs/common Type decorator
fix(assign-alert.dto.ts): fix import statement for @nestjs/common Type

fix(sentry.interceptor.ts): refactor SentryInterceptor to use SentryService for capturing exceptions and http exceptions
feat(sentry.service.ts): create SentryService to handle capturing exceptions and http exceptions with additional data
fix(bulk-transactions-created.dto.ts): add optional error field to BulkTransactionsCreatedDto
fix(transaction-create.dto.ts): make originator and beneficiary fields required in TransactionCreateDto
fix(transaction-created.dto.ts): make id field optional in TransactionCreatedDto

fix(transaction.controller.external.intg.test.ts): remove unused import of TransactionRepository
feat(transaction.controller.external.intg.test.ts): refactor test cases to use constants for bulk status and improve readability
fix(transaction.controller.external.intg.test.ts): fix validation test case to use valid transaction data for all transactions

fix(transaction.controller.external.ts): import missing BulkStatus and errors modules to resolve compilation errors
feat(transaction.controller.external.ts): add additional swagger annotations for createBulk endpoint to provide more accurate documentation
fix(transaction.mapper.ts): throw HttpException instead of Error when counterparty has both business and end user data
feat(transaction.module.ts): add SentryService as a provider to TransactionModule for error tracking
feat(transaction.service.ts): add SentryService as a dependency to TransactionService for error tracking and capture specific errors with additional logging
Copy link

changeset-bot bot commented Mar 10, 2024

⚠️ No Changeset found

Latest commit: 907b7da

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot force-pushed the bal-1620-schema-changes-from-branch branch from d5242cf to f943db2 Compare March 10, 2024 23:13
@liorzam liorzam changed the base branch from dev to bal-1420 March 10, 2024 23:13
… model

refactor(alert.controller.external.ts): update the select statement to include counterparty and endUser details
refactor(alert.service.ts): remove businessId and endUserId from the createAlert method parameters
refactor(transaction.controller.external.ts): remove the businessId query parameter and update the select statement to include counterpartyBeneficiary and counterpartyOriginator details
… 'Business' models to improve code clarity and maintainability

refactor(alert.controller.external.ts): update the selection of fields in the 'counterparty' object to include 'business' and 'endUser' fields for better data retrieval

refactor(alert.service.ts): remove unnecessary fields 'businessId' and 'endUserId' from the 'data' parameter in the 'createAlert' method to simplify the code

refactor(transaction.controller.external.ts): remove unused 'businessId' query parameter from the 'getTransactions' method to improve code clarity and maintainability. Update the selection of fields in the 'counterpartyBeneficiary' and 'counterpartyOriginator' objects to include 'business' and 'endUser' fields for better data retrieval
…dels to simplify the schema and remove unnecessary relationships

refactor(alert.controller.external.ts): update the select statement in the getAlerts method to include counterparty and endUser information for better data retrieval

refactor(alert.service.ts): remove businessId and endUserId from the createAlert method parameters since they are not needed

refactor(transaction.controller.external.ts): remove the businessId query parameter from the getTransactions method since it is not used

refactor(transaction.controller.external.ts): update the select statement in the getTransactions method to include counterpartyBeneficiary and counterpartyOriginator information for better data retrieval
…rcase PORT

The port variable in the server.ts file was changed from lowercase "port" to uppercase "PORT". This change was made to improve the semantics of the code and make it more readable.

feat(server.ts): Add support for process.env.PORT environment variable

In the server.ts file, support for the process.env.PORT environment variable was added. This allows the application to be run on a configurable port specified by the environment variable. This change was made to provide flexibility in running the application on different ports based on the deployment environment.
…dels to simplify the schema and remove unnecessary relationships

refactor(alert.controller.external.ts): update the select statement in the getAlerts method to include counterparty and endUser information for better data retrieval

refactor(alert.service.ts): remove businessId and endUserId from the createAlert method since they are no longer needed

refactor(transaction.controller.external.ts): remove the businessId query parameter from the getTransactions method since it is no longer used. Update the select statement to include counterpartyBeneficiary and counterpartyOriginator information for better data retrieval
…ry integration for error tracking in the alert module

feat(transaction.module.ts): add SentryModule to the imports to enable Sentry integration for error tracking in the transaction module
…dels to simplify the schema and remove unnecessary relationships

refactor(alert.controller.external.ts): update the select statement in the getAlerts method to include counterparty and endUser information for better data retrieval

refactor(alert.service.ts): remove businessId and endUserId from the createAlert method parameters since they are not needed

refactor(transaction.controller.external.ts): remove the businessId query parameter from the getTransactions method since it is not used

refactor(transaction.controller.external.ts): update the select statement in the getTransactions method to include counterpartyBeneficiary and counterpartyOriginator information for better data retrieval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants