Skip to content

The open alternative to Salesforce, designed for AI.

Create new sync statuses and stages for calendar (#5997)

bosiraphaelf3701281e9ec
diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids.ts
index 21910d0a758..402fc905f9e 100644
--- a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids.ts
@@ -71,6 +71,9 @@ export const CALENDAR_CHANNEL_STANDARD_FIELD_IDS = {
syncCursor: '20202020-bac2-4852-a5cb-7a7898992b70',
calendarChannelEventAssociations: '20202020-afb0-4a9f-979f-2d5087d71d09',
throttleFailureCount: '20202020-525c-4b76-b9bd-0dd57fd11d61',
+ syncStatus: '20202020-7116-41da-8b4b-035975c4eb6a',
+ syncStage: '20202020-6246-42e6-b5cd-003bd921782c',
+ syncStageStartedAt: '20202020-a934-46f1-a8e7-9568b1e3a53e',
};
export const CALENDAR_EVENT_PARTICIPANT_STANDARD_FIELD_IDS = {
diff --git a/packages/twenty-server/src/modules/calendar/standard-objects/calendar-channel.workspace-entity.ts b/packages/twenty-server/src/modules/calendar/standard-objects/calendar-channel.workspace-entity.ts
index 85aed3b43c9..c72af80f87f 100644
--- a/packages/twenty-server/src/modules/calendar/standard-objects/calendar-channel.workspace-entity.ts
+++ b/packages/twenty-server/src/modules/calendar/standard-objects/calendar-channel.workspace-entity.ts
@@ -15,12 +15,30 @@ import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is
import { WorkspaceIsNotAuditLogged } from 'src/engine/twenty-orm/decorators/workspace-is-not-audit-logged.decorator';
import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';
+import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
export enum CalendarChannelVisibility {
METADATA = 'METADATA',
SHARE_EVERYTHING = 'SHARE_EVERYTHING',
}
+export enum CalendarChannelSyncStatus {
+ NOT_SYNCED = 'NOT_SYNCED',
+ ONGOING = 'ONGOING',
+ ACTIVE = 'ACTIVE',
+ FAILED_INSUFFICIENT_PERMISSIONS = 'FAILED_INSUFFICIENT_PERMISSIONS',
+ FAILED_UNKNOWN = 'FAILED_UNKNOWN',
+}
+
+export enum CalendarChannelSyncStage {
+ FULL_CALENDAR_EVENT_LIST_FETCH_PENDING = 'FULL_CALENDAR_EVENT_LIST_FETCH_PENDING',
+ PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING = 'PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING',
+ CALENDAR_EVENT_LIST_FETCH_ONGOING = 'CALENDAR_EVENT_LIST_FETCH_ONGOING',
+ CALENDAR_EVENTS_IMPORT_PENDING = 'CALENDAR_EVENTS_IMPORT_PENDING',
+ CALENDAR_EVENTS_IMPORT_ONGOING = 'CALENDAR_EVENTS_IMPORT_ONGOING',
+ FAILED = 'FAILED',
+}
+
@WorkspaceEntity({
standardId: STANDARD_OBJECT_IDS.calendarChannel,
namePlural: 'calendarChannels',
@@ -41,6 +59,97 @@ export class CalendarChannelWorkspaceEntity extends BaseWorkspaceEntity {
})
handle: string;
+ @WorkspaceField({
+ standardId: CALENDAR_CHANNEL_STANDARD_FIELD_IDS.syncStatus,
+ type: FieldMetadataType.SELECT,
+ label: 'Sync status',
+ description: 'Sync status',
+ icon: 'IconStatusChange',
+ options: [
+ {
+ value: CalendarChannelSyncStatus.ONGOING,
+ label: 'Ongoing',
+ position: 1,
+ color: 'yellow',
+ },
+ {
+ value: CalendarChannelSyncStatus.NOT_SYNCED,
+ label: 'Not Synced',
+ position: 2,
+ color: 'blue',
+ },
+ {
+ value: CalendarChannelSyncStatus.ACTIVE,
+ label: 'Active',
+ position: 3,
+ color: 'green',
+ },
+ {
+ value: CalendarChannelSyncStatus.FAILED_INSUFFICIENT_PERMISSIONS,
+ label: 'Failed Insufficient Permissions',
+ position: 4,
+ color: 'red',
+ },
+ {
+ value: CalendarChannelSyncStatus.FAILED_UNKNOWN,
+ label: 'Failed Unknown',
+ position: 5,
+ color: 'red',
+ },
+ ],
+ })
+ @WorkspaceIsNullable()
+ syncStatus: CalendarChannelSyncStatus | null;
+
+ @WorkspaceField({
+ standardId: CALENDAR_CHANNEL_STANDARD_FIELD_IDS.syncStage,
+ type: FieldMetadataType.SELECT,
+ label: 'Sync stage',
+ description: 'Sync stage',
+ icon: 'IconStatusChange',
+ options: [
+ {
+ value: CalendarChannelSyncStage.FULL_CALENDAR_EVENT_LIST_FETCH_PENDING,
+ label: 'Full calendar event list fetch pending',
+ position: 0,
+ color: 'blue',
+ },
+ {
+ value:
+ CalendarChannelSyncStage.PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING,
+ label: 'Partial calendar event list fetch pending',
+ position: 1,
+ color: 'blue',
+ },
+ {
+ value: CalendarChannelSyncStage.CALENDAR_EVENT_LIST_FETCH_ONGOING,
+ label: 'Calendar event list fetch ongoing',
+ position: 2,
+ color: 'orange',
+ },
+ {
+ value: CalendarChannelSyncStage.CALENDAR_EVENTS_IMPORT_PENDING,
+ label: 'Calendar events import pending',
+ position: 3,
+ color: 'blue',
+ },
+ {
+ value: CalendarChannelSyncStage.CALENDAR_EVENTS_IMPORT_ONGOING,
+ label: 'Calendar events import ongoing',
+ position: 4,
+ color: 'orange',
+ },
+ {
+ value: CalendarChannelSyncStage.FAILED,
+ label: 'Failed',
+ position: 5,
+ color: 'red',
+ },
+ ],
+ defaultValue: `'${CalendarChannelSyncStage.FULL_CALENDAR_EVENT_LIST_FETCH_PENDING}'`,
+ })
+ syncStage: CalendarChannelSyncStage;
+
@WorkspaceField({
standardId: CALENDAR_CHANNEL_STANDARD_FIELD_IDS.visibility,
type: FieldMetadataType.SELECT,
@@ -96,6 +205,16 @@ export class CalendarChannelWorkspaceEntity extends BaseWorkspaceEntity {
})
syncCursor: string;
+ @WorkspaceField({
+ standardId: CALENDAR_CHANNEL_STANDARD_FIELD_IDS.syncStageStartedAt,
+ type: FieldMetadataType.DATE_TIME,
+ label: 'Sync stage started at',
+ description: 'Sync stage started at',
+ icon: 'IconHistory',
+ })
+ @WorkspaceIsNullable()
+ syncStageStartedAt: string | null;
+
@WorkspaceField({
standardId: CALENDAR_CHANNEL_STANDARD_FIELD_IDS.throttleFailureCount,
type: FieldMetadataType.NUMBER,