mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
ba6a87b699
* refactor(companion): split calcom.ts into modular service files Split the monolithic 1692-line calcom.ts file into focused modules: - auth.ts: Authentication configuration and token management - bookings.ts: Booking CRUD operations and actions - conferencing.ts: Conferencing options - event-types.ts: Event type CRUD operations - private-links.ts: Private link management for event types - request.ts: Core HTTP request functionality - schedules.ts: Schedule CRUD operations - user.ts: User profile management - utils.ts: JSON parsing and payload sanitization utilities - webhooks.ts: Webhook management (global and event type specific) - index.ts: Re-exports all functions and maintains backward compatibility This improves code organization, maintainability, and makes it easier to understand and modify specific functionality. Co-Authored-By: [email protected] <[email protected]> * fix(companion): avoid logging sensitive booking response data Replace logging of full responseText (which may contain PII like attendee emails and names) with responseLength for safer debugging. Addresses Cubic AI review feedback (confidence 9/10). Co-Authored-By: unknown <> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
173 lines
3.6 KiB
TypeScript
173 lines
3.6 KiB
TypeScript
/**
|
|
* Cal.com API Service
|
|
*
|
|
* This module provides a unified interface for interacting with the Cal.com API v2.
|
|
* It is organized into logical submodules for better maintainability:
|
|
*
|
|
* - auth: Authentication configuration and token management
|
|
* - bookings: Booking CRUD operations and actions
|
|
* - conferencing: Conferencing options
|
|
* - event-types: Event type CRUD operations
|
|
* - private-links: Private link management for event types
|
|
* - request: Core HTTP request functionality
|
|
* - schedules: Schedule CRUD operations
|
|
* - user: User profile management
|
|
* - utils: JSON parsing and payload sanitization utilities
|
|
* - webhooks: Webhook management (global and event type specific)
|
|
*/
|
|
|
|
// Re-export types for backward compatibility
|
|
export type {
|
|
EventType,
|
|
CreateEventTypeInput,
|
|
Booking,
|
|
BookingParticipationResult,
|
|
Schedule,
|
|
UserProfile,
|
|
ConferencingOption,
|
|
Webhook,
|
|
CreateWebhookInput,
|
|
UpdateWebhookInput,
|
|
PrivateLink,
|
|
CreatePrivateLinkInput,
|
|
UpdatePrivateLinkInput,
|
|
BookingLimitsCount,
|
|
BookingLimitsDuration,
|
|
ConfirmationPolicy,
|
|
} from "../types";
|
|
|
|
// Import all functions from submodules
|
|
import {
|
|
clearAuth,
|
|
setAccessToken,
|
|
setRefreshTokenFunction,
|
|
setTokenRefreshCallback,
|
|
} from "./auth";
|
|
import {
|
|
addGuests,
|
|
cancelBooking,
|
|
confirmBooking,
|
|
declineBooking,
|
|
getBookingByUid,
|
|
getBookingParticipation,
|
|
getBookings,
|
|
getConferencingSessions,
|
|
getRecordings,
|
|
getTranscripts,
|
|
markAbsent,
|
|
rescheduleBooking,
|
|
updateLocation,
|
|
updateLocationV2,
|
|
} from "./bookings";
|
|
import { getConferencingOptions } from "./conferencing";
|
|
import {
|
|
createEventType,
|
|
deleteEventType,
|
|
getEventTypeById,
|
|
getEventTypes,
|
|
updateEventType,
|
|
} from "./event-types";
|
|
import {
|
|
createEventTypePrivateLink,
|
|
deleteEventTypePrivateLink,
|
|
getEventTypePrivateLinks,
|
|
updateEventTypePrivateLink,
|
|
} from "./private-links";
|
|
import { testRawBookingsAPI } from "./request";
|
|
import {
|
|
createSchedule,
|
|
deleteSchedule,
|
|
duplicateSchedule,
|
|
getScheduleById,
|
|
getSchedules,
|
|
updateSchedule,
|
|
} from "./schedules";
|
|
import {
|
|
clearUserProfile,
|
|
getCurrentUser,
|
|
getUsername,
|
|
getUserProfile,
|
|
updateUserProfile,
|
|
} from "./user";
|
|
import {
|
|
createEventTypeWebhook,
|
|
createWebhook,
|
|
deleteEventTypeWebhook,
|
|
deleteWebhook,
|
|
getEventTypeWebhooks,
|
|
getWebhooks,
|
|
updateEventTypeWebhook,
|
|
updateWebhook,
|
|
} from "./webhooks";
|
|
|
|
// Re-export the booking participation helper for direct use
|
|
export { getBookingParticipation };
|
|
|
|
// Export the unified CalComAPIService object for backward compatibility
|
|
export const CalComAPIService = {
|
|
// Auth
|
|
setAccessToken,
|
|
setRefreshTokenFunction,
|
|
clearAuth,
|
|
setTokenRefreshCallback,
|
|
|
|
// User
|
|
getCurrentUser,
|
|
updateUserProfile,
|
|
getUserProfile,
|
|
getUsername,
|
|
clearUserProfile,
|
|
|
|
// Debug
|
|
testRawBookingsAPI,
|
|
|
|
// Event Types
|
|
deleteEventType,
|
|
createEventType,
|
|
getEventTypes,
|
|
getEventTypeById,
|
|
updateEventType,
|
|
|
|
// Bookings
|
|
cancelBooking,
|
|
rescheduleBooking,
|
|
confirmBooking,
|
|
declineBooking,
|
|
markAbsent,
|
|
addGuests,
|
|
updateLocation,
|
|
updateLocationV2,
|
|
getRecordings,
|
|
getConferencingSessions,
|
|
getTranscripts,
|
|
getBookingByUid,
|
|
getBookings,
|
|
|
|
// Schedules
|
|
getSchedules,
|
|
createSchedule,
|
|
getScheduleById,
|
|
updateSchedule,
|
|
duplicateSchedule,
|
|
deleteSchedule,
|
|
|
|
// Conferencing
|
|
getConferencingOptions,
|
|
|
|
// Webhooks
|
|
getWebhooks,
|
|
createWebhook,
|
|
updateWebhook,
|
|
deleteWebhook,
|
|
getEventTypeWebhooks,
|
|
createEventTypeWebhook,
|
|
updateEventTypeWebhook,
|
|
deleteEventTypeWebhook,
|
|
|
|
// Private Links
|
|
getEventTypePrivateLinks,
|
|
createEventTypePrivateLink,
|
|
updateEventTypePrivateLink,
|
|
deleteEventTypePrivateLink,
|
|
};
|