mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 17:11:17 +00:00
Context keys are now tuples instead of strings, inspired by
React Query's query keys. This prevents context collisions
when multiple instances of the same source type are registered.
Sources write to structured keys like
["aris.google-calendar", "nextEvent", { account: "work" }]
and consumers can query by prefix via context.find().
Co-authored-by: Ona <no-reply@ona.com>
25 lines
751 B
TypeScript
25 lines
751 B
TypeScript
import type { ContextKey } from "@aris/core"
|
|
|
|
import { contextKey } from "@aris/core"
|
|
|
|
import type { CalDavEventData } from "./types.ts"
|
|
|
|
/**
|
|
* Calendar context for downstream sources.
|
|
*
|
|
* Provides a snapshot of the user's upcoming CalDAV events so other sources
|
|
* can adapt (e.g. a commute source checking if there's a meeting soon).
|
|
*/
|
|
export interface CalendarContext {
|
|
/** Events happening right now */
|
|
inProgress: CalDavEventData[]
|
|
/** Next upcoming event, if any */
|
|
nextEvent: CalDavEventData | null
|
|
/** Whether the user has any events today */
|
|
hasTodayEvents: boolean
|
|
/** Total number of events today */
|
|
todayEventCount: number
|
|
}
|
|
|
|
export const CalDavCalendarKey: ContextKey<CalendarContext> = contextKey("aris.caldav", "calendar")
|