@miguelarios/cal-mcp 0.21.0 → 2.0.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/CHANGELOG.md +55 -0
- package/LICENSE +21 -0
- package/README.md +8 -5
- package/dist/providers/types.d.ts +18 -11
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/services/CalDavService.d.ts +6 -6
- package/dist/services/CalDavService.d.ts.map +1 -1
- package/dist/services/CalDavService.js +48 -44
- package/dist/services/CalDavService.js.map +1 -1
- package/dist/services/sharing.d.ts +2 -2
- package/dist/services/sharing.d.ts.map +1 -1
- package/dist/services/sharing.js +3 -3
- package/dist/services/sharing.js.map +1 -1
- package/dist/services/urlCache.d.ts +1 -1
- package/dist/services/urlCache.js +2 -2
- package/dist/services/urlCache.js.map +1 -1
- package/dist/tools/calendarManagementTools.d.ts.map +1 -1
- package/dist/tools/calendarManagementTools.js +18 -34
- package/dist/tools/calendarManagementTools.js.map +1 -1
- package/dist/tools/calendarSchemas.d.ts +55 -50
- package/dist/tools/calendarSchemas.d.ts.map +1 -1
- package/dist/tools/calendarSchemas.js +20 -19
- package/dist/tools/calendarSchemas.js.map +1 -1
- package/dist/tools/calendarTools.d.ts.map +1 -1
- package/dist/tools/calendarTools.js +147 -106
- package/dist/tools/calendarTools.js.map +1 -1
- package/dist/tools/presentEvent.d.ts +13 -0
- package/dist/tools/presentEvent.d.ts.map +1 -0
- package/dist/tools/presentEvent.js +72 -0
- package/dist/tools/presentEvent.js.map +1 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.0 (2026-11-17)
|
|
4
|
+
|
|
5
|
+
- **Breaking: event times come back in `PIM_TIMEZONE`, and all-day events as dates** (#162). Every event result (`list_events`, `get_today_events`, `search_events`, `get_event`, `create_event`, `update_event`, `move_event`, `create_events_batch`, `import_ics`) used to give `start`, `end` and `occurrenceDate` as UTC instants. All-day events were UTC midnight, which reads as the previous evening anywhere west of Greenwich. The values now look like this:
|
|
6
|
+
|
|
7
|
+
| Event | Was | Now |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| Timed, 8:30 Central | `2026-11-16T14:30:00.000Z` | `2026-11-16T08:30:00-06:00` |
|
|
10
|
+
| All-day, Nov 16 | `2026-11-16T00:00:00.000Z` | `2026-11-16` |
|
|
11
|
+
|
|
12
|
+
Timed values are the same instant as before, with the offset for that date (DST included), as `find_free_slots` already returned. All-day `end` is still exclusive. `occurrenceDate` follows the series: a date for an all-day series, even for an occurrence moved to a timed slot, and a local time otherwise. Both forms are accepted back as `occurrenceDate` by `get_event`, `update_event` and `delete_event`. If `PIM_TIMEZONE` is not a zone the runtime knows, times are rendered in UTC.
|
|
13
|
+
- **New `timeZone` field on every event:** the zone it was written in (`"America/Chicago"`), `"UTC"` for a UTC time, `null` for a floating time or an all-day event. A server that expands recurrences itself (SabreDAV/Nextcloud) rewrites instances to UTC, so those report `"UTC"`.
|
|
14
|
+
- Requires `@miguelarios/pim-core` 1.1.0.
|
|
15
|
+
|
|
16
|
+
## 1.0.0 (2026-10-18)
|
|
17
|
+
|
|
18
|
+
First stable release. The public contract, and what a minor or patch may change from here, is in [`docs/versioning.md`](../../docs/versioning.md).
|
|
19
|
+
|
|
20
|
+
- **Breaking: requires Node.js 22.12.0 or newer** (was 20.19.0). Node 20 reached end of life in April 2026, and raising the floor after 1.0 would need a major release (#150).
|
|
21
|
+
- **Breaking: errors use pim-core's `ErrorCode` values**, the same vocabulary as card-mcp and email-mcp (#150). The `message` and `retryable` fields are unchanged.
|
|
22
|
+
|
|
23
|
+
| Was | Now |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `validation_error` | `VALIDATION_FAILED`, or `INVALID_ICS` when `import_ics` content does not parse or has no events |
|
|
26
|
+
| `not_found` | `CALENDAR_NOT_FOUND` or `EVENT_NOT_FOUND` |
|
|
27
|
+
| `backend_error` | `WRITE_FAILED`, `OPERATION_FAILED`, `CONNECTION_FAILED`, `CONNECTION_TIMEOUT`, `AUTH_FAILED` or `INTERNAL_ERROR` |
|
|
28
|
+
|
|
29
|
+
- Caller mistakes that reached the server as `backend_error` are now caught first and reported as such: an unparseable or inverted `start`/`end` on `list_events`, `search_events` and `find_free_slots`, an unparseable date on `create_event` / `create_events_batch` (`VALIDATION_FAILED`), and unparseable `import_ics` content (`INVALID_ICS`).
|
|
30
|
+
- **`delete_event` with `span: "this"` no longer corrupts the series on an unparseable `occurrenceDate`.** It wrote `EXDATE:NaN-aNNaN…` into the event and reported success; it now fails with `VALIDATION_FAILED` before anything is written, as does `update_event` with `span: "this"`.
|
|
31
|
+
- **Breaking: every tool parameter and output field is camelCase**, like card-mcp and email-mcp (#150). Tool names and enum values are unchanged (`list_events`, `span: "this"`, `access: "read-write"`).
|
|
32
|
+
|
|
33
|
+
| Was | Now |
|
|
34
|
+
|---|---|
|
|
35
|
+
| `all_day` | `allDay` |
|
|
36
|
+
| `calendar_id` | `calendarId` |
|
|
37
|
+
| `can_be_published` | `canBePublished` |
|
|
38
|
+
| `can_be_shared` | `canBeShared` |
|
|
39
|
+
| `detail_level` | `detailLevel` |
|
|
40
|
+
| `display_name` | `displayName` |
|
|
41
|
+
| `exclude_calendars` | `excludeCalendars` |
|
|
42
|
+
| `ics_content` | `icsContent` |
|
|
43
|
+
| `ignore_tentative` | `ignoreTentative` |
|
|
44
|
+
| `include_all_day_as_busy` | `includeAllDayAsBusy` |
|
|
45
|
+
| `is_recurring` | `isRecurring` |
|
|
46
|
+
| `last_modified` | `lastModified` |
|
|
47
|
+
| `occurrence_date` | `occurrenceDate` |
|
|
48
|
+
| `preferred_end` | `preferredEnd` |
|
|
49
|
+
| `preferred_start` | `preferredStart` |
|
|
50
|
+
| `read_only` | `readOnly` |
|
|
51
|
+
| `recurrence_rule` | `recurrenceRule` |
|
|
52
|
+
| `target_calendar` | `targetCalendar` |
|
|
53
|
+
| `trigger_human` | `triggerHuman` |
|
|
54
|
+
| `unavailable_providers` | `unavailableProviders` |
|
|
55
|
+
- A CalDAV read's HTTP error is classified by its status rather than by words in the server's reply: a 500 whose page said "connection" was a retryable `CONNECTION_FAILED` (pim-core).
|
|
56
|
+
- Bumped `@miguelarios/pim-core` to `^1.0.0`. cal-mcp needs it: it returns core's renamed `/ics` fields as they are, so with a 0.x core its events would fail validation.
|
|
57
|
+
|
|
3
58
|
## 0.21.0 (2026-10-18)
|
|
4
59
|
|
|
5
60
|
- **Calendar sharing** (#47): `get_calendar_sharing` (who a calendar is shared with, at what access, and whether they accepted), `share_calendar` and `unshare_calendar` (both ask for confirmation). Reads CalendarServer sharing (mailbox.org / Open-Xchange, Apple), Nextcloud's ownCloud sharing, or WebDAV resource sharing, and writes in the dialect the server answered with. On Nextcloud the sharee is a principal such as `principals/users/bob`. See `docs/tools/cal-mcp.md`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Miguel Rios
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Every tool declares a `title`, all four behaviour annotations, and an `outputSch
|
|
|
9
9
|
|
|
10
10
|
`delete_event` asks the user to confirm whenever it removes the calendar object — `span: "all"`, and `span: "this"` on a non-recurring event. Excluding one occurrence of a recurring event is recoverable and is not gated. `delete_calendar` always asks, and so does an `update_event` with `span: "future"` that would drop per-occurrence changes. Set `PIM_MCP_CONFIRM=off` to skip confirmation in headless use.
|
|
11
11
|
|
|
12
|
-
Requires Node.js **
|
|
12
|
+
Requires Node.js **22.12.0 or newer**.
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
@@ -41,7 +41,7 @@ Add multiple providers by using different IDs: `CALDAV_NEXTCLOUD_URL`, `CALDAV_N
|
|
|
41
41
|
|
|
42
42
|
Optional env vars:
|
|
43
43
|
|
|
44
|
-
- `PIM_TIMEZONE` — IANA timezone used for "today", free-slot searches and
|
|
44
|
+
- `PIM_TIMEZONE` — IANA timezone used for "today", free-slot searches and the times events are returned in (`2026-11-16T08:30:00-06:00`; all-day events come back as plain dates, `2026-11-16`). Each event also carries `timeZone`, the zone it was written in. Defaults to the host timezone, which in a container is usually UTC.
|
|
45
45
|
- `CAL_MCP_DEBUG` — set to `1` to attach per-step CalDAV timings to tool results under `_meta`.
|
|
46
46
|
|
|
47
47
|
## Over HTTP and in Docker
|
|
@@ -53,14 +53,14 @@ docker run -d --name cal-mcp --restart unless-stopped --user node \
|
|
|
53
53
|
--env-file cal.env \
|
|
54
54
|
-e PIM_MCP_TRANSPORT=http -e PIM_MCP_HTTP_HOST=0.0.0.0 \
|
|
55
55
|
-p 127.0.0.1:3002:3000 -v cal-mcp-home:/home/node \
|
|
56
|
-
node:22-alpine npx -y @miguelarios/cal-mcp@0.
|
|
56
|
+
node:22-alpine npx -y @miguelarios/cal-mcp@2.0.0
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
See the [Docker guide](https://github.com/miguelarios/pim-agents/blob/main/docs/docker.md) for the env file, stdio use from a desktop client, Docker Compose, and exposing a server safely, and the [README](https://github.com/miguelarios/pim-agents/blob/main/README.md#over-streamable-http) for every HTTP setting.
|
|
60
60
|
|
|
61
|
-
## Tools (
|
|
61
|
+
## Tools (19)
|
|
62
62
|
|
|
63
|
-
See [docs/tools/cal-mcp.md](
|
|
63
|
+
See [docs/tools/cal-mcp.md](https://github.com/miguelarios/pim-agents/blob/main/docs/tools/cal-mcp.md) for full parameter and output details.
|
|
64
64
|
|
|
65
65
|
| Tool | Description |
|
|
66
66
|
|------|-------------|
|
|
@@ -80,6 +80,9 @@ See [docs/tools/cal-mcp.md](../../docs/tools/cal-mcp.md) for full parameter and
|
|
|
80
80
|
| `create_calendar` | Create a calendar collection |
|
|
81
81
|
| `update_calendar` | Rename or recolour a calendar |
|
|
82
82
|
| `delete_calendar` | Delete a calendar and every event in it |
|
|
83
|
+
| `get_calendar_sharing` | Who a calendar is shared with, at what access, and whether they accepted |
|
|
84
|
+
| `share_calendar` | Share a calendar with a person or group, read or read-write |
|
|
85
|
+
| `unshare_calendar` | Stop sharing a calendar with someone |
|
|
83
86
|
|
|
84
87
|
## License
|
|
85
88
|
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { FreeBusyPeriod, ParsedAlarm } from "@miguelarios/pim-core/ics";
|
|
6
6
|
export interface CalendarInfo {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
calendarId: string;
|
|
8
|
+
displayName: string;
|
|
9
9
|
color: string | null;
|
|
10
10
|
description: string | null;
|
|
11
11
|
/** IANA zone the calendar defaults to (`calendar-timezone`), when the provider reports one. */
|
|
@@ -13,28 +13,35 @@ export interface CalendarInfo {
|
|
|
13
13
|
/** Sort position among the account's calendars (Apple `calendar-order`), when reported. */
|
|
14
14
|
order: number | null;
|
|
15
15
|
source: string;
|
|
16
|
-
|
|
16
|
+
readOnly: boolean;
|
|
17
17
|
url: string;
|
|
18
18
|
ctag?: string;
|
|
19
19
|
}
|
|
20
20
|
/** A calendar collection as the management tools name it. */
|
|
21
21
|
export interface CalendarCollection {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
calendarId: string;
|
|
23
|
+
displayName: string;
|
|
24
24
|
url: string;
|
|
25
25
|
provider: string;
|
|
26
26
|
}
|
|
27
27
|
export interface EventSummary {
|
|
28
28
|
uid: string;
|
|
29
|
-
|
|
29
|
+
calendarId: string;
|
|
30
30
|
title: string;
|
|
31
31
|
start: string;
|
|
32
32
|
end: string;
|
|
33
|
-
|
|
33
|
+
allDay: boolean;
|
|
34
|
+
/** The TZID the event was written in; "UTC" for a UTC time, null when floating or all-day. */
|
|
35
|
+
timeZone: string | null;
|
|
34
36
|
location: string | null;
|
|
35
37
|
status: string | null;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
isRecurring: boolean;
|
|
39
|
+
occurrenceDate: string | null;
|
|
40
|
+
/**
|
|
41
|
+
* Internal: true when the RECURRENCE-ID is a date (an all-day series). The
|
|
42
|
+
* tool layer uses it to render `occurrenceDate` and strips it from results.
|
|
43
|
+
*/
|
|
44
|
+
occurrenceAllDay?: boolean;
|
|
38
45
|
}
|
|
39
46
|
export interface EventFull extends EventSummary {
|
|
40
47
|
description: string | null;
|
|
@@ -51,9 +58,9 @@ export interface EventFull extends EventSummary {
|
|
|
51
58
|
name: string | null;
|
|
52
59
|
email: string;
|
|
53
60
|
} | null;
|
|
54
|
-
|
|
61
|
+
recurrenceRule: string | null;
|
|
55
62
|
created: string | null;
|
|
56
|
-
|
|
63
|
+
lastModified: string | null;
|
|
57
64
|
alarms: ParsedAlarm[];
|
|
58
65
|
categories: string[];
|
|
59
66
|
geo: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7E,MAAM,WAAW,YAAY;IAC3B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7E,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,+FAA+F;IAC/F,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,2FAA2F;IAC3F,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,6DAA6D;AAC7D,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,8FAA8F;IAC9F,QAAQ,EAAE,MAAM,GAAG,IAAI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B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,iDAAiD;AACjD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEnD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,cAAc,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,WAAW,EAAE,mBAAmB,EAAE,CAAC;CACpC"}
|
|
@@ -56,7 +56,7 @@ export declare class CalDavService implements IcsCalendarBackend {
|
|
|
56
56
|
*/
|
|
57
57
|
listReachableCalendars(): Promise<ReachableCalendars>;
|
|
58
58
|
private listProviderCalendars;
|
|
59
|
-
/** The configured provider IDs — the prefix half of every `
|
|
59
|
+
/** The configured provider IDs — the prefix half of every `calendarId`. */
|
|
60
60
|
listProviders(): string[];
|
|
61
61
|
/**
|
|
62
62
|
* Picks the account a new calendar is created on.
|
|
@@ -68,7 +68,7 @@ export declare class CalDavService implements IcsCalendarBackend {
|
|
|
68
68
|
*/
|
|
69
69
|
private resolveProvider;
|
|
70
70
|
/**
|
|
71
|
-
* Resolves a
|
|
71
|
+
* Resolves a calendarId to the entry it names, so a caller can say what it
|
|
72
72
|
* is about to act on rather than echoing back the string it was handed.
|
|
73
73
|
*/
|
|
74
74
|
findCalendarEntry(calendarId: string): Promise<CalendarCollection>;
|
|
@@ -123,7 +123,7 @@ export declare class CalDavService implements IcsCalendarBackend {
|
|
|
123
123
|
/**
|
|
124
124
|
* Updates a calendar's display name, description and/or colour via PROPPATCH.
|
|
125
125
|
*
|
|
126
|
-
* Renaming changes the calendar's identity: `
|
|
126
|
+
* Renaming changes the calendar's identity: `calendarId` is
|
|
127
127
|
* `provider/DisplayName`, so the old ID stops resolving and the *new* one
|
|
128
128
|
* comes back in the result. The collection URL is untouched — display name
|
|
129
129
|
* and slug are allowed to drift, exactly as in every CalDAV client.
|
|
@@ -147,17 +147,17 @@ export declare class CalDavService implements IcsCalendarBackend {
|
|
|
147
147
|
* exactly as `list_events` would expand it. That covers a plain rule-generated
|
|
148
148
|
* occurrence and an override VEVENT alike: the override's fields (moved time,
|
|
149
149
|
* changed title) come back in place of the master's, which is what a caller
|
|
150
|
-
* holding an `
|
|
150
|
+
* holding an `occurrenceDate` from `list_events` needs (#39).
|
|
151
151
|
*/
|
|
152
152
|
private readEvent;
|
|
153
153
|
/**
|
|
154
154
|
* Expands the series over a two-day window around `occurrenceDate` and keeps
|
|
155
|
-
* the instance whose `
|
|
155
|
+
* the instance whose `occurrenceDate` is exactly that instant. The expansion
|
|
156
156
|
* filters on the rule-generated slot (the RECURRENCE-ID), not on an
|
|
157
157
|
* override's own DTSTART, so a moved override is found by its slot like any
|
|
158
158
|
* other occurrence. The window exists because the range is half-open
|
|
159
159
|
* `[start, end)`: a zero-width range would exclude the target itself. The
|
|
160
|
-
* exact match on `
|
|
160
|
+
* exact match on `occurrenceDate` then keeps the neighbours out.
|
|
161
161
|
*/
|
|
162
162
|
private pickOccurrence;
|
|
163
163
|
getEvent(calendarId: string, uid: string, occurrenceDate?: string): Promise<EventFull>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalDavService.d.ts","sourceRoot":"","sources":["../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IAoBvD,sFAAsF;YACxE,qBAAqB;IAqCnC,oEAAoE;IACpE,OAAO,CAAC,MAAM,CAAC,UAAU;IAWzB;;;;;;;;OAQG;YACW,mBAAmB;IAoCjC;;;;;;;OAOG;IACG,WAAW,CACf,WAAW,EAAE,MAAM,EAAE,EACrB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,cAAc,CAAC;IA+CpB,aAAa,CACjB,WAAW,EAAE,MAAM,EAAE,EACrB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,eAAe,EAAE,MAAM,EACvB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,QAAQ,EAAE,CAAC;IAyKtB,OAAO,CAAC,WAAW;IA4BnB,OAAO,CAAC,WAAW;CAOpB"}
|
|
@@ -406,7 +406,7 @@ export class CalDavService {
|
|
|
406
406
|
return true; // Default to writable on error
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
|
-
// Returns the CalDAV account username for the given
|
|
409
|
+
// Returns the CalDAV account username for the given calendarId. Used by
|
|
410
410
|
// the tool layer to populate ORGANIZER on events that include attendees —
|
|
411
411
|
// without this, strict CalDAV servers reject the PUT with 412 (see
|
|
412
412
|
// updateEvent and generateEventIcs for context).
|
|
@@ -468,14 +468,14 @@ export class CalDavService {
|
|
|
468
468
|
const displayName = displayNameOf(cal);
|
|
469
469
|
const canWrite = await this.fetchPrivileges(client, cal.url);
|
|
470
470
|
out.push({
|
|
471
|
-
|
|
472
|
-
|
|
471
|
+
calendarId: `${providerId}/${displayName}`,
|
|
472
|
+
displayName: displayName,
|
|
473
473
|
color: cal.calendarColor ?? null,
|
|
474
474
|
description: descriptionOf(cal),
|
|
475
475
|
timezone: timezoneOf(cal),
|
|
476
476
|
order: orderOf(cal),
|
|
477
477
|
source: providerId,
|
|
478
|
-
|
|
478
|
+
readOnly: !canWrite,
|
|
479
479
|
url: cal.url,
|
|
480
480
|
// tsdav parses a bare-integer <getctag> (Nextcloud) as a number. It
|
|
481
481
|
// is still a valid change marker, so keep it, as the string it is typed as.
|
|
@@ -487,7 +487,7 @@ export class CalDavService {
|
|
|
487
487
|
}
|
|
488
488
|
return out;
|
|
489
489
|
}
|
|
490
|
-
/** The configured provider IDs — the prefix half of every `
|
|
490
|
+
/** The configured provider IDs — the prefix half of every `calendarId`. */
|
|
491
491
|
listProviders() {
|
|
492
492
|
return [...this.accounts.keys()];
|
|
493
493
|
}
|
|
@@ -516,7 +516,7 @@ export class CalDavService {
|
|
|
516
516
|
throw new ValidationError(`provider is required when several accounts are configured — choose one of: ${known.join(", ")}`, "provider");
|
|
517
517
|
}
|
|
518
518
|
/**
|
|
519
|
-
* Resolves a
|
|
519
|
+
* Resolves a calendarId to the entry it names, so a caller can say what it
|
|
520
520
|
* is about to act on rather than echoing back the string it was handed.
|
|
521
521
|
*/
|
|
522
522
|
async findCalendarEntry(calendarId) {
|
|
@@ -525,8 +525,8 @@ export class CalDavService {
|
|
|
525
525
|
const client = await this.getClient(account);
|
|
526
526
|
const calendar = await this.findCalendar(client, calendarName, account.id);
|
|
527
527
|
return {
|
|
528
|
-
|
|
529
|
-
|
|
528
|
+
calendarId: calendarId,
|
|
529
|
+
displayName: calendarName,
|
|
530
530
|
url: calendar.url,
|
|
531
531
|
provider: account.id,
|
|
532
532
|
};
|
|
@@ -590,7 +590,7 @@ export class CalDavService {
|
|
|
590
590
|
throw new ValidationError("sharee is required", "sharee");
|
|
591
591
|
const before = await this.getCalendarSharing(calendarId);
|
|
592
592
|
const protocol = before.protocol;
|
|
593
|
-
if (!before.
|
|
593
|
+
if (!before.canBeShared || (protocol !== "calendarserver" && protocol !== "owncloud")) {
|
|
594
594
|
throw new ValidationError(`Calendar "${calendarId}" cannot be shared through this server: it reports neither CalendarServer nor Nextcloud sharing`, "calendar");
|
|
595
595
|
}
|
|
596
596
|
let body;
|
|
@@ -668,11 +668,11 @@ export class CalDavService {
|
|
|
668
668
|
*/
|
|
669
669
|
async createCalendar(opts) {
|
|
670
670
|
const account = this.resolveProvider(opts.provider);
|
|
671
|
-
// A calendar with no display name has no addressable
|
|
671
|
+
// A calendar with no display name has no addressable calendarId at all —
|
|
672
672
|
// `provider/` resolves to nothing — so creating one is refused rather than
|
|
673
673
|
// quietly made unreachable.
|
|
674
674
|
if (opts.displayName.trim() === "") {
|
|
675
|
-
throw new ValidationError("
|
|
675
|
+
throw new ValidationError("displayName cannot be empty", "displayName");
|
|
676
676
|
}
|
|
677
677
|
if (opts.slug !== undefined && !/^[a-z0-9][a-z0-9-]{0,62}$/.test(opts.slug)) {
|
|
678
678
|
throw new ValidationError(`Invalid slug "${opts.slug}" — use lowercase letters, digits and hyphens, starting with a letter or digit`, "slug");
|
|
@@ -683,7 +683,7 @@ export class CalDavService {
|
|
|
683
683
|
const client = await this.getClient(account);
|
|
684
684
|
const existing = await this.fetchCalendarsFor(client, account.id);
|
|
685
685
|
// A second calendar with the same display name on the same provider would
|
|
686
|
-
// make its
|
|
686
|
+
// make its calendarId ambiguous on *every subsequent call* — the name is
|
|
687
687
|
// not a convenience alias here, it is half the ID, and findCalendar
|
|
688
688
|
// resolves every event operation by exact display-name match. So duplicates
|
|
689
689
|
// are refused rather than suffixed; that also keeps a retried create from
|
|
@@ -745,8 +745,8 @@ export class CalDavService {
|
|
|
745
745
|
// that cache — so drop it or the calendar stays invisible to this process.
|
|
746
746
|
this.calendarsCache.delete(account.id);
|
|
747
747
|
return {
|
|
748
|
-
|
|
749
|
-
|
|
748
|
+
calendarId: `${account.id}/${opts.displayName}`,
|
|
749
|
+
displayName: opts.displayName,
|
|
750
750
|
url,
|
|
751
751
|
provider: account.id,
|
|
752
752
|
};
|
|
@@ -754,7 +754,7 @@ export class CalDavService {
|
|
|
754
754
|
/**
|
|
755
755
|
* Updates a calendar's display name, description and/or colour via PROPPATCH.
|
|
756
756
|
*
|
|
757
|
-
* Renaming changes the calendar's identity: `
|
|
757
|
+
* Renaming changes the calendar's identity: `calendarId` is
|
|
758
758
|
* `provider/DisplayName`, so the old ID stops resolving and the *new* one
|
|
759
759
|
* comes back in the result. The collection URL is untouched — display name
|
|
760
760
|
* and slug are allowed to drift, exactly as in every CalDAV client.
|
|
@@ -765,10 +765,10 @@ export class CalDavService {
|
|
|
765
765
|
opts.color === undefined &&
|
|
766
766
|
opts.timezone === undefined &&
|
|
767
767
|
opts.order === undefined) {
|
|
768
|
-
throw new ValidationError("Nothing to change — provide a
|
|
768
|
+
throw new ValidationError("Nothing to change — provide a displayName, color, description, timezone and/or order");
|
|
769
769
|
}
|
|
770
770
|
if (opts.displayName !== undefined && opts.displayName.trim() === "") {
|
|
771
|
-
throw new ValidationError("
|
|
771
|
+
throw new ValidationError("displayName cannot be empty", "displayName");
|
|
772
772
|
}
|
|
773
773
|
const color = opts.color !== undefined ? normalizeCalendarColor(opts.color) : undefined;
|
|
774
774
|
const timezone = opts.timezone !== undefined ? normalizeCalendarTimezone(opts.timezone) : undefined;
|
|
@@ -777,7 +777,7 @@ export class CalDavService {
|
|
|
777
777
|
const client = await this.getClient(account);
|
|
778
778
|
const calendar = await this.findCalendar(client, calendarName, account.id);
|
|
779
779
|
const url = calendar.url;
|
|
780
|
-
// Renaming onto a name already in use would make that
|
|
780
|
+
// Renaming onto a name already in use would make that calendarId ambiguous
|
|
781
781
|
// — the same reason create refuses duplicates. The calendar being renamed is
|
|
782
782
|
// excluded so re-applying its own name stays a no-op rather than an error.
|
|
783
783
|
if (opts.displayName !== undefined) {
|
|
@@ -823,12 +823,12 @@ export class CalDavService {
|
|
|
823
823
|
const newDisplayName = opts.displayName ?? calendarName;
|
|
824
824
|
const newCalendarId = `${account.id}/${newDisplayName}`;
|
|
825
825
|
this.calendarsCache.delete(account.id);
|
|
826
|
-
// The UID→URL cache is keyed by
|
|
826
|
+
// The UID→URL cache is keyed by calendarId; a rename leaves its entries
|
|
827
827
|
// valid but filed under a key nothing looks up again.
|
|
828
828
|
moveCachedCalendar(calendarId, newCalendarId);
|
|
829
829
|
return {
|
|
830
|
-
|
|
831
|
-
|
|
830
|
+
calendarId: newCalendarId,
|
|
831
|
+
displayName: newDisplayName,
|
|
832
832
|
url,
|
|
833
833
|
provider: account.id,
|
|
834
834
|
};
|
|
@@ -852,8 +852,8 @@ export class CalDavService {
|
|
|
852
852
|
this.calendarsCache.delete(account.id);
|
|
853
853
|
purgeCachedCalendar(calendarId);
|
|
854
854
|
return {
|
|
855
|
-
|
|
856
|
-
|
|
855
|
+
calendarId: calendarId,
|
|
856
|
+
displayName: calendarName,
|
|
857
857
|
url,
|
|
858
858
|
provider: account.id,
|
|
859
859
|
};
|
|
@@ -893,15 +893,17 @@ export class CalDavService {
|
|
|
893
893
|
}
|
|
894
894
|
summaries.push({
|
|
895
895
|
uid: event.uid,
|
|
896
|
-
|
|
896
|
+
calendarId: calendarId,
|
|
897
897
|
title: event.title,
|
|
898
898
|
start: event.start,
|
|
899
899
|
end: event.end,
|
|
900
|
-
|
|
900
|
+
allDay: event.allDay,
|
|
901
|
+
timeZone: event.timeZone,
|
|
901
902
|
location: event.location,
|
|
902
903
|
status: event.status,
|
|
903
|
-
|
|
904
|
-
|
|
904
|
+
isRecurring: event.isRecurring,
|
|
905
|
+
occurrenceDate: event.occurrenceDate,
|
|
906
|
+
occurrenceAllDay: event.occurrenceAllDay,
|
|
905
907
|
});
|
|
906
908
|
}
|
|
907
909
|
}
|
|
@@ -946,7 +948,7 @@ export class CalDavService {
|
|
|
946
948
|
* exactly as `list_events` would expand it. That covers a plain rule-generated
|
|
947
949
|
* occurrence and an override VEVENT alike: the override's fields (moved time,
|
|
948
950
|
* changed title) come back in place of the master's, which is what a caller
|
|
949
|
-
* holding an `
|
|
951
|
+
* holding an `occurrenceDate` from `list_events` needs (#39).
|
|
950
952
|
*/
|
|
951
953
|
async readEvent(calendarId, uid, occurrenceDate) {
|
|
952
954
|
const { account, calendarName } = this.resolveAccount(calendarId);
|
|
@@ -975,29 +977,29 @@ export class CalDavService {
|
|
|
975
977
|
}
|
|
976
978
|
/**
|
|
977
979
|
* Expands the series over a two-day window around `occurrenceDate` and keeps
|
|
978
|
-
* the instance whose `
|
|
980
|
+
* the instance whose `occurrenceDate` is exactly that instant. The expansion
|
|
979
981
|
* filters on the rule-generated slot (the RECURRENCE-ID), not on an
|
|
980
982
|
* override's own DTSTART, so a moved override is found by its slot like any
|
|
981
983
|
* other occurrence. The window exists because the range is half-open
|
|
982
984
|
* `[start, end)`: a zero-width range would exclude the target itself. The
|
|
983
|
-
* exact match on `
|
|
985
|
+
* exact match on `occurrenceDate` then keeps the neighbours out.
|
|
984
986
|
*/
|
|
985
987
|
pickOccurrence(data, uid, master, occurrenceDate) {
|
|
986
988
|
const target = new Date(occurrenceDate).getTime();
|
|
987
989
|
if (Number.isNaN(target)) {
|
|
988
|
-
throw new ValidationError(`Invalid
|
|
990
|
+
throw new ValidationError(`Invalid occurrenceDate "${occurrenceDate}" — use an ISO 8601 date-time`, "occurrenceDate");
|
|
989
991
|
}
|
|
990
|
-
if (!master.
|
|
991
|
-
throw new ValidationError(`Event "${uid}" is not recurring — omit
|
|
992
|
+
if (!master.isRecurring) {
|
|
993
|
+
throw new ValidationError(`Event "${uid}" is not recurring — omit occurrenceDate to read it`, "occurrenceDate");
|
|
992
994
|
}
|
|
993
995
|
const DAY = 86_400_000;
|
|
994
996
|
const window = {
|
|
995
997
|
start: new Date(target - DAY).toISOString(),
|
|
996
998
|
end: new Date(target + DAY).toISOString(),
|
|
997
999
|
};
|
|
998
|
-
const hit = parseIcsEvents(data, window, this.timezone).find((e) => e.uid === uid && e.
|
|
1000
|
+
const hit = parseIcsEvents(data, window, this.timezone).find((e) => e.uid === uid && e.occurrenceDate !== null && Date.parse(e.occurrenceDate) === target);
|
|
999
1001
|
if (!hit) {
|
|
1000
|
-
throw new CalendarError(`Event "${uid}" has no occurrence at ${occurrenceDate} —
|
|
1002
|
+
throw new CalendarError(`Event "${uid}" has no occurrence at ${occurrenceDate} — occurrenceDate must be a value list_events returned for it`, ErrorCode.EVENT_NOT_FOUND, uid);
|
|
1001
1003
|
}
|
|
1002
1004
|
return hit;
|
|
1003
1005
|
}
|
|
@@ -1248,8 +1250,8 @@ export class CalDavService {
|
|
|
1248
1250
|
end: event.end,
|
|
1249
1251
|
status: event.status,
|
|
1250
1252
|
availability: event.availability,
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
+
allDay: event.allDay,
|
|
1254
|
+
calendarId: calendarId,
|
|
1253
1255
|
});
|
|
1254
1256
|
}
|
|
1255
1257
|
}
|
|
@@ -1264,7 +1266,7 @@ export class CalDavService {
|
|
|
1264
1266
|
/** Which candidates actually block time under the given options. */
|
|
1265
1267
|
static blocksTime(e, options) {
|
|
1266
1268
|
// Skip all-day events unless includeAllDayAsBusy
|
|
1267
|
-
if (e.
|
|
1269
|
+
if (e.allDay && !options.includeAllDayAsBusy)
|
|
1268
1270
|
return false;
|
|
1269
1271
|
// Skip free events
|
|
1270
1272
|
if (e.availability === "free")
|
|
@@ -1507,23 +1509,25 @@ export class CalDavService {
|
|
|
1507
1509
|
toEventFull(event, calendarId) {
|
|
1508
1510
|
return {
|
|
1509
1511
|
uid: event.uid,
|
|
1510
|
-
|
|
1512
|
+
calendarId: calendarId,
|
|
1511
1513
|
title: event.title,
|
|
1512
1514
|
start: event.start,
|
|
1513
1515
|
end: event.end,
|
|
1514
|
-
|
|
1516
|
+
allDay: event.allDay,
|
|
1517
|
+
timeZone: event.timeZone,
|
|
1515
1518
|
location: event.location,
|
|
1516
1519
|
status: event.status,
|
|
1517
|
-
|
|
1518
|
-
|
|
1520
|
+
isRecurring: event.isRecurring,
|
|
1521
|
+
occurrenceDate: event.occurrenceDate,
|
|
1522
|
+
occurrenceAllDay: event.occurrenceAllDay,
|
|
1519
1523
|
description: event.description,
|
|
1520
1524
|
url: event.url,
|
|
1521
1525
|
availability: event.availability,
|
|
1522
1526
|
attendees: event.attendees,
|
|
1523
1527
|
organizer: event.organizer,
|
|
1524
|
-
|
|
1528
|
+
recurrenceRule: event.recurrenceRule,
|
|
1525
1529
|
created: event.created,
|
|
1526
|
-
|
|
1530
|
+
lastModified: event.lastModified,
|
|
1527
1531
|
alarms: event.alarms,
|
|
1528
1532
|
categories: event.categories,
|
|
1529
1533
|
geo: event.geo,
|