caldav-adapter 8.2.11 → 8.3.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/common/tags.js CHANGED
@@ -90,18 +90,18 @@ module.exports = function (options) {
90
90
  },
91
91
  getcontenttype: {
92
92
  doc: 'https://tools.ietf.org/html/rfc2518#section-13.5',
93
- async resp({ resource }) {
93
+ async resp({ resource, event }) {
94
94
  if (resource === 'calendar') {
95
95
  return {
96
- [buildTag(dav, 'getcontenttype')]:
97
- 'text/calendar; charset=utf-8; component=VEVENT'
96
+ [buildTag(dav, 'getcontenttype')]: 'text/calendar; charset=utf-8'
98
97
  };
99
98
  }
100
99
 
101
100
  if (resource === 'event') {
101
+ const componentType = event?.componentType || 'VEVENT';
102
102
  return {
103
103
  [buildTag(dav, 'getcontenttype')]:
104
- 'text/calendar; charset=utf-8; component=VEVENT'
104
+ `text/calendar; charset=utf-8; component=${componentType}`
105
105
  };
106
106
  }
107
107
  }
@@ -360,9 +360,10 @@ module.exports = function (options) {
360
360
  if (resource === 'calendar') {
361
361
  return {
362
362
  [buildTag(cal, 'supported-calendar-component-set')]: {
363
- [buildTag(cal, 'comp')]: {
364
- '@name': 'VEVENT'
365
- }
363
+ [buildTag(cal, 'comp')]: [
364
+ { '@name': 'VEVENT' },
365
+ { '@name': 'VTODO' }
366
+ ]
366
367
  }
367
368
  };
368
369
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "caldav-adapter",
3
3
  "description": "CalDAV server for Node.js and Koa. Modernized and maintained for Forward Email.",
4
- "version": "8.2.11",
4
+ "version": "8.3.0",
5
5
  "author": "Sanders DeNardi and Forward Email LLC",
6
6
  "contributors": [
7
7
  "Sanders DeNardi <sedenardi@gmail.com> (http://www.sandersdenardi.com/)",
@@ -8,10 +8,21 @@ module.exports = function (options) {
8
8
  const eventResponse = calEventResponse(options);
9
9
  return async function (ctx, calendar) {
10
10
  /* https://tools.ietf.org/html/rfc4791#section-9.9 */
11
- const filters = xml.get(
11
+ const veventFilters = xml.get(
12
12
  "/CAL:calendar-query/CAL:filter/CAL:comp-filter[@name='VCALENDAR']/CAL:comp-filter[@name='VEVENT']/CAL:time-range",
13
13
  ctx.request.xml
14
14
  );
15
+ const vtodoFilters = xml.get(
16
+ "/CAL:calendar-query/CAL:filter/CAL:comp-filter[@name='VCALENDAR']/CAL:comp-filter[@name='VTODO']/CAL:time-range",
17
+ ctx.request.xml
18
+ );
19
+
20
+ const filters = veventFilters || vtodoFilters;
21
+ const componentType = veventFilters
22
+ ? 'VEVENT'
23
+ : vtodoFilters
24
+ ? 'VTODO'
25
+ : null;
15
26
  const { children } = xml.getWithChildren(
16
27
  '/CAL:calendar-query/D:prop',
17
28
  ctx.request.xml
@@ -25,7 +36,8 @@ module.exports = function (options) {
25
36
  principalId: ctx.state.params.principalId,
26
37
  calendarId: options.data.getCalendarId(ctx, calendar),
27
38
  user: ctx.state.user,
28
- fullData
39
+ fullData,
40
+ componentType
29
41
  });
30
42
 
31
43
  return eventResponse(ctx, events, calendar, children);
@@ -73,7 +85,8 @@ module.exports = function (options) {
73
85
  start,
74
86
  end,
75
87
  user: ctx.state.user,
76
- fullData
88
+ fullData,
89
+ componentType
77
90
  });
78
91
  return eventResponse(ctx, events, calendar, children);
79
92
  };
package/test/test.js CHANGED
@@ -6,3 +6,36 @@ const caldavAdapter = require('..');
6
6
  test('exports a function', (t) => {
7
7
  t.true(typeof caldavAdapter === 'function');
8
8
  });
9
+
10
+ test('VTODO supported component set includes VTODO', (t) => {
11
+ const options = {
12
+ data: {
13
+ getCalendarId: () => 'test',
14
+ buildICS: () => 'test',
15
+ getETag: () => 'test'
16
+ }
17
+ };
18
+
19
+ const { tags } = require('../common/tags')(options);
20
+ const supportedComponentSetTag =
21
+ tags['urn:ietf:params:xml:ns:caldav']['supported-calendar-component-set'];
22
+
23
+ t.is(typeof supportedComponentSetTag, 'object');
24
+ t.is(typeof supportedComponentSetTag.resp, 'function');
25
+ });
26
+
27
+ test('VTODO content type is dynamic based on component', (t) => {
28
+ const options = {
29
+ data: {
30
+ getCalendarId: () => 'test',
31
+ buildICS: () => 'test',
32
+ getETag: () => 'test'
33
+ }
34
+ };
35
+
36
+ const { tags } = require('../common/tags')(options);
37
+ const contentTypeTag = tags['DAV:'].getcontenttype;
38
+
39
+ t.is(typeof contentTypeTag, 'object');
40
+ t.is(typeof contentTypeTag.resp, 'function');
41
+ });