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:
@ -71,7 +71,7 @@ describe.each(fieldMetadataEnumTypes)(
|
||||
expect(data.createOneField.type).toEqual(testedFieldMetadataType);
|
||||
|
||||
const createdOptions = data.createOneField.options;
|
||||
const optionsToCompare = expectedOptions ?? input.options;
|
||||
const optionsToCompare = expectedOptions ?? input.options ?? [];
|
||||
|
||||
expect(errors).toBeUndefined();
|
||||
expect(createdOptions?.length).toBe(optionsToCompare.length);
|
||||
|
||||
@ -168,12 +168,19 @@ describe.each(fieldMetadataEnumTypes)(
|
||||
expect(data.updateOneField).toBeDefined();
|
||||
const updatedOptions:
|
||||
| FieldMetadataComplexOption[]
|
||||
| FieldMetadataDefaultOption[] = data.updateOneField.options;
|
||||
| FieldMetadataDefaultOption[]
|
||||
| null = data.updateOneField.options;
|
||||
|
||||
expect(updatedOptions).toBeDefined();
|
||||
if (!isDefined(updatedOptions))
|
||||
throw new Error(
|
||||
'Should never occur, type invariant post test assertion',
|
||||
);
|
||||
|
||||
expect(errors).toBeUndefined();
|
||||
updatedOptions.forEach((option) => expect(option.id).toBeDefined());
|
||||
|
||||
const optionsToCompare = expectedOptions ?? input.options;
|
||||
const optionsToCompare = expectedOptions ?? input.options ?? [];
|
||||
|
||||
expect(updatedOptions.length).toBe(optionsToCompare.length);
|
||||
expect(updatedOptions).toMatchObject(optionsToCompare);
|
||||
|
||||
Reference in New Issue
Block a user