caldav in JavaScript; made easy.
The caldav and ICS specifications are large. Additionally, I'm not sure I ever want to implement them completely. But I saw the need to a simple module that works with e.g. radicale and provides decent developer experience. simple-caldav is that attempt.
$ npm i --save simple-caldavconst SimpleCalDAV = require("simple-caldav");
const URI = "https://example.com/cal/";
const dav = new SimpleCalDAV(URI, { credentials: "include", mode: "cors"});
const evt = dav.getEvent("abc")
.then(console.log)
.catch(console.log);For now, see tests.
- We translate a VEVENT's
STATUS&LOCATIONin the whole library to the name_status&_locationto make sure we're not violating any reserved words rules of JavaScript. - When initializing
new SimpleCalDAVfetchrequest options can be supplied on the second parameter (type object).
When using simple-caldav in combination with a remote server and CORS starts
to become an issue, make sure you allow the following CORS properties:
- methods that need to be allowed:
GET, POST, PUT, DELETE, REPORT, PROPFIND, OPTIONS - headers that need to be allowed:
Content-Type,If-None-Match,Depth
$ git clone [email protected]:TimDaub/simple-caldav.git
$ cd simple-caldav && npm i
$ npm run testThe process outlined in PUBLISH.md SHOULD be followed when releasing a new version of simple-caldav.
- Add
;LANGUAGE=localeto VEVENT & VALARMdescription,summary,location. Function interfaces and return values have changed therefore. Instead of strings, an object of the shape{ value: "string, language: "locale"}is now required. Thelanguageprop is optional. - In some cases
subjectwas wrongly used instead ofsummary. All occurrences have been changed tosummary. - Some internal code now uses optional chaining, which is why node requires a version > 14 now.
0.7.1 (came after 0.8.0, branch)
- Bump a few dependencies' versions to fix vulnerabilities
- Instead of passing
fetch'scredentialsoption as"include"by default, it's now possible to addfetchrequest options when initializing theSimpleCalDAVclass. credentials: "include"aren't passed as default anymore.
- For all
fetchrequests, allow passing credentials by usingcredentials: true - Add note on CORS
- Remove
xpathandxmldomdependencies for smaller builds. - Remove
getETagsmethod.
0.4.7 (after 0.5.0, branch)
- Upgrade xmldom to v0.5.0
- Add
static applyDuration(date, duration)that allows applying an specifically-shaped duration to a JavaScriptDate.
- Add VALUE=DATE-TIME to absolute-time trigger in VALARM.
- Add support for relative
triggers.
RELATED=syntax not yet supported.
- When updating an event, alarm's attendee would wrongly collect action
prefixes like
mailto:orsms:, e.g.mailto:mailto:mailto:[email protected].
- Include
hrefto event when callinggetEventorlistEvents.
- Add
LOCATIONproperty to VEVENT. - Add
ORGANIZER;CN=:mailtoproperty to VEVENT.
- Fix UTC time zone shift calculation in
formatDateTime.
- Switched out moment.js with
date-fns. Breaking change is thatformatDateTimenow only acceptsDateobjects, or throws otherwise.
- Bug fix: When adding multiple alarms,
,BEGIN:VALARMwould show up in VEVENT text.
- Bug fix: When adding a status to an event, in its ical representation status
statement didn't add new
\nnew line instruction.
- Add static
SimpleCalDAV.extractUid(href)method.
- Add
_statusproperty to event.
- Bug fix:
syncCollectionwasn't able to detect a single VEVENT deletion event and simply returned an empty array.
- Bug fix: Stop attempting to parse relative-time VALARMS, as ical.js isn't capable of doing that either. Relative-time VALARMS are now ignored instead. Previously they threw.
- Bug fix: Ensure correct order of
etagandhrefproperties returned fromsyncCollection.
- Introduce new method for retrieving single events with
uid:getEvent(uid). - Parse and include
VALARMs ingetEventandlistEvents.
- Removed
TraversalErrorfrom code base entirely. listEventsnow returns an empty array when no events are found or an invalid xml gets passed.- Instead of throwing
TraversalError,SimpleCalDAV.traverseXMLnow returns an empty array when path couldn't be found. - Added
getSyncTokenmethod to retrieve a sync token from a server. - Added
syncCollectionto receive a diff of an entire collection with a sync token. - Added
ServerErrorthat is thrown when there are problems with the server.
- Fix bug in VALARM construction.
- Fix bug in VEVENT construction.
- Allow adding VALARMS to VEVENTS.
- Transform ical.js events to simple JSON objects and all customizable
transformation parameter on
listEventsmethod.
- Initial release.
[WIP]