MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / fetchCalendarObjects

Function fetchCalendarObjects

lib/models/dav.js:9854–10004  ·  view source on GitHub ↗
(params)

Source from the content-addressed store, hash-verified

9852 })));
9853};
9854const fetchCalendarObjects = async (params) => {
9855 const { calendar, objectUrls, filters: customFilters, timeRange, headers, expand, urlFilter = (url) => Boolean(url === null || url === void 0 ? void 0 : url.includes('.ics')), useMultiGet = true, headersToExclude, } = params;
9856 if (timeRange) {
9857 // validate timeRange
9858 const ISO_8601 = /^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i;
9859 const ISO_8601_FULL = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;
9860 if ((!ISO_8601.test(timeRange.start) || !ISO_8601.test(timeRange.end)) &&
9861 (!ISO_8601_FULL.test(timeRange.start) || !ISO_8601_FULL.test(timeRange.end))) {
9862 throw new Error('invalid timeRange format, not in ISO8601');
9863 }
9864 }
9865 debug$2(`Fetching calendar objects from ${calendar === null || calendar === void 0 ? void 0 : calendar.url}`);
9866 const requiredFields = ['url'];
9867 if (!calendar || !hasFields(calendar, requiredFields)) {
9868 if (!calendar) {
9869 throw new Error('cannot fetchCalendarObjects for undefined calendar');
9870 }
9871 throw new Error(`calendar must have ${findMissingFieldNames(calendar, requiredFields)} before fetchCalendarObjects`);
9872 }
9873 // default to fetch all
9874 const filters = customFilters !== null && customFilters !== void 0 ? customFilters : [
9875 {
9876 'comp-filter': {
9877 _attributes: {
9878 name: 'VCALENDAR',
9879 },
9880 'comp-filter': {
9881 _attributes: {
9882 name: 'VEVENT',
9883 },
9884 ...(timeRange
9885 ? {
9886 'time-range': {
9887 _attributes: {
9888 start: `${new Date(timeRange.start)
9889 .toISOString()
9890 .slice(0, 19)
9891 .replace(/[-:.]/g, '')}Z`,
9892 end: `${new Date(timeRange.end)
9893 .toISOString()
9894 .slice(0, 19)
9895 .replace(/[-:.]/g, '')}Z`,
9896 },
9897 },
9898 }
9899 : {}),
9900 },
9901 },
9902 },
9903 ];
9904 const calendarObjectUrls = (objectUrls !== null && objectUrls !== void 0 ? objectUrls :
9905 // fetch all objects of the calendar
9906 (await calendarQuery({
9907 url: calendar.url,
9908 props: {
9909 [`${DAVNamespaceShort.DAV}:getetag`]: {
9910 ...(expand && timeRange
9911 ? {

Callers 1

createAccountFunction · 0.85

Calls 5

hasFieldsFunction · 0.85
findMissingFieldNamesFunction · 0.85
calendarQueryFunction · 0.85
excludeHeadersFunction · 0.85
calendarMultiGetFunction · 0.85

Tested by

no test coverage detected