Improve FieldMetadataEntity defaultValue, settings and options typing (#13320)

# Introduction
Following https://github.com/twentyhq/twenty/pull/13264, this PR
introduces several `fieldMetadataEntity` typing enhancement suggestions.

Mainly any nullable field metadata entity properties are now either
nullable or defined.
Or never if field is dynamically required or not depending on the field
metadata type

This enhance DevX

## Standards

- field enum ( `MULTI_SELECT`, `SELECT`, `RATING` ) will never have
`options` set to `NULL` in db
- field `RELATION` or `MORH_RELATION` won't ever have its relation
fields set to `NULL` in db
- field of any type `settings`, even if possibly defined, can still be
`NULL` in db
- field of any type `defaultValue`, even if possibly defined, can still
be `NULL` in db

It coud be interesting to guard these standards by adding dedicated pg
constraints on each field

## TypesScript type tests
added coverage for each `settings`, `defaultValue`, and `options`
depending on the current `fieldMetadata`
Honestly I don' know if this typescript assertions test file is not
overkill, but regarding metadata staticness it might be very interesting
to have this guard

## Possible improvements
- We could type as `unknown` instead of "all" on `FieldMetadataType`
inferrance
- We still need to deprecate remaining duplicated entities such as
`Index/Field/MetadataInterface` etc not a huge refactor neither urgent
This commit is contained in:
Paul Rastoin
2025-07-23 13:43:27 +02:00
committed by GitHub
parent 602e446337
commit a0a575fa0b
36 changed files with 611 additions and 214 deletions
@@ -6,19 +6,16 @@ import { FlatFieldMetadata } from 'src/engine/workspace-manager/workspace-migrat
type FlatFieldMetadataOverrides<
T extends FieldMetadataType = FieldMetadataType,
> = Required<
Pick<FlatFieldMetadata<T>, 'uniqueIdentifier' | 'objectMetadataId'>
Pick<FlatFieldMetadata<T>, 'uniqueIdentifier' | 'objectMetadataId' | 'type'>
> &
Partial<FlatFieldMetadata<T>>;
export const getFlatFieldMetadataMock = <
T extends FieldMetadataType = FieldMetadataType.TEXT,
>(
export const getFlatFieldMetadataMock = <T extends FieldMetadataType>(
overrides: FlatFieldMetadataOverrides<T>,
): FlatFieldMetadata<T> => {
): FlatFieldMetadata => {
const createdAt = faker.date.anytime();
return {
type: FieldMetadataType.TEXT as T,
createdAt,
description: 'default flat field metadata description',
icon: 'icon',
@@ -32,7 +29,8 @@ export const getFlatFieldMetadataMock = <
isLabelSyncedWithName: false,
isSystem: false,
standardId: null,
standardOverrides: undefined,
standardOverrides: null,
settings: null,
updatedAt: createdAt,
workspaceId: faker.string.uuid(),
defaultValue: null,
@@ -25,8 +25,9 @@ exports[`Workspace migration builder field actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field-metadata-unique-identifier-1",
"updatedAt": Any<ClockDate>,
@@ -58,8 +59,9 @@ exports[`Workspace migration builder field actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_0",
"updatedAt": Any<ClockDate>,
@@ -85,8 +87,9 @@ exports[`Workspace migration builder field actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_1",
"updatedAt": Any<ClockDate>,
@@ -112,8 +115,9 @@ exports[`Workspace migration builder field actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_2",
"updatedAt": Any<ClockDate>,
@@ -139,8 +143,9 @@ exports[`Workspace migration builder field actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_3",
"updatedAt": Any<ClockDate>,
@@ -166,8 +171,9 @@ exports[`Workspace migration builder field actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_4",
"updatedAt": Any<ClockDate>,
@@ -226,8 +232,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field-metadata-unique-identifier-1",
"updatedAt": Any<ClockDate>,
@@ -259,8 +266,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field-metadata-unique-identifier-1",
"updatedAt": Any<ClockDate>,
@@ -319,8 +327,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": Any<String>,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": Any<String>,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "RELATION",
"uniqueIdentifier": "field-metadata-unique-identifier-1",
"updatedAt": Any<ClockDate>,
@@ -352,8 +361,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": Any<String>,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": Any<String>,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "RELATION",
"uniqueIdentifier": "field-metadata-unique-identifier-1",
"updatedAt": Any<ClockDate>,
@@ -412,8 +422,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field-metadata-unique-identifier-1",
"updatedAt": Any<ClockDate>,
@@ -445,8 +456,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_0",
"updatedAt": Any<ClockDate>,
@@ -472,8 +484,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_1",
"updatedAt": Any<ClockDate>,
@@ -499,8 +512,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_2",
"updatedAt": Any<ClockDate>,
@@ -526,8 +540,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_3",
"updatedAt": Any<ClockDate>,
@@ -553,8 +568,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_4",
"updatedAt": Any<ClockDate>,
@@ -580,8 +596,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field-metadata-unique-identifier-1",
"updatedAt": Any<ClockDate>,
@@ -662,8 +679,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": Any<String>,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": Any<String>,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "RELATION",
"uniqueIdentifier": "field-metadata-unique-identifier-1",
"updatedAt": Any<ClockDate>,
@@ -695,8 +713,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_0",
"updatedAt": Any<ClockDate>,
@@ -722,8 +741,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_1",
"updatedAt": Any<ClockDate>,
@@ -749,8 +769,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_2",
"updatedAt": Any<ClockDate>,
@@ -776,8 +797,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_3",
"updatedAt": Any<ClockDate>,
@@ -803,8 +825,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_4",
"updatedAt": Any<ClockDate>,
@@ -830,8 +853,9 @@ exports[`Workspace migration builder field actions test suite It should build an
"relationTargetFieldMetadataId": Any<String>,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": Any<String>,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "RELATION",
"uniqueIdentifier": "field-metadata-unique-identifier-1",
"updatedAt": Any<ClockDate>,
@@ -1038,8 +1062,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_0",
"updatedAt": Any<ClockDate>,
@@ -1065,8 +1090,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_1",
"updatedAt": Any<ClockDate>,
@@ -1092,8 +1118,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_2",
"updatedAt": Any<ClockDate>,
@@ -1119,8 +1146,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_3",
"updatedAt": Any<ClockDate>,
@@ -1146,8 +1174,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_4",
"updatedAt": Any<ClockDate>,
@@ -1201,8 +1230,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_0",
"updatedAt": Any<ClockDate>,
@@ -1234,8 +1264,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_0",
"updatedAt": Any<ClockDate>,
@@ -1261,8 +1292,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_1",
"updatedAt": Any<ClockDate>,
@@ -1288,8 +1320,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_2",
"updatedAt": Any<ClockDate>,
@@ -1315,8 +1348,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_3",
"updatedAt": Any<ClockDate>,
@@ -1342,8 +1376,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_4",
"updatedAt": Any<ClockDate>,
@@ -1397,8 +1432,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_1",
"updatedAt": Any<ClockDate>,
@@ -1430,8 +1466,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_0",
"updatedAt": Any<ClockDate>,
@@ -1457,8 +1494,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_1",
"updatedAt": Any<ClockDate>,
@@ -1484,8 +1522,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_2",
"updatedAt": Any<ClockDate>,
@@ -1511,8 +1550,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_3",
"updatedAt": Any<ClockDate>,
@@ -1538,8 +1578,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_4",
"updatedAt": Any<ClockDate>,
@@ -1593,8 +1634,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_2",
"updatedAt": Any<ClockDate>,
@@ -1626,8 +1668,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_0",
"updatedAt": Any<ClockDate>,
@@ -1653,8 +1696,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_1",
"updatedAt": Any<ClockDate>,
@@ -1680,8 +1724,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_2",
"updatedAt": Any<ClockDate>,
@@ -1707,8 +1752,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_3",
"updatedAt": Any<ClockDate>,
@@ -1734,8 +1780,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_4",
"updatedAt": Any<ClockDate>,
@@ -1789,8 +1836,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_3",
"updatedAt": Any<ClockDate>,
@@ -1822,8 +1870,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_0",
"updatedAt": Any<ClockDate>,
@@ -1849,8 +1898,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_1",
"updatedAt": Any<ClockDate>,
@@ -1876,8 +1926,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_2",
"updatedAt": Any<ClockDate>,
@@ -1903,8 +1954,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_3",
"updatedAt": Any<ClockDate>,
@@ -1930,8 +1982,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_4",
"updatedAt": Any<ClockDate>,
@@ -1985,8 +2038,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_4",
"updatedAt": Any<ClockDate>,
@@ -2018,8 +2072,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_0",
"updatedAt": Any<ClockDate>,
@@ -2045,8 +2100,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_1",
"updatedAt": Any<ClockDate>,
@@ -2072,8 +2128,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_2",
"updatedAt": Any<ClockDate>,
@@ -2099,8 +2156,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_3",
"updatedAt": Any<ClockDate>,
@@ -2126,8 +2184,9 @@ exports[`Workspace migration builder object actions test suite It should build a
"relationTargetFieldMetadataId": undefined,
"relationTargetObjectMetadata": undefined,
"relationTargetObjectMetadataId": undefined,
"settings": null,
"standardId": null,
"standardOverrides": undefined,
"standardOverrides": null,
"type": "TEXT",
"uniqueIdentifier": "field_4",
"updatedAt": Any<ClockDate>,
@@ -12,6 +12,7 @@ const basicFlatFieldMetadatas = Array.from({ length: 5 }, (_value, index) =>
getFlatFieldMetadataMock({
objectMetadataId: basicObjectMetadataId,
uniqueIdentifier: `field_${index}`,
type: FieldMetadataType.TEXT,
}),
);
@@ -110,7 +111,6 @@ const relationTestCases: WorkspaceMigrationBuilderTestCase[] = [
type: FieldMetadataType.RELATION,
settings: {
relationType: RelationType.MANY_TO_ONE,
isForeignKey: true,
joinColumnName: 'column-name',
onDelete: undefined,
},
@@ -129,7 +129,7 @@ const relationTestCases: WorkspaceMigrationBuilderTestCase[] = [
{
...flatObjectMetadata,
flatFieldMetadatas: [
getFlatFieldMetadataMock({
{
...updatedFieldMetadata,
settings: {
relationType: RelationType.ONE_TO_MANY,
@@ -139,7 +139,7 @@ const relationTestCases: WorkspaceMigrationBuilderTestCase[] = [
},
relationTargetFieldMetadataId: faker.string.uuid(),
relationTargetObjectMetadataId: faker.string.uuid(),
}),
},
],
},
],
@@ -158,6 +158,7 @@ const basicCrudTestCases: WorkspaceMigrationBuilderTestCase[] = [
const flatFieldMetadata = getFlatFieldMetadataMock({
uniqueIdentifier: 'field-metadata-unique-identifier-1',
type: FieldMetadataType.TEXT,
objectMetadataId,
});
const flatObjectMetadata = getFlatObjectMetadataMock({
@@ -189,6 +190,7 @@ const basicCrudTestCases: WorkspaceMigrationBuilderTestCase[] = [
const flatFieldMetadata = getFlatFieldMetadataMock({
uniqueIdentifier: 'field-metadata-unique-identifier-1',
type: FieldMetadataType.TEXT,
objectMetadataId,
});
const flatObjectMetadata = getFlatObjectMetadataMock({
@@ -228,6 +230,7 @@ const basicCrudTestCases: WorkspaceMigrationBuilderTestCase[] = [
const flatFieldMetadata = getFlatFieldMetadataMock({
uniqueIdentifier: 'field-metadata-unique-identifier-1',
type: FieldMetadataType.TEXT,
objectMetadataId,
});
const flatObjectMetadata = getFlatObjectMetadataMock({
@@ -264,6 +267,7 @@ export const WORKSPACE_MIGRATION_FIELD_BUILDER_TEST_CASES: WorkspaceMigrationBui
const objectMetadataId = faker.string.uuid();
const flatFieldMetadata = getFlatFieldMetadataMock({
uniqueIdentifier: 'field-metadata-unique-identifier-1',
type: FieldMetadataType.TEXT,
objectMetadataId,
});
const from = [
@@ -1,4 +1,5 @@
import { faker } from '@faker-js/faker';
import { FieldMetadataType } from 'twenty-shared/types';
import { getFlatFieldMetadataMock } from 'src/engine/workspace-manager/workspace-migration-v2/__tests__/get-flat-field-metadata.mock';
import { getFlatObjectMetadataMock } from 'src/engine/workspace-manager/workspace-migration-v2/__tests__/get-flat-object-metadata.mock';
@@ -66,6 +67,7 @@ export const WORKSPACE_MIGRATION_OBJECT_BUILDER_TEST_CASES: WorkspaceMigrationBu
{ length: 5 },
(_value, index) =>
getFlatFieldMetadataMock({
type: FieldMetadataType.TEXT,
objectMetadataId,
uniqueIdentifier: `field_${index}`,
}),