- Notifications
You must be signed in to change notification settings - Fork50
:sparkles feat(sub-calendars): use event schema WIP#1163
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull Request Overview
This PR migrates the codebase to use a new event schema that supports sub-calendars, moving away from user-based event organization to a calendar-based approach. The changes consolidate event-related types and update import paths to reflect the new schema structure.
Key changes:
- Migrated
Categories_Eventand related enums from@core/types/event.typesto@web/common/types/web.event.types - Updated event date handling to use native
Dateobjects instead of string-based date formats - Removed several deprecated types and utility functions related to the old event schema
- Updated import paths across the codebase to reflect the new type locations
Reviewed Changes
Copilot reviewed 168 out of 168 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/web/src/common/types/web.event.types.ts | DefinedCategories_Event enum and updated schema definitions for web events |
| packages/core/src/types/event.types.ts | RemovedCategories_Event enum and consolidated event schemas with calendar support |
| packages/web/src/views/Forms/EventForm/DateControlsSection/RecurrenceSection/useRecurrence/useRecurrence.ts | Updated to useDate objects instead of string-based dates |
| packages/core/src/util/event/event.util.ts | Removed deprecated date parsing functions and updated event categorization logic |
| packages/core/src/mappers/map.event.ts | Simplified mapper to remove provider data methods and consolidate metadata handling |
| packages/backend/src/user/services/user.service.ts | Updated user service methods to useObjectId instead of strings |
| packages/scripts/src/migrations/*.ts | Updated migration scripts to use new event schema |
| Event_Core, | ||
| Schema_Event, | ||
| }from"@core/types/event.types"; | ||
| import{Event_Core,Schema_Event}from"@core/types/event.types"; |
CopilotAIOct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The function referencesEventSchema but it's not imported. This will cause a runtime error. ImportEventSchema from@core/types/event.types.
| import{Event_Core,Schema_Event}from"@core/types/event.types"; | |
| import{Event_Core,Schema_Event,EventSchema}from"@core/types/event.types"; |
| constdbUser=awaitmongoService.user.findOne({ _id}); | ||
| constevents=this.#generateEvents(userId); |
CopilotAIOct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
VariableuserId is used but never defined. It should be_id.toString() or the result should be assigned to auserId variable after line 138.
| ); | ||
| awaituserService.saveTimeFor("lastLoggedInAt",userId); | ||
| awaituserService.updateLastLoggedInTime("lastLoggedInAt",userId); |
CopilotAIOct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The method signature appears incorrect. Based on the changes inuser.service.ts,updateLastLoggedInTime now takes only one parameter (userId as ObjectId), but here it's called with two string parameters.
| awaituserService.updateLastLoggedInTime("lastLoggedInAt",userId); | |
| awaituserService.updateLastLoggedInTime(mongoService.objectId(userId)); |
| for(constuserofusers){ | ||
| constuserId=user?._id.toString(); | ||
| constsummary=awaituserService.deleteCompassDataForUser(userId); | ||
| constsummary=awaituserService.deleteCompassDataForUser(user._id); |
CopilotAIOct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Theuser._id field is already anObjectId from the database query, but the iteration variableuser shadows the outer scopeuser parameter (which is a string). This creates confusion. Consider renaming the loop variable todbUser for clarity.
9bafc94 to085f0aeCompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull Request Overview
Copilot reviewed 184 out of 184 changed files in this pull request and generated 29 comments.
Comments suppressed due to low confidence (1)
packages/backend/src/sync/services/sync/tests/compass.sync.processor.all-event.test.ts:1
- More references to removed properties:
gRecurringEventId,gEventId, anduserthat need to be updated to use the new metadata structure (metadata.recurringEventId,metadata.id) and calendar-based associations.
import { ObjectId } from "mongodb";| constuserId=(awaitthis.#findUserOrThrow(user!))._id.toString(); | ||
| constdbUser=awaitmongoService.user.findOne({ _id}); | ||
| constevents=this.#generateEvents(userId); |
CopilotAIOct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
VariableuserId is used on line 139 but is no longer defined after the changes. The code now uses_id anddbUser, butuserId needs to be extracted from one of these. This will cause a ReferenceError.
| constevents=this.#generateEvents(userId); | |
| constevents=this.#generateEvents(dbUser._id.toString()); |
| summary:"New Standalone Event", | ||
| }); | ||
| constprocessor=newGcalSyncProcessor(user._id.toString()); | ||
| constprocessor=newGcalEventsSyncProcessor(user._id.toString()); |
CopilotAIOct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The constructor signature changed to accept a calendar object instead of a user ID string. This call should pass a calendar object but is still passinguser._id.toString(). This will cause a type error.
| /* Act */ | ||
| constprocessor=newGcalSyncProcessor(user._id.toString()); | ||
| constprocessor=newGcalEventsSyncProcessor(user._id.toString()); |
CopilotAIOct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The constructor signature changed to accept a calendar object, but this is still passing a user ID string. This needs to be updated to pass a calendar object consistent with the new architecture.
| constprocessor=newGcalEventsSyncProcessor(user._id.toString()); | |
| constprocessor=newGcalEventsSyncProcessor(calendar); |
| /* Act */ | ||
| constprocessor=newGcalSyncProcessor(user._id.toString()); | ||
| constprocessor=newGcalEventsSyncProcessor(user._id.toString()); |
CopilotAIOct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Multiple instances whereGcalEventsSyncProcessor is constructed with a user ID string instead of a calendar object. All these need to be updated to match the new constructor signature.
| }; | ||
| constprocessor=newGcalSyncProcessor(user._id.toString()); | ||
| constprocessor=newGcalEventsSyncProcessor(user._id.toString()); |
CopilotAIOct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Multiple instances whereGcalEventsSyncProcessor is constructed with a user ID string instead of a calendar object. All these need to be updated to match the new constructor signature.
| constprocessor=newGcalEventsSyncProcessor(user._id.toString()); | |
| constcalendar=awaitCalendarDriver.getByUserId(user._id); | |
| constprocessor=newGcalEventsSyncProcessor(calendar); |
| _getGcal(user,instanceUpdate!.gRecurringEventId!), | ||
| EventDriver.getGCalEvent( | ||
| user, | ||
| instanceUpdate!.gRecurringEventId!, |
CopilotAIOct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
More references to removed properties:gRecurringEventId,gEventId, anduser that need to be updated to use the new metadata structure (metadata.recurringEventId,metadata.id) and calendar-based associations.
| newInstances.map((instance)=> | ||
| expect(_getGcal(user,instance.gEventId!)).rejects.toThrow( | ||
| expect( | ||
| EventDriver.getGCalEvent(user,instance.gEventId!), |
CopilotAIOct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
More references to removed properties:gRecurringEventId,gEventId, anduser that need to be updated to use the new metadata structure (metadata.recurringEventId,metadata.id) and calendar-based associations.
| gcalInstances.map(()=> | ||
| expect.objectContaining({ | ||
| recurringEventId:event!.gEventId, | ||
| recurringEventId:event.metadata?.id, |
CopilotAIOct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
More references to removed properties:gRecurringEventId,gEventId, anduser that need to be updated to use the new metadata structure (metadata.recurringEventId,metadata.id) and calendar-based associations.
| recurringEventId:event.metadata?.id, | |
| recurringEventId:event.metadata?.recurringEventId, |
| _getGcal(updatedPayload.user!,updatedPayload.gEventId!), | ||
| EventDriver.getGCalEvent( | ||
| updatedPayload.user!, | ||
| updatedPayload.gEventId!, |
CopilotAIOct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
More references to removed properties:gRecurringEventId,gEventId, anduser that need to be updated to use the new metadata structure (metadata.recurringEventId,metadata.id) and calendar-based associations.
| instances.map((instance)=> | ||
| expect( | ||
| _getGcal(instance.user!,instance.gEventId!), | ||
| EventDriver.getGCalEvent(instance.user!,instance.gEventId!), |
CopilotAIOct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
More references to removed properties:gRecurringEventId,gEventId, anduser that need to be updated to use the new metadata structure (metadata.recurringEventId,metadata.id) and calendar-based associations.
085f0ae tod0b6831Compared0b6831 to36abb72CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull Request Overview
Copilot reviewed 104 out of 194 changed files in this pull request and generated 9 comments.
| constevents=awaitgetEventsInDb({calendar:calendar._id, isSomeday}); | ||
| consttypeFilter=type==="ALLDAY" ?isAllDay :isInstance; | ||
| constinstanceEvents=events.filter(isInstance).filter(typeFilter); | ||
| console.log("Events:",events.filter(isInstance)); |
CopilotAIOct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Remove debug console.log statement from production code
| console.log("Events:", events.filter(isInstance)); |
| constupdateChanges=awaitCompassSyncProcessor.processEvents([ | ||
| { | ||
| payload:updatedPayloadasCompassThisEvent["payload"], | ||
| payload, |
CopilotAIOct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The payload should beupdatedPayload instead of the originalpayload to match the test's intent of updating the priority field
| payload, | |
| payload:updatedPayload, |
| constupdateChanges=awaitCompassSyncProcessor.processEvents([ | ||
| { | ||
| payload:updatedPayloadasCompassThisEvent["payload"], | ||
| payload, |
CopilotAIOct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The payload should beupdatedPayload instead of the originalpayload to match the test's intent of updating the endDate field
| payload, | |
| payload:updatedPayload, |
| constcalendar=awaitCalendarDriver.getRandomUserCalendar(_user._id); | ||
| constisSomeday=false; | ||
| constrecurrence={rule:["RRULE:FREQ=WEEKLY;COUNT=10"]}; | ||
| constpayload=createMockBaseEvent({ isSomeday, user, recurrence}); |
CopilotAIOct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The parameter should becalendar: calendar._id instead ofuser to match the updated API signature
| constpayload=createMockBaseEvent({ isSomeday,user, recurrence}); | |
| constpayload=createMockBaseEvent({ isSomeday,calendar:calendar._id, recurrence}); |
| // check that event is deleted in db | ||
| awaitexpect( | ||
| eventService.readById(user,deletedInstanceId), | ||
| eventService.readById(calendar,deletedInstanceId), |
CopilotAIOct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The first parameter should becalendar._id instead ofcalendar to match the service's expected signature
| eventService.readById(calendar,deletedInstanceId), | |
| eventService.readById(calendar._id,deletedInstanceId), |
| constupdateChanges=awaitCompassSyncProcessor.processEvents([ | ||
| { | ||
| payload:updatedPayloadasCompassAllEvents["payload"], | ||
| user:_user._id, |
CopilotAIOct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This field should not be present in the event payload as it's now handled through the calendar parameter
| user: _user._id, |
| conststatus=CompassEventStatus.CONFIRMED; | ||
| const_user=awaitAuthDriver.googleSignup(); | ||
| constcalendar=awaitCalendarDriver.getRandomUserCalendar(user._id); | ||
| conststatus=EventStatus.CONFIRMED; |
CopilotAIOct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The status variable is declared but not used in the test. Either use it or remove the declaration
| const status = EventStatus.CONFIRMED; |
| constuser=_user._id.toString(); | ||
| conststatus=CompassEventStatus.CONFIRMED; | ||
| const_user=awaitAuthDriver.googleSignup(); | ||
| constcalendar=awaitCalendarDriver.getRandomUserCalendar(user._id); |
CopilotAIOct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The variable should be_user._id instead ofuser._id to match the declared variable name
| constcalendar=awaitCalendarDriver.getRandomUserCalendar(user._id); | |
| constcalendar=awaitCalendarDriver.getRandomUserCalendar(_user._id); |
| constcalendar=awaitCalendarDriver.getRandomUserCalendar(user._id); | ||
| conststatus=EventStatus.CONFIRMED; | ||
| constrecurrence={rule:["RRULE:FREQ=WEEKLY;COUNT=10"]}; | ||
| constpayload=createMockBaseEvent({ recurrence, user}); |
CopilotAIOct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The parameter should becalendar: calendar._id instead ofuser to match the updated API signature
| constcalendar=awaitCalendarDriver.getRandomUserCalendar(user._id); | |
| conststatus=EventStatus.CONFIRMED; | |
| constrecurrence={rule:["RRULE:FREQ=WEEKLY;COUNT=10"]}; | |
| constpayload=createMockBaseEvent({ recurrence,user}); | |
| constcalendar=awaitCalendarDriver.getRandomUserCalendar(_user._id); | |
| conststatus=EventStatus.CONFIRMED; | |
| constrecurrence={rule:["RRULE:FREQ=WEEKLY;COUNT=10"]}; | |
| constpayload=createMockBaseEvent({ recurrence,calendar:calendar._id}); |
36abb72 tod27d482Compared27d482 to20e53cbCompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull Request Overview
Copilot reviewed 103 out of 256 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
packages/backend/src/sync/services/sync/tests/compass-sync-processor-this-event/instance.test.ts:1
- Debug console.log statement should be removed from production code. This appears to be leftover debug code that should be cleaned up.
import { faker } from "@faker-js/faker";| ` | ||
| ImportAllEvents completed for calendar(${calendar._id.toString()}). |
CopilotAINov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
[nitpick] The template literal has an unnecessary leading newline character. The backtick should be placed directly after the opening parenthesis for better code formatting.
| ` | |
| ImportAllEventscompletedforcalendar(${calendar._id.toString()}). | |
| `ImportAllEvents completed for calendar(${calendar._id.toString()}). |
What does this PR do?
This PR migrates the codebase to use the new event's schema with sub-calendar support.
Use Case
closes#1135