caldav-adapter 4.2.0 → 4.3.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.
@@ -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);
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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,8 +32,8 @@ const lodash_1 = __importDefault(require("lodash"));
28
32
  const propfind_1 = __importDefault(require("../calendar/propfind"));
29
33
  const tags_1 = __importDefault(require("../../../common/tags"));
30
34
  function default_1(opts) {
31
- const { calendarResponse } = propfind_1.default(opts);
32
- const tags = tags_1.default(opts);
35
+ const { calendarResponse } = (0, propfind_1.default)(opts);
36
+ const tags = (0, tags_1.default)(opts);
33
37
  const exec = async function (ctx) {
34
38
  const { children } = xml.getWithChildren('/D:propfind/D:prop', ctx.request.xml);
35
39
  const checksum = lodash_1.default.some(children, (child) => child.localName === 'checksum-versions');
@@ -42,7 +46,7 @@ function default_1(opts) {
42
46
  });
43
47
  const res = await Promise.all(actions);
44
48
  const props = lodash_1.default.compact(res);
45
- const responses = [xBuild_1.response(ctx.url, props.length ? xBuild_1.status[200] : xBuild_1.status[404], props)];
49
+ const responses = [(0, xBuild_1.response)(ctx.url, props.length ? xBuild_1.status[200] : xBuild_1.status[404], props)];
46
50
  const calendars = await opts.data.getCalendarsForPrincipal({
47
51
  principalId: ctx.state.params.principalId,
48
52
  user: ctx.state.user
@@ -50,8 +54,8 @@ function default_1(opts) {
50
54
  const calResponses = !checksum ? await Promise.all(calendars.map(async (cal) => {
51
55
  return await calendarResponse(ctx, cal);
52
56
  })) : [];
53
- const ms = xBuild_1.multistatus([...responses, ...lodash_1.default.compact(calResponses)]);
54
- return xBuild_1.build(ms);
57
+ const ms = (0, xBuild_1.multistatus)([...responses, ...lodash_1.default.compact(calResponses)]);
58
+ return (0, xBuild_1.build)(ms);
55
59
  };
56
60
  return {
57
61
  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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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) {
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) => {
@@ -38,8 +42,8 @@ function default_1(opts) {
38
42
  });
39
43
  });
40
44
  const res = await Promise.all(actions);
41
- const ms = xBuild_1.multistatus(lodash_1.default.compact(res));
42
- return xBuild_1.build(ms);
45
+ const ms = (0, xBuild_1.multistatus)(lodash_1.default.compact(res));
46
+ return (0, xBuild_1.build)(ms);
43
47
  };
