Skip to content
← Public packages

@kentcdodds/quiet-hours

Quiet hours for Kent's bots: 10 PM to 8 AM MT (DST-aware) clock, shared overnight queue, override, and the 8 AM digest of finished work and open decisions.

FollowFork

Files

types.ts

60 lines · 1.7 KB · TypeScript
export const ITEM_KINDS = ['done', 'needs-decision', 'fyi', 'kent-request'] as const
export type ItemKind = (typeof ITEM_KINDS)[number]

export const PRIORITIES = ['urgent', 'high', 'normal', 'low'] as const
export type Priority = (typeof PRIORITIES)[number]

/** Bots that keep normal behavior and never write to the shared queue. */
export const EXCLUDED_BOTS = ['lilly', 'imogen'] as const

export type OverrideMode = 'on' | 'off'

export type QuietOverride = {
	/** 'off' = quiet off until the next 10 PM; 'on' = quiet on until the next 8 AM. */
	mode: OverrideMode
	setAt: string
	expiresAt: string
	by?: string | null
}

export type QuietStatus = {
	quiet: boolean
	/** ISO instant when the current state (quiet or not) ends. */
	until: string
	/** Active override, or null when the clock decides. */
	override: QuietOverride | null
	/** Present (true) when `bot` was Lilly or Imogen: they ignore quiet hours. */
	excluded?: true
	/** Present (true) when storage was unreachable and only the clock decided. */
	degraded?: true
}

export type QueueItem = {
	id: string
	createdAt: string
	bot: string
	kind: ItemKind
	priority: Priority
	title: string
	link: string | null
	detail: string | null
	deadline: string | null
	deliveredAt: string | null
	digestId: string | null
	waitingOnMe: { ok: boolean; id?: string | null; error?: string; skipped?: string } | null
}

export const DIGEST_BUCKETS = [
	'urgent-resolved',
	'deadline-today',
	'decision',
	'fyi',
] as const
export type DigestBucket = (typeof DIGEST_BUCKETS)[number]

export const BUCKET_LABELS: Record<DigestBucket, string> = {
	'urgent-resolved': 'Urgent, already handled',
	'deadline-today': 'Due today',
	decision: 'Needs you (decisions)',
	fyi: 'Done and FYI',
}