caldav-adapter 4.2.0 → 4.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/lib/common/date.js +3 -2
- package/lib/common/eventBuild.js +30 -28
- package/lib/common/parseBody.js +1 -1
- package/lib/common/response.js +16 -4
- package/lib/common/tags.js +57 -57
- package/lib/common/winston.js +1 -1
- package/lib/common/xBuild.d.ts +1 -1
- package/lib/common/xBuild.js +32 -24
- package/lib/common/xml.js +5 -3
- package/lib/index.d.ts +19 -19
- package/lib/koa.js +8 -8
- package/lib/routes/calendar/calendar/calendar-multiget.js +11 -7
- package/lib/routes/calendar/calendar/calendar-query.js +9 -5
- package/lib/routes/calendar/calendar/delete.js +3 -3
- package/lib/routes/calendar/calendar/eventResponse.js +3 -3
- package/lib/routes/calendar/calendar/expand-property.js +2 -2
- package/lib/routes/calendar/calendar/get.js +3 -3
- package/lib/routes/calendar/calendar/propfind.js +11 -7
- package/lib/routes/calendar/calendar/proppatch.js +9 -5
- package/lib/routes/calendar/calendar/put.js +8 -8
- package/lib/routes/calendar/calendar/report.js +8 -8
- package/lib/routes/calendar/calendar/sync-collection.js +7 -3
- package/lib/routes/calendar/calendar.js +14 -13
- package/lib/routes/calendar/user/propfind.js +11 -7
- package/lib/routes/calendar/user/proppatch.js +9 -5
- package/lib/routes/principal/principal.js +6 -5
- package/lib/routes/principal/propfind.js +10 -6
- package/lib/routes/principal/report.js +5 -5
- package/package.json +23 -23
package/lib/common/xml.js
CHANGED
|
@@ -18,11 +18,13 @@ exports.nsLookup = {
|
|
|
18
18
|
'http://apple.com/ns/ical/': 'ICAL'
|
|
19
19
|
};
|
|
20
20
|
const select = xpath_1.default.useNamespaces(exports.namespaces);
|
|
21
|
-
|
|
21
|
+
const get = function (path, doc) {
|
|
22
22
|
return select(path, doc);
|
|
23
23
|
};
|
|
24
|
-
exports.
|
|
25
|
-
|
|
24
|
+
exports.get = get;
|
|
25
|
+
const getWithChildren = function (path, doc) {
|
|
26
|
+
const propNode = (0, exports.get)(path, doc);
|
|
26
27
|
const children = propNode[0] ? Array.from(propNode[0].childNodes) : [];
|
|
27
28
|
return { propNode, children };
|
|
28
29
|
};
|
|
30
|
+
exports.getWithChildren = getWithChildren;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AlarmData } from 'ical-generator';
|
|
2
|
-
export
|
|
2
|
+
export type CalDavAuthPrincipal = {
|
|
3
3
|
principalId: string;
|
|
4
4
|
principalName: string;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type CalDavCalendar = {
|
|
7
7
|
calendarId: string;
|
|
8
8
|
ownerId?: string;
|
|
9
9
|
calendarName: string;
|
|
@@ -14,7 +14,7 @@ export declare type CalDavCalendar = {
|
|
|
14
14
|
syncToken: string;
|
|
15
15
|
createdOn?: string;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type CalDavRecurrence = {
|
|
18
18
|
recurrenceId: string;
|
|
19
19
|
summary?: string;
|
|
20
20
|
location?: string;
|
|
@@ -29,13 +29,13 @@ export declare type CalDavRecurrence = {
|
|
|
29
29
|
createdOn?: string;
|
|
30
30
|
lastModifiedOn?: string;
|
|
31
31
|
};
|
|
32
|
-
export
|
|
32
|
+
export type CalDavRecurring = {
|
|
33
33
|
freq: 'SECONDLY' | 'MINUTELY' | 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY' | 'HOURLY';
|
|
34
34
|
until?: string;
|
|
35
35
|
exdate?: string[];
|
|
36
36
|
recurrences?: CalDavRecurrence[];
|
|
37
37
|
};
|
|
38
|
-
export
|
|
38
|
+
export type CalDavEvent = {
|
|
39
39
|
eventId: string;
|
|
40
40
|
calendarId?: string;
|
|
41
41
|
summary: string;
|
|
@@ -54,27 +54,27 @@ export declare type CalDavEvent = {
|
|
|
54
54
|
ical?: string;
|
|
55
55
|
recurring?: CalDavRecurring;
|
|
56
56
|
};
|
|
57
|
-
export
|
|
57
|
+
export type CalDavAuthenticate = (opts: {
|
|
58
58
|
username: string;
|
|
59
59
|
password: string;
|
|
60
60
|
principalId: string;
|
|
61
61
|
}) => Promise<CalDavAuthPrincipal>;
|
|
62
|
-
export
|
|
62
|
+
export type CalDavGetCalendar = (opts: {
|
|
63
63
|
calendarId: string;
|
|
64
64
|
principalId: string;
|
|
65
65
|
user: any;
|
|
66
66
|
}) => Promise<CalDavCalendar>;
|
|
67
|
-
export
|
|
67
|
+
export type CalDavGetCalendarsForPrincipal = (opts: {
|
|
68
68
|
principalId: string;
|
|
69
69
|
user: any;
|
|
70
70
|
}) => Promise<CalDavCalendar[]>;
|
|
71
|
-
export
|
|
71
|
+
export type CalDavGetEventsForCalendar = (opts: {
|
|
72
72
|
calendarId: string;
|
|
73
73
|
principalId: string;
|
|
74
74
|
fullData: boolean;
|
|
75
75
|
user: any;
|
|
76
76
|
}) => Promise<CalDavEvent[]>;
|
|
77
|
-
export
|
|
77
|
+
export type CalDavGetEventsByDate = (opts: {
|
|
78
78
|
calendarId: string;
|
|
79
79
|
principalId: string;
|
|
80
80
|
start: string;
|
|
@@ -82,36 +82,36 @@ export declare type CalDavGetEventsByDate = (opts: {
|
|
|
82
82
|
fullData: boolean;
|
|
83
83
|
user: any;
|
|
84
84
|
}) => Promise<CalDavEvent[]>;
|
|
85
|
-
export
|
|
85
|
+
export type CalDavGetEvent = (opts: {
|
|
86
86
|
eventId: string;
|
|
87
87
|
calendarId: string;
|
|
88
88
|
principalId: string;
|
|
89
89
|
fullData: boolean;
|
|
90
90
|
user: any;
|
|
91
91
|
}) => Promise<CalDavEvent>;
|
|
92
|
-
export
|
|
92
|
+
export type CalDavCreateEvent = (opts: {
|
|
93
93
|
event: CalDavEvent;
|
|
94
94
|
calendarId: string;
|
|
95
95
|
principalId: string;
|
|
96
96
|
user: any;
|
|
97
97
|
}) => Promise<CalDavEvent>;
|
|
98
|
-
export
|
|
98
|
+
export type CalDavUpdateEvent = (opts: {
|
|
99
99
|
event: CalDavEvent;
|
|
100
100
|
calendarId: string;
|
|
101
101
|
principalId: string;
|
|
102
102
|
user: any;
|
|
103
103
|
}) => Promise<CalDavEvent>;
|
|
104
|
-
export
|
|
104
|
+
export type CalDavDeleteEvent = (opts: {
|
|
105
105
|
eventId: string;
|
|
106
106
|
calendarId: string;
|
|
107
107
|
principalId: string;
|
|
108
108
|
user: any;
|
|
109
109
|
}) => Promise<void>;
|
|
110
|
-
export
|
|
110
|
+
export type CalDavOptionsLogging = {
|
|
111
111
|
logEnabled?: boolean;
|
|
112
112
|
logLevel?: string;
|
|
113
113
|
};
|
|
114
|
-
export
|
|
114
|
+
export type CalDavOptionsData = {
|
|
115
115
|
data: {
|
|
116
116
|
getCalendar: CalDavGetCalendar;
|
|
117
117
|
getCalendarsForPrincipal: CalDavGetCalendarsForPrincipal;
|
|
@@ -123,15 +123,15 @@ export declare type CalDavOptionsData = {
|
|
|
123
123
|
deleteEvent: CalDavDeleteEvent;
|
|
124
124
|
};
|
|
125
125
|
};
|
|
126
|
-
export
|
|
126
|
+
export type CalDavOptionsProId = {
|
|
127
127
|
proId: {
|
|
128
128
|
company: string;
|
|
129
129
|
product: string;
|
|
130
130
|
language: string;
|
|
131
131
|
};
|
|
132
132
|
};
|
|
133
|
-
export
|
|
134
|
-
export
|
|
133
|
+
export type CalDavOptionsModule = CalDavOptionsLogging & CalDavOptionsData & CalDavOptionsProId;
|
|
134
|
+
export type CalDavOptions = CalDavOptionsModule & {
|
|
135
135
|
authenticate: CalDavAuthenticate;
|
|
136
136
|
authRealm: string;
|
|
137
137
|
caldavRoot?: string;
|
package/lib/koa.js
CHANGED
|
@@ -18,22 +18,22 @@ const defaults = {
|
|
|
18
18
|
};
|
|
19
19
|
function default_1(opts) {
|
|
20
20
|
opts = Object.assign(defaults, opts);
|
|
21
|
-
const log = winston_1.default(Object.assign(Object.assign({}, opts), { label: 'index' }));
|
|
21
|
+
const log = (0, winston_1.default)(Object.assign(Object.assign({}, opts), { label: 'index' }));
|
|
22
22
|
const rootRoute = path_1.posix.join('/', opts.caldavRoot);
|
|
23
23
|
const calendarRoute = path_1.posix.join(rootRoute, opts.calendarRoot);
|
|
24
24
|
const principalRoute = path_1.posix.join(rootRoute, opts.principalRoot, '/');
|
|
25
|
-
const rootRegexp = path_to_regexp_1.pathToRegexp(path_1.posix.join(rootRoute, '/:params*'));
|
|
25
|
+
const rootRegexp = (0, path_to_regexp_1.pathToRegexp)(path_1.posix.join(rootRoute, '/:params*'));
|
|
26
26
|
const calendarRegex = { keys: [] };
|
|
27
|
-
calendarRegex.regexp = path_to_regexp_1.pathToRegexp(path_1.posix.join(calendarRoute, '/:principalId/:calendarId?/:eventId*'), calendarRegex.keys);
|
|
27
|
+
calendarRegex.regexp = (0, path_to_regexp_1.pathToRegexp)(path_1.posix.join(calendarRoute, '/:principalId/:calendarId?/:eventId*'), calendarRegex.keys);
|
|
28
28
|
const principalRegex = { keys: [] };
|
|
29
|
-
principalRegex.regexp = path_to_regexp_1.pathToRegexp(path_1.posix.join(principalRoute, '/:principalId?'), principalRegex.keys);
|
|
30
|
-
const calendarRoutes = calendar_1.default({
|
|
29
|
+
principalRegex.regexp = (0, path_to_regexp_1.pathToRegexp)(path_1.posix.join(principalRoute, '/:principalId?'), principalRegex.keys);
|
|
30
|
+
const calendarRoutes = (0, calendar_1.default)({
|
|
31
31
|
logEnabled: opts.logEnabled,
|
|
32
32
|
logLevel: opts.logLevel,
|
|
33
33
|
proId: opts.proId,
|
|
34
34
|
data: opts.data
|
|
35
35
|
});
|
|
36
|
-
const principalRoutes = principal_1.default({
|
|
36
|
+
const principalRoutes = (0, principal_1.default)({
|
|
37
37
|
logEnabled: opts.logEnabled,
|
|
38
38
|
logLevel: opts.logLevel,
|
|
39
39
|
proId: opts.proId,
|
|
@@ -64,7 +64,7 @@ function default_1(opts) {
|
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
const auth = async function (ctx) {
|
|
67
|
-
const creds = basic_auth_1.default(ctx);
|
|
67
|
+
const creds = (0, basic_auth_1.default)(ctx);
|
|
68
68
|
if (!creds) {
|
|
69
69
|
ctx.status = 401;
|
|
70
70
|
ctx.response.set('WWW-Authenticate', `Basic realm="${opts.authRealm}"`);
|
|
@@ -112,7 +112,7 @@ function default_1(opts) {
|
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
114
|
fillRoutes(ctx);
|
|
115
|
-
await parseBody_1.default(ctx);
|
|
115
|
+
await (0, parseBody_1.default)(ctx);
|
|
116
116
|
log.verbose(`REQUEST BODY: ${ctx.request.body ? ('\n' + ctx.request.body) : 'empty'}`);
|
|
117
117
|
if (calendarRegex.regexp.test(ctx.url)) {
|
|
118
118
|
await calendarRoutes(ctx);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
@@ -28,14 +32,14 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
28
32
|
const winston_1 = __importDefault(require("../../../common/winston"));
|
|
29
33
|
const eventBuild_1 = __importDefault(require("../../../common/eventBuild"));
|
|
30
34
|
function default_1(opts) {
|
|
31
|
-
const log = winston_1.default(Object.assign(Object.assign({}, opts), { label: 'calendar/report/calendar-multiget' }));
|
|
32
|
-
const { buildICS } = eventBuild_1.default(opts);
|
|
35
|
+
const log = (0, winston_1.default)(Object.assign(Object.assign({}, opts), { label: 'calendar/report/calendar-multiget' }));
|
|
36
|
+
const { buildICS } = (0, eventBuild_1.default)(opts);
|
|
33
37
|
return async function (ctx, calendar) {
|
|
34
38
|
const hrefs = xml.get('/CAL:calendar-multiget/D:href', ctx.request.xml);
|
|
35
39
|
const eventActions = lodash_1.default.map(hrefs, async (node) => {
|
|
36
40
|
const href = node.textContent;
|
|
37
41
|
if (!href) {
|
|
38
|
-
return xBuild_1.response(href, xBuild_1.status[404]);
|
|
42
|
+
return (0, xBuild_1.response)(href, xBuild_1.status[404]);
|
|
39
43
|
}
|
|
40
44
|
const hrefParts = href.split('/');
|
|
41
45
|
const eventId = hrefParts[hrefParts.length - 1].slice(0, -4);
|
|
@@ -48,10 +52,10 @@ function default_1(opts) {
|
|
|
48
52
|
});
|
|
49
53
|
log.debug(`event ${event ? 'found' : 'missing'}: ${eventId}`);
|
|
50
54
|
if (!event) {
|
|
51
|
-
return xBuild_1.response(href, xBuild_1.status[404]);
|
|
55
|
+
return (0, xBuild_1.response)(href, xBuild_1.status[404]);
|
|
52
56
|
}
|
|
53
57
|
const ics = buildICS(event, calendar);
|
|
54
|
-
return xBuild_1.response(href, xBuild_1.status[200], [{
|
|
58
|
+
return (0, xBuild_1.response)(href, xBuild_1.status[200], [{
|
|
55
59
|
'D:getetag': event.lastModifiedOn
|
|
56
60
|
}, {
|
|
57
61
|
'CAL:calendar-data': ics
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
@@ -28,7 +32,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
28
32
|
const eventResponse_1 = __importDefault(require("./eventResponse"));
|
|
29
33
|
function default_1(opts) {
|
|
30
34
|
// const log = winston({ ...opts, label: 'calendar/report/calendar-query' });
|
|
31
|
-
const eventResponse = eventResponse_1.default(opts);
|
|
35
|
+
const eventResponse = (0, eventResponse_1.default)(opts);
|
|
32
36
|
return async function (ctx, calendar) {
|
|
33
37
|
/* https://tools.ietf.org/html/rfc4791#section-9.9 */
|
|
34
38
|
const filters = xml.get('/CAL:calendar-query/CAL:filter/CAL:comp-filter[@name=\'VCALENDAR\']/CAL:comp-filter[@name=\'VEVENT\']/CAL:time-range', ctx.request.xml);
|
|
@@ -37,9 +41,9 @@ function default_1(opts) {
|
|
|
37
41
|
}
|
|
38
42
|
const filter = filters[0];
|
|
39
43
|
const startAttr = lodash_1.default.find(filter.attributes, { localName: 'start' });
|
|
40
|
-
const start = startAttr ? date_1.formatted(startAttr.nodeValue) : null;
|
|
44
|
+
const start = startAttr ? (0, date_1.formatted)(startAttr.nodeValue) : null;
|
|
41
45
|
const endAttr = lodash_1.default.find(filter.attributes, { localName: 'end' });
|
|
42
|
-
const end = endAttr ? date_1.formatted(endAttr.nodeValue) : null;
|
|
46
|
+
const end = endAttr ? (0, date_1.formatted)(endAttr.nodeValue) : null;
|
|
43
47
|
const { children } = xml.getWithChildren('/CAL:calendar-query/D:prop', ctx.request.xml);
|
|
44
48
|
const fullData = lodash_1.default.some(children, (child) => {
|
|
45
49
|
return child.localName === 'calendar-data';
|
|
@@ -8,14 +8,14 @@ const response_1 = require("../../../common/response");
|
|
|
8
8
|
const winston_1 = __importDefault(require("../../../common/winston"));
|
|
9
9
|
/* https://tools.ietf.org/html/rfc2518#section-8.6 */
|
|
10
10
|
function default_1(opts) {
|
|
11
|
-
const log = winston_1.default(Object.assign(Object.assign({}, opts), { label: 'calendar/delete' }));
|
|
11
|
+
const log = (0, winston_1.default)(Object.assign(Object.assign({}, opts), { label: 'calendar/delete' }));
|
|
12
12
|
const exec = async function (ctx, calendar) {
|
|
13
13
|
if (calendar.readOnly) {
|
|
14
|
-
return response_1.setMissingMethod(ctx);
|
|
14
|
+
return (0, response_1.setMissingMethod)(ctx);
|
|
15
15
|
}
|
|
16
16
|
if (!ctx.state.params.eventId) {
|
|
17
17
|
log.warn('eventId param not present');
|
|
18
|
-
ctx.body = xBuild_1.notFound(ctx.url); // make more meaningful
|
|
18
|
+
ctx.body = (0, xBuild_1.notFound)(ctx.url); // make more meaningful
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
const existing = await opts.data.getEvent({
|
|
@@ -8,7 +8,7 @@ const path_1 = require("path");
|
|
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
9
|
const tags_1 = __importDefault(require("../../../common/tags"));
|
|
10
10
|
function default_1(opts) {
|
|
11
|
-
const tags = tags_1.default(opts);
|
|
11
|
+
const tags = (0, tags_1.default)(opts);
|
|
12
12
|
return async function (ctx, events, calendar, children) {
|
|
13
13
|
const eventActions = lodash_1.default.map(events, async (event) => {
|
|
14
14
|
const misses = [];
|
|
@@ -23,9 +23,9 @@ function default_1(opts) {
|
|
|
23
23
|
});
|
|
24
24
|
const pRes = await Promise.all(propActions);
|
|
25
25
|
const url = path_1.posix.join(ctx.url, `${event.eventId}.ics`);
|
|
26
|
-
const resp = xBuild_1.response(url, xBuild_1.status[200], lodash_1.default.compact(pRes));
|
|
26
|
+
const resp = (0, xBuild_1.response)(url, xBuild_1.status[200], lodash_1.default.compact(pRes));
|
|
27
27
|
if (misses.length) {
|
|
28
|
-
resp['D:propstat'].push(xBuild_1.missingPropstats(misses));
|
|
28
|
+
resp['D:propstat'].push((0, xBuild_1.missingPropstats)(misses));
|
|
29
29
|
}
|
|
30
30
|
return resp;
|
|
31
31
|
});
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const xBuild_1 = require("../../../common/xBuild");
|
|
7
7
|
const winston_1 = __importDefault(require("../../../common/winston"));
|
|
8
8
|
function default_1(opts) {
|
|
9
|
-
const log = winston_1.default(Object.assign(Object.assign({}, opts), { label: 'calendar/report/expand-property' }));
|
|
9
|
+
const log = (0, winston_1.default)(Object.assign(Object.assign({}, opts), { label: 'calendar/report/expand-property' }));
|
|
10
10
|
return async function (ctx /*, calendar*/) {
|
|
11
11
|
log.debug('returning blank 200 response');
|
|
12
|
-
return { responses: [xBuild_1.response(ctx.url, xBuild_1.status[200])] };
|
|
12
|
+
return { responses: [(0, xBuild_1.response)(ctx.url, xBuild_1.status[200])] };
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
exports.default = default_1;
|
|
@@ -7,8 +7,8 @@ const response_1 = require("../../../common/response");
|
|
|
7
7
|
const winston_1 = __importDefault(require("../../../common/winston"));
|
|
8
8
|
const eventBuild_1 = __importDefault(require("../../../common/eventBuild"));
|
|
9
9
|
function default_1(opts) {
|
|
10
|
-
const log = winston_1.default(Object.assign(Object.assign({}, opts), { label: 'calendar/get' }));
|
|
11
|
-
const { buildICS } = eventBuild_1.default(opts);
|
|
10
|
+
const log = (0, winston_1.default)(Object.assign(Object.assign({}, opts), { label: 'calendar/get' }));
|
|
11
|
+
const { buildICS } = (0, eventBuild_1.default)(opts);
|
|
12
12
|
const exec = async function (ctx, calendar) {
|
|
13
13
|
const event = await opts.data.getEvent({
|
|
14
14
|
principalId: ctx.state.params.principalId,
|
|
@@ -19,7 +19,7 @@ function default_1(opts) {
|
|
|
19
19
|
});
|
|
20
20
|
if (!event) {
|
|
21
21
|
log.debug(`event ${ctx.state.params.eventId} not found`);
|
|
22
|
-
return response_1.setMissingMethod(ctx);
|
|
22
|
+
return (0, response_1.setMissingMethod)(ctx);
|
|
23
23
|
}
|
|
24
24
|
return buildICS(event, calendar);
|
|
25
25
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
@@ -29,8 +33,8 @@ const path_1 = require("path");
|
|
|
29
33
|
const tags_1 = __importDefault(require("../../../common/tags"));
|
|
30
34
|
const eventResponse_1 = __importDefault(require("./eventResponse"));
|
|
31
35
|
function default_1(opts) {
|
|
32
|
-
const tags = tags_1.default(opts);
|
|
33
|
-
const eventResponse = eventResponse_1.default(opts);
|
|
36
|
+
const tags = (0, tags_1.default)(opts);
|
|
37
|
+
const eventResponse = (0, eventResponse_1.default)(opts);
|
|
34
38
|
const calendarResponse = async function (ctx, calendar) {
|
|
35
39
|
const { children } = xml.getWithChildren('/D:propfind/D:prop', ctx.request.xml);
|
|
36
40
|
const actions = lodash_1.default.map(children, async (child) => {
|
|
@@ -44,7 +48,7 @@ function default_1(opts) {
|
|
|
44
48
|
const res = await Promise.all(actions);
|
|
45
49
|
const calendarUrl = path_1.posix.join(ctx.state.calendarHomeUrl, calendar.calendarId, '/');
|
|
46
50
|
const props = lodash_1.default.compact(res);
|
|
47
|
-
return xBuild_1.response(calendarUrl, props.length ? xBuild_1.status[200] : xBuild_1.status[404], props);
|
|
51
|
+
return (0, xBuild_1.response)(calendarUrl, props.length ? xBuild_1.status[200] : xBuild_1.status[404], props);
|
|
48
52
|
};
|
|
49
53
|
const exec = async function (ctx, calendar) {
|
|
50
54
|
const resp = await calendarResponse(ctx, calendar);
|
|
@@ -61,8 +65,8 @@ function default_1(opts) {
|
|
|
61
65
|
});
|
|
62
66
|
const { responses } = await eventResponse(ctx, events, calendar, children);
|
|
63
67
|
resps.push(...responses);
|
|
64
|
-
const ms = xBuild_1.multistatus(resps);
|
|
65
|
-
return xBuild_1.build(ms);
|
|
68
|
+
const ms = (0, xBuild_1.multistatus)(resps);
|
|
69
|
+
return (0, xBuild_1.build)(ms);
|
|
66
70
|
};
|
|
67
71
|
return {
|
|
68
72
|
exec,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
@@ -27,7 +31,7 @@ const xBuild_1 = require("../../../common/xBuild");
|
|
|
27
31
|
const lodash_1 = __importDefault(require("lodash"));
|
|
28
32
|
const tags_1 = __importDefault(require("../../../common/tags"));
|
|
29
33
|
function default_1(opts) {
|
|
30
|
-
const tags = tags_1.default(opts);
|
|
34
|
+
const tags = (0, tags_1.default)(opts);
|
|
31
35
|
const exec = async function (ctx, calendar) {
|
|
32
36
|
const { children } = xml.getWithChildren('/D:propertyupdate/D:set/D:prop', ctx.request.xml);
|
|
33
37
|
const actions = lodash_1.default.map(children, async (child) => {
|
|
@@ -39,8 +43,8 @@ function default_1(opts) {
|
|
|
39
43
|
});
|
|
40
44
|
});
|
|
41
45
|
const res = await Promise.all(actions);
|
|
42
|
-
const ms = xBuild_1.multistatus(lodash_1.default.compact(res));
|
|
43
|
-
return xBuild_1.build(ms);
|
|
46
|
+
const ms = (0, xBuild_1.multistatus)(lodash_1.default.compact(res));
|
|
47
|
+
return (0, xBuild_1.build)(ms);
|
|
44
48
|
};
|
|
45
49
|
return {
|
|
46
50
|
exec
|
|
@@ -10,20 +10,20 @@ const winston_1 = __importDefault(require("../../../common/winston"));
|
|
|
10
10
|
const eventBuild_1 = __importDefault(require("../../../common/eventBuild"));
|
|
11
11
|
/* https://tools.ietf.org/html/rfc4791#section-5.3.2 */
|
|
12
12
|
function default_1(opts) {
|
|
13
|
-
const log = winston_1.default(Object.assign(Object.assign({}, opts), { label: 'calendar/put' }));
|
|
14
|
-
const { buildObj } = eventBuild_1.default(opts);
|
|
13
|
+
const log = (0, winston_1.default)(Object.assign(Object.assign({}, opts), { label: 'calendar/put' }));
|
|
14
|
+
const { buildObj } = (0, eventBuild_1.default)(opts);
|
|
15
15
|
const exec = async function (ctx, calendar) {
|
|
16
16
|
if (calendar.readOnly) {
|
|
17
|
-
return response_1.setMissingMethod(ctx);
|
|
17
|
+
return (0, response_1.setMissingMethod)(ctx);
|
|
18
18
|
}
|
|
19
19
|
if (!ctx.state.params.eventId) {
|
|
20
20
|
log.warn('eventId param not present');
|
|
21
|
-
return ctx.body = xBuild_1.notFound(ctx.url); // make more meaningful
|
|
21
|
+
return ctx.body = (0, xBuild_1.notFound)(ctx.url); // make more meaningful
|
|
22
22
|
}
|
|
23
23
|
const incoming = lodash_1.default.find(ctx.request.ical, { type: 'VEVENT' });
|
|
24
24
|
if (!incoming) {
|
|
25
25
|
log.warn('incoming VEVENT not present');
|
|
26
|
-
ctx.body = xBuild_1.notFound(ctx.url); // make more meaningful
|
|
26
|
+
ctx.body = (0, xBuild_1.notFound)(ctx.url); // make more meaningful
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
const incomingObj = buildObj(ctx.request.body, incoming, calendar);
|
|
@@ -43,13 +43,13 @@ function default_1(opts) {
|
|
|
43
43
|
user: ctx.state.user
|
|
44
44
|
});
|
|
45
45
|
log.debug('new event created');
|
|
46
|
-
response_1.setEventPutResponse(ctx, newObj);
|
|
46
|
+
(0, response_1.setEventPutResponse)(ctx, newObj);
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
49
|
if (ctx.get('if-none-match') === '*') {
|
|
50
50
|
log.warn('if-none-match: * header present, precondition failed');
|
|
51
51
|
ctx.status = 412;
|
|
52
|
-
return ctx.body = xBuild_1.preconditionFail(ctx.url, 'no-uid-conflict');
|
|
52
|
+
return ctx.body = (0, xBuild_1.preconditionFail)(ctx.url, 'no-uid-conflict');
|
|
53
53
|
}
|
|
54
54
|
const updateObj = await opts.data.updateEvent({
|
|
55
55
|
principalId: ctx.state.params.principalId,
|
|
@@ -58,7 +58,7 @@ function default_1(opts) {
|
|
|
58
58
|
user: ctx.state.user
|
|
59
59
|
});
|
|
60
60
|
log.debug('event updated');
|
|
61
|
-
response_1.setEventPutResponse(ctx, updateObj);
|
|
61
|
+
(0, response_1.setEventPutResponse)(ctx, updateObj);
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
return {
|
|
@@ -10,27 +10,27 @@ const calendar_multiget_1 = __importDefault(require("./calendar-multiget"));
|
|
|
10
10
|
const expand_property_1 = __importDefault(require("./expand-property"));
|
|
11
11
|
const sync_collection_1 = __importDefault(require("./sync-collection"));
|
|
12
12
|
function default_1(opts) {
|
|
13
|
-
const log = winston_1.default(Object.assign(Object.assign({}, opts), { label: 'calendar/report' }));
|
|
13
|
+
const log = (0, winston_1.default)(Object.assign(Object.assign({}, opts), { label: 'calendar/report' }));
|
|
14
14
|
const rootActions = {
|
|
15
15
|
/* https://tools.ietf.org/html/rfc4791#section-7.8 */
|
|
16
|
-
'calendar-query': calendar_query_1.default(opts),
|
|
16
|
+
'calendar-query': (0, calendar_query_1.default)(opts),
|
|
17
17
|
/* https://tools.ietf.org/html/rfc4791#section-7.9 */
|
|
18
|
-
'calendar-multiget': calendar_multiget_1.default(opts),
|
|
18
|
+
'calendar-multiget': (0, calendar_multiget_1.default)(opts),
|
|
19
19
|
/* https://tools.ietf.org/html/rfc3253#section-3.8 */
|
|
20
|
-
'expand-property': expand_property_1.default(opts),
|
|
20
|
+
'expand-property': (0, expand_property_1.default)(opts),
|
|
21
21
|
/* https://tools.ietf.org/html/rfc6578#section-3.2 */
|
|
22
|
-
'sync-collection': sync_collection_1.default(opts)
|
|
22
|
+
'sync-collection': (0, sync_collection_1.default)(opts)
|
|
23
23
|
};
|
|
24
24
|
const exec = async function (ctx, calendar) {
|
|
25
25
|
const rootTag = ctx.request.xml.documentElement.localName;
|
|
26
26
|
const rootAction = rootActions[rootTag];
|
|
27
27
|
log.debug(`report ${rootAction ? 'hit' : 'miss'}: ${rootTag}`);
|
|
28
28
|
if (!rootAction) {
|
|
29
|
-
return xBuild_1.notFound(ctx.url);
|
|
29
|
+
return (0, xBuild_1.notFound)(ctx.url);
|
|
30
30
|
}
|
|
31
31
|
const { responses, other } = await rootAction(ctx, calendar);
|
|
32
|
-
const ms = xBuild_1.multistatus(responses, other);
|
|
33
|
-
return xBuild_1.build(ms);
|
|
32
|
+
const ms = (0, xBuild_1.multistatus)(responses, other);
|
|
33
|
+
return (0, xBuild_1.build)(ms);
|
|
34
34
|
};
|
|
35
35
|
return {
|
|
36
36
|
exec
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
@@ -27,7 +31,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
27
31
|
const eventResponse_1 = __importDefault(require("./eventResponse"));
|
|
28
32
|
function default_1(opts) {
|
|
29
33
|
// const log = winston({ ...opts, label: 'calendar/report/sync-collection' });
|
|
30
|
-
const eventResponse = eventResponse_1.default(opts);
|
|
34
|
+
const eventResponse = (0, eventResponse_1.default)(opts);
|
|
31
35
|
const tagActions = {
|
|
32
36
|
'sync-token': async (ctx, calendar) => { return { 'D:sync-token': calendar.syncToken }; },
|
|
33
37
|
};
|
|
@@ -15,30 +15,31 @@ const get_1 = __importDefault(require("./calendar/get"));
|
|
|
15
15
|
const put_1 = __importDefault(require("./calendar/put"));
|
|
16
16
|
const delete_1 = __importDefault(require("./calendar/delete"));
|
|
17
17
|
function default_1(opts) {
|
|
18
|
-
const log = winston_1.default(Object.assign(Object.assign({}, opts), { label: 'calendar' }));
|
|
18
|
+
const log = (0, winston_1.default)(Object.assign(Object.assign({}, opts), { label: 'calendar' }));
|
|
19
19
|
const userMethods = {
|
|
20
|
-
propfind: propfind_1.default(opts),
|
|
20
|
+
propfind: (0, propfind_1.default)(opts),
|
|
21
|
+
// proppatch: routerUserProppatch(opts)
|
|
21
22
|
};
|
|
22
23
|
const calMethods = {
|
|
23
|
-
propfind: propfind_2.default(opts),
|
|
24
|
-
report: report_1.default(opts),
|
|
25
|
-
get: get_1.default(opts),
|
|
24
|
+
propfind: (0, propfind_2.default)(opts),
|
|
25
|
+
report: (0, report_1.default)(opts),
|
|
26
|
+
get: (0, get_1.default)(opts),
|
|
26
27
|
// proppatch: routerCalProppatch(opts),
|
|
27
|
-
put: put_1.default(opts),
|
|
28
|
-
delete: delete_1.default(opts)
|
|
28
|
+
put: (0, put_1.default)(opts),
|
|
29
|
+
delete: (0, delete_1.default)(opts)
|
|
29
30
|
};
|
|
30
31
|
return async function (ctx) {
|
|
31
32
|
const method = ctx.method.toLowerCase();
|
|
32
33
|
const calendarId = ctx.state.params.calendarId;
|
|
33
|
-
response_1.setMultistatusResponse(ctx);
|
|
34
|
+
(0, response_1.setMultistatusResponse)(ctx);
|
|
34
35
|
if (!calendarId) {
|
|
35
36
|
if (method === 'options') {
|
|
36
|
-
response_1.setOptions(ctx, ['OPTIONS', 'PROPFIND']);
|
|
37
|
+
(0, response_1.setOptions)(ctx, ['OPTIONS', 'PROPFIND']);
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
if (!userMethods[method]) {
|
|
40
41
|
log.warn(`method handler not found: ${method}`);
|
|
41
|
-
ctx.body = xBuild_1.notFound(ctx.url);
|
|
42
|
+
ctx.body = (0, xBuild_1.notFound)(ctx.url);
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
45
|
ctx.body = await userMethods[method].exec(ctx);
|
|
@@ -54,17 +55,17 @@ function default_1(opts) {
|
|
|
54
55
|
const methods = calendar && calendar.readOnly ?
|
|
55
56
|
['OPTIONS', 'PROPFIND', 'REPORT'] :
|
|
56
57
|
['OPTIONS', 'PROPFIND', 'REPORT', 'PUT', 'DELETE'];
|
|
57
|
-
response_1.setOptions(ctx, methods);
|
|
58
|
+
(0, response_1.setOptions)(ctx, methods);
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
61
|
if (!calendar) {
|
|
61
62
|
log.warn(`calendar not found: ${calendarId}`);
|
|
62
|
-
ctx.body = xBuild_1.notFound(ctx.url);
|
|
63
|
+
ctx.body = (0, xBuild_1.notFound)(ctx.url);
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
65
66
|
if (!calMethods[method]) {
|
|
66
67
|
log.warn(`method handler not found: ${method}`);
|
|
67
|
-
ctx.body = xBuild_1.notFound(ctx.url);
|
|
68
|
+
ctx.body = (0, xBuild_1.notFound)(ctx.url);
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
71
|
const body = await calMethods[method].exec(ctx, calendar);
|