@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.
- package/index.cjs.js +423 -54
- package/index.esm.js +414 -55
- package/nestjs/index.cjs.js +21 -4
- package/nestjs/index.esm.js +23 -5
- package/nestjs/package.json +5 -5
- package/nestjs/src/lib/calcom/calcom.api.d.ts +12 -0
- package/nestjs/src/lib/webhook/webhook.calcom.d.ts +0 -1
- package/nestjs/src/lib/webhook/webhook.calcom.type.d.ts +26 -5
- package/package.json +4 -4
- package/src/lib/calcom/calcom.api.booking.d.ts +104 -4
- package/src/lib/calcom/calcom.api.calendar.d.ts +128 -12
- package/src/lib/calcom/calcom.api.eventtype.d.ts +123 -13
- package/src/lib/calcom/calcom.api.schedule.d.ts +19 -3
- package/src/lib/calcom/calcom.api.slot.d.ts +18 -7
- package/src/lib/calcom/calcom.api.user.d.ts +15 -3
- package/src/lib/calcom/calcom.api.webhook.d.ts +129 -8
- package/src/lib/calcom/calcom.error.api.d.ts +27 -1
- package/src/lib/calcom.type.d.ts +21 -6
package/nestjs/index.cjs.js
CHANGED
|
@@ -1454,6 +1454,16 @@ exports.CalcomApi = __decorate([
|
|
|
1454
1454
|
return calcom.getBooking(this.context);
|
|
1455
1455
|
}
|
|
1456
1456
|
},
|
|
1457
|
+
{
|
|
1458
|
+
key: "getBookings",
|
|
1459
|
+
get: /**
|
|
1460
|
+
* Configured pass-through for {@link getBookings}.
|
|
1461
|
+
*
|
|
1462
|
+
* @returns Function to retrieve a page of bookings.
|
|
1463
|
+
*/ function get() {
|
|
1464
|
+
return calcom.getBookings(this.context);
|
|
1465
|
+
}
|
|
1466
|
+
},
|
|
1457
1467
|
{
|
|
1458
1468
|
key: "cancelBooking",
|
|
1459
1469
|
get: /**
|
|
@@ -1526,6 +1536,16 @@ exports.CalcomApi = __decorate([
|
|
|
1526
1536
|
return calcom.getBusyTimes(this.context);
|
|
1527
1537
|
}
|
|
1528
1538
|
},
|
|
1539
|
+
{
|
|
1540
|
+
key: "getBusyTimesForConnectedCalendars",
|
|
1541
|
+
get: /**
|
|
1542
|
+
* Configured pass-through for {@link getBusyTimesForConnectedCalendars}.
|
|
1543
|
+
*
|
|
1544
|
+
* @returns Function to retrieve busy times without having to resolve `calendarsToLoad` first.
|
|
1545
|
+
*/ function get() {
|
|
1546
|
+
return calcom.getBusyTimesForConnectedCalendars(this.context);
|
|
1547
|
+
}
|
|
1548
|
+
},
|
|
1529
1549
|
{
|
|
1530
1550
|
key: "createWebhook",
|
|
1531
1551
|
get: // MARK: Webhooks
|
|
@@ -1654,7 +1674,6 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
1654
1674
|
var CALCOM_WEBHOOK_BOOKING_CREATED = 'BOOKING_CREATED';
|
|
1655
1675
|
var CALCOM_WEBHOOK_BOOKING_CANCELLED = 'BOOKING_CANCELLED';
|
|
1656
1676
|
var CALCOM_WEBHOOK_BOOKING_RESCHEDULED = 'BOOKING_RESCHEDULED';
|
|
1657
|
-
var CALCOM_WEBHOOK_BOOKING_CONFIRMED = 'BOOKING_CONFIRMED';
|
|
1658
1677
|
|
|
1659
1678
|
function _define_property$3(obj, key, value) {
|
|
1660
1679
|
if (key in obj) {
|
|
@@ -1724,8 +1743,7 @@ var calcomEventHandlerConfigurerFactory = util.handlerConfigurerFactory({
|
|
|
1724
1743
|
var configurer = _object_spread_props(_object_spread({}, accessor), {
|
|
1725
1744
|
handleBookingCreated: fnWithKey(CALCOM_WEBHOOK_BOOKING_CREATED),
|
|
1726
1745
|
handleBookingCancelled: fnWithKey(CALCOM_WEBHOOK_BOOKING_CANCELLED),
|
|
1727
|
-
handleBookingRescheduled: fnWithKey(CALCOM_WEBHOOK_BOOKING_RESCHEDULED)
|
|
1728
|
-
handleBookingConfirmed: fnWithKey(CALCOM_WEBHOOK_BOOKING_CONFIRMED)
|
|
1746
|
+
handleBookingRescheduled: fnWithKey(CALCOM_WEBHOOK_BOOKING_RESCHEDULED)
|
|
1729
1747
|
});
|
|
1730
1748
|
return configurer;
|
|
1731
1749
|
}
|
|
@@ -2378,7 +2396,6 @@ exports.CALCOM_REFRESH_TOKEN_CONFIG_KEY = CALCOM_REFRESH_TOKEN_CONFIG_KEY;
|
|
|
2378
2396
|
exports.CALCOM_SERVER_TOKEN_FILE_KEY = CALCOM_SERVER_TOKEN_FILE_KEY;
|
|
2379
2397
|
exports.CALCOM_SERVICE_NAME = CALCOM_SERVICE_NAME;
|
|
2380
2398
|
exports.CALCOM_WEBHOOK_BOOKING_CANCELLED = CALCOM_WEBHOOK_BOOKING_CANCELLED;
|
|
2381
|
-
exports.CALCOM_WEBHOOK_BOOKING_CONFIRMED = CALCOM_WEBHOOK_BOOKING_CONFIRMED;
|
|
2382
2399
|
exports.CALCOM_WEBHOOK_BOOKING_CREATED = CALCOM_WEBHOOK_BOOKING_CREATED;
|
|
2383
2400
|
exports.CALCOM_WEBHOOK_BOOKING_RESCHEDULED = CALCOM_WEBHOOK_BOOKING_RESCHEDULED;
|
|
2384
2401
|
exports.CALCOM_WEBHOOK_SECRET_CONFIG_KEY = CALCOM_WEBHOOK_SECRET_CONFIG_KEY;
|
package/nestjs/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger, Injectable, Inject, Post, Res, Req, Controller, Module } from '@nestjs/common';
|
|
2
|
-
import { calcomOAuthFactory, calcomAuthCredentialFromValues, exchangeAuthorizationCode, calcomAccessTokenFromTokenResponse, calcomFactory, getMe, getSchedules, createBooking, getBooking, cancelBooking, getEventTypes, createEventType, updateEventType, deleteEventType, getCalendars, getBusyTimes, createWebhook, getWebhooks, getWebhook, updateWebhook, deleteWebhook, getAvailableSlots } from '@dereekb/calcom';
|
|
2
|
+
import { calcomOAuthFactory, calcomAuthCredentialFromValues, exchangeAuthorizationCode, calcomAccessTokenFromTokenResponse, calcomFactory, getMe, getSchedules, createBooking, getBooking, getBookings, cancelBooking, getEventTypes, createEventType, updateEventType, deleteEventType, getCalendars, getBusyTimes, getBusyTimesForConnectedCalendars, createWebhook, getWebhooks, getWebhook, updateWebhook, deleteWebhook, getAvailableSlots } from '@dereekb/calcom';
|
|
3
3
|
import { inMemoryAsyncValueCache, inMemoryAsyncKeyedValueCache, mergeAsyncValueCaches, isExpired, filterMaybeArrayValues, cachedGetter, handlerFactory, handlerConfigurerFactory, handlerMappedSetFunctionFactory } from '@dereekb/util';
|
|
4
4
|
import { createMemoizedJsonFileAsyncValueCache, RawBody } from '@dereekb/nestjs';
|
|
5
5
|
import { createHash, createHmac } from 'node:crypto';
|
|
@@ -1452,6 +1452,16 @@ CalcomApi = __decorate([
|
|
|
1452
1452
|
return getBooking(this.context);
|
|
1453
1453
|
}
|
|
1454
1454
|
},
|
|
1455
|
+
{
|
|
1456
|
+
key: "getBookings",
|
|
1457
|
+
get: /**
|
|
1458
|
+
* Configured pass-through for {@link getBookings}.
|
|
1459
|
+
*
|
|
1460
|
+
* @returns Function to retrieve a page of bookings.
|
|
1461
|
+
*/ function get() {
|
|
1462
|
+
return getBookings(this.context);
|
|
1463
|
+
}
|
|
1464
|
+
},
|
|
1455
1465
|
{
|
|
1456
1466
|
key: "cancelBooking",
|
|
1457
1467
|
get: /**
|
|
@@ -1524,6 +1534,16 @@ CalcomApi = __decorate([
|
|
|
1524
1534
|
return getBusyTimes(this.context);
|
|
1525
1535
|
}
|
|
1526
1536
|
},
|
|
1537
|
+
{
|
|
1538
|
+
key: "getBusyTimesForConnectedCalendars",
|
|
1539
|
+
get: /**
|
|
1540
|
+
* Configured pass-through for {@link getBusyTimesForConnectedCalendars}.
|
|
1541
|
+
*
|
|
1542
|
+
* @returns Function to retrieve busy times without having to resolve `calendarsToLoad` first.
|
|
1543
|
+
*/ function get() {
|
|
1544
|
+
return getBusyTimesForConnectedCalendars(this.context);
|
|
1545
|
+
}
|
|
1546
|
+
},
|
|
1527
1547
|
{
|
|
1528
1548
|
key: "createWebhook",
|
|
1529
1549
|
get: // MARK: Webhooks
|
|
@@ -1652,7 +1672,6 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
1652
1672
|
var CALCOM_WEBHOOK_BOOKING_CREATED = 'BOOKING_CREATED';
|
|
1653
1673
|
var CALCOM_WEBHOOK_BOOKING_CANCELLED = 'BOOKING_CANCELLED';
|
|
1654
1674
|
var CALCOM_WEBHOOK_BOOKING_RESCHEDULED = 'BOOKING_RESCHEDULED';
|
|
1655
|
-
var CALCOM_WEBHOOK_BOOKING_CONFIRMED = 'BOOKING_CONFIRMED';
|
|
1656
1675
|
|
|
1657
1676
|
function _define_property$3(obj, key, value) {
|
|
1658
1677
|
if (key in obj) {
|
|
@@ -1722,8 +1741,7 @@ var calcomEventHandlerConfigurerFactory = handlerConfigurerFactory({
|
|
|
1722
1741
|
var configurer = _object_spread_props(_object_spread({}, accessor), {
|
|
1723
1742
|
handleBookingCreated: fnWithKey(CALCOM_WEBHOOK_BOOKING_CREATED),
|
|
1724
1743
|
handleBookingCancelled: fnWithKey(CALCOM_WEBHOOK_BOOKING_CANCELLED),
|
|
1725
|
-
handleBookingRescheduled: fnWithKey(CALCOM_WEBHOOK_BOOKING_RESCHEDULED)
|
|
1726
|
-
handleBookingConfirmed: fnWithKey(CALCOM_WEBHOOK_BOOKING_CONFIRMED)
|
|
1744
|
+
handleBookingRescheduled: fnWithKey(CALCOM_WEBHOOK_BOOKING_RESCHEDULED)
|
|
1727
1745
|
});
|
|
1728
1746
|
return configurer;
|
|
1729
1747
|
}
|
|
@@ -2369,4 +2387,4 @@ CalcomWebhookModule = __decorate([
|
|
|
2369
2387
|
};
|
|
2370
2388
|
}
|
|
2371
2389
|
|
|
2372
|
-
export { CALCOM_API_KEY_CONFIG_KEY, CALCOM_CLIENT_ID_CONFIG_KEY, CALCOM_CLIENT_SECRET_CONFIG_KEY, CALCOM_REFRESH_TOKEN_CONFIG_KEY, CALCOM_SERVER_TOKEN_FILE_KEY, CALCOM_SERVICE_NAME, CALCOM_WEBHOOK_BOOKING_CANCELLED,
|
|
2390
|
+
export { CALCOM_API_KEY_CONFIG_KEY, CALCOM_CLIENT_ID_CONFIG_KEY, CALCOM_CLIENT_SECRET_CONFIG_KEY, CALCOM_REFRESH_TOKEN_CONFIG_KEY, CALCOM_SERVER_TOKEN_FILE_KEY, CALCOM_SERVICE_NAME, CALCOM_WEBHOOK_BOOKING_CANCELLED, CALCOM_WEBHOOK_BOOKING_CREATED, CALCOM_WEBHOOK_BOOKING_RESCHEDULED, CALCOM_WEBHOOK_SECRET_CONFIG_KEY, CalcomApi, CalcomApiContextInstance, CalcomOAuthAccessTokenCacheService, CalcomOAuthApi, CalcomOAuthServiceConfig, CalcomServiceConfig, CalcomWebhookController, CalcomWebhookModule, CalcomWebhookService, CalcomWebhookServiceConfig, DEFAULT_FILE_CALCOM_ACCESS_TOKEN_CACHE_DIR, appCalcomModuleMetadata, appCalcomOAuthModuleMetadata, appCalcomWebhookModuleMetadata, calcomAccessTokenCacheFileKey, calcomEventHandlerConfigurerFactory, calcomEventHandlerFactory, calcomOAuthServiceConfigFactory, calcomRefreshTokenCacheKey, calcomServiceConfigFactory, calcomWebhookEvent, calcomWebhookEventVerifier, calcomWebhookServiceConfigFactory, fileCalcomOAuthAccessTokenCacheService, logMergeCalcomOAuthAccessTokenCacheServiceErrorFunction, memoryCalcomOAuthAccessTokenCacheService, mergeCalcomOAuthAccessTokenCacheServices };
|
package/nestjs/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/calcom/nestjs",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.37.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/nestjs": "13.
|
|
6
|
-
"@dereekb/rxjs": "13.
|
|
7
|
-
"@dereekb/util": "13.
|
|
8
|
-
"@dereekb/calcom": "13.
|
|
5
|
+
"@dereekb/nestjs": "13.37.0",
|
|
6
|
+
"@dereekb/rxjs": "13.37.0",
|
|
7
|
+
"@dereekb/util": "13.37.0",
|
|
8
|
+
"@dereekb/calcom": "13.37.0",
|
|
9
9
|
"@nestjs/common": "^11.1.19",
|
|
10
10
|
"@nestjs/config": "^4.0.4",
|
|
11
11
|
"express": "^5.2.1"
|
|
@@ -132,6 +132,12 @@ export declare class CalcomApiContextInstance {
|
|
|
132
132
|
* @returns Function to retrieve a booking by UID.
|
|
133
133
|
*/
|
|
134
134
|
get getBooking(): (uid: import("@dereekb/calcom").CalcomBookingUid) => Promise<import("@dereekb/calcom").CalcomGetBookingResponse>;
|
|
135
|
+
/**
|
|
136
|
+
* Configured pass-through for {@link getBookings}.
|
|
137
|
+
*
|
|
138
|
+
* @returns Function to retrieve a page of bookings.
|
|
139
|
+
*/
|
|
140
|
+
get getBookings(): (input?: import("@dereekb/util").Maybe<import("@dereekb/calcom").CalcomGetBookingsInput>) => Promise<import("@dereekb/calcom").CalcomGetBookingsResponse>;
|
|
135
141
|
/**
|
|
136
142
|
* Configured pass-through for {@link cancelBooking}.
|
|
137
143
|
*
|
|
@@ -174,6 +180,12 @@ export declare class CalcomApiContextInstance {
|
|
|
174
180
|
* @returns Function to retrieve busy time ranges across connected calendars.
|
|
175
181
|
*/
|
|
176
182
|
get getBusyTimes(): (input: import("@dereekb/calcom").CalcomGetBusyTimesInput) => Promise<import("@dereekb/calcom").CalcomGetBusyTimesResponse>;
|
|
183
|
+
/**
|
|
184
|
+
* Configured pass-through for {@link getBusyTimesForConnectedCalendars}.
|
|
185
|
+
*
|
|
186
|
+
* @returns Function to retrieve busy times without having to resolve `calendarsToLoad` first.
|
|
187
|
+
*/
|
|
188
|
+
get getBusyTimesForConnectedCalendars(): (input: import("@dereekb/calcom").CalcomGetBusyTimesForConnectedCalendarsInput) => Promise<import("@dereekb/calcom").CalcomGetBusyTimesResponse>;
|
|
177
189
|
/**
|
|
178
190
|
* Configured pass-through for {@link createWebhook}.
|
|
179
191
|
*
|
|
@@ -14,6 +14,5 @@ export interface CalcomEventHandlerConfigurer extends HandlerBindAccessor<Untype
|
|
|
14
14
|
handleBookingCreated: CalcomHandlerMappedSetFunction<CalcomWebhookBookingPayload>;
|
|
15
15
|
handleBookingCancelled: CalcomHandlerMappedSetFunction<CalcomWebhookBookingPayload>;
|
|
16
16
|
handleBookingRescheduled: CalcomHandlerMappedSetFunction<CalcomWebhookBookingPayload>;
|
|
17
|
-
handleBookingConfirmed: CalcomHandlerMappedSetFunction<CalcomWebhookBookingPayload>;
|
|
18
17
|
}
|
|
19
18
|
export declare const calcomEventHandlerConfigurerFactory: import("@dereekb/util").HandlerConfigurerFactory<CalcomEventHandlerConfigurer, UntypedCalcomWebhookEvent, string, boolean>;
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
import { type EmailAddress, type ISO8601DateString, type TimezoneString } from '@dereekb/util';
|
|
2
|
-
import { type CalcomBookingId, type CalcomBookingUid, type CalcomBookingStatus } from '@dereekb/calcom';
|
|
1
|
+
import { type EmailAddress, type ISO8601DateString, type SuggestedString, type TimezoneString } from '@dereekb/util';
|
|
2
|
+
import { type CalcomBookingId, type CalcomBookingUid, type CalcomBookingStatus, type CalcomWebhookTrigger } from '@dereekb/calcom';
|
|
3
3
|
export declare const CALCOM_WEBHOOK_BOOKING_CREATED = "BOOKING_CREATED";
|
|
4
4
|
export declare const CALCOM_WEBHOOK_BOOKING_CANCELLED = "BOOKING_CANCELLED";
|
|
5
5
|
export declare const CALCOM_WEBHOOK_BOOKING_RESCHEDULED = "BOOKING_RESCHEDULED";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The `triggerEvent` of an inbound webhook payload.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately open-ended: this is a value Cal.com sends US, so a trigger added upstream — or one
|
|
10
|
+
* enabled on a subscription that predates this package — has to keep parsing rather than fail to
|
|
11
|
+
* type. {@link CalcomWebhookTrigger} is the set the API actually accepts on a subscription, and is
|
|
12
|
+
* what autocompletes here.
|
|
13
|
+
*
|
|
14
|
+
* Note there is no `BOOKING_CONFIRMED` trigger, despite this package once declaring one: a booking
|
|
15
|
+
* awaiting confirmation arrives as `BOOKING_REQUESTED` and its acceptance as `BOOKING_CREATED`.
|
|
16
|
+
*/
|
|
17
|
+
export type CalcomWebhookEventType = SuggestedString<CalcomWebhookTrigger>;
|
|
18
|
+
export interface CalcomWebhookEvent<T, ET extends CalcomWebhookEventType = CalcomWebhookEventType> {
|
|
9
19
|
readonly triggerEvent: ET;
|
|
10
20
|
readonly createdAt: ISO8601DateString;
|
|
11
21
|
readonly payload: T;
|
|
@@ -21,6 +31,17 @@ export interface CalcomWebhookBookingOrganizer {
|
|
|
21
31
|
readonly name: string;
|
|
22
32
|
readonly timeZone: TimezoneString;
|
|
23
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* The booking as Cal.com POSTs it to a webhook subscriber.
|
|
36
|
+
*
|
|
37
|
+
* Deliberately NOT the same shape as the REST {@link CalcomBooking}: the webhook payload mirrors
|
|
38
|
+
* Cal.com's internal booking model and uses `startTime`/`endTime`, while `GET /v2/bookings/{uid}`
|
|
39
|
+
* returns `start`/`end`. Do not "align" these two out of a belief that they drifted — they are
|
|
40
|
+
* different surfaces.
|
|
41
|
+
*
|
|
42
|
+
* NOTE: unlike the REST types in this package, this shape has not been verified against a live
|
|
43
|
+
* payload (that requires a publicly reachable subscriber). Treat it as unconfirmed.
|
|
44
|
+
*/
|
|
24
45
|
export interface CalcomWebhookBookingPayload {
|
|
25
46
|
readonly id: CalcomBookingId;
|
|
26
47
|
readonly uid: CalcomBookingUid;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/calcom",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.37.0",
|
|
4
4
|
"exports": {
|
|
5
5
|
"./nestjs": {
|
|
6
6
|
"module": "./nestjs/index.esm.js",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@dereekb/nestjs": "13.
|
|
21
|
-
"@dereekb/rxjs": "13.
|
|
22
|
-
"@dereekb/util": "13.
|
|
20
|
+
"@dereekb/nestjs": "13.37.0",
|
|
21
|
+
"@dereekb/rxjs": "13.37.0",
|
|
22
|
+
"@dereekb/util": "13.37.0",
|
|
23
23
|
"@nestjs/common": "^11.1.19",
|
|
24
24
|
"@nestjs/config": "^4.0.4",
|
|
25
25
|
"express": "^5.2.1",
|
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
import { type EmailAddress, type ISO8601DateString, type Maybe, type Minutes, type TimezoneString } from '@dereekb/util';
|
|
1
|
+
import { type Count, type EmailAddress, type ISO8601DateString, type Maybe, type Minutes, type SortingOrder, type TimezoneString, type WebsiteUrl } from '@dereekb/util';
|
|
2
2
|
import { type CalcomContext } from './calcom.config';
|
|
3
|
-
import { type CalcomBookingId, type CalcomBookingUid, type CalcomBookingStatus, type CalcomEventTypeId, type CalcomResponseStatus } from '../calcom.type';
|
|
3
|
+
import { type CalcomBookingId, type CalcomBookingUid, type CalcomBookingStatus, type CalcomEventTypeId, type CalcomEventTypeSlug, type CalcomPagination, type CalcomResponseStatus, type CalcomUserId, type CalcomUsername } from '../calcom.type';
|
|
4
4
|
export interface CalcomBookingAttendee {
|
|
5
5
|
readonly name: string;
|
|
6
6
|
readonly email: EmailAddress;
|
|
7
|
+
readonly displayEmail: Maybe<EmailAddress>;
|
|
7
8
|
readonly timeZone: TimezoneString;
|
|
9
|
+
readonly language: string;
|
|
10
|
+
readonly absent: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface CalcomBookingHost {
|
|
13
|
+
readonly id: CalcomUserId;
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly email: EmailAddress;
|
|
16
|
+
readonly displayEmail: Maybe<EmailAddress>;
|
|
17
|
+
readonly username: CalcomUsername;
|
|
18
|
+
readonly timeZone: TimezoneString;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The event type a booking was made against, as embedded on the booking itself.
|
|
22
|
+
*/
|
|
23
|
+
export interface CalcomBookingEventType {
|
|
24
|
+
readonly id: CalcomEventTypeId;
|
|
25
|
+
readonly slug: CalcomEventTypeSlug;
|
|
8
26
|
}
|
|
9
27
|
export interface CalcomCreateBookingInput {
|
|
10
28
|
readonly start: ISO8601DateString;
|
|
@@ -15,6 +33,13 @@ export interface CalcomCreateBookingInput {
|
|
|
15
33
|
readonly timeZone: TimezoneString;
|
|
16
34
|
};
|
|
17
35
|
readonly metadata?: Maybe<Record<string, unknown>>;
|
|
36
|
+
/**
|
|
37
|
+
* Only valid when the target event type declares `lengthInMinutesOptions`.
|
|
38
|
+
*
|
|
39
|
+
* Sending it to an event type with a single fixed length is rejected with "Can't specify
|
|
40
|
+
* 'lengthInMinutes' because event type does not have multiple possible lengths", so leave it
|
|
41
|
+
* unset unless the event type is explicitly multi-length.
|
|
42
|
+
*/
|
|
18
43
|
readonly lengthInMinutes?: Maybe<Minutes>;
|
|
19
44
|
readonly guests?: Maybe<string[]>;
|
|
20
45
|
}
|
|
@@ -22,11 +47,34 @@ export interface CalcomBooking {
|
|
|
22
47
|
readonly id: CalcomBookingId;
|
|
23
48
|
readonly uid: CalcomBookingUid;
|
|
24
49
|
readonly title: string;
|
|
50
|
+
readonly description: string;
|
|
25
51
|
readonly status: CalcomBookingStatus;
|
|
26
|
-
|
|
27
|
-
|
|
52
|
+
/**
|
|
53
|
+
* The start of the booking. Note the API returns `start`/`end`, NOT `startTime`/`endTime`.
|
|
54
|
+
*/
|
|
55
|
+
readonly start: ISO8601DateString;
|
|
56
|
+
readonly end: ISO8601DateString;
|
|
57
|
+
readonly duration: Minutes;
|
|
58
|
+
readonly eventTypeId: CalcomEventTypeId;
|
|
59
|
+
readonly eventType: CalcomBookingEventType;
|
|
60
|
+
readonly hosts: CalcomBookingHost[];
|
|
28
61
|
readonly attendees: CalcomBookingAttendee[];
|
|
62
|
+
readonly guests: EmailAddress[];
|
|
63
|
+
/**
|
|
64
|
+
* The join url Cal.com supplies for the meeting, when the location is a conferencing app.
|
|
65
|
+
*/
|
|
66
|
+
readonly meetingUrl: Maybe<WebsiteUrl>;
|
|
67
|
+
readonly location: Maybe<string>;
|
|
68
|
+
readonly absentHost: boolean;
|
|
69
|
+
readonly cancellationReason: Maybe<string>;
|
|
70
|
+
readonly cancelledByEmail: Maybe<EmailAddress>;
|
|
71
|
+
readonly rescheduledByEmail: Maybe<EmailAddress>;
|
|
72
|
+
readonly icsUid: string;
|
|
73
|
+
readonly rating: Maybe<number>;
|
|
29
74
|
readonly metadata: Record<string, unknown>;
|
|
75
|
+
readonly bookingFieldsResponses: Record<string, unknown>;
|
|
76
|
+
readonly createdAt: ISO8601DateString;
|
|
77
|
+
readonly updatedAt: ISO8601DateString;
|
|
30
78
|
}
|
|
31
79
|
export interface CalcomCreateBookingResponse {
|
|
32
80
|
readonly status: CalcomResponseStatus;
|
|
@@ -36,6 +84,40 @@ export interface CalcomGetBookingResponse {
|
|
|
36
84
|
readonly status: CalcomResponseStatus;
|
|
37
85
|
readonly data: CalcomBooking;
|
|
38
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* How {@link getBookings} filters by status.
|
|
89
|
+
*
|
|
90
|
+
* Note this is a filter over the booking's position in time as well as its state, and is NOT the
|
|
91
|
+
* {@link CalcomBookingStatus} carried on a booking: passing an unknown value is rejected with
|
|
92
|
+
* "Invalid status. Allowed are upcoming, recurring, past, cancelled, unconfirmed".
|
|
93
|
+
*/
|
|
94
|
+
export type CalcomBookingsFilterStatus = 'upcoming' | 'recurring' | 'past' | 'cancelled' | 'unconfirmed';
|
|
95
|
+
export interface CalcomGetBookingsInput {
|
|
96
|
+
/**
|
|
97
|
+
* The number of bookings to return. The endpoint applies its own default (10) when unset.
|
|
98
|
+
*/
|
|
99
|
+
readonly take?: Maybe<Count>;
|
|
100
|
+
readonly skip?: Maybe<Count>;
|
|
101
|
+
readonly status?: Maybe<CalcomBookingsFilterStatus>;
|
|
102
|
+
readonly eventTypeId?: Maybe<CalcomEventTypeId>;
|
|
103
|
+
readonly attendeeEmail?: Maybe<EmailAddress>;
|
|
104
|
+
/**
|
|
105
|
+
* Only bookings that start at or after this instant.
|
|
106
|
+
*/
|
|
107
|
+
readonly afterStart?: Maybe<ISO8601DateString>;
|
|
108
|
+
/**
|
|
109
|
+
* Only bookings that end at or before this instant.
|
|
110
|
+
*/
|
|
111
|
+
readonly beforeEnd?: Maybe<ISO8601DateString>;
|
|
112
|
+
readonly sortStart?: Maybe<SortingOrder>;
|
|
113
|
+
readonly sortEnd?: Maybe<SortingOrder>;
|
|
114
|
+
readonly sortCreated?: Maybe<SortingOrder>;
|
|
115
|
+
}
|
|
116
|
+
export interface CalcomGetBookingsResponse {
|
|
117
|
+
readonly status: CalcomResponseStatus;
|
|
118
|
+
readonly data: CalcomBooking[];
|
|
119
|
+
readonly pagination: CalcomPagination;
|
|
120
|
+
}
|
|
39
121
|
export interface CalcomCancelBookingInput {
|
|
40
122
|
readonly uid: CalcomBookingUid;
|
|
41
123
|
readonly cancellationReason?: Maybe<string>;
|
|
@@ -66,6 +148,24 @@ export interface CalcomCancelBookingResponse {
|
|
|
66
148
|
* @__NO_SIDE_EFFECTS__
|
|
67
149
|
*/
|
|
68
150
|
export declare function createBooking(context: CalcomContext): (input: CalcomCreateBookingInput) => Promise<CalcomCreateBookingResponse>;
|
|
151
|
+
/**
|
|
152
|
+
* Retrieves the bookings visible to the authenticated user, newest page first.
|
|
153
|
+
*
|
|
154
|
+
* Paginated: read {@link CalcomGetBookingsResponse.pagination} rather than assuming `data` holds
|
|
155
|
+
* everything, as the endpoint caps a page even with no `take`.
|
|
156
|
+
*
|
|
157
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
158
|
+
* @returns Retrieves a page of bookings for the given input.
|
|
159
|
+
*
|
|
160
|
+
* @see https://cal.com/docs/api-reference/v2/bookings/get-all-bookings
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* const response = await getBookings(context)({ take: 10, status: 'upcoming', sortStart: 'asc' });
|
|
165
|
+
* console.log(response.pagination.totalItems, response.data.map(b => b.uid));
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
export declare function getBookings(context: CalcomContext): (input?: Maybe<CalcomGetBookingsInput>) => Promise<CalcomGetBookingsResponse>;
|
|
69
169
|
/**
|
|
70
170
|
* Retrieves a booking by its unique UID.
|
|
71
171
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EmailAddress, type ISO8601DateString, type Maybe } from '@dereekb/util';
|
|
1
|
+
import { type EmailAddress, type ISO8601DateString, type ISO8601DayString, type Maybe, type TimezoneString, type WebsiteUrl } from '@dereekb/util';
|
|
2
2
|
import { type CalcomContext } from './calcom.config';
|
|
3
3
|
import { type CalcomId, type CalcomCredentialId, type CalcomCalendarIntegration, type CalcomUserId, type CalcomEventTypeId, type CalcomResponseStatus } from '../calcom.type';
|
|
4
4
|
export interface CalcomCalendar {
|
|
@@ -7,15 +7,58 @@ export interface CalcomCalendar {
|
|
|
7
7
|
readonly name: string;
|
|
8
8
|
readonly readOnly: boolean;
|
|
9
9
|
readonly email: EmailAddress;
|
|
10
|
+
/**
|
|
11
|
+
* Whether Cal.com checks this calendar for conflicts.
|
|
12
|
+
*
|
|
13
|
+
* This is the flag to filter on when loading busy times; it is independent of {@link primary},
|
|
14
|
+
* and an account commonly has a selected calendar that is not its primary one.
|
|
15
|
+
*/
|
|
10
16
|
readonly isSelected: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether this is the primary calendar of the connection. Null on non-primary calendars.
|
|
19
|
+
*/
|
|
20
|
+
readonly primary: Maybe<boolean>;
|
|
11
21
|
readonly credentialId: CalcomCredentialId;
|
|
22
|
+
readonly delegationCredentialId: Maybe<CalcomId>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* App metadata describing the integration behind a connected calendar.
|
|
26
|
+
*
|
|
27
|
+
* Note this is an OBJECT, distinct from the {@link CalcomCalendarIntegration} string
|
|
28
|
+
* (e.g. `"google_calendar"`) carried on each individual {@link CalcomCalendar}.
|
|
29
|
+
*/
|
|
30
|
+
export interface CalcomCalendarIntegrationApp {
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly type: CalcomCalendarIntegration;
|
|
33
|
+
readonly title: string;
|
|
34
|
+
readonly slug: string;
|
|
35
|
+
readonly description: string;
|
|
36
|
+
readonly variant: string;
|
|
37
|
+
readonly category: string;
|
|
38
|
+
readonly categories: string[];
|
|
39
|
+
readonly logo: string;
|
|
40
|
+
readonly publisher: string;
|
|
41
|
+
readonly url: WebsiteUrl;
|
|
42
|
+
readonly email: EmailAddress;
|
|
43
|
+
readonly installed: boolean;
|
|
44
|
+
readonly isOAuth: boolean;
|
|
45
|
+
readonly dirName: Maybe<string>;
|
|
46
|
+
readonly locationOption: Maybe<unknown>;
|
|
47
|
+
readonly appData: Maybe<unknown>;
|
|
48
|
+
readonly delegationCredential: Maybe<unknown>;
|
|
12
49
|
}
|
|
13
50
|
export interface CalcomConnectedCalendar {
|
|
14
|
-
readonly integration:
|
|
51
|
+
readonly integration: CalcomCalendarIntegrationApp;
|
|
15
52
|
readonly credentialId: CalcomCredentialId;
|
|
16
|
-
readonly
|
|
17
|
-
|
|
18
|
-
|
|
53
|
+
readonly delegationCredentialId: Maybe<CalcomId>;
|
|
54
|
+
/**
|
|
55
|
+
* The primary calendar of this connection, as a single calendar.
|
|
56
|
+
*/
|
|
57
|
+
readonly primary: Maybe<CalcomCalendar>;
|
|
58
|
+
/**
|
|
59
|
+
* Every calendar available on this connection, as a sibling of {@link primary}.
|
|
60
|
+
*/
|
|
61
|
+
readonly calendars: CalcomCalendar[];
|
|
19
62
|
}
|
|
20
63
|
export interface CalcomDestinationCalendar {
|
|
21
64
|
readonly id: CalcomId;
|
|
@@ -27,9 +70,12 @@ export interface CalcomDestinationCalendar {
|
|
|
27
70
|
readonly email: EmailAddress;
|
|
28
71
|
readonly isSelected: boolean;
|
|
29
72
|
readonly credentialId: CalcomCredentialId;
|
|
73
|
+
readonly delegationCredentialId: Maybe<CalcomId>;
|
|
30
74
|
readonly userId: CalcomUserId;
|
|
31
75
|
readonly eventTypeId: Maybe<CalcomEventTypeId>;
|
|
32
76
|
readonly integrationTitle: string;
|
|
77
|
+
readonly createdAt: ISO8601DateString;
|
|
78
|
+
readonly updatedAt: ISO8601DateString;
|
|
33
79
|
}
|
|
34
80
|
export interface CalcomGetCalendarsResponseData {
|
|
35
81
|
readonly connectedCalendars: CalcomConnectedCalendar[];
|
|
@@ -39,11 +85,46 @@ export interface CalcomGetCalendarsResponse {
|
|
|
39
85
|
readonly status: CalcomResponseStatus;
|
|
40
86
|
readonly data: CalcomGetCalendarsResponseData;
|
|
41
87
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Addresses a single calendar to load busy times from.
|
|
90
|
+
*
|
|
91
|
+
* Both halves are required: the endpoint matches a calendar by its external id within a
|
|
92
|
+
* specific credential, and rejects the request when either is missing.
|
|
93
|
+
*/
|
|
94
|
+
export interface CalcomCalendarToLoad {
|
|
95
|
+
readonly credentialId: CalcomCredentialId;
|
|
96
|
+
readonly externalId: string;
|
|
97
|
+
}
|
|
98
|
+
export interface CalcomGetBusyTimesInputBase {
|
|
99
|
+
/**
|
|
100
|
+
* Accepts either a plain day (`2026-08-01`) or a full ISO instant.
|
|
101
|
+
*/
|
|
102
|
+
readonly dateFrom: ISO8601DateString | ISO8601DayString;
|
|
103
|
+
readonly dateTo: ISO8601DateString | ISO8601DayString;
|
|
104
|
+
/**
|
|
105
|
+
* The calendars to load, obtained from {@link getCalendars}.
|
|
106
|
+
*
|
|
107
|
+
* Encoded as an indexed object array (`calendarsToLoad[0][credentialId]=…`); the endpoint
|
|
108
|
+
* rejects any scalar form with "calendarsToLoad must be an array".
|
|
109
|
+
*/
|
|
110
|
+
readonly calendarsToLoad: CalcomCalendarToLoad[];
|
|
46
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* The endpoint rejects a request carrying neither timezone with
|
|
114
|
+
* "Either timeZone or loggedInUsersTz must be provided", so at least one is required.
|
|
115
|
+
*/
|
|
116
|
+
export type CalcomGetBusyTimesTimezoneInput = {
|
|
117
|
+
readonly timeZone: TimezoneString;
|
|
118
|
+
readonly loggedInUsersTz?: Maybe<TimezoneString>;
|
|
119
|
+
} | {
|
|
120
|
+
readonly timeZone?: Maybe<TimezoneString>;
|
|
121
|
+
readonly loggedInUsersTz: TimezoneString;
|
|
122
|
+
};
|
|
123
|
+
export type CalcomGetBusyTimesInput = CalcomGetBusyTimesInputBase & CalcomGetBusyTimesTimezoneInput;
|
|
124
|
+
/**
|
|
125
|
+
* Input for {@link getBusyTimesForConnectedCalendars}, which derives `calendarsToLoad` itself.
|
|
126
|
+
*/
|
|
127
|
+
export type CalcomGetBusyTimesForConnectedCalendarsInput = Omit<CalcomGetBusyTimesInputBase, 'calendarsToLoad'> & CalcomGetBusyTimesTimezoneInput;
|
|
47
128
|
export interface CalcomBusyTime {
|
|
48
129
|
readonly start: ISO8601DateString;
|
|
49
130
|
readonly end: ISO8601DateString;
|
|
@@ -64,12 +145,25 @@ export interface CalcomGetBusyTimesResponse {
|
|
|
64
145
|
* @example
|
|
65
146
|
* ```ts
|
|
66
147
|
* const response = await getCalendars(context)();
|
|
67
|
-
* response.data.connectedCalendars.forEach(cc => console.log(cc.integration));
|
|
148
|
+
* response.data.connectedCalendars.forEach(cc => console.log(cc.integration.slug, cc.calendars.length));
|
|
68
149
|
* ```
|
|
69
150
|
*/
|
|
70
151
|
export declare function getCalendars(context: CalcomContext): () => Promise<CalcomGetCalendarsResponse>;
|
|
71
152
|
/**
|
|
72
|
-
*
|
|
153
|
+
* Selects the calendars to load busy times from, out of a set of connected calendars.
|
|
154
|
+
*
|
|
155
|
+
* Prefers the calendars Cal.com is configured to check for conflicts (`isSelected`), and falls
|
|
156
|
+
* back to a connection's primary calendar when that connection has nothing selected.
|
|
157
|
+
*
|
|
158
|
+
* @param connectedCalendars - The connected calendars to select from.
|
|
159
|
+
* @returns The calendars to load.
|
|
160
|
+
*/
|
|
161
|
+
export declare function calcomCalendarsToLoadFromConnectedCalendars(connectedCalendars: CalcomConnectedCalendar[]): CalcomCalendarToLoad[];
|
|
162
|
+
/**
|
|
163
|
+
* Retrieves busy time ranges across the given calendars for a date range.
|
|
164
|
+
*
|
|
165
|
+
* A caller cannot address this endpoint without first knowing its calendars, so this is the
|
|
166
|
+
* single-request primitive — see {@link getBusyTimesForConnectedCalendars} to resolve them too.
|
|
73
167
|
*
|
|
74
168
|
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
75
169
|
* @returns Retrieves busy time ranges for a date range.
|
|
@@ -80,9 +174,31 @@ export declare function getCalendars(context: CalcomContext): () => Promise<Calc
|
|
|
80
174
|
* ```ts
|
|
81
175
|
* const response = await getBusyTimes(context)({
|
|
82
176
|
* dateFrom: '2026-03-17',
|
|
83
|
-
* dateTo: '2026-03-24'
|
|
177
|
+
* dateTo: '2026-03-24',
|
|
178
|
+
* timeZone: 'America/Chicago',
|
|
179
|
+
* calendarsToLoad: [{ credentialId: 1845764, externalId: 'someone@example.com' }]
|
|
84
180
|
* });
|
|
85
181
|
* response.data.forEach(bt => console.log(bt.start, bt.end));
|
|
86
182
|
* ```
|
|
87
183
|
*/
|
|
88
184
|
export declare function getBusyTimes(context: CalcomContext): (input: CalcomGetBusyTimesInput) => Promise<CalcomGetBusyTimesResponse>;
|
|
185
|
+
/**
|
|
186
|
+
* Retrieves busy time ranges across the user's connected calendars for a date range.
|
|
187
|
+
*
|
|
188
|
+
* Convenience over {@link getBusyTimes}: loads the connected calendars first and derives
|
|
189
|
+
* `calendarsToLoad` via {@link calcomCalendarsToLoadFromConnectedCalendars}, so a caller does not
|
|
190
|
+
* have to know Cal.com's `isSelected`/primary selection rule. Issues two requests.
|
|
191
|
+
*
|
|
192
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
193
|
+
* @returns Retrieves busy time ranges across the user's connected calendars.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* const response = await getBusyTimesForConnectedCalendars(context)({
|
|
198
|
+
* dateFrom: '2026-03-17',
|
|
199
|
+
* dateTo: '2026-03-24',
|
|
200
|
+
* loggedInUsersTz: 'UTC'
|
|
201
|
+
* });
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
export declare function getBusyTimesForConnectedCalendars(context: CalcomContext): (input: CalcomGetBusyTimesForConnectedCalendarsInput) => Promise<CalcomGetBusyTimesResponse>;
|