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

fix mappings from prisma models to domain objects accross the codebase #780

Conversation

ognjenkurtic
Copy link
Collaborator

Description

Apply the previously approved POC for mapping of prisma models to domain objects across the codebase.
PR review hint: Go through commits one by one from oldest.

Related Issue

#740

Motivation and Context

Fixes broken mapping that was present previously

How Has This Been Tested

Ran all unit tests
Ran e2e test locally
Executed random endpoints via Postman manually

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Request to be added as a Code Owner/Maintainer

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • [] I have added tests to cover my changes.
  • All new and existing tests passed.
  • I commit to abide by the Responsibilities of Code Owners/Maintainers.

export class PrismaMapper {
constructor(private readonly merkleTreeService: MerkleTreeService) {}

public mapBpiSubjectPrismaModelToDomainObject(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im a bit rusty with typescript, but can these be like generic method, and then only define these verbose methods if there is something more tricky than simple assign? generic like this (this is also ugly, but just as illustration):

public map<T extends object>(source: any, targetType: IConstructor<T>): T {
    const target = this.activator(targetType)
    Object.assign(target, source);
    return target;
  }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, spent some time during POC trying to implement the generic method but got stuck with some dumb issue and decided to leave it for later. Applied now everywhere based on your proposal, please rereview. We can improve as we go. @skosito

@ognjenkurtic ognjenkurtic requested a review from skosito January 20, 2024 21:54
Copy link
Collaborator

@Therecanbeonlyone1969 Therecanbeonlyone1969 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ognjenkurtic ognjenkurtic merged commit dce2003 into main Jan 24, 2024
1 of 2 checks passed
@ognjenkurtic ognjenkurtic deleted the feature/740-fix-mappings-from-prisma-models-to-domain-objects-full-codebase branch January 24, 2024 20:28
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