Skip to content

Commit

Permalink
add neo4j validations
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Nov 23, 2023
1 parent 5e2a97c commit fe06a25
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions generators/spring-data-neo4j/generator.mts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,40 @@ export default class Neo4jGenerator extends BaseApplicationGenerator {
return this.delegateTasksToBlueprint(() => this.preparing);
}

get configuringEachEntity() {
return this.asConfiguringEachEntityTaskGroup({
async configuringEachEntity({ entityConfig }) {
if (entityConfig.dto && entityConfig.dto !== 'no') {
this.log.warn(
`The DTO option is not supported for Neo4j database. Neo4j persists the entire constelation, DTO causes the constelation to be incomplete. DTO is found in entity ${entityConfig.name}.`,
);
}
},
});
}

get [BaseApplicationGenerator.CONFIGURING_EACH_ENTITY]() {
return this.delegateTasksToBlueprint(() => this.configuringEachEntity);
}

get default() {
return this.asDefaultTaskGroup({
async checkUserRelationship({ entities }) {
entities.forEach(entity => {
if (entity.relationships.some(relationship => relationship.builtInUser)) {
this.log.warn(
`Relationship with User entity should be avoided for Neo4j database. Neo4j persists the entire constelation, related User entity will be updated causing security problems. Relationship with User entity is found in entity ${entity.name}.`,
);
}
});
},
});
}

get [BaseApplicationGenerator.DEFAULT]() {
return this.delegateTasksToBlueprint(() => this.default);
}

get writing() {
return this.asWritingTaskGroup({
cleanupTask,
Expand Down

0 comments on commit fe06a25

Please sign in to comment.