Refactor backend folder structure (#4505)
* Refactor backend folder structure Co-authored-by: Charles Bochet <charles@twenty.com> * fix tests * fix * move yoga hooks --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -0,0 +1,30 @@
|
||||
import { FieldMetadataInterface } from 'src/engine-metadata/field-metadata/interfaces/field-metadata.interface';
|
||||
import { RelationMetadataInterface } from 'src/engine-metadata/field-metadata/interfaces/relation-metadata.interface';
|
||||
|
||||
export enum RelationDirection {
|
||||
FROM = 'from',
|
||||
TO = 'to',
|
||||
}
|
||||
|
||||
export const deduceRelationDirection = (
|
||||
fieldMetadata: FieldMetadataInterface,
|
||||
relationMetadata: RelationMetadataInterface,
|
||||
): RelationDirection => {
|
||||
if (
|
||||
relationMetadata.fromObjectMetadataId === fieldMetadata.objectMetadataId &&
|
||||
relationMetadata.fromFieldMetadataId === fieldMetadata.id
|
||||
) {
|
||||
return RelationDirection.FROM;
|
||||
}
|
||||
|
||||
if (
|
||||
relationMetadata.toObjectMetadataId === fieldMetadata.objectMetadataId &&
|
||||
relationMetadata.toFieldMetadataId === fieldMetadata.id
|
||||
) {
|
||||
return RelationDirection.TO;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Relation metadata ${relationMetadata.id} is not related to object ${fieldMetadata.objectMetadataId}`,
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user