Openstatus www.openstatus.dev
at main 21 lines 693 B view raw
1import type { PageComponentType } from "@openstatus/db/src/schema"; 2 3/** 4 * Type guard to check if a pageComponent is a monitor type with a valid monitor relation 5 * Filters out static components and ensures the monitor is active and not deleted 6 */ 7export function isMonitorComponent(component: { 8 type: PageComponentType; 9 monitor?: { active: boolean | null; deletedAt: Date | null } | null; 10}): component is { 11 type: "monitor"; 12 monitor: { active: true; deletedAt: null }; 13} { 14 return ( 15 component.type === "monitor" && 16 component.monitor !== null && 17 component.monitor !== undefined && 18 component.monitor.active === true && 19 component.monitor.deletedAt === null 20 ); 21}