-
Notifications
You must be signed in to change notification settings - Fork 10.4k
docs: add getBusyTimes API documentation and update usage details #22754
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: main
Are you sure you want to change the base?
docs: add getBusyTimes API documentation and update usage details #22754
Conversation
@shivraj2805 is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
WalkthroughThe pull request updates the OpenAPI documentation at apps/api/v2/swagger/documentation.json by adding descriptions and examples for two query parameters on the calendars busy-times endpoint: credentialId (number) and externalId (string). The new descriptions explain what each parameter represents and where to obtain their values (/v2/credentials and listing connected calendars). Example values were added: 135 for credentialId and "user@gmail.com" for externalId. No types, required flags, or schemas were changed. Assessment against linked issues
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (07/26/25)1 reviewer was added to this PR based on Keith Williams's automation. "Add community label" took an action on this PR • (07/26/25)1 label was added to this PR based on Keith Williams's automation. "Add ready-for-e2e label" took an action on this PR • (08/22/25)1 label was added to this PR based on Keith Williams's automation. |
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/lib/getBusyTimes.ts (2)
1-13
: Complete the JSDoc – list all params & return typeThe new header comment is a great start, but only two of the many parameters are documented and there is no
@returns
section. Consumers who rely on IntelliSense / typedoc will still have to jump into the implementation to understand the full contract.Consider expanding the block (or linking to the type literal) so that every field accepted by
_getBusyTimes
is discoverable from the docs:/** * Gets busy time slots from internal bookings and connected external calendars. + * + * @returns Promise<EventBusyDetails[]> Busy intervals with `start`/`end` Date objects * * @param credentials … * @param selectedCalendars … + * @param userId … + * @param startTime ISO-8601 string + * @param endTime ISO-8601 string + * @param beforeEventBuffer Minutes + * @param afterEventBuffer Minutes + * @param bypassBusyCalendarTimes When true, skips external calendar lookup + * … etc. * * Other params are used to customize the time window, buffers, rescheduling, etc. */This keeps IDE hints trustworthy and avoids future guesswork.
135-182
: Hot loop repeatedly instantiates Day.js objects – cache or use timestampsInside the
reduce
, every booking creates up to sixdayjs()
instances (and severaltoDate()
conversions). For large booking lists this becomes a noticeable hotspot.A lightweight optimisation:
- const { id, startTime, endTime, eventType, title, ...rest } = booking; - const minutesToBlockBeforeEvent = … - const minutesToBlockAfterEvent = … - - if (rest._count?.seatsReferences) { - const bookedAt = `${dayjs(startTime).utc().format()}<>${dayjs(endTime).utc().format()}`; + const { id, startTime, endTime, eventType, title, ...rest } = booking; + const start = dayjs.utc(startTime); // one instantiation + const end = dayjs.utc(endTime); // one instantiation + + const minutesToBlockBeforeEvent = … + const minutesToBlockAfterEvent = … + + if (rest._count?.seatsReferences) { + const bookedAt = `${start.format()}<>${end.format()}`; … - aggregate.push({ - start: dayjs(startTime).subtract(minutesToBlockBeforeEvent, "minute").toDate(), - end: dayjs(startTime).toDate(), + aggregate.push({ + start: start.subtract(minutesToBlockBeforeEvent, "minute").toDate(), + end: start.toDate(), }); … } - aggregate.push({ - start: dayjs(startTime).subtract(minutesToBlockBeforeEvent, "minute").toDate(), - end: dayjs(endTime).add(minutesToBlockAfterEvent, "minute").toDate(), + aggregate.push({ + start: start.subtract(minutesToBlockBeforeEvent, "minute").toDate(), + end: end.add(minutesToBlockAfterEvent, "minute").toDate(), title, source: `eventType-${eventType?.id}-booking-${id}`, });Benefits:
• Cuts day-js allocations in half.
• Forces UTC consistently, avoiding accidental TZ drift.Not critical, but aligns with the performance guideline to limit Day.js in tight loops.
docs/api-reference/v2/calendars/get-busy-times.mdx (1)
13-22
: Align parameter names with code-level APIAt runtime the service expects an array of
credentials
and a parallel list ofselectedCalendars
, not singularcredentialId
/externalId
. If the REST façade truly accepts single-value fields, note that internally they are wrapped as arrays so integrators aren’t surprised when reading the TS docs or source.A one-liner clarification is enough, for example:
credentialId
– (or arraycredentials[]
if you call the TypeScript lib directly) …This keeps the public docs in sync with the implementation detail just added to
getBusyTimes.ts
.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
docs/api-reference/v2/calendars/get-busy-times.mdx
(1 hunks)packages/lib/getBusyTimes.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)
Flag excessive Day.js use in performance-critical code. Functions like .add, .diff, .isBefore, and .isAfter are slow, especially in timezone mode. Prefer .utc() for better performance. Where possible, replace with native Date and direct .valueOf() comparisons for faster execution. Recommend using native methods or Day.js .utc() consistently in hot paths like loops.
Files:
packages/lib/getBusyTimes.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Install dependencies / Yarn install & cache
- GitHub Check: Codacy Static Code Analysis
This PR is being marked as stale due to inactivity. |
E2E results are ready! |
Fetches busy time slots from internal bookings and connected external calendars, such as Google Calendar or Outlook, based on the provided credentials and calendar IDs. | ||
|
||
This is useful for checking calendar availability to avoid scheduling conflicts in booking systems. | ||
|
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.
You don't need to add new mdx file, just add description into those props inside swagger file
What does this PR do?
credentialId
andexternalId
in the/api-reference/v2/calendars/get-busy-times
documentation.What was added?
📘 Added Documentation for:
credentialId
: Refers to the ID of the connected calendar account (e.g., Google, Outlook). This is typically obtained when a user connects a calendar integration through Cal.com and a credential record is created in the database.externalId
: Refers to the ID of the calendar itself, retrieved from the external provider (likeprimary
for Google Calendar). You can list calendars using the/v2/calendars
API to get this.Example: