@dereekb/calcom 13.4.0 → 13.4.2
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 +143 -13
- package/index.esm.js +143 -13
- package/nestjs/index.cjs.js +108 -8
- package/nestjs/index.esm.js +108 -8
- package/nestjs/package.json +4 -4
- package/nestjs/src/lib/calcom/calcom.api.d.ts +48 -1
- package/nestjs/src/lib/calcom/calcom.module.d.ts +9 -0
- package/nestjs/src/lib/oauth/oauth.api.d.ts +13 -1
- package/nestjs/src/lib/oauth/oauth.config.d.ts +6 -0
- package/nestjs/src/lib/oauth/oauth.module.d.ts +3 -0
- package/nestjs/src/lib/oauth/oauth.service.d.ts +16 -0
- package/nestjs/src/lib/webhook/webhook.calcom.d.ts +3 -0
- package/nestjs/src/lib/webhook/webhook.calcom.module.d.ts +9 -0
- package/package.json +3 -3
- package/src/lib/calcom/calcom.api.booking.d.ts +9 -0
- package/src/lib/calcom/calcom.api.calendar.d.ts +6 -0
- package/src/lib/calcom/calcom.api.eventtype.d.ts +12 -0
- package/src/lib/calcom/calcom.api.schedule.d.ts +3 -0
- package/src/lib/calcom/calcom.api.slot.d.ts +3 -0
- package/src/lib/calcom/calcom.api.user.d.ts +3 -0
- package/src/lib/calcom/calcom.api.webhook.d.ts +15 -0
- package/src/lib/calcom/calcom.error.api.d.ts +15 -0
- package/src/lib/calcom/calcom.factory.d.ts +8 -0
- package/src/lib/calcom.error.api.d.ts +15 -1
- package/src/lib/calcom.limit.d.ts +7 -0
- package/src/lib/oauth/oauth.api.d.ts +6 -0
- package/src/lib/oauth/oauth.d.ts +5 -0
- package/src/lib/oauth/oauth.error.api.d.ts +16 -0
- package/src/lib/oauth/oauth.factory.d.ts +13 -0
- package/src/lib/shared/calcom.api-version.d.ts +3 -0
package/nestjs/index.esm.js
CHANGED
|
@@ -89,7 +89,12 @@ var CALCOM_API_KEY_CONFIG_KEY = 'CALCOM_API_KEY';
|
|
|
89
89
|
]);
|
|
90
90
|
return CalcomOAuthServiceConfig;
|
|
91
91
|
}();
|
|
92
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Factory function that creates a {@link CalcomOAuthServiceConfig} from NestJS ConfigService environment variables.
|
|
94
|
+
*
|
|
95
|
+
* @param configService - the NestJS ConfigService instance
|
|
96
|
+
* @returns a validated CalcomOAuthServiceConfig
|
|
97
|
+
*/ function calcomOAuthServiceConfigFactory(configService) {
|
|
93
98
|
var clientId = configService.get(CALCOM_CLIENT_ID_CONFIG_KEY);
|
|
94
99
|
var clientSecret = configService.get(CALCOM_CLIENT_SECRET_CONFIG_KEY);
|
|
95
100
|
var refreshToken = configService.get(CALCOM_REFRESH_TOKEN_CONFIG_KEY);
|
|
@@ -311,10 +316,18 @@ CalcomOAuthAccessTokenCacheService = __decorate([
|
|
|
311
316
|
], CalcomOAuthAccessTokenCacheService);
|
|
312
317
|
/**
|
|
313
318
|
* Derives a short, filesystem-safe cache key from a refresh token using md5.
|
|
319
|
+
*
|
|
320
|
+
* @param refreshToken - the OAuth refresh token to hash
|
|
321
|
+
* @returns a 16-character hex string suitable for use as a cache key
|
|
314
322
|
*/ function calcomRefreshTokenCacheKey(refreshToken) {
|
|
315
323
|
return createHash('md5').update(refreshToken).digest('hex').substring(0, 16);
|
|
316
324
|
}
|
|
317
|
-
|
|
325
|
+
/**
|
|
326
|
+
* Default error logging function for {@link mergeCalcomOAuthAccessTokenCacheServices}.
|
|
327
|
+
* Logs a warning for each cache that failed to update.
|
|
328
|
+
*
|
|
329
|
+
* @param failedUpdates - array of tuples containing the failed cache and its error
|
|
330
|
+
*/ function logMergeCalcomOAuthAccessTokenCacheServiceErrorFunction(failedUpdates) {
|
|
318
331
|
console.warn("mergeCalcomOAuthAccessTokenCacheServices(): failed updating ".concat(failedUpdates.length, " caches."));
|
|
319
332
|
failedUpdates.forEach(function(param, i) {
|
|
320
333
|
var _param = _sliced_to_array(param, 2); _param[0]; var e = _param[1];
|
|
@@ -328,6 +341,8 @@ function logMergeCalcomOAuthAccessTokenCacheServiceErrorFunction(failedUpdates)
|
|
|
328
341
|
* When updating a cached token, it will update the token across all services.
|
|
329
342
|
*
|
|
330
343
|
* @param inputServicesToMerge Must include at least one service. Empty arrays will throw an error.
|
|
344
|
+
* @param logError - optional error logging configuration; pass a function, true for default logging, or false to disable
|
|
345
|
+
* @returns a merged CalcomOAuthAccessTokenCacheService that delegates across all input services
|
|
331
346
|
*/ function mergeCalcomOAuthAccessTokenCacheServices(inputServicesToMerge, logError) {
|
|
332
347
|
var allServices = _to_consumable_array$3(inputServicesToMerge);
|
|
333
348
|
var logErrorFunction = typeof logError === 'function' ? logError : logError !== false ? logMergeCalcomOAuthAccessTokenCacheServiceErrorFunction : undefined;
|
|
@@ -412,6 +427,10 @@ function logMergeCalcomOAuthAccessTokenCacheServiceErrorFunction(failedUpdates)
|
|
|
412
427
|
/**
|
|
413
428
|
* Creates a CalcomOAuthAccessTokenCacheService that uses in-memory storage.
|
|
414
429
|
* Per-user caches are stored in a Map keyed by the md5 hash of the refresh token.
|
|
430
|
+
*
|
|
431
|
+
* @param existingToken - optional pre-existing server-level access token to seed the cache
|
|
432
|
+
* @param logAccessToConsole - when true, logs all cache reads and writes to console
|
|
433
|
+
* @returns a CalcomOAuthAccessTokenCacheService backed by in-memory Maps
|
|
415
434
|
*/ function memoryCalcomOAuthAccessTokenCacheService(existingToken, logAccessToConsole) {
|
|
416
435
|
var serverToken = existingToken;
|
|
417
436
|
var userTokens = new Map();
|
|
@@ -484,6 +503,7 @@ var CALCOM_SERVER_TOKEN_FILE_KEY = 'server';
|
|
|
484
503
|
* ```
|
|
485
504
|
*
|
|
486
505
|
* @param cacheDir Directory to store token files. Defaults to `.tmp/calcom-tokens`.
|
|
506
|
+
* @returns a CalcomOAuthAccessTokenCacheService backed by the file system
|
|
487
507
|
*/ function fileCalcomOAuthAccessTokenCacheService() {
|
|
488
508
|
var cacheDir = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_FILE_CALCOM_ACCESS_TOKEN_CACHE_DIR;
|
|
489
509
|
var memoryTokens = new Map();
|
|
@@ -673,13 +693,22 @@ var CalcomOAuthApi = /*#__PURE__*/ function() {
|
|
|
673
693
|
{
|
|
674
694
|
key: "exchangeAuthorizationCode",
|
|
675
695
|
get: // MARK: Accessors
|
|
676
|
-
/**
|
|
696
|
+
/**
|
|
697
|
+
* Configured pass-through for {@link exchangeAuthorizationCode}.
|
|
698
|
+
*
|
|
699
|
+
* @returns function to exchange an OAuth authorization code for tokens
|
|
700
|
+
*/ function get() {
|
|
677
701
|
return exchangeAuthorizationCode(this.oauthContext);
|
|
678
702
|
}
|
|
679
703
|
},
|
|
680
704
|
{
|
|
681
705
|
/**
|
|
682
706
|
* Retrieves an access token for a specific user using their refresh token.
|
|
707
|
+
*
|
|
708
|
+
* @param input - contains the user's refresh token and optional access token cache
|
|
709
|
+
* @param input.refreshToken - the user's OAuth refresh token
|
|
710
|
+
* @param input.userAccessTokenCache - optional cache to store/retrieve the user's access token
|
|
711
|
+
* @returns a promise resolving to the user's CalcomAccessToken
|
|
683
712
|
*/ key: "userAccessToken",
|
|
684
713
|
value: function userAccessToken(input) {
|
|
685
714
|
var factory = this.oauthContext.makeUserAccessTokenFactory(input);
|
|
@@ -690,6 +719,9 @@ var CalcomOAuthApi = /*#__PURE__*/ function() {
|
|
|
690
719
|
/**
|
|
691
720
|
* Returns a per-user CalcomAccessTokenCache derived from the refresh token (md5 hashed as the file key).
|
|
692
721
|
* Returns undefined if the cache service does not support per-user caching.
|
|
722
|
+
*
|
|
723
|
+
* @param refreshToken - the user's OAuth refresh token used to derive the cache key
|
|
724
|
+
* @returns a per-user access token cache, or undefined if not supported
|
|
693
725
|
*/ key: "cacheForRefreshToken",
|
|
694
726
|
value: function cacheForRefreshToken(refreshToken) {
|
|
695
727
|
var _this_cacheService_cacheForRefreshToken, _this_cacheService;
|
|
@@ -732,6 +764,9 @@ function _unsupported_iterable_to_array$2(o, minLen) {
|
|
|
732
764
|
}
|
|
733
765
|
/**
|
|
734
766
|
* Convenience function used to generate ModuleMetadata for an app's CalcomOAuthModule.
|
|
767
|
+
*
|
|
768
|
+
* @param config - the module metadata configuration including optional dependency module and config factory
|
|
769
|
+
* @returns NestJS ModuleMetadata for registering the CalcomOAuthModule
|
|
735
770
|
*/ function appCalcomOAuthModuleMetadata(config) {
|
|
736
771
|
var _config_calcomOAuthServiceConfigFactory;
|
|
737
772
|
var dependencyModule = config.dependencyModule, imports = config.imports, exports$1 = config.exports, providers = config.providers;
|
|
@@ -924,6 +959,8 @@ function _object_spread_props$1(target, source) {
|
|
|
924
959
|
get: /**
|
|
925
960
|
* Returns the cached {@link CalcomApiContextInstance} for the server context.
|
|
926
961
|
* All API functions are available through this instance.
|
|
962
|
+
*
|
|
963
|
+
* @returns the server context instance
|
|
927
964
|
*/ function get() {
|
|
928
965
|
return this._serverInstance();
|
|
929
966
|
}
|
|
@@ -931,7 +968,11 @@ function _object_spread_props$1(target, source) {
|
|
|
931
968
|
{
|
|
932
969
|
key: "getAvailableSlots",
|
|
933
970
|
get: // MARK: Public Context
|
|
934
|
-
/**
|
|
971
|
+
/**
|
|
972
|
+
* Configured pass-through for {@link getAvailableSlots} using the public (unauthenticated) context.
|
|
973
|
+
*
|
|
974
|
+
* @returns function to query available slots without authentication
|
|
975
|
+
*/ function get() {
|
|
935
976
|
return getAvailableSlots(this._publicContext());
|
|
936
977
|
}
|
|
937
978
|
},
|
|
@@ -945,6 +986,9 @@ function _object_spread_props$1(target, source) {
|
|
|
945
986
|
* resolved from the cache service using an md5 hash of the refresh token as the key.
|
|
946
987
|
* This ensures tokens persist across requests and server restarts without collisions.
|
|
947
988
|
*
|
|
989
|
+
* @param input - the user context factory input containing the refresh token and optional cache
|
|
990
|
+
* @returns a new CalcomApiContextInstance scoped to the user
|
|
991
|
+
*
|
|
948
992
|
* @example
|
|
949
993
|
* ```ts
|
|
950
994
|
* // Automatic per-user caching (recommended):
|
|
@@ -975,6 +1019,9 @@ function _object_spread_props$1(target, source) {
|
|
|
975
1019
|
{
|
|
976
1020
|
/**
|
|
977
1021
|
* Creates a {@link CalcomApiContextInstance} from any {@link CalcomContext}.
|
|
1022
|
+
*
|
|
1023
|
+
* @param context - the CalcomContext (server or user) to wrap
|
|
1024
|
+
* @returns a new CalcomApiContextInstance bound to the given context
|
|
978
1025
|
*/ key: "makeContextInstance",
|
|
979
1026
|
value: function makeContextInstance(context) {
|
|
980
1027
|
return new CalcomApiContextInstance(this, context);
|
|
@@ -984,6 +1031,9 @@ function _object_spread_props$1(target, source) {
|
|
|
984
1031
|
/**
|
|
985
1032
|
* Creates a raw {@link CalcomUserContext} from a refresh token, without wrapping in a {@link CalcomApiContextInstance}.
|
|
986
1033
|
* Prefer {@link makeUserContextInstance} unless you need direct context access.
|
|
1034
|
+
*
|
|
1035
|
+
* @param input - the user context factory input containing the refresh token and optional cache
|
|
1036
|
+
* @returns a CalcomUserContext for the given user
|
|
987
1037
|
*/ key: "makeUserContext",
|
|
988
1038
|
value: function makeUserContext(input) {
|
|
989
1039
|
return this.calcom.calcomServerContext.makeUserContext(input);
|
|
@@ -1030,6 +1080,8 @@ CalcomApi = __decorate([
|
|
|
1030
1080
|
get: // MARK: User
|
|
1031
1081
|
/**
|
|
1032
1082
|
* Configured pass-through for {@link getMe}.
|
|
1083
|
+
*
|
|
1084
|
+
* @returns function to retrieve the authenticated user's profile
|
|
1033
1085
|
*/ function get() {
|
|
1034
1086
|
return getMe(this.context);
|
|
1035
1087
|
}
|
|
@@ -1039,6 +1091,8 @@ CalcomApi = __decorate([
|
|
|
1039
1091
|
get: // MARK: Schedules
|
|
1040
1092
|
/**
|
|
1041
1093
|
* Configured pass-through for {@link getSchedules}.
|
|
1094
|
+
*
|
|
1095
|
+
* @returns function to retrieve all schedules for the authenticated user
|
|
1042
1096
|
*/ function get() {
|
|
1043
1097
|
return getSchedules(this.context);
|
|
1044
1098
|
}
|
|
@@ -1048,6 +1102,8 @@ CalcomApi = __decorate([
|
|
|
1048
1102
|
get: // MARK: Bookings
|
|
1049
1103
|
/**
|
|
1050
1104
|
* Configured pass-through for {@link createBooking}.
|
|
1105
|
+
*
|
|
1106
|
+
* @returns function to create a new booking
|
|
1051
1107
|
*/ function get() {
|
|
1052
1108
|
return createBooking(this.context);
|
|
1053
1109
|
}
|
|
@@ -1056,6 +1112,8 @@ CalcomApi = __decorate([
|
|
|
1056
1112
|
key: "getBooking",
|
|
1057
1113
|
get: /**
|
|
1058
1114
|
* Configured pass-through for {@link getBooking}.
|
|
1115
|
+
*
|
|
1116
|
+
* @returns function to retrieve a booking by UID
|
|
1059
1117
|
*/ function get() {
|
|
1060
1118
|
return getBooking(this.context);
|
|
1061
1119
|
}
|
|
@@ -1064,6 +1122,8 @@ CalcomApi = __decorate([
|
|
|
1064
1122
|
key: "cancelBooking",
|
|
1065
1123
|
get: /**
|
|
1066
1124
|
* Configured pass-through for {@link cancelBooking}.
|
|
1125
|
+
*
|
|
1126
|
+
* @returns function to cancel a booking by UID
|
|
1067
1127
|
*/ function get() {
|
|
1068
1128
|
return cancelBooking(this.context);
|
|
1069
1129
|
}
|
|
@@ -1073,6 +1133,8 @@ CalcomApi = __decorate([
|
|
|
1073
1133
|
get: // MARK: Event Types
|
|
1074
1134
|
/**
|
|
1075
1135
|
* Configured pass-through for {@link getEventTypes}.
|
|
1136
|
+
*
|
|
1137
|
+
* @returns function to retrieve all event types for the authenticated user
|
|
1076
1138
|
*/ function get() {
|
|
1077
1139
|
return getEventTypes(this.context);
|
|
1078
1140
|
}
|
|
@@ -1081,6 +1143,8 @@ CalcomApi = __decorate([
|
|
|
1081
1143
|
key: "createEventType",
|
|
1082
1144
|
get: /**
|
|
1083
1145
|
* Configured pass-through for {@link createEventType}.
|
|
1146
|
+
*
|
|
1147
|
+
* @returns function to create a new event type
|
|
1084
1148
|
*/ function get() {
|
|
1085
1149
|
return createEventType(this.context);
|
|
1086
1150
|
}
|
|
@@ -1089,6 +1153,8 @@ CalcomApi = __decorate([
|
|
|
1089
1153
|
key: "updateEventType",
|
|
1090
1154
|
get: /**
|
|
1091
1155
|
* Configured pass-through for {@link updateEventType}.
|
|
1156
|
+
*
|
|
1157
|
+
* @returns function to update an existing event type by ID
|
|
1092
1158
|
*/ function get() {
|
|
1093
1159
|
return updateEventType(this.context);
|
|
1094
1160
|
}
|
|
@@ -1097,6 +1163,8 @@ CalcomApi = __decorate([
|
|
|
1097
1163
|
key: "deleteEventType",
|
|
1098
1164
|
get: /**
|
|
1099
1165
|
* Configured pass-through for {@link deleteEventType}.
|
|
1166
|
+
*
|
|
1167
|
+
* @returns function to delete an event type by ID
|
|
1100
1168
|
*/ function get() {
|
|
1101
1169
|
return deleteEventType(this.context);
|
|
1102
1170
|
}
|
|
@@ -1106,6 +1174,8 @@ CalcomApi = __decorate([
|
|
|
1106
1174
|
get: // MARK: Calendars
|
|
1107
1175
|
/**
|
|
1108
1176
|
* Configured pass-through for {@link getCalendars}.
|
|
1177
|
+
*
|
|
1178
|
+
* @returns function to retrieve all connected calendars
|
|
1109
1179
|
*/ function get() {
|
|
1110
1180
|
return getCalendars(this.context);
|
|
1111
1181
|
}
|
|
@@ -1114,6 +1184,8 @@ CalcomApi = __decorate([
|
|
|
1114
1184
|
key: "getBusyTimes",
|
|
1115
1185
|
get: /**
|
|
1116
1186
|
* Configured pass-through for {@link getBusyTimes}.
|
|
1187
|
+
*
|
|
1188
|
+
* @returns function to retrieve busy time ranges across connected calendars
|
|
1117
1189
|
*/ function get() {
|
|
1118
1190
|
return getBusyTimes(this.context);
|
|
1119
1191
|
}
|
|
@@ -1123,6 +1195,8 @@ CalcomApi = __decorate([
|
|
|
1123
1195
|
get: // MARK: Webhooks
|
|
1124
1196
|
/**
|
|
1125
1197
|
* Configured pass-through for {@link createWebhook}.
|
|
1198
|
+
*
|
|
1199
|
+
* @returns function to create a webhook subscription
|
|
1126
1200
|
*/ function get() {
|
|
1127
1201
|
return createWebhook(this.context);
|
|
1128
1202
|
}
|
|
@@ -1131,6 +1205,8 @@ CalcomApi = __decorate([
|
|
|
1131
1205
|
key: "getWebhooks",
|
|
1132
1206
|
get: /**
|
|
1133
1207
|
* Configured pass-through for {@link getWebhooks}.
|
|
1208
|
+
*
|
|
1209
|
+
* @returns function to retrieve all webhooks
|
|
1134
1210
|
*/ function get() {
|
|
1135
1211
|
return getWebhooks(this.context);
|
|
1136
1212
|
}
|
|
@@ -1139,6 +1215,8 @@ CalcomApi = __decorate([
|
|
|
1139
1215
|
key: "getWebhook",
|
|
1140
1216
|
get: /**
|
|
1141
1217
|
* Configured pass-through for {@link getWebhook}.
|
|
1218
|
+
*
|
|
1219
|
+
* @returns function to retrieve a specific webhook by ID
|
|
1142
1220
|
*/ function get() {
|
|
1143
1221
|
return getWebhook(this.context);
|
|
1144
1222
|
}
|
|
@@ -1147,6 +1225,8 @@ CalcomApi = __decorate([
|
|
|
1147
1225
|
key: "updateWebhook",
|
|
1148
1226
|
get: /**
|
|
1149
1227
|
* Configured pass-through for {@link updateWebhook}.
|
|
1228
|
+
*
|
|
1229
|
+
* @returns function to update an existing webhook by ID
|
|
1150
1230
|
*/ function get() {
|
|
1151
1231
|
return updateWebhook(this.context);
|
|
1152
1232
|
}
|
|
@@ -1155,6 +1235,8 @@ CalcomApi = __decorate([
|
|
|
1155
1235
|
key: "deleteWebhook",
|
|
1156
1236
|
get: /**
|
|
1157
1237
|
* Configured pass-through for {@link deleteWebhook}.
|
|
1238
|
+
*
|
|
1239
|
+
* @returns function to delete a webhook by ID
|
|
1158
1240
|
*/ function get() {
|
|
1159
1241
|
return deleteWebhook(this.context);
|
|
1160
1242
|
}
|
|
@@ -1190,7 +1272,12 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
1190
1272
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
1191
1273
|
}
|
|
1192
1274
|
// MARK: Provider Factories
|
|
1193
|
-
|
|
1275
|
+
/**
|
|
1276
|
+
* Factory function that creates a {@link CalcomServiceConfig} from NestJS ConfigService values.
|
|
1277
|
+
*
|
|
1278
|
+
* @param _configService - the NestJS ConfigService instance
|
|
1279
|
+
* @returns a validated CalcomServiceConfig
|
|
1280
|
+
*/ function calcomServiceConfigFactory(_configService) {
|
|
1194
1281
|
var config = {
|
|
1195
1282
|
calcom: {}
|
|
1196
1283
|
};
|
|
@@ -1199,6 +1286,9 @@ function calcomServiceConfigFactory(_configService) {
|
|
|
1199
1286
|
}
|
|
1200
1287
|
/**
|
|
1201
1288
|
* Convenience function used to generate ModuleMetadata for an app's CalcomModule.
|
|
1289
|
+
*
|
|
1290
|
+
* @param config - the module metadata configuration including optional dependency module
|
|
1291
|
+
* @returns NestJS ModuleMetadata for registering the CalcomModule
|
|
1202
1292
|
*/ function appCalcomModuleMetadata(config) {
|
|
1203
1293
|
var dependencyModule = config.dependencyModule, imports = config.imports, exports$1 = config.exports, providers = config.providers;
|
|
1204
1294
|
var dependencyModuleImport = dependencyModule ? [
|
|
@@ -1279,6 +1369,9 @@ function _object_spread_props(target, source) {
|
|
|
1279
1369
|
}
|
|
1280
1370
|
/**
|
|
1281
1371
|
* Creates a CalcomWebhookEvent and treats the data as the input type.
|
|
1372
|
+
*
|
|
1373
|
+
* @param event - the untyped webhook event to convert
|
|
1374
|
+
* @returns a typed CalcomWebhookEvent with the payload cast to type T
|
|
1282
1375
|
*/ function calcomWebhookEvent(event) {
|
|
1283
1376
|
return {
|
|
1284
1377
|
triggerEvent: event.triggerEvent,
|
|
@@ -1291,7 +1384,6 @@ var calcomEventHandlerFactory = handlerFactory(function(x) {
|
|
|
1291
1384
|
});
|
|
1292
1385
|
var calcomEventHandlerConfigurerFactory = handlerConfigurerFactory({
|
|
1293
1386
|
configurerForAccessor: function configurerForAccessor(accessor) {
|
|
1294
|
-
// eslint-disable-next-line
|
|
1295
1387
|
var fnWithKey = handlerMappedSetFunctionFactory(accessor, calcomWebhookEvent);
|
|
1296
1388
|
var configurer = _object_spread_props(_object_spread({}, accessor), {
|
|
1297
1389
|
handleBookingCreated: fnWithKey(CALCOM_WEBHOOK_BOOKING_CREATED),
|
|
@@ -1371,7 +1463,7 @@ var CALCOM_WEBHOOK_SECRET_CONFIG_KEY = 'CALCOM_WEBHOOK_SECRET';
|
|
|
1371
1463
|
var event;
|
|
1372
1464
|
try {
|
|
1373
1465
|
event = JSON.parse(rawBodyString);
|
|
1374
|
-
} catch (
|
|
1466
|
+
} catch (unused) {
|
|
1375
1467
|
event = {
|
|
1376
1468
|
triggerEvent: '',
|
|
1377
1469
|
createdAt: '',
|
|
@@ -1868,7 +1960,12 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
1868
1960
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1869
1961
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1870
1962
|
}
|
|
1871
|
-
|
|
1963
|
+
/**
|
|
1964
|
+
* Factory function that creates a {@link CalcomWebhookServiceConfig} from NestJS ConfigService environment variables.
|
|
1965
|
+
*
|
|
1966
|
+
* @param configService - the NestJS ConfigService instance
|
|
1967
|
+
* @returns a validated CalcomWebhookServiceConfig
|
|
1968
|
+
*/ function calcomWebhookServiceConfigFactory(configService) {
|
|
1872
1969
|
var config = {
|
|
1873
1970
|
webhookConfig: {
|
|
1874
1971
|
webhookSecret: configService.get(CALCOM_WEBHOOK_SECRET_CONFIG_KEY)
|
|
@@ -1907,6 +2004,9 @@ CalcomWebhookModule = __decorate([
|
|
|
1907
2004
|
], CalcomWebhookModule);
|
|
1908
2005
|
/**
|
|
1909
2006
|
* Convenience function used to generate ModuleMetadata for an app's CalcomWebhookModule.
|
|
2007
|
+
*
|
|
2008
|
+
* @param config - the module metadata configuration including optional dependency module
|
|
2009
|
+
* @returns NestJS ModuleMetadata for registering the CalcomWebhookModule
|
|
1910
2010
|
*/ function appCalcomWebhookModuleMetadata(config) {
|
|
1911
2011
|
var dependencyModule = config.dependencyModule, imports = config.imports, exports$1 = config.exports, providers = config.providers;
|
|
1912
2012
|
var dependencyModuleImport = dependencyModule ? [
|
package/nestjs/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/calcom/nestjs",
|
|
3
|
-
"version": "13.4.
|
|
3
|
+
"version": "13.4.2",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/nestjs": "13.4.
|
|
6
|
-
"@dereekb/util": "13.4.
|
|
7
|
-
"@dereekb/calcom": "13.4.
|
|
5
|
+
"@dereekb/nestjs": "13.4.2",
|
|
6
|
+
"@dereekb/util": "13.4.2",
|
|
7
|
+
"@dereekb/calcom": "13.4.2",
|
|
8
8
|
"@nestjs/common": "^11.1.16",
|
|
9
9
|
"@nestjs/config": "^4.0.3",
|
|
10
10
|
"express": "^5.0.0"
|
|
@@ -32,9 +32,15 @@ export declare class CalcomApi {
|
|
|
32
32
|
/**
|
|
33
33
|
* Returns the cached {@link CalcomApiContextInstance} for the server context.
|
|
34
34
|
* All API functions are available through this instance.
|
|
35
|
+
*
|
|
36
|
+
* @returns the server context instance
|
|
35
37
|
*/
|
|
36
38
|
get serverContextInstance(): CalcomApiContextInstance;
|
|
37
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Configured pass-through for {@link getAvailableSlots} using the public (unauthenticated) context.
|
|
41
|
+
*
|
|
42
|
+
* @returns function to query available slots without authentication
|
|
43
|
+
*/
|
|
38
44
|
get getAvailableSlots(): (input: import("@dereekb/calcom").CalcomGetAvailableSlotsInput) => Promise<import("@dereekb/calcom").CalcomGetAvailableSlotsResponse>;
|
|
39
45
|
/**
|
|
40
46
|
* Creates a {@link CalcomApiContextInstance} for a specific user using their OAuth refresh token.
|
|
@@ -44,6 +50,9 @@ export declare class CalcomApi {
|
|
|
44
50
|
* resolved from the cache service using an md5 hash of the refresh token as the key.
|
|
45
51
|
* This ensures tokens persist across requests and server restarts without collisions.
|
|
46
52
|
*
|
|
53
|
+
* @param input - the user context factory input containing the refresh token and optional cache
|
|
54
|
+
* @returns a new CalcomApiContextInstance scoped to the user
|
|
55
|
+
*
|
|
47
56
|
* @example
|
|
48
57
|
* ```ts
|
|
49
58
|
* // Automatic per-user caching (recommended):
|
|
@@ -61,11 +70,17 @@ export declare class CalcomApi {
|
|
|
61
70
|
makeUserContextInstance(input: CalcomUserContextFactoryInput): CalcomApiContextInstance;
|
|
62
71
|
/**
|
|
63
72
|
* Creates a {@link CalcomApiContextInstance} from any {@link CalcomContext}.
|
|
73
|
+
*
|
|
74
|
+
* @param context - the CalcomContext (server or user) to wrap
|
|
75
|
+
* @returns a new CalcomApiContextInstance bound to the given context
|
|
64
76
|
*/
|
|
65
77
|
makeContextInstance(context: CalcomContext): CalcomApiContextInstance;
|
|
66
78
|
/**
|
|
67
79
|
* Creates a raw {@link CalcomUserContext} from a refresh token, without wrapping in a {@link CalcomApiContextInstance}.
|
|
68
80
|
* Prefer {@link makeUserContextInstance} unless you need direct context access.
|
|
81
|
+
*
|
|
82
|
+
* @param input - the user context factory input containing the refresh token and optional cache
|
|
83
|
+
* @returns a CalcomUserContext for the given user
|
|
69
84
|
*/
|
|
70
85
|
makeUserContext(input: CalcomUserContextFactoryInput): CalcomUserContext;
|
|
71
86
|
}
|
|
@@ -95,66 +110,98 @@ export declare class CalcomApiContextInstance {
|
|
|
95
110
|
constructor(calcomApi: CalcomApi, context: CalcomContext);
|
|
96
111
|
/**
|
|
97
112
|
* Configured pass-through for {@link getMe}.
|
|
113
|
+
*
|
|
114
|
+
* @returns function to retrieve the authenticated user's profile
|
|
98
115
|
*/
|
|
99
116
|
get getMe(): () => Promise<import("@dereekb/calcom").CalcomGetMeResponse>;
|
|
100
117
|
/**
|
|
101
118
|
* Configured pass-through for {@link getSchedules}.
|
|
119
|
+
*
|
|
120
|
+
* @returns function to retrieve all schedules for the authenticated user
|
|
102
121
|
*/
|
|
103
122
|
get getSchedules(): () => Promise<import("@dereekb/calcom").CalcomGetSchedulesResponse>;
|
|
104
123
|
/**
|
|
105
124
|
* Configured pass-through for {@link createBooking}.
|
|
125
|
+
*
|
|
126
|
+
* @returns function to create a new booking
|
|
106
127
|
*/
|
|
107
128
|
get createBooking(): (input: import("@dereekb/calcom").CalcomCreateBookingInput) => Promise<import("@dereekb/calcom").CalcomCreateBookingResponse>;
|
|
108
129
|
/**
|
|
109
130
|
* Configured pass-through for {@link getBooking}.
|
|
131
|
+
*
|
|
132
|
+
* @returns function to retrieve a booking by UID
|
|
110
133
|
*/
|
|
111
134
|
get getBooking(): (uid: import("@dereekb/calcom").CalcomBookingUid) => Promise<import("@dereekb/calcom").CalcomGetBookingResponse>;
|
|
112
135
|
/**
|
|
113
136
|
* Configured pass-through for {@link cancelBooking}.
|
|
137
|
+
*
|
|
138
|
+
* @returns function to cancel a booking by UID
|
|
114
139
|
*/
|
|
115
140
|
get cancelBooking(): (input: import("@dereekb/calcom").CalcomCancelBookingInput) => Promise<import("@dereekb/calcom").CalcomCancelBookingResponse>;
|
|
116
141
|
/**
|
|
117
142
|
* Configured pass-through for {@link getEventTypes}.
|
|
143
|
+
*
|
|
144
|
+
* @returns function to retrieve all event types for the authenticated user
|
|
118
145
|
*/
|
|
119
146
|
get getEventTypes(): () => Promise<import("@dereekb/calcom").CalcomGetEventTypesResponse>;
|
|
120
147
|
/**
|
|
121
148
|
* Configured pass-through for {@link createEventType}.
|
|
149
|
+
*
|
|
150
|
+
* @returns function to create a new event type
|
|
122
151
|
*/
|
|
123
152
|
get createEventType(): (input: import("@dereekb/calcom").CalcomCreateEventTypeInput) => Promise<import("@dereekb/calcom").CalcomEventTypeResponse>;
|
|
124
153
|
/**
|
|
125
154
|
* Configured pass-through for {@link updateEventType}.
|
|
155
|
+
*
|
|
156
|
+
* @returns function to update an existing event type by ID
|
|
126
157
|
*/
|
|
127
158
|
get updateEventType(): (eventTypeId: import("@dereekb/calcom").CalcomEventTypeId, input: import("@dereekb/calcom").CalcomUpdateEventTypeInput) => Promise<import("@dereekb/calcom").CalcomEventTypeResponse>;
|
|
128
159
|
/**
|
|
129
160
|
* Configured pass-through for {@link deleteEventType}.
|
|
161
|
+
*
|
|
162
|
+
* @returns function to delete an event type by ID
|
|
130
163
|
*/
|
|
131
164
|
get deleteEventType(): (eventTypeId: import("@dereekb/calcom").CalcomEventTypeId) => Promise<import("@dereekb/calcom").CalcomEventTypeResponse>;
|
|
132
165
|
/**
|
|
133
166
|
* Configured pass-through for {@link getCalendars}.
|
|
167
|
+
*
|
|
168
|
+
* @returns function to retrieve all connected calendars
|
|
134
169
|
*/
|
|
135
170
|
get getCalendars(): () => Promise<import("@dereekb/calcom").CalcomGetCalendarsResponse>;
|
|
136
171
|
/**
|
|
137
172
|
* Configured pass-through for {@link getBusyTimes}.
|
|
173
|
+
*
|
|
174
|
+
* @returns function to retrieve busy time ranges across connected calendars
|
|
138
175
|
*/
|
|
139
176
|
get getBusyTimes(): (input: import("@dereekb/calcom").CalcomGetBusyTimesInput) => Promise<import("@dereekb/calcom").CalcomGetBusyTimesResponse>;
|
|
140
177
|
/**
|
|
141
178
|
* Configured pass-through for {@link createWebhook}.
|
|
179
|
+
*
|
|
180
|
+
* @returns function to create a webhook subscription
|
|
142
181
|
*/
|
|
143
182
|
get createWebhook(): (input: import("@dereekb/calcom").CalcomCreateWebhookInput) => Promise<import("@dereekb/calcom").CalcomWebhookResponse>;
|
|
144
183
|
/**
|
|
145
184
|
* Configured pass-through for {@link getWebhooks}.
|
|
185
|
+
*
|
|
186
|
+
* @returns function to retrieve all webhooks
|
|
146
187
|
*/
|
|
147
188
|
get getWebhooks(): () => Promise<import("@dereekb/calcom").CalcomGetWebhooksResponse>;
|
|
148
189
|
/**
|
|
149
190
|
* Configured pass-through for {@link getWebhook}.
|
|
191
|
+
*
|
|
192
|
+
* @returns function to retrieve a specific webhook by ID
|
|
150
193
|
*/
|
|
151
194
|
get getWebhook(): (webhookId: import("@dereekb/calcom").CalcomWebhookId) => Promise<import("@dereekb/calcom").CalcomWebhookResponse>;
|
|
152
195
|
/**
|
|
153
196
|
* Configured pass-through for {@link updateWebhook}.
|
|
197
|
+
*
|
|
198
|
+
* @returns function to update an existing webhook by ID
|
|
154
199
|
*/
|
|
155
200
|
get updateWebhook(): (webhookId: import("@dereekb/calcom").CalcomWebhookId, input: import("@dereekb/calcom").CalcomUpdateWebhookInput) => Promise<import("@dereekb/calcom").CalcomWebhookResponse>;
|
|
156
201
|
/**
|
|
157
202
|
* Configured pass-through for {@link deleteWebhook}.
|
|
203
|
+
*
|
|
204
|
+
* @returns function to delete a webhook by ID
|
|
158
205
|
*/
|
|
159
206
|
get deleteWebhook(): (webhookId: import("@dereekb/calcom").CalcomWebhookId) => Promise<import("@dereekb/calcom").CalcomWebhookResponse>;
|
|
160
207
|
}
|
|
@@ -2,6 +2,12 @@ import { type ModuleMetadata } from '@nestjs/common';
|
|
|
2
2
|
import { ConfigService } from '@nestjs/config';
|
|
3
3
|
import { CalcomServiceConfig } from './calcom.config';
|
|
4
4
|
import { type Maybe } from '@dereekb/util';
|
|
5
|
+
/**
|
|
6
|
+
* Factory function that creates a {@link CalcomServiceConfig} from NestJS ConfigService values.
|
|
7
|
+
*
|
|
8
|
+
* @param _configService - the NestJS ConfigService instance
|
|
9
|
+
* @returns a validated CalcomServiceConfig
|
|
10
|
+
*/
|
|
5
11
|
export declare function calcomServiceConfigFactory(_configService: ConfigService): CalcomServiceConfig;
|
|
6
12
|
export interface ProvideAppCalcomMetadataConfig extends Pick<ModuleMetadata, 'imports' | 'exports' | 'providers'> {
|
|
7
13
|
/**
|
|
@@ -14,5 +20,8 @@ export interface ProvideAppCalcomMetadataConfig extends Pick<ModuleMetadata, 'im
|
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
22
|
* Convenience function used to generate ModuleMetadata for an app's CalcomModule.
|
|
23
|
+
*
|
|
24
|
+
* @param config - the module metadata configuration including optional dependency module
|
|
25
|
+
* @returns NestJS ModuleMetadata for registering the CalcomModule
|
|
17
26
|
*/
|
|
18
27
|
export declare function appCalcomModuleMetadata(config: ProvideAppCalcomMetadataConfig): ModuleMetadata;
|
|
@@ -8,10 +8,19 @@ export declare class CalcomOAuthApi {
|
|
|
8
8
|
readonly calcomOAuth: CalcomOAuth;
|
|
9
9
|
get oauthContext(): CalcomOAuthContext;
|
|
10
10
|
constructor(config: CalcomOAuthServiceConfig, cacheService: CalcomOAuthAccessTokenCacheService);
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Configured pass-through for {@link exchangeAuthorizationCode}.
|
|
13
|
+
*
|
|
14
|
+
* @returns function to exchange an OAuth authorization code for tokens
|
|
15
|
+
*/
|
|
12
16
|
get exchangeAuthorizationCode(): (input: import("@dereekb/calcom").CalcomOAuthExchangeAuthorizationCodeInput) => Promise<import("@dereekb/calcom").CalcomOAuthTokenResponse>;
|
|
13
17
|
/**
|
|
14
18
|
* Retrieves an access token for a specific user using their refresh token.
|
|
19
|
+
*
|
|
20
|
+
* @param input - contains the user's refresh token and optional access token cache
|
|
21
|
+
* @param input.refreshToken - the user's OAuth refresh token
|
|
22
|
+
* @param input.userAccessTokenCache - optional cache to store/retrieve the user's access token
|
|
23
|
+
* @returns a promise resolving to the user's CalcomAccessToken
|
|
15
24
|
*/
|
|
16
25
|
userAccessToken(input: {
|
|
17
26
|
refreshToken: string;
|
|
@@ -20,6 +29,9 @@ export declare class CalcomOAuthApi {
|
|
|
20
29
|
/**
|
|
21
30
|
* Returns a per-user CalcomAccessTokenCache derived from the refresh token (md5 hashed as the file key).
|
|
22
31
|
* Returns undefined if the cache service does not support per-user caching.
|
|
32
|
+
*
|
|
33
|
+
* @param refreshToken - the user's OAuth refresh token used to derive the cache key
|
|
34
|
+
* @returns a per-user access token cache, or undefined if not supported
|
|
23
35
|
*/
|
|
24
36
|
cacheForRefreshToken(refreshToken: CalcomRefreshToken): Maybe<CalcomAccessTokenCache>;
|
|
25
37
|
}
|
|
@@ -19,4 +19,10 @@ export declare abstract class CalcomOAuthServiceConfig {
|
|
|
19
19
|
readonly factoryConfig?: CalcomOAuthFactoryConfig;
|
|
20
20
|
static assertValidConfig(config: CalcomOAuthServiceConfig): void;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Factory function that creates a {@link CalcomOAuthServiceConfig} from NestJS ConfigService environment variables.
|
|
24
|
+
*
|
|
25
|
+
* @param configService - the NestJS ConfigService instance
|
|
26
|
+
* @returns a validated CalcomOAuthServiceConfig
|
|
27
|
+
*/
|
|
22
28
|
export declare function calcomOAuthServiceConfigFactory(configService: ConfigService): CalcomOAuthServiceConfig;
|
|
@@ -20,5 +20,8 @@ export interface ProvideAppCalcomOAuthMetadataConfig extends Pick<ModuleMetadata
|
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Convenience function used to generate ModuleMetadata for an app's CalcomOAuthModule.
|
|
23
|
+
*
|
|
24
|
+
* @param config - the module metadata configuration including optional dependency module and config factory
|
|
25
|
+
* @returns NestJS ModuleMetadata for registering the CalcomOAuthModule
|
|
23
26
|
*/
|
|
24
27
|
export declare function appCalcomOAuthModuleMetadata(config: ProvideAppCalcomOAuthMetadataConfig): ModuleMetadata;
|
|
@@ -24,9 +24,18 @@ export declare abstract class CalcomOAuthAccessTokenCacheService {
|
|
|
24
24
|
export type CalcomOAuthAccessTokenCacheServiceWithRefreshToken = Required<CalcomOAuthAccessTokenCacheService>;
|
|
25
25
|
/**
|
|
26
26
|
* Derives a short, filesystem-safe cache key from a refresh token using md5.
|
|
27
|
+
*
|
|
28
|
+
* @param refreshToken - the OAuth refresh token to hash
|
|
29
|
+
* @returns a 16-character hex string suitable for use as a cache key
|
|
27
30
|
*/
|
|
28
31
|
export declare function calcomRefreshTokenCacheKey(refreshToken: string): string;
|
|
29
32
|
export type LogMergeCalcomOAuthAccessTokenCacheServiceErrorFunction = (failedUpdates: (readonly [CalcomAccessTokenCache, unknown])[]) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Default error logging function for {@link mergeCalcomOAuthAccessTokenCacheServices}.
|
|
35
|
+
* Logs a warning for each cache that failed to update.
|
|
36
|
+
*
|
|
37
|
+
* @param failedUpdates - array of tuples containing the failed cache and its error
|
|
38
|
+
*/
|
|
30
39
|
export declare function logMergeCalcomOAuthAccessTokenCacheServiceErrorFunction(failedUpdates: (readonly [CalcomAccessTokenCache, unknown])[]): void;
|
|
31
40
|
/**
|
|
32
41
|
* Merges the input services in order to use some as a backup source.
|
|
@@ -35,11 +44,17 @@ export declare function logMergeCalcomOAuthAccessTokenCacheServiceErrorFunction(
|
|
|
35
44
|
* When updating a cached token, it will update the token across all services.
|
|
36
45
|
*
|
|
37
46
|
* @param inputServicesToMerge Must include at least one service. Empty arrays will throw an error.
|
|
47
|
+
* @param logError - optional error logging configuration; pass a function, true for default logging, or false to disable
|
|
48
|
+
* @returns a merged CalcomOAuthAccessTokenCacheService that delegates across all input services
|
|
38
49
|
*/
|
|
39
50
|
export declare function mergeCalcomOAuthAccessTokenCacheServices(inputServicesToMerge: CalcomOAuthAccessTokenCacheService[], logError?: Maybe<boolean | LogMergeCalcomOAuthAccessTokenCacheServiceErrorFunction>): CalcomOAuthAccessTokenCacheService;
|
|
40
51
|
/**
|
|
41
52
|
* Creates a CalcomOAuthAccessTokenCacheService that uses in-memory storage.
|
|
42
53
|
* Per-user caches are stored in a Map keyed by the md5 hash of the refresh token.
|
|
54
|
+
*
|
|
55
|
+
* @param existingToken - optional pre-existing server-level access token to seed the cache
|
|
56
|
+
* @param logAccessToConsole - when true, logs all cache reads and writes to console
|
|
57
|
+
* @returns a CalcomOAuthAccessTokenCacheService backed by in-memory Maps
|
|
43
58
|
*/
|
|
44
59
|
export declare function memoryCalcomOAuthAccessTokenCacheService(existingToken?: Maybe<CalcomAccessToken>, logAccessToConsole?: boolean): CalcomOAuthAccessTokenCacheService;
|
|
45
60
|
export declare const DEFAULT_FILE_CALCOM_ACCESS_TOKEN_CACHE_DIR = ".tmp/calcom-tokens";
|
|
@@ -62,5 +77,6 @@ export interface FileSystemCalcomOAuthAccessTokenCacheService extends CalcomOAut
|
|
|
62
77
|
* ```
|
|
63
78
|
*
|
|
64
79
|
* @param cacheDir Directory to store token files. Defaults to `.tmp/calcom-tokens`.
|
|
80
|
+
* @returns a CalcomOAuthAccessTokenCacheService backed by the file system
|
|
65
81
|
*/
|
|
66
82
|
export declare function fileCalcomOAuthAccessTokenCacheService(cacheDir?: string): FileSystemCalcomOAuthAccessTokenCacheService;
|
|
@@ -2,6 +2,9 @@ import { type HandlerBindAccessor, type HandlerMappedSetFunction, type Handler }
|
|
|
2
2
|
import { type CalcomWebhookEventType, type UntypedCalcomWebhookEvent, type CalcomWebhookEvent, type CalcomWebhookBookingPayload } from './webhook.calcom.type';
|
|
3
3
|
/**
|
|
4
4
|
* Creates a CalcomWebhookEvent and treats the data as the input type.
|
|
5
|
+
*
|
|
6
|
+
* @param event - the untyped webhook event to convert
|
|
7
|
+
* @returns a typed CalcomWebhookEvent with the payload cast to type T
|
|
5
8
|
*/
|
|
6
9
|
export declare function calcomWebhookEvent<T>(event: UntypedCalcomWebhookEvent): CalcomWebhookEvent<T>;
|
|
7
10
|
export type CalcomEventHandler = Handler<UntypedCalcomWebhookEvent, CalcomWebhookEventType>;
|