2811 create message thread data model (#2955)

* create message thread

* link message threads and message

* add ton index.ts

* finished models

* header mail id

* update icon

* modifications

* update externalId
This commit is contained in:
bosiraphael 2023-12-12 16:08:51 +01:00 committed by GitHub
parent 0048216abf
commit a21fc4976b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 172 additions and 0 deletions

View File

@ -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,
];

View File

@ -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[];
}

View File

@ -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[];
}

View File

@ -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;
}