Conversation
String entity names bypass type inference and silently break when an entity is renamed or not registered. The entity classes are created by the application (or by a factory inside the module), so they are now provided via DI tokens (`DAM_FILE_ENTITY`, `DAM_FOLDER_ENTITY`, `REDIRECT_ENTITY`, `PAGE_TREE_NODE_ENTITY` and the `BREVO_*_ENTITY` tokens) and injected where needed. Resolver factories use the entity classes they already receive. The string-based `MikroOrmModule.forFeature` registrations in brevo-api are replaced with classes or removed, since strings only registered repository providers that are no longer used. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016mE6dC24agzeytj4aohiLy
Relations referencing an entity by name break silently when the entity is renamed or not registered, and the name has to be kept in sync with the application's class. The relations now reference the entity classes: - Self-references in the file and folder factories use the class created by the factory. - Relations of entities created before the entity they reference are defined by the factory of the referenced entity: createFileEntity defines Folder.files, DamFileImage.file and the DamMediaAlternative relations, createEmailCampaignEntity defines TargetGroup.campaigns. - The PageTreeNodeFullText view entity is created by PageTreeModule. - The page tree node entity is created by the new createPageTreeNodeEntity factory, since PageTreeNodeBase can't reference the application's entity for the parent relation. The database schema and the GraphQL schema stay unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016mE6dC24agzeytj4aohiLy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016mE6dC24agzeytj4aohiLy
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Entity creation in the codebase was using conditional logic at the module level to create different entity classes based on configuration (e.g., with or without scope). This pattern made it difficult to:
Solution
Refactor entity creation to use factory functions that encapsulate the conditional logic and return the concrete entity class. This allows:
createFileEntity,createFolderEntity,createPageTreeNodeEntity, andcreatePageTreeNodeFullTextEntityKey changes:
createConcreteFileEntity(), moved relation definitions to after entity creation using the returnedDamFileclasscreateConcreteFolderEntity(), removed@OneToManydecorator for files relation (now defined in file entity)createPageTreeNodeEntity()factory function that handles scope and category configurationcreatePageTreeNodeFullTextEntity()factory function to acceptPageTreeNodeas a parameterentityManager.find/findOneOrFail/findAndCountcalls to use entity class references instead of string namesThis is a major breaking change for applications that directly extend
PageTreeNodeBase— they must now usecreatePageTreeNodeEntity()instead.Changeset
See
.changeset/cms-api-create-page-tree-node-entity.mdfor migration guide details.https://claude.ai/code/session_016mE6dC24agzeytj4aohiLy