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 00cdbef46378..18b8f3bbd033 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,8 @@ 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 { 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'; import { PersonObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/person.object-metadata'; import { PipelineStepObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/pipeline-step.object-metadata'; @@ -35,5 +37,7 @@ export const standardObjectMetadata = [ ViewObjectMetadata, WebhookObjectMetadata, WorkspaceMemberObjectMetadata, + MessageThreadObjectMetadata, + MessageObjectMetadata, MessageChannelObjectMetadata, ]; diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata.ts index 513d6a60215c..c8947c17cfc0 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata.ts @@ -1,12 +1,15 @@ 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 { ConnectedAccountObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/connected-account.object-metadata'; +import { MessageThreadObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata'; @ObjectMetadata({ namePlural: 'messageChannels', @@ -45,6 +48,7 @@ export class MessageChannelObjectMetadata extends BaseObjectMetadata { connectedAccount: ConnectedAccountObjectMetadata; @FieldMetadata({ + // This will be a type select later : email, sms, chat type: FieldMetadataType.TEXT, label: 'Type', description: 'Type', @@ -52,4 +56,17 @@ export class MessageChannelObjectMetadata extends BaseObjectMetadata { }) @IsNullable() type: string; + + @FieldMetadata({ + type: FieldMetadataType.RELATION, + label: 'Message Threads', + description: 'Threads from the channel.', + icon: 'IconMessage', + }) + @RelationMetadata({ + type: RelationMetadataType.ONE_TO_MANY, + objectName: 'messageThread', + }) + @IsNullable() + messageThreads: MessageThreadObjectMetadata[]; } diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts new file mode 100644 index 000000000000..3e1c1edef9a1 --- /dev/null +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts @@ -0,0 +1,75 @@ +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 { MessageChannelObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata'; +import { MessageObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata'; + +@ObjectMetadata({ + namePlural: 'messageThreads', + labelSingular: 'Message Thread', + labelPlural: 'Message Threads', + description: 'Message Thread', + icon: 'IconMessage', +}) +@IsSystem() +export class MessageThreadObjectMetadata extends BaseObjectMetadata { + @FieldMetadata({ + // will be an array + type: FieldMetadataType.TEXT, + label: 'External Id', + description: 'Thread id from the messaging provider', + icon: 'IconMessage', + }) + @IsNullable() + externalId: string; + + @FieldMetadata({ + type: FieldMetadataType.TEXT, + label: 'Subject', + description: 'Subject', + icon: 'IconMessage', + }) + @IsNullable() + subject: string; + + @FieldMetadata({ + type: FieldMetadataType.RELATION, + label: 'Message Channel Id', + description: 'Message Channel Id', + icon: 'IconHash', + joinColumn: 'messageChannelId', + }) + @IsNullable() + messageChannel: MessageChannelObjectMetadata; + + @FieldMetadata({ + // This will be a type select later: default, subject, share_everything + type: FieldMetadataType.TEXT, + label: 'Visibility', + description: 'Visibility', + icon: 'IconEyeglass', + defaultValue: { value: 'default' }, + }) + @IsNullable() + visibility: string; + + @FieldMetadata({ + type: FieldMetadataType.RELATION, + label: 'Messages', + description: 'Messages from the thread.', + icon: 'IconMessage', + }) + @RelationMetadata({ + type: RelationMetadataType.ONE_TO_MANY, + objectName: 'message', + }) + @IsNullable() + messages: MessageObjectMetadata[]; +} 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 new file mode 100644 index 000000000000..a98983214cda --- /dev/null +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts @@ -0,0 +1,76 @@ +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 { MessageThreadObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata'; + +@ObjectMetadata({ + namePlural: 'message', + labelSingular: 'Message', + labelPlural: 'Messages', + description: 'Message', + icon: 'IconMessage', +}) +@IsSystem() +export class MessageObjectMetadata extends BaseObjectMetadata { + @FieldMetadata({ + // will be an array + type: FieldMetadataType.TEXT, + label: 'External Id', + description: 'Message id from the messaging provider', + icon: 'IconHash', + }) + @IsNullable() + externalId: string; + + @FieldMetadata({ + type: FieldMetadataType.TEXT, + label: 'Header message Id', + description: 'Message id from the message header', + icon: 'IconHash', + }) + @IsNullable() + headerMessageId: string; + + @FieldMetadata({ + type: FieldMetadataType.RELATION, + label: 'Message Thread Id', + description: 'Message Thread Id', + icon: 'IconHash', + joinColumn: 'messageThreadId', + }) + @IsNullable() + messageThread: MessageThreadObjectMetadata; + + @FieldMetadata({ + // will be a select later: incoming, outgoing + type: FieldMetadataType.TEXT, + label: 'Direction', + description: 'Direction', + icon: 'IconDirection', + defaultValue: { value: 'incoming' }, + }) + direction: string; + + @FieldMetadata({ + type: FieldMetadataType.TEXT, + label: 'Subject', + description: 'Subject', + icon: 'IconMessage', + }) + @IsNullable() + subject: string; + + @FieldMetadata({ + type: FieldMetadataType.TEXT, + label: 'Body', + description: 'Body', + icon: 'IconMessage', + }) + @IsNullable() + body: string; +}