Deprecate FieldMetadataInterface (#13264)
# Introduction
From the moment replaced the FieldMetadataInterface definition to:
```ts
import { FieldMetadataType } from 'twenty-shared/types';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
export type FieldMetadataInterface<
T extends FieldMetadataType = FieldMetadataType,
> = FieldMetadataEntity<T>;
```
After this PR merge will create a new one removing the type and
replacing it to `FieldMetadataEntity`.
Did not renamed it here to avoid conflicts on naming + type issues fixs
within the same PR
## Field metadata entity RELATION or MORPH
Relations fields cannot be null for those field metadata entity instance
anymore, but are never for the others see
`packages/twenty-server/src/engine/metadata-modules/field-metadata/types/field-metadata-entity-test.type.ts`
( introduced TypeScript tests )
## Concerns
- TS_VECTOR is the most at risk with the `generatedType` and
`asExpression` removal from interface
## What's next
- `FielMetadataInterface` removal and rename ( see introduction )
- Depcrecating `ObjectMetadataInterface`
- Refactor `FieldMetadataEntity` optional fiels to be nullable only
- TO DIG `never` occurences on settings, defaultValue etc
- Some interfaces will be replaced by the `FlatFieldMetadata` when
deprecating the current sync and comparators tools
This commit is contained in:
+9
-1
@@ -195,6 +195,8 @@ export class WorkspaceFieldRelationComparator {
|
||||
throw new Error(`Field ${fieldId} not found in standardObjectMetadata`);
|
||||
}
|
||||
|
||||
const relationFieldMetadata = propertiesMap[fieldId];
|
||||
|
||||
if (relationTypeChange) {
|
||||
result.push({
|
||||
action: ComparatorAction.DELETE,
|
||||
@@ -204,9 +206,11 @@ export class WorkspaceFieldRelationComparator {
|
||||
result.push({
|
||||
action: ComparatorAction.CREATE,
|
||||
object: {
|
||||
...propertiesMap[fieldId],
|
||||
...relationFieldMetadata,
|
||||
id: originalFieldMetadata.id,
|
||||
standardId: standardFieldMetadata.standardId ?? undefined,
|
||||
description: relationFieldMetadata.description ?? undefined,
|
||||
icon: relationFieldMetadata.icon ?? undefined,
|
||||
},
|
||||
});
|
||||
} else if (allOldPropertiesAreNull) {
|
||||
@@ -216,6 +220,8 @@ export class WorkspaceFieldRelationComparator {
|
||||
...propertiesMap[fieldId],
|
||||
id: originalFieldMetadata.id,
|
||||
standardId: standardFieldMetadata.standardId ?? undefined,
|
||||
description: relationFieldMetadata.description ?? undefined,
|
||||
icon: relationFieldMetadata.icon ?? undefined,
|
||||
},
|
||||
});
|
||||
} else if (allNewPropertiesAreNull) {
|
||||
@@ -230,6 +236,8 @@ export class WorkspaceFieldRelationComparator {
|
||||
...propertiesMap[fieldId],
|
||||
id: originalFieldMetadata.id,
|
||||
standardId: standardFieldMetadata.standardId ?? undefined,
|
||||
description: relationFieldMetadata.description ?? undefined,
|
||||
icon: relationFieldMetadata.icon ?? undefined,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
+12
-2
@@ -143,8 +143,8 @@ export class StandardFieldFactory {
|
||||
icon: workspaceFieldMetadataArgs.icon,
|
||||
label: workspaceFieldMetadataArgs.label,
|
||||
description: workspaceFieldMetadataArgs.description,
|
||||
defaultValue: workspaceFieldMetadataArgs.defaultValue,
|
||||
options: workspaceFieldMetadataArgs.options,
|
||||
defaultValue: workspaceFieldMetadataArgs.defaultValue ?? null,
|
||||
options: workspaceFieldMetadataArgs.options ?? null,
|
||||
settings: workspaceFieldMetadataArgs.settings,
|
||||
workspaceId: context.workspaceId,
|
||||
isNullable: workspaceFieldMetadataArgs.isNullable,
|
||||
@@ -155,6 +155,10 @@ export class StandardFieldFactory {
|
||||
asExpression: workspaceFieldMetadataArgs.asExpression,
|
||||
generatedType: workspaceFieldMetadataArgs.generatedType,
|
||||
isLabelSyncedWithName: workspaceFieldMetadataArgs.isLabelSyncedWithName,
|
||||
relationTargetFieldMetadata: null,
|
||||
relationTargetFieldMetadataId: null,
|
||||
relationTargetObjectMetadata: null,
|
||||
relationTargetObjectMetadataId: null,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -195,6 +199,12 @@ export class StandardFieldFactory {
|
||||
isActive: workspaceRelationMetadataArgs.isActive ?? true,
|
||||
isLabelSyncedWithName:
|
||||
workspaceRelationMetadataArgs.isLabelSyncedWithName,
|
||||
defaultValue: null,
|
||||
options: null,
|
||||
relationTargetFieldMetadata: null,
|
||||
relationTargetFieldMetadataId: null,
|
||||
relationTargetObjectMetadata: null,
|
||||
relationTargetObjectMetadataId: null,
|
||||
});
|
||||
|
||||
return fieldMetadataCollection;
|
||||
|
||||
+12
-2
@@ -5,6 +5,7 @@ import { WorkspaceDynamicRelationMetadataArgsFactory } from 'src/engine/twenty-o
|
||||
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
|
||||
// Should get deprecated in favor of the FlatFieldMetadata
|
||||
export type PartialFieldMetadata<
|
||||
T extends FieldMetadataType = FieldMetadataType,
|
||||
> = Omit<
|
||||
@@ -15,6 +16,15 @@ export type PartialFieldMetadata<
|
||||
| 'objectMetadataId'
|
||||
| 'createdAt'
|
||||
| 'updatedAt'
|
||||
| 'standardId'
|
||||
| 'icon'
|
||||
| 'isSystem'
|
||||
| 'workspaceId'
|
||||
| 'isActive'
|
||||
| 'asExpression'
|
||||
| 'indexFieldMetadatas'
|
||||
| 'fieldPermissions'
|
||||
| 'object'
|
||||
> & {
|
||||
standardId: string;
|
||||
label: string | ((objectMetadata: ObjectMetadataEntity) => string);
|
||||
@@ -24,8 +34,8 @@ export type PartialFieldMetadata<
|
||||
workspaceId: string;
|
||||
objectMetadataId?: string;
|
||||
isActive?: boolean;
|
||||
asExpression?: string;
|
||||
generatedType?: 'STORED' | 'VIRTUAL';
|
||||
asExpression?: string; // not accurate
|
||||
generatedType?: 'STORED' | 'VIRTUAL'; // not accurate
|
||||
};
|
||||
|
||||
export type PartialComputedFieldMetadata = {
|
||||
|
||||
+6
@@ -48,6 +48,12 @@ export const computeStandardFields = (
|
||||
defaultValue: null,
|
||||
isNullable: true,
|
||||
isLabelSyncedWithName: true,
|
||||
isUnique: null,
|
||||
options: null,
|
||||
relationTargetFieldMetadata: null,
|
||||
relationTargetFieldMetadataId: null,
|
||||
relationTargetObjectMetadata: null,
|
||||
relationTargetObjectMetadataId: null,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user