Deprecate ObjectMetadataInterface and improve entity typing (#13310)
# Introduction Following `FieldMetadataInterface` deprecation in https://github.com/twentyhq/twenty/pull/13264 As for the previous PR will rename and remove all the file in a secondary PR to avoid conflicts and over loading this one ## Improvements Removed optional properties from the `objectMetadataEntity` model and added utils to retrieve test data ## Notes By touching to `ObjectMetadataDTO` I would have expected a twenty-front codegenerated types mutation, but it does not seem to be granular enough to null/undefined coercion
This commit is contained in:
@ -2,114 +2,115 @@ import { FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
import { WorkspaceEntityDuplicateCriteria } from 'src/engine/api/graphql/workspace-query-builder/types/workspace-entity-duplicate-criteria.type';
|
||||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { ObjectMetadataItemWithFieldMaps } from 'src/engine/metadata-modules/types/object-metadata-item-with-field-maps';
|
||||
import { getMockFieldMetadataEntity } from 'src/utils/__test__/get-field-metadata-entity.mock';
|
||||
import { getMockObjectMetadataItemWithFieldsMaps } from 'src/utils/__test__/get-object-metadata-item-with-fields-maps.mock';
|
||||
|
||||
const workspaceId = '20202020-1c25-4d02-bf25-6aeccf7ea419';
|
||||
|
||||
export const mockPersonObjectMetadataWithFieldMaps = (
|
||||
duplicateCriteria: WorkspaceEntityDuplicateCriteria[],
|
||||
): ObjectMetadataItemWithFieldMaps => ({
|
||||
id: '',
|
||||
icon: 'Icon123',
|
||||
standardId: '',
|
||||
nameSingular: 'person',
|
||||
namePlural: 'people',
|
||||
labelSingular: 'Person',
|
||||
labelPlural: 'People',
|
||||
description: 'A person',
|
||||
targetTableName: 'DEPRECATED',
|
||||
isCustom: false,
|
||||
isRemote: false,
|
||||
isActive: true,
|
||||
isSystem: false,
|
||||
isAuditLogged: true,
|
||||
isSearchable: true,
|
||||
duplicateCriteria: duplicateCriteria,
|
||||
labelIdentifierFieldMetadataId: '',
|
||||
imageIdentifierFieldMetadataId: '',
|
||||
workspaceId,
|
||||
indexMetadatas: [],
|
||||
fieldIdByName: {
|
||||
name: 'name-id',
|
||||
emails: 'emails-id',
|
||||
linkedinLink: 'linkedinLink-id',
|
||||
jobTitle: 'jobTitle-id',
|
||||
},
|
||||
fieldIdByJoinColumnName: {},
|
||||
fieldsById: {
|
||||
'name-id': getMockFieldMetadataEntity({
|
||||
workspaceId,
|
||||
objectMetadataId: '',
|
||||
id: 'name-id',
|
||||
type: FieldMetadataType.FULL_NAME,
|
||||
name: 'name',
|
||||
label: 'Name',
|
||||
defaultValue: {
|
||||
lastName: "''",
|
||||
firstName: "''",
|
||||
},
|
||||
description: "Contact's name",
|
||||
isCustom: false,
|
||||
isNullable: true,
|
||||
isUnique: false,
|
||||
isLabelSyncedWithName: true,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
}) as FieldMetadataEntity,
|
||||
'emails-id': getMockFieldMetadataEntity({
|
||||
workspaceId,
|
||||
objectMetadataId: '',
|
||||
id: 'emails-id',
|
||||
type: FieldMetadataType.EMAILS,
|
||||
name: 'emails',
|
||||
label: 'Emails',
|
||||
defaultValue: {
|
||||
primaryEmail: "''",
|
||||
additionalEmails: null,
|
||||
},
|
||||
description: "Contact's Emails",
|
||||
isCustom: false,
|
||||
isNullable: true,
|
||||
isLabelSyncedWithName: true,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
}) as FieldMetadataEntity,
|
||||
'linkedinLink-id': getMockFieldMetadataEntity({
|
||||
workspaceId,
|
||||
objectMetadataId: '',
|
||||
id: 'linkedinLink-id',
|
||||
type: FieldMetadataType.LINKS,
|
||||
name: 'linkedinLink',
|
||||
label: 'Linkedin',
|
||||
defaultValue: {
|
||||
primaryLinkUrl: "''",
|
||||
secondaryLinks: [],
|
||||
primaryLinkLabel: "''",
|
||||
},
|
||||
description: "Contact's Linkedin account",
|
||||
isCustom: false,
|
||||
isNullable: true,
|
||||
isUnique: false,
|
||||
isLabelSyncedWithName: true,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
}) as FieldMetadataEntity,
|
||||
'jobTitle-id': getMockFieldMetadataEntity({
|
||||
workspaceId,
|
||||
objectMetadataId: '',
|
||||
id: 'jobTitle-id',
|
||||
type: FieldMetadataType.TEXT,
|
||||
name: 'jobTitle',
|
||||
label: 'Job Title',
|
||||
defaultValue: "''",
|
||||
description: "Contact's job title",
|
||||
isCustom: false,
|
||||
isNullable: false,
|
||||
isUnique: false,
|
||||
isLabelSyncedWithName: true,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
}) as FieldMetadataEntity,
|
||||
},
|
||||
});
|
||||
) =>
|
||||
getMockObjectMetadataItemWithFieldsMaps({
|
||||
id: '',
|
||||
icon: 'Icon123',
|
||||
standardId: '',
|
||||
nameSingular: 'person',
|
||||
namePlural: 'people',
|
||||
labelSingular: 'Person',
|
||||
labelPlural: 'People',
|
||||
description: 'A person',
|
||||
targetTableName: 'DEPRECATED',
|
||||
isCustom: false,
|
||||
isRemote: false,
|
||||
isActive: true,
|
||||
isSystem: false,
|
||||
isAuditLogged: true,
|
||||
isSearchable: true,
|
||||
duplicateCriteria: duplicateCriteria,
|
||||
labelIdentifierFieldMetadataId: '',
|
||||
imageIdentifierFieldMetadataId: '',
|
||||
workspaceId,
|
||||
indexMetadatas: [],
|
||||
fieldIdByName: {
|
||||
name: 'name-id',
|
||||
emails: 'emails-id',
|
||||
linkedinLink: 'linkedinLink-id',
|
||||
jobTitle: 'jobTitle-id',
|
||||
},
|
||||
fieldIdByJoinColumnName: {},
|
||||
fieldsById: {
|
||||
'name-id': getMockFieldMetadataEntity({
|
||||
workspaceId,
|
||||
objectMetadataId: '',
|
||||
id: 'name-id',
|
||||
type: FieldMetadataType.FULL_NAME,
|
||||
name: 'name',
|
||||
label: 'Name',
|
||||
defaultValue: {
|
||||
lastName: "''",
|
||||
firstName: "''",
|
||||
},
|
||||
description: "Contact's name",
|
||||
isCustom: false,
|
||||
isNullable: true,
|
||||
isUnique: false,
|
||||
isLabelSyncedWithName: true,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
}) as FieldMetadataEntity,
|
||||
'emails-id': getMockFieldMetadataEntity({
|
||||
workspaceId,
|
||||
objectMetadataId: '',
|
||||
id: 'emails-id',
|
||||
type: FieldMetadataType.EMAILS,
|
||||
name: 'emails',
|
||||
label: 'Emails',
|
||||
defaultValue: {
|
||||
primaryEmail: "''",
|
||||
additionalEmails: null,
|
||||
},
|
||||
description: "Contact's Emails",
|
||||
isCustom: false,
|
||||
isNullable: true,
|
||||
isLabelSyncedWithName: true,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
}) as FieldMetadataEntity,
|
||||
'linkedinLink-id': getMockFieldMetadataEntity({
|
||||
workspaceId,
|
||||
objectMetadataId: '',
|
||||
id: 'linkedinLink-id',
|
||||
type: FieldMetadataType.LINKS,
|
||||
name: 'linkedinLink',
|
||||
label: 'Linkedin',
|
||||
defaultValue: {
|
||||
primaryLinkUrl: "''",
|
||||
secondaryLinks: [],
|
||||
primaryLinkLabel: "''",
|
||||
},
|
||||
description: "Contact's Linkedin account",
|
||||
isCustom: false,
|
||||
isNullable: true,
|
||||
isUnique: false,
|
||||
isLabelSyncedWithName: true,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
}) as FieldMetadataEntity,
|
||||
'jobTitle-id': getMockFieldMetadataEntity({
|
||||
workspaceId,
|
||||
objectMetadataId: '',
|
||||
id: 'jobTitle-id',
|
||||
type: FieldMetadataType.TEXT,
|
||||
name: 'jobTitle',
|
||||
label: 'Job Title',
|
||||
defaultValue: "''",
|
||||
description: "Contact's job title",
|
||||
isCustom: false,
|
||||
isNullable: false,
|
||||
isUnique: false,
|
||||
isLabelSyncedWithName: true,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
}) as FieldMetadataEntity,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user