ProvenPin Install

ical-generator .ics feed round-tripped through node-ical: working versions (tested 2026-10-15)

Generate an iCalendar feed with ical-generator (escaped text, attendees, a weekly RRULE with an EXDATE) and parse it back with node-ical, expanding the recurrence offline.

passed3 passed · 0 failed2026-10-15 20:08 UTC
Status
passed
Last passed
2026-10-15 20:08 UTC
Tests
3 / 3
Language
TypeScript
Runtime
node v22.23.3
pinned versions4
ical-generator@11.1.2node-ical@0.27.3@types/node@26.6.5tsx@4.23.15
run it
npm install --no-audit --no-fund --ignore-scripts=false
npm test
test environment
node v22.23.3
linux 6.17.0-1022-azure
x64
runner: github-actions 38799498972

The code

Exactly the files that passed. Your agent can pull them with get_recipe("ical-generator-node-ical-roundtrip") (install), or see them on GitHub.

package.json
{
  "name": "ical-generator-node-ical-roundtrip",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node --import tsx --test test/*.test.ts"
  },
  "dependencies": {
    "ical-generator": "11.1.2",
    "node-ical": "0.27.3"
  },
  "devDependencies": {
    "@types/node": "26.6.5",
    "tsx": "4.23.15"
  }
}
src/calendar.ts
import ical, { ICalEventRepeatingFreq, ICalAttendeeRole } from "ical-generator";
import nodeIcal from "node-ical";

export type Session = { id: string; title: string; start: Date; end: Date; location: string };

/** Build an .ics feed: one-off sessions plus a weekly recurring office hour with an exception date. */
export function buildCalendar(sessions: Session[]) {
  const cal = ical({ name: "AIA Classes", prodId: { company: "provenpin", product: "recipes" }, timezone: "UTC" });
  for (const s of sessions) {
    cal.createEvent({
      id: s.id, start: s.start, end: s.end, summary: s.title, location: s.location,
      stamp: new Date("2026-10-01T00:00:00Z"),
      attendees: [{ email: "[email protected]", name: "Instructor", role: ICalAttendeeRole.CHAIR }],
    });
  }
  cal.createEvent({
    id: "office-hours", summary: "Office hours", stamp: new Date("2026-10-01T00:00:00Z"),
    start: new Date("2026-11-02T18:00:00Z"), end: new Date("2026-11-02T19:00:00Z"),
    repeating: { freq: ICalEventRepeatingFreq.WEEKLY, count: 4, exclude: [new Date("2026-11-16T18:00:00Z")] },
  });
  return cal.toString();
}

export function parseCalendar(ics: string) {
  const data = nodeIcal.sync.parseICS(ics);
  return Object.values(data)
    .filter((c): c is nodeIcal.VEvent => c.type === "VEVENT")
    .map((e) => ({
      uid: e.uid,
      summary: String(e.summary),
      start: new Date(e.start).toISOString(),
      end: new Date(e.end).toISOString(),
      location: e.location ? String(e.location) : null,
      rrule: e.rrule ? e.rrule.toString() : null,
      // node-ical keys each EXDATE under more than one lookup key, so de-duplicate
      exdates: e.exdate ? [...new Set(Object.values(e.exdate).map((d) => new Date(d as Date).toISOString()))] : [],
      occurrences: e.rrule ? e.rrule.all().map((d) => d.toISOString()) : [],
    }));
}
test/calendar.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { buildCalendar, parseCalendar } from "../src/calendar.ts";

const sessions = [
  { id: "cits-1", title: "CITS Orientation, Day 1", start: new Date("2026-11-01T17:00:00Z"), end: new Date("2026-11-02T01:00:00Z"), location: "Kenai, AK" },
  { id: "rig-1", title: "Rigging; slings, hitches", start: new Date("2026-11-05T17:00:00Z"), end: new Date("2026-11-05T21:00:00Z"), location: "Shop 2" },
];

test("generates valid iCalendar text", () => {
  const ics = buildCalendar(sessions);
  assert.match(ics, /^BEGIN:VCALENDAR\r\n/);
  assert.match(ics, /PRODID:-\/\/provenpin\/\/recipes\/\/EN/);
  assert.match(ics, /SUMMARY:Rigging\\; slings\\, hitches/); // RFC 5545 escaping
  assert.match(ics, /RRULE:FREQ=WEEKLY;COUNT=4/);
  assert.ok(ics.trimEnd().endsWith("END:VCALENDAR"));
});

test("round trips through node-ical", () => {
  const events = parseCalendar(buildCalendar(sessions));
  const byId = Object.fromEntries(events.map((e) => [e.uid, e]));
  assert.deepEqual(Object.keys(byId).sort(), ["cits-1", "office-hours", "rig-1"]);
  assert.equal(byId["rig-1"].summary, "Rigging; slings, hitches");
  assert.equal(byId["cits-1"].start, "2026-11-01T17:00:00.000Z");
  assert.equal(byId["cits-1"].end, "2026-11-02T01:00:00.000Z");
  assert.equal(byId["cits-1"].location, "Kenai, AK");
});

test("recurrence rule and exception dates survive", () => {
  const oh = parseCalendar(buildCalendar(sessions)).find((e) => e.uid === "office-hours")!;
  assert.match(oh.rrule!, /FREQ=WEEKLY;COUNT=4/);
  assert.deepEqual(oh.exdates, ["2026-11-16T18:00:00.000Z"]);
  const active = oh.occurrences.filter((d) => !oh.exdates.includes(d));
  assert.deepEqual(active, ["2026-11-02T18:00:00.000Z", "2026-11-09T18:00:00.000Z", "2026-11-23T18:00:00.000Z"]);
});

Connect to ProvenPin

Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.

terminal
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp

Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.