Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
2.3 kB ยท 80 lines
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081// Core types for the subscription system
import type { PageComponentImpact } from "@openstatus/db/src/schema/page_components/constants";
export interface Subscription { id: number; pageId: number; pageName: string; pageSlug: string; customDomain?: string | null; componentIds: number[]; // Empty = entire page
// Only ONE identifier populated based on channelType channelType: "email" | "webhook" | "slack"; email?: string; webhookUrl?: string; slackChannelId?: string; channelConfig?: string; // JSON string for headers, secrets, slack teamId, etc.
token?: string; acceptedAt?: Date; unsubscribedAt?: Date;}
/** * Generic page update (status reports, maintenance, incidents, etc.) * Used for all types of notifications sent to subscribers */export interface PageUpdate { id: number; pageId: number; title: string; status: | "investigating" | "identified" | "monitoring" | "resolved" | "maintenance"; message: string; pageComponentIds: number[]; pageComponents: string[]; date: string; // can be single string or "from - to"
// Optional fields consumed by the prepared (staged) generic webhook payload. // Populated by the matching dispatcher; ignored by email/Slack/Discord // builders, which key off the fields above. updateId?: number; // statusReportUpdate.id (status reports only) pageComponentsWithId?: { id: number; name: string }[]; // Current impact per component as of this update (not the raw delta). componentsWithImpact?: { id: number; name: string; impact: PageComponentImpact; }[]; startsAt?: string; // maintenance only, ISO endsAt?: string; // maintenance only, ISO}
/** * Interface for notification channels (email, webhook, etc.) * Channels handle the actual delivery of notifications. */export interface SubscriptionChannel { id: string;
// Validate channel-specific config validateConfig(config: unknown): Promise<{ valid: boolean; error?: string }>;
// Send verification if needed sendVerification?( subscription: Subscription, verifyUrl: string, ): Promise<void>;
// Send notifications to multiple subscribers (batched) sendNotifications( subscriptions: Subscription[], pageUpdate: PageUpdate, ): Promise<void>;}