feat: rename tenant into workspace (#2553)
* feat: rename tenant into workspace * fix: missing some files and reset not working * fix: wrong import * Use link in company seeds * Use link in company seeds --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
23
server/src/workspace/utils/deduce-relation-direction.util.ts
Normal file
23
server/src/workspace/utils/deduce-relation-direction.util.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { RelationMetadataInterface } from 'src/workspace/workspace-schema-builder/interfaces/relation-metadata.interface';
|
||||
|
||||
export enum RelationDirection {
|
||||
FROM = 'from',
|
||||
TO = 'to',
|
||||
}
|
||||
|
||||
export const deduceRelationDirection = (
|
||||
currentObjectId: string,
|
||||
relationMetadata: RelationMetadataInterface,
|
||||
): RelationDirection => {
|
||||
if (relationMetadata.fromObjectMetadataId === currentObjectId) {
|
||||
return RelationDirection.FROM;
|
||||
}
|
||||
|
||||
if (relationMetadata.toObjectMetadataId === currentObjectId) {
|
||||
return RelationDirection.TO;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Relation metadata ${relationMetadata.id} is not related to object ${currentObjectId}`,
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user