Skip to main content

Function: overageLinkState()

overageLinkState(link, nowMs, expiringSoonDays?): OverageLinkState

Defined in: src/lib/overage.ts:37

Bucket a week's latest overage link into its OverageLinkState. A link is expired when its stored status says so OR it is still pending but already past expires_at (the DB status is only flipped lazily on the next request, so trust the clock too). expiring catches pending links within expiringSoonDays (default 3) of lapsing so the owner re-requests before the window closes.

Parameters

OverageLink | null

the most-recent approval_requests row for the week, or null if none exists yet.

nowMs

number

current time in epoch ms (injected so the mapping stays pure/testable).

expiringSoonDays?

number = 3

days-before-expiry that count as expiring. Default 3.

Returns

OverageLinkState