-
Notifications
You must be signed in to change notification settings - Fork 0
Async import of the appStore packages #10
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
base: appstore-sync-refactor-base
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,63 +1,33 @@ | ||
| // import * as example from "./_example"; | ||
| import * as applecalendar from "./applecalendar"; | ||
| import * as caldavcalendar from "./caldavcalendar"; | ||
| import * as closecom from "./closecom"; | ||
| import * as dailyvideo from "./dailyvideo"; | ||
| import * as exchange2013calendar from "./exchange2013calendar"; | ||
| import * as exchange2016calendar from "./exchange2016calendar"; | ||
| import * as exchangecalendar from "./exchangecalendar"; | ||
| import * as facetime from "./facetime"; | ||
| import * as giphy from "./giphy"; | ||
| import * as googlecalendar from "./googlecalendar"; | ||
| import * as googlevideo from "./googlevideo"; | ||
| import * as hubspot from "./hubspot"; | ||
| import * as huddle01video from "./huddle01video"; | ||
| import * as jitsivideo from "./jitsivideo"; | ||
| import * as larkcalendar from "./larkcalendar"; | ||
| import * as office365calendar from "./office365calendar"; | ||
| import * as office365video from "./office365video"; | ||
| import * as plausible from "./plausible"; | ||
| import * as salesforce from "./salesforce"; | ||
| import * as sendgrid from "./sendgrid"; | ||
| import * as stripepayment from "./stripepayment"; | ||
| import * as sylapsvideo from "./sylapsvideo"; | ||
| import * as tandemvideo from "./tandemvideo"; | ||
| import * as vital from "./vital"; | ||
| import * as wipemycalother from "./wipemycalother"; | ||
| import * as zapier from "./zapier"; | ||
| import * as zohocrm from "./zohocrm"; | ||
| import * as zoomvideo from "./zoomvideo"; | ||
|
|
||
| const appStore = { | ||
| // example, | ||
| applecalendar, | ||
| caldavcalendar, | ||
| closecom, | ||
| dailyvideo, | ||
| googlecalendar, | ||
| googlevideo, | ||
| hubspot, | ||
| huddle01video, | ||
| jitsivideo, | ||
| sylapsvideo, | ||
| larkcalendar, | ||
| office365calendar, | ||
| office365video, | ||
| plausible, | ||
| salesforce, | ||
| zohocrm, | ||
| sendgrid, | ||
| stripepayment, | ||
| tandemvideo, | ||
| vital, | ||
| zoomvideo, | ||
| wipemycalother, | ||
| giphy, | ||
| zapier, | ||
| exchange2013calendar, | ||
| exchange2016calendar, | ||
| exchangecalendar, | ||
| facetime, | ||
| // example: import("./example"), | ||
| applecalendar: import("./applecalendar"), | ||
| caldavcalendar: import("./caldavcalendar"), | ||
| closecom: import("./closecom"), | ||
| dailyvideo: import("./dailyvideo"), | ||
| googlecalendar: import("./googlecalendar"), | ||
| googlevideo: import("./googlevideo"), | ||
| hubspot: import("./hubspot"), | ||
| huddle01video: import("./huddle01video"), | ||
| jitsivideo: import("./jitsivideo"), | ||
| larkcalendar: import("./larkcalendar"), | ||
| office365calendar: import("./office365calendar"), | ||
| office365video: import("./office365video"), | ||
| plausible: import("./plausible"), | ||
| salesforce: import("./salesforce"), | ||
| zohocrm: import("./zohocrm"), | ||
| sendgrid: import("./sendgrid"), | ||
| stripepayment: import("./stripepayment"), | ||
| tandemvideo: import("./tandemvideo"), | ||
| vital: import("./vital"), | ||
| zoomvideo: import("./zoomvideo"), | ||
| wipemycalother: import("./wipemycalother"), | ||
| giphy: import("./giphy"), | ||
| zapier: import("./zapier"), | ||
| exchange2013calendar: import("./exchange2013calendar"), | ||
| exchange2016calendar: import("./exchange2016calendar"), | ||
| exchangecalendar: import("./exchangecalendar"), | ||
| facetime: import("./facetime"), | ||
| sylapsvideo: import("./sylapsvideo"), | ||
| }; | ||
|
|
||
| export default appStore; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,7 +240,7 @@ async function handler(req: CustomRequest) { | |
| integrationsToDelete.push(deleteMeeting(credential, reference.uid)); | ||
| } | ||
| if (reference.type.includes("_calendar")) { | ||
| const calendar = getCalendar(credential); | ||
| const calendar = await getCalendar(credential); | ||
| if (calendar) { | ||
| integrationsToDelete.push( | ||
| calendar?.deleteEvent(reference.uid, evt, reference.externalCalendarId) | ||
|
|
@@ -262,7 +262,7 @@ async function handler(req: CustomRequest) { | |
| ); | ||
| } | ||
| if (reference.type.includes("_calendar")) { | ||
| const calendar = getCalendar(credential); | ||
| const calendar = await getCalendar(credential); | ||
| if (calendar) { | ||
| integrationsToDelete.push( | ||
| calendar?.updateEvent(reference.uid, updatedEvt, reference.externalCalendarId) | ||
|
|
@@ -449,7 +449,7 @@ async function handler(req: CustomRequest) { | |
| (credential) => credential.id === credentialId | ||
| ); | ||
| if (calendarCredential) { | ||
| const calendar = getCalendar(calendarCredential); | ||
| const calendar = await getCalendar(calendarCredential); | ||
| if ( | ||
| bookingToDelete.eventType?.recurringEvent && | ||
| bookingToDelete.recurringEventId && | ||
|
|
@@ -458,7 +458,7 @@ async function handler(req: CustomRequest) { | |
| bookingToDelete.user.credentials | ||
| .filter((credential) => credential.type.endsWith("_calendar")) | ||
| .forEach(async (credential) => { | ||
| const calendar = getCalendar(credential); | ||
| const calendar = await getCalendar(credential); | ||
| for (const updBooking of updatedBookings) { | ||
| const bookingRef = updBooking.references.find((ref) => ref.type.includes("_calendar")); | ||
| if (bookingRef) { | ||
|
Comment on lines
458
to
464
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new async callback in Useful? React with 👍 / 👎. |
||
|
|
@@ -474,12 +474,13 @@ async function handler(req: CustomRequest) { | |
| } | ||
| } else { | ||
| // For bookings made before the refactor we go through the old behaviour of running through each calendar credential | ||
| bookingToDelete.user.credentials | ||
| .filter((credential) => credential.type.endsWith("_calendar")) | ||
| .forEach((credential) => { | ||
| const calendar = getCalendar(credential); | ||
| apiDeletes.push(calendar?.deleteEvent(uid, evt, externalCalendarId) as Promise<unknown>); | ||
| }); | ||
| const calendarCredentials = bookingToDelete.user.credentials.filter((credential) => | ||
| credential.type.endsWith("_calendar") | ||
| ); | ||
| for (const credential of calendarCredentials) { | ||
| const calendar = await getCalendar(credential); | ||
| apiDeletes.push(calendar?.deleteEvent(uid, evt, externalCalendarId) as Promise<unknown>); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -585,7 +586,7 @@ async function handler(req: CustomRequest) { | |
| } | ||
|
|
||
| // Posible to refactor TODO: | ||
| const paymentApp = appStore[paymentAppCredential?.app?.dirName as keyof typeof appStore]; | ||
| const paymentApp = await appStore[paymentAppCredential?.app?.dirName as keyof typeof appStore]; | ||
| if (!(paymentApp && "lib" in paymentApp && "PaymentService" in paymentApp.lib)) { | ||
| console.warn(`payment App service of type ${paymentApp} is not implemented`); | ||
| return null; | ||
|
|
||
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.
In both
wipemycalother(and likewisepackages/app-store/vital/lib/reschedule.tsaround the same lines) the cancellation logic is nowbookingRefsFiltered.forEach(async bookingRef => … await getCalendar …). BecauseforEachdoesn’t await its async callback, the surroundingtry/catchnever sees errors thrown inside and the function can return before the calendar/video deletions actually execute, leaving unhandled rejections whengetCalendarordeleteEventfails. To restore the original semantics, iterate withfor…of(awaiting each deletion) or collect the promises andawait Promise.allso that errors are caught and the reschedule waits for the clean-up to finish.Useful? React with 👍 / 👎.