@dereekb/calcom 13.35.0 → 13.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,80 @@
1
- import { type Minutes, type Maybe } from '@dereekb/util';
1
+ import { type Minutes, type Maybe, type WebsiteUrl } from '@dereekb/util';
2
2
  import { type CalcomContext } from './calcom.config';
3
- import { type CalcomEventTypeId, type CalcomEventTypeSlug, type CalcomResponseStatus } from '../calcom.type';
3
+ import { type CalcomEventTypeId, type CalcomEventTypeSlug, type CalcomResponseStatus, type CalcomScheduleId, type CalcomUserId } from '../calcom.type';
4
+ /**
5
+ * A toggleable event-type policy, returned either disabled or with its configuration.
6
+ *
7
+ * Cal.com models several independent settings this way (`confirmationPolicy`, `bookingWindow`,
8
+ * `seats`, `bookerActiveBookingsLimit`), each as `{ disabled: true }` or a settings object.
9
+ */
10
+ export type CalcomEventTypePolicy = {
11
+ readonly disabled: true;
12
+ } | Record<string, unknown>;
13
+ /**
14
+ * A boolean event-type setting Cal.com wraps in an object rather than sending bare.
15
+ *
16
+ * `disableCancelling`/`disableRescheduling` are `{ disabled: false }` on the wire in BOTH
17
+ * directions — the response never carries a bare boolean (so `if (eventType.disableCancelling)`
18
+ * on one would always be truthy), and passing one to create/update is rejected with "nested
19
+ * property disableCancelling must be either object or array".
20
+ */
21
+ export interface CalcomEventTypeDisabledPolicy {
22
+ readonly disabled: boolean;
23
+ }
4
24
  export interface CalcomEventType {
5
25
  readonly id: CalcomEventTypeId;
26
+ readonly ownerId: CalcomUserId;
6
27
  readonly title: string;
7
28
  readonly slug: CalcomEventTypeSlug;
8
29
  readonly description: Maybe<string>;
9
30
  readonly lengthInMinutes: Minutes;
31
+ /**
32
+ * The selectable lengths of a multi-length event type. Absent on a fixed-length event type —
33
+ * which is exactly when `lengthInMinutes` may NOT be passed to create-booking.
34
+ */
35
+ readonly lengthInMinutesOptions?: Maybe<Minutes[]>;
10
36
  readonly locations: unknown[];
37
+ readonly bookingFields: unknown[];
38
+ readonly hidden: boolean;
39
+ readonly scheduleId: Maybe<CalcomScheduleId>;
40
+ readonly slotInterval: Maybe<Minutes>;
41
+ readonly minimumBookingNotice: Minutes;
42
+ readonly beforeEventBuffer: Minutes;
43
+ readonly afterEventBuffer: Minutes;
44
+ readonly offsetStart: Minutes;
45
+ readonly disableGuests: boolean;
46
+ readonly hideCalendarNotes: boolean;
47
+ readonly hideCalendarEventDetails: boolean;
48
+ readonly hideOrganizerEmail: boolean;
49
+ readonly requiresBookerEmailVerification: boolean;
50
+ readonly skipAttendeeEmailDeliverabilityCheck: boolean;
51
+ readonly lockTimeZoneToggleOnBookingPage: boolean;
52
+ readonly onlyShowFirstAvailableSlot: boolean;
53
+ readonly showOptimizedSlots: boolean;
54
+ readonly isInstantEvent: boolean;
55
+ readonly useDestinationCalendarEmail: boolean;
56
+ readonly bookingRequiresAuthentication: boolean;
57
+ readonly disableCancelling: CalcomEventTypeDisabledPolicy;
58
+ readonly disableRescheduling: CalcomEventTypeDisabledPolicy;
59
+ readonly allowReschedulingPastBookings: boolean;
60
+ readonly allowReschedulingCancelledBookings: boolean;
61
+ readonly forwardParamsSuccessRedirect: boolean;
62
+ readonly successRedirectUrl: Maybe<WebsiteUrl>;
63
+ readonly bookingUrl: Maybe<WebsiteUrl>;
64
+ readonly interfaceLanguage: Maybe<string>;
65
+ readonly price: number;
66
+ readonly currency: string;
67
+ readonly recurrence: Maybe<unknown>;
68
+ readonly metadata: Record<string, unknown>;
69
+ readonly users: unknown[];
70
+ readonly calVideoSettings: Maybe<Record<string, unknown>>;
71
+ readonly confirmationPolicy: CalcomEventTypePolicy;
72
+ readonly bookingWindow: CalcomEventTypePolicy;
73
+ readonly seats: CalcomEventTypePolicy;
74
+ readonly bookerActiveBookingsLimit: CalcomEventTypePolicy;
75
+ readonly privateNoteEnabled: boolean;
76
+ readonly privateNoteMode: Maybe<string>;
77
+ readonly privateNoteTemplate: Maybe<string>;
11
78
  }
