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:
@ -3,17 +3,19 @@ import { Relation } from 'src/engine/workspace-manager/workspace-sync-metadata/i
|
||||
import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_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 { 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';
|
||||
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 { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
|
||||
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
|
||||
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';
|
||||
import { RelationMetadataType } from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
||||
|
||||
@ObjectMetadata({
|
||||
@WorkspaceEntity({
|
||||
standardId: STANDARD_OBJECT_IDS.messageChannelMessageAssociation,
|
||||
namePlural: 'messageChannelMessageAssociations',
|
||||
labelSingular: 'Message Channel Message Association',
|
||||
@ -21,33 +23,10 @@ import { IsNotAuditLogged } from 'src/engine/workspace-manager/workspace-sync-me
|
||||
description: 'Message Synced with a Message Channel',
|
||||
icon: 'IconMessage',
|
||||
})
|
||||
@IsNotAuditLogged()
|
||||
@IsSystem()
|
||||
export class MessageChannelMessageAssociationObjectMetadata extends BaseObjectMetadata {
|
||||
@FieldMetadata({
|
||||
standardId:
|
||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_STANDARD_FIELD_IDS.messageChannel,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Message Channel Id',
|
||||
description: 'Message Channel Id',
|
||||
icon: 'IconHash',
|
||||
joinColumn: 'messageChannelId',
|
||||
})
|
||||
@IsNullable()
|
||||
messageChannel: Relation<MessageChannelObjectMetadata>;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_STANDARD_FIELD_IDS.message,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Message Id',
|
||||
description: 'Message Id',
|
||||
icon: 'IconHash',
|
||||
joinColumn: 'messageId',
|
||||
})
|
||||
@IsNullable()
|
||||
message: Relation<MessageObjectMetadata>;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceIsNotAuditLogged()
|
||||
@WorkspaceIsSystem()
|
||||
export class MessageChannelMessageAssociationObjectMetadata extends BaseWorkspaceEntity {
|
||||
@WorkspaceField({
|
||||
standardId:
|
||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_STANDARD_FIELD_IDS.messageExternalId,
|
||||
type: FieldMetadataType.TEXT,
|
||||
@ -55,22 +34,10 @@ export class MessageChannelMessageAssociationObjectMetadata extends BaseObjectMe
|
||||
description: 'Message id from the messaging provider',
|
||||
icon: 'IconHash',
|
||||
})
|
||||
@IsNullable()
|
||||
@WorkspaceIsNullable()
|
||||
messageExternalId: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId:
|
||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_STANDARD_FIELD_IDS.messageThread,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Message Thread Id',
|
||||
description: 'Message Thread Id',
|
||||
icon: 'IconHash',
|
||||
joinColumn: 'messageThreadId',
|
||||
})
|
||||
@IsNullable()
|
||||
messageThread: Relation<MessageThreadObjectMetadata>;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId:
|
||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_STANDARD_FIELD_IDS.messageThreadExternalId,
|
||||
type: FieldMetadataType.TEXT,
|
||||
@ -78,6 +45,47 @@ export class MessageChannelMessageAssociationObjectMetadata extends BaseObjectMe
|
||||
description: 'Thread id from the messaging provider',
|
||||
icon: 'IconHash',
|
||||
})
|
||||
@IsNullable()
|
||||
@WorkspaceIsNullable()
|
||||
messageThreadExternalId: string;
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId:
|
||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_STANDARD_FIELD_IDS.messageChannel,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
label: 'Message Channel Id',
|
||||
description: 'Message Channel Id',
|
||||
icon: 'IconHash',
|
||||
joinColumn: 'messageChannelId',
|
||||
inverseSideTarget: () => MessageChannelObjectMetadata,
|
||||
inverseSideFieldKey: 'messageChannelMessageAssociations',
|
||||
})
|
||||
@WorkspaceIsNullable()
|
||||
messageChannel: Relation<MessageChannelObjectMetadata>;
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_STANDARD_FIELD_IDS.message,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
label: 'Message Id',
|
||||
description: 'Message Id',
|
||||
icon: 'IconHash',
|
||||
joinColumn: 'messageId',
|
||||
inverseSideTarget: () => MessageObjectMetadata,
|
||||
inverseSideFieldKey: 'messageChannelMessageAssociations',
|
||||
})
|
||||
@WorkspaceIsNullable()
|
||||
message: Relation<MessageObjectMetadata>;
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId:
|
||||
MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_STANDARD_FIELD_IDS.messageThread,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
label: 'Message Thread Id',
|
||||
description: 'Message Thread Id',
|
||||
icon: 'IconHash',
|
||||
joinColumn: 'messageThreadId',
|
||||
inverseSideTarget: () => MessageThreadObjectMetadata,
|
||||
inverseSideFieldKey: 'messageChannelMessageAssociations',
|
||||
})
|
||||
@WorkspaceIsNullable()
|
||||
messageThread: Relation<MessageThreadObjectMetadata>;
|
||||
}
|
||||
|
||||
@ -7,15 +7,15 @@ import {
|
||||
} from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
||||
import { MESSAGE_CHANNEL_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 { 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';
|
||||
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 { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
|
||||
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
|
||||
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';
|
||||
|
||||
export enum MessageChannelSyncStatus {
|
||||
PENDING = 'PENDING',
|
||||
@ -35,7 +35,7 @@ export enum MessageChannelType {
|
||||
SMS = 'sms',
|
||||
}
|
||||
|
||||
@ObjectMetadata({
|
||||
@WorkspaceEntity({
|
||||
standardId: STANDARD_OBJECT_IDS.messageChannel,
|
||||
namePlural: 'messageChannels',
|
||||
labelSingular: 'Message Channel',
|
||||
@ -43,10 +43,10 @@ export enum MessageChannelType {
|
||||
description: 'Message Channels',
|
||||
icon: 'IconMessage',
|
||||
})
|
||||
@IsNotAuditLogged()
|
||||
@IsSystem()
|
||||
export class MessageChannelObjectMetadata extends BaseObjectMetadata {
|
||||
@FieldMetadata({
|
||||
@WorkspaceIsNotAuditLogged()
|
||||
@WorkspaceIsSystem()
|
||||
export class MessageChannelObjectMetadata extends BaseWorkspaceEntity {
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.visibility,
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Visibility',
|
||||
@ -76,7 +76,7 @@ export class MessageChannelObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
visibility: string;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.handle,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Handle',
|
||||
@ -85,17 +85,7 @@ export class MessageChannelObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
handle: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.connectedAccount,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Connected Account',
|
||||
description: 'Connected Account',
|
||||
icon: 'IconUserCircle',
|
||||
joinColumn: 'connectedAccountId',
|
||||
})
|
||||
connectedAccount: Relation<ConnectedAccountObjectMetadata>;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.type,
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Type',
|
||||
@ -119,7 +109,7 @@ export class MessageChannelObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
type: string;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.isContactAutoCreationEnabled,
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'Is Contact Auto Creation Enabled',
|
||||
@ -129,7 +119,7 @@ export class MessageChannelObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
isContactAutoCreationEnabled: boolean;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.isSyncEnabled,
|
||||
type: FieldMetadataType.BOOLEAN,
|
||||
label: 'Is Sync Enabled',
|
||||
@ -139,25 +129,7 @@ export class MessageChannelObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
isSyncEnabled: boolean;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId:
|
||||
MESSAGE_CHANNEL_STANDARD_FIELD_IDS.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: Relation<
|
||||
MessageChannelMessageAssociationObjectMetadata[]
|
||||
>;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.syncCursor,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Last sync cursor',
|
||||
@ -166,17 +138,17 @@ export class MessageChannelObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
syncCursor: string;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.syncedAt,
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Last sync date',
|
||||
description: 'Last sync date',
|
||||
icon: 'IconHistory',
|
||||
})
|
||||
@IsNullable()
|
||||
@WorkspaceIsNullable()
|
||||
syncedAt: string;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.syncStatus,
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Last sync status',
|
||||
@ -209,16 +181,43 @@ export class MessageChannelObjectMetadata extends BaseObjectMetadata {
|
||||
},
|
||||
],
|
||||
})
|
||||
@IsNullable()
|
||||
@WorkspaceIsNullable()
|
||||
syncStatus: MessageChannelSyncStatus;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.ongoingSyncStartedAt,
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Ongoing sync started at',
|
||||
description: 'Ongoing sync started at',
|
||||
icon: 'IconHistory',
|
||||
})
|
||||
@IsNullable()
|
||||
@WorkspaceIsNullable()
|
||||
ongoingSyncStartedAt: string;
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.connectedAccount,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
label: 'Connected Account',
|
||||
description: 'Connected Account',
|
||||
icon: 'IconUserCircle',
|
||||
joinColumn: 'connectedAccountId',
|
||||
inverseSideTarget: () => ConnectedAccountObjectMetadata,
|
||||
inverseSideFieldKey: 'messageChannels',
|
||||
})
|
||||
connectedAccount: Relation<ConnectedAccountObjectMetadata>;
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId:
|
||||
MESSAGE_CHANNEL_STANDARD_FIELD_IDS.messageChannelMessageAssociations,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
label: 'Message Channel Association',
|
||||
description: 'Messages from the channel.',
|
||||
icon: 'IconMessage',
|
||||
inverseSideTarget: () => MessageChannelMessageAssociationObjectMetadata,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
})
|
||||
@WorkspaceIsNullable()
|
||||
messageChannelMessageAssociations: Relation<
|
||||
MessageChannelMessageAssociationObjectMetadata[]
|
||||
>;
|
||||
}
|
||||
|
||||
@ -3,17 +3,19 @@ import { Relation } from 'src/engine/workspace-manager/workspace-sync-metadata/i
|
||||
import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { MESSAGE_PARTICIPANT_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 { 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';
|
||||
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 { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
|
||||
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';
|
||||
import { RelationMetadataType } from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
||||
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
|
||||
|
||||
@ObjectMetadata({
|
||||
@WorkspaceEntity({
|
||||
standardId: STANDARD_OBJECT_IDS.messageParticipant,
|
||||
namePlural: 'messageParticipants',
|
||||
labelSingular: 'Message Participant',
|
||||
@ -21,20 +23,10 @@ import { IsNotAuditLogged } from 'src/engine/workspace-manager/workspace-sync-me
|
||||
description: 'Message Participants',
|
||||
icon: 'IconUserCircle',
|
||||
})
|
||||
@IsNotAuditLogged()
|
||||
@IsSystem()
|
||||
export class MessageParticipantObjectMetadata extends BaseObjectMetadata {
|
||||
@FieldMetadata({
|
||||
standardId: MESSAGE_PARTICIPANT_STANDARD_FIELD_IDS.message,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Message',
|
||||
description: 'Message',
|
||||
icon: 'IconMessage',
|
||||
joinColumn: 'messageId',
|
||||
})
|
||||
message: Relation<MessageObjectMetadata>;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceIsNotAuditLogged()
|
||||
@WorkspaceIsSystem()
|
||||
export class MessageParticipantObjectMetadata extends BaseWorkspaceEntity {
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_PARTICIPANT_STANDARD_FIELD_IDS.role,
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Role',
|
||||
@ -50,7 +42,7 @@ export class MessageParticipantObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
role: string;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_PARTICIPANT_STANDARD_FIELD_IDS.handle,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Handle',
|
||||
@ -59,7 +51,7 @@ export class MessageParticipantObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
handle: string;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_PARTICIPANT_STANDARD_FIELD_IDS.displayName,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Display Name',
|
||||
@ -68,25 +60,41 @@ export class MessageParticipantObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
displayName: string;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_PARTICIPANT_STANDARD_FIELD_IDS.message,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
label: 'Message',
|
||||
description: 'Message',
|
||||
icon: 'IconMessage',
|
||||
joinColumn: 'messageId',
|
||||
inverseSideTarget: () => MessageObjectMetadata,
|
||||
inverseSideFieldKey: 'messageParticipants',
|
||||
})
|
||||
message: Relation<MessageObjectMetadata>;
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_PARTICIPANT_STANDARD_FIELD_IDS.person,
|
||||
type: FieldMetadataType.RELATION,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
label: 'Person',
|
||||
description: 'Person',
|
||||
icon: 'IconUser',
|
||||
joinColumn: 'personId',
|
||||
inverseSideTarget: () => PersonObjectMetadata,
|
||||
inverseSideFieldKey: 'messageParticipants',
|
||||
})
|
||||
@IsNullable()
|
||||
@WorkspaceIsNullable()
|
||||
person: Relation<PersonObjectMetadata>;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_PARTICIPANT_STANDARD_FIELD_IDS.workspaceMember,
|
||||
type: FieldMetadataType.RELATION,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
label: 'Workspace Member',
|
||||
description: 'Workspace member',
|
||||
icon: 'IconCircleUser',
|
||||
joinColumn: 'workspaceMemberId',
|
||||
inverseSideTarget: () => WorkspaceMemberObjectMetadata,
|
||||
inverseSideFieldKey: 'messageParticipants',
|
||||
})
|
||||
@IsNullable()
|
||||
@WorkspaceIsNullable()
|
||||
workspaceMember: Relation<WorkspaceMemberObjectMetadata>;
|
||||
}
|
||||
|
||||
@ -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[]
|
||||
>;
|
||||
|
||||
@ -7,18 +7,18 @@ import {
|
||||
} from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
||||
import { MESSAGE_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 { MessageParticipantObjectMetadata } from 'src/modules/messaging/standard-objects/message-participant.object-metadata';
|
||||
import { MessageThreadObjectMetadata } from 'src/modules/messaging/standard-objects/message-thread.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 { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.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.message,
|
||||
namePlural: 'messages',
|
||||
labelSingular: 'Message',
|
||||
@ -26,10 +26,10 @@ import { IsNotAuditLogged } from 'src/engine/workspace-manager/workspace-sync-me
|
||||
description: 'Message',
|
||||
icon: 'IconMessage',
|
||||
})
|
||||
@IsNotAuditLogged()
|
||||
@IsSystem()
|
||||
export class MessageObjectMetadata extends BaseObjectMetadata {
|
||||
@FieldMetadata({
|
||||
@WorkspaceIsNotAuditLogged()
|
||||
@WorkspaceIsSystem()
|
||||
export class MessageObjectMetadata extends BaseWorkspaceEntity {
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_STANDARD_FIELD_IDS.headerMessageId,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Header message Id',
|
||||
@ -38,18 +38,7 @@ export class MessageObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
headerMessageId: string;
|
||||
|
||||
@FieldMetadata({
|
||||
standardId: MESSAGE_STANDARD_FIELD_IDS.messageThread,
|
||||
type: FieldMetadataType.RELATION,
|
||||
label: 'Message Thread Id',
|
||||
description: 'Message Thread Id',
|
||||
icon: 'IconHash',
|
||||
joinColumn: 'messageThreadId',
|
||||
})
|
||||
@IsNullable()
|
||||
messageThread: Relation<MessageThreadObjectMetadata>;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_STANDARD_FIELD_IDS.direction,
|
||||
type: FieldMetadataType.SELECT,
|
||||
label: 'Direction',
|
||||
@ -63,7 +52,7 @@ export class MessageObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
direction: string;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_STANDARD_FIELD_IDS.subject,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Subject',
|
||||
@ -72,7 +61,7 @@ export class MessageObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
subject: string;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_STANDARD_FIELD_IDS.text,
|
||||
type: FieldMetadataType.TEXT,
|
||||
label: 'Text',
|
||||
@ -81,45 +70,52 @@ export class MessageObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
text: string;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceField({
|
||||
standardId: MESSAGE_STANDARD_FIELD_IDS.receivedAt,
|
||||
type: FieldMetadataType.DATE_TIME,
|
||||
label: 'Received At',
|
||||
description: 'The date the message was received',
|
||||
icon: 'IconCalendar',
|
||||
})
|
||||
@IsNullable()
|
||||
@WorkspaceIsNullable()
|
||||
receivedAt: string;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_STANDARD_FIELD_IDS.messageThread,
|
||||
type: RelationMetadataType.MANY_TO_ONE,
|
||||
label: 'Message Thread Id',
|
||||
description: 'Message Thread Id',
|
||||
icon: 'IconHash',
|
||||
joinColumn: 'messageThreadId',
|
||||
inverseSideTarget: () => MessageThreadObjectMetadata,
|
||||
inverseSideFieldKey: 'messages',
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
})
|
||||
@WorkspaceIsNullable()
|
||||
messageThread: Relation<MessageThreadObjectMetadata>;
|
||||
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_STANDARD_FIELD_IDS.messageParticipants,
|
||||
type: FieldMetadataType.RELATION,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
label: 'Message Participants',
|
||||
description: 'Message Participants',
|
||||
icon: 'IconUserCircle',
|
||||
})
|
||||
@RelationMetadata({
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
inverseSideTarget: () => MessageParticipantObjectMetadata,
|
||||
inverseSideFieldKey: 'message',
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
})
|
||||
@IsNullable()
|
||||
@WorkspaceIsNullable()
|
||||
messageParticipants: Relation<MessageParticipantObjectMetadata[]>;
|
||||
|
||||
@FieldMetadata({
|
||||
@WorkspaceRelation({
|
||||
standardId: MESSAGE_STANDARD_FIELD_IDS.messageChannelMessageAssociations,
|
||||
type: FieldMetadataType.RELATION,
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
label: 'Message Channel Association',
|
||||
description: 'Messages from the channel.',
|
||||
icon: 'IconMessage',
|
||||
})
|
||||
@RelationMetadata({
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
inverseSideTarget: () => MessageChannelMessageAssociationObjectMetadata,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
})
|
||||
@IsNullable()
|
||||
@WorkspaceIsNullable()
|
||||
messageChannelMessageAssociations: Relation<
|
||||
MessageChannelMessageAssociationObjectMetadata[]
|
||||
>;
|
||||
|
||||
Reference in New Issue
Block a user