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:
+30
-14
@@ -2,17 +2,30 @@ import { FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
import { RelationType } from 'src/engine/metadata-modules/field-metadata/interfaces/relation-type.interface';
|
||||
|
||||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { IndexMetadataEntity } from 'src/engine/metadata-modules/index-metadata/index-metadata.entity';
|
||||
import { createIndexMigration } from 'src/engine/workspace-manager/workspace-migration-builder/factories/utils/workspace-migration-index.factory.utils';
|
||||
import { getMockFieldMetadataEntity } from 'src/utils/__test__/get-field-metadata-entity.mock';
|
||||
|
||||
describe('WorkspaceMigrationIndexFactory', () => {
|
||||
it('should create index migrations for simple fields', async () => {
|
||||
const simpleField = getMockFieldMetadataEntity({
|
||||
workspaceId: '20202020-0000-0000-0000-000000000000',
|
||||
objectMetadataId: '20202020-0000-0000-0000-000000000001',
|
||||
id: 'f1',
|
||||
type: FieldMetadataType.TEXT,
|
||||
name: 'simpleField',
|
||||
label: 'Simple Field',
|
||||
isNullable: true,
|
||||
isLabelSyncedWithName: true,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
});
|
||||
|
||||
const objectMetadata = {
|
||||
id: 'obj1',
|
||||
workspaceId: 'ws1',
|
||||
id: '20202020-0000-0000-0000-000000000002',
|
||||
workspaceId: '20202020-0000-0000-0000-000000000000',
|
||||
nameSingular: 'Test',
|
||||
fields: [{ id: 'f1', name: 'simpleField', type: FieldMetadataType.TEXT }],
|
||||
fields: [simpleField],
|
||||
isCustom: false,
|
||||
};
|
||||
const indexMetadata = {
|
||||
@@ -39,25 +52,28 @@ describe('WorkspaceMigrationIndexFactory', () => {
|
||||
});
|
||||
|
||||
it('should create index migrations for relation fields', async () => {
|
||||
const fieldMetadata: Pick<
|
||||
FieldMetadataEntity<FieldMetadataType.RELATION>,
|
||||
'id' | 'name' | 'type' | 'settings' | 'isCustom'
|
||||
> = {
|
||||
const relationField = getMockFieldMetadataEntity({
|
||||
workspaceId: '20202020-0000-0000-0000-000000000000',
|
||||
objectMetadataId: '20202020-0000-0000-0000-000000000001',
|
||||
id: 'f2',
|
||||
name: 'author',
|
||||
type: FieldMetadataType.RELATION,
|
||||
name: 'author',
|
||||
label: 'Author',
|
||||
isNullable: true,
|
||||
isLabelSyncedWithName: true,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
settings: {
|
||||
relationType: RelationType.MANY_TO_ONE,
|
||||
joinColumnName: 'authorId',
|
||||
},
|
||||
isCustom: false,
|
||||
};
|
||||
});
|
||||
|
||||
const objectMetadata = {
|
||||
id: 'obj2',
|
||||
workspaceId: 'ws1',
|
||||
id: '20202020-0000-0000-0000-000000000003',
|
||||
workspaceId: '20202020-0000-0000-0000-000000000000',
|
||||
nameSingular: 'Attachment',
|
||||
fields: [fieldMetadata],
|
||||
fields: [relationField],
|
||||
isCustom: false,
|
||||
};
|
||||
const indexMetadata = {
|
||||
|
||||
Reference in New Issue
Block a user