Skip to content

feat(cli): add unified calendar API commands#31

Draft
sahitya-chandra wants to merge 2 commits intomainfrom
devin/1773318133-unified-cal-cli
Draft

feat(cli): add unified calendar API commands#31
sahitya-chandra wants to merge 2 commits intomainfrom
devin/1773318133-unified-cal-cli

Conversation

@sahitya-chandra
Copy link
Member

@sahitya-chandra sahitya-chandra commented Mar 12, 2026

feat(cli): add unified calendar API commands

Summary

Adds a new unified-cal command group to the companion CLI that exposes the unified calendar API endpoints for full CRUD operations on connected calendar events. This uses the existing calcom login auth infrastructure (API key or OAuth) — no new auth flow is needed.

Commands added:

  • calcom unified-cal connections — list calendar connections
  • calcom unified-cal events list — list events for a connection (requires --connection-id, --from, --to)
  • calcom unified-cal events get — get a single event by ID
  • calcom unified-cal events create — create a new event (title, start, end, optional description/location/attendees)
  • calcom unified-cal events update — update an existing event
  • calcom unified-cal events delete — delete/cancel an event
  • calcom unified-cal freebusy — get free/busy times for a connection

All commands support --json for machine-readable output. Follows the existing command pattern (commander subcommands, withErrorHandling, shared output helpers).

Files added:

  • packages/cli/src/commands/unified-cal/command.ts — command definitions and API calls
  • packages/cli/src/commands/unified-cal/output.ts — rendering/display functions
  • packages/cli/src/commands/unified-cal/types.ts — TypeScript interfaces for API responses
  • packages/cli/src/commands/unified-cal/index.ts — barrel export

Files modified:

  • packages/cli/src/index.ts — registers the new unified-cal command

Updates since last revision

  • Added empty body guard for events update command — now throws a descriptive error if no updatable fields are provided instead of sending an empty PATCH request (identified by cubic).

Review & Testing Checklist for Human

  • API dependency (blocking): These commands call /v2/calendars/connections/... endpoints from cal.com PR #28297. Those endpoints must be merged and deployed before any of these commands will work. Verify the backend is available before testing.
  • Hand-written types vs actual API response: The types.ts interfaces are manually written to match the expected API shape (especially CalendarEvent fields like title, isAllDay, organizer, attendees). If the actual API response uses different field names or structure, commands will silently render empty/incorrect data. Cross-check types.ts against the real API output once available.
  • Type assertions bypass safety: Multiple response.data as CalendarEvent[] casts in command.ts — if the apiRequest response wrapper nests data differently than assumed, these will fail at runtime without a compile-time error.
  • DELETE bypasses shared apiRequest: The delete command uses raw fetch() because apiRequest calls response.json() which fails on 204 No Content. This duplicates auth header logic (command.ts:236-260). Verify token handling matches what apiRequest does.
  • End-to-end test plan: Run calcom login, then:
    1. calcom unified-cal connections — verify it lists connected calendars
    2. calcom unified-cal events list --connection-id <id> --from 2026-03-01 --to 2026-03-31 — verify events are returned
    3. calcom unified-cal events create --connection-id <id> --title "Test" --start 2026-03-20T14:00:00 --end 2026-03-20T15:00:00 — verify event is created
    4. calcom unified-cal events update --connection-id <id> --event-id <id> --title "Updated" — verify update works
    5. calcom unified-cal events update --connection-id <id> --event-id <id> (no fields) — verify it rejects with error
    6. calcom unified-cal events delete --connection-id <id> --event-id <id> — verify deletion
    7. calcom unified-cal freebusy --connection-id <id> --from 2026-03-01 --to 2026-03-31 — verify busy times

Notes

  • Lint (biome lint) and typecheck (tsc --noEmit) both pass clean.
  • No new dependencies added — uses existing commander, chalk, and the shared apiRequest/config utilities.
  • The openapi-ts config already includes Cal Unified Calendars tag — once the backend API spec is updated in the OpenAPI JSON, these hand-written types should ideally be replaced with generated SDK types for better type safety.
  • Requested by: @sahitya-chandra
  • Link to Devin Session

Add new 'unified-cal' command group to the companion CLI that exposes
the unified calendar API endpoints for full CRUD operations on connected
calendar events.

Commands added:
- calcom unified-cal connections — list calendar connections
- calcom unified-cal events list — list events for a connection
- calcom unified-cal events get — get a single event
- calcom unified-cal events create — create a new event
- calcom unified-cal events update — update an existing event
- calcom unified-cal events delete — delete/cancel an event
- calcom unified-cal freebusy — get free/busy times

Uses the existing 'calcom login' auth infrastructure (API key or OAuth).
All commands support --json output.
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/cli/src/commands/unified-cal/command.ts">

<violation number="1" location="packages/cli/src/commands/unified-cal/command.ts:140">
P2: Guard against empty updates so the CLI doesn’t send a PATCH with an empty body. Validate at least one updatable field before calling the API.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@sahitya-chandra sahitya-chandra marked this pull request as draft March 12, 2026 12:46
@vercel
Copy link

vercel bot commented Mar 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
companion-chat Ignored Ignored Mar 12, 2026 0:46am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant