@dereekb/calcom 13.11.14 → 13.11.16
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 +98 -89
- package/index.esm.js +98 -89
- package/nestjs/index.cjs.js +79 -74
- package/nestjs/index.esm.js +79 -74
- package/nestjs/package.json +5 -5
- package/nestjs/src/lib/calcom/calcom.api.d.ts +24 -24
- package/nestjs/src/lib/calcom/calcom.module.d.ts +4 -4
- package/nestjs/src/lib/oauth/oauth.api.d.ts +7 -7
- package/nestjs/src/lib/oauth/oauth.config.d.ts +2 -2
- package/nestjs/src/lib/oauth/oauth.module.d.ts +2 -2
- package/nestjs/src/lib/oauth/oauth.service.d.ts +12 -11
- package/nestjs/src/lib/webhook/webhook.calcom.d.ts +2 -2
- package/nestjs/src/lib/webhook/webhook.calcom.module.d.ts +4 -4
- package/nestjs/src/lib/webhook/webhook.calcom.verify.d.ts +2 -2
- package/package.json +4 -4
- package/src/lib/calcom/calcom.api.booking.d.ts +10 -9
- package/src/lib/calcom/calcom.api.calendar.d.ts +6 -6
- package/src/lib/calcom/calcom.api.eventtype.d.ts +15 -14
- package/src/lib/calcom/calcom.api.schedule.d.ts +3 -3
- package/src/lib/calcom/calcom.api.slot.d.ts +3 -3
- package/src/lib/calcom/calcom.api.user.d.ts +6 -6
- package/src/lib/calcom/calcom.api.webhook.d.ts +19 -18
- package/src/lib/calcom/calcom.error.api.d.ts +5 -5
- package/src/lib/calcom/calcom.factory.d.ts +3 -2
- package/src/lib/calcom.error.api.d.ts +12 -10
- package/src/lib/calcom.limit.d.ts +2 -2
- package/src/lib/oauth/oauth.api.d.ts +6 -6
- package/src/lib/oauth/oauth.d.ts +3 -2
- package/src/lib/oauth/oauth.error.api.d.ts +5 -5
- package/src/lib/oauth/oauth.factory.d.ts +8 -6
- package/src/lib/shared/calcom.api-version.d.ts +2 -2
|
@@ -22,7 +22,7 @@ export declare abstract class CalcomOAuthServiceConfig {
|
|
|
22
22
|
/**
|
|
23
23
|
* Factory function that creates a {@link CalcomOAuthServiceConfig} from NestJS ConfigService environment variables.
|
|
24
24
|
*
|
|
25
|
-
* @param configService -
|
|
26
|
-
* @returns
|
|
25
|
+
* @param configService - The NestJS ConfigService instance.
|
|
26
|
+
* @returns A validated CalcomOAuthServiceConfig.
|
|
27
27
|
*/
|
|
28
28
|
export declare function calcomOAuthServiceConfigFactory(configService: ConfigService): CalcomOAuthServiceConfig;
|
|
@@ -21,7 +21,7 @@ export interface ProvideAppCalcomOAuthMetadataConfig extends Pick<ModuleMetadata
|
|
|
21
21
|
/**
|
|
22
22
|
* Convenience function used to generate ModuleMetadata for an app's CalcomOAuthModule.
|
|
23
23
|
*
|
|
24
|
-
* @param config -
|
|
25
|
-
* @returns NestJS ModuleMetadata for registering the CalcomOAuthModule
|
|
24
|
+
* @param config - The module metadata configuration including optional dependency module and config factory.
|
|
25
|
+
* @returns NestJS ModuleMetadata for registering the CalcomOAuthModule.
|
|
26
26
|
*/
|
|
27
27
|
export declare function appCalcomOAuthModuleMetadata(config: ProvideAppCalcomOAuthMetadataConfig): ModuleMetadata;
|
|
@@ -27,8 +27,8 @@ export type CalcomOAuthAccessTokenCacheServiceWithRefreshToken = Required<Calcom
|
|
|
27
27
|
*
|
|
28
28
|
* Uses SHA-256 truncated to 16 hex chars; the goal is fingerprinting, not security.
|
|
29
29
|
*
|
|
30
|
-
* @param refreshToken -
|
|
31
|
-
* @returns
|
|
30
|
+
* @param refreshToken - The OAuth refresh token to hash.
|
|
31
|
+
* @returns A 16-character hex string suitable for use as a cache key.
|
|
32
32
|
*/
|
|
33
33
|
export declare function calcomRefreshTokenCacheKey(refreshToken: string): string;
|
|
34
34
|
export type LogMergeCalcomOAuthAccessTokenCacheServiceErrorFunction = (failedUpdates: (readonly [CalcomAccessTokenCache, unknown])[]) => void;
|
|
@@ -36,7 +36,7 @@ export type LogMergeCalcomOAuthAccessTokenCacheServiceErrorFunction = (failedUpd
|
|
|
36
36
|
* Default error logging function for {@link mergeCalcomOAuthAccessTokenCacheServices}.
|
|
37
37
|
* Logs a warning for each cache that failed to update.
|
|
38
38
|
*
|
|
39
|
-
* @param failedUpdates -
|
|
39
|
+
* @param failedUpdates - Array of tuples containing the failed cache and its error.
|
|
40
40
|
*/
|
|
41
41
|
export declare function logMergeCalcomOAuthAccessTokenCacheServiceErrorFunction(failedUpdates: (readonly [CalcomAccessTokenCache, unknown])[]): void;
|
|
42
42
|
/**
|
|
@@ -50,9 +50,10 @@ export declare function logMergeCalcomOAuthAccessTokenCacheServiceErrorFunction(
|
|
|
50
50
|
* never short-circuits the lookup. Updates run across all services in parallel via
|
|
51
51
|
* `Promise.allSettled`, mirroring the previous behavior, with optional error logging.
|
|
52
52
|
*
|
|
53
|
-
* @param inputServicesToMerge Must include at least one service. Empty arrays will throw an error.
|
|
54
|
-
* @param logError -
|
|
55
|
-
* @returns
|
|
53
|
+
* @param inputServicesToMerge - Must include at least one service. Empty arrays will throw an error.
|
|
54
|
+
* @param logError - Optional error logging configuration; pass a function, true for default logging, or false to disable.
|
|
55
|
+
* @returns A merged CalcomOAuthAccessTokenCacheService that delegates across all input services.
|
|
56
|
+
* @throws {Error} When `inputServicesToMerge` is empty.
|
|
56
57
|
*/
|
|
57
58
|
export declare function mergeCalcomOAuthAccessTokenCacheServices(inputServicesToMerge: CalcomOAuthAccessTokenCacheService[], logError?: Maybe<boolean | LogMergeCalcomOAuthAccessTokenCacheServiceErrorFunction>): CalcomOAuthAccessTokenCacheService;
|
|
58
59
|
/**
|
|
@@ -62,9 +63,9 @@ export declare function mergeCalcomOAuthAccessTokenCacheServices(inputServicesTo
|
|
|
62
63
|
* per-user tokens are held in an {@link inMemoryAsyncKeyedValueCache} keyed by the
|
|
63
64
|
* sha256-truncated refresh token hash.
|
|
64
65
|
*
|
|
65
|
-
* @param existingToken -
|
|
66
|
-
* @param logAccessToConsole -
|
|
67
|
-
* @returns
|
|
66
|
+
* @param existingToken - Optional pre-existing server-level access token to seed the cache.
|
|
67
|
+
* @param logAccessToConsole - When true, logs all cache reads and writes to console.
|
|
68
|
+
* @returns A CalcomOAuthAccessTokenCacheService backed by in-memory caches.
|
|
68
69
|
*/
|
|
69
70
|
export declare function memoryCalcomOAuthAccessTokenCacheService(existingToken?: Maybe<CalcomAccessToken>, logAccessToConsole?: boolean): CalcomOAuthAccessTokenCacheService;
|
|
70
71
|
export declare const DEFAULT_FILE_CALCOM_ACCESS_TOKEN_CACHE_DIR = ".tmp/calcom-tokens";
|
|
@@ -89,7 +90,7 @@ export interface FileSystemCalcomOAuthAccessTokenCacheService extends CalcomOAut
|
|
|
89
90
|
* user-<sha256hash>.json — per-user tokens (hash of initial refresh token)
|
|
90
91
|
* ```
|
|
91
92
|
*
|
|
92
|
-
* @param cacheDir Directory to store token files. Defaults to `.tmp/calcom-tokens`.
|
|
93
|
-
* @returns
|
|
93
|
+
* @param cacheDir - Directory to store token files. Defaults to `.tmp/calcom-tokens`.
|
|
94
|
+
* @returns A CalcomOAuthAccessTokenCacheService backed by the file system.
|
|
94
95
|
*/
|
|
95
96
|
export declare function fileCalcomOAuthAccessTokenCacheService(cacheDir?: string): FileSystemCalcomOAuthAccessTokenCacheService;
|
|
@@ -3,8 +3,8 @@ import { type CalcomWebhookEventType, type UntypedCalcomWebhookEvent, type Calco
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates a CalcomWebhookEvent and treats the data as the input type.
|
|
5
5
|
*
|
|
6
|
-
* @param event -
|
|
7
|
-
* @returns
|
|
6
|
+
* @param event - The untyped webhook event to convert.
|
|
7
|
+
* @returns A typed CalcomWebhookEvent with the payload cast to type T.
|
|
8
8
|
*/
|
|
9
9
|
export declare function calcomWebhookEvent<T>(event: UntypedCalcomWebhookEvent): CalcomWebhookEvent<T>;
|
|
10
10
|
export type CalcomEventHandler = Handler<UntypedCalcomWebhookEvent, CalcomWebhookEventType>;
|
|
@@ -5,8 +5,8 @@ import { type Maybe } from '@dereekb/util';
|
|
|
5
5
|
/**
|
|
6
6
|
* Factory function that creates a {@link CalcomWebhookServiceConfig} from NestJS ConfigService environment variables.
|
|
7
7
|
*
|
|
8
|
-
* @param configService -
|
|
9
|
-
* @returns
|
|
8
|
+
* @param configService - The NestJS ConfigService instance.
|
|
9
|
+
* @returns A validated CalcomWebhookServiceConfig.
|
|
10
10
|
*/
|
|
11
11
|
export declare function calcomWebhookServiceConfigFactory(configService: ConfigService): CalcomWebhookServiceConfig;
|
|
12
12
|
/**
|
|
@@ -23,7 +23,7 @@ export interface ProvideAppCalcomWebhookMetadataConfig extends Pick<ModuleMetada
|
|
|
23
23
|
/**
|
|
24
24
|
* Convenience function used to generate ModuleMetadata for an app's CalcomWebhookModule.
|
|
25
25
|
*
|
|
26
|
-
* @param config -
|
|
27
|
-
* @returns NestJS ModuleMetadata for registering the CalcomWebhookModule
|
|
26
|
+
* @param config - The module metadata configuration including optional dependency module.
|
|
27
|
+
* @returns NestJS ModuleMetadata for registering the CalcomWebhookModule.
|
|
28
28
|
*/
|
|
29
29
|
export declare function appCalcomWebhookModuleMetadata(config: ProvideAppCalcomWebhookMetadataConfig): ModuleMetadata;
|
|
@@ -10,7 +10,7 @@ export type CalcomWebhookEventVerifier = (rawBody: Buffer, headers: Record<strin
|
|
|
10
10
|
/**
|
|
11
11
|
* Verifies a Cal.com webhook event using HMAC-SHA256 signature.
|
|
12
12
|
*
|
|
13
|
-
* @param secret The webhook signing secret.
|
|
14
|
-
* @returns
|
|
13
|
+
* @param secret - The webhook signing secret.
|
|
14
|
+
* @returns Verifies a Cal.com webhook event.
|
|
15
15
|
*/
|
|
16
16
|
export declare function calcomWebhookEventVerifier(secret: string): CalcomWebhookEventVerifier;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/calcom",
|
|
3
|
-
"version": "13.11.
|
|
3
|
+
"version": "13.11.16",
|
|
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.11.
|
|
21
|
-
"@dereekb/rxjs": "13.11.
|
|
22
|
-
"@dereekb/util": "13.11.
|
|
20
|
+
"@dereekb/nestjs": "13.11.16",
|
|
21
|
+
"@dereekb/rxjs": "13.11.16",
|
|
22
|
+
"@dereekb/util": "13.11.16",
|
|
23
23
|
"@nestjs/common": "^11.1.19",
|
|
24
24
|
"@nestjs/config": "^4.0.4",
|
|
25
25
|
"express": "^5.2.1",
|
|
@@ -48,10 +48,10 @@ export interface CalcomCancelBookingResponse {
|
|
|
48
48
|
* Creates a new booking for the specified event type. The `attendee` represents the person
|
|
49
49
|
* booking (the client), not the host. This endpoint can be called without authentication.
|
|
50
50
|
*
|
|
51
|
-
* @
|
|
51
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
52
|
+
* @returns Creates a booking from the given input.
|
|
52
53
|
*
|
|
53
|
-
* @
|
|
54
|
-
* @returns a function that creates a booking from the given input
|
|
54
|
+
* @see https://cal.com/docs/api-reference/v2/bookings/create-a-booking
|
|
55
55
|
*
|
|
56
56
|
* @example
|
|
57
57
|
* ```ts
|
|
@@ -62,16 +62,17 @@ export interface CalcomCancelBookingResponse {
|
|
|
62
62
|
* });
|
|
63
63
|
* console.log(response.data.uid);
|
|
64
64
|
* ```
|
|
65
|
+
*
|
|
65
66
|
* @__NO_SIDE_EFFECTS__
|
|
66
67
|
*/
|
|
67
68
|
export declare function createBooking(context: CalcomContext): (input: CalcomCreateBookingInput) => Promise<CalcomCreateBookingResponse>;
|
|
68
69
|
/**
|
|
69
70
|
* Retrieves a booking by its unique UID.
|
|
70
71
|
*
|
|
71
|
-
* @
|
|
72
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
73
|
+
* @returns Retrieves a booking by its UID.
|
|
72
74
|
*
|
|
73
|
-
* @
|
|
74
|
-
* @returns a function that retrieves a booking by its UID
|
|
75
|
+
* @see https://cal.com/docs/api-reference/v2/bookings/get-a-booking
|
|
75
76
|
*
|
|
76
77
|
* @example
|
|
77
78
|
* ```ts
|
|
@@ -83,10 +84,10 @@ export declare function getBooking(context: CalcomContext): (uid: CalcomBookingU
|
|
|
83
84
|
/**
|
|
84
85
|
* Cancels a booking by its unique UID, with an optional cancellation reason.
|
|
85
86
|
*
|
|
86
|
-
* @
|
|
87
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
88
|
+
* @returns Cancels a booking by UID.
|
|
87
89
|
*
|
|
88
|
-
* @
|
|
89
|
-
* @returns a function that cancels a booking by UID
|
|
90
|
+
* @see https://cal.com/docs/api-reference/v2/bookings/cancel-a-booking
|
|
90
91
|
*
|
|
91
92
|
* @example
|
|
92
93
|
* ```ts
|
|
@@ -56,10 +56,10 @@ export interface CalcomGetBusyTimesResponse {
|
|
|
56
56
|
/**
|
|
57
57
|
* Retrieves all connected calendars and the destination calendar for the authenticated user.
|
|
58
58
|
*
|
|
59
|
-
* @
|
|
59
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
60
|
+
* @returns Retrieves all connected calendars.
|
|
60
61
|
*
|
|
61
|
-
* @
|
|
62
|
-
* @returns a function that retrieves all connected calendars
|
|
62
|
+
* @see https://cal.com/docs/api-reference/v2/calendars/get-all-calendars
|
|
63
63
|
*
|
|
64
64
|
* @example
|
|
65
65
|
* ```ts
|
|
@@ -71,10 +71,10 @@ export declare function getCalendars(context: CalcomContext): () => Promise<Calc
|
|
|
71
71
|
/**
|
|
72
72
|
* Retrieves busy time ranges across the user's connected calendars for a given date range.
|
|
73
73
|
*
|
|
74
|
-
* @
|
|
74
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
75
|
+
* @returns Retrieves busy time ranges for a date range.
|
|
75
76
|
*
|
|
76
|
-
* @
|
|
77
|
-
* @returns a function that retrieves busy time ranges for a date range
|
|
77
|
+
* @see https://cal.com/docs/api-reference/v2/calendars/get-busy-times
|
|
78
78
|
*
|
|
79
79
|
* @example
|
|
80
80
|
* ```ts
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type Minutes } from '@dereekb/util';
|
|
1
|
+
import { type Minutes, type Maybe } from '@dereekb/util';
|
|
2
2
|
import { type CalcomContext } from './calcom.config';
|
|
3
3
|
import { type CalcomEventTypeId, type CalcomEventTypeSlug, type CalcomResponseStatus } from '../calcom.type';
|
|
4
4
|
export interface CalcomEventType {
|
|
5
5
|
readonly id: CalcomEventTypeId;
|
|
6
6
|
readonly title: string;
|
|
7
7
|
readonly slug: CalcomEventTypeSlug;
|
|
8
|
-
readonly description: string
|
|
8
|
+
readonly description: Maybe<string>;
|
|
9
9
|
readonly lengthInMinutes: Minutes;
|
|
10
10
|
readonly locations: unknown[];
|
|
11
11
|
}
|
|
@@ -36,10 +36,10 @@ export interface CalcomUpdateEventTypeInput {
|
|
|
36
36
|
/**
|
|
37
37
|
* Retrieves all event types for the authenticated user.
|
|
38
38
|
*
|
|
39
|
-
* @
|
|
39
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
40
|
+
* @returns Retrieves all event types.
|
|
40
41
|
*
|
|
41
|
-
* @
|
|
42
|
-
* @returns a function that retrieves all event types
|
|
42
|
+
* @see https://cal.com/docs/api-reference/v2/event-types/get-all-event-types
|
|
43
43
|
*
|
|
44
44
|
* @example
|
|
45
45
|
* ```ts
|
|
@@ -51,10 +51,10 @@ export declare function getEventTypes(context: CalcomContext): () => Promise<Cal
|
|
|
51
51
|
/**
|
|
52
52
|
* Creates a new event type for the authenticated user.
|
|
53
53
|
*
|
|
54
|
-
* @
|
|
54
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
55
|
+
* @returns Creates a new event type from the given input.
|
|
55
56
|
*
|
|
56
|
-
* @
|
|
57
|
-
* @returns a function that creates a new event type from the given input
|
|
57
|
+
* @see https://cal.com/docs/api-reference/v2/event-types/create-an-event-type
|
|
58
58
|
*
|
|
59
59
|
* @example
|
|
60
60
|
* ```ts
|
|
@@ -65,16 +65,17 @@ export declare function getEventTypes(context: CalcomContext): () => Promise<Cal
|
|
|
65
65
|
* });
|
|
66
66
|
* console.log(response.data.id);
|
|
67
67
|
* ```
|
|
68
|
+
*
|
|
68
69
|
* @__NO_SIDE_EFFECTS__
|
|
69
70
|
*/
|
|
70
71
|
export declare function createEventType(context: CalcomContext): (input: CalcomCreateEventTypeInput) => Promise<CalcomEventTypeResponse>;
|
|
71
72
|
/**
|
|
72
73
|
* Updates an existing event type by ID.
|
|
73
74
|
*
|
|
74
|
-
* @
|
|
75
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
76
|
+
* @returns Updates an event type by ID.
|
|
75
77
|
*
|
|
76
|
-
* @
|
|
77
|
-
* @returns a function that updates an event type by ID
|
|
78
|
+
* @see https://cal.com/docs/api-reference/v2/event-types/update-an-event-type
|
|
78
79
|
*
|
|
79
80
|
* @example
|
|
80
81
|
* ```ts
|
|
@@ -85,10 +86,10 @@ export declare function updateEventType(context: CalcomContext): (eventTypeId: C
|
|
|
85
86
|
/**
|
|
86
87
|
* Deletes an event type by ID.
|
|
87
88
|
*
|
|
88
|
-
* @
|
|
89
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
90
|
+
* @returns Deletes an event type by ID.
|
|
89
91
|
*
|
|
90
|
-
* @
|
|
91
|
-
* @returns a function that deletes an event type by ID
|
|
92
|
+
* @see https://cal.com/docs/api-reference/v2/event-types/delete-an-event-type
|
|
92
93
|
*
|
|
93
94
|
* @example
|
|
94
95
|
* ```ts
|
|
@@ -21,10 +21,10 @@ export interface CalcomGetSchedulesResponse {
|
|
|
21
21
|
/**
|
|
22
22
|
* Retrieves all schedules for the authenticated user, including availability rules and overrides.
|
|
23
23
|
*
|
|
24
|
-
* @
|
|
24
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
25
|
+
* @returns Retrieves all schedules.
|
|
25
26
|
*
|
|
26
|
-
* @
|
|
27
|
-
* @returns a function that retrieves all schedules
|
|
27
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/get-all-schedules
|
|
28
28
|
*
|
|
29
29
|
* @example
|
|
30
30
|
* ```ts
|
|
@@ -28,10 +28,10 @@ export interface CalcomGetAvailableSlotsResponse {
|
|
|
28
28
|
*
|
|
29
29
|
* Identify the event type by `eventTypeId`, or by `eventTypeSlug` + `username`/`teamSlug`.
|
|
30
30
|
*
|
|
31
|
-
* @
|
|
31
|
+
* @param context - The Cal.com API context (authenticated or public)
|
|
32
|
+
* @returns Queries available slots for the given input.
|
|
32
33
|
*
|
|
33
|
-
* @
|
|
34
|
-
* @returns a function that queries available slots for the given input
|
|
34
|
+
* @see https://cal.com/docs/api-reference/v2/slots/get-available-time-slots-for-an-event-type
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
37
|
* ```ts
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { type EmailAddress, type ISO8601DateString, type TimezoneString } from '@dereekb/util';
|
|
1
|
+
import { type EmailAddress, type ISO8601DateString, type TimezoneString, type Maybe } from '@dereekb/util';
|
|
2
2
|
import { type CalcomContext } from './calcom.config';
|
|
3
3
|
import { type CalcomUserId, type CalcomUsername, type CalcomScheduleId, type CalcomResponseStatus } from '../calcom.type';
|
|
4
4
|
export interface CalcomUser {
|
|
5
5
|
readonly id: CalcomUserId;
|
|
6
6
|
readonly email: EmailAddress;
|
|
7
|
-
readonly username: CalcomUsername
|
|
7
|
+
readonly username: Maybe<CalcomUsername>;
|
|
8
8
|
readonly timeZone: TimezoneString;
|
|
9
9
|
readonly weekStart: string;
|
|
10
10
|
readonly createdDate: ISO8601DateString;
|
|
11
11
|
readonly timeFormat: number;
|
|
12
|
-
readonly defaultScheduleId: CalcomScheduleId
|
|
12
|
+
readonly defaultScheduleId: Maybe<CalcomScheduleId>;
|
|
13
13
|
}
|
|
14
14
|
export interface CalcomGetMeResponse {
|
|
15
15
|
readonly status: CalcomResponseStatus;
|
|
@@ -18,10 +18,10 @@ export interface CalcomGetMeResponse {
|
|
|
18
18
|
/**
|
|
19
19
|
* Retrieves the profile of the currently authenticated Cal.com user.
|
|
20
20
|
*
|
|
21
|
-
* @
|
|
21
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
22
|
+
* @returns Retrieves the authenticated user's profile.
|
|
22
23
|
*
|
|
23
|
-
* @
|
|
24
|
-
* @returns a function that retrieves the authenticated user's profile
|
|
24
|
+
* @see https://cal.com/docs/api-reference/v2/me
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
27
|
* ```ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type WebsiteUrl } from '@dereekb/util';
|
|
1
|
+
import { type WebsiteUrl, type Maybe } from '@dereekb/util';
|
|
2
2
|
import { type CalcomContext } from './calcom.config';
|
|
3
3
|
import { type CalcomWebhookId, type CalcomResponseStatus } from '../calcom.type';
|
|
4
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';
|
|
@@ -7,8 +7,8 @@ export interface CalcomWebhook {
|
|
|
7
7
|
readonly subscriberUrl: WebsiteUrl;
|
|
8
8
|
readonly triggers: CalcomWebhookTrigger[];
|
|
9
9
|
readonly active: boolean;
|
|
10
|
-
readonly payloadTemplate?: string
|
|
11
|
-
readonly secret?: string
|
|
10
|
+
readonly payloadTemplate?: Maybe<string>;
|
|
11
|
+
readonly secret?: Maybe<string>;
|
|
12
12
|
}
|
|
13
13
|
export interface CalcomCreateWebhookInput {
|
|
14
14
|
readonly subscriberUrl: WebsiteUrl;
|
|
@@ -36,10 +36,10 @@ export interface CalcomGetWebhooksResponse {
|
|
|
36
36
|
* Creates a webhook subscription for the authenticated user. Webhooks notify your app
|
|
37
37
|
* when specified events occur (e.g., bookings created, cancelled, rescheduled).
|
|
38
38
|
*
|
|
39
|
-
* @
|
|
39
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
40
|
+
* @returns Creates a webhook subscription from the given input.
|
|
40
41
|
*
|
|
41
|
-
* @
|
|
42
|
-
* @returns a function that creates a webhook subscription from the given input
|
|
42
|
+
* @see https://cal.com/docs/api-reference/v2/webhooks/create-a-webhook
|
|
43
43
|
*
|
|
44
44
|
* @example
|
|
45
45
|
* ```ts
|
|
@@ -50,16 +50,17 @@ export interface CalcomGetWebhooksResponse {
|
|
|
50
50
|
* });
|
|
51
51
|
* console.log(response.data.id);
|
|
52
52
|
* ```
|
|
53
|
+
*
|
|
53
54
|
* @__NO_SIDE_EFFECTS__
|
|
54
55
|
*/
|
|
55
56
|
export declare function createWebhook(context: CalcomContext): (input: CalcomCreateWebhookInput) => Promise<CalcomWebhookResponse>;
|
|
56
57
|
/**
|
|
57
58
|
* Retrieves all webhooks for the authenticated user.
|
|
58
59
|
*
|
|
59
|
-
* @
|
|
60
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
61
|
+
* @returns Retrieves all webhooks.
|
|
60
62
|
*
|
|
61
|
-
* @
|
|
62
|
-
* @returns a function that retrieves all webhooks
|
|
63
|
+
* @see https://cal.com/docs/api-reference/v2/webhooks/get-all-webhooks
|
|
63
64
|
*
|
|
64
65
|
* @example
|
|
65
66
|
* ```ts
|
|
@@ -71,10 +72,10 @@ export declare function getWebhooks(context: CalcomContext): () => Promise<Calco
|
|
|
71
72
|
/**
|
|
72
73
|
* Retrieves a specific webhook by ID.
|
|
73
74
|
*
|
|
74
|
-
* @
|
|
75
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
76
|
+
* @returns Retrieves a specific webhook by ID.
|
|
75
77
|
*
|
|
76
|
-
* @
|
|
77
|
-
* @returns a function that retrieves a specific webhook by ID
|
|
78
|
+
* @see https://cal.com/docs/api-reference/v2/webhooks/get-a-webhook
|
|
78
79
|
*
|
|
79
80
|
* @example
|
|
80
81
|
* ```ts
|
|
@@ -86,10 +87,10 @@ export declare function getWebhook(context: CalcomContext): (webhookId: CalcomWe
|
|
|
86
87
|
/**
|
|
87
88
|
* Updates an existing webhook by ID.
|
|
88
89
|
*
|
|
89
|
-
* @
|
|
90
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
91
|
+
* @returns Updates an existing webhook by ID.
|
|
90
92
|
*
|
|
91
|
-
* @
|
|
92
|
-
* @returns a function that updates an existing webhook by ID
|
|
93
|
+
* @see https://cal.com/docs/api-reference/v2/webhooks/update-a-webhook
|
|
93
94
|
*
|
|
94
95
|
* @example
|
|
95
96
|
* ```ts
|
|
@@ -100,10 +101,10 @@ export declare function updateWebhook(context: CalcomContext): (webhookId: Calco
|
|
|
100
101
|
/**
|
|
101
102
|
* Deletes a webhook by ID.
|
|
102
103
|
*
|
|
103
|
-
* @
|
|
104
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
105
|
+
* @returns Deletes a webhook by ID.
|
|
104
106
|
*
|
|
105
|
-
* @
|
|
106
|
-
* @returns a function that deletes a webhook by ID
|
|
107
|
+
* @see https://cal.com/docs/api-reference/v2/webhooks/delete-a-webhook
|
|
107
108
|
*
|
|
108
109
|
* @example
|
|
109
110
|
* ```ts
|
|
@@ -5,17 +5,17 @@ export declare const logCalcomErrorToConsole: import("..").LogCalcomServerErrorF
|
|
|
5
5
|
* Parses a FetchResponseError from a Cal.com API call into a typed CalcomServerError.
|
|
6
6
|
* Attempts to extract JSON error data from the response body.
|
|
7
7
|
*
|
|
8
|
-
* @param responseError -
|
|
9
|
-
* @returns
|
|
8
|
+
* @param responseError - The fetch response error to parse.
|
|
9
|
+
* @returns A parsed CalcomServerError, or undefined if the response body cannot be parsed.
|
|
10
10
|
*/
|
|
11
11
|
export declare function parseCalcomApiError(responseError: FetchResponseError): Promise<ParsedCalcomServerError>;
|
|
12
12
|
/**
|
|
13
13
|
* Parses Cal.com API server error response data into a specific error type.
|
|
14
14
|
* Delegates to {@link parseCalcomServerErrorData} for general error classification.
|
|
15
15
|
*
|
|
16
|
-
* @param calcomServerError -
|
|
17
|
-
* @param responseError -
|
|
18
|
-
* @returns
|
|
16
|
+
* @param calcomServerError - The parsed error data from the Cal.com response body.
|
|
17
|
+
* @param responseError - The original FetchResponseError containing the HTTP response.
|
|
18
|
+
* @returns A parsed CalcomServerError, or undefined if the error data is falsy.
|
|
19
19
|
*/
|
|
20
20
|
export declare function parseCalcomApiServerErrorResponseData(calcomServerError: CalcomServerErrorData, responseError: FetchResponseError): ParsedCalcomServerError;
|
|
21
21
|
export declare const handleCalcomErrorFetch: import("..").HandleCalcomErrorFetchFactory;
|
|
@@ -25,8 +25,9 @@ export type CalcomFactory = (config: CalcomConfig) => Calcom;
|
|
|
25
25
|
* Sets up rate limiting, error handling, OAuth token management, and both server
|
|
26
26
|
* and per-user fetch contexts.
|
|
27
27
|
*
|
|
28
|
-
* @param factoryConfig -
|
|
29
|
-
* @returns
|
|
28
|
+
* @param factoryConfig - Configuration including OAuth context, rate limiter, and optional fetch/logging overrides.
|
|
29
|
+
* @returns A factory function that accepts a CalcomConfig and produces a Calcom instance.
|
|
30
|
+
*
|
|
30
31
|
* @__NO_SIDE_EFFECTS__
|
|
31
32
|
*/
|
|
32
33
|
export declare function calcomFactory(factoryConfig: CalcomFactoryConfig): CalcomFactory;
|
|
@@ -39,8 +39,9 @@ export type LogCalcomServerErrorFunction = (error: FetchRequestFactoryError | Ca
|
|
|
39
39
|
/**
|
|
40
40
|
* Creates a logCalcomServerErrorFunction that logs the error to console.
|
|
41
41
|
*
|
|
42
|
-
* @param calcomApiNamePrefix Prefix to use when logging. I.E. CalcomError, etc.
|
|
43
|
-
* @returns
|
|
42
|
+
* @param calcomApiNamePrefix - Prefix to use when logging. I.E. CalcomError, etc.
|
|
43
|
+
* @returns A LogCalcomServerErrorFunction that logs errors with the given prefix.
|
|
44
|
+
*
|
|
44
45
|
* @__NO_SIDE_EFFECTS__
|
|
45
46
|
*/
|
|
46
47
|
export declare function logCalcomServerErrorFunction(calcomApiNamePrefix: string): LogCalcomServerErrorFunction;
|
|
@@ -53,9 +54,10 @@ export type ParseCalcomFetchResponseErrorFunction = (responseError: FetchRespons
|
|
|
53
54
|
/**
|
|
54
55
|
* Wraps a ConfiguredFetch to support handling errors returned by fetch.
|
|
55
56
|
*
|
|
56
|
-
* @param parseCalcomError -
|
|
57
|
-
* @param defaultLogError -
|
|
58
|
-
* @returns
|
|
57
|
+
* @param parseCalcomError - Function to parse a FetchResponseError into a CalcomServerError.
|
|
58
|
+
* @param defaultLogError - Default error logging function used when no override is provided.
|
|
59
|
+
* @returns A factory that wraps any ConfiguredFetch with Cal.com error handling.
|
|
60
|
+
*
|
|
59
61
|
* @__NO_SIDE_EFFECTS__
|
|
60
62
|
*/
|
|
61
63
|
export declare function handleCalcomErrorFetchFactory(parseCalcomError: ParseCalcomFetchResponseErrorFunction, defaultLogError: LogCalcomServerErrorFunction): HandleCalcomErrorFetchFactory;
|
|
@@ -85,8 +87,8 @@ export interface CalcomRateLimitHeaderDetails {
|
|
|
85
87
|
/**
|
|
86
88
|
* Extracts Cal.com rate limit information from HTTP response headers.
|
|
87
89
|
*
|
|
88
|
-
* @param headers -
|
|
89
|
-
* @returns
|
|
90
|
+
* @param headers - The HTTP response headers to parse.
|
|
91
|
+
* @returns Parsed rate limit details, or null if no rate limit headers are present.
|
|
90
92
|
*/
|
|
91
93
|
export declare function calcomRateLimitHeaderDetails(headers: Headers): Maybe<CalcomRateLimitHeaderDetails>;
|
|
92
94
|
export declare class CalcomTooManyRequestsError extends CalcomServerFetchResponseError {
|
|
@@ -95,8 +97,8 @@ export declare class CalcomTooManyRequestsError extends CalcomServerFetchRespons
|
|
|
95
97
|
/**
|
|
96
98
|
* Function that parses/transforms a CalcomServerErrorData into a general CalcomServerError or other known error type.
|
|
97
99
|
*
|
|
98
|
-
* @param calcomServerError -
|
|
99
|
-
* @param responseError -
|
|
100
|
-
* @returns
|
|
100
|
+
* @param calcomServerError - The parsed error data from the Cal.com response body.
|
|
101
|
+
* @param responseError - The original FetchResponseError containing the HTTP response.
|
|
102
|
+
* @returns A CalcomServerFetchResponseError (or subclass like CalcomTooManyRequestsError), or undefined if unrecognized.
|
|
101
103
|
*/
|
|
102
104
|
export declare function parseCalcomServerErrorData(calcomServerError: CalcomServerErrorData, responseError: FetchResponseError): CalcomServerFetchResponseError | undefined;
|
|
@@ -36,7 +36,7 @@ export type CalcomRateLimitedFetchHandler = RateLimitedFetchHandler<ResetPeriodP
|
|
|
36
36
|
* Creates a rate-limited fetch handler configured for Cal.com API rate limits.
|
|
37
37
|
* Automatically adjusts based on rate limit response headers and retries on 429 responses.
|
|
38
38
|
*
|
|
39
|
-
* @param config -
|
|
40
|
-
* @returns
|
|
39
|
+
* @param config - Optional rate limiter configuration overrides.
|
|
40
|
+
* @returns A CalcomRateLimitedFetchHandler that enforces rate limiting.
|
|
41
41
|
*/
|
|
42
42
|
export declare function calcomRateLimitedFetchHandler(config?: Maybe<CalcomRateLimitedFetchHandlerConfig>): CalcomRateLimitedFetchHandler;
|
|
@@ -25,10 +25,10 @@ export interface CalcomOAuthAccessTokenErrorResponse {
|
|
|
25
25
|
*
|
|
26
26
|
* Cal.com uses JSON body (not Basic Auth) for token requests.
|
|
27
27
|
*
|
|
28
|
-
* @
|
|
28
|
+
* @param context - The Cal.com OAuth context providing client credentials and fetch capabilities.
|
|
29
|
+
* @returns Refreshes an access token using an optional refresh token override.
|
|
29
30
|
*
|
|
30
|
-
* @
|
|
31
|
-
* @returns a function that refreshes an access token using an optional refresh token override
|
|
31
|
+
* @see https://cal.com/docs/api-reference/v2/oauth/refresh-an-existing-access-token
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
34
|
* ```ts
|
|
@@ -43,10 +43,10 @@ export declare function refreshAccessToken(context: CalcomOAuthContext): (input?
|
|
|
43
43
|
*
|
|
44
44
|
* Cal.com uses JSON body (not Basic Auth) for token requests.
|
|
45
45
|
*
|
|
46
|
-
* @
|
|
46
|
+
* @param context - The Cal.com OAuth context providing client credentials and fetch capabilities.
|
|
47
|
+
* @returns Exchanges an authorization code for access and refresh tokens.
|
|
47
48
|
*
|
|
48
|
-
* @
|
|
49
|
-
* @returns a function that exchanges an authorization code for access and refresh tokens
|
|
49
|
+
* @see https://cal.com/docs/api-reference/v2/oauth/exchange-an-authorization-code-for-access-tokens
|
|
50
50
|
*
|
|
51
51
|
* @example
|
|
52
52
|
* ```ts
|
package/src/lib/oauth/oauth.d.ts
CHANGED
|
@@ -63,8 +63,9 @@ export type CalcomAccessTokenStringFactory = () => Promise<CalcomAccessTokenStri
|
|
|
63
63
|
* Wraps a CalcomAccessTokenFactory to extract just the access token string,
|
|
64
64
|
* throwing a CalcomOAuthAuthFailureError if the token is missing.
|
|
65
65
|
*
|
|
66
|
-
* @param calcomAccessTokenFactory -
|
|
67
|
-
* @returns
|
|
66
|
+
* @param calcomAccessTokenFactory - The factory that produces CalcomAccessToken objects.
|
|
67
|
+
* @returns A factory function that returns the access token string.
|
|
68
|
+
*
|
|
68
69
|
* @__NO_SIDE_EFFECTS__
|
|
69
70
|
*/
|
|
70
71
|
export declare function calcomAccessTokenStringFactory(calcomAccessTokenFactory: CalcomAccessTokenFactory): CalcomAccessTokenStringFactory;
|
|
@@ -25,8 +25,8 @@ export declare const logCalcomOAuthErrorToConsole: import("..").LogCalcomServerE
|
|
|
25
25
|
* Parses a FetchResponseError from a Cal.com OAuth call into a typed error.
|
|
26
26
|
* Attempts to extract JSON error data from the response body.
|
|
27
27
|
*
|
|
28
|
-
* @param responseError -
|
|
29
|
-
* @returns
|
|
28
|
+
* @param responseError - The fetch response error to parse.
|
|
29
|
+
* @returns A parsed CalcomServerError or CalcomOAuthAccessTokenError, or undefined if unparseable.
|
|
30
30
|
*/
|
|
31
31
|
export declare function parseCalcomOAuthError(responseError: FetchResponseError): Promise<ParsedCalcomServerError>;
|
|
32
32
|
/**
|
|
@@ -34,9 +34,9 @@ export declare function parseCalcomOAuthError(responseError: FetchResponseError)
|
|
|
34
34
|
* Handles known error codes like `invalid_grant` and delegates unknown errors
|
|
35
35
|
* to {@link parseCalcomServerErrorData}.
|
|
36
36
|
*
|
|
37
|
-
* @param calcomServerError -
|
|
38
|
-
* @param responseError -
|
|
39
|
-
* @returns
|
|
37
|
+
* @param calcomServerError - The parsed error data from the Cal.com OAuth response body.
|
|
38
|
+
* @param responseError - The original FetchResponseError containing the HTTP response.
|
|
39
|
+
* @returns A parsed error instance, or undefined if the error data is falsy.
|
|
40
40
|
*/
|
|
41
41
|
export declare function parseCalcomOAuthServerErrorResponseData(calcomServerError: CalcomServerErrorData, responseError: FetchResponseError): ParsedCalcomServerError;
|
|
42
42
|
export declare const handleCalcomOAuthErrorFetch: import("..").HandleCalcomErrorFetchFactory;
|