12
79
  export interface CalcomGetEventTypesResponse {
13
80
  readonly status: CalcomResponseStatus;
@@ -17,21 +84,64 @@ export interface CalcomEventTypeResponse {
17
84
  readonly status: CalcomResponseStatus;
18
85
  readonly data: CalcomEventType;
19
86
  }
20
- export interface CalcomCreateEventTypeInput {
87
+ /**
88
+ * The event-type settings accepted on both create and update.
89
+ */
90
+ export interface CalcomEventTypeInputSettings {
91
+ readonly description?: Maybe<string>;
92
+ readonly locations?: Maybe<unknown[]>;
93
+ readonly bookingFields?: Maybe<unknown[]>;
94
+ /**
95
+ * The selectable lengths of a multi-length event type. Required before a booking may pass
96
+ * `lengthInMinutes`.
97
+ */
98
+ readonly lengthInMinutesOptions?: Maybe<Minutes[]>;
99
+ readonly hidden?: Maybe<boolean>;
100
+ readonly scheduleId?: Maybe<CalcomScheduleId>;
101
+ readonly slotInterval?: Maybe<Minutes>;
102
+ readonly minimumBookingNotice?: Maybe<Minutes>;
103
+ readonly beforeEventBuffer?: Maybe<Minutes>;
104
+ readonly afterEventBuffer?: Maybe<Minutes>;
105
+ readonly offsetStart?: Maybe<Minutes>;
106
+ readonly disableGuests?: Maybe<boolean>;
107
+ readonly hideCalendarNotes?: Maybe<boolean>;
108
+ readonly hideCalendarEventDetails?: Maybe<boolean>;
109
+ readonly hideOrganizerEmail?: Maybe<boolean>;
110
+ readonly requiresBookerEmailVerification?: Maybe<boolean>;
111
+ /**
112
+ * Skips Cal.com's deliverability check on the attendee email, which otherwise rejects
113
+ * addresses it cannot verify.
114
+ */
115
+ readonly skipAttendeeEmailDeliverabilityCheck?: Maybe<boolean>;
116
+ readonly lockTimeZoneToggleOnBookingPage?: Maybe<boolean>;
117
+ readonly onlyShowFirstAvailableSlot?: Maybe<boolean>;
118
+ readonly useDestinationCalendarEmail?: Maybe<boolean>;
119
+ readonly bookingRequiresAuthentication?: Maybe<boolean>;
120
+ readonly disableCancelling?: Maybe<CalcomEventTypeDisabledPolicy>;
121
+ readonly disableRescheduling?: Maybe<CalcomEventTypeDisabledPolicy>;
122
+ readonly allowReschedulingPastBookings?: Maybe<boolean>;
123
+ readonly allowReschedulingCancelledBookings?: Maybe<boolean>;
124
+ readonly forwardParamsSuccessRedirect?: Maybe<boolean>;
125
+ readonly successRedirectUrl?: Maybe<WebsiteUrl>;
126
+ readonly interfaceLanguage?: Maybe<string>;
127
+ readonly price?: Maybe<number>;
128
+ readonly currency?: Maybe<string>;
129
+ readonly recurrence?: Maybe<unknown>;
130
+ readonly metadata?: Maybe<Record<string, unknown>>;
131
+ readonly confirmationPolicy?: Maybe<CalcomEventTypePolicy>;
132
+ readonly bookingWindow?: Maybe<CalcomEventTypePolicy>;
133
+ readonly seats?: Maybe<CalcomEventTypePolicy>;
134
+ readonly bookerActiveBookingsLimit?: Maybe<CalcomEventTypePolicy>;
135
+ }
136
+ export interface CalcomCreateEventTypeInput extends CalcomEventTypeInputSettings {
21
137
  readonly title: string;
22
138
  readonly slug: CalcomEventTypeSlug;
23
139
  readonly lengthInMinutes: Minutes;
24
- readonly description?: string;
25
- readonly locations?: unknown[];
26
- readonly bookingFields?: unknown[];
27
140
  }
28
- export interface CalcomUpdateEventTypeInput {
29
- readonly title?: string;
30
- readonly slug?: CalcomEventTypeSlug;
31
- readonly lengthInMinutes?: Minutes;
32
- readonly description?: string;
33
- readonly locations?: unknown[];
34
- readonly bookingFields?: unknown[];
141
+ export interface CalcomUpdateEventTypeInput extends CalcomEventTypeInputSettings {
142
+ readonly title?: Maybe<string>;
143
+ readonly slug?: Maybe<CalcomEventTypeSlug>;
144
+ readonly lengthInMinutes?: Maybe<Minutes>;
35
145
  }
36
146
  /**
37
147
  * Retrieves all event types for the authenticated user.
@@ -1,18 +1,34 @@
1
- import { type TimezoneString } from '@dereekb/util';
1
+ import { type ISO8601DayString, type TimezoneString } from '@dereekb/util';
2
2
  import { type CalcomContext } from './calcom.config';
3
- import { type CalcomScheduleId, type CalcomResponseStatus } from '../calcom.type';
3
+ import { type CalcomScheduleId, type CalcomResponseStatus, type CalcomUserId } from '../calcom.type';
4
4
  export interface CalcomAvailabilityRule {
5
5
  readonly days: string[];
6
6
  readonly startTime: string;
7
7
  readonly endTime: string;
8
8
  }
9
+ /**
10
+ * A date-specific exception to a schedule's weekly availability.
11
+ *
12
+ * NOTE: the array itself is confirmed against the live API, but this entry shape is taken from
13
+ * the Cal.com docs — the account used to verify this package has no overrides configured, so no
14
+ * real entry was observed. Treat the field names as unverified.
15
+ */
16
+ export interface CalcomScheduleOverride {
17
+ readonly date: ISO8601DayString;
18
+ readonly startTime: string;
19
+ readonly endTime: string;
20
+ }
9
21
  export interface CalcomSchedule {
10
22
  readonly id: CalcomScheduleId;
23
+ readonly ownerId: CalcomUserId;
11
24
  readonly name: string;
12
25
  readonly timeZone: TimezoneString;
13
26
  readonly availability: CalcomAvailabilityRule[];
14
27
  readonly isDefault: boolean;
15
- readonly overrides: Record<string, CalcomAvailabilityRule[]>;
28
+ /**
29
+ * Date-specific overrides, returned as an ARRAY (not a date-keyed record).
30
+ */
31
+ readonly overrides: CalcomScheduleOverride[];
16
32
  }
17
33
  export interface CalcomGetSchedulesResponse {
18
34
  readonly status: CalcomResponseStatus;
@@ -1,4 +1,4 @@
1
- import { type ISO8601DateString, type Maybe, type Minutes, type TimezoneString } from '@dereekb/util';
1
+ import { type ISO8601DateString, type ISO8601DayString, type Maybe, type Minutes, type TimezoneString } from '@dereekb/util';
2
2
  import { type CalcomContext, type CalcomPublicContext } from './calcom.config';
3
3
  import { type CalcomEventTypeId, type CalcomEventTypeSlug, type CalcomUsername, type CalcomTeamSlug, type CalcomOrganizationSlug, type CalcomResponseStatus } from '../calcom.type';
4
4
  export interface CalcomGetAvailableSlotsInput {
@@ -14,13 +14,22 @@ export interface CalcomGetAvailableSlotsInput {
14
14
  readonly format?: Maybe<'range' | 'time'>;
15
15
  }
16
16
  export interface CalcomSlot {
17
- readonly time: ISO8601DateString;
17
+ readonly start: ISO8601DateString;
18
+ /**
19
+ * The end of the slot. Only returned when `format: 'range'` was requested.
20
+ */
21
+ readonly end?: Maybe<ISO8601DateString>;
18
22
  }
23
+ /**
24
+ * Available slots keyed by day (`"2026-08-12"`), each holding that day's slots.
25
+ */
26
+ export type CalcomSlotsByDay = Record<ISO8601DayString, CalcomSlot[]>;
19
27
  export interface CalcomGetAvailableSlotsResponse {
20
28
  readonly status: CalcomResponseStatus;
21
- readonly data: {
22
- readonly slots: Record<string, CalcomSlot[]>;
23
- };
29
+ /**
30
+ * The day-keyed slot map itself — at `cal-api-version: 2024-09-04` there is no `slots` wrapper.
31
+ */
32
+ readonly data: CalcomSlotsByDay;
24
33
  }
25
34
  /**
26
35
  * Queries available booking slots for a given event type within a date range.
@@ -31,6 +40,8 @@ export interface CalcomGetAvailableSlotsResponse {
31
40
  * @param context - The Cal.com API context (authenticated or public)
32
41
  * @returns Queries available slots for the given input.
33
42
  *
43
+ * The `cal-api-version` header is REQUIRED here — without it the endpoint 404s.
44
+ *
34
45
  * @see https://cal.com/docs/api-reference/v2/slots/get-available-time-slots-for-an-event-type
35
46
  *
36
47
  * @example
@@ -41,8 +52,8 @@ export interface CalcomGetAvailableSlotsResponse {
41
52
  * eventTypeId: 12345
42
53
  * });
43
54
  *
44
- * for (const [date, slots] of Object.entries(response.data.slots)) {
45
- * console.log(date, slots.map(s => s.time));
55
+ * for (const [date, slots] of Object.entries(response.data)) {
56
+ * console.log(date, slots.map(s => s.start));
46
57
  * }
47
58
  * ```
48
59
  */
@@ -1,15 +1,27 @@
1
- import { type EmailAddress, type ISO8601DateString, type TimezoneString, type Maybe } from '@dereekb/util';
1
+ import { type EmailAddress, type TimezoneString, type Maybe, type WebsiteUrl } from '@dereekb/util';
2
2
  import { type CalcomContext } from './calcom.config';
3
- import { type CalcomUserId, type CalcomUsername, type CalcomScheduleId, type CalcomResponseStatus } from '../calcom.type';
3
+ import { type CalcomId, type CalcomUserId, type CalcomUsername, type CalcomScheduleId, type CalcomResponseStatus } from '../calcom.type';
4
+ /**
5
+ * The organization a user belongs to, as embedded on the user.
6
+ */
7
+ export interface CalcomUserOrganization {
8
+ readonly id: CalcomId;
9
+ readonly isPlatform: boolean;
10
+ }
4
11
  export interface CalcomUser {
5
12
  readonly id: CalcomUserId;
6
13
  readonly email: EmailAddress;
14
+ readonly name: Maybe<string>;
7
15
  readonly username: Maybe<CalcomUsername>;
8
16
  readonly timeZone: TimezoneString;
9
17
  readonly weekStart: string;
10
- readonly createdDate: ISO8601DateString;
11
18
  readonly timeFormat: number;
12
19
  readonly defaultScheduleId: Maybe<CalcomScheduleId>;
20
+ readonly avatarUrl: Maybe<WebsiteUrl>;
21
+ readonly bio: Maybe<string>;
22
+ readonly locale: Maybe<string>;
23
+ readonly organizationId: Maybe<CalcomId>;
24
+ readonly organization: Maybe<CalcomUserOrganization>;
13
25
  }
14
26
  export interface CalcomGetMeResponse {
15
27
  readonly status: CalcomResponseStatus;
@@ -1,29 +1,123 @@
1
- import { type WebsiteUrl, type Maybe } from '@dereekb/util';
1
+ import { type WebsiteUrl, type Maybe, type ISO8601DateString, type TimeDuration, type TimeUnit } from '@dereekb/util';
2
2
  import { type CalcomContext } from './calcom.config';
3
- import { type CalcomWebhookId, type CalcomResponseStatus } from '../calcom.type';
4
- export type CalcomWebhookTrigger = 'BOOKING_CREATED' | 'BOOKING_CANCELLED' | 'BOOKING_RESCHEDULED' | 'BOOKING_REQUESTED' | 'BOOKING_REJECTED' | 'BOOKING_NO_SHOW_UPDATED' | 'BOOKING_PAYMENT_INITIATED' | 'BOOKING_PAID' | 'MEETING_STARTED' | 'MEETING_ENDED' | 'RECORDING_READY' | 'RECORDING_TRANSCRIPTION_GENERATED';
3
+ import { type CalcomWebhookId, type CalcomResponseStatus, type CalcomUserId, type CalcomId, type CalcomEventTypeId } from '../calcom.type';
4
+ /**
5
+ * The triggers that fire a set amount of time after the booking, rather than on an event.
6
+ *
7
+ * These are the only triggers a {@link CalcomWebhookTimeOffset} applies to.
8
+ */
9
+ export type CalcomWebhookTimeRelativeTrigger = 'AFTER_HOSTS_CAL_VIDEO_NO_SHOW' | 'AFTER_GUESTS_CAL_VIDEO_NO_SHOW';
10
+ /**
11
+ * All {@link CalcomWebhookTimeRelativeTrigger} values.
12
+ */
13
+ export declare const ALL_CALCOM_WEBHOOK_TIME_RELATIVE_TRIGGERS: readonly CalcomWebhookTimeRelativeTrigger[];
14
+ /**
15
+ * The events a webhook may subscribe to.
16
+ *
17
+ * Enumerated by the API itself: posting an unknown trigger returns the full accepted set.
18
+ */
19
+ export type CalcomWebhookTrigger = CalcomWebhookTimeRelativeTrigger | 'BOOKING_CREATED' | 'BOOKING_PAYMENT_INITIATED' | 'BOOKING_PAID' | 'BOOKING_RESCHEDULED' | 'BOOKING_REQUESTED' | 'BOOKING_CANCELLED' | 'BOOKING_REJECTED' | 'BOOKING_NO_SHOW_UPDATED' | 'BOOKING_LOCATION_UPDATED' | 'FORM_SUBMITTED' | 'FORM_SUBMITTED_NO_EVENT' | 'MEETING_STARTED' | 'MEETING_ENDED' | 'RECORDING_READY' | 'RECORDING_TRANSCRIPTION_GENERATED' | 'INSTANT_MEETING' | 'INSTANT_MEETING_ACCEPTED' | 'OOO_CREATED' | 'ROUTING_FORM_FALLBACK_HIT' | 'WRONG_ASSIGNMENT_REPORT' | 'CALENDAR_ENTRY_REJECTED' | 'DELEGATION_CREDENTIAL_ERROR' | 'DELEGATION_CREDENTIAL_ROTATION_REQUIRED' | 'DELEGATION_CREDENTIAL_SECRET_ROTATED' | 'DELEGATION_CREDENTIAL_SECRET_ROTATION_FAILED';
20
+ /**
21
+ * The payload format Cal.com sends to the subscriber.
22
+ *
23
+ * Enumerated by the API: posting an unknown value returns "version must be one of the following
24
+ * values: 2021-10-20, 2026-07-27". Distinct from the `cal-api-version` header, which the webhook
25
+ * endpoints do not use at all.
26
+ */
27
+ export type CalcomWebhookVersion = '2021-10-20' | '2026-07-27';
28
+ /**
29
+ * All {@link CalcomWebhookVersion} values, oldest first.
30
+ */
31
+ export declare const ALL_CALCOM_WEBHOOK_VERSIONS: readonly CalcomWebhookVersion[];
32
+ /**
33
+ * The unit a {@link CalcomWebhookTimeOffset} is counted in.
34
+ *
35
+ * Enumerated by the API: posting an unknown value returns "timeUnit must be one of the following
36
+ * values: DAY, HOUR, MINUTE". These are UPPERCASE and unrelated to the lowercase `@dereekb/util`
37
+ * {@link TimeUnit} strings — map between them with {@link CALCOM_WEBHOOK_TIME_UNIT_TIME_UNIT_MAP}.
38
+ */
39
+ export type CalcomWebhookTimeUnit = 'MINUTE' | 'HOUR' | 'DAY';
40
+ /**
41
+ * All {@link CalcomWebhookTimeUnit} values, smallest first.
42
+ */
43
+ export declare const ALL_CALCOM_WEBHOOK_TIME_UNITS: readonly CalcomWebhookTimeUnit[];
44
+ /**
45
+ * Maps each {@link CalcomWebhookTimeUnit} to the equivalent `@dereekb/util` {@link TimeUnit}.
46
+ */
47
+ export declare const CALCOM_WEBHOOK_TIME_UNIT_TIME_UNIT_MAP: Readonly<Record<CalcomWebhookTimeUnit, TimeUnit>>;
48
+ /**
49
+ * How many {@link CalcomWebhookTimeUnit} units after the booking start the trigger is evaluated.
50
+ *
51
+ * A whole number of at least 1 — the API rejects 0 with "time must not be less than 1".
52
+ */
53
+ export type CalcomWebhookTimeAmount = number;
54
+ /**
55
+ * How long after the booking start a {@link CalcomWebhookTimeRelativeTrigger} is evaluated.
56
+ *
57
+ * Carried on the wire as the sibling `time` + `timeUnit` fields; convert to a `@dereekb/util`
58
+ * {@link TimeDuration} with {@link calcomWebhookTimeOffsetToTimeDuration} to do arithmetic on it.
59
+ */
60
+ export interface CalcomWebhookTimeOffset {
61
+ readonly time: CalcomWebhookTimeAmount;
62
+ readonly timeUnit: CalcomWebhookTimeUnit;
63
+ }
64
+ /**
65
+ * Either both halves of a {@link CalcomWebhookTimeOffset}, or neither.
66
+ *
67
+ * The API does not enforce the pairing itself — it accepts a `time` with no `timeUnit` and then
68
+ * has no unit to apply it in — so this input type is what keeps a caller from sending half of one.
69
+ */
70
+ export type CalcomWebhookTimeOffsetInput = CalcomWebhookTimeOffset | {
71
+ readonly time?: never;
72
+ readonly timeUnit?: never;
73
+ };
5
74
  export interface CalcomWebhook {
6
75
  readonly id: CalcomWebhookId;
7
76
  readonly subscriberUrl: WebsiteUrl;
8
77
  readonly triggers: CalcomWebhookTrigger[];
9
78
  readonly active: boolean;
10
- readonly payloadTemplate?: Maybe<string>;
11
- readonly secret?: Maybe<string>;
79
+ readonly payloadTemplate: Maybe<string>;
80
+ readonly secret: Maybe<string>;
81
+ readonly userId: Maybe<CalcomUserId>;
82
+ readonly version: Maybe<CalcomWebhookVersion>;
83
+ /**
84
+ * The magnitude of the webhook's {@link CalcomWebhookTimeOffset}, null unless it subscribes to a
85
+ * {@link CalcomWebhookTimeRelativeTrigger}. Read both halves together with
86
+ * {@link calcomWebhookTimeOffsetFromWebhook}.
87
+ */
88
+ readonly time: Maybe<CalcomWebhookTimeAmount>;
89
+ readonly timeUnit: Maybe<CalcomWebhookTimeUnit>;
90
+ /**
91
+ * Returned when reading a webhook, but not on the create response.
92
+ */
93
+ readonly createdAt?: Maybe<ISO8601DateString>;
94
+ readonly teamId?: Maybe<CalcomId>;
95
+ readonly eventTypeId?: Maybe<CalcomEventTypeId>;
96
+ readonly appId?: Maybe<string>;
97
+ readonly platform?: Maybe<boolean>;
98
+ readonly oAuthClientId?: Maybe<string>;
12
99
  }
13
- export interface CalcomCreateWebhookInput {
100
+ export interface CalcomCreateWebhookInputBase {
14
101
  readonly subscriberUrl: WebsiteUrl;
15
102
  readonly triggers: CalcomWebhookTrigger[];
16
- readonly active?: boolean;
103
+ /**
104
+ * Required: a create with no `active` is rejected with "active must be a boolean value".
105
+ */
106
+ readonly active: boolean;
17
107
  readonly payloadTemplate?: string;
18
108
  readonly secret?: string;
109
+ readonly version?: CalcomWebhookVersion;
19
110
  }
20
- export interface CalcomUpdateWebhookInput {
111
+ export type CalcomCreateWebhookInput = CalcomCreateWebhookInputBase & CalcomWebhookTimeOffsetInput;
112
+ export interface CalcomUpdateWebhookInputBase {
21
113
  readonly subscriberUrl?: WebsiteUrl;
22
114
  readonly triggers?: CalcomWebhookTrigger[];
23
115
  readonly active?: boolean;
24
116
  readonly payloadTemplate?: string;
25
117
  readonly secret?: string;
118
+ readonly version?: CalcomWebhookVersion;
26
119
  }
120
+ export type CalcomUpdateWebhookInput = CalcomUpdateWebhookInputBase & CalcomWebhookTimeOffsetInput;
27
121
  export interface CalcomWebhookResponse {
28
122
  readonly status: CalcomResponseStatus;
29
123
  readonly data: CalcomWebhook;
@@ -32,6 +126,33 @@ export interface CalcomGetWebhooksResponse {
32
126
  readonly status: CalcomResponseStatus;
33
127
  readonly data: CalcomWebhook[];
34
128
  }
129
+ /**
130
+ * Converts a Cal.com webhook time offset to a `@dereekb/util` {@link TimeDuration}, so the
131
+ * duration utilities (`timeDurationToMilliseconds()`, `convertTimeDuration()`, ...) apply to it.
132
+ *
133
+ * @param offset - The webhook time offset to convert.
134
+ * @returns The equivalent TimeDuration.
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * timeDurationToMilliseconds(calcomWebhookTimeOffsetToTimeDuration({ time: 5, timeUnit: 'MINUTE' })); // 300000
139
+ * ```
140
+ *
141
+ * @__NO_SIDE_EFFECTS__
142
+ */
143
+ export declare function calcomWebhookTimeOffsetToTimeDuration(offset: CalcomWebhookTimeOffset): TimeDuration;
144
+ /**
145
+ * Reads a webhook's {@link CalcomWebhookTimeOffset} out of the sibling `time`/`timeUnit` fields.
146
+ *
147
+ * Returns undefined unless both halves are present, as the API returns them null on a webhook
148
+ * with no {@link CalcomWebhookTimeRelativeTrigger} and a magnitude with no unit means nothing.
149
+ *
150
+ * @param webhook - The webhook to read the offset from.
151
+ * @returns The webhook's time offset, or undefined when it has none.
152
+ *
153
+ * @__NO_SIDE_EFFECTS__
154
+ */
155
+ export declare function calcomWebhookTimeOffsetFromWebhook(webhook: Pick<CalcomWebhook, 'time' | 'timeUnit'>): Maybe<CalcomWebhookTimeOffset>;
35
156
  /**
36
157
  * Creates a webhook subscription for the authenticated user. Webhooks notify your app
37
158
  * when specified events occur (e.g., bookings created, cancelled, rescheduled).
@@ -1,6 +1,32 @@
1
+ import { type Maybe } from '@dereekb/util';
1
2
  import { type FetchResponseError } from '@dereekb/util/fetch';
2
- import { type CalcomServerErrorData, type ParsedCalcomServerError } from '../calcom.error.api';
3
+ import { type CalcomServerErrorCode, type CalcomServerErrorData, type ParsedCalcomServerError } from '../calcom.error.api';
3
4
  export declare const logCalcomErrorToConsole: import("..").LogCalcomServerErrorFunction;
5
+ /**
6
+ * The error envelope returned by the Cal.com v2 API.
7
+ *
8
+ * The code and message are nested under `error` — they are NOT top-level fields on the body.
9
+ */
10
+ export interface CalcomApiErrorResponseBody {
11
+ readonly status?: Maybe<string>;
12
+ readonly timestamp?: Maybe<string>;
13
+ readonly path?: Maybe<string>;
14
+ readonly error?: Maybe<{
15
+ readonly code?: Maybe<CalcomServerErrorCode>;
16
+ readonly message?: Maybe<string>;
17
+ readonly details?: Maybe<unknown>;
18
+ }>;
19
+ }
20
+ /**
21
+ * Flattens a Cal.com API error response body into {@link CalcomServerErrorData}.
22
+ *
23
+ * Reads the nested `error` envelope when present, and otherwise treats the body as already
24
+ * flat — so an endpoint that returns a bare error object still yields its code and message.
25
+ *
26
+ * @param body - The parsed error response body.
27
+ * @returns The flattened error data.
28
+ */
29
+ export declare function calcomServerErrorDataFromApiErrorResponseBody(body: CalcomApiErrorResponseBody): CalcomServerErrorData;
4
30
  /**
5
31
  * Parses a FetchResponseError from a Cal.com API call into a typed CalcomServerError.
6
32
  * Attempts to extract JSON error data from the response body.
@@ -1,3 +1,4 @@
1
+ import { type Count, type PageNumber } from '@dereekb/util';
1
2
  /**
2
3
  * A numeric identifier in Cal.com.
3
4
  */
@@ -20,8 +21,11 @@ export type CalcomBookingId = number;
20
21
  export type CalcomScheduleId = number;
21
22
  /**
22
23
  * Cal.com webhook identifier.
24
+ *
25
+ * A UUID string (e.g. `"7c3b0811-8a5a-4754-8b31-9f594559f98e"`), unlike the numeric ids used
26
+ * elsewhere in the API.
23
27
  */
24
- export type CalcomWebhookId = number;
28
+ export type CalcomWebhookId = string;
25
29
  /**
26
30
  * Cal.com credential identifier, used to reference connected calendar credentials.
27
31
  */
@@ -55,11 +59,6 @@ export type CalcomOrganizationSlug = string;
55
59
  * (e.g., "google_calendar", "outlook_calendar", "apple_calendar").
56
60
  */
57
61
  export type CalcomCalendarIntegration = string;
58
- /**
59
- * Cal.com webhook event type string
60
- * (e.g., "BOOKING_CREATED", "BOOKING_CANCELLED").
61
- */
62
- export type CalcomWebhookEventTypeString = string;
63
62
  /**
64
63
  * Cal.com API response status string (e.g., "success", "error").
65
64
  */
@@ -68,3 +67,19 @@ export type CalcomResponseStatus = 'success' | 'error';
68
67
  * Cal.com booking status string.
69
68
  */
70
69
  export type CalcomBookingStatus = 'accepted' | 'pending' | 'cancelled' | 'rejected';
70
+ /**
71
+ * The pagination envelope a paginated Cal.com list response carries beside its `data`.
72
+ *
73
+ * `currentPage`/`totalPages` are 1-based, and are derived from the `take`/`skip` of the request
74
+ * rather than being a cursor.
75
+ */
76
+ export interface CalcomPagination {
77
+ readonly returnedItems: Count;
78
+ readonly totalItems: Count;
79
+ readonly itemsPerPage: Count;
80
+ readonly remainingItems: Count;
81
+ readonly currentPage: PageNumber;
82
+ readonly totalPages: Count;
83
+ readonly hasNextPage: boolean;
84
+ readonly hasPreviousPage: boolean;
85
+ }