diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/index.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/index.ts index 18b8f3bbd0..50ff3fbffa 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/index.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/index.ts @@ -7,6 +7,7 @@ import { CompanyObjectMetadata } from 'src/workspace/workspace-sync-metadata/sta import { ConnectedAccountObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/connected-account.object-metadata'; import { FavoriteObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/favorite.object-metadata'; import { MessageChannelObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata'; +import { MessageRecipientObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-recipient.object-metadata'; import { MessageThreadObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata'; import { MessageObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata'; import { OpportunityObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/opportunity.object-metadata'; @@ -16,7 +17,7 @@ import { ViewFieldObjectMetadata } from 'src/workspace/workspace-sync-metadata/s import { ViewFilterObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/view-filter.object-metadata'; import { ViewSortObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/view-sort.object-metadata'; import { ViewObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/view.object-metadata'; -import { WebhookObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/webook.object-metadata'; +import { WebhookObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/webhook.object-metadata'; import { WorkspaceMemberObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/workspace-member.object-metadata'; export const standardObjectMetadata = [ @@ -40,4 +41,5 @@ export const standardObjectMetadata = [ MessageThreadObjectMetadata, MessageObjectMetadata, MessageChannelObjectMetadata, + MessageRecipientObjectMetadata, ]; diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-recipient.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-recipient.object-metadata.ts new file mode 100644 index 0000000000..3569eec030 --- /dev/null +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-recipient.object-metadata.ts @@ -0,0 +1,77 @@ +import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity'; +import { + ObjectMetadata, + IsSystem, + FieldMetadata, + IsNullable, +} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator'; +import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata'; +import { MessageObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata'; +import { PersonObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/person.object-metadata'; +import { WorkspaceMemberObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/workspace-member.object-metadata'; + +@ObjectMetadata({ + namePlural: 'messageRecipients', + labelSingular: 'Message Recipient', + labelPlural: 'Message Recipients', + description: 'Message Recipients', + icon: 'IconUserCircle', +}) +@IsSystem() +export class MessageRecipientObjectMetadata extends BaseObjectMetadata { + @FieldMetadata({ + type: FieldMetadataType.RELATION, + label: 'Message', + description: 'Message', + icon: 'IconMessage', + joinColumn: 'messageId', + }) + message: MessageObjectMetadata; + + @FieldMetadata({ + // this will be a type select: from, to, cc, bcc + type: FieldMetadataType.TEXT, + label: 'Role', + description: 'Role', + icon: 'IconAt', + defaultValue: { value: 'from' }, + }) + role: string; + + @FieldMetadata({ + type: FieldMetadataType.TEXT, + label: 'Handle', + description: 'Handle', + icon: 'IconAt', + }) + handle: string; + + @FieldMetadata({ + type: FieldMetadataType.TEXT, + label: 'Display Name', + description: 'Display Name', + icon: 'IconUser', + }) + @IsNullable() + displayName: string; + + @FieldMetadata({ + type: FieldMetadataType.RELATION, + label: 'Person', + description: 'Person', + icon: 'IconUser', + joinColumn: 'personId', + }) + @IsNullable() + person: PersonObjectMetadata; + + @FieldMetadata({ + type: FieldMetadataType.RELATION, + label: 'Workspace Member', + description: 'Workspace member', + icon: 'IconCircleUser', + joinColumn: 'workspaceMemberId', + }) + @IsNullable() + workspaceMember: WorkspaceMemberObjectMetadata; +} diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts index a98983214c..dd238eac44 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts @@ -1,11 +1,14 @@ import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity'; +import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity'; import { ObjectMetadata, IsSystem, FieldMetadata, IsNullable, + RelationMetadata, } from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator'; import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata'; +import { MessageRecipientObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-recipient.object-metadata'; import { MessageThreadObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata'; @ObjectMetadata({ @@ -73,4 +76,18 @@ export class MessageObjectMetadata extends BaseObjectMetadata { }) @IsNullable() body: string; + + @FieldMetadata({ + type: FieldMetadataType.RELATION, + label: 'Message Recipients', + description: 'Message Recipients', + icon: 'IconUserCircle', + }) + @RelationMetadata({ + type: RelationMetadataType.ONE_TO_MANY, + objectName: 'messageRecipient', + inverseSideFieldName: 'message', + }) + @IsNullable() + messageRecipients: MessageRecipientObjectMetadata[]; } diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/person.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/person.object-metadata.ts index 7fbebf6796..ec1724e632 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/person.object-metadata.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/person.object-metadata.ts @@ -14,6 +14,7 @@ import { AttachmentObjectMetadata } from 'src/workspace/workspace-sync-metadata/ import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata'; import { CompanyObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/company.object-metadata'; import { FavoriteObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/favorite.object-metadata'; +import { MessageRecipientObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-recipient.object-metadata'; import { OpportunityObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/opportunity.object-metadata'; @ObjectMetadata({ @@ -173,4 +174,18 @@ export class PersonObjectMetadata extends BaseObjectMetadata { }) @IsNullable() attachments: AttachmentObjectMetadata[]; + + @FieldMetadata({ + type: FieldMetadataType.RELATION, + label: 'Message Recipients', + description: 'Message Recipients', + icon: 'IconUserCircle', + }) + @RelationMetadata({ + type: RelationMetadataType.ONE_TO_MANY, + objectName: 'messageRecipient', + inverseSideFieldName: 'person', + }) + @IsNullable() + messageRecipients: MessageRecipientObjectMetadata[]; } diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/webook.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/webhook.object-metadata.ts similarity index 100% rename from packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/webook.object-metadata.ts rename to packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/webhook.object-metadata.ts diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/workspace-member.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/workspace-member.object-metadata.ts index 1f9a64387b..80c461897a 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/workspace-member.object-metadata.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/workspace-member.object-metadata.ts @@ -15,6 +15,7 @@ import { CommentObjectMetadata } from 'src/workspace/workspace-sync-metadata/sta import { CompanyObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/company.object-metadata'; import { ConnectedAccountObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/connected-account.object-metadata'; import { FavoriteObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/favorite.object-metadata'; +import { MessageRecipientObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-recipient.object-metadata'; @ObjectMetadata({ namePlural: 'workspaceMembers', @@ -164,4 +165,18 @@ export class WorkspaceMemberObjectMetadata extends BaseObjectMetadata { }) @IsNullable() connectedAccounts: ConnectedAccountObjectMetadata[]; + + @FieldMetadata({ + type: FieldMetadataType.RELATION, + label: 'Message Recipients', + description: 'Message Recipients', + icon: 'IconUserCircle', + }) + @RelationMetadata({ + type: RelationMetadataType.ONE_TO_MANY, + objectName: 'messageRecipient', + inverseSideFieldName: 'workspaceMember', + }) + @IsNullable() + messageRecipients: MessageRecipientObjectMetadata[]; }