Refactor backend folder structure (#4505)
* Refactor backend folder structure Co-authored-by: Charles Bochet <charles@twenty.com> * fix tests * fix * move yoga hooks --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -0,0 +1,77 @@
|
||||
import { FieldMetadataType } from 'src/engine-metadata/field-metadata/field-metadata.entity';
|
||||
import { messageChannelMessageAssociationStandardFieldIds } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
import { standardObjectIds } 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 { BaseObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/standard-objects/base.object-metadata';
|
||||
import { MessageChannelObjectMetadata } from 'src/modules/messaging/standard-objects/message-channel.object-metadata';
|
||||
import { MessageThreadObjectMetadata } from 'src/modules/messaging/standard-objects/message-thread.object-metadata';
|
||||
import { MessageObjectMetadata } from 'src/modules/messaging/standard-objects/message.object-metadata';
|
||||
|
||||
@ObjectMetadata({
|
||||
standardId: standardObjectIds.messageChannelMessageAssociation,
|
||||
namePlural: 'messageChannelMessageAssociations',
|
||||
labelSingular: 'Message Channel Message Association',
|
||||
labelPlural: 'Message Channel Message Associations',
|
||||
description: 'Message Synced with a Message Channel',
|
||||
icon: 'IconMessage',
|
||||
})
|
||||
@IsSystem()
|
||||
export class MessageChannelMessageAssociationObjectMetadata extends BaseObjectMetadata {
|
||||
@FieldMetadata({
|
||||
standardId: messageChannelMessageAssociationStandardFieldIds.messageChannel,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Message Channel Id',
|
||||
description: 'Message Channel Id',
|
||||
icon: 'IconHash',
|
||||
joinColumn: 'messageChannelId',
|
||||
})
|
||||
@IsNullable()
|
||||
messageChannel: MessageChannelObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageChannelMessageAssociationStandardFieldIds.message,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Message Id',
|
||||
description: 'Message Id',
|
||||
icon: 'IconHash',
|
||||
joinColumn: 'messageId',
|
||||
})
|
||||
@IsNullable()
|
||||
message: MessageObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId:
|
||||
messageChannelMessageAssociationStandardFieldIds.messageExternalId,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Message External Id',
|
||||
description: 'Message id from the messaging provider',
|
||||
icon: 'IconHash',
|
||||
})
|
||||
@IsNullable()
|
||||
messageExternalId: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageChannelMessageAssociationStandardFieldIds.messageThread,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Message Thread Id',
|
||||
description: 'Message Thread Id',
|
||||
icon: 'IconHash',
|
||||
joinColumn: 'messageThreadId',
|
||||
})
|
||||
@IsNullable()
|
||||
messageThread: MessageThreadObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId:
|
||||
messageChannelMessageAssociationStandardFieldIds.messageThreadExternalId,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Thread External Id',
|
||||
description: 'Thread id from the messaging provider',
|
||||
icon: 'IconHash',
|
||||
})
|
||||
@IsNullable()
|
||||
messageThreadExternalId: string;
|
||||
}
|
||||
@ -0,0 +1,105 @@
|
||||
import { FieldMetadataType } from 'src/engine-metadata/field-metadata/field-metadata.entity';
|
||||
import {
|
||||
RelationMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
} from 'src/engine-metadata/relation-metadata/relation-metadata.entity';
|
||||
import { messageChannelStandardFieldIds } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
import { standardObjectIds } 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 { ConnectedAccountObjectMetadata } from 'src/modules/connected-account/standard-objects/connected-account.object-metadata';
|
||||
import { MessageChannelMessageAssociationObjectMetadata } from 'src/modules/messaging/standard-objects/message-channel-message-association.object-metadata';
|
||||
|
||||
@ObjectMetadata({
|
||||
standardId: standardObjectIds.messageChannel,
|
||||
namePlural: 'messageChannels',
|
||||
labelSingular: 'Message Channel',
|
||||
labelPlural: 'Message Channels',
|
||||
description: 'Message Channels',
|
||||
icon: 'IconMessage',
|
||||
})
|
||||
@IsSystem()
|
||||
export class MessageChannelObjectMetadata extends BaseObjectMetadata {
|
||||
@FieldMetadata({
|
||||
standardId: messageChannelStandardFieldIds.visibility,
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Visibility',
|
||||
description: 'Visibility',
|
||||
icon: 'IconEyeglass',
|
||||
options: [
|
||||
{ value: 'metadata', label: 'Metadata', position: 0, color: 'green' },
|
||||
{ value: 'subject', label: 'Subject', position: 1, color: 'blue' },
|
||||
{
|
||||
value: 'share_everything',
|
||||
label: 'Share Everything',
|
||||
position: 2,
|
||||
color: 'orange',
|
||||
},
|
||||
],
|
||||
defaultValue: { value: 'share_everything' },
|
||||
})
|
||||
visibility: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageChannelStandardFieldIds.handle,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Handle',
|
||||
description: 'Handle',
|
||||
icon: 'IconAt',
|
||||
})
|
||||
handle: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageChannelStandardFieldIds.connectedAccount,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Connected Account',
|
||||
description: 'Connected Account',
|
||||
icon: 'IconUserCircle',
|
||||
joinColumn: 'connectedAccountId',
|
||||
})
|
||||
connectedAccount: ConnectedAccountObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageChannelStandardFieldIds.type,
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Type',
|
||||
description: 'Channel Type',
|
||||
icon: 'IconMessage',
|
||||
options: [
|
||||
{ value: 'email', label: 'Email', position: 0, color: 'green' },
|
||||
{ value: 'sms', label: 'SMS', position: 1, color: 'blue' },
|
||||
],
|
||||
defaultValue: { value: 'email' },
|
||||
})
|
||||
type: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageChannelStandardFieldIds.isContactAutoCreationEnabled,
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'Is Contact Auto Creation Enabled',
|
||||
description: 'Is Contact Auto Creation Enabled',
|
||||
icon: 'IconUserCircle',
|
||||
defaultValue: { value: true },
|
||||
})
|
||||
isContactAutoCreationEnabled: boolean;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId:
|
||||
messageChannelStandardFieldIds.messageChannelMessageAssociations,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Message Channel Association',
|
||||
description: 'Messages from the channel.',
|
||||
icon: 'IconMessage',
|
||||
})
|
||||
@RelationMetadata({
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
inverseSideTarget: () => MessageChannelMessageAssociationObjectMetadata,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
})
|
||||
@IsNullable()
|
||||
messageChannelMessageAssociations: MessageChannelMessageAssociationObjectMetadata[];
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
import { FieldMetadataType } from 'src/engine-metadata/field-metadata/field-metadata.entity';
|
||||
import { messageParticipantStandardFieldIds } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
import { standardObjectIds } 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 { BaseObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/standard-objects/base.object-metadata';
|
||||
import { MessageObjectMetadata } from 'src/modules/messaging/standard-objects/message.object-metadata';
|
||||
import { PersonObjectMetadata } from 'src/modules/person/standard-objects/person.object-metadata';
|
||||
import { WorkspaceMemberObjectMetadata } from 'src/modules/workspace-member/standard-objects/workspace-member.object-metadata';
|
||||
|
||||
@ObjectMetadata({
|
||||
standardId: standardObjectIds.messageParticipant,
|
||||
namePlural: 'messageParticipants',
|
||||
labelSingular: 'Message Participant',
|
||||
labelPlural: 'Message Participants',
|
||||
description: 'Message Participants',
|
||||
icon: 'IconUserCircle',
|
||||
})
|
||||
@IsSystem()
|
||||
export class MessageParticipantObjectMetadata extends BaseObjectMetadata {
|
||||
@FieldMetadata({
|
||||
standardId: messageParticipantStandardFieldIds.message,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Message',
|
||||
description: 'Message',
|
||||
icon: 'IconMessage',
|
||||
joinColumn: 'messageId',
|
||||
})
|
||||
message: MessageObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageParticipantStandardFieldIds.role,
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Role',
|
||||
description: 'Role',
|
||||
icon: 'IconAt',
|
||||
options: [
|
||||
{ value: 'from', label: 'From', position: 0, color: 'green' },
|
||||
{ value: 'to', label: 'To', position: 1, color: 'blue' },
|
||||
{ value: 'cc', label: 'Cc', position: 2, color: 'orange' },
|
||||
{ value: 'bcc', label: 'Bcc', position: 3, color: 'red' },
|
||||
],
|
||||
defaultValue: { value: 'from' },
|
||||
})
|
||||
role: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageParticipantStandardFieldIds.handle,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Handle',
|
||||
description: 'Handle',
|
||||
icon: 'IconAt',
|
||||
})
|
||||
handle: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageParticipantStandardFieldIds.displayName,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Display Name',
|
||||
description: 'Display Name',
|
||||
icon: 'IconUser',
|
||||
})
|
||||
displayName: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageParticipantStandardFieldIds.person,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Person',
|
||||
description: 'Person',
|
||||
icon: 'IconUser',
|
||||
joinColumn: 'personId',
|
||||
})
|
||||
@IsNullable()
|
||||
person: PersonObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageParticipantStandardFieldIds.workspaceMember,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Workspace Member',
|
||||
description: 'Workspace member',
|
||||
icon: 'IconCircleUser',
|
||||
joinColumn: 'workspaceMemberId',
|
||||
})
|
||||
@IsNullable()
|
||||
workspaceMember: WorkspaceMemberObjectMetadata;
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
import { FieldMetadataType } from 'src/engine-metadata/field-metadata/field-metadata.entity';
|
||||
import {
|
||||
RelationMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
} from 'src/engine-metadata/relation-metadata/relation-metadata.entity';
|
||||
import { messageThreadStandardFieldIds } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
import { standardObjectIds } 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';
|
||||
|
||||
@ObjectMetadata({
|
||||
standardId: standardObjectIds.messageThread,
|
||||
namePlural: 'messageThreads',
|
||||
labelSingular: 'Message Thread',
|
||||
labelPlural: 'Message Threads',
|
||||
description: 'Message Thread',
|
||||
icon: 'IconMessage',
|
||||
})
|
||||
@IsSystem()
|
||||
export class MessageThreadObjectMetadata extends BaseObjectMetadata {
|
||||
@FieldMetadata({
|
||||
standardId: messageThreadStandardFieldIds.messages,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Messages',
|
||||
description: 'Messages from the thread.',
|
||||
icon: 'IconMessage',
|
||||
})
|
||||
@RelationMetadata({
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
inverseSideTarget: () => MessageObjectMetadata,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
})
|
||||
@IsNullable()
|
||||
messages: MessageObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageThreadStandardFieldIds.messageChannelMessageAssociations,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Message Channel Association',
|
||||
description: 'Messages from the channel.',
|
||||
icon: 'IconMessage',
|
||||
})
|
||||
@RelationMetadata({
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
inverseSideTarget: () => MessageChannelMessageAssociationObjectMetadata,
|
||||
onDelete: RelationOnDeleteAction.RESTRICT,
|
||||
})
|
||||
@IsNullable()
|
||||
messageChannelMessageAssociations: MessageChannelMessageAssociationObjectMetadata[];
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
import { FieldMetadataType } from 'src/engine-metadata/field-metadata/field-metadata.entity';
|
||||
import {
|
||||
RelationMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
} from 'src/engine-metadata/relation-metadata/relation-metadata.entity';
|
||||
import { messageStandardFieldIds } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
import { standardObjectIds } 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 { MessageParticipantObjectMetadata } from 'src/modules/messaging/standard-objects/message-participant.object-metadata';
|
||||
import { MessageThreadObjectMetadata } from 'src/modules/messaging/standard-objects/message-thread.object-metadata';
|
||||
|
||||
@ObjectMetadata({
|
||||
standardId: standardObjectIds.message,
|
||||
namePlural: 'messages',
|
||||
labelSingular: 'Message',
|
||||
labelPlural: 'Messages',
|
||||
description: 'Message',
|
||||
icon: 'IconMessage',
|
||||
})
|
||||
@IsSystem()
|
||||
export class MessageObjectMetadata extends BaseObjectMetadata {
|
||||
@FieldMetadata({
|
||||
standardId: messageStandardFieldIds.headerMessageId,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Header message Id',
|
||||
description: 'Message id from the message header',
|
||||
icon: 'IconHash',
|
||||
})
|
||||
headerMessageId: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageStandardFieldIds.messageThread,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Message Thread Id',
|
||||
description: 'Message Thread Id',
|
||||
icon: 'IconHash',
|
||||
joinColumn: 'messageThreadId',
|
||||
})
|
||||
@IsNullable()
|
||||
messageThread: MessageThreadObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageStandardFieldIds.direction,
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Direction',
|
||||
description: 'Message Direction',
|
||||
icon: 'IconDirection',
|
||||
options: [
|
||||
{ value: 'incoming', label: 'Incoming', position: 0, color: 'green' },
|
||||
{ value: 'outgoing', label: 'Outgoing', position: 1, color: 'blue' },
|
||||
],
|
||||
defaultValue: { value: 'incoming' },
|
||||
})
|
||||
direction: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageStandardFieldIds.subject,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Subject',
|
||||
description: 'Subject',
|
||||
icon: 'IconMessage',
|
||||
})
|
||||
subject: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageStandardFieldIds.text,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Text',
|
||||
description: 'Text',
|
||||
icon: 'IconMessage',
|
||||
})
|
||||
text: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageStandardFieldIds.receivedAt,
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Received At',
|
||||
description: 'The date the message was received',
|
||||
icon: 'IconCalendar',
|
||||
})
|
||||
@IsNullable()
|
||||
receivedAt: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageStandardFieldIds.messageParticipants,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Message Participants',
|
||||
description: 'Message Participants',
|
||||
icon: 'IconUserCircle',
|
||||
})
|
||||
@RelationMetadata({
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
inverseSideTarget: () => MessageParticipantObjectMetadata,
|
||||
inverseSideFieldKey: 'message',
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
})
|
||||
@IsNullable()
|
||||
messageParticipants: MessageParticipantObjectMetadata[];
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: messageStandardFieldIds.messageChannelMessageAssociations,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Message Channel Association',
|
||||
description: 'Messages from the channel.',
|
||||
icon: 'IconMessage',
|
||||
})
|
||||
@RelationMetadata({
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
inverseSideTarget: () => MessageChannelMessageAssociationObjectMetadata,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
})
|
||||
@IsNullable()
|
||||
messageChannelMessageAssociations: MessageChannelMessageAssociationObjectMetadata[];
|
||||
}
|
||||
Reference in New Issue
Block a user