feat: twenty orm sync (#5266)

This PR is updating all object metadata entities with the new
decorators, and deleting the old ones.
This way we can use the new TwentyORM with all the standard objects.

---------

Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
Jérémy M
2024-05-15 16:58:47 +02:00
committed by GitHub
parent 6898c1e4d8
commit f0383e3147
81 changed files with 1721 additions and 2060 deletions
@@ -1,23 +1,21 @@
import { Relation } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/relation.interface';
import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
import {
RelationMetadataType,
RelationOnDeleteAction,
} from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
import { MESSAGE_THREAD_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
import { FieldMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/field-metadata.decorator';
import { IsNullable } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/is-nullable.decorator';
import { IsSystem } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/is-system.decorator';
import { ObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/object-metadata.decorator';
import { RelationMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/relation-metadata.decorator';
import { BaseObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/standard-objects/base.object-metadata';
import { MessageChannelMessageAssociationObjectMetadata } from 'src/modules/messaging/standard-objects/message-channel-message-association.object-metadata';
import { MessageObjectMetadata } from 'src/modules/messaging/standard-objects/message.object-metadata';
import { IsNotAuditLogged } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/is-not-audit-logged.decorator';
import { BaseWorkspaceEntity } from 'src/engine/twenty-orm/base.workspace-entity';
import { WorkspaceEntity } from 'src/engine/twenty-orm/decorators/workspace-object.decorator';
import { WorkspaceIsNotAuditLogged } from 'src/engine/twenty-orm/decorators/workspace-is-not-audit-logged.decorator';
import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator';
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';
@ObjectMetadata({
@WorkspaceEntity({
standardId: STANDARD_OBJECT_IDS.messageThread,
namePlural: 'messageThreads',
labelSingular: 'Message Thread',
@@ -25,38 +23,32 @@ import { IsNotAuditLogged } from 'src/engine/workspace-manager/workspace-sync-me
description: 'Message Thread',
icon: 'IconMessage',
})
@IsNotAuditLogged()
@IsSystem()
export class MessageThreadObjectMetadata extends BaseObjectMetadata {
@FieldMetadata({
@WorkspaceIsNotAuditLogged()
@WorkspaceIsSystem()
export class MessageThreadObjectMetadata extends BaseWorkspaceEntity {
@WorkspaceRelation({
standardId: MESSAGE_THREAD_STANDARD_FIELD_IDS.messages,
type: FieldMetadataType.RELATION,
type: RelationMetadataType.ONE_TO_MANY,
label: 'Messages',
description: 'Messages from the thread.',
icon: 'IconMessage',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
inverseSideTarget: () => MessageObjectMetadata,
onDelete: RelationOnDeleteAction.CASCADE,
})
@IsNullable()
@WorkspaceIsNullable()
messages: Relation<MessageObjectMetadata[]>;
@FieldMetadata({
@WorkspaceRelation({
standardId:
MESSAGE_THREAD_STANDARD_FIELD_IDS.messageChannelMessageAssociations,
type: FieldMetadataType.RELATION,
label: 'Message Channel Association',
description: 'Messages from the channel.',
icon: 'IconMessage',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
label: 'Message Channel Association',
description: 'Messages from the channel',
icon: 'IconMessage',
inverseSideTarget: () => MessageChannelMessageAssociationObjectMetadata,
onDelete: RelationOnDeleteAction.RESTRICT,
})
@IsNullable()
@WorkspaceIsNullable()
messageChannelMessageAssociations: Relation<
MessageChannelMessageAssociationObjectMetadata[]
>;