Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4283 create calendareventattendee data model #4333

Merged
merged 10 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this was not needed in the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe needed for the way we display events (first person to appear on the right)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we confirm with @Bonapara? The closest thing to this field would be "role" inside messageParticipant where we need to display from/to/bcc/etc differently but here I'm not sure

Copy link
Member

@Weiko Weiko Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed offline, ok lgtm


@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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's create an enum here too? Also I feel like "response" is not really clear, is it "availability status" or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Availability is another concept, it could be interpreted as "is the person available" rather than "is the person coming to the event"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Availability is another concept, it could be interpreted as "is the person available" rather than "is the person coming to the event"

That's true 👍 @bosiraphael


@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
Loading