@dereekb/calcom 13.35.0 → 13.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -10,7 +10,7 @@ function _assert_this_initialized$1(self) {
10
10
  }
11
11
  return self;
12
12
  }
13
- function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
13
+ function asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, key, arg) {
14
14
  try {
15
15
  var info = gen[key](arg);
16
16
  var value = info.value;
@@ -24,16 +24,16 @@ function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
24
24
  Promise.resolve(value).then(_next, _throw);
25
25
  }
26
26
  }
27
- function _async_to_generator$5(fn) {
27
+ function _async_to_generator$6(fn) {
28
28
  return function() {
29
29
  var self = this, args = arguments;
30
30
  return new Promise(function(resolve, reject) {
31
31
  var gen = fn.apply(self, args);
32
32
  function _next(value) {
33
- asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "next", value);
33
+ asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, "next", value);
34
34
  }
35
35
  function _throw(err) {
36
- asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "throw", err);
36
+ asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, "throw", err);
37
37
  }
38
38
  _next(undefined);
39
39
  });
@@ -61,7 +61,7 @@ function _create_class(Constructor, protoProps, staticProps) {
61
61
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
62
62
  return Constructor;
63
63
  }
64
- function _define_property$2(obj, key, value) {
64
+ function _define_property$3(obj, key, value) {
65
65
  if (key in obj) {
66
66
  Object.defineProperty(obj, key, {
67
67
  value: value,
@@ -126,7 +126,7 @@ function _is_native_reflect_construct$1() {
126
126
  return !!result;
127
127
  })();
128
128
  }
129
- function _ts_generator$5(thisArg, body) {
129
+ function _ts_generator$6(thisArg, body) {
130
130
  var f, y, t, _ = {
131
131
  label: 0,
132
132
  sent: function() {
@@ -234,7 +234,7 @@ function _ts_generator$5(thisArg, body) {
234
234
  var _this;
235
235
  _this = _call_super$1(this, CalcomServerError, [
236
236
  error.message
237
- ]), _define_property$2(_this, "error", void 0);
237
+ ]), _define_property$3(_this, "error", void 0);
238
238
  _this.error = error;
239
239
  return _this;
240
240
  }
@@ -257,7 +257,7 @@ function _ts_generator$5(thisArg, body) {
257
257
  var _this;
258
258
  _this = _call_super$1(this, CalcomServerFetchResponseError, [
259
259
  data
260
- ]), _define_property$2(_this, "data", void 0), _define_property$2(_this, "responseError", void 0);
260
+ ]), _define_property$3(_this, "data", void 0), _define_property$3(_this, "responseError", void 0);
261
261
  _this.data = data;
262
262
  _this.responseError = responseError;
263
263
  return _this;
@@ -301,9 +301,9 @@ function _ts_generator$5(thisArg, body) {
301
301
  return function(fetch$1) {
302
302
  var logError = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultLogError;
303
303
  return function(x, y) {
304
- return _async_to_generator$5(function() {
304
+ return _async_to_generator$6(function() {
305
305
  var e, error;
306
- return _ts_generator$5(this, function(_state) {
306
+ return _ts_generator$6(this, function(_state) {
307
307
  switch(_state.label){
308
308
  case 0:
309
309
  _state.trys.push([
@@ -422,7 +422,7 @@ var CalcomTooManyRequestsError = /*#__PURE__*/ function(CalcomServerFetchRespons
422
422
  return result;
423
423
  }
424
424
 
425
- function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
425
+ function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
426
426
  try {
427
427
  var info = gen[key](arg);
428
428
  var value = info.value;
@@ -436,22 +436,22 @@ function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
436
436
  Promise.resolve(value).then(_next, _throw);
437
437
  }
438
438
  }
439
- function _async_to_generator$4(fn) {
439
+ function _async_to_generator$5(fn) {
440
440
  return function() {
441
441
  var self = this, args = arguments;
442
442
  return new Promise(function(resolve, reject) {
443
443
  var gen = fn.apply(self, args);
444
444
  function _next(value) {
445
- asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
445
+ asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "next", value);
446
446
  }
447
447
  function _throw(err) {
448
- asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
448
+ asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "throw", err);
449
449
  }
450
450
  _next(undefined);
451
451
  });
452
452
  };
453
453
  }
454
- function _ts_generator$4(thisArg, body) {
454
+ function _ts_generator$5(thisArg, body) {
455
455
  var f, y, t, _ = {
456
456
  label: 0,
457
457
  sent: function() {
@@ -552,6 +552,25 @@ function _ts_generator$4(thisArg, body) {
552
552
  }
553
553
  // MARK: Parser
554
554
  var logCalcomErrorToConsole = logCalcomServerErrorFunction('Calcom');
555
+ /**
556
+ * Flattens a Cal.com API error response body into {@link CalcomServerErrorData}.
557
+ *
558
+ * Reads the nested `error` envelope when present, and otherwise treats the body as already
559
+ * flat — so an endpoint that returns a bare error object still yields its code and message.
560
+ *
561
+ * @param body - The parsed error response body.
562
+ * @returns The flattened error data.
563
+ */ function calcomServerErrorDataFromApiErrorResponseBody(body) {
564
+ var _ref, _ref1, _ref2;
565
+ var error = body.error, status = body.status;
566
+ var flatBody = body;
567
+ return {
568
+ code: (_ref = error === null || error === void 0 ? void 0 : error.code) !== null && _ref !== void 0 ? _ref : flatBody.code,
569
+ message: (_ref1 = error === null || error === void 0 ? void 0 : error.message) !== null && _ref1 !== void 0 ? _ref1 : flatBody.message,
570
+ details: (_ref2 = error === null || error === void 0 ? void 0 : error.details) !== null && _ref2 !== void 0 ? _ref2 : flatBody.details,
571
+ status: status !== null && status !== void 0 ? status : undefined
572
+ };
573
+ }
555
574
  /**
556
575
  * Parses a FetchResponseError from a Cal.com API call into a typed CalcomServerError.
557
576
  * Attempts to extract JSON error data from the response body.
@@ -559,9 +578,9 @@ var logCalcomErrorToConsole = logCalcomServerErrorFunction('Calcom');
559
578
  * @param responseError - The fetch response error to parse.
560
579
  * @returns A parsed CalcomServerError, or undefined if the response body cannot be parsed.
561
580
  */ function parseCalcomApiError(responseError) {
562
- return _async_to_generator$4(function() {
563
- var data, result;
564
- return _ts_generator$4(this, function(_state) {
581
+ return _async_to_generator$5(function() {
582
+ var body, result;
583
+ return _ts_generator$5(this, function(_state) {
565
584
  switch(_state.label){
566
585
  case 0:
567
586
  return [
@@ -571,9 +590,9 @@ var logCalcomErrorToConsole = logCalcomServerErrorFunction('Calcom');
571
590
  })
572
591
  ];
573
592
  case 1:
574
- data = _state.sent();
575
- if (data) {
576
- result = parseCalcomApiServerErrorResponseData(data, responseError);
593
+ body = _state.sent();
594
+ if (body) {
595
+ result = parseCalcomApiServerErrorResponseData(calcomServerErrorDataFromApiErrorResponseBody(body), responseError);
577
596
  }
578
597
  return [
579
598
  2,
@@ -609,7 +628,7 @@ function _assert_this_initialized(self) {
609
628
  }
610
629
  return self;
611
630
  }
612
- function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
631
+ function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
613
632
  try {
614
633
  var info = gen[key](arg);
615
634
  var value = info.value;
@@ -623,16 +642,16 @@ function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
623
642
  Promise.resolve(value).then(_next, _throw);
624
643
  }
625
644
  }
626
- function _async_to_generator$3(fn) {
645
+ function _async_to_generator$4(fn) {
627
646
  return function() {
628
647
  var self = this, args = arguments;
629
648
  return new Promise(function(resolve, reject) {
630
649
  var gen = fn.apply(self, args);
631
650
  function _next(value) {
632
- asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
651
+ asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
633
652
  }
634
653
  function _throw(err) {
635
- asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
654
+ asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
636
655
  }
637
656
  _next(undefined);
638
657
  });
@@ -647,7 +666,7 @@ function _class_call_check(instance, Constructor) {
647
666
  throw new TypeError("Cannot call a class as a function");
648
667
  }
649
668
  }
650
- function _define_property$1(obj, key, value) {
669
+ function _define_property$2(obj, key, value) {
651
670
  if (key in obj) {
652
671
  Object.defineProperty(obj, key, {
653
672
  value: value,
@@ -704,7 +723,7 @@ function _is_native_reflect_construct() {
704
723
  return !!result;
705
724
  })();
706
725
  }
707
- function _ts_generator$3(thisArg, body) {
726
+ function _ts_generator$4(thisArg, body) {
708
727
  var f, y, t, _ = {
709
728
  label: 0,
710
729
  sent: function() {
@@ -816,7 +835,7 @@ function _ts_generator$3(thisArg, body) {
816
835
  var _this;
817
836
  _this = _call_super(this, CalcomOAuthAccessTokenError, [
818
837
  "CalcomOAuthAccessTokenError: ".concat(errorCode)
819
- ]), _define_property$1(_this, "errorCode", void 0);
838
+ ]), _define_property$2(_this, "errorCode", void 0);
820
839
  _this.errorCode = errorCode;
821
840
  return _this;
822
841
  }
@@ -831,7 +850,7 @@ function _ts_generator$3(thisArg, body) {
831
850
  var _this;
832
851
  _this = _call_super(this, CalcomOAuthAuthFailureError, [
833
852
  "Failed to retrieve proper authentication for the API call. Reason: ".concat(reason)
834
- ]), _define_property$1(_this, "reason", void 0);
853
+ ]), _define_property$2(_this, "reason", void 0);
835
854
  _this.reason = reason;
836
855
  return _this;
837
856
  }
@@ -845,9 +864,9 @@ var logCalcomOAuthErrorToConsole = logCalcomServerErrorFunction('CalcomOAuth');
845
864
  * @param responseError - The fetch response error to parse.
846
865
  * @returns A parsed CalcomServerError or CalcomOAuthAccessTokenError, or undefined if unparseable.
847
866
  */ function parseCalcomOAuthError(responseError) {
848
- return _async_to_generator$3(function() {
867
+ return _async_to_generator$4(function() {
849
868
  var data, result;
850
- return _ts_generator$3(this, function(_state) {
869
+ return _ts_generator$4(this, function(_state) {
851
870
  switch(_state.label){
852
871
  case 0:
853
872
  return [
@@ -895,7 +914,7 @@ var logCalcomOAuthErrorToConsole = logCalcomServerErrorFunction('CalcomOAuth');
895
914
  }
896
915
  var handleCalcomOAuthErrorFetch = handleCalcomErrorFetchFactory(parseCalcomOAuthError, logCalcomOAuthErrorToConsole);
897
916
 
898
- function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
917
+ function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
899
918
  try {
900
919
  var info = gen[key](arg);
901
920
  var value = info.value;
@@ -909,22 +928,22 @@ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
909
928
  Promise.resolve(value).then(_next, _throw);
910
929
  }
911
930
  }
912
- function _async_to_generator$2(fn) {
931
+ function _async_to_generator$3(fn) {
913
932
  return function() {
914
933
  var self = this, args = arguments;
915
934
  return new Promise(function(resolve, reject) {
916
935
  var gen = fn.apply(self, args);
917
936
  function _next(value) {
918
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
937
+ asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
919
938
  }
920
939
  function _throw(err) {
921
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
940
+ asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
922
941
  }
923
942
  _next(undefined);
924
943
  });
925
944
  };
926
945
  }
927
- function _ts_generator$2(thisArg, body) {
946
+ function _ts_generator$3(thisArg, body) {
928
947
  var f, y, t, _ = {
929
948
  label: 0,
930
949
  sent: function() {
@@ -1034,9 +1053,9 @@ function _ts_generator$2(thisArg, body) {
1034
1053
  * @__NO_SIDE_EFFECTS__
1035
1054
  */ function calcomAccessTokenStringFactory(calcomAccessTokenFactory) {
1036
1055
  return function() {
1037
- return _async_to_generator$2(function() {
1056
+ return _async_to_generator$3(function() {
1038
1057
  var token;
1039
- return _ts_generator$2(this, function(_state) {
1058
+ return _ts_generator$3(this, function(_state) {
1040
1059
  switch(_state.label){
1041
1060
  case 0:
1042
1061
  return [
@@ -1129,7 +1148,7 @@ var DEFAULT_CALCOM_RATE_LIMITED_TOO_MANY_REQUESTS_LOG_FUNCTION = function DEFAUL
1129
1148
  * The Cal.com API URL.
1130
1149
  */ var CALCOM_API_URL = 'https://api.cal.com/v2';
1131
1150
 
1132
- function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
1151
+ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
1133
1152
  try {
1134
1153
  var info = gen[key](arg);
1135
1154
  var value = info.value;
@@ -1143,22 +1162,22 @@ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
1143
1162
  Promise.resolve(value).then(_next, _throw);
1144
1163
  }
1145
1164
  }
1146
- function _async_to_generator$1(fn) {
1165
+ function _async_to_generator$2(fn) {
1147
1166
  return function() {
1148
1167
  var self = this, args = arguments;
1149
1168
  return new Promise(function(resolve, reject) {
1150
1169
  var gen = fn.apply(self, args);
1151
1170
  function _next(value) {
1152
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
1171
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
1153
1172
  }
1154
1173
  function _throw(err) {
1155
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
1174
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
1156
1175
  }
1157
1176
  _next(undefined);
1158
1177
  });
1159
1178
  };
1160
1179
  }
1161
- function _ts_generator$1(thisArg, body) {
1180
+ function _ts_generator$2(thisArg, body) {
1162
1181
  var f, y, t, _ = {
1163
1182
  label: 0,
1164
1183
  sent: function() {
@@ -1274,9 +1293,9 @@ function _ts_generator$1(thisArg, body) {
1274
1293
  return fetch.fetchApiFetchService.makeFetch({
1275
1294
  baseUrl: CALCOM_API_URL,
1276
1295
  baseRequest: function baseRequest() {
1277
- return _async_to_generator$1(function() {
1296
+ return _async_to_generator$2(function() {
1278
1297
  var _tmp, _tmp1, _, _1;
1279
- return _ts_generator$1(this, function(_state) {
1298
+ return _ts_generator$2(this, function(_state) {
1280
1299
  switch(_state.label){
1281
1300
  case 0:
1282
1301
  _tmp = {};
@@ -1376,7 +1395,7 @@ function _ts_generator$1(thisArg, body) {
1376
1395
  };
1377
1396
  }
1378
1397
 
1379
- function _define_property(obj, key, value) {
1398
+ function _define_property$1(obj, key, value) {
1380
1399
  if (key in obj) {
1381
1400
  Object.defineProperty(obj, key, {
1382
1401
  value: value,
@@ -1406,7 +1425,7 @@ var CALCOM_API_VERSION_HEADER = 'cal-api-version';
1406
1425
  * @param version - The Cal.com API version string to include in the header.
1407
1426
  * @returns A headers record containing the cal-api-version header.
1408
1427
  */ function calcomApiVersionHeaders(version) {
1409
- return _define_property({}, CALCOM_API_VERSION_HEADER, version);
1428
+ return _define_property$1({}, CALCOM_API_VERSION_HEADER, version);
1410
1429
  }
1411
1430
 
1412
1431
  /**
@@ -1462,6 +1481,8 @@ var CALCOM_API_VERSION_HEADER = 'cal-api-version';
1462
1481
  * @param context - The Cal.com API context (authenticated or public)
1463
1482
  * @returns Queries available slots for the given input.
1464
1483
  *
1484
+ * The `cal-api-version` header is REQUIRED here — without it the endpoint 404s.
1485
+ *
1465
1486
  * @see https://cal.com/docs/api-reference/v2/slots/get-available-time-slots-for-an-event-type
1466
1487
  *
1467
1488
  * @example
@@ -1472,8 +1493,8 @@ var CALCOM_API_VERSION_HEADER = 'cal-api-version';
1472
1493
  * eventTypeId: 12345
1473
1494
  * });
1474
1495
  *
1475
- * for (const [date, slots] of Object.entries(response.data.slots)) {
1476
- * console.log(date, slots.map(s => s.time));
1496
+ * for (const [date, slots] of Object.entries(response.data)) {
1497
+ * console.log(date, slots.map(s => s.start));
1477
1498
  * }
1478
1499
  * ```
1479
1500
  */ function getAvailableSlots(context) {
@@ -1515,6 +1536,31 @@ var CALCOM_API_VERSION_HEADER = 'cal-api-version';
1515
1536
  });
1516
1537
  };
1517
1538
  }
1539
+ /**
1540
+ * Retrieves the bookings visible to the authenticated user, newest page first.
1541
+ *
1542
+ * Paginated: read {@link CalcomGetBookingsResponse.pagination} rather than assuming `data` holds
1543
+ * everything, as the endpoint caps a page even with no `take`.
1544
+ *
1545
+ * @param context - The Cal.com API context providing authentication and fetch capabilities.
1546
+ * @returns Retrieves a page of bookings for the given input.
1547
+ *
1548
+ * @see https://cal.com/docs/api-reference/v2/bookings/get-all-bookings
1549
+ *
1550
+ * @example
1551
+ * ```ts
1552
+ * const response = await getBookings(context)({ take: 10, status: 'upcoming', sortStart: 'asc' });
1553
+ * console.log(response.pagination.totalItems, response.data.map(b => b.uid));
1554
+ * ```
1555
+ */ function getBookings(context) {
1556
+ return function(input) {
1557
+ var params = fetch.makeUrlSearchParams(input);
1558
+ return context.fetchJson("/bookings?".concat(params), {
1559
+ method: 'GET',
1560
+ headers: calcomApiVersionHeaders(CALCOM_API_VERSION_BOOKINGS)
1561
+ });
1562
+ };
1563
+ }
1518
1564
  /**
1519
1565
  * Retrieves a booking by its unique UID.
1520
1566
  *
@@ -1653,6 +1699,181 @@ var CALCOM_API_VERSION_HEADER = 'cal-api-version';
1653
1699
  };
1654
1700
  }
1655
1701
 
1702
+ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
1703
+ try {
1704
+ var info = gen[key](arg);
1705
+ var value = info.value;
1706
+ } catch (error) {
1707
+ reject(error);
1708
+ return;
1709
+ }
1710
+ if (info.done) {
1711
+ resolve(value);
1712
+ } else {
1713
+ Promise.resolve(value).then(_next, _throw);
1714
+ }
1715
+ }
1716
+ function _async_to_generator$1(fn) {
1717
+ return function() {
1718
+ var self = this, args = arguments;
1719
+ return new Promise(function(resolve, reject) {
1720
+ var gen = fn.apply(self, args);
1721
+ function _next(value) {
1722
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
1723
+ }
1724
+ function _throw(err) {
1725
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
1726
+ }
1727
+ _next(undefined);
1728
+ });
1729
+ };
1730
+ }
1731
+ function _define_property(obj, key, value) {
1732
+ if (key in obj) {
1733
+ Object.defineProperty(obj, key, {
1734
+ value: value,
1735
+ enumerable: true,
1736
+ configurable: true,
1737
+ writable: true
1738
+ });
1739
+ } else {
1740
+ obj[key] = value;
1741
+ }
1742
+ return obj;
1743
+ }
1744
+ function _object_spread(target) {
1745
+ for(var i = 1; i < arguments.length; i++){
1746
+ var source = arguments[i] != null ? arguments[i] : {};
1747
+ var ownKeys = Object.keys(source);
1748
+ if (typeof Object.getOwnPropertySymbols === "function") {
1749
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1750
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1751
+ }));
1752
+ }
1753
+ ownKeys.forEach(function(key) {
1754
+ _define_property(target, key, source[key]);
1755
+ });
1756
+ }
1757
+ return target;
1758
+ }
1759
+ function ownKeys(object, enumerableOnly) {
1760
+ var keys = Object.keys(object);
1761
+ if (Object.getOwnPropertySymbols) {
1762
+ var symbols = Object.getOwnPropertySymbols(object);
1763
+ keys.push.apply(keys, symbols);
1764
+ }
1765
+ return keys;
1766
+ }
1767
+ function _object_spread_props(target, source) {
1768
+ source = source != null ? source : {};
1769
+ if (Object.getOwnPropertyDescriptors) {
1770
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1771
+ } else {
1772
+ ownKeys(Object(source)).forEach(function(key) {
1773
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1774
+ });
1775
+ }
1776
+ return target;
1777
+ }
1778
+ function _ts_generator$1(thisArg, body) {
1779
+ var f, y, t, _ = {
1780
+ label: 0,
1781
+ sent: function() {
1782
+ if (t[0] & 1) throw t[1];
1783
+ return t[1];
1784
+ },
1785
+ trys: [],
1786
+ ops: []
1787
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
1788
+ return d(g, "next", {
1789
+ value: verb(0)
1790
+ }), d(g, "throw", {
1791
+ value: verb(1)
1792
+ }), d(g, "return", {
1793
+ value: verb(2)
1794
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
1795
+ value: function() {
1796
+ return this;
1797
+ }
1798
+ }), g;
1799
+ function verb(n) {
1800
+ return function(v) {
1801
+ return step([
1802
+ n,
1803
+ v
1804
+ ]);
1805
+ };
1806
+ }
1807
+ function step(op) {
1808
+ if (f) throw new TypeError("Generator is already executing.");
1809
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
1810
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1811
+ if (y = 0, t) op = [
1812
+ op[0] & 2,
1813
+ t.value
1814
+ ];
1815
+ switch(op[0]){
1816
+ case 0:
1817
+ case 1:
1818
+ t = op;
1819
+ break;
1820
+ case 4:
1821
+ _.label++;
1822
+ return {
1823
+ value: op[1],
1824
+ done: false
1825
+ };
1826
+ case 5:
1827
+ _.label++;
1828
+ y = op[1];
1829
+ op = [
1830
+ 0
1831
+ ];
1832
+ continue;
1833
+ case 7:
1834
+ op = _.ops.pop();
1835
+ _.trys.pop();
1836
+ continue;
1837
+ default:
1838
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1839
+ _ = 0;
1840
+ continue;
1841
+ }
1842
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1843
+ _.label = op[1];
1844
+ break;
1845
+ }
1846
+ if (op[0] === 6 && _.label < t[1]) {
1847
+ _.label = t[1];
1848
+ t = op;
1849
+ break;
1850
+ }
1851
+ if (t && _.label < t[2]) {
1852
+ _.label = t[2];
1853
+ _.ops.push(op);
1854
+ break;
1855
+ }
1856
+ if (t[2]) _.ops.pop();
1857
+ _.trys.pop();
1858
+ continue;
1859
+ }
1860
+ op = body.call(thisArg, _);
1861
+ } catch (e) {
1862
+ op = [
1863
+ 6,
1864
+ e
1865
+ ];
1866
+ y = 0;
1867
+ } finally{
1868
+ f = t = 0;
1869
+ }
1870
+ if (op[0] & 5) throw op[1];
1871
+ return {
1872
+ value: op[0] ? op[1] : void 0,
1873
+ done: true
1874
+ };
1875
+ }
1876
+ }
1656
1877
  /**
1657
1878
  * Retrieves all connected calendars and the destination calendar for the authenticated user.
1658
1879
  *
@@ -1664,7 +1885,7 @@ var CALCOM_API_VERSION_HEADER = 'cal-api-version';
1664
1885
  * @example
1665
1886
  * ```ts
1666
1887
  * const response = await getCalendars(context)();
1667
- * response.data.connectedCalendars.forEach(cc => console.log(cc.integration));
1888
+ * response.data.connectedCalendars.forEach(cc => console.log(cc.integration.slug, cc.calendars.length));
1668
1889
  * ```
1669
1890
  */ function getCalendars(context) {
1670
1891
  return function() {
@@ -1675,7 +1896,35 @@ var CALCOM_API_VERSION_HEADER = 'cal-api-version';
1675
1896
  };
1676
1897
  }
1677
1898
  /**
1678
- * Retrieves busy time ranges across the user's connected calendars for a given date range.
1899
+ * Selects the calendars to load busy times from, out of a set of connected calendars.
1900
+ *
1901
+ * Prefers the calendars Cal.com is configured to check for conflicts (`isSelected`), and falls
1902
+ * back to a connection's primary calendar when that connection has nothing selected.
1903
+ *
1904
+ * @param connectedCalendars - The connected calendars to select from.
1905
+ * @returns The calendars to load.
1906
+ */ function calcomCalendarsToLoadFromConnectedCalendars(connectedCalendars) {
1907
+ return connectedCalendars.flatMap(function(connection) {
1908
+ var selectedCalendars = connection.calendars.filter(function(x) {
1909
+ return x.isSelected;
1910
+ });
1911
+ var primaryCalendars = connection.primary ? [
1912
+ connection.primary
1913
+ ] : [];
1914
+ var calendars = selectedCalendars.length > 0 ? selectedCalendars : primaryCalendars;
1915
+ return calendars.map(function(x) {
1916
+ return {
1917
+ credentialId: x.credentialId,
1918
+ externalId: x.externalId
1919
+ };
1920
+ });
1921
+ });
1922
+ }
1923
+ /**
1924
+ * Retrieves busy time ranges across the given calendars for a date range.
1925
+ *
1926
+ * A caller cannot address this endpoint without first knowing its calendars, so this is the
1927
+ * single-request primitive — see {@link getBusyTimesForConnectedCalendars} to resolve them too.
1679
1928
  *
1680
1929
  * @param context - The Cal.com API context providing authentication and fetch capabilities.
1681
1930
  * @returns Retrieves busy time ranges for a date range.
@@ -1686,17 +1935,22 @@ var CALCOM_API_VERSION_HEADER = 'cal-api-version';
1686
1935
  * ```ts
1687
1936
  * const response = await getBusyTimes(context)({
1688
1937
  * dateFrom: '2026-03-17',
1689
- * dateTo: '2026-03-24'
1938
+ * dateTo: '2026-03-24',
1939
+ * timeZone: 'America/Chicago',
1940
+ * calendarsToLoad: [{ credentialId: 1845764, externalId: 'someone@example.com' }]
1690
1941
  * });
1691
1942
  * response.data.forEach(bt => console.log(bt.start, bt.end));
1692
1943
  * ```
1693
1944
  */ function getBusyTimes(context) {
1694
1945
  return function(input) {
1695
- var _input_calendarsToLoad;
1696
1946
  var params = fetch.makeUrlSearchParams({
1947
+ timeZone: input.timeZone,
1948
+ loggedInUsersTz: input.loggedInUsersTz,
1697
1949
  dateFrom: input.dateFrom,
1698
1950
  dateTo: input.dateTo,
1699
- calendarsToLoad: (_input_calendarsToLoad = input.calendarsToLoad) === null || _input_calendarsToLoad === void 0 ? void 0 : _input_calendarsToLoad.join(',')
1951
+ calendarsToLoad: input.calendarsToLoad
1952
+ }, {
1953
+ useBracketNotation: true
1700
1954
  });
1701
1955
  return context.fetchJson("/calendars/busy-times?".concat(params), {
1702
1956
  method: 'GET',
@@ -1704,7 +1958,112 @@ var CALCOM_API_VERSION_HEADER = 'cal-api-version';
1704
1958
  });
1705
1959
  };
1706
1960
  }
1961
+ /**
1962
+ * Retrieves busy time ranges across the user's connected calendars for a date range.
1963
+ *
1964
+ * Convenience over {@link getBusyTimes}: loads the connected calendars first and derives
1965
+ * `calendarsToLoad` via {@link calcomCalendarsToLoadFromConnectedCalendars}, so a caller does not
1966
+ * have to know Cal.com's `isSelected`/primary selection rule. Issues two requests.
1967
+ *
1968
+ * @param context - The Cal.com API context providing authentication and fetch capabilities.
1969
+ * @returns Retrieves busy time ranges across the user's connected calendars.
1970
+ *
1971
+ * @example
1972
+ * ```ts
1973
+ * const response = await getBusyTimesForConnectedCalendars(context)({
1974
+ * dateFrom: '2026-03-17',
1975
+ * dateTo: '2026-03-24',
1976
+ * loggedInUsersTz: 'UTC'
1977
+ * });
1978
+ * ```
1979
+ */ function getBusyTimesForConnectedCalendars(context) {
1980
+ return function(input) {
1981
+ return _async_to_generator$1(function() {
1982
+ var calendarsResponse, calendarsToLoad;
1983
+ return _ts_generator$1(this, function(_state) {
1984
+ switch(_state.label){
1985
+ case 0:
1986
+ return [
1987
+ 4,
1988
+ getCalendars(context)()
1989
+ ];
1990
+ case 1:
1991
+ calendarsResponse = _state.sent();
1992
+ calendarsToLoad = calcomCalendarsToLoadFromConnectedCalendars(calendarsResponse.data.connectedCalendars);
1993
+ return [
1994
+ 2,
1995
+ getBusyTimes(context)(_object_spread_props(_object_spread({}, input), {
1996
+ calendarsToLoad: calendarsToLoad
1997
+ }))
1998
+ ];
1999
+ }
2000
+ });
2001
+ })();
2002
+ };
2003
+ }
1707
2004
 
2005
+ /**
2006
+ * All {@link CalcomWebhookTimeRelativeTrigger} values.
2007
+ */ var ALL_CALCOM_WEBHOOK_TIME_RELATIVE_TRIGGERS = [
2008
+ 'AFTER_HOSTS_CAL_VIDEO_NO_SHOW',
2009
+ 'AFTER_GUESTS_CAL_VIDEO_NO_SHOW'
2010
+ ];
2011
+ /**
2012
+ * All {@link CalcomWebhookVersion} values, oldest first.
2013
+ */ var ALL_CALCOM_WEBHOOK_VERSIONS = [
2014
+ '2021-10-20',
2015
+ '2026-07-27'
2016
+ ];
2017
+ /**
2018
+ * All {@link CalcomWebhookTimeUnit} values, smallest first.
2019
+ */ var ALL_CALCOM_WEBHOOK_TIME_UNITS = [
2020
+ 'MINUTE',
2021
+ 'HOUR',
2022
+ 'DAY'
2023
+ ];
2024
+ /**
2025
+ * Maps each {@link CalcomWebhookTimeUnit} to the equivalent `@dereekb/util` {@link TimeUnit}.
2026
+ */ var CALCOM_WEBHOOK_TIME_UNIT_TIME_UNIT_MAP = {
2027
+ MINUTE: 'min',
2028
+ HOUR: 'h',
2029
+ DAY: 'd'
2030
+ };
2031
+ /**
2032
+ * Converts a Cal.com webhook time offset to a `@dereekb/util` {@link TimeDuration}, so the
2033
+ * duration utilities (`timeDurationToMilliseconds()`, `convertTimeDuration()`, ...) apply to it.
2034
+ *
2035
+ * @param offset - The webhook time offset to convert.
2036
+ * @returns The equivalent TimeDuration.
2037
+ *
2038
+ * @example
2039
+ * ```ts
2040
+ * timeDurationToMilliseconds(calcomWebhookTimeOffsetToTimeDuration({ time: 5, timeUnit: 'MINUTE' })); // 300000
2041
+ * ```
2042
+ *
2043
+ * @__NO_SIDE_EFFECTS__
2044
+ */ function calcomWebhookTimeOffsetToTimeDuration(offset) {
2045
+ return {
2046
+ amount: offset.time,
2047
+ unit: CALCOM_WEBHOOK_TIME_UNIT_TIME_UNIT_MAP[offset.timeUnit]
2048
+ };
2049
+ }
2050
+ /**
2051
+ * Reads a webhook's {@link CalcomWebhookTimeOffset} out of the sibling `time`/`timeUnit` fields.
2052
+ *
2053
+ * Returns undefined unless both halves are present, as the API returns them null on a webhook
2054
+ * with no {@link CalcomWebhookTimeRelativeTrigger} and a magnitude with no unit means nothing.
2055
+ *
2056
+ * @param webhook - The webhook to read the offset from.
2057
+ * @returns The webhook's time offset, or undefined when it has none.
2058
+ *
2059
+ * @__NO_SIDE_EFFECTS__
2060
+ */ function calcomWebhookTimeOffsetFromWebhook(webhook) {
2061
+ var time = webhook.time, timeUnit = webhook.timeUnit;
2062
+ return time != null && timeUnit != null ? {
2063
+ time: time,
2064
+ timeUnit: timeUnit
2065
+ } : undefined;
2066
+ }
1708
2067
  /**
1709
2068
  * Creates a webhook subscription for the authenticated user. Webhooks notify your app
1710
2069
  * when specified events occur (e.g., bookings created, cancelled, rescheduled).
@@ -2428,6 +2787,9 @@ function _ts_generator(thisArg, body) {
2428
2787
  }
2429
2788
 
2430
2789
  exports.ALL_CALCOM_OAUTH_SCOPES = ALL_CALCOM_OAUTH_SCOPES;
2790
+ exports.ALL_CALCOM_WEBHOOK_TIME_RELATIVE_TRIGGERS = ALL_CALCOM_WEBHOOK_TIME_RELATIVE_TRIGGERS;
2791
+ exports.ALL_CALCOM_WEBHOOK_TIME_UNITS = ALL_CALCOM_WEBHOOK_TIME_UNITS;
2792
+ exports.ALL_CALCOM_WEBHOOK_VERSIONS = ALL_CALCOM_WEBHOOK_VERSIONS;
2431
2793
  exports.CALCOM_API_KEY_ACCESS_TOKEN_EXPIRATION = CALCOM_API_KEY_ACCESS_TOKEN_EXPIRATION;
2432
2794
  exports.CALCOM_API_URL = CALCOM_API_URL;
2433
2795
  exports.CALCOM_API_VERSION_BOOKINGS = CALCOM_API_VERSION_BOOKINGS;
@@ -2448,6 +2810,7 @@ exports.CALCOM_RATE_LIMIT_LIMIT_HEADER = CALCOM_RATE_LIMIT_LIMIT_HEADER;
2448
2810
  exports.CALCOM_RATE_LIMIT_REMAINING_HEADER = CALCOM_RATE_LIMIT_REMAINING_HEADER;
2449
2811
  exports.CALCOM_RATE_LIMIT_RESET_HEADER = CALCOM_RATE_LIMIT_RESET_HEADER;
2450
2812
  exports.CALCOM_TOO_MANY_REQUESTS_HTTP_STATUS_CODE = CALCOM_TOO_MANY_REQUESTS_HTTP_STATUS_CODE;
2813
+ exports.CALCOM_WEBHOOK_TIME_UNIT_TIME_UNIT_MAP = CALCOM_WEBHOOK_TIME_UNIT_TIME_UNIT_MAP;
2451
2814
  exports.CalcomOAuthAccessTokenError = CalcomOAuthAccessTokenError;
2452
2815
  exports.CalcomOAuthAuthFailureError = CalcomOAuthAuthFailureError;
2453
2816
  exports.CalcomServerError = CalcomServerError;
@@ -2461,12 +2824,16 @@ exports.calcomAccessTokenFromTokenResponse = calcomAccessTokenFromTokenResponse;
2461
2824
  exports.calcomAccessTokenStringFactory = calcomAccessTokenStringFactory;
2462
2825
  exports.calcomApiVersionHeaders = calcomApiVersionHeaders;
2463
2826
  exports.calcomAuthCredentialFromValues = calcomAuthCredentialFromValues;
2827
+ exports.calcomCalendarsToLoadFromConnectedCalendars = calcomCalendarsToLoadFromConnectedCalendars;
2464
2828
  exports.calcomFactory = calcomFactory;
2465
2829
  exports.calcomOAuthAccessTokenFactory = calcomOAuthAccessTokenFactory;
2466
2830
  exports.calcomOAuthAuthorizeUrlFactory = calcomOAuthAuthorizeUrlFactory;
2467
2831
  exports.calcomOAuthFactory = calcomOAuthFactory;
2468
2832
  exports.calcomRateLimitHeaderDetails = calcomRateLimitHeaderDetails;
2469
2833
  exports.calcomRateLimitedFetchHandler = calcomRateLimitedFetchHandler;
2834
+ exports.calcomServerErrorDataFromApiErrorResponseBody = calcomServerErrorDataFromApiErrorResponseBody;
2835
+ exports.calcomWebhookTimeOffsetFromWebhook = calcomWebhookTimeOffsetFromWebhook;
2836
+ exports.calcomWebhookTimeOffsetToTimeDuration = calcomWebhookTimeOffsetToTimeDuration;
2470
2837
  exports.cancelBooking = cancelBooking;
2471
2838
  exports.createBooking = createBooking;
2472
2839
  exports.createEventType = createEventType;
@@ -2476,7 +2843,9 @@ exports.deleteWebhook = deleteWebhook;
2476
2843
  exports.exchangeAuthorizationCode = exchangeAuthorizationCode;
2477
2844
  exports.getAvailableSlots = getAvailableSlots;
2478
2845
  exports.getBooking = getBooking;
2846
+ exports.getBookings = getBookings;
2479
2847
  exports.getBusyTimes = getBusyTimes;
2848
+ exports.getBusyTimesForConnectedCalendars = getBusyTimesForConnectedCalendars;
2480
2849
  exports.getCalendars = getCalendars;
2481
2850
  exports.getEventTypes = getEventTypes;
2482
2851
  exports.getMe = getMe;