Something went wrong. Try again.
Mirror of https://github.com/kualta/site — web infrastructure
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170import type { Post as BlueskyPostView } from "@astro-community/astro-embed-bluesky";import type { AppBskyEmbedExternal } from "@atcute/bluesky";
export const ACTIVITY_SOURCES = ["github", "bluesky"] as const;
export const GITHUB_ACTIVITY_ACTIONS = [ "added", "answered", "assigned", "category_changed", "closed", "created", "deleted", "demilestoned", "dismissed", "edited", "forked", "labeled", "locked", "merged", "milestoned", "opened", "pinned", "prereleased", "published", "released", "reopened", "review_request_removed", "review_requested", "started", "submitted", "synchronize", "transferred", "unanswered", "unassigned", "unlabeled", "unlocked", "unpinned", "unpublished", "updated",] as const;
export type ActivitySource = (typeof ACTIVITY_SOURCES)[number];export type GitHubActivityAction = (typeof GITHUB_ACTIVITY_ACTIONS)[number];
interface BaseActivity { id: string; source: ActivitySource; occurredAt: string;}
export interface GitHubRepository { name: string; url: string;}
export interface GitHubTarget { title?: string; url: string;}
interface GitHubActivityBase extends BaseActivity { source: "github"; kind: "event"; eventType: string; action?: GitHubActivityAction;}
export interface PrivateGitHubActivity extends GitHubActivityBase { visibility: "private"; repository?: never; target?: never; refType?: never;}
export interface PublicGitHubActivity extends GitHubActivityBase { visibility: "public"; repository?: GitHubRepository; target?: GitHubTarget; refType?: "branch" | "repository" | "tag";}
/** * The events API only reaches back three days, so older GitHub history arrives * as the contribution calendar's daily totals instead — coarser, but it covers * the year the detailed feed cannot. */export interface GitHubContributionsActivity extends BaseActivity { source: "github"; kind: "contributions"; /** what GitHub counted that day, private work included as an opaque total */ count: number;}
export type GitHubEventActivity = PrivateGitHubActivity | PublicGitHubActivity;export type GitHubActivity = GitHubEventActivity | GitHubContributionsActivity;
export interface BlueskyActivity extends BaseActivity { source: "bluesky"; action: "post" | "reply" | "repost"; uri: string; url: string; text: string; author: { displayName?: string; handle: string; }; post: BlueskyPostView; /** a card for a link the post shares without one; null once the page had nothing to show */ linkPreview?: LinkPreview | null;}
/** the card Bluesky would have drawn for a link, as its external embed view holds it */export type LinkPreview = Pick<AppBskyEmbedExternal.ViewExternal, "uri" | "title" | "description" | "thumb">;
export type ActivityEvent = GitHubActivity | BlueskyActivity;
export type PresenceState = | "definitely-alive" | "most-likely-alive" | "somewhere-else" | "kinda-lost" | "not-around" | "most-likely-dead" | "unknown";
export interface SourceHealth { status: "fresh" | "stale" | "unavailable"; fetchedAt: string | null;}
export interface ActivityFeed { /** newest events only; older ones are paged in from the archive */ events: ActivityEvent[]; lastSeenAt: string | null; presence: PresenceState; sources: Record<ActivitySource, SourceHealth>; delayed: boolean; /** first source to cross the five-minute freshness budget */ freshUntil: string | null; trustedUntil: string | null; /** oldest point every source still reaches; below it the feed is partial */ completeSince: string | null; /** the source that runs out at `completeSince` */ coverageLimitedBy: ActivitySource | null; /** feed position to request the next page from */ cursor: string | null;}
export interface ActivityCacheStore { get(key: string): Promise<string | null>; put(key: string, value: string): Promise<void>;}
export type ActivityFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
export interface ProviderContext { fetch: ActivityFetch; signal: AbortSignal; now: Date; secrets: { githubToken?: string; };}
export interface ActivityProvider { id: ActivitySource; fetch(context: ProviderContext): Promise<ActivityEvent[]>;}