@dereekb/calcom 13.35.0 → 13.37.0

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