47b60bd49f
# 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
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
import {
|
|
CreateOneFieldFactoryInput,
|
|
createOneFieldMetadataQueryFactory,
|
|
} from 'test/integration/metadata/suites/field-metadata/utils/create-one-field-metadata-query-factory.util';
|
|
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
|
|
import { CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
|
|
import { PerformMetadataQueryParams } from 'test/integration/metadata/types/perform-metadata-query.type';
|
|
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
|
|
import { FieldMetadataType } from 'twenty-shared/types';
|
|
|
|
import { FieldMetadataDTO } from 'src/engine/metadata-modules/field-metadata/dtos/field-metadata.dto';
|
|
|
|
export const createOneFieldMetadata = async <T extends FieldMetadataType>({
|
|
input,
|
|
gqlFields,
|
|
expectToFail = false,
|
|
}: PerformMetadataQueryParams<CreateOneFieldFactoryInput>): CommonResponseBody<{
|
|
createOneField: FieldMetadataDTO<T>;
|
|
}> => {
|
|
const graphqlOperation = createOneFieldMetadataQueryFactory({
|
|
input,
|
|
gqlFields,
|
|
});
|
|
|
|
const response = await makeMetadataAPIRequest(graphqlOperation);
|
|
|
|
if (expectToFail) {
|
|
warnIfNoErrorButExpectedToFail({
|
|
response,
|
|
errorMessage: 'Field Metadata creation should have failed but did not',
|
|
});
|
|
}
|
|
|
|
return { data: response.body.data, errors: response.body.errors };
|
|
};
|