@dereekb/calcom 13.36.0 → 13.38.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 +120 -0
- package/index.esm.js +116 -1
- package/nestjs/package.json +5 -5
- package/package.json +4 -4
- package/src/lib/calcom/calcom.api.schedule.d.ts +167 -8
package/index.cjs.js
CHANGED
|
@@ -1471,6 +1471,121 @@ var CALCOM_API_VERSION_HEADER = 'cal-api-version';
|
|
|
1471
1471
|
});
|
|
1472
1472
|
};
|
|
1473
1473
|
}
|
|
1474
|
+
/**
|
|
1475
|
+
* Creates a new schedule for the authenticated user.
|
|
1476
|
+
*
|
|
1477
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
1478
|
+
* @returns Creates a new schedule from the given input.
|
|
1479
|
+
*
|
|
1480
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/create-a-schedule
|
|
1481
|
+
*
|
|
1482
|
+
* @example
|
|
1483
|
+
* ```ts
|
|
1484
|
+
* const response = await createSchedule(context)({
|
|
1485
|
+
* name: 'Coaching Hours',
|
|
1486
|
+
* timeZone: 'America/Chicago',
|
|
1487
|
+
* isDefault: false,
|
|
1488
|
+
* availability: [{ days: ['Monday', 'Friday'], startTime: '08:00', endTime: '12:00' }],
|
|
1489
|
+
* overrides: [{ date: '2026-12-24', startTime: '10:00', endTime: '11:00' }]
|
|
1490
|
+
* });
|
|
1491
|
+
* console.log(response.data.id);
|
|
1492
|
+
* ```
|
|
1493
|
+
*/ function createSchedule(context) {
|
|
1494
|
+
return function(input) {
|
|
1495
|
+
return context.fetchJson('/schedules', {
|
|
1496
|
+
method: 'POST',
|
|
1497
|
+
headers: calcomApiVersionHeaders(CALCOM_API_VERSION_SCHEDULES),
|
|
1498
|
+
body: JSON.stringify(input)
|
|
1499
|
+
});
|
|
1500
|
+
};
|
|
1501
|
+
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Retrieves the authenticated user's default schedule.
|
|
1504
|
+
*
|
|
1505
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
1506
|
+
* @returns Retrieves the default schedule.
|
|
1507
|
+
*
|
|
1508
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/get-default-schedule
|
|
1509
|
+
*
|
|
1510
|
+
* @example
|
|
1511
|
+
* ```ts
|
|
1512
|
+
* const response = await getDefaultSchedule(context)();
|
|
1513
|
+
* console.log(response.data?.name, response.data?.timeZone);
|
|
1514
|
+
* ```
|
|
1515
|
+
*/ function getDefaultSchedule(context) {
|
|
1516
|
+
return function() {
|
|
1517
|
+
return context.fetchJson('/schedules/default', {
|
|
1518
|
+
method: 'GET',
|
|
1519
|
+
headers: calcomApiVersionHeaders(CALCOM_API_VERSION_SCHEDULES)
|
|
1520
|
+
});
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* Retrieves a single schedule by ID.
|
|
1525
|
+
*
|
|
1526
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
1527
|
+
* @returns Retrieves a schedule by ID.
|
|
1528
|
+
*
|
|
1529
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/get-a-schedule
|
|
1530
|
+
*
|
|
1531
|
+
* @example
|
|
1532
|
+
* ```ts
|
|
1533
|
+
* const response = await getSchedule(context)(588440);
|
|
1534
|
+
* console.log(response.data.availability, response.data.overrides);
|
|
1535
|
+
* ```
|
|
1536
|
+
*/ function getSchedule(context) {
|
|
1537
|
+
return function(scheduleId) {
|
|
1538
|
+
return context.fetchJson("/schedules/".concat(scheduleId), {
|
|
1539
|
+
method: 'GET',
|
|
1540
|
+
headers: calcomApiVersionHeaders(CALCOM_API_VERSION_SCHEDULES)
|
|
1541
|
+
});
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Updates an existing schedule by ID.
|
|
1546
|
+
*
|
|
1547
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
1548
|
+
* @returns Updates a schedule by ID.
|
|
1549
|
+
*
|
|
1550
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/update-a-schedule
|
|
1551
|
+
*
|
|
1552
|
+
* @example
|
|
1553
|
+
* ```ts
|
|
1554
|
+
* // replaces the weekly rules and marks the whole of Christmas Day unavailable
|
|
1555
|
+
* await updateSchedule(context)(588440, {
|
|
1556
|
+
* availability: [{ days: ['Monday'], startTime: '09:00', endTime: '17:00' }],
|
|
1557
|
+
* overrides: [{ date: '2026-12-25', startTime: '00:00', endTime: '00:00' }]
|
|
1558
|
+
* });
|
|
1559
|
+
* ```
|
|
1560
|
+
*/ function updateSchedule(context) {
|
|
1561
|
+
return function(scheduleId, input) {
|
|
1562
|
+
return context.fetchJson("/schedules/".concat(scheduleId), {
|
|
1563
|
+
method: 'PATCH',
|
|
1564
|
+
headers: calcomApiVersionHeaders(CALCOM_API_VERSION_SCHEDULES),
|
|
1565
|
+
body: JSON.stringify(input)
|
|
1566
|
+
});
|
|
1567
|
+
};
|
|
1568
|
+
}
|
|
1569
|
+
/**
|
|
1570
|
+
* Deletes a schedule by ID.
|
|
1571
|
+
*
|
|
1572
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
1573
|
+
* @returns Deletes a schedule by ID.
|
|
1574
|
+
*
|
|
1575
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/delete-a-schedule
|
|
1576
|
+
*
|
|
1577
|
+
* @example
|
|
1578
|
+
* ```ts
|
|
1579
|
+
* await deleteSchedule(context)(588440);
|
|
1580
|
+
* ```
|
|
1581
|
+
*/ function deleteSchedule(context) {
|
|
1582
|
+
return function(scheduleId) {
|
|
1583
|
+
return context.fetchJson("/schedules/".concat(scheduleId), {
|
|
1584
|
+
method: 'DELETE',
|
|
1585
|
+
headers: calcomApiVersionHeaders(CALCOM_API_VERSION_SCHEDULES)
|
|
1586
|
+
});
|
|
1587
|
+
};
|
|
1588
|
+
}
|
|
1474
1589
|
|
|
1475
1590
|
/**
|
|
1476
1591
|
* Queries available booking slots for a given event type within a date range.
|
|
@@ -2837,8 +2952,10 @@ exports.calcomWebhookTimeOffsetToTimeDuration = calcomWebhookTimeOffsetToTimeDur
|
|
|
2837
2952
|
exports.cancelBooking = cancelBooking;
|
|
2838
2953
|
exports.createBooking = createBooking;
|
|
2839
2954
|
exports.createEventType = createEventType;
|
|
2955
|
+
exports.createSchedule = createSchedule;
|
|
2840
2956
|
exports.createWebhook = createWebhook;
|
|
2841
2957
|
exports.deleteEventType = deleteEventType;
|
|
2958
|
+
exports.deleteSchedule = deleteSchedule;
|
|
2842
2959
|
exports.deleteWebhook = deleteWebhook;
|
|
2843
2960
|
exports.exchangeAuthorizationCode = exchangeAuthorizationCode;
|
|
2844
2961
|
exports.getAvailableSlots = getAvailableSlots;
|
|
@@ -2847,8 +2964,10 @@ exports.getBookings = getBookings;
|
|
|
2847
2964
|
exports.getBusyTimes = getBusyTimes;
|
|
2848
2965
|
exports.getBusyTimesForConnectedCalendars = getBusyTimesForConnectedCalendars;
|
|
2849
2966
|
exports.getCalendars = getCalendars;
|
|
2967
|
+
exports.getDefaultSchedule = getDefaultSchedule;
|
|
2850
2968
|
exports.getEventTypes = getEventTypes;
|
|
2851
2969
|
exports.getMe = getMe;
|
|
2970
|
+
exports.getSchedule = getSchedule;
|
|
2852
2971
|
exports.getSchedules = getSchedules;
|
|
2853
2972
|
exports.getWebhook = getWebhook;
|
|
2854
2973
|
exports.getWebhooks = getWebhooks;
|
|
@@ -2867,4 +2986,5 @@ exports.parseCalcomOAuthServerErrorResponseData = parseCalcomOAuthServerErrorRes
|
|
|
2867
2986
|
exports.parseCalcomServerErrorData = parseCalcomServerErrorData;
|
|
2868
2987
|
exports.refreshAccessToken = refreshAccessToken;
|
|
2869
2988
|
exports.updateEventType = updateEventType;
|
|
2989
|
+
exports.updateSchedule = updateSchedule;
|
|
2870
2990
|
exports.updateWebhook = updateWebhook;
|
package/index.esm.js
CHANGED
|
@@ -1469,6 +1469,121 @@ var CALCOM_API_VERSION_HEADER = 'cal-api-version';
|
|
|
1469
1469
|
});
|
|
1470
1470
|
};
|
|
1471
1471
|
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Creates a new schedule for the authenticated user.
|
|
1474
|
+
*
|
|
1475
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
1476
|
+
* @returns Creates a new schedule from the given input.
|
|
1477
|
+
*
|
|
1478
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/create-a-schedule
|
|
1479
|
+
*
|
|
1480
|
+
* @example
|
|
1481
|
+
* ```ts
|
|
1482
|
+
* const response = await createSchedule(context)({
|
|
1483
|
+
* name: 'Coaching Hours',
|
|
1484
|
+
* timeZone: 'America/Chicago',
|
|
1485
|
+
* isDefault: false,
|
|
1486
|
+
* availability: [{ days: ['Monday', 'Friday'], startTime: '08:00', endTime: '12:00' }],
|
|
1487
|
+
* overrides: [{ date: '2026-12-24', startTime: '10:00', endTime: '11:00' }]
|
|
1488
|
+
* });
|
|
1489
|
+
* console.log(response.data.id);
|
|
1490
|
+
* ```
|
|
1491
|
+
*/ function createSchedule(context) {
|
|
1492
|
+
return function(input) {
|
|
1493
|
+
return context.fetchJson('/schedules', {
|
|
1494
|
+
method: 'POST',
|
|
1495
|
+
headers: calcomApiVersionHeaders(CALCOM_API_VERSION_SCHEDULES),
|
|
1496
|
+
body: JSON.stringify(input)
|
|
1497
|
+
});
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Retrieves the authenticated user's default schedule.
|
|
1502
|
+
*
|
|
1503
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
1504
|
+
* @returns Retrieves the default schedule.
|
|
1505
|
+
*
|
|
1506
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/get-default-schedule
|
|
1507
|
+
*
|
|
1508
|
+
* @example
|
|
1509
|
+
* ```ts
|
|
1510
|
+
* const response = await getDefaultSchedule(context)();
|
|
1511
|
+
* console.log(response.data?.name, response.data?.timeZone);
|
|
1512
|
+
* ```
|
|
1513
|
+
*/ function getDefaultSchedule(context) {
|
|
1514
|
+
return function() {
|
|
1515
|
+
return context.fetchJson('/schedules/default', {
|
|
1516
|
+
method: 'GET',
|
|
1517
|
+
headers: calcomApiVersionHeaders(CALCOM_API_VERSION_SCHEDULES)
|
|
1518
|
+
});
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
/**
|
|
1522
|
+
* Retrieves a single schedule by ID.
|
|
1523
|
+
*
|
|
1524
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
1525
|
+
* @returns Retrieves a schedule by ID.
|
|
1526
|
+
*
|
|
1527
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/get-a-schedule
|
|
1528
|
+
*
|
|
1529
|
+
* @example
|
|
1530
|
+
* ```ts
|
|
1531
|
+
* const response = await getSchedule(context)(588440);
|
|
1532
|
+
* console.log(response.data.availability, response.data.overrides);
|
|
1533
|
+
* ```
|
|
1534
|
+
*/ function getSchedule(context) {
|
|
1535
|
+
return function(scheduleId) {
|
|
1536
|
+
return context.fetchJson("/schedules/".concat(scheduleId), {
|
|
1537
|
+
method: 'GET',
|
|
1538
|
+
headers: calcomApiVersionHeaders(CALCOM_API_VERSION_SCHEDULES)
|
|
1539
|
+
});
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Updates an existing schedule by ID.
|
|
1544
|
+
*
|
|
1545
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
1546
|
+
* @returns Updates a schedule by ID.
|
|
1547
|
+
*
|
|
1548
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/update-a-schedule
|
|
1549
|
+
*
|
|
1550
|
+
* @example
|
|
1551
|
+
* ```ts
|
|
1552
|
+
* // replaces the weekly rules and marks the whole of Christmas Day unavailable
|
|
1553
|
+
* await updateSchedule(context)(588440, {
|
|
1554
|
+
* availability: [{ days: ['Monday'], startTime: '09:00', endTime: '17:00' }],
|
|
1555
|
+
* overrides: [{ date: '2026-12-25', startTime: '00:00', endTime: '00:00' }]
|
|
1556
|
+
* });
|
|
1557
|
+
* ```
|
|
1558
|
+
*/ function updateSchedule(context) {
|
|
1559
|
+
return function(scheduleId, input) {
|
|
1560
|
+
return context.fetchJson("/schedules/".concat(scheduleId), {
|
|
1561
|
+
method: 'PATCH',
|
|
1562
|
+
headers: calcomApiVersionHeaders(CALCOM_API_VERSION_SCHEDULES),
|
|
1563
|
+
body: JSON.stringify(input)
|
|
1564
|
+
});
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Deletes a schedule by ID.
|
|
1569
|
+
*
|
|
1570
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
1571
|
+
* @returns Deletes a schedule by ID.
|
|
1572
|
+
*
|
|
1573
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/delete-a-schedule
|
|
1574
|
+
*
|
|
1575
|
+
* @example
|
|
1576
|
+
* ```ts
|
|
1577
|
+
* await deleteSchedule(context)(588440);
|
|
1578
|
+
* ```
|
|
1579
|
+
*/ function deleteSchedule(context) {
|
|
1580
|
+
return function(scheduleId) {
|
|
1581
|
+
return context.fetchJson("/schedules/".concat(scheduleId), {
|
|
1582
|
+
method: 'DELETE',
|
|
1583
|
+
headers: calcomApiVersionHeaders(CALCOM_API_VERSION_SCHEDULES)
|
|
1584
|
+
});
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1472
1587
|
|
|
1473
1588
|
/**
|
|
1474
1589
|
* Queries available booking slots for a given event type within a date range.
|
|
@@ -2784,4 +2899,4 @@ function _ts_generator(thisArg, body) {
|
|
|
2784
2899
|
};
|
|
2785
2900
|
}
|
|
2786
2901
|
|
|
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 };
|
|
2902
|
+
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, createSchedule, createWebhook, deleteEventType, deleteSchedule, deleteWebhook, exchangeAuthorizationCode, getAvailableSlots, getBooking, getBookings, getBusyTimes, getBusyTimesForConnectedCalendars, getCalendars, getDefaultSchedule, getEventTypes, getMe, getSchedule, getSchedules, getWebhook, getWebhooks, handleCalcomErrorFetch, handleCalcomErrorFetchFactory, handleCalcomOAuthErrorFetch, isCalcomApiKeyCredential, isCalcomOAuthScope, logCalcomErrorToConsole, logCalcomOAuthErrorToConsole, logCalcomServerErrorFunction, parseCalcomApiError, parseCalcomApiServerErrorResponseData, parseCalcomOAuthError, parseCalcomOAuthServerErrorResponseData, parseCalcomServerErrorData, refreshAccessToken, updateEventType, updateSchedule, updateWebhook };
|
package/nestjs/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/calcom/nestjs",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.38.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/nestjs": "13.
|
|
6
|
-
"@dereekb/rxjs": "13.
|
|
7
|
-
"@dereekb/util": "13.
|
|
8
|
-
"@dereekb/calcom": "13.
|
|
5
|
+
"@dereekb/nestjs": "13.38.0",
|
|
6
|
+
"@dereekb/rxjs": "13.38.0",
|
|
7
|
+
"@dereekb/util": "13.38.0",
|
|
8
|
+
"@dereekb/calcom": "13.38.0",
|
|
9
9
|
"@nestjs/common": "^11.1.19",
|
|
10
10
|
"@nestjs/config": "^4.0.4",
|
|
11
11
|
"express": "^5.2.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/calcom",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.38.0",
|
|
4
4
|
"exports": {
|
|
5
5
|
"./nestjs": {
|
|
6
6
|
"module": "./nestjs/index.esm.js",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@dereekb/nestjs": "13.
|
|
21
|
-
"@dereekb/rxjs": "13.
|
|
22
|
-
"@dereekb/util": "13.
|
|
20
|
+
"@dereekb/nestjs": "13.38.0",
|
|
21
|
+
"@dereekb/rxjs": "13.38.0",
|
|
22
|
+
"@dereekb/util": "13.38.0",
|
|
23
23
|
"@nestjs/common": "^11.1.19",
|
|
24
24
|
"@nestjs/config": "^4.0.4",
|
|
25
25
|
"express": "^5.2.1",
|
|
@@ -1,22 +1,38 @@
|
|
|
1
|
-
import { type ISO8601DayString, type TimezoneString } from '@dereekb/util';
|
|
1
|
+
import { type ISO8601DayString, type Maybe, type TimezoneString } from '@dereekb/util';
|
|
2
2
|
import { type CalcomContext } from './calcom.config';
|
|
3
3
|
import { type CalcomScheduleId, type CalcomResponseStatus, type CalcomUserId } from '../calcom.type';
|
|
4
|
+
/**
|
|
5
|
+
* A time of day within a schedule, as the `HH:MM` (24-hour, zero-padded) string Cal.com uses.
|
|
6
|
+
*
|
|
7
|
+
* The format is enforced server-side: a value that does not match is rejected with a 400 whose
|
|
8
|
+
* detail reads "startTime must be a valid time format HH:MM". Seconds are not accepted.
|
|
9
|
+
*/
|
|
10
|
+
export type CalcomTimeOfDayString = string;
|
|
4
11
|
export interface CalcomAvailabilityRule {
|
|
5
12
|
readonly days: string[];
|
|
6
|
-
readonly startTime:
|
|
7
|
-
readonly endTime:
|
|
13
|
+
readonly startTime: CalcomTimeOfDayString;
|
|
14
|
+
readonly endTime: CalcomTimeOfDayString;
|
|
8
15
|
}
|
|
9
16
|
/**
|
|
10
17
|
* A date-specific exception to a schedule's weekly availability.
|
|
11
18
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
19
|
+
* An override REPLACES the weekly rules for its date rather than adding to them — verified live by
|
|
20
|
+
* overriding a Monday whose weekly rule was 08:00-12:00 with 13:00-14:00 and observing `/slots`
|
|
21
|
+
* return only the 13:00-14:00 slots for that day.
|
|
22
|
+
*
|
|
23
|
+
* A full-day "unavailable" IS expressible here: `startTime` and `endTime` are both REQUIRED (see
|
|
24
|
+
* {@link CalcomTimeOfDayString} — omitting either is a 400), but a ZERO-LENGTH range of
|
|
25
|
+
* `00:00`-`00:00` is accepted, round-trips verbatim, and removes the day from availability
|
|
26
|
+
* entirely. Verified live by putting a zero-length override on one Monday while leaving a second
|
|
27
|
+
* Monday untouched, then reading a single `/slots` window covering both: the overridden day came
|
|
28
|
+
* back with no slots at all (absent from the day map) while the control Monday kept its 8. So a
|
|
29
|
+
* caller representing a day off as an empty range list maps it to `00:00`-`00:00` here, and does
|
|
30
|
+
* NOT need the separate `/v2/ooo` (out-of-office) endpoints for it.
|
|
15
31
|
*/
|
|
16
32
|
export interface CalcomScheduleOverride {
|
|
17
33
|
readonly date: ISO8601DayString;
|
|
18
|
-
readonly startTime:
|
|
19
|
-
readonly endTime:
|
|
34
|
+
readonly startTime: CalcomTimeOfDayString;
|
|
35
|
+
readonly endTime: CalcomTimeOfDayString;
|
|
20
36
|
}
|
|
21
37
|
export interface CalcomSchedule {
|
|
22
38
|
readonly id: CalcomScheduleId;
|
|
@@ -34,6 +50,66 @@ export interface CalcomGetSchedulesResponse {
|
|
|
34
50
|
readonly status: CalcomResponseStatus;
|
|
35
51
|
readonly data: CalcomSchedule[];
|
|
36
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* A response carrying a single schedule.
|
|
55
|
+
*
|
|
56
|
+
* Returned by create/read/update — each echoes the full schedule back, including the availability
|
|
57
|
+
* rules and overrides as they were persisted.
|
|
58
|
+
*/
|
|
59
|
+
export interface CalcomScheduleResponse {
|
|
60
|
+
readonly status: CalcomResponseStatus;
|
|
61
|
+
readonly data: CalcomSchedule;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The response to a default-schedule lookup.
|
|
65
|
+
*
|
|
66
|
+
* Distinct from {@link CalcomScheduleResponse} because `data` is optional: an account with a
|
|
67
|
+
* default schedule was observed returning the full schedule object, but an account that has
|
|
68
|
+
* deleted every schedule was deliberately not exercised (doing so would have meant destroying the
|
|
69
|
+
* verifying account's only schedule), so the absent case is typed rather than assumed away.
|
|
70
|
+
*/
|
|
71
|
+
export interface CalcomDefaultScheduleResponse {
|
|
72
|
+
readonly status: CalcomResponseStatus;
|
|
73
|
+
readonly data: Maybe<CalcomSchedule>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The response to a schedule deletion.
|
|
77
|
+
*
|
|
78
|
+
* Carries NO `data` — unlike the event-type and webhook deletes, which echo the deleted record,
|
|
79
|
+
* this endpoint returns a bare `{ "status": "success" }`.
|
|
80
|
+
*/
|
|
81
|
+
export interface CalcomDeleteScheduleResponse {
|
|
82
|
+
readonly status: CalcomResponseStatus;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The schedule fields accepted by both create and update.
|
|
86
|
+
*/
|
|
87
|
+
export interface CalcomScheduleInputSettings {
|
|
88
|
+
/**
|
|
89
|
+
* The weekly availability rules. Omitting this on create yields a schedule with no availability.
|
|
90
|
+
*/
|
|
91
|
+
readonly availability?: Maybe<CalcomAvailabilityRule[]>;
|
|
92
|
+
/**
|
|
93
|
+
* The date-specific exceptions. See {@link CalcomScheduleOverride} for expressing a full day off.
|
|
94
|
+
*/
|
|
95
|
+
readonly overrides?: Maybe<CalcomScheduleOverride[]>;
|
|
96
|
+
}
|
|
97
|
+
export interface CalcomCreateScheduleInput extends CalcomScheduleInputSettings {
|
|
98
|
+
readonly name: string;
|
|
99
|
+
readonly timeZone: TimezoneString;
|
|
100
|
+
readonly isDefault: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* A PARTIAL update — every field is optional and only the provided ones are changed.
|
|
104
|
+
*
|
|
105
|
+
* Note that `availability` and `overrides` are REPLACED wholesale when provided, not merged, so
|
|
106
|
+
* passing `overrides: []` clears every existing override.
|
|
107
|
+
*/
|
|
108
|
+
export interface CalcomUpdateScheduleInput extends CalcomScheduleInputSettings {
|
|
109
|
+
readonly name?: Maybe<string>;
|
|
110
|
+
readonly timeZone?: Maybe<TimezoneString>;
|
|
111
|
+
readonly isDefault?: Maybe<boolean>;
|
|
112
|
+
}
|
|
37
113
|
/**
|
|
38
114
|
* Retrieves all schedules for the authenticated user, including availability rules and overrides.
|
|
39
115
|
*
|
|
@@ -49,3 +125,86 @@ export interface CalcomGetSchedulesResponse {
|
|
|
49
125
|
* ```
|
|
50
126
|
*/
|
|
51
127
|
export declare function getSchedules(context: CalcomContext): () => Promise<CalcomGetSchedulesResponse>;
|
|
128
|
+
/**
|
|
129
|
+
* Creates a new schedule for the authenticated user.
|
|
130
|
+
*
|
|
131
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
132
|
+
* @returns Creates a new schedule from the given input.
|
|
133
|
+
*
|
|
134
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/create-a-schedule
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* const response = await createSchedule(context)({
|
|
139
|
+
* name: 'Coaching Hours',
|
|
140
|
+
* timeZone: 'America/Chicago',
|
|
141
|
+
* isDefault: false,
|
|
142
|
+
* availability: [{ days: ['Monday', 'Friday'], startTime: '08:00', endTime: '12:00' }],
|
|
143
|
+
* overrides: [{ date: '2026-12-24', startTime: '10:00', endTime: '11:00' }]
|
|
144
|
+
* });
|
|
145
|
+
* console.log(response.data.id);
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export declare function createSchedule(context: CalcomContext): (input: CalcomCreateScheduleInput) => Promise<CalcomScheduleResponse>;
|
|
149
|
+
/**
|
|
150
|
+
* Retrieves the authenticated user's default schedule.
|
|
151
|
+
*
|
|
152
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
153
|
+
* @returns Retrieves the default schedule.
|
|
154
|
+
*
|
|
155
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/get-default-schedule
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* const response = await getDefaultSchedule(context)();
|
|
160
|
+
* console.log(response.data?.name, response.data?.timeZone);
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export declare function getDefaultSchedule(context: CalcomContext): () => Promise<CalcomDefaultScheduleResponse>;
|
|
164
|
+
/**
|
|
165
|
+
* Retrieves a single schedule by ID.
|
|
166
|
+
*
|
|
167
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
168
|
+
* @returns Retrieves a schedule by ID.
|
|
169
|
+
*
|
|
170
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/get-a-schedule
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* const response = await getSchedule(context)(588440);
|
|
175
|
+
* console.log(response.data.availability, response.data.overrides);
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
export declare function getSchedule(context: CalcomContext): (scheduleId: CalcomScheduleId) => Promise<CalcomScheduleResponse>;
|
|
179
|
+
/**
|
|
180
|
+
* Updates an existing schedule by ID.
|
|
181
|
+
*
|
|
182
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
183
|
+
* @returns Updates a schedule by ID.
|
|
184
|
+
*
|
|
185
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/update-a-schedule
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* // replaces the weekly rules and marks the whole of Christmas Day unavailable
|
|
190
|
+
* await updateSchedule(context)(588440, {
|
|
191
|
+
* availability: [{ days: ['Monday'], startTime: '09:00', endTime: '17:00' }],
|
|
192
|
+
* overrides: [{ date: '2026-12-25', startTime: '00:00', endTime: '00:00' }]
|
|
193
|
+
* });
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
export declare function updateSchedule(context: CalcomContext): (scheduleId: CalcomScheduleId, input: CalcomUpdateScheduleInput) => Promise<CalcomScheduleResponse>;
|
|
197
|
+
/**
|
|
198
|
+
* Deletes a schedule by ID.
|
|
199
|
+
*
|
|
200
|
+
* @param context - The Cal.com API context providing authentication and fetch capabilities.
|
|
201
|
+
* @returns Deletes a schedule by ID.
|
|
202
|
+
*
|
|
203
|
+
* @see https://cal.com/docs/api-reference/v2/schedules/delete-a-schedule
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts
|
|
207
|
+
* await deleteSchedule(context)(588440);
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
export declare function deleteSchedule(context: CalcomContext): (scheduleId: CalcomScheduleId) => Promise<CalcomDeleteScheduleResponse>;
|