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

Function freeBusyQuery

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

Source from the content-addressed store, hash-verified

10086 : [...unchanged, ...created, ...updatedWithObjects];
10087};
10088const freeBusyQuery = async (params) => {
10089 const { url, timeRange, depth, headers, headersToExclude } = params;
10090 if (timeRange) {
10091 // validate timeRange
10092 const ISO_8601 = /^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i;
10093 const ISO_8601_FULL = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/i;
10094 if ((!ISO_8601.test(timeRange.start) || !ISO_8601.test(timeRange.end)) &&
10095 (!ISO_8601_FULL.test(timeRange.start) || !ISO_8601_FULL.test(timeRange.end))) {
10096 throw new Error('invalid timeRange format, not in ISO8601');
10097 }
10098 }
10099 else {
10100 throw new Error('timeRange is required');
10101 }
10102 const result = await collectionQuery({
10103 url,
10104 body: {
10105 'free-busy-query': cleanupFalsy({
10106 _attributes: getDAVAttribute([DAVNamespace.CALDAV]),
10107 [`${DAVNamespaceShort.CALDAV}:time-range`]: {
10108 _attributes: {
10109 start: `${new Date(timeRange.start).toISOString().slice(0, 19).replace(/[-:.]/g, '')}Z`,
10110 end: `${new Date(timeRange.end).toISOString().slice(0, 19).replace(/[-:.]/g, '')}Z`,
10111 },
10112 },
10113 }),
10114 },
10115 defaultNamespace: DAVNamespaceShort.CALDAV,
10116 depth,
10117 headers: excludeHeaders(headers, headersToExclude),
10118 });
10119 return result[0];
10120};
10121
10122var calendar = /*#__PURE__*/Object.freeze({
10123 __proto__: null,

Callers

nothing calls this directly

Calls 4

collectionQueryFunction · 0.85
cleanupFalsyFunction · 0.85
getDAVAttributeFunction · 0.85
excludeHeadersFunction · 0.85

Tested by

no test coverage detected