Remove some dead code (#6611)
We could remove a lot more than this, this is just a start. There are various tools to help with this, knip is a good one
This commit is contained in:
@ -1,38 +0,0 @@
|
||||
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
||||
import { RelationDirections } from '@/object-record/record-field/types/FieldDefinition';
|
||||
import {
|
||||
FieldMetadataType,
|
||||
RelationDefinitionType,
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
export const getFieldRelationDirections = (
|
||||
field: Pick<FieldMetadataItem, 'type' | 'relationDefinition'> | undefined,
|
||||
): RelationDirections => {
|
||||
if (!field || field.type !== FieldMetadataType.Relation) {
|
||||
throw new Error(`Field is not a relation field.`);
|
||||
}
|
||||
|
||||
switch (field.relationDefinition?.direction) {
|
||||
case RelationDefinitionType.ManyToMany:
|
||||
throw new Error(`Many to many relations are not supported.`);
|
||||
case RelationDefinitionType.OneToMany:
|
||||
return {
|
||||
from: 'FROM_ONE_OBJECT',
|
||||
to: 'TO_MANY_OBJECTS',
|
||||
};
|
||||
case RelationDefinitionType.ManyToOne:
|
||||
return {
|
||||
from: 'FROM_MANY_OBJECTS',
|
||||
to: 'TO_ONE_OBJECT',
|
||||
};
|
||||
case RelationDefinitionType.OneToOne:
|
||||
return {
|
||||
from: 'FROM_ONE_OBJECT',
|
||||
to: 'TO_ONE_OBJECT',
|
||||
};
|
||||
default:
|
||||
throw new Error(
|
||||
`Invalid relation definition type direction : ${field.relationDefinition?.direction}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user