@bimetal/calendar-data
v0.17.0
Published
Calendar-domain event-sourcing: CalendarEvent commands/events, calendarAggregate, calendarProjection, createCalendarStore. Built on @bimetal/event-sourcing.
Maintainers
Readme
@bimetal/calendar-data
Calendar-domain event sourcing. Builds on @bimetal/event-sourcing and adds the calendar aggregate, projection, command factories, and createCalendarStore.
Installation
npm install @bimetal/calendar-dataWhat's Inside
Domain
CalendarEventData— mutable fields of aCalendarEvent(title, timeRange, allDay, metadata, domains, recurrence, exceptions, resourceId)CalendarReadModel—{ events: readonly CalendarEvent[]; version: number }
Domain Events
CalendarEventCreated/Updated/Deleted/Reverted- Union:
CalendarDomainEvent
Commands
CreateCalendarEvent,UpdateCalendarEvent,DeleteCalendarEventUndoLastChange— pops the per-entity undo stackModifyInstance,DeleteInstance— recurring-event instance ops- Union:
CalendarCommand
Command Factories
createEvent,updateEvent,deleteEvent,undoLastChange,modifyInstance,deleteInstance
Facade
CalendarStore— extendsDomainStore<AggregateState, CalendarCommand, CalendarDomainEvent, CalendarReadModel>withgetEvents()andgetEventsInRange(start, end)createCalendarStore(config?)— main entry pointHydratableCalendarStore— addshydrate()andrebuild()
Calendar-flavored generics (with T = CalendarEvent defaults)
AggregateState,AggregateSnapshot,SnapshotStore— aliases of the generic versions in@bimetal/event-sourcing
Convenience Re-exports
For ergonomics, the most commonly used generic primitives from @bimetal/event-sourcing are re-exported: DomainEvent, Command, EventStore, EventBus, Projection, Aggregate, Unsubscribe, EventMetadataProvider, createInMemoryEventStore, createEventBus, DataValidationError, ConcurrencyError.
Example
import { createCalendarStore, createEvent, updateEvent, undoLastChange } from '@bimetal/calendar-data';
import { createDateTime, createTimeRange } from '@bimetal/core';
const store = createCalendarStore();
const event = {
id: 'e1',
title: 'Standup',
timeRange: createTimeRange(createDateTime(2026, 5, 17, 9, 0, 'UTC'), createDateTime(2026, 5, 17, 10, 0, 'UTC')),
allDay: false,
metadata: {},
};
await store.dispatch(createEvent(event));
await store.dispatch(updateEvent('e1', { title: 'Daily Standup' }));
await store.dispatch(undoLastChange('e1')); // title reverts to 'Standup'Replaces
This package contains the calendar-specific portion of the (removed) @bimetal/data. Generic primitives live in @bimetal/event-sourcing.
License
PolyForm Noncommercial License 1.0.0
