caldav-adapter 4.3.1 → 5.0.1
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/.commitlintrc.js +3 -0
- package/.editorconfig +9 -0
- package/.gitattributes +1 -0
- package/.github/workflows/ci.yml +24 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.lintstagedrc.js +5 -0
- package/.prettierrc.js +5 -0
- package/.remarkignore +1 -0
- package/.remarkrc.js +3 -0
- package/.xo-config.js +8 -0
- package/LICENSE +21 -0
- package/README.md +26 -240
- package/common/parse-body.js +16 -0
- package/common/response.js +51 -0
- package/common/tags.js +412 -0
- package/common/winston.js +32 -0
- package/common/x-build.js +109 -0
- package/common/xml.js +36 -0
- package/index.js +171 -0
- package/package.json +58 -40
- package/routes/calendar/calendar/calendar-multiget.js +48 -0
- package/routes/calendar/calendar/calendar-query.js +80 -0
- package/routes/calendar/calendar/delete.js +40 -0
- package/routes/calendar/calendar/event-response.js +37 -0
- package/routes/calendar/calendar/expand-property.js +11 -0
- package/routes/calendar/calendar/get.js +27 -0
- package/routes/calendar/calendar/propfind.js +73 -0
- package/routes/calendar/calendar/proppatch.js +32 -0
- package/routes/calendar/calendar/put.js +76 -0
- package/routes/calendar/calendar/report.js +36 -0
- package/routes/calendar/calendar/sync-collection.js +36 -0
- package/routes/calendar/calendar.js +80 -0
- package/routes/calendar/user/propfind.js +60 -0
- package/routes/calendar/user/proppatch.js +31 -0
- package/routes/principal/mkcalendar.js +69 -0
- package/routes/principal/principal.js +33 -0
- package/routes/principal/propfind.js +32 -0
- package/routes/principal/report.js +27 -0
- package/test/test.js +8 -0
- package/lib/common/date.d.ts +0 -2
- package/lib/common/date.js +0 -11
- package/lib/common/eventBuild.d.ts +0 -6
- package/lib/common/eventBuild.js +0 -170
- package/lib/common/parseBody.d.ts +0 -2
- package/lib/common/parseBody.js +0 -21
- package/lib/common/response.d.ts +0 -6
- package/lib/common/response.js +0 -53
- package/lib/common/tags.d.ts +0 -263
- package/lib/common/tags.js +0 -337
- package/lib/common/winston.d.ts +0 -11
- package/lib/common/winston.js +0 -26
- package/lib/common/xBuild.d.ts +0 -17
- package/lib/common/xBuild.js +0 -80
- package/lib/common/xml.d.ts +0 -17
- package/lib/common/xml.js +0 -30
- package/lib/index.d.ts +0 -143
- package/lib/index.js +0 -8
- package/lib/koa.d.ts +0 -21
- package/lib/koa.js +0 -130
- package/lib/routes/calendar/calendar/calendar-multiget.d.ts +0 -7
- package/lib/routes/calendar/calendar/calendar-multiget.js +0 -68
- package/lib/routes/calendar/calendar/calendar-query.d.ts +0 -7
- package/lib/routes/calendar/calendar/calendar-query.js +0 -68
- package/lib/routes/calendar/calendar/delete.d.ts +0 -5
- package/lib/routes/calendar/calendar/delete.js +0 -40
- package/lib/routes/calendar/calendar/eventResponse.d.ts +0 -7
- package/lib/routes/calendar/calendar/eventResponse.js +0 -36
- package/lib/routes/calendar/calendar/expand-property.d.ts +0 -7
- package/lib/routes/calendar/calendar/expand-property.js +0 -15
- package/lib/routes/calendar/calendar/get.d.ts +0 -5
- package/lib/routes/calendar/calendar/get.js +0 -30
- package/lib/routes/calendar/calendar/propfind.d.ts +0 -8
- package/lib/routes/calendar/calendar/propfind.js +0 -76
- package/lib/routes/calendar/calendar/proppatch.d.ts +0 -5
- package/lib/routes/calendar/calendar/proppatch.js +0 -53
- package/lib/routes/calendar/calendar/put.d.ts +0 -5
- package/lib/routes/calendar/calendar/put.js +0 -68
- package/lib/routes/calendar/calendar/report.d.ts +0 -5
- package/lib/routes/calendar/calendar/report.js +0 -39
- package/lib/routes/calendar/calendar/sync-collection.d.ts +0 -10
- package/lib/routes/calendar/calendar/sync-collection.js +0 -57
- package/lib/routes/calendar/calendar.d.ts +0 -3
- package/lib/routes/calendar/calendar.js +0 -78
- package/lib/routes/calendar/user/propfind.d.ts +0 -5
- package/lib/routes/calendar/user/propfind.js +0 -64
- package/lib/routes/calendar/user/proppatch.d.ts +0 -5
- package/lib/routes/calendar/user/proppatch.js +0 -52
- package/lib/routes/principal/principal.d.ts +0 -3
- package/lib/routes/principal/principal.js +0 -32
- package/lib/routes/principal/propfind.d.ts +0 -3
- package/lib/routes/principal/propfind.js +0 -50
- package/lib/routes/principal/report.d.ts +0 -3
- package/lib/routes/principal/report.js +0 -32
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
7
|
-
const xBuild_1 = require("../../../common/xBuild");
|
|
8
|
-
const response_1 = require("../../../common/response");
|
|
9
|
-
const winston_1 = __importDefault(require("../../../common/winston"));
|
|
10
|
-
const eventBuild_1 = __importDefault(require("../../../common/eventBuild"));
|
|
11
|
-
/* https://tools.ietf.org/html/rfc4791#section-5.3.2 */
|
|
12
|
-
function default_1(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
|
-
const exec = async function (ctx, calendar) {
|
|
16
|
-
if (calendar.readOnly) {
|
|
17
|
-
return (0, response_1.setMissingMethod)(ctx);
|
|
18
|
-
}
|
|
19
|
-
if (!ctx.state.params.eventId) {
|
|
20
|
-
log.warn('eventId param not present');
|
|
21
|
-
return ctx.body = (0, xBuild_1.notFound)(ctx.url); // make more meaningful
|
|
22
|
-
}
|
|
23
|
-
const incoming = lodash_1.default.find(ctx.request.ical, { type: 'VEVENT' });
|
|
24
|
-
if (!incoming) {
|
|
25
|
-
log.warn('incoming VEVENT not present');
|
|
26
|
-
ctx.body = (0, xBuild_1.notFound)(ctx.url); // make more meaningful
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const incomingObj = buildObj(ctx.request.body, incoming, calendar);
|
|
30
|
-
const existing = await opts.data.getEvent({
|
|
31
|
-
principalId: ctx.state.params.principalId,
|
|
32
|
-
calendarId: ctx.state.params.calendarId,
|
|
33
|
-
eventId: ctx.state.params.eventId,
|
|
34
|
-
user: ctx.state.user,
|
|
35
|
-
fullData: false
|
|
36
|
-
});
|
|
37
|
-
log.debug(`existing event${existing ? '' : ' not'} found`);
|
|
38
|
-
if (!existing) {
|
|
39
|
-
const newObj = await opts.data.createEvent({
|
|
40
|
-
principalId: ctx.state.params.principalId,
|
|
41
|
-
calendarId: ctx.state.params.calendarId,
|
|
42
|
-
event: incomingObj,
|
|
43
|
-
user: ctx.state.user
|
|
44
|
-
});
|
|
45
|
-
log.debug('new event created');
|
|
46
|
-
(0, response_1.setEventPutResponse)(ctx, newObj);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
if (ctx.get('if-none-match') === '*') {
|
|
50
|
-
log.warn('if-none-match: * header present, precondition failed');
|
|
51
|
-
ctx.status = 412;
|
|
52
|
-
return ctx.body = (0, xBuild_1.preconditionFail)(ctx.url, 'no-uid-conflict');
|
|
53
|
-
}
|
|
54
|
-
const updateObj = await opts.data.updateEvent({
|
|
55
|
-
principalId: ctx.state.params.principalId,
|
|
56
|
-
calendarId: ctx.state.params.calendarId,
|
|
57
|
-
event: incomingObj,
|
|
58
|
-
user: ctx.state.user
|
|
59
|
-
});
|
|
60
|
-
log.debug('event updated');
|
|
61
|
-
(0, response_1.setEventPutResponse)(ctx, updateObj);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
return {
|
|
65
|
-
exec
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
exports.default = default_1;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const xBuild_1 = require("../../../common/xBuild");
|
|
7
|
-
const winston_1 = __importDefault(require("../../../common/winston"));
|
|
8
|
-
const calendar_query_1 = __importDefault(require("./calendar-query"));
|
|
9
|
-
const calendar_multiget_1 = __importDefault(require("./calendar-multiget"));
|
|
10
|
-
const expand_property_1 = __importDefault(require("./expand-property"));
|
|
11
|
-
const sync_collection_1 = __importDefault(require("./sync-collection"));
|
|
12
|
-
function default_1(opts) {
|
|
13
|
-
const log = (0, winston_1.default)(Object.assign(Object.assign({}, opts), { label: 'calendar/report' }));
|
|
14
|
-
const rootActions = {
|
|
15
|
-
/* https://tools.ietf.org/html/rfc4791#section-7.8 */
|
|
16
|
-
'calendar-query': (0, calendar_query_1.default)(opts),
|
|
17
|
-
/* https://tools.ietf.org/html/rfc4791#section-7.9 */
|
|
18
|
-
'calendar-multiget': (0, calendar_multiget_1.default)(opts),
|
|
19
|
-
/* https://tools.ietf.org/html/rfc3253#section-3.8 */
|
|
20
|
-
'expand-property': (0, expand_property_1.default)(opts),
|
|
21
|
-
/* https://tools.ietf.org/html/rfc6578#section-3.2 */
|
|
22
|
-
'sync-collection': (0, sync_collection_1.default)(opts)
|
|
23
|
-
};
|
|
24
|
-
const exec = async function (ctx, calendar) {
|
|
25
|
-
const rootTag = ctx.request.xml.documentElement.localName;
|
|
26
|
-
const rootAction = rootActions[rootTag];
|
|
27
|
-
log.debug(`report ${rootAction ? 'hit' : 'miss'}: ${rootTag}`);
|
|
28
|
-
if (!rootAction) {
|
|
29
|
-
return (0, xBuild_1.notFound)(ctx.url);
|
|
30
|
-
}
|
|
31
|
-
const { responses, other } = await rootAction(ctx, calendar);
|
|
32
|
-
const ms = (0, xBuild_1.multistatus)(responses, other);
|
|
33
|
-
return (0, xBuild_1.build)(ms);
|
|
34
|
-
};
|
|
35
|
-
return {
|
|
36
|
-
exec
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
exports.default = default_1;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { CalDavOptionsModule, CalDavCalendar } from '../../..';
|
|
2
|
-
import { CalendarContext } from '../../../koa';
|
|
3
|
-
export default function (opts: CalDavOptionsModule): (ctx: CalendarContext, calendar: CalDavCalendar) => Promise<{
|
|
4
|
-
responses: {
|
|
5
|
-
[tag: string]: any;
|
|
6
|
-
}[];
|
|
7
|
-
other: {
|
|
8
|
-
'D:sync-token': string;
|
|
9
|
-
};
|
|
10
|
-
}>;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const xml = __importStar(require("../../../common/xml"));
|
|
30
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
31
|
-
const eventResponse_1 = __importDefault(require("./eventResponse"));
|
|
32
|
-
function default_1(opts) {
|
|
33
|
-
// const log = winston({ ...opts, label: 'calendar/report/sync-collection' });
|
|
34
|
-
const eventResponse = (0, eventResponse_1.default)(opts);
|
|
35
|
-
const tagActions = {
|
|
36
|
-
'sync-token': async (ctx, calendar) => { return { 'D:sync-token': calendar.syncToken }; },
|
|
37
|
-
};
|
|
38
|
-
return async function (ctx, calendar) {
|
|
39
|
-
const { children } = xml.getWithChildren('/D:sync-collection/D:prop', ctx.request.xml);
|
|
40
|
-
const fullData = lodash_1.default.some(children, (child) => {
|
|
41
|
-
return child.localName === 'calendar-data';
|
|
42
|
-
});
|
|
43
|
-
const events = await opts.data.getEventsForCalendar({
|
|
44
|
-
principalId: ctx.state.params.principalId,
|
|
45
|
-
calendarId: calendar.calendarId,
|
|
46
|
-
user: ctx.state.user,
|
|
47
|
-
fullData: fullData
|
|
48
|
-
});
|
|
49
|
-
const { responses } = await eventResponse(ctx, events, calendar, children);
|
|
50
|
-
const token = await tagActions['sync-token'](ctx, calendar);
|
|
51
|
-
return {
|
|
52
|
-
responses,
|
|
53
|
-
other: token
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
exports.default = default_1;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const xBuild_1 = require("../../common/xBuild");
|
|
7
|
-
const response_1 = require("../../common/response");
|
|
8
|
-
const winston_1 = __importDefault(require("../../common/winston"));
|
|
9
|
-
const propfind_1 = __importDefault(require("./user/propfind"));
|
|
10
|
-
// import routerUserProppatch from './user/proppatch';
|
|
11
|
-
const propfind_2 = __importDefault(require("./calendar/propfind"));
|
|
12
|
-
const report_1 = __importDefault(require("./calendar/report"));
|
|
13
|
-
const get_1 = __importDefault(require("./calendar/get"));
|
|
14
|
-
// import routerCalProppatch from './calendar/proppatch';
|
|
15
|
-
const put_1 = __importDefault(require("./calendar/put"));
|
|
16
|
-
const delete_1 = __importDefault(require("./calendar/delete"));
|
|
17
|
-
function default_1(opts) {
|
|
18
|
-
const log = (0, winston_1.default)(Object.assign(Object.assign({}, opts), { label: 'calendar' }));
|
|
19
|
-
const userMethods = {
|
|
20
|
-
propfind: (0, propfind_1.default)(opts),
|
|
21
|
-
// proppatch: routerUserProppatch(opts)
|
|
22
|
-
};
|
|
23
|
-
const calMethods = {
|
|
24
|
-
propfind: (0, propfind_2.default)(opts),
|
|
25
|
-
report: (0, report_1.default)(opts),
|
|
26
|
-
get: (0, get_1.default)(opts),
|
|
27
|
-
// proppatch: routerCalProppatch(opts),
|
|
28
|
-
put: (0, put_1.default)(opts),
|
|
29
|
-
delete: (0, delete_1.default)(opts)
|
|
30
|
-
};
|
|
31
|
-
return async function (ctx) {
|
|
32
|
-
const method = ctx.method.toLowerCase();
|
|
33
|
-
const calendarId = ctx.state.params.calendarId;
|
|
34
|
-
(0, response_1.setMultistatusResponse)(ctx);
|
|
35
|
-
if (!calendarId) {
|
|
36
|
-
if (method === 'options') {
|
|
37
|
-
(0, response_1.setOptions)(ctx, ['OPTIONS', 'PROPFIND']);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (!userMethods[method]) {
|
|
41
|
-
log.warn(`method handler not found: ${method}`);
|
|
42
|
-
ctx.body = (0, xBuild_1.notFound)(ctx.url);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
ctx.body = await userMethods[method].exec(ctx);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
// check calendar exists & user has access
|
|
49
|
-
const calendar = await opts.data.getCalendar({
|
|
50
|
-
principalId: ctx.state.params.principalId,
|
|
51
|
-
calendarId: calendarId,
|
|
52
|
-
user: ctx.state.user
|
|
53
|
-
});
|
|
54
|
-
if (method === 'options') {
|
|
55
|
-
const methods = calendar && calendar.readOnly ?
|
|
56
|
-
['OPTIONS', 'PROPFIND', 'REPORT'] :
|
|
57
|
-
['OPTIONS', 'PROPFIND', 'REPORT', 'PUT', 'DELETE'];
|
|
58
|
-
(0, response_1.setOptions)(ctx, methods);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (!calendar) {
|
|
62
|
-
log.warn(`calendar not found: ${calendarId}`);
|
|
63
|
-
ctx.body = (0, xBuild_1.notFound)(ctx.url);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (!calMethods[method]) {
|
|
67
|
-
log.warn(`method handler not found: ${method}`);
|
|
68
|
-
ctx.body = (0, xBuild_1.notFound)(ctx.url);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const body = await calMethods[method].exec(ctx, calendar);
|
|
72
|
-
if (body) {
|
|
73
|
-
ctx.body = body;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
exports.default = default_1;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const xml = __importStar(require("../../../common/xml"));
|
|
30
|
-
const xBuild_1 = require("../../../common/xBuild");
|
|
31
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
32
|
-
const propfind_1 = __importDefault(require("../calendar/propfind"));
|
|
33
|
-
const tags_1 = __importDefault(require("../../../common/tags"));
|
|
34
|
-
function default_1(opts) {
|
|
35
|
-
const { calendarResponse } = (0, propfind_1.default)(opts);
|
|
36
|
-
const tags = (0, tags_1.default)(opts);
|
|
37
|
-
const exec = async function (ctx) {
|
|
38
|
-
const { children } = xml.getWithChildren('/D:propfind/D:prop', ctx.request.xml);
|
|
39
|
-
const checksum = lodash_1.default.some(children, (child) => child.localName === 'checksum-versions');
|
|
40
|
-
const actions = lodash_1.default.map(children, async (child) => {
|
|
41
|
-
return await tags.getResponse({
|
|
42
|
-
resource: 'calCollection',
|
|
43
|
-
child,
|
|
44
|
-
ctx
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
const res = await Promise.all(actions);
|
|
48
|
-
const props = lodash_1.default.compact(res);
|
|
49
|
-
const responses = [(0, xBuild_1.response)(ctx.url, props.length ? xBuild_1.status[200] : xBuild_1.status[404], props)];
|
|
50
|
-
const calendars = await opts.data.getCalendarsForPrincipal({
|
|
51
|
-
principalId: ctx.state.params.principalId,
|
|
52
|
-
user: ctx.state.user
|
|
53
|
-
});
|
|
54
|
-
const calResponses = !checksum ? await Promise.all(calendars.map(async (cal) => {
|
|
55
|
-
return await calendarResponse(ctx, cal);
|
|
56
|
-
})) : [];
|
|
57
|
-
const ms = (0, xBuild_1.multistatus)([...responses, ...lodash_1.default.compact(calResponses)]);
|
|
58
|
-
return (0, xBuild_1.build)(ms);
|
|
59
|
-
};
|
|
60
|
-
return {
|
|
61
|
-
exec
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
exports.default = default_1;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const xml = __importStar(require("../../../common/xml"));
|
|
30
|
-
const xBuild_1 = require("../../../common/xBuild");
|
|
31
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
32
|
-
const tags_1 = __importDefault(require("../../../common/tags"));
|
|
33
|
-
function default_1(opts) {
|
|
34
|
-
const tags = (0, tags_1.default)(opts);
|
|
35
|
-
const exec = async function (ctx) {
|
|
36
|
-
const { children } = xml.getWithChildren('/D:propertyupdate/D:set/D:prop', ctx.request.xml);
|
|
37
|
-
const actions = lodash_1.default.map(children, async (child) => {
|
|
38
|
-
return await tags.getResponse({
|
|
39
|
-
resource: 'calCollectionProppatch',
|
|
40
|
-
child,
|
|
41
|
-
ctx
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
const res = await Promise.all(actions);
|
|
45
|
-
const ms = (0, xBuild_1.multistatus)(lodash_1.default.compact(res));
|
|
46
|
-
return (0, xBuild_1.build)(ms);
|
|
47
|
-
};
|
|
48
|
-
return {
|
|
49
|
-
exec
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
exports.default = default_1;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const xBuild_1 = require("../../common/xBuild");
|
|
7
|
-
const response_1 = require("../../common/response");
|
|
8
|
-
const winston_1 = __importDefault(require("../../common/winston"));
|
|
9
|
-
const propfind_1 = __importDefault(require("./propfind"));
|
|
10
|
-
// import routeReport from './report';
|
|
11
|
-
function default_1(opts) {
|
|
12
|
-
const log = (0, winston_1.default)(Object.assign(Object.assign({}, opts), { label: 'principal' }));
|
|
13
|
-
const methods = {
|
|
14
|
-
propfind: (0, propfind_1.default)(opts),
|
|
15
|
-
// report: reportReport(opts)
|
|
16
|
-
};
|
|
17
|
-
return async function (ctx) {
|
|
18
|
-
const method = ctx.method.toLowerCase();
|
|
19
|
-
(0, response_1.setMultistatusResponse)(ctx);
|
|
20
|
-
if (method === 'options') {
|
|
21
|
-
(0, response_1.setOptions)(ctx, ['OPTIONS', 'PROPFIND']);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (!methods[method]) {
|
|
25
|
-
log.warn(`method handler not found: ${method}`);
|
|
26
|
-
ctx.body = (0, xBuild_1.notFound)(ctx.url);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
ctx.body = await methods[method](ctx);
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
exports.default = default_1;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const xml = __importStar(require("../../common/xml"));
|
|
30
|
-
const xBuild_1 = require("../../common/xBuild");
|
|
31
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
32
|
-
const tags_1 = __importDefault(require("../../common/tags"));
|
|
33
|
-
function default_1(opts) {
|
|
34
|
-
const tags = (0, tags_1.default)(opts);
|
|
35
|
-
return async function (ctx) {
|
|
36
|
-
const { children } = xml.getWithChildren('/D:propfind/D:prop', ctx.request.xml);
|
|
37
|
-
const actions = lodash_1.default.map(children, async (child) => {
|
|
38
|
-
return await tags.getResponse({
|
|
39
|
-
resource: 'principal',
|
|
40
|
-
child,
|
|
41
|
-
ctx
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
const res = await Promise.all(actions);
|
|
45
|
-
const resps = (0, xBuild_1.response)(ctx.url, xBuild_1.status[200], lodash_1.default.compact(res));
|
|
46
|
-
const ms = (0, xBuild_1.multistatus)([resps]);
|
|
47
|
-
return (0, xBuild_1.build)(ms);
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
exports.default = default_1;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const xBuild_1 = require("../../common/xBuild");
|
|
7
|
-
const winston_1 = __importDefault(require("../../common/winston"));
|
|
8
|
-
function default_1(opts) {
|
|
9
|
-
const log = (0, winston_1.default)(Object.assign(Object.assign({}, opts), { label: 'principal/report' }));
|
|
10
|
-
return async function (ctx) {
|
|
11
|
-
const rootTag = ctx.request.xml.documentElement.localName;
|
|
12
|
-
if (rootTag === 'principal-search-property-set') {
|
|
13
|
-
log.debug('principal-search-property-set');
|
|
14
|
-
/* https://tools.ietf.org/html/rfc3744#section-9.5 */
|
|
15
|
-
return (0, xBuild_1.build)({
|
|
16
|
-
'D:principal-search-property-set': {
|
|
17
|
-
'@xmlns:D': 'DAV:'
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
else if (rootTag === 'principal-property-search') {
|
|
22
|
-
log.debug('principal-property-search');
|
|
23
|
-
/* https://tools.ietf.org/html/rfc3744#section-9.4 */
|
|
24
|
-
const blank = (0, xBuild_1.multistatus)();
|
|
25
|
-
return (0, xBuild_1.build)(blank);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
return (0, xBuild_1.notFound)(ctx.url);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
exports.default = default_1;
|