44
48
  return {
45
49
  exec
@@ -9,20 +9,21 @@ const winston_1 = __importDefault(require("../../common/winston"));
9
9
  const propfind_1 = __importDefault(require("./propfind"));
10
10
  // import routeReport from './report';
11
11
  function default_1(opts) {
12
- const log = winston_1.default(Object.assign(Object.assign({}, opts), { label: 'principal' }));
12
+ const log = (0, winston_1.default)(Object.assign(Object.assign({}, opts), { label: 'principal' }));
13
13
  const methods = {
14
- propfind: propfind_1.default(opts),
14
+ propfind: (0, propfind_1.default)(opts),
15
+ // report: reportReport(opts)
15
16
  };
16
17
  return async function (ctx) {
17
18
  const method = ctx.method.toLowerCase();
18
- response_1.setMultistatusResponse(ctx);
19
+ (0, response_1.setMultistatusResponse)(ctx);
19
20
  if (method === 'options') {
20
- response_1.setOptions(ctx, ['OPTIONS', 'PROPFIND']);
21
+ (0, response_1.setOptions)(ctx, ['OPTIONS', 'PROPFIND']);
21
22
  return;
22
23
  }
23
24
  if (!methods[method]) {
24
25
  log.warn(`method handler not found: ${method}`);
25
- ctx.body = xBuild_1.notFound(ctx.url);
26
+ ctx.body = (0, xBuild_1.notFound)(ctx.url);
26
27
  return;
27
28
  }
28
29
  ctx.body = await methods[method](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.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
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
  return async function (ctx) {
32
36
  const { children } = xml.getWithChildren('/D:propfind/D:prop', ctx.request.xml);
33
37
  const actions = lodash_1.default.map(children, async (child) => {
@@ -38,9 +42,9 @@ function default_1(opts) {
38
42
  });
39
43
  });
40
44
  const res = await Promise.all(actions);
41
- const resps = xBuild_1.response(ctx.url, xBuild_1.status[200], lodash_1.default.compact(res));
42
- const ms = xBuild_1.multistatus([resps]);
43
- return xBuild_1.build(ms);
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);
44
48
  };
45
49
  }
46
50
  exports.default = default_1;
@@ -6,13 +6,13 @@ 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: 'principal/report' }));
9
+ const log = (0, winston_1.default)(Object.assign(Object.assign({}, opts), { label: 'principal/report' }));
10
10
  return async function (ctx) {
11
11
  const rootTag = ctx.request.xml.documentElement.localName;
12
12
  if (rootTag === 'principal-search-property-set') {
13
13
  log.debug('principal-search-property-set');
14
14
  /* https://tools.ietf.org/html/rfc3744#section-9.5 */
15
- return xBuild_1.build({
15
+ return (0, xBuild_1.build)({
16
16
  'D:principal-search-property-set': {
17
17
  '@xmlns:D': 'DAV:'
18
18
  }
@@ -21,11 +21,11 @@ function default_1(opts) {
21
21
  else if (rootTag === 'principal-property-search') {
22
22
  log.debug('principal-property-search');
23
23
  /* https://tools.ietf.org/html/rfc3744#section-9.4 */
24
- const blank = xBuild_1.multistatus();
25
- return xBuild_1.build(blank);
24
+ const blank = (0, xBuild_1.multistatus)();
25
+ return (0, xBuild_1.build)(blank);
26
26
  }
27
27
  else {
28
- return xBuild_1.notFound(ctx.url);
28
+ return (0, xBuild_1.notFound)(ctx.url);
29
29
  }
30
30
  };
31
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caldav-adapter",
3
- "version": "4.2.0",
3
+ "version": "4.3.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "description": "Middleware to handle CalDAV requests to node web server.",
@@ -17,37 +17,37 @@
17
17
  "scripts": {
18
18
  "build": "tsc",
19
19
  "eslint": "eslint --ext .ts src/**",
20
- "prepare": "npm run eslint && npm run build",
20
+ "test": "npm run eslint && npm run build",
21
21
  "watch": "nodemon -e js --ignore node_modules/ --inspect example/server.js"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/ical": "^0.6.1",
25
- "@types/koa": "^2.11.3",
26
- "@types/lodash": "^4.14.151",
27
- "@types/node": "^14.0.1",
28
- "@types/xmldom": "^0.1.29",
29
- "@typescript-eslint/eslint-plugin": "^2.31.0",
30
- "@typescript-eslint/parser": "^2.31.0",
31
- "eslint": "^6.8.0",
32
- "koa": "^2.11.0",
33
- "koa-compress": "^4.0.1",
25
+ "@types/koa": "^2.13.12",
26
+ "@types/lodash": "^4.14.202",
27
+ "@types/node": "^20.10.6",
28
+ "@types/xmldom": "^0.1.34",
29
+ "@typescript-eslint/eslint-plugin": "^6.16.0",
30
+ "@typescript-eslint/parser": "^6.16.0",
31
+ "eslint": "^8.56.0",
32
+ "koa": "^2.15.0",
33
+ "koa-compress": "^5.1.1",
34
34
  "koa-morgan": "^1.0.1",
35
- "nodemon": "^2.0.4",
36
- "typescript": "^3.9.2"
35
+ "nodemon": "^3.0.2",
36
+ "typescript": "^5.3.3"
37
37
  },
38
38
  "dependencies": {
39
39
  "basic-auth": "^2.0.1",
40
40
  "ical": "^0.8.0",
41
41
  "ical-generator": "^1.10.0",
42
- "lodash": "^4.17.15",
43
- "moment": "^2.25.3",
44
- "moment-timezone": "^0.5.28",
45
- "path-to-regexp": "^6.1.0",
46
- "raw-body": "^2.4.1",
47
- "rrule": "^2.6.4",
48
- "winston": "^3.2.0",
49
- "xmlbuilder2": "^2.1.2",
50
- "xmldom": "^0.3.0",
51
- "xpath": "0.0.27"
42
+ "lodash": "^4.17.21",
43
+ "moment": "^2.30.1",
44
+ "moment-timezone": "^0.5.44",
45
+ "path-to-regexp": "^6.2.1",
46
+ "raw-body": "^2.5.2",
47
+ "rrule": "^2.8.1",
48
+ "winston": "^3.11.0",
49
+ "xmlbuilder2": "^3.1.1",
50
+ "xmldom": "^0.6.0",
51
+ "xpath": "0.0.34"
52
52
  }
53
53
  }