CalendaryInstance
CalendaryInstance class - the main instance
Example
Section titled “Example”// Default usageconst cal = calendary();
// With typed metadatainterface LiturgicalMetadata { rank: string; vestmentColor: string; }const cal = calendary<LiturgicalMetadata>();const day = cal.getDay("2025-12-25");day.events[0].metadata?.rank; // TypeScript knows this existsType Parameters
Section titled “Type Parameters”TMetadata
Section titled “TMetadata”TMetadata extends Record<string, unknown> = Record<string, unknown>
Custom metadata type for events
TCategory
Section titled “TCategory”TCategory extends string = string
Category type for events
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CalendaryInstance<
TMetadata,TCategory>(cfg?):CalendaryInstance<TMetadata,TCategory>
Parameters
Section titled “Parameters”Record<string, unknown>
Returns
Section titled “Returns”CalendaryInstance<TMetadata, TCategory>
Properties
Section titled “Properties”$isCalendary
Section titled “$isCalendary”$isCalendary:
boolean=true
Methods
Section titled “Methods”add(…
events):this
Add events without the group ceremony — they land in a shared "events"
group. Repeated calls accumulate; pass builders or plain configs.
Parameters
Section titled “Parameters”events
Section titled “events”…(Buildable | EventConfig)[]
Returns
Section titled “Returns”this
Example
Section titled “Example”cal.add( weekly("monday").title("Gym"), yearly(12, 25).title("Christmas"),);addGroup()
Section titled “addGroup()”addGroup(
config):this
Parameters
Section titled “Parameters”config
Section titled “config”Returns
Section titled “Returns”this
clone()
Section titled “clone()”clone():
CalendaryInstance<TMetadata,TCategory>
Clone this instance
Returns
Section titled “Returns”CalendaryInstance<TMetadata, TCategory>
getDay()
Section titled “getDay()”getDay(
date):CalendarDay<TMetadata,TCategory>
Get a single calendar day
Parameters
Section titled “Parameters”string | DateComponents
Returns
Section titled “Returns”CalendarDay<TMetadata, TCategory>
getDays()
Section titled “getDays()”getDays(
options):CalendarDay<TMetadata,TCategory>[]
Get calendar days for a date range
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”CalendarDay<TMetadata, TCategory>[]
getEvents()
Section titled “getEvents()”getEvents(
date):CalendarEvent<TMetadata,TCategory>[]
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”CalendarEvent<TMetadata, TCategory>[]
getEventsByGroup()
Section titled “getEventsByGroup()”getEventsByGroup(
groupId,from,to):CalendarEvent<TMetadata,TCategory>[]
Parameters
Section titled “Parameters”groupId
Section titled “groupId”string
string
string
Returns
Section titled “Returns”CalendarEvent<TMetadata, TCategory>[]
getEventsInRange()
Section titled “getEventsInRange()”getEventsInRange(
from,to):CalendarEvent<TMetadata,TCategory>[]
All occurrences in [from, to] (both inclusive), globally sorted: date
ascending, then priority descending (higher = on top), across every year in
the range — not just within a year. Ties keep generation order (stable). A
consumer can render the list directly without re-sorting.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”CalendarEvent<TMetadata, TCategory>[]
getGroup()
Section titled “getGroup()”getGroup(
groupId):Group|undefined
Parameters
Section titled “Parameters”groupId
Section titled “groupId”string
Returns
Section titled “Returns”Group | undefined
getGroups()
Section titled “getGroups()”getGroups():
Group[]
Returns
Section titled “Returns”Group[]
getSkipped()
Section titled “getSkipped()”getSkipped(
range):SkippedOccurrence<TMetadata>[]
Occurrences that WOULD have fallen in the range but were removed by an
exceptions skip (ICS EXDATE) — so a consumer can render them (e.g. a
struck-through “ghost”) without re-reading the event store. Moved occurrences
carry CalendarEvent.movedFrom on the normal output instead.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”SkippedOccurrence<TMetadata>[]
getUpcomingEvents()
Section titled “getUpcomingEvents()”getUpcomingEvents(
days):CalendarEvent<TMetadata,TCategory>[]
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”CalendarEvent<TMetadata, TCategory>[]
hasDayEnricher()
Section titled “hasDayEnricher()”hasDayEnricher(
name):boolean
Check if a day enricher is registered
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
hasPlugin()
Section titled “hasPlugin()”hasPlugin(
name):boolean
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
invalidateCache()
Section titled “invalidateCache()”invalidateCache():
this
Returns
Section titled “Returns”this
load()
Section titled “load()”load(
input,options?):this
Load a Collection — a portable bundle of events (a .cdy document is
its JSON form) — or a CollectionBundle carrying several named
collections, expanded into one group each (id/priority/color preserved). Pass
an object or a JSON string. Declared plugins must already be registered
(cal.use(...)); a clear error lists any that aren’t. Nothing is fetched or
executed behind your back.
options.priority overrides the priority of a single collection; for a bundle
each collection keeps its own (that’s the point of a bundle).
Parameters
Section titled “Parameters”string | Collection | CollectionBundle
options?
Section titled “options?”priority?
Section titled “priority?”number
Returns
Section titled “Returns”this
registerAnchor()
Section titled “registerAnchor()”registerAnchor(
name,fn):this
Register a named anchor — a year → Date resolver that relative events
(the builder’s from(anchor).plus(...)) offset from. Anchors share the
formula registry; this is the anchor-flavoured name for the same call.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”this
registerDayEnricher()
Section titled “registerDayEnricher()”registerDayEnricher(
enricher):this
Register a day enricher to add custom data to CalendarDay objects
Parameters
Section titled “Parameters”enricher
Section titled “enricher”Returns
Section titled “Returns”this
registerFormula()
Section titled “registerFormula()”registerFormula(
name,fn):this
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”this
removeGroup()
Section titled “removeGroup()”removeGroup(
groupId):this
Parameters
Section titled “Parameters”groupId
Section titled “groupId”string
Returns
Section titled “Returns”this
requiredPlugins()
Section titled “requiredPlugins()”requiredPlugins(
events?):string[]
The npm names of the registered plugins whose event types appear in events
— the minimal manifest a consumer must install + use(). Defaults to every
loaded event. This is the derivation toCollection uses, exposed so you
don’t re-implement a “plugins for these events” helper.
Parameters
Section titled “Parameters”events?
Section titled “events?”events to inspect (default: all loaded events, across groups).
Returns
Section titled “Returns”string[]
search()
Section titled “search()”search():
SearchBuilder<TMetadata,TCategory>
Create a search builder for advanced event queries. Supports text search, metadata search, categories, and more.
Every search needs a bounded window — recurrences are infinite, so
“search everything” has no meaning. Set it with .range(from, to),
.date(date), .year(y), or .month(y, m).
Returns
Section titled “Returns”SearchBuilder<TMetadata, TCategory>
Example
Section titled “Example”// Search by text (case-insensitive), within a yearcal.search().text('christmas').year(2026).getEvents();
// Search by metadatacal.search().metadata({ season: 'advent' }).year(2026).getEvents();
// Combined searchcal.search() .text('easter') .categories(['liturgical']) .range('2025-01-01', '2025-12-31') .sortBy('date', 'asc') .getEvents();setGroupEnabled()
Section titled “setGroupEnabled()”setGroupEnabled(
groupId,enabled):this
Parameters
Section titled “Parameters”groupId
Section titled “groupId”string
enabled
Section titled “enabled”boolean
Returns
Section titled “Returns”this
toBundle()
Section titled “toBundle()”toBundle(
options?):SerializedCollectionBundle
Export every group as a SerializedCollectionBundle — one collection
per group, each keeping its id / name / priority / color and its own
plugin manifest. The inverse of load() on a bundle; round-trips several named,
independently-styled collections through a single .cdy file (unlike
toCollection, which flattens every group’s events into one collection).
Parameters
Section titled “Parameters”options?
Section titled “options?”schema?
Section titled “schema?”string
version?
Section titled “version?”string
Returns
Section titled “Returns”toCollection()
Section titled “toCollection()”toCollection(
options?):SerializedCollection
Export events as a portable Collection — the inverse of load.
Serializes the plain event configs plus a manifest of the plugins their event
types need, so the result round-trips back through load(). Pass it to
JSON.stringify for a .cdy document.
Parameters
Section titled “Parameters”options?
Section titled “options?”group?
Section titled “group?”string
export a single group; omit to export every group’s events.
string
the collection name (also the default group id on re-load).
version?
Section titled “version?”string
an informational version stamp.
Returns
Section titled “Returns”use(
plugin):this
Register a plugin (use/extend)
Parameters
Section titled “Parameters”plugin
Section titled “plugin”Returns
Section titled “Returns”this