export type TimeRange = { startMsInEpoch: number; endMsInEpoch: number; }; export type TemporalUnit = "day" | "days" | "hour" | "hours" | "month" | "months"; export type TemporalDirection = "next" | "last"; export type TemporalPeriod = { direction: TemporalDirection; count: number; unit: TemporalUnit; }; export type SelectedTimeRange = { timeRange: TimeRange | null; temporalPeriod: TemporalPeriod | null; }; export interface TimeRangeContext { /** * Gets the current time range. * This is the time range that is currently selected. * If the user has selected a temporal period, this will be the start and end of the temporal period. * If the user has selected a custom time range, this will be the start and end of the custom time range. * * @returns the current time range */ timeRange: TimeRange | null; /** * Gets the current temporal period. * This is only if the user has selected a temporal period. * If the user has selected a custom time range, this will be null. * * @returns the current temporal period */ temporalPeriod: TemporalPeriod | null; } export interface TimeRangeRuntimeApi { /** * Used to get the current time range, only if the host page has a time range. */ getTimeRange: () => Promise<{ timeRange: TimeRange | null; temporalPeriod: TemporalPeriod | null; }>; }