Skip to content

Commit

Permalink
4283 create calendareventattendee data model (twentyhq#4333)
Browse files Browse the repository at this point in the history
* add person relation

* add workspaceMember relation

* done

* update channel

* update event data-model

* add relation

* done

* changes after review

* update model
  • Loading branch information
bosiraphael authored Mar 6, 2024
1 parent ce2901b commit b270843
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { ObjectMetadata } from 'src/workspace/workspace-sync-metadata/decorators
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';

export enum CalendarChannelVisibility {
METADATA = 'METADATA',
SHARE_EVERYTHING = 'SHARE_EVERYTHING',
}

@ObjectMetadata({
namePlural: 'calendarChannels',
labelSingular: 'Calendar Channel',
Expand Down Expand Up @@ -42,15 +47,20 @@ export class CalendarChannelObjectMetadata extends BaseObjectMetadata {
description: 'Visibility',
icon: 'IconEyeglass',
options: [
{ value: 'metadata', label: 'Metadata', position: 0, color: 'green' },
{
value: 'share_everything',
value: CalendarChannelVisibility.METADATA,
label: 'Metadata',
position: 0,
color: 'green',
},
{
value: CalendarChannelVisibility.SHARE_EVERYTHING,
label: 'Share Everything',
position: 1,
color: 'orange',
},
],
defaultValue: { value: 'share_everything' },
defaultValue: { value: CalendarChannelVisibility.SHARE_EVERYTHING },
})
visibility: string;

Expand All @@ -74,9 +84,10 @@ export class CalendarChannelObjectMetadata extends BaseObjectMetadata {

@FieldMetadata({
type: FieldMetadataType.TEXT,
label: 'Next Sync Token',
description: 'Next Sync Token',
label: 'Sync Cursor',
description:
'Sync Cursor. Used for syncing events from the calendar provider',
icon: 'IconReload',
})
nextSyncToken: string;
syncCursor: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
import { Gate } from 'src/workspace/workspace-sync-metadata/decorators/gate.decorator';
import { IsNullable } from 'src/workspace/workspace-sync-metadata/decorators/is-nullable.decorator';
import { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.decorator';
import { ObjectMetadata } from 'src/workspace/workspace-sync-metadata/decorators/object-metadata.decorator';
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
import { CalendarEventObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/calendar-event.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';

export enum CalendarEventAttendeeResponseStatus {
NEEDS_ACTION = 'NEEDS_ACTION',
DECLINED = 'DECLINED',
TENTATIVE = 'TENTATIVE',
ACCEPTED = 'ACCEPTED',
}

@ObjectMetadata({
namePlural: 'calendarEventAttendees',
labelSingular: 'Calendar event attendee',
labelPlural: 'Calendar event attendees',
description: 'Calendar event attendees',
icon: 'IconCalendar',
})
@IsSystem()
@Gate({
featureFlag: 'IS_CALENDAR_ENABLED',
})
export class CalendarEventAttendeeObjectMetadata extends BaseObjectMetadata {
@FieldMetadata({
type: FieldMetadataType.RELATION,
label: 'Event ID',
description: 'Event ID',
icon: 'IconCalendar',
joinColumn: 'calendarEventId',
})
calendarEvent: CalendarEventObjectMetadata;

@FieldMetadata({
type: FieldMetadataType.TEXT,
label: 'Handle',
description: 'Handle',
icon: 'IconMail',
})
handle: string;

@FieldMetadata({
type: FieldMetadataType.TEXT,
label: 'Display Name',
description: 'Display Name',
icon: 'IconUser',
})
displayName: string;

@FieldMetadata({
type: FieldMetadataType.BOOLEAN,
label: 'Is Organizer',
description: 'Is Organizer',
icon: 'IconUser',
})
isOrganizer: boolean;

@FieldMetadata({
type: FieldMetadataType.SELECT,
label: 'Response Status',
description: 'Response Status',
icon: 'IconUser',
options: [
{
value: CalendarEventAttendeeResponseStatus.NEEDS_ACTION,
label: 'Needs Action',
position: 0,
color: 'orange',
},
{
value: CalendarEventAttendeeResponseStatus.DECLINED,
label: 'Declined',
position: 1,
color: 'red',
},
{
value: CalendarEventAttendeeResponseStatus.TENTATIVE,
label: 'Tentative',
position: 2,
color: 'yellow',
},
{
value: CalendarEventAttendeeResponseStatus.ACCEPTED,
label: 'Accepted',
position: 3,
color: 'green',
},
],
defaultValue: { value: CalendarEventAttendeeResponseStatus.NEEDS_ACTION },
})
responseStatus: 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: 'IconUser',
joinColumn: 'workspaceMemberId',
})
@IsNullable()
workspaceMember: WorkspaceMemberObjectMetadata;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { RelationMetadata } from 'src/workspace/workspace-sync-metadata/decorators/relation-metadata.decorator';
import { FeatureFlagKeys } from 'src/core/feature-flag/feature-flag.entity';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import {
RelationMetadataType,
RelationOnDeleteAction,
} from 'src/metadata/relation-metadata/relation-metadata.entity';
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
import { Gate } from 'src/workspace/workspace-sync-metadata/decorators/gate.decorator';
import { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.decorator';
import { ObjectMetadata } from 'src/workspace/workspace-sync-metadata/decorators/object-metadata.decorator';
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';

export enum CalendarEventStatus {
CONFIRMED = 'CONFIRMED',
TENTATIVE = 'TENTATIVE',
CANCELED = 'CANCELED',
}
import { CalendarEventAttendeeObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/calendar-event-attendee.object-metadata';

@ObjectMetadata({
namePlural: 'calendarEvents',
Expand All @@ -33,33 +33,12 @@ export class CalendarEventObjectMetadata extends BaseObjectMetadata {
title: string;

@FieldMetadata({
type: FieldMetadataType.SELECT,
label: 'Status',
description: 'Status',
icon: 'IconCheckbox',
options: [
{
value: CalendarEventStatus.CONFIRMED,
label: 'Confirmed',
position: 0,
color: 'green',
},
{
value: CalendarEventStatus.TENTATIVE,
label: 'Tentative',
position: 1,
color: 'blue',
},
{
value: CalendarEventStatus.CANCELED,
label: 'Canceled',
position: 2,
color: 'red',
},
],
defaultValue: { value: CalendarEventStatus.CONFIRMED },
type: FieldMetadataType.BOOLEAN,
label: 'Is canceled',
description: 'Is canceled',
icon: 'IconCalendarCancel',
})
status: string;
isCanceled: boolean;

@FieldMetadata({
type: FieldMetadataType.BOOLEAN,
Expand Down Expand Up @@ -148,4 +127,17 @@ export class CalendarEventObjectMetadata extends BaseObjectMetadata {
icon: 'IconHistory',
})
recurringEventExternalId: string;

@FieldMetadata({
type: FieldMetadataType.RELATION,
label: 'Event Attendees',
description: 'Event Attendees',
icon: 'IconUserCircle',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
objectName: 'calendarEventAttendee',
onDelete: RelationOnDeleteAction.CASCADE,
})
eventAttendees: CalendarEventAttendeeObjectMetadata[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { AttachmentObjectMetadata } from 'src/workspace/workspace-sync-metadata/
import { BlocklistObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/blocklist.object-metadata';
import { CalendarEventObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/calendar-event.object-metadata';
import { CalendarChannelObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/calendar-channel.object-metadata';
import { CalendarEventAttendeeObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/calendar-event-attendee.object-metadata';
import { CommentObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/comment.object-metadata';
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';
Expand Down Expand Up @@ -50,4 +51,5 @@ export const standardObjectMetadataCollection = [
MessageChannelMessageAssociationObjectMetadata,
CalendarEventObjectMetadata,
CalendarChannelObjectMetadata,
CalendarEventAttendeeObjectMetadata,
];
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import {
RelationOnDeleteAction,
} from 'src/metadata/relation-metadata/relation-metadata.entity';
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
import { Gate } from 'src/workspace/workspace-sync-metadata/decorators/gate.decorator';
import { IsNullable } from 'src/workspace/workspace-sync-metadata/decorators/is-nullable.decorator';
import { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.decorator';
import { ObjectMetadata } from 'src/workspace/workspace-sync-metadata/decorators/object-metadata.decorator';
import { RelationMetadata } from 'src/workspace/workspace-sync-metadata/decorators/relation-metadata.decorator';
import { ActivityTargetObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/activity-target.object-metadata';
import { AttachmentObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/attachment.object-metadata';
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
import { CalendarEventAttendeeObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/calendar-event-attendee.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 { MessageParticipantObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-participant.object-metadata';
Expand Down Expand Up @@ -112,7 +114,6 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
icon: 'IconBuildingSkyscraper',
joinColumn: 'companyId',
})
@IsNullable()
company: CompanyObjectMetadata;

@FieldMetadata({
Expand All @@ -126,7 +127,6 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
objectName: 'opportunity',
inverseSideFieldName: 'pointOfContact',
})
@IsNullable()
pointOfContactForOpportunities: OpportunityObjectMetadata[];

@FieldMetadata({
Expand All @@ -140,7 +140,6 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
objectName: 'activityTarget',
onDelete: RelationOnDeleteAction.CASCADE,
})
@IsNullable()
activityTargets: ActivityTargetObjectMetadata[];

@FieldMetadata({
Expand All @@ -154,7 +153,6 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
objectName: 'favorite',
onDelete: RelationOnDeleteAction.CASCADE,
})
@IsNullable()
favorites: FavoriteObjectMetadata[];

@FieldMetadata({
Expand All @@ -168,7 +166,6 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
objectName: 'attachment',
onDelete: RelationOnDeleteAction.CASCADE,
})
@IsNullable()
attachments: AttachmentObjectMetadata[];

@FieldMetadata({
Expand All @@ -182,6 +179,21 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
objectName: 'messageParticipant',
inverseSideFieldName: 'person',
})
@IsNullable()
messageParticipants: MessageParticipantObjectMetadata[];

@FieldMetadata({
type: FieldMetadataType.RELATION,
label: 'Calendar Event Attendees',
description: 'Calendar Event Attendees',
icon: 'IconCalendar',
})
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
objectName: 'calendarEventAttendee',
inverseSideFieldName: 'person',
})
@Gate({
featureFlag: 'IS_CALENDAR_ENABLED',
})
calendarEventAttendees: CalendarEventAttendeeObjectMetadata[];
}
Loading

0 comments on commit b270843

Please sign in to comment.