@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.
@@ -91,7 +91,12 @@ var CALCOM_API_KEY_CONFIG_KEY = 'CALCOM_API_KEY';
91
91
  ]);
92
92
  return CalcomOAuthServiceConfig;
93
93
  }();
94
- function calcomOAuthServiceConfigFactory(configService) {
94
+ /**
95
+ * Factory function that creates a {@link CalcomOAuthServiceConfig} from NestJS ConfigService environment variables.
96
+ *
97
+ * @param configService - the NestJS ConfigService instance
98
+ * @returns a validated CalcomOAuthServiceConfig
99
+ */ function calcomOAuthServiceConfigFactory(configService) {
95
100
  var clientId = configService.get(CALCOM_CLIENT_ID_CONFIG_KEY);
96
101
  var clientSecret = configService.get(CALCOM_CLIENT_SECRET_CONFIG_KEY);
97
102
  var refreshToken = configService.get(CALCOM_REFRESH_TOKEN_CONFIG_KEY);
@@ -313,10 +318,18 @@ exports.CalcomOAuthAccessTokenCacheService = __decorate([
313
318
  ], exports.CalcomOAuthAccessTokenCacheService);
314
319
  /**
315
320
  * Derives a short, filesystem-safe cache key from a refresh token using md5.
321
+ *
322
+ * @param refreshToken - the OAuth refresh token to hash
323
+ * @returns a 16-character hex string suitable for use as a cache key
316
324
  */ function calcomRefreshTokenCacheKey(refreshToken) {
317
325
  return crypto.createHash('md5').update(refreshToken).digest('hex').substring(0, 16);
318
326
  }
319
- function logMergeCalcomOAuthAccessTokenCacheServiceErrorFunction(failedUpdates) {
327
+ /**
328
+ * Default error logging function for {@link mergeCalcomOAuthAccessTokenCacheServices}.
329
+ * Logs a warning for each cache that failed to update.
330
+ *
331
+ * @param failedUpdates - array of tuples containing the failed cache and its error
332
+ */ function logMergeCalcomOAuthAccessTokenCacheServiceErrorFunction(failedUpdates) {
320
333
  console.warn("mergeCalcomOAuthAccessTokenCacheServices(): failed updating ".concat(failedUpdates.length, " caches."));
321
334
  failedUpdates.forEach(function(param, i) {
322
335
  var _param = _sliced_to_array(param, 2); _param[0]; var e = _param[1];
@@ -330,6 +343,8 @@ function logMergeCalcomOAuthAccessTokenCacheServiceErrorFunction(failedUpdates)
330
343
  * When updating a cached token, it will update the token across all services.
331
344
  *
332
345
  * @param inputServicesToMerge Must include at least one service. Empty arrays will throw an error.
346
+ * @param logError - optional error logging configuration; pass a function, true for default logging, or false to disable
347
+ * @returns a merged CalcomOAuthAccessTokenCacheService that delegates across all input services
333
348
  */ function mergeCalcomOAuthAccessTokenCacheServices(inputServicesToMerge, logError) {
334
349
  var allServices = _to_consumable_array$3(inputServicesToMerge);
335
350
  var logErrorFunction = typeof logError === 'function' ? logError : logError !== false ? logMergeCalcomOAuthAccessTokenCacheServiceErrorFunction : undefined;
@@ -414,6 +429,10 @@ function logMergeCalcomOAuthAccessTokenCacheServiceErrorFunction(failedUpdates)
414
429
  /**
415
430
  * Creates a CalcomOAuthAccessTokenCacheService that uses in-memory storage.
416
431
  * Per-user caches are stored in a Map keyed by the md5 hash of the refresh token.
432
+ *
433
+ * @param existingToken - optional pre-existing server-level access token to seed the cache
434
+ * @param logAccessToConsole - when true, logs all cache reads and writes to console
435
+ * @returns a CalcomOAuthAccessTokenCacheService backed by in-memory Maps
417
436
  */ function memoryCalcomOAuthAccessTokenCacheService(existingToken, logAccessToConsole) {
418
437
  var serverToken = existingToken;
419
438
  var userTokens = new Map();
@@ -486,6 +505,7 @@ var CALCOM_SERVER_TOKEN_FILE_KEY = 'server';
486
505
  * ```
487
506
  *
488
507
  * @param cacheDir Directory to store token files. Defaults to `.tmp/calcom-tokens`.
508
+ * @returns a CalcomOAuthAccessTokenCacheService backed by the file system
489
509
  */ function fileCalcomOAuthAccessTokenCacheService() {
490
510
  var cacheDir = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_FILE_CALCOM_ACCESS_TOKEN_CACHE_DIR;
491
511
  var memoryTokens = new Map();
@@ -675,13 +695,22 @@ exports.CalcomOAuthApi = /*#__PURE__*/ function() {
675
695
  {
676
696
  key: "exchangeAuthorizationCode",
677
697
  get: // MARK: Accessors
678
- /** Configured pass-through for {@link exchangeAuthorizationCode}. */ function get() {
698
+ /**
699
+ * Configured pass-through for {@link exchangeAuthorizationCode}.
700
+ *
701
+ * @returns function to exchange an OAuth authorization code for tokens
702
+ */ function get() {
679
703
  return calcom.exchangeAuthorizationCode(this.oauthContext);
680
704
  }
681
705
  },
682
706
  {
683
707
  /**
684
708
  * Retrieves an access token for a specific user using their refresh token.
709
+ *
710
+ * @param input - contains the user's refresh token and optional access token cache
711
+ * @param input.refreshToken - the user's OAuth refresh token
712
+ * @param input.userAccessTokenCache - optional cache to store/retrieve the user's access token
713
+ * @returns a promise resolving to the user's CalcomAccessToken
685
714
  */ key: "userAccessToken",
686
715
  value: function userAccessToken(input) {
687
716
  var factory = this.oauthContext.makeUserAccessTokenFactory(input);
@@ -692,6 +721,9 @@ exports.CalcomOAuthApi = /*#__PURE__*/ function() {
692
721
  /**
693
722
  * Returns a per-user CalcomAccessTokenCache derived from the refresh token (md5 hashed as the file key).
694
723
  * Returns undefined if the cache service does not support per-user caching.
724
+ *
725
+ * @param refreshToken - the user's OAuth refresh token used to derive the cache key
726
+ * @returns a per-user access token cache, or undefined if not supported
695
727
  */ key: "cacheForRefreshToken",
696
728
  value: function cacheForRefreshToken(refreshToken) {
697
729
  var _this_cacheService_cacheForRefreshToken, _this_cacheService;
@@ -734,6 +766,9 @@ function _unsupported_iterable_to_array$2(o, minLen) {
734
766
  }
735
767
  /**
736
768
  * Convenience function used to generate ModuleMetadata for an app's CalcomOAuthModule.
769
+ *
770
+ * @param config - the module metadata configuration including optional dependency module and config factory
771
+ * @returns NestJS ModuleMetadata for registering the CalcomOAuthModule
737
772
  */ function appCalcomOAuthModuleMetadata(config$1) {
738
773
  var _config_calcomOAuthServiceConfigFactory;
739
774
  var dependencyModule = config$1.dependencyModule, imports = config$1.imports, exports$1 = config$1.exports, providers = config$1.providers;
@@ -926,6 +961,8 @@ function _object_spread_props$1(target, source) {
926
961
  get: /**
927
962
  * Returns the cached {@link CalcomApiContextInstance} for the server context.
928
963
  * All API functions are available through this instance.
964
+ *
965
+ * @returns the server context instance
929
966
  */ function get() {
930
967
  return this._serverInstance();
931
968
  }
@@ -933,7 +970,11 @@ function _object_spread_props$1(target, source) {
933
970
  {
934
971
  key: "getAvailableSlots",
935
972
  get: // MARK: Public Context
936
- /** Configured pass-through for {@link getAvailableSlots} using the public (unauthenticated) context. */ function get() {
973
+ /**
974
+ * Configured pass-through for {@link getAvailableSlots} using the public (unauthenticated) context.
975
+ *
976
+ * @returns function to query available slots without authentication
977
+ */ function get() {
937
978
  return calcom.getAvailableSlots(this._publicContext());
938
979
  }
939
980
  },
@@ -947,6 +988,9 @@ function _object_spread_props$1(target, source) {
947
988
  * resolved from the cache service using an md5 hash of the refresh token as the key.
948
989
  * This ensures tokens persist across requests and server restarts without collisions.
949
990
  *
991
+ * @param input - the user context factory input containing the refresh token and optional cache
992
+ * @returns a new CalcomApiContextInstance scoped to the user
993
+ *
950
994
  * @example
951
995
  * ```ts
952
996
  * // Automatic per-user caching (recommended):
@@ -977,6 +1021,9 @@ function _object_spread_props$1(target, source) {
977
1021
  {
978
1022
  /**
979
1023
  * Creates a {@link CalcomApiContextInstance} from any {@link CalcomContext}.
1024
+ *
1025
+ * @param context - the CalcomContext (server or user) to wrap
1026
+ * @returns a new CalcomApiContextInstance bound to the given context
980
1027
  */ key: "makeContextInstance",
981
1028
  value: function makeContextInstance(context) {
982
1029
  return new CalcomApiContextInstance(this, context);
@@ -986,6 +1033,9 @@ function _object_spread_props$1(target, source) {
986
1033
  /**
987
1034
  * Creates a raw {@link CalcomUserContext} from a refresh token, without wrapping in a {@link CalcomApiContextInstance}.
988
1035
  * Prefer {@link makeUserContextInstance} unless you need direct context access.
1036
+ *
1037
+ * @param input - the user context factory input containing the refresh token and optional cache
1038
+ * @returns a CalcomUserContext for the given user
989
1039
  */ key: "makeUserContext",
990
1040
  value: function makeUserContext(input) {
991
1041
  return this.calcom.calcomServerContext.makeUserContext(input);
@@ -1032,6 +1082,8 @@ exports.CalcomApi = __decorate([
1032
1082
  get: // MARK: User
1033
1083
  /**
1034
1084
  * Configured pass-through for {@link getMe}.
1085
+ *
1086
+ * @returns function to retrieve the authenticated user's profile
1035
1087
  */ function get() {
1036
1088
  return calcom.getMe(this.context);
1037
1089
  }
@@ -1041,6 +1093,8 @@ exports.CalcomApi = __decorate([
1041
1093
  get: // MARK: Schedules
1042
1094
  /**
1043
1095
  * Configured pass-through for {@link getSchedules}.
1096
+ *
1097
+ * @returns function to retrieve all schedules for the authenticated user
1044
1098
  */ function get() {
1045
1099
  return calcom.getSchedules(this.context);
1046
1100
  }
@@ -1050,6 +1104,8 @@ exports.CalcomApi = __decorate([
1050
1104
  get: // MARK: Bookings
1051
1105
  /**
1052
1106
  * Configured pass-through for {@link createBooking}.
1107
+ *
1108
+ * @returns function to create a new booking
1053
1109
  */ function get() {
1054
1110
  return calcom.createBooking(this.context);
1055
1111
  }
@@ -1058,6 +1114,8 @@ exports.CalcomApi = __decorate([
1058
1114
  key: "getBooking",
1059
1115
  get: /**
1060
1116
  * Configured pass-through for {@link getBooking}.
1117
+ *
1118
+ * @returns function to retrieve a booking by UID
1061
1119
  */ function get() {
1062
1120
  return calcom.getBooking(this.context);
1063
1121
  }
@@ -1066,6 +1124,8 @@ exports.CalcomApi = __decorate([
1066
1124
  key: "cancelBooking",
1067
1125
  get: /**
1068
1126
  * Configured pass-through for {@link cancelBooking}.
1127
+ *
1128
+ * @returns function to cancel a booking by UID
1069
1129
  */ function get() {
1070
1130
  return calcom.cancelBooking(this.context);
1071
1131
  }
@@ -1075,6 +1135,8 @@ exports.CalcomApi = __decorate([
1075
1135
  get: // MARK: Event Types
1076
1136
  /**
1077
1137
  * Configured pass-through for {@link getEventTypes}.
1138
+ *
1139
+ * @returns function to retrieve all event types for the authenticated user
1078
1140
  */ function get() {
1079
1141
  return calcom.getEventTypes(this.context);
1080
1142
  }
@@ -1083,6 +1145,8 @@ exports.CalcomApi = __decorate([
1083
1145
  key: "createEventType",
1084
1146
  get: /**
1085
1147
  * Configured pass-through for {@link createEventType}.
1148
+ *
1149
+ * @returns function to create a new event type
1086
1150
  */ function get() {
1087
1151
  return calcom.createEventType(this.context);
1088
1152
  }
@@ -1091,6 +1155,8 @@ exports.CalcomApi = __decorate([
1091
1155
  key: "updateEventType",
1092
1156
  get: /**
1093
1157
  * Configured pass-through for {@link updateEventType}.
1158
+ *
1159
+ * @returns function to update an existing event type by ID
1094
1160
  */ function get() {
1095
1161
  return calcom.updateEventType(this.context);
1096
1162
  }
@@ -1099,6 +1165,8 @@ exports.CalcomApi = __decorate([
1099
1165
  key: "deleteEventType",
1100
1166
  get: /**
1101
1167
  * Configured pass-through for {@link deleteEventType}.
1168
+ *
1169
+ * @returns function to delete an event type by ID
1102
1170
  */ function get() {
1103
1171
  return calcom.deleteEventType(this.context);
1104
1172
  }
@@ -1108,6 +1176,8 @@ exports.CalcomApi = __decorate([
1108
1176
  get: // MARK: Calendars
1109
1177
  /**
1110
1178
  * Configured pass-through for {@link getCalendars}.
1179
+ *
1180
+ * @returns function to retrieve all connected calendars
1111
1181
  */ function get() {
1112
1182
  return calcom.getCalendars(this.context);
1113
1183
  }
@@ -1116,6 +1186,8 @@ exports.CalcomApi = __decorate([
1116
1186
  key: "getBusyTimes",
1117
1187
  get: /**
1118
1188
  * Configured pass-through for {@link getBusyTimes}.
1189
+ *
1190
+ * @returns function to retrieve busy time ranges across connected calendars
1119
1191
  */ function get() {
1120
1192
  return calcom.getBusyTimes(this.context);
1121
1193
  }
@@ -1125,6 +1197,8 @@ exports.CalcomApi = __decorate([
1125
1197
  get: // MARK: Webhooks
1126
1198
  /**
1127
1199
  * Configured pass-through for {@link createWebhook}.
1200
+ *
1201
+ * @returns function to create a webhook subscription
1128
1202
  */ function get() {
1129
1203
  return calcom.createWebhook(this.context);
1130
1204
  }
@@ -1133,6 +1207,8 @@ exports.CalcomApi = __decorate([
1133
1207
  key: "getWebhooks",
1134
1208
  get: /**
1135
1209
  * Configured pass-through for {@link getWebhooks}.
1210
+ *
1211
+ * @returns function to retrieve all webhooks
1136
1212
  */ function get() {
1137
1213
  return calcom.getWebhooks(this.context);
1138
1214
  }
@@ -1141,6 +1217,8 @@ exports.CalcomApi = __decorate([
1141
1217
  key: "getWebhook",
1142
1218
  get: /**
1143
1219
  * Configured pass-through for {@link getWebhook}.
1220
+ *
1221
+ * @returns function to retrieve a specific webhook by ID
1144
1222
  */ function get() {
1145
1223
  return calcom.getWebhook(this.context);
1146
1224
  }
@@ -1149,6 +1227,8 @@ exports.CalcomApi = __decorate([
1149
1227
  key: "updateWebhook",
1150
1228
  get: /**
1151
1229
  * Configured pass-through for {@link updateWebhook}.
1230
+ *
1231
+ * @returns function to update an existing webhook by ID
1152
1232
  */ function get() {
1153
1233
  return calcom.updateWebhook(this.context);
1154
1234
  }
@@ -1157,6 +1237,8 @@ exports.CalcomApi = __decorate([
1157
1237
  key: "deleteWebhook",
1158
1238
  get: /**
1159
1239
  * Configured pass-through for {@link deleteWebhook}.
1240
+ *
1241
+ * @returns function to delete a webhook by ID
1160
1242
  */ function get() {
1161
1243
  return calcom.deleteWebhook(this.context);
1162
1244
  }
@@ -1192,7 +1274,12 @@ function _unsupported_iterable_to_array$1(o, minLen) {
1192
1274
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
1193
1275
  }
1194
1276
  // MARK: Provider Factories
1195
- function calcomServiceConfigFactory(_configService) {
1277
+ /**
1278
+ * Factory function that creates a {@link CalcomServiceConfig} from NestJS ConfigService values.
1279
+ *
1280
+ * @param _configService - the NestJS ConfigService instance
1281
+ * @returns a validated CalcomServiceConfig
1282
+ */ function calcomServiceConfigFactory(_configService) {
1196
1283
  var config = {
1197
1284
  calcom: {}
1198
1285
  };
@@ -1201,6 +1288,9 @@ function calcomServiceConfigFactory(_configService) {
1201
1288
  }
1202
1289
  /**
1203
1290
  * Convenience function used to generate ModuleMetadata for an app's CalcomModule.
1291
+ *
1292
+ * @param config - the module metadata configuration including optional dependency module
1293
+ * @returns NestJS ModuleMetadata for registering the CalcomModule
1204
1294
  */ function appCalcomModuleMetadata(config$1) {
1205
1295
  var dependencyModule = config$1.dependencyModule, imports = config$1.imports, exports$1 = config$1.exports, providers = config$1.providers;
1206
1296
  var dependencyModuleImport = dependencyModule ? [
@@ -1281,6 +1371,9 @@ function _object_spread_props(target, source) {
1281
1371
  }
1282
1372
  /**
1283
1373
  * Creates a CalcomWebhookEvent and treats the data as the input type.
1374
+ *
1375
+ * @param event - the untyped webhook event to convert
1376
+ * @returns a typed CalcomWebhookEvent with the payload cast to type T
1284
1377
  */ function calcomWebhookEvent(event) {
1285
1378
  return {
1286
1379
  triggerEvent: event.triggerEvent,
@@ -1293,7 +1386,6 @@ var calcomEventHandlerFactory = util.handlerFactory(function(x) {
1293
1386
  });
1294
1387
  var calcomEventHandlerConfigurerFactory = util.handlerConfigurerFactory({
1295
1388
  configurerForAccessor: function configurerForAccessor(accessor) {
1296
- // eslint-disable-next-line
1297
1389
  var fnWithKey = util.handlerMappedSetFunctionFactory(accessor, calcomWebhookEvent);
1298
1390
  var configurer = _object_spread_props(_object_spread({}, accessor), {
1299
1391
  handleBookingCreated: fnWithKey(CALCOM_WEBHOOK_BOOKING_CREATED),
@@ -1373,7 +1465,7 @@ var CALCOM_WEBHOOK_SECRET_CONFIG_KEY = 'CALCOM_WEBHOOK_SECRET';
1373
1465
  var event;
1374
1466
  try {
1375
1467
  event = JSON.parse(rawBodyString);
1376
- } catch (e) {
1468
+ } catch (unused) {
1377
1469
  event = {
1378
1470
  triggerEvent: '',
1379
1471
  createdAt: '',
@@ -1870,7 +1962,12 @@ function _unsupported_iterable_to_array(o, minLen) {
1870
1962
  if (n === "Map" || n === "Set") return Array.from(n);
1871
1963
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
1872
1964
  }
1873
- function calcomWebhookServiceConfigFactory(configService) {
1965
+ /**
1966
+ * Factory function that creates a {@link CalcomWebhookServiceConfig} from NestJS ConfigService environment variables.
1967
+ *
1968
+ * @param configService - the NestJS ConfigService instance
1969
+ * @returns a validated CalcomWebhookServiceConfig
1970
+ */ function calcomWebhookServiceConfigFactory(configService) {
1874
1971
  var config = {
1875
1972
  webhookConfig: {
1876
1973
  webhookSecret: configService.get(CALCOM_WEBHOOK_SECRET_CONFIG_KEY)
@@ -1909,6 +2006,9 @@ exports.CalcomWebhookModule = __decorate([
1909
2006
  ], exports.CalcomWebhookModule);
1910
2007
  /**
1911
2008
  * Convenience function used to generate ModuleMetadata for an app's CalcomWebhookModule.
2009
+ *
2010
+ * @param config - the module metadata configuration including optional dependency module
2011
+ * @returns NestJS ModuleMetadata for registering the CalcomWebhookModule
1912
2012
  */ function appCalcomWebhookModuleMetadata(config$1) {
1913
2013
  var dependencyModule = config$1.dependencyModule, imports = config$1.imports, exports$1 = config$1.exports, providers = config$1.providers;
1914
2014
  var dependencyModuleImport = dependencyModule ? [