Skip to content

Open-source status page, incident response and uptime monitoring

feat: status-report impact (#2258)

Maximilian Kaskec203fbce8e2c
diff --git a/apps/dashboard/src/app/(dashboard)/status-pages/[id]/status-reports/[reportId]/page.tsx b/apps/dashboard/src/app/(dashboard)/status-pages/[id]/status-reports/[reportId]/page.tsx
index 6c53f2847..9b0ef3cf6 100644
--- a/apps/dashboard/src/app/(dashboard)/status-pages/[id]/status-reports/[reportId]/page.tsx
+++ b/apps/dashboard/src/app/(dashboard)/status-pages/[id]/status-reports/[reportId]/page.tsx
@@ -1,5 +1,6 @@
"use client";
+import { currentImpactsFromUpdates } from "@openstatus/db/src/schema/page_components/constants";
import { Button } from "@openstatus/ui/components/ui/button";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { Plus } from "lucide-react";
@@ -20,9 +21,15 @@ import {
import { FormCardGroup } from "@/components/forms/form-card";
import { FormSheetWithDirtyProtection } from "@/components/forms/form-sheet";
import type { FormValues } from "@/components/forms/status-report-update/form";
-import { FormStatusReportUpdateCard } from "@/components/forms/status-report-update/form-status-report";
+import {
+ FormStatusReportUpdateCard,
+ type FormValues as UpdateCardFormValues,
+} from "@/components/forms/status-report-update/form-status-report";
import { FormSheetStatusReportUpdate } from "@/components/forms/status-report-update/sheet";
-import { getNextStatus } from "@/data/status-report-updates.client";
+import {
+ getNextStatus,
+ impactsEqual,
+} from "@/data/status-report-updates.client";
import { useTRPC } from "@/lib/trpc/client";
export default function Page() {
@@ -70,6 +77,11 @@ export default function Page() {
.map((component) => component.name)
.join(", ");
+ const reportHasImpacts = statusReport.updates.some(
+ (u) => u.componentImpacts.length > 0,
+ );
+ const currentImpacts = currentImpactsFromUpdates(statusReport.updates);
+
return (
<SectionGroup>
<Section>
@@ -91,12 +103,30 @@ export default function Page() {
<FormSheetStatusReportUpdate
defaultValues={{
status: getNextStatus(statusReport.status),
+ componentImpacts: statusReport.pageComponents.map((c) => ({
+ pageComponentId: c.id,
+ impact: currentImpacts.get(c.id) ?? "operational",
+ })),
}}
+ components={statusReport.pageComponents.map((c) => ({
+ id: c.id,
+ name: c.name,
+ }))}
onSubmit={async (values: FormValues) => {
+ // a legacy report stays legacy unless the operator actively
+ // sets a non-operational impact — never silently flip it green
+ const sendImpacts =
+ reportHasImpacts ||
+ values.componentImpacts?.some(
+ (ci) => ci.impact !== "operational",
+ );
await createStatusReportUpdateMutation.mutateAsync({
statusReportId: statusReport.id,
message: values.message,
status: values.status,
+ componentImpacts: sendImpacts
+ ? values.componentImpacts
+ : undefined,
date: values.date,
notifySubscribers: values.notifySubscribers,
});
@@ -116,17 +146,33 @@ export default function Page() {
id={`update-form-${update.id}`}
index={index}
update={update}
+ components={statusReport.pageComponents.map((c) => ({
+ id: c.id,
+ name: c.name,
+ }))}
defaultValues={{
status: update.status,
message: update.message,
date: update.date,
+ componentImpacts: update.componentImpacts.map((ci) => ({
+ pageComponentId: ci.pageComponentId,
+ impact: ci.impact,
+ })),
}}
- onSubmit={async (values: FormValues) => {
+ onSubmit={async (values: UpdateCardFormValues) => {
await updateStatusReportUpdateMutation.mutateAsync({
id: update.id,
statusReportId: statusReport.id,
message: values.message,
status: values.status,
+ // replace-set semantics: only send when actually edited,
+ // so untouched (incl. legacy) updates keep their rows
+ componentImpacts: impactsEqual(
+ values.componentImpacts ?? [],
+ update.componentImpacts,
+ )
+ ? undefined
+ : values.componentImpacts,
date: values.date,
});
}}
diff --git a/apps/dashboard/src/app/(dashboard)/status-pages/[id]/status-reports/page.tsx b/apps/dashboard/src/app/(dashboard)/status-pages/[id]/status-reports/page.tsx
index e8e0d9947..883f40cea 100644
--- a/apps/dashboard/src/app/(dashboard)/status-pages/[id]/status-reports/page.tsx
+++ b/apps/dashboard/src/app/(dashboard)/status-pages/[id]/status-reports/page.tsx
@@ -91,11 +91,23 @@ export default function Page() {
// NOTE: for type safety, we need to check if the values have a date property
// because of the union type
if ("date" in values) {
+ // every selected component gets an impact row — fresh
+ // reports are never legacy (untouched pickers ⇒ operational)
+ const componentImpacts = values.pageComponents.map(
+ (pageComponentId) => ({
+ pageComponentId,
+ impact:
+ values.componentImpacts?.find(
+ (ci) => ci.pageComponentId === pageComponentId,
+ )?.impact ?? ("operational" as const),
+ }),
+ );
await createStatusReportMutation.mutateAsync({
title: values.title,
status: values.status,
pageId: Number.parseInt(id),
pageComponents: values.pageComponents,
+ componentImpacts,
date: values.date,
message: values.message,
notifySubscribers: values.notifySubscribers,
@@ -120,6 +132,10 @@ export default function Page() {
<UpdatesDataTable
updates={row.original.updates}
reportId={row.original.id}
+ components={row.original.pageComponents.map((c) => ({
+ id: c.id,
+ name: c.name,
+ }))}
/>
)}
/>
diff --git a/apps/dashboard/src/components/chat/tool-renderers/add-status-report-update.tsx b/apps/dashboard/src/components/chat/tool-renderers/add-status-report-update.tsx
index c02152201..586fe8808 100644
--- a/apps/dashboard/src/components/chat/tool-renderers/add-status-report-update.tsx
+++ b/apps/dashboard/src/components/chat/tool-renderers/add-status-report-update.tsx
@@ -1,4 +1,5 @@
import type { AgentToolInput } from "@openstatus/services/agent-tools";
+import { formatComponentImpacts } from "@openstatus/services/status-report/utils";
import type { ChangeRow } from "@/components/common/changes-table";
@@ -22,6 +23,12 @@ export function addStatusReportUpdateChanges(
after: applied?.notified !== undefined ? applied.notified : input.notify,
},
];
+ if (input.componentImpacts?.length) {
+ changes.push({
+ field: "componentImpacts",
+ after: formatComponentImpacts(input.componentImpacts),
+ });
+ }
if (input.date) {
changes.push({ field: "date", after: input.date });
}
diff --git a/apps/dashboard/src/components/chat/tool-renderers/create-status-report.tsx b/apps/dashboard/src/components/chat/tool-renderers/create-status-report.tsx
index 1833987f6..6cc118d4b 100644
--- a/apps/dashboard/src/components/chat/tool-renderers/create-status-report.tsx
+++ b/apps/dashboard/src/components/chat/tool-renderers/create-status-report.tsx
@@ -1,4 +1,5 @@
import type { AgentToolInput } from "@openstatus/services/agent-tools";
+import { formatComponentImpacts } from "@openstatus/services/status-report/utils";
import type { ChangeRow } from "@/components/common/changes-table";
@@ -23,13 +24,26 @@ export function createStatusReportChanges(
{ field: "status", after: input.status },
{ field: "message", after: input.message },
{ field: "pageId", after: input.pageId },
- { field: "pageComponentIds", after: input.pageComponentIds },
{
field: "notify",
after: applied?.notified !== undefined ? applied.notified : input.notify,
},
];
+ if (input.pageComponentIds?.length) {
+ changes.push({
+ field: "pageComponentIds",
+ after: input.pageComponentIds,
+ });
+ }
+
+ if (input.componentImpacts?.length) {
+ changes.push({
+ field: "componentImpacts",
+ after: formatComponentImpacts(input.componentImpacts),
+ });
+ }
+
const resolvedDate = input.date ?? undefined;
if (resolvedDate !== undefined) {
changes.push({ field: "date", after: resolvedDate });
diff --git a/apps/dashboard/src/components/data-table/status-report-updates/data-table-row-actions.tsx b/apps/dashboard/src/components/data-table/status-report-updates/data-table-row-actions.tsx
index 73fc207e4..5d1033b8b 100644
--- a/apps/dashboard/src/components/data-table/status-report-updates/data-table-row-actions.tsx
+++ b/apps/dashboard/src/components/data-table/status-report-updates/data-table-row-actions.tsx
@@ -7,7 +7,7 @@ import { useRef } from "react";
import { QuickActions } from "@/components/dropdowns/quick-actions";
import { FormSheetStatusReportUpdate } from "@/components/forms/status-report-update/sheet";
-import { getActions } from "@/data/status-report-updates.client";
+import { getActions, impactsEqual } from "@/data/status-report-updates.client";
import { useTRPC } from "@/lib/trpc/client";
type StatusReportUpdate =
@@ -15,9 +15,13 @@ type StatusReportUpdate =
interface DataTableRowActionsProps {
row: StatusReportUpdate;
+ components?: { id: number; name: string }[];
}
-export function DataTableRowActions({ row }: DataTableRowActionsProps) {
+export function DataTableRowActions({
+ row,
+ components,
+}: DataTableRowActionsProps) {
const buttonRef = useRef<HTMLButtonElement>(null);
const { id } = useParams<{ id: string }>();
const trpc = useTRPC();
@@ -79,13 +83,27 @@ export function DataTableRowActions({ row }: DataTableRowActionsProps) {
message: row.message,
date: row.date,
status: row.status,
+ componentImpacts: row.componentImpacts.map((ci) => ({
+ pageComponentId: ci.pageComponentId,
+ impact: ci.impact,
+ })),
}}
+ components={components}
+ allowUnsetImpacts
onSubmit={async (values) => {
await updateStatusReportUpdateMutation.mutateAsync({
id: row.id,
statusReportId: row.statusReportId,
message: values.message,
status: values.status,
+ // replace-set semantics: only send when actually edited, so
+ // untouched (incl. legacy) updates keep their rows
+ componentImpacts: impactsEqual(
+ values.componentImpacts ?? [],
+ row.componentImpacts,
+ )
+ ? undefined
+ : values.componentImpacts,
date: values.date,
});
}}
diff --git a/apps/dashboard/src/components/data-table/status-report-updates/data-table.tsx b/apps/dashboard/src/components/data-table/status-report-updates/data-table.tsx
index 983139c2a..75a630561 100644
--- a/apps/dashboard/src/components/data-table/status-report-updates/data-table.tsx
+++ b/apps/dashboard/src/components/data-table/status-report-updates/data-table.tsx
@@ -1,6 +1,7 @@
"use client";
import type { RouterOutputs } from "@openstatus/api";
+import { currentImpactsFromUpdates } from "@openstatus/db/src/schema/page_components/constants";
import { Button } from "@openstatus/ui/components/ui/button";
import {
Table,
@@ -36,10 +37,14 @@ type StatusReportUpdates =
export function DataTable({
updates,
reportId,
+ components = [],
}: {
updates: StatusReportUpdates;
reportId: number;
+ components?: { id: number; name: string }[];
}) {
+ const reportHasImpacts = updates.some((u) => u.componentImpacts.length > 0);
+ const currentImpacts = currentImpactsFromUpdates(updates);
const trpc = useTRPC();
const { id } = useParams<{ id: string }>();
const queryClient = useQueryClient();
@@ -88,12 +93,27 @@ export function DataTable({
status: getNextStatus(
updates[updates.length - 1]?.status ?? "investigating",
),
+ componentImpacts: components.map((c) => ({
+ pageComponentId: c.id,
+ impact: currentImpacts.get(c.id) ?? "operational",
+ })),
}}
+ components={components}
onSubmit={async (values) => {
+ // a legacy report stays legacy unless the operator
+ // actively sets a non-operational impact
+ const sendImpacts =
+ reportHasImpacts ||
+ values.componentImpacts?.some(
+ (ci) => ci.impact !== "operational",
+ );
await createStatusReportUpdateMutation.mutateAsync({
statusReportId: reportId,
message: values.message,
status: values.status,
+ componentImpacts: sendImpacts
+ ? values.componentImpacts
+ : undefined,
date: values.date,
notifySubscribers: values.notifySubscribers,
});
@@ -133,7 +153,7 @@ export function DataTable({
<TableCellDate value={update.date} />
</TableCell>
<TableCell className="w-8">
- <DataTableRowActions row={update} />
+ <DataTableRowActions row={update} components={components} />
</TableCell>
</TableRow>
);
diff --git a/apps/dashboard/src/components/data-table/status-reports/columns.tsx b/apps/dashboard/src/components/data-table/status-reports/columns.tsx
index 7650f5987..ab97fe26b 100644
--- a/apps/dashboard/src/components/data-table/status-reports/columns.tsx
+++ b/apps/dashboard/src/components/data-table/status-reports/columns.tsx
@@ -1,6 +1,11 @@
"use client";
import type { RouterOutputs } from "@openstatus/api";
+import {
+ currentImpactsFromUpdates,
+ type PageComponentImpact,
+ worstImpact,
+} from "@openstatus/db/src/schema/page_components/constants";
import { Button } from "@openstatus/ui/components/ui/button";
import { cn } from "@openstatus/ui/lib/utils";
import type { ColumnDef } from "@tanstack/react-table";
@@ -12,12 +17,24 @@ import { TableCellDate } from "@/components/data-table/table-cell-date";
import { TableCellLink } from "@/components/data-table/table-cell-link";
import { TableCellNumber } from "@/components/data-table/table-cell-number";
import { DataTableColumnHeader } from "@/components/ui/data-table/data-table-column-header";
-import { colors } from "@/data/status-report-updates.client";
+import {
+ colors,
+ impactConfig,
+ untriagedImpact,
+} from "@/data/status-report-updates.client";
import { DataTableRowActions } from "./data-table-row-actions";
type StatusReport = RouterOutputs["statusReport"]["list"][number];
+// derived top-level impact = worst current impact across components;
+// legacy reports (no impact rows) read "Untriaged"
+function worstCurrentImpact(report: StatusReport) {
+ const current = currentImpactsFromUpdates(report.updates);
+ if (current.size === 0) return null;
+ return worstImpact(current.values());
+}
+
export const columns: ColumnDef<StatusReport>[] = [
{
id: "expander",
@@ -93,10 +110,23 @@ export const columns: ColumnDef<StatusReport>[] = [
enableSorting: false,
enableHiding: false,
},
+ {
+ id: "impact",
+ accessorFn: (row) => worstCurrentImpact(row),
+ header: "Impact",
+ cell: ({ row }) => {
+ const impact = row.getValue<PageComponentImpact | null>("impact");
+ const config = impact ? impactConfig[impact] : untriagedImpact;
+ return (
+ <div className={cn("font-mono", config.color)}>{config.label}</div>
+ );
+ },
+ enableSorting: false,
+ },
{
id: "updates",
accessorFn: (row) => row.updates.length,
- header: "Total Updates",
+ header: "Updates",
cell: ({ row }) => {
const value = row.getValue("updates");
return <TableCellNumber value={value} />;
diff --git a/apps/dashboard/src/components/forms/status-report-update/form-status-report.tsx b/apps/dashboard/src/components/forms/status-report-update/form-status-report.tsx
index b2127bb59..b47595868 100644
--- a/apps/dashboard/src/components/forms/status-report-update/form-status-report.tsx
+++ b/apps/dashboard/src/components/forms/status-report-update/form-status-report.tsx
@@ -5,6 +5,7 @@ import {
type StatusReportUpdate,
statusReportStatus,
} from "@openstatus/db/src/schema";
+import { pageComponentImpact } from "@openstatus/db/src/schema/page_components/constants";
import { Button } from "@openstatus/ui/components/ui/button";
import { Calendar } from "@openstatus/ui/components/ui/calendar";
import { Checkbox } from "@openstatus/ui/components/ui/checkbox";
@@ -60,6 +61,7 @@ import {
FormCardTitle,
} from "@/components/forms/form-card";
import { useFormSheetDirty } from "@/components/forms/form-sheet";
+import { ComponentImpactList } from "@/components/forms/status-report/component-impact-field";
import { colors } from "@/data/status-report-updates.client";
import { useTRPC } from "@/lib/trpc/client";
@@ -67,6 +69,14 @@ const schema = z.object({
status: z.enum(statusReportStatus),
message: z.string(),
date: z.date(),
+ componentImpacts: z
+ .array(
+ z.object({
+ pageComponentId: z.number(),
+ impact: z.enum(pageComponentImpact),
+ }),
+ )
+ .optional(),
notifySubscribers: z.boolean().optional(),
});
@@ -78,12 +88,15 @@ export function FormStatusReportUpdateCard({
className,
index,
update,
+ components,
...props
}: Omit<React.ComponentProps<"form">, "onSubmit"> & {
defaultValues?: FormValues;
onSubmit: (values: FormValues) => Promise<void>;
index: number;
update: StatusReportUpdate;
+ /** The report's affected components; renders the per-component impact picker. */
+ components?: { id: number; name: string }[];
}) {
const { reportId } = useParams<{ id: string; reportId: string }>();
const trpc = useTRPC();
@@ -98,6 +111,7 @@ export function FormStatusReportUpdateCard({
status: "identified",
message: "",
date: new Date(),
+ componentImpacts: undefined,
notifySubscribers: true,
},
});
@@ -312,6 +326,35 @@ export function FormStatusReportUpdateCard({
).
</FormDescription>
</FormCardContent>
+ {components && components.length > 0 ? (
+ <>
+ <FormCardSeparator />
+ <FormCardContent>
+ <FormField
+ control={form.control}
+ name="componentImpacts"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Component Impact</FormLabel>
+ <FormDescription>
+ The impact this update set per component. Components
+ marked &quot;No change&quot; keep their prior impact.
+ </FormDescription>
+ <FormControl>
+ <ComponentImpactList
+ components={components}
+ value={field.value ?? []}
+ onValueChange={field.onChange}
+ allowUnset
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </FormCardContent>
+ </>
+ ) : null}
<FormCardSeparator />
<FormCardContent>
<Tabs defaultValue="tab-1">
diff --git a/apps/dashboard/src/components/forms/status-report-update/form.tsx b/apps/dashboard/src/components/forms/status-report-update/form.tsx
index d7932cd14..00633f05a 100644
--- a/apps/dashboard/src/components/forms/status-report-update/form.tsx
+++ b/apps/dashboard/src/components/forms/status-report-update/form.tsx
@@ -2,6 +2,7 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { statusReportStatus } from "@openstatus/db/src/schema";
+import { pageComponentImpact } from "@openstatus/db/src/schema/page_components/constants";
import { Button } from "@openstatus/ui/components/ui/button";
import { Calendar } from "@openstatus/ui/components/ui/calendar";
import { Checkbox } from "@openstatus/ui/components/ui/checkbox";
@@ -49,6 +50,7 @@ import {
FormCardSeparator,
} from "@/components/forms/form-card";
import { useFormSheetDirty } from "@/components/forms/form-sheet";
+import { ComponentImpactList } from "@/components/forms/status-report/component-impact-field";
import { colors } from "@/data/status-report-updates.client";
import { useTRPC } from "@/lib/trpc/client";
@@ -56,6 +58,14 @@ const schema = z.object({
status: z.enum(statusReportStatus),
message: z.string(),
date: z.date(),
+ componentImpacts: z
+ .array(
+ z.object({
+ pageComponentId: z.number(),
+ impact: z.enum(pageComponentImpact),
+ }),
+ )
+ .optional(),
notifySubscribers: z.boolean().optional(),
});
@@ -65,10 +75,16 @@ export function FormStatusReportUpdate({
defaultValues,
onSubmit,
className,
+ components,
+ allowUnsetImpacts = false,
...props
}: Omit<React.ComponentProps<"form">, "onSubmit"> & {
defaultValues?: Partial<FormValues>;
onSubmit: (values: FormValues) => Promise<void>;
+ /** The report's affected components; renders the per-component impact picker. */
+ components?: { id: number; name: string }[];
+ /** Edit mode: components without an entry show "No change". */
+ allowUnsetImpacts?: boolean;
}) {
const trpc = useTRPC();
const { data: workspace } = useQuery(
@@ -82,6 +98,7 @@ export function FormStatusReportUpdate({
status: defaultValues?.status ?? "identified",
message: defaultValues?.message ?? "",
date: defaultValues?.date ?? new Date(),
+ componentImpacts: defaultValues?.componentImpacts,
notifySubscribers: defaultValues?.notifySubscribers ?? true,
},
});
@@ -274,6 +291,34 @@ export function FormStatusReportUpdate({
)}
/>
</FormCardContent>
+ {components && components.length > 0 ? (
+ <>
+ <FormCardSeparator />
+ <FormCardContent>
+ <FormField
+ control={form.control}
+ name="componentImpacts"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Component Impact</FormLabel>
+ <FormDescription>
+ How badly is each affected component impacted?
+ </FormDescription>
+ <FormControl>
+ <ComponentImpactList
+ components={components}
+ value={field.value ?? []}
+ onValueChange={field.onChange}
+ allowUnset={allowUnsetImpacts}
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </FormCardContent>
+ </>
+ ) : null}
<FormCardSeparator />
<FormCardContent>
<Tabs defaultValue="tab-1">
diff --git a/apps/dashboard/src/components/forms/status-report-update/sheet.tsx b/apps/dashboard/src/components/forms/status-report-update/sheet.tsx
index f16d61fa1..9e10e3601 100644
--- a/apps/dashboard/src/components/forms/status-report-update/sheet.tsx
+++ b/apps/dashboard/src/components/forms/status-report-update/sheet.tsx
@@ -22,9 +22,13 @@ export function FormSheetStatusReportUpdate({
children,
defaultValues,
onSubmit,
+ components,
+ allowUnsetImpacts,
}: Omit<React.ComponentProps<typeof FormSheetTrigger>, "onSubmit"> & {
defaultValues?: Partial<FormValues>;
onSubmit: (values: FormValues) => Promise<void>;
+ components?: { id: number; name: string }[];
+ allowUnsetImpacts?: boolean;
}) {
const [open, setOpen] = useState(false);
return (
@@ -47,6 +51,8 @@ export function FormSheetStatusReportUpdate({
setOpen(false);
}}
defaultValues={defaultValues}
+ components={components}
+ allowUnsetImpacts={allowUnsetImpacts}
/>
</FormCard>
</FormCardGroup>
diff --git a/apps/dashboard/src/components/forms/status-report/component-impact-field.tsx b/apps/dashboard/src/components/forms/status-report/component-impact-field.tsx
new file mode 100644
index 000000000..3c061523e
--- /dev/null
+++ b/apps/dashboard/src/components/forms/status-report/component-impact-field.tsx
@@ -0,0 +1,92 @@
+"use client";
+
+import {
+ type PageComponentImpact,
+ pageComponentImpact,
+} from "@openstatus/db/src/schema/page_components/constants";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@openstatus/ui/components/ui/select";
+import { cn } from "@openstatus/ui/lib/utils";
+
+import { impactConfig } from "@/data/status-report-updates.client";
+
+export type ComponentImpactValue = {
+ pageComponentId: number;
+ impact: PageComponentImpact;
+};
+
+export function ComponentImpactList({
+ components,
+ value,
+ onValueChange,
+ allowUnset = false,
+ placeholder = "No change",
+}: {
+ components: { id: number; name: string }[];
+ value: ComponentImpactValue[];
+ onValueChange: (value: ComponentImpactValue[]) => void;
+ /** Components without an entry show the placeholder instead of defaulting to operational. */
+ allowUnset?: boolean;
+ placeholder?: string;
+}) {
+ function impactFor(id: number): PageComponentImpact | undefined {
+ const found = value.find((v) => v.pageComponentId === id)?.impact;
+ if (found) return found;
+ return allowUnset ? undefined : "operational";
+ }
+
+ function setImpact(id: number, impact: PageComponentImpact) {
+ const rest = value.filter((v) => v.pageComponentId !== id);
+ onValueChange([...rest, { pageComponentId: id, impact }]);
+ }
+
+ if (components.length === 0) return null;
+
+ return (
+ <div className="grid gap-2">
+ {components.map((component) => {
+ const impact = impactFor(component.id);
+ return (
+ <div
+ key={component.id}
+ className="flex items-center justify-between gap-2"
+ >
+ <span className="truncate text-sm">{component.name}</span>
+ <Select
+ value={impact}
+ onValueChange={(next) =>
+ setImpact(component.id, next as PageComponentImpact)
+ }
+ >
+ <SelectTrigger
+ size="sm"
+ className={cn(
+ impact ? impactConfig[impact].color : "text-muted-foreground",
+ "w-[180px] font-mono",
+ )}
+ >
+ <SelectValue placeholder={placeholder} />
+ </SelectTrigger>
+ <SelectContent>
+ {pageComponentImpact.map((option) => (
+ <SelectItem
+ key={option}
+ value={option}
+ className={cn(impactConfig[option].color, "font-mono")}
+ >
+ {impactConfig[option].label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </div>
+ );
+ })}
+ </div>
+ );
+}
diff --git a/apps/dashboard/src/components/forms/status-report/form.tsx b/apps/dashboard/src/components/forms/status-report/form.tsx
index 955b59e7e..924456e34 100644
--- a/apps/dashboard/src/components/forms/status-report/form.tsx
+++ b/apps/dashboard/src/components/forms/status-report/form.tsx
@@ -2,6 +2,7 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { statusReportStatus } from "@openstatus/db/src/schema";
+import { pageComponentImpact } from "@openstatus/db/src/schema/page_components/constants";
import { Button } from "@openstatus/ui/components/ui/button";
import { Calendar } from "@openstatus/ui/components/ui/calendar";
import { Checkbox } from "@openstatus/ui/components/ui/checkbox";
@@ -53,6 +54,7 @@ import {
FormCardSeparator,
} from "@/components/forms/form-card";
import { useFormSheetDirty } from "@/components/forms/form-sheet";
+import { ComponentImpactList } from "@/components/forms/status-report/component-impact-field";
import {
CheckboxTree,
type CheckboxTreeItem,
@@ -62,16 +64,26 @@ import { useTRPC } from "@/lib/trpc/client";
const schema = z.object({
status: z.enum(statusReportStatus),
- title: z.string(),
+ title: z.string().min(1, "Title is required.").max(256),
message: z.string(),
date: z.date(),
pageComponents: z.array(z.number()),
+ componentImpacts: z
+ .array(
+ z.object({
+ pageComponentId: z.number(),
+ impact: z.enum(pageComponentImpact),
+ }),
+ )
+ .optional(),
notifySubscribers: z.boolean().optional(),
});
+// membership-only edit: impacts change via status report updates
const updateSchema = schema.omit({
message: true,
date: true,
+ componentImpacts: true,
notifySubscribers: true,
});
@@ -106,9 +118,15 @@ export function FormStatusReport({
},
});
const watchMessage = form.watch("message");
+ const watchPageComponents = form.watch("pageComponents");
const [isPending, startTransition] = useTransition();
const { setIsDirty } = useFormSheetDirty();
+ const selectedComponents = React.useMemo(() => {
+ const flat = items.flatMap((item) => item.children ?? [item]);
+ return flat.filter((c) => (watchPageComponents ?? []).includes(c.id));
+ }, [items, watchPageComponents]);
+
const formIsDirty = form.formState.isDirty;
React.useEffect(() => {
setIsDirty(formIsDirty);
@@ -379,6 +397,41 @@ export function FormStatusReport({
)}
/>
</FormCardContent>
+ {!defaultValues && selectedComponents.length > 0 ? (
+ <>
+ <FormCardSeparator />
+ <FormCardContent>
+ <FormField
+ control={form.control}
+ name="componentImpacts"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Component Impact</FormLabel>
+ <FormDescription>
+ How badly is each affected component impacted?
+ </FormDescription>
+ <FormControl>
+ {/* unset must stay visibly unset — a fake "Operational"
+ default would submit no impact rows (legacy report)
+ while the bar renders orange, not the green shown */}
+ <ComponentImpactList
+ components={selectedComponents.map((c) => ({
+ id: c.id,
+ name: c.label,
+ }))}
+ value={field.value ?? []}
+ onValueChange={field.onChange}
+ allowUnset
+ placeholder="No impact set"
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </FormCardContent>
+ </>
+ ) : null}
{!defaultValues && workspace?.limits["status-subscribers"] ? (
<>
<FormCardSeparator />
diff --git a/apps/dashboard/src/data/status-report-updates.client.ts b/apps/dashboard/src/data/status-report-updates.client.ts
index c156dddcb..c95a27be1 100644
--- a/apps/dashboard/src/data/status-report-updates.client.ts
+++ b/apps/dashboard/src/data/status-report-updates.client.ts
@@ -1,6 +1,52 @@
import type { StatusReportStatus } from "@openstatus/db/src/schema";
+import type { PageComponentImpact } from "@openstatus/db/src/schema/page_components/constants";
import { Cog, Trash2 } from "lucide-react";
+export const impactConfig = {
+ operational: {
+ label: "Operational",
+ color:
+ "text-success/80 data-[state=selected]:bg-success/10 data-[state=selected]:text-success",
+ },
+ degraded_performance: {
+ label: "Degraded performance",
+ color:
+ "text-warning/80 data-[state=selected]:bg-warning/10 data-[state=selected]:text-warning",
+ },
+ partial_outage: {
+ label: "Partial outage",
+ color:
+ "text-warning/80 data-[state=selected]:bg-warning/10 data-[state=selected]:text-warning",
+ },
+ major_outage: {
+ label: "Major outage",
+ color:
+ "text-destructive/80 data-[state=selected]:bg-destructive/10 data-[state=selected]:text-destructive",
+ },
+} as const satisfies Record<
+ PageComponentImpact,
+ { label: string; color: string }
+>;
+
+/** Set equality regardless of order — used to skip no-op impact writes. */
+export function impactsEqual(
+ a: { pageComponentId: number; impact: string }[],
+ b: { pageComponentId: number; impact: string }[],
+) {
+ const key = (list: { pageComponentId: number; impact: string }[]) =>
+ [...list]
+ .sort((x, y) => x.pageComponentId - y.pageComponentId)
+ .map((x) => `${x.pageComponentId}:${x.impact}`)
+ .join(",");
+ return key(a) === key(b);
+}
+
+// legacy report (created before impact tracking): no impact rows
+export const untriagedImpact = {
+ label: "Untriaged",
+ color: "text-muted-foreground/80",
+} as const;
+
export const actions = [
{
id: "edit",
diff --git a/apps/server/src/routes/rpc/handlers/status-page/index.ts b/apps/server/src/routes/rpc/handlers/status-page/index.ts
index 8a38a2071..3dae69fe5 100644
--- a/apps/server/src/routes/rpc/handlers/status-page/index.ts
+++ b/apps/server/src/routes/rpc/handlers/status-page/index.ts
@@ -21,6 +21,7 @@ import {
pageSubscriber,
statusReport,
statusReportUpdate,
+ statusReportUpdateToPageComponents,
statusReportsToPageComponents,
} from "@openstatus/db/src/schema";
import type { StatusPageService } from "@openstatus/proto/status_page/v1";
@@ -1393,8 +1394,31 @@ export const statusPageServiceImpl: ServiceImpl<typeof StatusPageService> = {
.all()
: [];
- // Import the converter from status-report service
- const { dbStatusToProto } = await import("../status-report/converters");
+ // Get impact rows for the reports' updates, grouped per update id
+ const updateIds = reportUpdates.map((u) => u.id);
+ const updateImpacts =
+ updateIds.length > 0
+ ? await db
+ .select()
+ .from(statusReportUpdateToPageComponents)
+ .where(
+ inArray(
+ statusReportUpdateToPageComponents.statusReportUpdateId,
+ updateIds,
+ ),
+ )
+ .all()
+ : [];
+ const impactsByUpdate = new Map<number, typeof updateImpacts>();
+ for (const row of updateImpacts) {
+ const arr = impactsByUpdate.get(row.statusReportUpdateId);
+ if (arr) arr.push(row);
+ else impactsByUpdate.set(row.statusReportUpdateId, [row]);
+ }
+
+ // Import the converters from status-report service
+ const { dbStatusToProto, dbUpdateToProto } =
+ await import("../status-report/converters");
// Convert reports to proto format
const statusReports = activeReports.map((report) => {
@@ -1411,14 +1435,15 @@ export const statusPageServiceImpl: ServiceImpl<typeof StatusPageService> = {
status: dbStatusToProto(report.status),
title: report.title,
pageComponentIds: componentIds,
- updates: updates.map((u) => ({
- $typeName: "openstatus.status_report.v1.StatusReportUpdate" as const,
- id: String(u.id),
- status: dbStatusToProto(u.status),
- date: u.date.toISOString(),
- message: u.message,
- createdAt: u.createdAt?.toISOString() ?? "",
- })),
+ updates: updates.map((u) =>
+ dbUpdateToProto({
+ ...u,
+ componentImpacts: (impactsByUpdate.get(u.id) ?? []).map((row) => ({
+ pageComponentId: row.pageComponentId,
+ impact: row.impact,
+ })),
+ }),
+ ),
createdAt: report.createdAt?.toISOString() ?? "",
updatedAt: report.updatedAt?.toISOString() ?? "",
};
diff --git a/apps/server/src/routes/rpc/handlers/status-report/__tests__/status-report.test.ts b/apps/server/src/routes/rpc/handlers/status-report/__tests__/status-report.test.ts
index d0be78394..57e03d4c1 100644
--- a/apps/server/src/routes/rpc/handlers/status-report/__tests__/status-report.test.ts
+++ b/apps/server/src/routes/rpc/handlers/status-report/__tests__/status-report.test.ts
@@ -7,13 +7,21 @@ import {
pageSubscriber,
statusReport,
statusReportUpdate,
+ statusReportUpdateToPageComponents,
statusReportsToPageComponents,
} from "@openstatus/db/src/schema";
-import { StatusReportStatus } from "@openstatus/proto/status_report/v1";
+import {
+ PageComponentImpact,
+ StatusReportStatus,
+} from "@openstatus/proto/status_report/v1";
import { app } from "@/index";
-import { protoStatusToDb } from "../converters";
+import {
+ dbImpactToProto,
+ protoImpactToDb,
+ protoStatusToDb,
+} from "../converters";
const subscriptionSpies = (globalThis as Record<string, unknown>)
.__subscriptionSpies as {
@@ -1615,6 +1623,335 @@ describe("StatusReportService.AddStatusReportUpdate", () => {
});
});
+describe("StatusReportService component impacts", () => {
+ async function cleanupReport(id: number) {
+ // update deletion cascades the impact join rows
+ await db
+ .delete(statusReportUpdate)
+ .where(eq(statusReportUpdate.statusReportId, id));
+ await db
+ .delete(statusReportsToPageComponents)
+ .where(eq(statusReportsToPageComponents.statusReportId, id));
+ await db.delete(statusReport).where(eq(statusReport.id, id));
+ }
+
+ test("create round-trips componentImpacts and extends membership", async () => {
+ const res = await connectRequest(
+ "CreateStatusReport",
+ {
+ title: `${TEST_PREFIX}-with-impacts`,
+ status: "STATUS_REPORT_STATUS_INVESTIGATING",
+ message: "Component is down.",
+ date: new Date().toISOString(),
+ pageId: "1",
+ pageComponentIds: [],
+ componentImpacts: [
+ {
+ pageComponentId: String(testPageComponentId),
+ impact: "PAGE_COMPONENT_IMPACT_MAJOR_OUTAGE",
+ },
+ ],
+ },
+ { "x-openstatus-key": "1" },
+ );
+
+ expect(res.status).toBe(200);
+
+ const data = await res.json();
+ try {
+ // impacted components join the report's affected set even when
+ // pageComponentIds is empty
+ expect(data.statusReport.pageComponentIds).toContain(
+ String(testPageComponentId),
+ );
+ expect(data.statusReport.updates).toHaveLength(1);
+ expect(data.statusReport.updates[0].componentImpacts).toEqual([
+ {
+ pageComponentId: String(testPageComponentId),
+ impact: "PAGE_COMPONENT_IMPACT_MAJOR_OUTAGE",
+ },
+ ]);
+
+ const updateId = Number(data.statusReport.updates[0].id);
+ const rows = await db
+ .select()
+ .from(statusReportUpdateToPageComponents)
+ .where(
+ eq(statusReportUpdateToPageComponents.statusReportUpdateId, updateId),
+ )
+ .all();
+ expect(rows).toHaveLength(1);
+ expect(rows[0].pageComponentId).toBe(testPageComponentId);
+ expect(rows[0].impact).toBe("major_outage");
+ } finally {
+ await cleanupReport(Number(data.statusReport.id));
+ }
+ });
+
+ test("create without componentImpacts yields a legacy report (no impact rows)", async () => {
+ const res = await connectRequest(
+ "CreateStatusReport",
+ {
+ title: `${TEST_PREFIX}-legacy`,
+ status: "STATUS_REPORT_STATUS_INVESTIGATING",
+ message: "Legacy report without impact tracking.",
+ date: new Date().toISOString(),
+ pageId: "1",
+ pageComponentIds: [String(testPageComponentId)],
+ },
+ { "x-openstatus-key": "1" },
+ );
+
+ expect(res.status).toBe(200);
+
+ const data = await res.json();
+ try {
+ const impacts = data.statusReport.updates[0].componentImpacts ?? [];
+ expect(impacts).toHaveLength(0);
+
+ const updateId = Number(data.statusReport.updates[0].id);
+ const rows = await db
+ .select()
+ .from(statusReportUpdateToPageComponents)
+ .where(
+ eq(statusReportUpdateToPageComponents.statusReportUpdateId, updateId),
+ )
+ .all();
+ expect(rows).toHaveLength(0);
+ } finally {
+ await cleanupReport(Number(data.statusReport.id));
+ }
+ });
+
+ test("create rejects UNSPECIFIED impact", async () => {
+ const res = await connectRequest(
+ "CreateStatusReport",
+ {
+ title: `${TEST_PREFIX}-unspecified-impact`,
+ status: "STATUS_REPORT_STATUS_INVESTIGATING",
+ message: "Should fail.",
+ date: new Date().toISOString(),
+ pageId: "1",
+ pageComponentIds: [],
+ componentImpacts: [
+ {
+ pageComponentId: String(testPageComponentId),
+ impact: "PAGE_COMPONENT_IMPACT_UNSPECIFIED",
+ },
+ ],
+ },
+ { "x-openstatus-key": "1" },
+ );
+
+ expect(res.status).toBe(400);
+ const data = await res.json();
+ expect(data.message).toContain("Invalid component impact");
+ });
+
+ test("create returns 404 for impact on unknown component", async () => {
+ const res = await connectRequest(
+ "CreateStatusReport",
+ {
+ title: `${TEST_PREFIX}-unknown-impact-component`,
+ status: "STATUS_REPORT_STATUS_INVESTIGATING",
+ message: "Should fail.",
+ date: new Date().toISOString(),
+ pageId: "1",
+ pageComponentIds: [],
+ componentImpacts: [
+ {
+ pageComponentId: "99999",
+ impact: "PAGE_COMPONENT_IMPACT_MAJOR_OUTAGE",
+ },
+ ],
+ },
+ { "x-openstatus-key": "1" },
+ );
+
+ expect(res.status).toBe(404);
+ });
+
+ test("addStatusReportUpdate writes impacts on the new update", async () => {
+ const createRes = await connectRequest(
+ "CreateStatusReport",
+ {
+ title: `${TEST_PREFIX}-add-update-impacts`,
+ status: "STATUS_REPORT_STATUS_INVESTIGATING",
+ message: "Initial.",
+ date: new Date(Date.now() - 60 * 60 * 1000).toISOString(),
+ pageId: "1",
+ pageComponentIds: [String(testPageComponentId)],
+ },
+ { "x-openstatus-key": "1" },
+ );
+ const created = await createRes.json();
+
+ try {
+ const res = await connectRequest(
+ "AddStatusReportUpdate",
+ {
+ statusReportId: created.statusReport.id,
+ status: "STATUS_REPORT_STATUS_IDENTIFIED",
+ message: "Now we know which component.",
+ date: new Date().toISOString(),
+ componentImpacts: [
+ {
+ pageComponentId: String(testPageComponentId),
+ impact: "PAGE_COMPONENT_IMPACT_DEGRADED_PERFORMANCE",
+ },
+ ],
+ },
+ { "x-openstatus-key": "1" },
+ );
+
+ expect(res.status).toBe(200);
+
+ const data = await res.json();
+ const newUpdate = data.statusReport.updates.find(
+ (u: { message: string }) =>
+ u.message === "Now we know which component.",
+ );
+ expect(newUpdate).toBeDefined();
+ expect(newUpdate.componentImpacts).toEqual([
+ {
+ pageComponentId: String(testPageComponentId),
+ impact: "PAGE_COMPONENT_IMPACT_DEGRADED_PERFORMANCE",
+ },
+ ]);
+ } finally {
+ await cleanupReport(Number(created.statusReport.id));
+ }
+ });
+
+ test("resolved update auto-clears unnamed impacted components", async () => {
+ const createRes = await connectRequest(
+ "CreateStatusReport",
+ {
+ title: `${TEST_PREFIX}-resolve-clears`,
+ status: "STATUS_REPORT_STATUS_INVESTIGATING",
+ message: "Component is down.",
+ date: new Date(Date.now() - 60 * 60 * 1000).toISOString(),
+ pageId: "1",
+ pageComponentIds: [],
+ componentImpacts: [
+ {
+ pageComponentId: String(testPageComponentId),
+ impact: "PAGE_COMPONENT_IMPACT_MAJOR_OUTAGE",
+ },
+ ],
+ },
+ { "x-openstatus-key": "1" },
+ );
+ const created = await createRes.json();
+
+ try {
+ const res = await connectRequest(
+ "AddStatusReportUpdate",
+ {
+ statusReportId: created.statusReport.id,
+ status: "STATUS_REPORT_STATUS_RESOLVED",
+ message: "All clear.",
+ date: new Date().toISOString(),
+ },
+ { "x-openstatus-key": "1" },
+ );
+
+ expect(res.status).toBe(200);
+
+ const data = await res.json();
+ const resolveUpdate = data.statusReport.updates.find(
+ (u: { message: string }) => u.message === "All clear.",
+ );
+ expect(resolveUpdate).toBeDefined();
+ expect(resolveUpdate.componentImpacts).toEqual([
+ {
+ pageComponentId: String(testPageComponentId),
+ impact: "PAGE_COMPONENT_IMPACT_OPERATIONAL",
+ },
+ ]);
+ } finally {
+ await cleanupReport(Number(created.statusReport.id));
+ }
+ });
+
+ test("addStatusReportUpdate rejects impacts for components on a different page", async () => {
+ const createRes = await connectRequest(
+ "CreateStatusReport",
+ {
+ title: `${TEST_PREFIX}-cross-page-impact`,
+ status: "STATUS_REPORT_STATUS_INVESTIGATING",
+ message: "Initial.",
+ date: new Date().toISOString(),
+ pageId: "1",
+ pageComponentIds: [String(testPageComponentId)],
+ },
+ { "x-openstatus-key": "1" },
+ );
+ const created = await createRes.json();
+
+ try {
+ const res = await connectRequest(
+ "AddStatusReportUpdate",
+ {
+ statusReportId: created.statusReport.id,
+ status: "STATUS_REPORT_STATUS_IDENTIFIED",
+ message: "Impact on wrong page.",
+ componentImpacts: [
+ {
+ pageComponentId: String(testPage2ComponentId),
+ impact: "PAGE_COMPONENT_IMPACT_PARTIAL_OUTAGE",
+ },
+ ],
+ },
+ { "x-openstatus-key": "1" },
+ );
+
+ expect(res.status).toBe(400);
+ const data = await res.json();
+ expect(data.message).toContain("not the report's page");
+ } finally {
+ await cleanupReport(Number(created.statusReport.id));
+ }
+ });
+});
+
+describe("impact converters", () => {
+ test("protoImpactToDb converts all named impacts", () => {
+ expect(protoImpactToDb(PageComponentImpact.OPERATIONAL)).toBe(
+ "operational",
+ );
+ expect(protoImpactToDb(PageComponentImpact.DEGRADED_PERFORMANCE)).toBe(
+ "degraded_performance",
+ );
+ expect(protoImpactToDb(PageComponentImpact.PARTIAL_OUTAGE)).toBe(
+ "partial_outage",
+ );
+ expect(protoImpactToDb(PageComponentImpact.MAJOR_OUTAGE)).toBe(
+ "major_outage",
+ );
+ });
+
+ test("protoImpactToDb throws for UNSPECIFIED and unknown values", () => {
+ expect(() => protoImpactToDb(PageComponentImpact.UNSPECIFIED)).toThrow(
+ "Invalid component impact",
+ );
+ expect(() => protoImpactToDb(999 as PageComponentImpact)).toThrow(
+ "Invalid component impact",
+ );
+ });
+
+ test("dbImpactToProto round-trips every DB impact", () => {
+ for (const impact of [
+ "operational",
+ "degraded_performance",
+ "partial_outage",
+ "major_outage",
+ ] as const) {
+ expect(protoImpactToDb(dbImpactToProto(impact))).toBe(impact);
+ }
+ });
+});
+
describe("protoStatusToDb converter", () => {
test("converts valid statuses correctly", () => {
expect(protoStatusToDb(StatusReportStatus.INVESTIGATING)).toBe(
diff --git a/apps/server/src/routes/rpc/handlers/status-report/converters.ts b/apps/server/src/routes/rpc/handlers/status-report/converters.ts
index bc8104982..0d6b444c2 100644
--- a/apps/server/src/routes/rpc/handlers/status-report/converters.ts
+++ b/apps/server/src/routes/rpc/handlers/status-report/converters.ts
@@ -1,12 +1,28 @@
+import { Code, ConnectError } from "@connectrpc/connect";
import type {
+ ComponentImpact,
StatusReport,
StatusReportSummary,
StatusReportUpdate,
} from "@openstatus/proto/status_report/v1";
-import { StatusReportStatus } from "@openstatus/proto/status_report/v1";
+import {
+ PageComponentImpact,
+ StatusReportStatus,
+} from "@openstatus/proto/status_report/v1";
import { invalidStatusError } from "./errors";
+type DBPageComponentImpact =
+ | "operational"
+ | "degraded_performance"
+ | "partial_outage"
+ | "major_outage";
+
+type DBComponentImpact = {
+ pageComponentId: number;
+ impact: DBPageComponentImpact;
+};
+
type DBStatusReport = {
id: number;
status: "investigating" | "identified" | "monitoring" | "resolved";
@@ -25,6 +41,7 @@ type DBStatusReportUpdate = {
statusReportId: number;
createdAt: Date | null;
updatedAt: Date | null;
+ componentImpacts?: DBComponentImpact[];
};
/**
@@ -69,6 +86,59 @@ export function protoStatusToDb(
}
}
+/**
+ * Convert DB impact string to proto enum.
+ */
+export function dbImpactToProto(
+ impact: DBPageComponentImpact,
+): PageComponentImpact {
+ switch (impact) {
+ case "operational":
+ return PageComponentImpact.OPERATIONAL;
+ case "degraded_performance":
+ return PageComponentImpact.DEGRADED_PERFORMANCE;
+ case "partial_outage":
+ return PageComponentImpact.PARTIAL_OUTAGE;
+ case "major_outage":
+ return PageComponentImpact.MAJOR_OUTAGE;
+ default:
+ return PageComponentImpact.UNSPECIFIED;
+ }
+}
+
+/**
+ * Convert proto enum to DB impact string. UNSPECIFIED is a caller error here —
+ * "doesn't speak impact" is expressed by omitting the entry, never by sending
+ * an unspecified one (it must not silently become operational).
+ */
+export function protoImpactToDb(
+ impact: PageComponentImpact,
+): DBPageComponentImpact {
+ switch (impact) {
+ case PageComponentImpact.OPERATIONAL:
+ return "operational";
+ case PageComponentImpact.DEGRADED_PERFORMANCE:
+ return "degraded_performance";
+ case PageComponentImpact.PARTIAL_OUTAGE:
+ return "partial_outage";
+ case PageComponentImpact.MAJOR_OUTAGE:
+ return "major_outage";
+ default:
+ throw new ConnectError(
+ `Invalid component impact: ${impact}`,
+ Code.InvalidArgument,
+ );
+ }
+}
+
+function dbComponentImpactToProto(impact: DBComponentImpact): ComponentImpact {
+ return {
+ $typeName: "openstatus.status_report.v1.ComponentImpact" as const,
+ pageComponentId: String(impact.pageComponentId),
+ impact: dbImpactToProto(impact.impact),
+ };
+}
+
/**
* Convert a DB status report update to proto format.
*/
@@ -82,6 +152,9 @@ export function dbUpdateToProto(
date: update.date.toISOString(),
message: update.message,
createdAt: update.createdAt?.toISOString() ?? "",
+ componentImpacts: (update.componentImpacts ?? []).map(
+ dbComponentImpactToProto,
+ ),
};
}
diff --git a/apps/server/src/routes/rpc/handlers/status-report/index.ts b/apps/server/src/routes/rpc/handlers/status-report/index.ts
index 6a01a3b46..66b0553bc 100644
--- a/apps/server/src/routes/rpc/handlers/status-report/index.ts
+++ b/apps/server/src/routes/rpc/handlers/status-report/index.ts
@@ -1,5 +1,8 @@
import { Code, ConnectError, type ServiceImpl } from "@connectrpc/connect";
-import type { StatusReportService } from "@openstatus/proto/status_report/v1";
+import type {
+ ComponentImpact,
+ StatusReportService,
+} from "@openstatus/proto/status_report/v1";
import { StatusReportStatus } from "@openstatus/proto/status_report/v1";
import {
addStatusReportUpdate,
@@ -16,6 +19,7 @@ import { getRpcContext } from "../../interceptors";
import {
dbReportToProto,
dbReportToProtoSummary,
+ protoImpactToDb,
protoStatusToDb,
} from "./converters";
import { invalidDateFormatError, statusReportIdRequiredError } from "./errors";
@@ -41,6 +45,20 @@ function parsePageComponentIds(ids: ReadonlyArray<string>): number[] {
});
}
+// empty list ⇒ undefined: an old client omitting the field must produce a
+// legacy report (zero impact rows), never default to operational
+function parseComponentImpacts(
+ impacts: ReadonlyArray<ComponentImpact>,
+):
+ | { pageComponentId: number; impact: ReturnType<typeof protoImpactToDb> }[]
+ | undefined {
+ if (impacts.length === 0) return undefined;
+ return impacts.map((ci) => ({
+ pageComponentId: parsePageComponentIds([ci.pageComponentId])[0],
+ impact: protoImpactToDb(ci.impact),
+ }));
+}
+
export const statusReportServiceImpl: ServiceImpl<typeof StatusReportService> =
{
async createStatusReport(req, ctx) {
@@ -62,6 +80,7 @@ export const statusReportServiceImpl: ServiceImpl<typeof StatusReportService> =
date: parseDate(req.date),
pageId,
pageComponentIds: parsePageComponentIds(req.pageComponentIds),
+ componentImpacts: parseComponentImpacts(req.componentImpacts),
},
});
@@ -212,6 +231,7 @@ export const statusReportServiceImpl: ServiceImpl<typeof StatusReportService> =
status: protoStatusToDb(req.status),
message: req.message,
date: req.date ? parseDate(req.date) : undefined,
+ componentImpacts: parseComponentImpacts(req.componentImpacts),
},
});
diff --git a/apps/server/src/routes/slack/agent.ts b/apps/server/src/routes/slack/agent.ts
index 793ee38ec..739deb375 100644
--- a/apps/server/src/routes/slack/agent.ts
+++ b/apps/server/src/routes/slack/agent.ts
@@ -4,6 +4,7 @@ import { generateText, stepCountIs } from "ai";
import type { ModelMessage } from "ai";
import { buildSlackTools } from "./registry-runner";
+import { buildSystemPrompt } from "./system-prompt";
// Vercel AI Gateway model id. Override via SLACK_AGENT_MODEL when rolling
// out a new Sonnet version. Dotted format (`4.6`, not `4-6`) is what the
@@ -24,61 +25,6 @@ interface AgentResult {
toolResults: Array<{ toolName: string; result: unknown }>;
}
-export function buildSystemPrompt(workspaceName: string): string {
- // Intentional: a per-call ISO timestamp defeats Anthropic/Gateway
- // prompt caching, but the agent needs minute-level precision to parse
- // relative times like "next Friday from 2-3 PM". Slack agent volume is
- // low; the latency/cost trade is acceptable. If this ever becomes hot,
- // move the timestamp to the first user message so the rest of the
- // system prompt can cache.
- const now = new Date().toISOString();
- return `You are the OpenStatus assistant for workspace "${workspaceName}".
-The current date and time is: ${now} (UTC).
-You help teams create and manage status reports and maintenance windows through Slack.
-
-IMPORTANT: You have NO knowledge of this workspace's data. NEVER guess or make up IDs (page IDs, component IDs, report IDs). You MUST call the appropriate tool first to get real data.
-- Questions about pages or components -> call list_status_pages FIRST
-- Questions about reports -> call list_status_reports FIRST
-- Questions about maintenances -> call list_maintenances FIRST
-- Creating a report -> you MUST call list_status_pages first to get the real pageId, then call create_status_report with that pageId
-- Scheduling maintenance -> you MUST call list_status_pages first to get the real pageId, then call create_maintenance with that pageId
-- Components live on a specific page — call list_page_components({ pageId }) to discover pageComponentIds.
-- NEVER pass a pageId you did not receive from list_status_pages. Guessing a pageId WILL cause an error.
-
-Capabilities:
-- Create status reports on status pages (create_status_report)
-- Publish progress updates to existing reports (add_status_report_update)
-- Edit report metadata like title or components (update_status_report)
-- Resolve active reports (resolve_status_report)
-- List active status reports and status pages
-- Schedule maintenance windows (create_maintenance)
-- List upcoming maintenance windows (list_maintenances)
-
-Lifecycle: create_status_report once -> add_status_report_update repeatedly -> resolve_status_report.
-- "provide an update", "we found the cause" -> add_status_report_update
-- "it's fixed", "resolve it" -> resolve_status_report
-- "rename the report", "add a component" -> update_status_report (metadata only)
-
-Guidelines:
-- If multiple status pages exist, ask which one to use. If only one, use it automatically.
-- Infer the status from conversation context:
- "we have an incident" -> investigating
- "we found the root cause" -> identified
- "we're watching it" -> monitoring
- "it's fixed" -> resolved
-- Draft professional status page updates. Don't repeat the user verbatim.
-- When tagged in a thread, synthesize the full thread into a status report draft.
-- Status progression: investigating -> identified -> monitoring -> resolved
-- Be concise. Use Slack mrkdwn formatting (*bold*, _italic_).
-- For any mutation, always call the tool so the user sees a confirmation.
-
-Maintenance scheduling:
-- Parse natural language dates into ISO 8601 format. Convert relative dates like "next Friday from 2-3 PM" into proper ISO 8601 timestamps.
-- If the user doesn't specify a timezone, default to UTC and mention that in your response.
-- The "from" time must be before the "to" time.
-- Write a professional maintenance message describing what will happen during the window.`;
-}
-
function convertThreadToMessages(
thread: SlackThreadMessage[],
botUserId: string,
diff --git a/apps/server/src/routes/slack/blocks.test.ts b/apps/server/src/routes/slack/blocks.test.ts
index 29526a0af..65cd22bef 100644
--- a/apps/server/src/routes/slack/blocks.test.ts
+++ b/apps/server/src/routes/slack/blocks.test.ts
@@ -58,6 +58,50 @@ describe("buildConfirmationBlocks", () => {
expect(section.text.text).toContain("101, 102");
});
+ test("create_status_report shows impacts when provided", () => {
+ const tool = agentTools.create_status_report;
+ const blocks = buildConfirmationBlocks({
+ actionId: "i1",
+ tool,
+ input: {
+ title: "Test",
+ status: "investigating",
+ message: "msg",
+ pageId: 1,
+ pageComponentIds: [101],
+ componentImpacts: [
+ { pageComponentId: 101, impact: "major_outage" },
+ { pageComponentId: 102, impact: "degraded_performance" },
+ ],
+ },
+ });
+ const section = blocks.find((b) => b.type === "section") as {
+ text: { text: string };
+ };
+ expect(section.text.text).toContain("Impacts");
+ expect(section.text.text).toContain("101 → major_outage");
+ expect(section.text.text).toContain("102 → degraded_performance");
+ });
+
+ test("add_status_report_update shows impacts when provided", () => {
+ const tool = agentTools.add_status_report_update;
+ const blocks = buildConfirmationBlocks({
+ actionId: "i2",
+ tool,
+ input: {
+ statusReportId: 42,
+ status: "monitoring",
+ message: "recovering",
+ componentImpacts: [{ pageComponentId: 7, impact: "partial_outage" }],
+ },
+ });
+ const section = blocks.find((b) => b.type === "section") as {
+ text: { text: string };
+ };
+ expect(section.text.text).toContain("Impacts");
+ expect(section.text.text).toContain("7 → partial_outage");
+ });
+
test("add_status_report_update has 3 buttons", () => {
const tool = agentTools.add_status_report_update;
const blocks = buildConfirmationBlocks({
diff --git a/apps/server/src/routes/slack/registry-runner.test.ts b/apps/server/src/routes/slack/registry-runner.test.ts
index 50071cae9..e55c96097 100644
--- a/apps/server/src/routes/slack/registry-runner.test.ts
+++ b/apps/server/src/routes/slack/registry-runner.test.ts
@@ -96,6 +96,19 @@ describe("buildSlackTools", () => {
expect("pageId" in shape).toBe(true);
});
+ test("componentImpacts stays in the LLM-facing schema (only extraFlags are hidden)", () => {
+ for (const name of [
+ "create_status_report",
+ "add_status_report_update",
+ ] as const) {
+ const t = tools[name] as {
+ inputSchema: z.ZodObject<z.ZodRawShape>;
+ };
+ expect("componentImpacts" in t.inputSchema.shape, name).toBe(true);
+ expect("notify" in t.inputSchema.shape, name).toBe(false);
+ }
+ });
+
test("destructive tools without extraFlags keep their full schema", () => {
const t = tools.update_status_report as {
inputSchema: z.ZodObject<z.ZodRawShape>;
diff --git a/apps/server/src/routes/slack/agent.test.ts b/apps/server/src/routes/slack/system-prompt.test.ts
similarity index 61%
rename from apps/server/src/routes/slack/agent.test.ts
rename to apps/server/src/routes/slack/system-prompt.test.ts
index 078d031fa..0b23f7987 100644
--- a/apps/server/src/routes/slack/agent.test.ts
+++ b/apps/server/src/routes/slack/system-prompt.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test";
-import { buildSystemPrompt } from "./agent";
+import { buildSystemPrompt } from "./system-prompt";
describe("buildSystemPrompt", () => {
test("includes the current date and time in ISO 8601 format", () => {
@@ -23,4 +23,14 @@ describe("buildSystemPrompt", () => {
const prompt = buildSystemPrompt("Acme Corp");
expect(prompt).toContain('workspace "Acme Corp"');
});
+
+ test("guides the model on componentImpacts", () => {
+ const prompt = buildSystemPrompt("Acme Corp");
+ expect(prompt).toContain("componentImpacts");
+ expect(prompt).toContain("major_outage");
+ // resolve auto-clears impacts; the model must not publish a manual clear.
+ expect(prompt).toContain("clears every remaining impact");
+ // partial recovery before resolve IS reported manually, as operational.
+ expect(prompt).toContain("Recovery counts as a change");
+ });
});
diff --git a/apps/server/src/routes/slack/system-prompt.ts b/apps/server/src/routes/slack/system-prompt.ts
new file mode 100644
index 000000000..9d61da5ba
--- /dev/null
+++ b/apps/server/src/routes/slack/system-prompt.ts
@@ -0,0 +1,64 @@
+// dependency-free leaf so the prompt test doesn't link the agent's module
+// graph (ai + services) — bun test flakes on concurrent linking of large graphs.
+export function buildSystemPrompt(workspaceName: string): string {
+ // Intentional: a per-call ISO timestamp defeats Anthropic/Gateway
+ // prompt caching, but the agent needs minute-level precision to parse
+ // relative times like "next Friday from 2-3 PM". Slack agent volume is
+ // low; the latency/cost trade is acceptable. If this ever becomes hot,
+ // move the timestamp to the first user message so the rest of the
+ // system prompt can cache.
+ const now = new Date().toISOString();
+ return `You are the OpenStatus assistant for workspace "${workspaceName}".
+The current date and time is: ${now} (UTC).
+You help teams create and manage status reports and maintenance windows through Slack.
+
+IMPORTANT: You have NO knowledge of this workspace's data. NEVER guess or make up IDs (page IDs, component IDs, report IDs). You MUST call the appropriate tool first to get real data.
+- Questions about pages or components -> call list_status_pages FIRST
+- Questions about reports -> call list_status_reports FIRST
+- Questions about maintenances -> call list_maintenances FIRST
+- Creating a report -> you MUST call list_status_pages first to get the real pageId, then call create_status_report with that pageId
+- Scheduling maintenance -> you MUST call list_status_pages first to get the real pageId, then call create_maintenance with that pageId
+- Components live on a specific page — call list_page_components({ pageId }) to discover pageComponentIds.
+- componentImpacts on create_status_report and add_status_report_update reference components by id — those ids MUST also come from list_page_components.
+- NEVER pass a pageId you did not receive from list_status_pages. Guessing a pageId WILL cause an error.
+
+Capabilities:
+- Create status reports on status pages (create_status_report)
+- Publish progress updates to existing reports (add_status_report_update)
+- Edit report metadata like title or components (update_status_report)
+- Resolve active reports (resolve_status_report)
+- List active status reports and status pages
+- Schedule maintenance windows (create_maintenance)
+- List upcoming maintenance windows (list_maintenances)
+
+Lifecycle: create_status_report once -> add_status_report_update repeatedly -> resolve_status_report.
+- "provide an update", "we found the cause" -> add_status_report_update
+- "it's fixed", "resolve it" -> resolve_status_report
+- "rename the report", "add a component" -> update_status_report (metadata only)
+
+Component impact:
+- create_status_report and add_status_report_update accept componentImpacts: a per-component impact level (operational | degraded_performance | partial_outage | major_outage).
+- When the user names affected components, include componentImpacts in the draft — map their wording to a level: "down"/"unreachable" -> major_outage, "slow"/"degraded" -> degraded_performance, "broken for some users" -> partial_outage. Ask when the wording is ambiguous.
+- On follow-up updates, only name components whose impact CHANGED — omitted components keep their prior impact.
+- Recovery counts as a change: when a component is back to normal before the incident is resolved ("API is back up"), set it to operational in that update.
+- resolve_status_report clears every remaining impact back to operational automatically — never publish a manual "everything operational" update for that.
+
+Guidelines:
+- If multiple status pages exist, ask which one to use. If only one, use it automatically.
+- Infer the status from conversation context:
+ "we have an incident" -> investigating
+ "we found the root cause" -> identified
+ "we're watching it" -> monitoring
+ "it's fixed" -> resolved
+- Draft professional status page updates. Don't repeat the user verbatim.
+- When tagged in a thread, synthesize the full thread into a status report draft.
+- Status progression: investigating -> identified -> monitoring -> resolved
+- Be concise. Use Slack mrkdwn formatting (*bold*, _italic_).
+- For any mutation, always call the tool so the user sees a confirmation.
+
+Maintenance scheduling:
+- Parse natural language dates into ISO 8601 format. Convert relative dates like "next Friday from 2-3 PM" into proper ISO 8601 timestamps.
+- If the user doesn't specify a timezone, default to UTC and mention that in your response.
+- The "from" time must be before the "to" time.
+- Write a professional maintenance message describing what will happen during the window.`;
+}
diff --git a/apps/server/static/openapi.yaml b/apps/server/static/openapi.yaml
index 42c62ee79..64df79e74 100644
--- a/apps/server/static/openapi.yaml
+++ b/apps/server/static/openapi.yaml
@@ -3603,6 +3603,15 @@ components:
- "null"
title: notify
description: Whether to notify subscribers about this update (optional, defaults to false).
+ componentImpacts:
+ type: array
+ items:
+ $ref: '#/components/schemas/openstatus.status_report.v1.ComponentImpact'
+ title: component_impacts
+ description: |-
+ Per-component impacts this update sets (optional). Components named here
+ are added to the report's affected set; omitted components keep their
+ prior impact.
title: AddStatusReportUpdateRequest
additionalProperties: false
description: AddStatusReportUpdateRequest is the request to add a new update to a status report.
@@ -3616,6 +3625,20 @@ components:
title: AddStatusReportUpdateResponse
additionalProperties: false
description: AddStatusReportUpdateResponse is the response after adding an update to a status report.
+ openstatus.status_report.v1.ComponentImpact:
+ type: object
+ properties:
+ pageComponentId:
+ type: string
+ title: page_component_id
+ description: ID of the affected page component.
+ impact:
+ title: impact
+ description: Impact set for the component.
+ $ref: '#/components/schemas/openstatus.status_report.v1.PageComponentImpact'
+ title: ComponentImpact
+ additionalProperties: false
+ description: ComponentImpact pairs a page component with the impact an update set for it.
openstatus.status_report.v1.CreateStatusReportRequest:
type: object
properties:
@@ -3661,6 +3684,15 @@ components:
- "null"
title: notify
description: Whether to notify subscribers about this status report (optional, defaults to false).
+ componentImpacts:
+ type: array
+ items:
+ $ref: '#/components/schemas/openstatus.status_report.v1.ComponentImpact'
+ title: component_impacts
+ description: |-
+ Per-component impacts set by the initial update (optional). When provided,
+ the named components are added to the report's affected set. Omitting this
+ field creates a legacy report without impact tracking.
title: CreateStatusReportRequest
additionalProperties: false
description: CreateStatusReportRequest is the request to create a new status report.
@@ -3762,6 +3794,18 @@ components:
title: ListStatusReportsResponse
additionalProperties: false
description: ListStatusReportsResponse is the response containing status report summaries.
+ openstatus.status_report.v1.PageComponentImpact:
+ type: string
+ title: PageComponentImpact
+ enum:
+ - PAGE_COMPONENT_IMPACT_UNSPECIFIED
+ - PAGE_COMPONENT_IMPACT_OPERATIONAL
+ - PAGE_COMPONENT_IMPACT_DEGRADED_PERFORMANCE
+ - PAGE_COMPONENT_IMPACT_PARTIAL_OUTAGE
+ - PAGE_COMPONENT_IMPACT_MAJOR_OUTAGE
+ description: |-
+ PageComponentImpact is the per-component impact a status report update sets.
+ UNSPECIFIED means the caller doesn't speak impact (legacy) — it is NOT operational.
openstatus.status_report.v1.StatusReport:
type: object
properties:
@@ -3865,6 +3909,12 @@ components:
type: string
title: created_at
description: Timestamp when the update was created (RFC 3339 format).
+ componentImpacts:
+ type: array
+ items:
+ $ref: '#/components/schemas/openstatus.status_report.v1.ComponentImpact'
+ title: component_impacts
+ description: Per-component impacts this update set (empty for legacy reports).
title: StatusReportUpdate
additionalProperties: false
description: StatusReportUpdate represents a single update entry in a status report timeline.
diff --git a/apps/status-page/messages/de.json b/apps/status-page/messages/de.json
index 522b1c2b0..54db17e6c 100644
--- a/apps/status-page/messages/de.json
+++ b/apps/status-page/messages/de.json
@@ -92,6 +92,9 @@
"/GKH/w": "Wird untersucht",
"myq2ZL": "Normal",
"KN7zKn": "Fehler",
+ "SsC4IV": "Eingeschränkte Leistung",
+ "Fh9xh1": "Teilweiser Ausfall",
+ "sSIbEd": "Schwerwiegender Ausfall",
"kkpP2k": "heute",
"2wsjxR": "laufend",
"2syGZB": "Bericht gelöst",
diff --git a/apps/status-page/messages/en.json b/apps/status-page/messages/en.json
index d21680ade..3c3fdc8a9 100644
--- a/apps/status-page/messages/en.json
+++ b/apps/status-page/messages/en.json
@@ -92,6 +92,9 @@
"/GKH/w": "Investigating",
"myq2ZL": "Normal",
"KN7zKn": "Error",
+ "SsC4IV": "Degraded performance",
+ "Fh9xh1": "Partial outage",
+ "sSIbEd": "Major outage",
"kkpP2k": "today",
"2wsjxR": "ongoing",
"2syGZB": "Report resolved",
diff --git a/apps/status-page/messages/fr.json b/apps/status-page/messages/fr.json
index 883f8cecb..3fc108553 100644
--- a/apps/status-page/messages/fr.json
+++ b/apps/status-page/messages/fr.json
@@ -92,6 +92,9 @@
"/GKH/w": "En cours d'investigation",
"myq2ZL": "Normal",
"KN7zKn": "Erreur",
+ "SsC4IV": "Performances dégradées",
+ "Fh9xh1": "Panne partielle",
+ "sSIbEd": "Panne majeure",
"kkpP2k": "aujourd'hui",
"2wsjxR": "en cours",
"2syGZB": "Rapport résolu",
diff --git a/apps/status-page/messages/hi.json b/apps/status-page/messages/hi.json
index b456aa445..dabb72489 100644
--- a/apps/status-page/messages/hi.json
+++ b/apps/status-page/messages/hi.json
@@ -92,6 +92,9 @@
"/GKH/w": "जांच",
"myq2ZL": "सामान्य",
"KN7zKn": "त्रुटि",
+ "SsC4IV": "खराब प्रदर्शन",
+ "Fh9xh1": "आंशिक आउटेज",
+ "sSIbEd": "बड़ा आउटेज",
"kkpP2k": "आज",
"2wsjxR": "जारी",
"2syGZB": "रिपोर्ट समाधान किया गया",
@@ -116,7 +119,7 @@
"3Vaz8F": "स्थिति ट्रैकर",
"apbxET": "दिन {n} की स्थिति",
"GbVCQb": "अनपिन करने के लिए फिर से क्लिक करें",
- "Coy6SH": "",
+ "Coy6SH": "कैलेंडर",
"heezSZ": "({duration} में)",
"lKJjwW": "({timeFromLast} पहले)",
"VaZnIX": "({duration} के लिए)",
diff --git a/apps/status-page/messages/tr.json b/apps/status-page/messages/tr.json
index 30d1a6f1d..5d13c54ec 100644
--- a/apps/status-page/messages/tr.json
+++ b/apps/status-page/messages/tr.json
@@ -92,6 +92,9 @@
"/GKH/w": "İnceleniyor",
"myq2ZL": "Normal",
"KN7zKn": "Hata",
+ "SsC4IV": "Düşük performans",
+ "Fh9xh1": "Kısmi kesinti",
+ "sSIbEd": "Büyük kesinti",
"kkpP2k": "bugün",
"2wsjxR": "devam ediyor",
"2syGZB": "Rapor çözüldü",
diff --git a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/client.tsx b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/client.tsx
index 0beafd632..920c095df 100644
--- a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/client.tsx
+++ b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/client.tsx
@@ -52,6 +52,7 @@ import {
import { StatusFeed } from "@/components/status-page/status-feed";
import { useEmbed } from "@/hooks/use-embed";
import { usePathnamePrefix } from "@/hooks/use-pathname-prefix";
+import { updatesWithImpactChanges } from "@/lib/report-impacts";
import { useTRPC } from "@/lib/trpc/client";
export function Client() {
@@ -343,7 +344,7 @@ export function Client() {
affected: report.statusReportsToPageComponents.map(
(component) => component.pageComponent.name,
),
- updates: report.statusReportUpdates,
+ updates: updatesWithImpactChanges(report),
}))}
maintenances={page.maintenances
.filter((maintenance) =>
diff --git a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/events/(list)/page.tsx b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/events/(list)/page.tsx
index eff50678e..0d64d5c67 100644
--- a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/events/(list)/page.tsx
+++ b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/events/(list)/page.tsx
@@ -26,6 +26,7 @@ import {
StatusEventTitle,
StatusEventTitleCheck,
} from "@/components/status-page/status-events";
+import { updatesWithImpactChanges } from "@/lib/report-impacts";
import { useTRPC } from "@/lib/trpc/client";
import { searchParamsParsers } from "./search-params";
@@ -101,7 +102,7 @@ export default function Page() {
</StatusEventAffected>
) : null}
<StatusEventTimelineReport
- updates={report.statusReportUpdates}
+ updates={updatesWithImpactChanges(report)}
/>
</StatusEventContent>
</Link>
diff --git a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/events/(view)/report/[id]/page.tsx b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/events/(view)/report/[id]/page.tsx
index d5dd4b9b4..1387487c9 100644
--- a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/events/(view)/report/[id]/page.tsx
+++ b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/events/(view)/report/[id]/page.tsx
@@ -18,6 +18,7 @@ import {
StatusEventTitle,
StatusEventTitleCheck,
} from "@/components/status-page/status-events";
+import { updatesWithImpactChanges } from "@/lib/report-impacts";
import { useTRPC } from "@/lib/trpc/client";
export default function ReportPage() {
@@ -43,6 +44,8 @@ export default function ReportPage() {
const firstUpdate = updates[updates.length - 1];
const lastUpdate = updates[0];
+ const updatesWithImpacts = updatesWithImpactChanges(report);
+
// HACKY: LEGACY: only resolved via report and not via report update
const isReportResolvedOnly =
report.status === "resolved" && lastUpdate?.status !== "resolved";
@@ -73,7 +76,7 @@ export default function ReportPage() {
))}
</StatusEventAffected>
) : null}
- <StatusEventTimelineReport updates={report.statusReportUpdates} />
+ <StatusEventTimelineReport updates={updatesWithImpacts} />
</StatusEventContent>
</StatusEvent>
</div>
diff --git a/apps/status-page/src/components/i18n/status-blocks-provider.tsx b/apps/status-page/src/components/i18n/status-blocks-provider.tsx
index ff73c2601..36840be97 100644
--- a/apps/status-page/src/components/i18n/status-blocks-provider.tsx
+++ b/apps/status-page/src/components/i18n/status-blocks-provider.tsx
@@ -58,6 +58,12 @@ export function StatusBlocksProvider({
info: t("Maintenance"),
empty: t("No Data"),
},
+ componentImpact: {
+ operational: t("Operational"),
+ degraded_performance: t("Degraded performance"),
+ partial_outage: t("Partial outage"),
+ major_outage: t("Major outage"),
+ },
today: t("today"),
ongoing: t("ongoing"),
diff --git a/apps/status-page/src/components/status-page/status-bar.tsx b/apps/status-page/src/components/status-page/status-bar.tsx
index ab454d230..9b43257ab 100644
--- a/apps/status-page/src/components/status-page/status-bar.tsx
+++ b/apps/status-page/src/components/status-page/status-bar.tsx
@@ -30,6 +30,7 @@ export function StatusBar(
from={event.from}
to={event.to}
isAggregated={event.isAggregated}
+ status={event.status}
/>
);
if (event.type === "report" || event.type === "maintenance") {
diff --git a/apps/status-page/src/lib/report-impacts.ts b/apps/status-page/src/lib/report-impacts.ts
new file mode 100644
index 000000000..03f430da8
--- /dev/null
+++ b/apps/status-page/src/lib/report-impacts.ts
@@ -0,0 +1,35 @@
+import type { StatusReportImpact } from "@openstatus/ui/components/blocks/status.types";
+
+type ReportWithImpactRows<U> = {
+ statusReportsToPageComponents: {
+ pageComponent: { id: number; name: string };
+ }[];
+ statusReportUpdates: U[];
+};
+
+/**
+ * Maps a report's update impact rows to the `impactChanges` shape consumed by
+ * the timeline blocks, resolving component names from the report associations.
+ */
+export function updatesWithImpactChanges<
+ U extends {
+ statusReportUpdateToPageComponents: {
+ pageComponentId: number;
+ impact: StatusReportImpact;
+ }[];
+ },
+>(report: ReportWithImpactRows<U>) {
+ const nameById = new Map(
+ report.statusReportsToPageComponents.map((a) => [
+ a.pageComponent.id,
+ a.pageComponent.name,
+ ]),
+ );
+ return report.statusReportUpdates.map((update) => ({
+ ...update,
+ impactChanges: update.statusReportUpdateToPageComponents.map((ci) => ({
+ name: nameById.get(ci.pageComponentId) ?? `#${ci.pageComponentId}`,
+ impact: ci.impact,
+ })),
+ }));
+}
diff --git a/apps/web/public/assets/changelog/status-page-components-impact.png b/apps/web/public/assets/changelog/status-page-components-impact.png
new file mode 100644
index 000000000..b70f8ee81
Binary files /dev/null and b/apps/web/public/assets/changelog/status-page-components-impact.png differ
diff --git a/apps/web/src/content/pages/changelog/status-page-components-impact.mdx b/apps/web/src/content/pages/changelog/status-page-components-impact.mdx
new file mode 100644
index 000000000..63f8ef452
--- /dev/null
+++ b/apps/web/src/content/pages/changelog/status-page-components-impact.mdx
@@ -0,0 +1,21 @@
+---
+title: "Component impacts on status reports"
+description: "Tell visitors which components are affected and how badly — per update, over the whole incident."
+image: "/assets/changelog/status-page-components-impact.png"
+publishedAt: "2026-06-11"
+category: "statuspage"
+author: "openstatus"
+---
+
+Status reports can now carry a per-component **impact**: `operational`, `degraded performance`, `partial outage` or `major outage`. Instead of a single coarse "degraded" signal, every report update snapshots how badly each affected component is hit — and you can change those impacts update by update as the incident evolves.
+
+On the public status page:
+
+- component rows and the top-level indicator derive their color from the worst active impact
+- the report timeline shows impact change badges per update, so visitors can follow recovery (major outage → partial outage → operational)
+- the bar hover card surfaces the day's worst impact
+- manual uptime now weights time-in-status per component — a partial outage no longer counts the same as a full one
+
+In the dashboard, pick an impact per component when creating a report or posting an update; you can also edit impacts on existing updates. Impacts are available on the API and importers from Atlassian Statuspage and Better Stack preserve per-update impacts on migration.
+
+Existing reports are untouched — they keep today's behavior until you set impacts on a new one.
diff --git a/apps/web/src/content/pages/docs/concept/uptime-calculation-and-values.mdx b/apps/web/src/content/pages/docs/concept/uptime-calculation-and-values.mdx
index 4b868ba53..2ee44bc11 100644
--- a/apps/web/src/content/pages/docs/concept/uptime-calculation-and-values.mdx
+++ b/apps/web/src/content/pages/docs/concept/uptime-calculation-and-values.mdx
@@ -64,6 +64,18 @@ This is ideal if:
In this mode, all displayed uptime values and statuses come from your shared report data, not from active pings.
-In simple terms: `uptime = (total duration - status report duration) / total duration`
+In simple terms: `uptime = (total duration - weighted status report duration) / total duration`
+
+How much a report counts against uptime depends on the [component impact](/docs/reference/status-report#component-impacts) each update sets:
+
+| Impact | Downtime weight |
+|--------|-----------------|
+| `operational` / `degraded_performance` | 0 |
+| `partial_outage` | 0.5 |
+| `major_outage` | 1 |
+
+A report that goes `major_outage` → `partial_outage` → `operational` across its updates counts each interval at its own weight.
+
+> **Legacy behavior:** reports without impact levels (created before component impacts existed, or via clients that don't send them) count their full duration as downtime — `uptime = (total duration - status report duration) / total duration`.
> **Note:** the values you define are attached to a status page. You cannot change them per monitor (for now).
diff --git a/apps/web/src/content/pages/docs/reference/page-components.mdx b/apps/web/src/content/pages/docs/reference/page-components.mdx
index abe31c0ad..b5acaba30 100644
--- a/apps/web/src/content/pages/docs/reference/page-components.mdx
+++ b/apps/web/src/content/pages/docs/reference/page-components.mdx
@@ -72,7 +72,7 @@ You can customize the component name to be different from the monitor name. For
**Status hierarchy:**
-1. **Error** — active incidents from the linked monitor.
+1. **Error** — active incidents from the linked monitor, or a status report with a `major_outage` [impact](/docs/reference/status-report#component-impacts).
2. **Degraded** — unresolved status reports affecting this component.
3. **Info** — ongoing scheduled maintenance.
4. **Success** — healthy and operational.
@@ -113,8 +113,8 @@ Static components give you full manual control over what your visitors see:
**Status reports:**
Create status reports to indicate issues or degraded performance for static components. For example:
-- "Stripe payment processing experiencing delays" (degraded status).
-- "Email delivery service partially unavailable" (degraded status).
+- "Stripe payment processing experiencing delays" (degraded performance impact).
+- "Email delivery service partially unavailable" (partial outage impact).
Once you resolve the issue and mark the status report as resolved, the component returns to a success status.
@@ -134,9 +134,10 @@ Static components do not perform any health checks or generate incidents. You ar
**Status hierarchy:**
-1. **Degraded** — unresolved status reports affecting this component.
-2. **Info** — ongoing scheduled maintenance.
-3. **Success** — no active reports or maintenances.
+1. **Error** — a status report with a `major_outage` [impact](/docs/reference/status-report#component-impacts).
+2. **Degraded** — other unresolved status reports affecting this component.
+3. **Info** — ongoing scheduled maintenance.
+4. **Success** — no active reports or maintenances.
**What affects static components:**
@@ -205,7 +206,7 @@ Static components **never** generate incidents because they are not linked to mo
Status reports are manually created updates about component health or issues. They provide a way to communicate problems that may not trigger automatic monitoring or to manually report issues with static components.
-**Status impact:** components with unresolved status reports show a **degraded** status (unless overridden by an incident for monitor components).
+**Status impact:** each report update can set a per-component [impact level](/docs/reference/status-report#component-impacts) (`degraded_performance`, `partial_outage`, `major_outage`). A component with an active `major_outage` impact shows an **error** status; the other non-operational impacts show **degraded**. Reports without impact levels show a **degraded** status while unresolved.
**Use cases for monitor components:**
diff --git a/apps/web/src/content/pages/docs/reference/status-report.mdx b/apps/web/src/content/pages/docs/reference/status-report.mdx
index fb1dd4442..b29c63d1a 100644
--- a/apps/web/src/content/pages/docs/reference/status-report.mdx
+++ b/apps/web/src/content/pages/docs/reference/status-report.mdx
@@ -51,7 +51,67 @@ A descriptive message detailing the update, actions taken, or any relevant infor
- `"Fix deployed to production. Monitoring service health for full recovery."`
- `"All services restored to normal operation. Incident resolved."`
+### Affected components
+
+**Type:** Array of page component references (optional)
+
+A status report can be attached to one or more [page components](/docs/reference/page-components) on a single status page. The attached components define which services the report affects — they are highlighted on the public status page while the report is unresolved.
+
+All attached components must belong to the same status page. Adding a component impact in a later update (see below) automatically adds that component to the report's affected set.
+
+## Component impacts
+
+Beyond marking a component as affected, each update of a status report can declare **how badly** each component is affected. This per-component impact drives the component's live status, the report's overall indicator, and — for status pages using manual uptime — the uptime percentage.
+
+### Impact levels
+
+**Type:** Enumerated string, set per component and per update
+
+| Impact | Label | Meaning |
+|--------|-------|---------|
+| `operational` | Operational | The component has recovered or is unaffected. |
+| `degraded_performance` | Degraded performance | Slow or partially failing, but available. |
+| `partial_outage` | Partial outage | Some users or requests are failing. |
+| `major_outage` | Major outage | The component is down. |
+
+### How impacts evolve over time
+
+Impacts follow the timeline of the report's updates:
+
+- Each update snapshots the impacts it sets. A component's **current impact** is the one from the latest update that names it.
+- Components **omitted** from an update keep their prior impact — you only declare what changed.
+- Resolving a report sets every still-affected component back to `operational`, so the status page clears deterministically.
+
+**Example timeline:**
+
+```
+Update 1 (investigating): API → major outage
+Update 2 (identified): API → partial outage, Website → degraded performance
+Update 3 (resolved): API → operational, Website → operational
+```
+
+After update 2, the API shows _partial outage_ (latest update naming it) and the Website shows _degraded performance_.
+
+### Effect on the status page
+
+- **Component status:** `major_outage` renders the component and its status bar red; `degraded_performance` and `partial_outage` render orange; `operational` renders green.
+- **Report indicator:** the report's overall state is derived from the **worst** active component impact — it is not stored separately.
+- **Manual uptime:** on status pages using [manual uptime calculation](/docs/concept/uptime-calculation-and-values#manual-type), each interval between updates counts against uptime weighted by its impact:
+
+| Impact | Downtime weight |
+|--------|-----------------|
+| `operational` | 0 |
+| `degraded_performance` | 0 — slow but available is not downtime |
+| `partial_outage` | 0.5 — some users affected, not all |
+| `major_outage` | 1 — full downtime |
+
+<Aside>
+Status reports created before component impacts existed (or via API clients that don't send impacts) have no impact rows. They keep the previous behavior: the affected components render orange and, in manual mode, the report's full duration counts as downtime.
+</Aside>
+
## Related resources
- **[Incident reference](/docs/reference/incident)** — detailed information on incident creation and lifecycle.
- **[Status page reference](/docs/reference/status-page)** — how status reports are displayed on public status pages.
+- **[Page components reference](/docs/reference/page-components)** — the components a report and its impacts attach to.
+- **[Uptime calculation](/docs/concept/uptime-calculation-and-values)** — how impacts weight manual-mode uptime.
diff --git a/packages/api/src/router/statusPage.ts b/packages/api/src/router/statusPage.ts
index c088fddff..2692108c6 100644
--- a/packages/api/src/router/statusPage.ts
+++ b/packages/api/src/router/statusPage.ts
@@ -29,6 +29,7 @@ import { z } from "zod";
import { createTRPCRouter, publicProcedure } from "../trpc";
import {
type StatusData,
+ activeReportStatus,
fillStatusDataFor45Days,
fillStatusDataFor45DaysNoop,
getEvents,
@@ -86,6 +87,7 @@ export const statusPageRouter = createTRPCRouter({
with: {
statusReportUpdates: {
orderBy: (reports, { desc }) => desc(reports.date),
+ with: { statusReportUpdateToPageComponents: true },
},
statusReportsToPageComponents: { with: { pageComponent: true } },
},
@@ -146,36 +148,39 @@ export const statusPageRouter = createTRPCRouter({
// Calculate status based on component type
let status: "success" | "degraded" | "error" | "info";
+ // impact-aware: an active report colors the component by its derived
+ // status (major ⇒ error); legacy reports keep flat degraded
+ const reportStatus = activeReportStatus(events);
+
if (c.type === "static") {
// Static: only reports and maintenances affect status
- status = events.some((e) => e.type === "report" && !e.to)
- ? "degraded"
- : events.some(
- (e) =>
- e.type === "maintenance" &&
- e.to &&
- e.from.getTime() <= new Date().getTime() &&
- e.to.getTime() >= new Date().getTime(),
- )
+ status =
+ reportStatus ??
+ (events.some(
+ (e) =>
+ e.type === "maintenance" &&
+ e.to &&
+ e.from.getTime() <= new Date().getTime() &&
+ e.to.getTime() >= new Date().getTime(),
+ )
? "info"
- : "success";
+ : "success");
} else {
// Monitor: incidents, reports, and maintenances affect status
status =
events.some((e) => e.type === "incident" && !e.to) &&
barType !== "manual"
? "error"
- : events.some((e) => e.type === "report" && !e.to)
- ? "degraded"
- : events.some(
- (e) =>
- e.type === "maintenance" &&
- e.to &&
- e.from.getTime() <= new Date().getTime() &&
- e.to.getTime() >= new Date().getTime(),
- )
+ : (reportStatus ??
+ (events.some(
+ (e) =>
+ e.type === "maintenance" &&
+ e.to &&
+ e.from.getTime() <= new Date().getTime() &&
+ e.to.getTime() >= new Date().getTime(),
+ )
? "info"
- : "success";
+ : "success"));
}
return {
@@ -197,17 +202,16 @@ export const statusPageRouter = createTRPCRouter({
events.some((e) => e.type === "incident" && !e.to) &&
barType !== "manual"
? "error"
- : events.some((e) => e.type === "report" && !e.to)
- ? "degraded"
- : events.some(
- (e) =>
- e.type === "maintenance" &&
- e.to &&
- e.from.getTime() <= new Date().getTime() &&
- e.to.getTime() >= new Date().getTime(),
- )
+ : (activeReportStatus(events) ??
+ (events.some(
+ (e) =>
+ e.type === "maintenance" &&
+ e.to &&
+ e.from.getTime() <= new Date().getTime() &&
+ e.to.getTime() >= new Date().getTime(),
+ )
? "info"
- : "success";
+ : "success"));
return {
...c.monitor,
status,
@@ -218,14 +222,15 @@ export const statusPageRouter = createTRPCRouter({
};
});
- const status =
- monitors.some((m) => m.status === "error") && barType !== "manual"
- ? "error"
- : monitors.some((m) => m.status === "degraded")
- ? "degraded"
- : monitors.some((m) => m.status === "info")
- ? "info"
- : "success";
+ // no barType gate: incident-driven error is already suppressed per
+ // monitor in manual mode; report-driven error (major_outage) must show
+ const status = monitors.some((m) => m.status === "error")
+ ? "error"
+ : monitors.some((m) => m.status === "degraded")
+ ? "degraded"
+ : monitors.some((m) => m.status === "info")
+ ? "info"
+ : "success";
// Get page-wide events (not tied to specific monitors)
const pageEvents = getEvents({
@@ -425,6 +430,7 @@ export const statusPageRouter = createTRPCRouter({
with: {
statusReportUpdates: {
orderBy: (reports, { desc }) => desc(reports.date),
+ with: { statusReportUpdateToPageComponents: true },
},
statusReportsToPageComponents: { with: { pageComponent: true } },
},
@@ -547,7 +553,9 @@ export const statusPageRouter = createTRPCRouter({
statusReports: {
with: {
statusReportsToPageComponents: { with: { pageComponent: true } },
- statusReportUpdates: true,
+ statusReportUpdates: {
+ with: { statusReportUpdateToPageComponents: true },
+ },
},
},
pageComponents: {
@@ -745,6 +753,7 @@ export const statusPageRouter = createTRPCRouter({
},
statusReportUpdates: {
orderBy: (reports, { desc }) => desc(reports.date),
+ with: { statusReportUpdateToPageComponents: true },
},
},
});
@@ -763,7 +772,7 @@ export const statusPageRouter = createTRPCRouter({
const identifiedDate = new Date(date.setMinutes(date.getMinutes() - 32));
const investigatingDate = new Date(date.setMinutes(date.getMinutes() - 4));
- const props: z.infer<typeof selectStatusReportPageSchema> = {
+ const props: z.input<typeof selectStatusReportPageSchema> = {
id: 1,
pageId: 1,
workspaceId: 1,
diff --git a/packages/api/src/router/statusPage.utils.test.ts b/packages/api/src/router/statusPage.utils.test.ts
index 2cca00cd2..f2e9c515d 100644
--- a/packages/api/src/router/statusPage.utils.test.ts
+++ b/packages/api/src/router/statusPage.utils.test.ts
@@ -9,6 +9,7 @@ import type {
} from "@openstatus/db/src/schema";
import {
+ currentImpactByComponent,
fillStatusDataFor45Days,
getEvents,
getUptime,
@@ -950,7 +951,7 @@ describe("getUptime", () => {
expect(Number.parseFloat(uptime)).toBeGreaterThan(97);
expect(Number.parseFloat(uptime)).toBeLessThan(98);
});
- it("should ignore reports when calculating duration uptime", () => {
+ it("should ignore legacy reports (no impact rows) when calculating duration uptime", () => {
const data = Array.from({ length: 45 }, (_, i) =>
createStatusData(i, 100, 0, 0),
);
@@ -1288,3 +1289,787 @@ describe("getEvents - pageComponent filtering", () => {
expect(reportEvents[0].status).toBe("degraded");
});
});
+
+describe("componentImpacts", () => {
+ type Impact =
+ | "operational"
+ | "degraded_performance"
+ | "partial_outage"
+ | "major_outage";
+
+ function dayStartUTC(daysAgo: number): Date {
+ const d = new Date();
+ d.setUTCDate(d.getUTCDate() - daysAgo);
+ d.setUTCHours(0, 0, 0, 0);
+ return d;
+ }
+
+ function hoursAfter(date: Date, hours: number): Date {
+ return new Date(date.getTime() + hours * 60 * 60 * 1000);
+ }
+
+ function createImpactEvent(
+ id: number,
+ from: Date,
+ to: Date | null,
+ impactIntervals: { from: Date; to: Date | null; impact: Impact }[],
+ ) {
+ return {
+ id,
+ name: `Impact Report ${id}`,
+ from,
+ to,
+ type: "report" as const,
+ status: "degraded" as const,
+ impactIntervals,
+ };
+ }
+
+ function createLegacyEvent(id: number, from: Date, to: Date | null) {
+ return {
+ id,
+ name: `Legacy Report ${id}`,
+ from,
+ to,
+ type: "report" as const,
+ status: "degraded" as const,
+ };
+ }
+
+ function impactComponent(id: number, monitorId?: number): PageComponent {
+ return {
+ id,
+ workspaceId: 1,
+ pageId: 1,
+ type: monitorId ? ("monitor" as const) : ("static" as const),
+ monitorId: monitorId ?? null,
+ name: `Component ${id}`,
+ description: null,
+ order: 0,
+ groupId: null,
+ groupOrder: 0,
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ };
+ }
+
+ function createImpactReport(args: {
+ id: number;
+ status?: "investigating" | "resolved";
+ components: number[];
+ updates: Array<{
+ id: number;
+ date: Date;
+ status: "investigating" | "identified" | "monitoring" | "resolved";
+ impacts?: Array<{ pageComponentId: number; impact: Impact }>;
+ }>;
+ }) {
+ return {
+ id: args.id,
+ title: `Status Report ${args.id}`,
+ status: args.status ?? ("investigating" as const),
+ workspaceId: 1,
+ pageId: 1,
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ statusReportsToPageComponents: args.components.map((pcId) => ({
+ pageComponent: impactComponent(pcId, pcId * 10),
+ })),
+ statusReportUpdates: args.updates.map((u) => ({
+ id: u.id,
+ statusReportId: args.id,
+ date: u.date,
+ status: u.status,
+ message: "m",
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ statusReportUpdateToPageComponents: (u.impacts ?? []).map((r) => ({
+ pageComponentId: r.pageComponentId,
+ impact: r.impact,
+ })),
+ })),
+ };
+ }
+
+ describe("getUptime - manual mode weighting", () => {
+ const day = dayStartUTC(1);
+ const dayData = [createStatusData(1, 1)];
+
+ it("legacy report (no impact rows) counts its full duration", () => {
+ const events = [createLegacyEvent(1, day, hoursAfter(day, 24))];
+ expect(
+ getUptime({
+ data: dayData,
+ events,
+ barType: "manual",
+ cardType: "manual",
+ }),
+ ).toBe("0%");
+ });
+
+ it("major_outage counts full downtime", () => {
+ const events = [
+ createImpactEvent(1, day, hoursAfter(day, 24), [
+ { from: day, to: hoursAfter(day, 24), impact: "major_outage" },
+ ]),
+ ];
+ expect(
+ getUptime({
+ data: dayData,
+ events,
+ barType: "manual",
+ cardType: "manual",
+ }),
+ ).toBe("0%");
+ });
+
+ it("partial_outage counts half downtime (weight 0.5)", () => {
+ const events = [
+ createImpactEvent(1, day, hoursAfter(day, 24), [
+ { from: day, to: hoursAfter(day, 24), impact: "partial_outage" },
+ ]),
+ ];
+ expect(
+ getUptime({
+ data: dayData,
+ events,
+ barType: "manual",
+ cardType: "manual",
+ }),
+ ).toBe("50%");
+ });
+
+ it("degraded_performance counts as up", () => {
+ const events = [
+ createImpactEvent(1, day, hoursAfter(day, 24), [
+ {
+ from: day,
+ to: hoursAfter(day, 24),
+ impact: "degraded_performance",
+ },
+ ]),
+ ];
+ expect(
+ getUptime({
+ data: dayData,
+ events,
+ barType: "manual",
+ cardType: "manual",
+ }),
+ ).toBe("100%");
+ });
+
+ it("operational rows count as up", () => {
+ const events = [
+ createImpactEvent(1, day, hoursAfter(day, 24), [
+ { from: day, to: hoursAfter(day, 24), impact: "operational" },
+ ]),
+ ];
+ expect(
+ getUptime({
+ data: dayData,
+ events,
+ barType: "manual",
+ cardType: "manual",
+ }),
+ ).toBe("100%");
+ });
+
+ it("weights each interval of a multi-update timeline", () => {
+ // major 6h -> degraded 6h -> operational 12h: only the major 6h count
+ const events = [
+ createImpactEvent(1, day, hoursAfter(day, 24), [
+ { from: day, to: hoursAfter(day, 6), impact: "major_outage" },
+ {
+ from: hoursAfter(day, 6),
+ to: hoursAfter(day, 12),
+ impact: "degraded_performance",
+ },
+ {
+ from: hoursAfter(day, 12),
+ to: hoursAfter(day, 24),
+ impact: "operational",
+ },
+ ]),
+ ];
+ expect(
+ getUptime({
+ data: dayData,
+ events,
+ barType: "manual",
+ cardType: "manual",
+ }),
+ ).toBe("75%");
+ });
+
+ it("partial_outage intervals count half in a multi-update timeline", () => {
+ // major 6h (6h down) -> partial 6h (3h down) -> operational 12h
+ const events = [
+ createImpactEvent(1, day, hoursAfter(day, 24), [
+ { from: day, to: hoursAfter(day, 6), impact: "major_outage" },
+ {
+ from: hoursAfter(day, 6),
+ to: hoursAfter(day, 12),
+ impact: "partial_outage",
+ },
+ {
+ from: hoursAfter(day, 12),
+ to: hoursAfter(day, 24),
+ impact: "operational",
+ },
+ ]),
+ ];
+ expect(
+ getUptime({
+ data: dayData,
+ events,
+ barType: "manual",
+ cardType: "manual",
+ }),
+ ).toBe("62.5%");
+ });
+
+ it("mixes legacy and impact reports in one period", () => {
+ const day2 = dayStartUTC(2);
+ const data = [createStatusData(2, 1), createStatusData(1, 1)];
+ const events = [
+ createLegacyEvent(1, day2, hoursAfter(day2, 24)),
+ createImpactEvent(2, day, hoursAfter(day, 24), [
+ {
+ from: day,
+ to: hoursAfter(day, 24),
+ impact: "degraded_performance",
+ },
+ ]),
+ ];
+ expect(
+ getUptime({ data, events, barType: "manual", cardType: "manual" }),
+ ).toBe("50%");
+ });
+
+ it("overlapping legacy reports count once and never go negative", () => {
+ const events = [
+ createLegacyEvent(1, day, hoursAfter(day, 24)),
+ createLegacyEvent(2, day, hoursAfter(day, 24)),
+ ];
+ expect(
+ getUptime({
+ data: dayData,
+ events,
+ barType: "manual",
+ cardType: "manual",
+ }),
+ ).toBe("0%");
+ });
+
+ it("partially overlapping reports merge their downtime", () => {
+ const day2 = dayStartUTC(2);
+ const data = [createStatusData(2, 1), createStatusData(1, 1)];
+ // 0-24h and 12-36h overlap by 12h: 36h downtime over 48h, not 48h
+ const events = [
+ createLegacyEvent(1, day2, hoursAfter(day2, 24)),
+ createLegacyEvent(2, hoursAfter(day2, 12), hoursAfter(day2, 36)),
+ ];
+ expect(
+ getUptime({ data, events, barType: "manual", cardType: "manual" }),
+ ).toBe("25%");
+ });
+
+ it("overlapping partial_outage reports take the worst weight, not the sum", () => {
+ const events = [
+ createImpactEvent(1, day, hoursAfter(day, 24), [
+ { from: day, to: hoursAfter(day, 24), impact: "partial_outage" },
+ ]),
+ createImpactEvent(2, day, hoursAfter(day, 24), [
+ { from: day, to: hoursAfter(day, 24), impact: "partial_outage" },
+ ]),
+ ];
+ expect(
+ getUptime({
+ data: dayData,
+ events,
+ barType: "manual",
+ cardType: "manual",
+ }),
+ ).toBe("50%");
+ });
+
+ it("overlapping legacy and partial_outage reports take the worst weight", () => {
+ const events = [
+ createLegacyEvent(1, day, hoursAfter(day, 24)),
+ createImpactEvent(2, day, hoursAfter(day, 24), [
+ { from: day, to: hoursAfter(day, 24), impact: "partial_outage" },
+ ]),
+ ];
+ expect(
+ getUptime({
+ data: dayData,
+ events,
+ barType: "manual",
+ cardType: "manual",
+ }),
+ ).toBe("0%");
+ });
+ });
+
+ describe("getUptime - duration mode impact downtime", () => {
+ const day = dayStartUTC(1);
+ const day2 = dayStartUTC(2);
+ const twoDayData = [createStatusData(2, 1), createStatusData(1, 1)];
+
+ function createIncidentEvent(id: number, from: Date, to: Date | null) {
+ return {
+ id,
+ name: "Downtime",
+ from,
+ to,
+ type: "incident" as const,
+ status: "error" as const,
+ };
+ }
+
+ it("major_outage report intervals count as downtime", () => {
+ const events = [
+ createImpactEvent(1, day2, hoursAfter(day2, 24), [
+ { from: day2, to: hoursAfter(day2, 24), impact: "major_outage" },
+ ]),
+ ];
+ expect(
+ getUptime({
+ data: twoDayData,
+ events,
+ barType: "absolute",
+ cardType: "duration",
+ }),
+ ).toBe("50%");
+ });
+
+ it("partial_outage report intervals count half", () => {
+ const events = [
+ createImpactEvent(1, day2, hoursAfter(day2, 24), [
+ { from: day2, to: hoursAfter(day2, 24), impact: "partial_outage" },
+ ]),
+ ];
+ expect(
+ getUptime({
+ data: twoDayData,
+ events,
+ barType: "absolute",
+ cardType: "duration",
+ }),
+ ).toBe("75%");
+ });
+
+ it("degraded_performance report intervals count as up", () => {
+ const events = [
+ createImpactEvent(1, day2, hoursAfter(day2, 24), [
+ {
+ from: day2,
+ to: hoursAfter(day2, 24),
+ impact: "degraded_performance",
+ },
+ ]),
+ ];
+ expect(
+ getUptime({
+ data: twoDayData,
+ events,
+ barType: "absolute",
+ cardType: "duration",
+ }),
+ ).toBe("100%");
+ });
+
+ it("incident and overlapping major_outage report count once", () => {
+ const events = [
+ createIncidentEvent(1, day2, hoursAfter(day2, 24)),
+ createImpactEvent(2, day2, hoursAfter(day2, 24), [
+ { from: day2, to: hoursAfter(day2, 24), impact: "major_outage" },
+ ]),
+ ];
+ expect(
+ getUptime({
+ data: twoDayData,
+ events,
+ barType: "absolute",
+ cardType: "duration",
+ }),
+ ).toBe("50%");
+ });
+
+ it("incident downtime wins over an overlapping partial_outage report", () => {
+ const events = [
+ createIncidentEvent(1, day2, hoursAfter(day2, 24)),
+ createImpactEvent(2, day2, hoursAfter(day2, 24), [
+ { from: day2, to: hoursAfter(day2, 24), impact: "partial_outage" },
+ ]),
+ ];
+ expect(
+ getUptime({
+ data: twoDayData,
+ events,
+ barType: "absolute",
+ cardType: "duration",
+ }),
+ ).toBe("50%");
+ });
+
+ it("legacy reports stay ignored alongside impact reports", () => {
+ const events = [
+ createLegacyEvent(1, day2, hoursAfter(day2, 24)),
+ createImpactEvent(2, day, hoursAfter(day, 12), [
+ { from: day, to: hoursAfter(day, 12), impact: "major_outage" },
+ ]),
+ ];
+ expect(
+ getUptime({
+ data: twoDayData,
+ events,
+ barType: "absolute",
+ cardType: "duration",
+ }),
+ ).toBe("75%");
+ });
+ });
+
+ describe("getEvents - impact projection", () => {
+ const day = dayStartUTC(1);
+
+ it("projects the filtered component's own timeline and status", () => {
+ const report = createImpactReport({
+ id: 1,
+ components: [1, 2],
+ updates: [
+ {
+ id: 100,
+ date: day,
+ status: "investigating",
+ impacts: [
+ { pageComponentId: 1, impact: "major_outage" },
+ { pageComponentId: 2, impact: "degraded_performance" },
+ ],
+ },
+ ],
+ });
+
+ const apiEvents = getEvents({
+ maintenances: [],
+ incidents: [],
+ reports: [report],
+ pageComponentId: 1,
+ });
+ expect(apiEvents).toHaveLength(1);
+ expect(apiEvents[0].status).toBe("error");
+ expect(apiEvents[0].impactIntervals).toHaveLength(1);
+ expect(apiEvents[0].impactIntervals?.[0].impact).toBe("major_outage");
+
+ const webEvents = getEvents({
+ maintenances: [],
+ incidents: [],
+ reports: [report],
+ pageComponentId: 2,
+ });
+ expect(webEvents[0].status).toBe("degraded");
+ expect(webEvents[0].impactIntervals?.[0].impact).toBe(
+ "degraded_performance",
+ );
+ });
+
+ it("page-level projection takes the worst impact across components", () => {
+ const report = createImpactReport({
+ id: 1,
+ components: [1, 2],
+ updates: [
+ {
+ id: 100,
+ date: day,
+ status: "investigating",
+ impacts: [
+ { pageComponentId: 1, impact: "major_outage" },
+ { pageComponentId: 2, impact: "degraded_performance" },
+ ],
+ },
+ ],
+ });
+
+ const events = getEvents({
+ maintenances: [],
+ incidents: [],
+ reports: [report],
+ });
+ expect(events[0].status).toBe("error");
+ expect(events[0].impactIntervals?.[0].impact).toBe("major_outage");
+ });
+
+ it("legacy reports carry no impactIntervals and stay degraded", () => {
+ const report = createImpactReport({
+ id: 1,
+ components: [1],
+ updates: [{ id: 100, date: day, status: "investigating" }],
+ });
+
+ const events = getEvents({
+ maintenances: [],
+ incidents: [],
+ reports: [report],
+ pageComponentId: 1,
+ });
+ expect(events[0].status).toBe("degraded");
+ expect(events[0].impactIntervals).toBeUndefined();
+ });
+
+ it("an active report whose component recovered reads success", () => {
+ const report = createImpactReport({
+ id: 1,
+ components: [1],
+ updates: [
+ {
+ id: 100,
+ date: day,
+ status: "investigating",
+ impacts: [{ pageComponentId: 1, impact: "partial_outage" }],
+ },
+ {
+ id: 101,
+ date: hoursAfter(day, 2),
+ status: "identified",
+ impacts: [{ pageComponentId: 1, impact: "operational" }],
+ },
+ ],
+ });
+
+ const events = getEvents({
+ maintenances: [],
+ incidents: [],
+ reports: [report],
+ pageComponentId: 1,
+ });
+ expect(events[0].status).toBe("success");
+ // prior interval closed at the second update
+ expect(events[0].impactIntervals?.[0].to?.getTime()).toBe(
+ hoursAfter(day, 2).getTime(),
+ );
+ });
+
+ it("clamps open intervals to the resolved event end", () => {
+ const report = createImpactReport({
+ id: 1,
+ status: "resolved",
+ components: [1],
+ updates: [
+ {
+ id: 100,
+ date: day,
+ status: "investigating",
+ impacts: [{ pageComponentId: 1, impact: "major_outage" }],
+ },
+ {
+ id: 101,
+ date: hoursAfter(day, 3),
+ status: "resolved",
+ impacts: [{ pageComponentId: 1, impact: "operational" }],
+ },
+ ],
+ });
+
+ const events = getEvents({
+ maintenances: [],
+ incidents: [],
+ reports: [report],
+ pageComponentId: 1,
+ });
+ expect(events[0].status).toBe("success");
+ const intervals = events[0].impactIntervals ?? [];
+ expect(intervals).toHaveLength(2);
+ expect(intervals[0].impact).toBe("major_outage");
+ expect(intervals[0].to?.getTime()).toBe(hoursAfter(day, 3).getTime());
+ // trailing operational interval clamped to the event end, not open
+ expect(intervals[1].to?.getTime()).toBe(hoursAfter(day, 3).getTime());
+ });
+ });
+
+ describe("setDataByType - manual mode colors", () => {
+ const day = dayStartUTC(1);
+ const dayData = [createStatusData(1, 1)];
+
+ function manualBarStatus(
+ events: Parameters<typeof setDataByType>[0]["events"],
+ ) {
+ const result = setDataByType({
+ events,
+ data: dayData,
+ cardType: "manual",
+ barType: "manual",
+ });
+ return result[0].bar[0].status;
+ }
+
+ it("legacy report day stays degraded", () => {
+ expect(
+ manualBarStatus([createLegacyEvent(1, day, hoursAfter(day, 24))]),
+ ).toBe("degraded");
+ });
+
+ it("major_outage day renders error", () => {
+ expect(
+ manualBarStatus([
+ createImpactEvent(1, day, hoursAfter(day, 24), [
+ { from: day, to: hoursAfter(day, 24), impact: "major_outage" },
+ ]),
+ ]),
+ ).toBe("error");
+ });
+
+ it("partial_outage day renders degraded", () => {
+ expect(
+ manualBarStatus([
+ createImpactEvent(1, day, hoursAfter(day, 24), [
+ { from: day, to: hoursAfter(day, 24), impact: "partial_outage" },
+ ]),
+ ]),
+ ).toBe("degraded");
+ });
+
+ it("carries the day's worst impact for the hover card label", () => {
+ const result = setDataByType({
+ events: [
+ createImpactEvent(1, day, hoursAfter(day, 24), [
+ { from: day, to: hoursAfter(day, 24), impact: "partial_outage" },
+ ]),
+ ],
+ data: dayData,
+ cardType: "manual",
+ barType: "manual",
+ });
+ expect(result[0].card[0].status).toBe("degraded");
+ expect(result[0].card[0].impact).toBe("partial_outage");
+ });
+
+ it("legacy report day carries no impact (generic label)", () => {
+ const result = setDataByType({
+ events: [createLegacyEvent(1, day, hoursAfter(day, 24))],
+ data: dayData,
+ cardType: "manual",
+ barType: "manual",
+ });
+ expect(result[0].card[0].status).toBe("degraded");
+ expect(result[0].card[0].impact).toBeUndefined();
+ });
+
+ it("operational-only day renders success", () => {
+ expect(
+ manualBarStatus([
+ createImpactEvent(1, day, hoursAfter(day, 24), [
+ { from: day, to: hoursAfter(day, 24), impact: "operational" },
+ ]),
+ ]),
+ ).toBe("success");
+ });
+ });
+
+ describe("setDataByType - absolute bar impact proportions", () => {
+ const day = dayStartUTC(1);
+ const dayData = [createStatusData(1, 100)];
+
+ it("colors only the major_outage slice red, not the full report", () => {
+ // 1h major + 23h degraded: error keeps its true 1/24 share
+ const events = [
+ createImpactEvent(1, day, hoursAfter(day, 24), [
+ { from: day, to: hoursAfter(day, 1), impact: "major_outage" },
+ {
+ from: hoursAfter(day, 1),
+ to: hoursAfter(day, 24),
+ impact: "degraded_performance",
+ },
+ ]),
+ ];
+
+ const result = setDataByType({
+ events,
+ data: dayData,
+ cardType: "requests",
+ barType: "absolute",
+ });
+
+ const bar = result[0].bar;
+ const errorHeight = bar.find((b) => b.status === "error")?.height ?? 0;
+ const degradedHeight =
+ bar.find((b) => b.status === "degraded")?.height ?? 0;
+ expect(errorHeight).toBeCloseTo(100 / 24, 1);
+ expect(degradedHeight).toBeCloseTo(100 - 100 / 24, 1);
+ expect(errorHeight + degradedHeight).toBeCloseTo(100, 5);
+ });
+
+ it("shows uptime vs downtime when the only slice is an outage", () => {
+ // 1h major then operational: 23h green, 1h red — not a full red day
+ const events = [
+ createImpactEvent(1, day, hoursAfter(day, 24), [
+ { from: day, to: hoursAfter(day, 1), impact: "major_outage" },
+ {
+ from: hoursAfter(day, 1),
+ to: hoursAfter(day, 24),
+ impact: "operational",
+ },
+ ]),
+ ];
+
+ const result = setDataByType({
+ events,
+ data: dayData,
+ cardType: "requests",
+ barType: "absolute",
+ });
+
+ const bar = result[0].bar;
+ expect(bar.find((b) => b.status === "success")?.height).toBeCloseTo(
+ 100 - 100 / 24,
+ 1,
+ );
+ expect(bar.find((b) => b.status === "error")?.height).toBeCloseTo(
+ 100 / 24,
+ 1,
+ );
+ });
+ });
+
+ describe("currentImpactByComponent", () => {
+ const day = dayStartUTC(1);
+
+ it("latest update naming a component wins; resolve clears", () => {
+ const report = createImpactReport({
+ id: 1,
+ components: [1, 2],
+ updates: [
+ {
+ id: 100,
+ date: day,
+ status: "investigating",
+ impacts: [
+ { pageComponentId: 1, impact: "major_outage" },
+ { pageComponentId: 2, impact: "degraded_performance" },
+ ],
+ },
+ {
+ id: 101,
+ date: hoursAfter(day, 1),
+ status: "identified",
+ impacts: [{ pageComponentId: 1, impact: "partial_outage" }],
+ },
+ ],
+ });
+
+ const current = currentImpactByComponent(report);
+ expect(current.get(1)).toBe("partial_outage");
+ expect(current.get(2)).toBe("degraded_performance");
+ });
+
+ it("returns an empty map for legacy reports", () => {
+ const report = createImpactReport({
+ id: 1,
+ components: [1],
+ updates: [{ id: 100, date: day, status: "investigating" }],
+ });
+ expect(currentImpactByComponent(report).size).toBe(0);
+ });
+ });
+});
diff --git a/packages/api/src/router/statusPage.utils.ts b/packages/api/src/router/statusPage.utils.ts
index 6123d6798..9f541058b 100644
--- a/packages/api/src/router/statusPage.utils.ts
+++ b/packages/api/src/router/statusPage.utils.ts
@@ -2,11 +2,19 @@ import type {
Incident,
Maintenance,
PageComponent,
+ PageComponentImpact,
PageComponentType,
PageComponentWithMonitorRelation,
StatusReport,
StatusReportUpdate,
} from "@openstatus/db/src/schema";
+import {
+ LEGACY_IMPACT_WEIGHT,
+ currentImpactsFromUpdates,
+ impactToStatusType,
+ impactUptimeWeight,
+ worstImpact,
+} from "@openstatus/db/src/schema";
/**
* Type for a monitor component with a non-null monitor relation
@@ -116,6 +124,19 @@ export function fillStatusDataFor45DaysNoop({
return fillStatusDataFor45Days(data, "1", lookbackPeriod);
}
+export type ImpactInterval = {
+ from: Date;
+ to: Date | null; // null = still active
+ impact: PageComponentImpact;
+};
+
+export type StatusReportUpdateWithImpactRows = StatusReportUpdate & {
+ statusReportUpdateToPageComponents?: {
+ pageComponentId: number;
+ impact: PageComponentImpact;
+ }[];
+};
+
type Event = {
id: number;
name: string;
@@ -123,8 +144,113 @@ type Event = {
to: Date | null;
type: "maintenance" | "incident" | "report";
status: "success" | "degraded" | "error" | "info";
+ // absent ⇒ legacy report (no impact rows): orange bar, full-duration downtime
+ impactIntervals?: ImpactInterval[];
};
+// per component: change points across the report's updates
+function buildComponentImpactIntervals(
+ updates: StatusReportUpdateWithImpactRows[],
+): Map<number, ImpactInterval[]> {
+ // closing the last open interval relies on ascending order; don't trust callers
+ const sorted = [...updates].sort(
+ (a, b) => a.date.getTime() - b.date.getTime() || a.id - b.id,
+ );
+ const byComponent = new Map<number, ImpactInterval[]>();
+ for (const update of sorted) {
+ for (const row of update.statusReportUpdateToPageComponents ?? []) {
+ const intervals = byComponent.get(row.pageComponentId) ?? [];
+ const last = intervals[intervals.length - 1];
+ if (last && last.to === null) last.to = update.date;
+ intervals.push({ from: update.date, to: null, impact: row.impact });
+ byComponent.set(row.pageComponentId, intervals);
+ }
+ }
+ return byComponent;
+}
+
+// page-level projection: worst impact across components per time slice
+function mergeWorstImpactIntervals(
+ perComponent: ImpactInterval[][],
+): ImpactInterval[] {
+ const all = perComponent.flat();
+ if (all.length === 0) return [];
+
+ const boundaries = [...new Set(all.map((iv) => iv.from.getTime()))].sort(
+ (a, b) => a - b,
+ );
+
+ const merged: ImpactInterval[] = [];
+ for (let i = 0; i < boundaries.length; i++) {
+ const sliceStart = boundaries[i];
+ const sliceEnd = i + 1 < boundaries.length ? boundaries[i + 1] : null;
+ const active = all.filter(
+ (iv) =>
+ iv.from.getTime() <= sliceStart &&
+ (iv.to === null || iv.to.getTime() > sliceStart),
+ );
+ if (active.length === 0) continue;
+ const impact = worstImpact(active.map((iv) => iv.impact));
+ const last = merged[merged.length - 1];
+ if (
+ last &&
+ last.impact === impact &&
+ last.to !== null &&
+ last.to.getTime() === sliceStart
+ ) {
+ last.to = sliceEnd === null ? null : new Date(sliceEnd);
+ } else {
+ merged.push({
+ from: new Date(sliceStart),
+ to: sliceEnd === null ? null : new Date(sliceEnd),
+ impact,
+ });
+ }
+ }
+ return merged;
+}
+
+// keep impact downtime inside the event window the rest of the math uses
+function clampOpenIntervals(
+ intervals: ImpactInterval[] | undefined,
+ to: Date | null,
+): ImpactInterval[] | undefined {
+ if (!intervals || to === null) return intervals;
+ return intervals.map((iv) => (iv.to === null ? { ...iv, to } : iv));
+}
+
+/**
+ * Current impact per component: the latest update (by date, ties by id) that
+ * names it wins. Empty map ⇒ legacy report.
+ */
+export function currentImpactByComponent(report: {
+ statusReportUpdates: StatusReportUpdateWithImpactRows[];
+}): Map<number, PageComponentImpact> {
+ return currentImpactsFromUpdates(
+ report.statusReportUpdates.map((u) => ({
+ id: u.id,
+ date: u.date,
+ componentImpacts: u.statusReportUpdateToPageComponents ?? [],
+ })),
+ );
+}
+
+/**
+ * Worst status among still-active report events. "success"-status reports
+ * (everything operational for this projection) don't flag the component.
+ */
+export function activeReportStatus(
+ events: Event[],
+): "error" | "degraded" | undefined {
+ let worst: "error" | "degraded" | undefined;
+ for (const e of events) {
+ if (e.type !== "report" || e.to) continue;
+ if (e.status === "error") return "error";
+ if (e.status !== "success") worst = "degraded";
+ }
+ return worst;
+}
+
export function getEvents({
maintenances,
incidents,
@@ -144,7 +270,7 @@ export function getEvents({
statusReportsToPageComponents: {
pageComponent: PageComponent | null;
}[];
- statusReportUpdates: StatusReportUpdate[];
+ statusReportUpdates: StatusReportUpdateWithImpactRows[];
})[];
pageComponentId?: number;
monitorId?: number;
@@ -218,8 +344,8 @@ export function getEvents({
return true;
})
.map((report) => {
- const updates = report.statusReportUpdates.sort(
- (a, b) => a.date.getTime() - b.date.getTime(),
+ const updates = [...report.statusReportUpdates].sort(
+ (a, b) => a.date.getTime() - b.date.getTime() || a.id - b.id,
);
if (updates.length === 0) return;
@@ -229,31 +355,67 @@ export function getEvents({
// NOTE: we don't check threshold here because we display all unresolved reports
if (!firstUpdate?.date) return;
+ const componentIntervals = buildComponentImpactIntervals(updates);
+ const hasImpacts = componentIntervals.size > 0;
+
+ const targetComponentId =
+ pageComponentId ??
+ (monitorId
+ ? report.statusReportsToPageComponents.find(
+ (r) => r.pageComponent?.monitorId === monitorId,
+ )?.pageComponent?.id
+ : undefined);
+
+ // per-component view projects that component's timeline; page-level
+ // takes the worst impact across components per time slice
+ let impactIntervals: ImpactInterval[] | undefined;
+ if (hasImpacts) {
+ impactIntervals =
+ targetComponentId !== undefined
+ ? (componentIntervals.get(targetComponentId) ?? [])
+ : mergeWorstImpactIntervals([...componentIntervals.values()]);
+ }
+
// HACKY: LEGACY: we shouldn't have report.status anymore and instead use the update status for that.
- // Ideally, we could replace the status with "downtime", "degraded", "operational" to indicate the gravity of the issue
if (report.status === "resolved") {
+ const to = lastUpdate?.date ?? null;
events.push({
id: report.id,
name: report.title,
from: firstUpdate?.date,
- to: lastUpdate?.date,
+ to,
type: "report",
status: "success" as const,
+ impactIntervals: clampOpenIntervals(impactIntervals, to),
});
return;
}
+ const to =
+ lastUpdate?.status === "resolved" || lastUpdate?.status === "monitoring"
+ ? lastUpdate?.date
+ : null;
+
+ // derived from the open (current) impacts; legacy stays flat orange.
+ // No open non-operational interval — including the empty-projection
+ // case (component never named by any update) — reads "success" BY
+ // DESIGN: an open report whose impacts are all cleared no longer
+ // flags the component, even before the report is formally resolved.
+ const openImpacts = (impactIntervals ?? [])
+ .filter((iv) => iv.to === null)
+ .map((iv) => iv.impact);
+ const status = hasImpacts
+ ? impactToStatusType(worstImpact(openImpacts))
+ : ("degraded" as const);
+
events.push({
id: report.id,
name: report.title,
from: firstUpdate?.date,
- to:
- lastUpdate?.status === "resolved" ||
- lastUpdate?.status === "monitoring"
- ? lastUpdate?.date
- : null,
+ to,
type: "report",
- status: "degraded" as const,
+ status,
+ impactIntervals: clampOpenIntervals(impactIntervals, to),
});
});
@@ -263,18 +425,13 @@ export function getEvents({
// Keep the old function name for backward compatibility
export const getEventsByMonitorId = getEvents;
-export function getWorstVariant(
- statuses: (keyof typeof STATUS_PRIORITY)[],
-): keyof typeof STATUS_PRIORITY {
- if (statuses.length === 0) return "success";
-
- return statuses.reduce(
- (worst, current) => {
- return STATUS_PRIORITY[current] > STATUS_PRIORITY[worst]
- ? current
- : worst;
- },
- "success" as keyof typeof STATUS_PRIORITY,
+export function getWorstVariant<T extends keyof typeof STATUS_PRIORITY>(
+ statuses: T[],
+): T | "success" {
+ return statuses.reduce<T | "success">(
+ (worst, current) =>
+ STATUS_PRIORITY[current] > STATUS_PRIORITY[worst] ? current : worst,
+ "success",
);
}
@@ -288,6 +445,8 @@ type UptimeData = {
card: {
status: "success" | "degraded" | "error" | "info" | "empty";
value: string;
+ /** Worst report impact of the day — refines the generic status label. */
+ impact?: PageComponentImpact;
}[];
};
@@ -341,6 +500,37 @@ function formatDuration(minutes: number): string {
return `${hours}h ${remainingMinutes}m`;
}
+// worst report impact for one day; null = legacy event (no impact rows)
+function reportEventDayImpact(
+ event: Event,
+ date: Date,
+): PageComponentImpact | null {
+ if (!event.impactIntervals) return null;
+
+ const startOfDay = new Date(date);
+ startOfDay.setUTCHours(0, 0, 0, 0);
+ const endOfDay = new Date(date);
+ endOfDay.setUTCHours(23, 59, 59, 999);
+
+ const overlapping = event.impactIntervals.filter((iv) => {
+ const end = iv.to ?? new Date();
+ return (
+ iv.from.getTime() <= endOfDay.getTime() &&
+ end.getTime() >= startOfDay.getTime()
+ );
+ });
+ return worstImpact(overlapping.map((iv) => iv.impact));
+}
+
+// worst projected report color for one day; legacy events stay orange
+function reportEventDayStatus(
+ event: Event,
+ date: Date,
+): "success" | "degraded" | "error" {
+ const impact = reportEventDayImpact(event, date);
+ return impact === null ? "degraded" : impactToStatusType(impact);
+}
+
// Helper to check if date is within event range
function isDateWithinEvent(date: Date, event: Event): boolean {
const startOfDay = new Date(date);
@@ -450,10 +640,32 @@ export function setDataByType({
maintenances: Event[],
date: Date,
): Array<{ status: "info" | "degraded" | "error"; count: number }> {
+ // impact reports contribute per-interval slices to each color bucket, so a
+ // 1h major_outage inside a 24h report only paints 1h red; legacy reports
+ // keep their full duration in the degraded bucket; operational slices drop
+ const degradedSlices: Event[] = [];
+ const errorSlices: Event[] = [];
+ for (const report of reports) {
+ if (!report.impactIntervals) {
+ degradedSlices.push(report);
+ continue;
+ }
+ for (const iv of report.impactIntervals) {
+ const color = impactToStatusType(iv.impact);
+ if (color === "success") continue;
+ const slice = { ...report, from: iv.from, to: iv.to };
+ if (!isDateWithinEvent(date, slice)) continue;
+ (color === "error" ? errorSlices : degradedSlices).push(slice);
+ }
+ }
+
const eventTypes = [
{ status: "info" as const, events: maintenances },
- { status: "degraded" as const, events: reports },
- { status: "error" as const, events: incidents },
+ { status: "degraded" as const, events: degradedSlices },
+ {
+ status: "error" as const,
+ events: [...incidents, ...errorSlices],
+ },
];
return eventTypes
@@ -662,16 +874,20 @@ export function setDataByType({
const maintenances = dayEvents.filter((e) => e.type === "maintenance");
const hasIncidents = incidents.length > 0;
- const hasReports = reports.length > 0;
const hasMaintenances = maintenances.length > 0;
+ // worst impact color across the day's reports; "success" (operational all
+ // day) means reports don't color the day
+ const reportsDayStatus = reports.length
+ ? getWorstVariant(reports.map((e) => reportEventDayStatus(e, date)))
+ : undefined;
+ const activeReportsDayStatus =
+ reportsDayStatus === "success" ? undefined : reportsDayStatus;
+
const eventStatus = hasIncidents
? "error"
- : hasReports
- ? "degraded"
- : hasMaintenances
- ? "info"
- : undefined;
+ : (activeReportsDayStatus ??
+ (hasMaintenances ? ("info" as const) : undefined));
// Calculate bar data based on barType
// TODO: transform into a new Map<type, number>();
@@ -724,11 +940,8 @@ export function setDataByType({
];
break;
case "manual":
- const manualEventStatus = hasReports
- ? "degraded"
- : hasMaintenances
- ? "info"
- : undefined;
+ const manualEventStatus =
+ activeReportsDayStatus ?? (hasMaintenances ? "info" : undefined);
barData = [
{
status: manualEventStatus || "success",
@@ -800,19 +1013,29 @@ export function setDataByType({
];
break;
- case "manual":
- const manualEventStatus = hasReports
- ? "degraded"
- : hasMaintenances
- ? "info"
- : undefined;
+ case "manual": {
+ const manualCardStatus =
+ activeReportsDayStatus ?? (hasMaintenances ? "info" : undefined);
+ const dayImpacts = reports
+ .map((e) => reportEventDayImpact(e, date))
+ .filter((i): i is PageComponentImpact => i !== null);
+ const worstDayImpact =
+ dayImpacts.length > 0 ? worstImpact(dayImpacts) : null;
cardData = [
{
- status: manualEventStatus || "success",
+ status: manualCardStatus || "success",
value: "",
+ // only when the impact agrees with the day color — a mixed
+ // legacy+impact day where legacy dominates keeps the generic label
+ impact:
+ worstDayImpact !== null &&
+ impactToStatusType(worstDayImpact) === manualCardStatus
+ ? worstDayImpact
+ : undefined,
},
];
break;
+ }
default:
// Default to requests behavior
if (total === 0) {
@@ -849,7 +1072,15 @@ export function setDataByType({
return {
day: dayData.day,
events: [
- ...reports,
+ // row dot follows the day's worst impact; floors at degraded so an
+ // operational-only slice never renders a green row (mirrors calendar)
+ ...reports.map((e) => ({
+ ...e,
+ status:
+ reportEventDayStatus(e, date) === "error"
+ ? ("error" as const)
+ : ("degraded" as const),
+ })),
...maintenances,
...(barType === "absolute" ? bundledIncidents : []),
],
@@ -859,6 +1090,31 @@ export function setDataByType({
});
}
+type WeightedInterval = { from: number; to: number; weight: number };
+
+// concurrent events describing the same outage must not double-count
+// downtime: per time slice the worst (max) weight wins, mirroring
+// mergeWorstImpactIntervals — summing could push uptime negative
+function mergedDowntimeMs(intervals: WeightedInterval[]): number {
+ const boundaries = [
+ ...new Set(intervals.flatMap((iv) => [iv.from, iv.to])),
+ ].sort((a, b) => a - b);
+
+ let total = 0;
+ for (let i = 0; i + 1 < boundaries.length; i++) {
+ const sliceStart = boundaries[i];
+ const sliceEnd = boundaries[i + 1];
+ let weight = 0;
+ for (const iv of intervals) {
+ if (iv.from <= sliceStart && iv.to >= sliceEnd) {
+ weight = Math.max(weight, iv.weight);
+ }
+ }
+ total += weight * (sliceEnd - sliceStart);
+ }
+ return total;
+}
+
export function getUptime({
data,
events,
@@ -880,30 +1136,57 @@ export function getUptime({
windowEndDate.setUTCHours(23, 59, 59, 999);
const windowEnd = windowEndDate.getTime();
- function clampedDuration(item: Event): number {
- if (!item.from) return 0;
- const from = Math.max(item.from.getTime(), windowStart);
- const to = Math.min((item.to || new Date()).getTime(), windowEnd);
- return Math.max(0, to - from);
+ function clampedInterval(
+ from: Date,
+ to: Date | null,
+ weight: number,
+ ): WeightedInterval | null {
+ const start = Math.max(from.getTime(), windowStart);
+ const end = Math.min((to ?? new Date()).getTime(), windowEnd);
+ if (end <= start || weight === 0) return null;
+ return { from: start, to: end, weight };
+ }
+
+ function reportImpactIntervals(event: Event): WeightedInterval[] {
+ return (event.impactIntervals ?? [])
+ .map((iv) =>
+ clampedInterval(iv.from, iv.to, impactUptimeWeight(iv.impact)),
+ )
+ .filter((iv): iv is WeightedInterval => iv !== null);
}
if (barType === "manual") {
- const duration = events
- // NOTE: we want only user events
+ // NOTE: we want only user events; legacy reports (no impact rows) keep
+ // their full duration as downtime
+ const intervals = events
.filter((e) => e.type === "report")
- .reduce((acc, item) => acc + clampedDuration(item), 0);
+ .flatMap((e) =>
+ e.impactIntervals
+ ? reportImpactIntervals(e)
+ : (clampedInterval(e.from, e.to, LEGACY_IMPACT_WEIGHT) ?? []),
+ );
const total = data.length * MILLISECONDS_PER_DAY;
+ if (total === 0) return "100%";
+ const duration = mergedDowntimeMs(intervals);
return `${Math.floor(((total - duration) / total) * 10000) / 100}%`;
}
if (cardType === "duration") {
- const duration = events
- .filter((e) => e.type === "incident")
- .reduce((acc, item) => acc + clampedDuration(item), 0);
+ // incidents and impact-report downtime share one timeline so an incident
+ // plus a report describing the same outage counts once; legacy reports
+ // stay ignored to preserve pre-impact uptime values
+ const intervals = events.flatMap((e) => {
+ if (e.type === "incident") return clampedInterval(e.from, e.to, 1) ?? [];
+ if (e.type === "report") return reportImpactIntervals(e);
+ return [];
+ });
const total = data.length * MILLISECONDS_PER_DAY;
+ if (total === 0) return "100%";
+ const duration = mergedDowntimeMs(intervals);
+
return `${Math.floor(((total - duration) / total) * 10000) / 100}%`;
}
diff --git a/packages/api/src/router/statusReport.ts b/packages/api/src/router/statusReport.ts
index b1d0aecac..7015a2571 100644
--- a/packages/api/src/router/statusReport.ts
+++ b/packages/api/src/router/statusReport.ts
@@ -4,6 +4,7 @@ import {
AddStatusReportUpdateInput,
CreateStatusReportInput,
addStatusReportUpdate,
+ componentImpactsSchema,
createStatusReport,
deleteStatusReport,
deleteStatusReportUpdate,
@@ -26,6 +27,7 @@ const createStatusReportTRPCInput = z.object({
status: CreateStatusReportInput.shape.status,
pageId: z.number(),
pageComponents: z.array(z.number()),
+ componentImpacts: componentImpactsSchema.optional(),
date: z.coerce.date(),
message: z.string(),
notifySubscribers: z.boolean().nullish(),
@@ -36,6 +38,7 @@ const createStatusReportUpdateTRPCInput = z.object({
statusReportId: z.number(),
status: AddStatusReportUpdateInput.shape.status,
message: z.string(),
+ componentImpacts: componentImpactsSchema.optional(),
date: z.coerce.date().optional(),
notifySubscribers: z.boolean().nullish(),
});
@@ -45,6 +48,7 @@ const updateStatusReportUpdateTRPCInput = z.object({
statusReportId: z.number().optional(),
status: AddStatusReportUpdateInput.shape.status.optional(),
message: z.string().optional(),
+ componentImpacts: componentImpactsSchema.optional(),
date: z.coerce.date().optional(),
});
@@ -68,6 +72,7 @@ export const statusReportRouter = createTRPCRouter({
status: input.status,
pageId: input.pageId,
pageComponentIds: input.pageComponents,
+ componentImpacts: input.componentImpacts,
date: input.date,
message: input.message,
},
@@ -91,6 +96,7 @@ export const statusReportRouter = createTRPCRouter({
statusReportId: input.statusReportId,
status: input.status,
message: input.message,
+ componentImpacts: input.componentImpacts,
date: input.date,
},
});
@@ -114,6 +120,7 @@ export const statusReportRouter = createTRPCRouter({
id: input.id,
status: input.status,
message: input.message,
+ componentImpacts: input.componentImpacts,
date: input.date,
},
});
diff --git a/packages/db/drizzle/0075_yummy_ken_ellis.sql b/packages/db/drizzle/0075_yummy_ken_ellis.sql
new file mode 100644
index 000000000..808244447
--- /dev/null
+++ b/packages/db/drizzle/0075_yummy_ken_ellis.sql
@@ -0,0 +1,11 @@
+CREATE TABLE `status_report_update_to_page_component` (
+ `status_report_update_id` integer NOT NULL,
+ `page_component_id` integer NOT NULL,
+ `impact` text NOT NULL,
+ `created_at` integer DEFAULT (strftime('%s', 'now')),
+ PRIMARY KEY(`status_report_update_id`, `page_component_id`),
+ FOREIGN KEY (`status_report_update_id`) REFERENCES `status_report_update`(`id`) ON UPDATE no action ON DELETE cascade,
+ FOREIGN KEY (`page_component_id`) REFERENCES `page_component`(`id`) ON UPDATE no action ON DELETE cascade
+);
+--> statement-breakpoint
+CREATE INDEX `status_report_update_to_page_component_page_component_id_idx` ON `status_report_update_to_page_component` (`page_component_id`);
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0075_snapshot.json b/packages/db/drizzle/meta/0075_snapshot.json
new file mode 100644
index 000000000..3ca3fb35d
--- /dev/null
+++ b/packages/db/drizzle/meta/0075_snapshot.json
@@ -0,0 +1,4502 @@
+{
+ "version": "6",
+ "dialect": "sqlite",
+ "id": "38652d73-0c5d-4a06-8dda-e5fe7f7f008a",
+ "prevId": "ee96c648-1fc8-425a-8d84-a201788f265a",
+ "tables": {
+ "workspace": {
+ "name": "workspace",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "stripe_id": {
+ "name": "stripe_id",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "subscription_id": {
+ "name": "subscription_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "plan": {
+ "name": "plan",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ends_at": {
+ "name": "ends_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "paid_until": {
+ "name": "paid_until",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "limits": {
+ "name": "limits",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'{}'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "dsn": {
+ "name": "dsn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "workspace_slug_unique": {
+ "name": "workspace_slug_unique",
+ "columns": [
+ "slug"
+ ],
+ "isUnique": true
+ },
+ "workspace_stripe_id_unique": {
+ "name": "workspace_stripe_id_unique",
+ "columns": [
+ "stripe_id"
+ ],
+ "isUnique": true
+ },
+ "workspace_id_dsn_unique": {
+ "name": "workspace_id_dsn_unique",
+ "columns": [
+ "id",
+ "dsn"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "account": {
+ "name": "account",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider_account_id": {
+ "name": "provider_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "account_provider_provider_account_id_pk": {
+ "columns": [
+ "provider",
+ "provider_account_id"
+ ],
+ "name": "account_provider_provider_account_id_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "session": {
+ "name": "session",
+ "columns": {
+ "session_token": {
+ "name": "session_token",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires": {
+ "name": "expires",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "user": {
+ "name": "user",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tenant_id": {
+ "name": "tenant_id",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "photo_url": {
+ "name": "photo_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "user_tenant_id_unique": {
+ "name": "user_tenant_id_unique",
+ "columns": [
+ "tenant_id"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "users_to_workspaces": {
+ "name": "users_to_workspaces",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'member'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "users_to_workspaces_workspace_id_idx": {
+ "name": "users_to_workspaces_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "users_to_workspaces_user_id_user_id_fk": {
+ "name": "users_to_workspaces_user_id_user_id_fk",
+ "tableFrom": "users_to_workspaces",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "users_to_workspaces_workspace_id_workspace_id_fk": {
+ "name": "users_to_workspaces_workspace_id_workspace_id_fk",
+ "tableFrom": "users_to_workspaces",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "users_to_workspaces_user_id_workspace_id_pk": {
+ "columns": [
+ "user_id",
+ "workspace_id"
+ ],
+ "name": "users_to_workspaces_user_id_workspace_id_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "verification_token": {
+ "name": "verification_token",
+ "columns": {
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires": {
+ "name": "expires",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "verification_token_identifier_token_pk": {
+ "columns": [
+ "identifier",
+ "token"
+ ],
+ "name": "verification_token_identifier_token_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "status_report": {
+ "name": "status_report",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "page_id": {
+ "name": "page_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "status_report_workspace_created_idx": {
+ "name": "status_report_workspace_created_idx",
+ "columns": [
+ "workspace_id",
+ "created_at"
+ ],
+ "isUnique": false
+ },
+ "status_report_page_id_idx": {
+ "name": "status_report_page_id_idx",
+ "columns": [
+ "page_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "status_report_workspace_id_workspace_id_fk": {
+ "name": "status_report_workspace_id_workspace_id_fk",
+ "tableFrom": "status_report",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "status_report_page_id_page_id_fk": {
+ "name": "status_report_page_id_page_id_fk",
+ "tableFrom": "status_report",
+ "tableTo": "page",
+ "columnsFrom": [
+ "page_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "status_report_update": {
+ "name": "status_report_update",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "date": {
+ "name": "date",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status_report_id": {
+ "name": "status_report_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "status_report_update_status_report_id_idx": {
+ "name": "status_report_update_status_report_id_idx",
+ "columns": [
+ "status_report_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "status_report_update_status_report_id_status_report_id_fk": {
+ "name": "status_report_update_status_report_id_status_report_id_fk",
+ "tableFrom": "status_report_update",
+ "tableTo": "status_report",
+ "columnsFrom": [
+ "status_report_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "integration": {
+ "name": "integration",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "credential": {
+ "name": "credential",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "data": {
+ "name": "data",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "integration_workspace_id_idx": {
+ "name": "integration_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "integration_workspace_id_workspace_id_fk": {
+ "name": "integration_workspace_id_workspace_id_fk",
+ "tableFrom": "integration",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "page": {
+ "name": "page",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "custom_domain": {
+ "name": "custom_domain",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "published": {
+ "name": "published",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": false
+ },
+ "force_theme": {
+ "name": "force_theme",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'system'"
+ },
+ "password": {
+ "name": "password",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "password_protected": {
+ "name": "password_protected",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": false
+ },
+ "access_type": {
+ "name": "access_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'public'"
+ },
+ "auth_email_domains": {
+ "name": "auth_email_domains",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "allowed_ip_ranges": {
+ "name": "allowed_ip_ranges",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "homepage_url": {
+ "name": "homepage_url",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "contact_url": {
+ "name": "contact_url",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "default_locale": {
+ "name": "default_locale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'en'"
+ },
+ "locales": {
+ "name": "locales",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "legacy_page": {
+ "name": "legacy_page",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "configuration": {
+ "name": "configuration",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "allow_index": {
+ "name": "allow_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "show_monitor_values": {
+ "name": "show_monitor_values",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "page_slug_unique": {
+ "name": "page_slug_unique",
+ "columns": [
+ "slug"
+ ],
+ "isUnique": true
+ },
+ "page_lower_slug_idx": {
+ "name": "page_lower_slug_idx",
+ "columns": [
+ "LOWER(\"slug\")"
+ ],
+ "isUnique": false
+ },
+ "page_lower_custom_domain_idx": {
+ "name": "page_lower_custom_domain_idx",
+ "columns": [
+ "LOWER(\"custom_domain\")"
+ ],
+ "isUnique": false
+ },
+ "page_workspace_id_idx": {
+ "name": "page_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "page_workspace_id_workspace_id_fk": {
+ "name": "page_workspace_id_workspace_id_fk",
+ "tableFrom": "page",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "monitor": {
+ "name": "monitor",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "job_type": {
+ "name": "job_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'http'"
+ },
+ "periodicity": {
+ "name": "periodicity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'other'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'active'"
+ },
+ "active": {
+ "name": "active",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": false
+ },
+ "regions": {
+ "name": "regions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "url": {
+ "name": "url",
+ "type": "text(2048)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "external_name": {
+ "name": "external_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "headers": {
+ "name": "headers",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "method": {
+ "name": "method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'GET'"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "timeout": {
+ "name": "timeout",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 45000
+ },
+ "degraded_after": {
+ "name": "degraded_after",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "assertions": {
+ "name": "assertions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "otel_endpoint": {
+ "name": "otel_endpoint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "otel_headers": {
+ "name": "otel_headers",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "public": {
+ "name": "public",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": false
+ },
+ "retry": {
+ "name": "retry",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 3
+ },
+ "follow_redirects": {
+ "name": "follow_redirects",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "monitor_workspace_id_active_idx": {
+ "name": "monitor_workspace_id_active_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false,
+ "where": "\"monitor\".\"deleted_at\" IS NULL"
+ }
+ },
+ "foreignKeys": {
+ "monitor_workspace_id_workspace_id_fk": {
+ "name": "monitor_workspace_id_workspace_id_fk",
+ "tableFrom": "monitor",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "page_subscriber": {
+ "name": "page_subscriber",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "page_id": {
+ "name": "page_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "channel_type": {
+ "name": "channel_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'email'"
+ },
+ "webhook_url": {
+ "name": "webhook_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "channel_config": {
+ "name": "channel_config",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'self_signup'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "unsubscribed_at": {
+ "name": "unsubscribed_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "idx_page_subscriber_email_page_active": {
+ "name": "idx_page_subscriber_email_page_active",
+ "columns": [
+ "LOWER(\"email\")",
+ "page_id"
+ ],
+ "isUnique": true,
+ "where": "\"page_subscriber\".\"unsubscribed_at\" IS NULL AND \"page_subscriber\".\"channel_type\" = 'email'"
+ },
+ "idx_page_subscriber_webhook_page_active": {
+ "name": "idx_page_subscriber_webhook_page_active",
+ "columns": [
+ "LOWER(\"webhook_url\")",
+ "page_id"
+ ],
+ "isUnique": true,
+ "where": "\"page_subscriber\".\"unsubscribed_at\" IS NULL AND \"page_subscriber\".\"channel_type\" = 'webhook'"
+ }
+ },
+ "foreignKeys": {
+ "page_subscriber_page_id_page_id_fk": {
+ "name": "page_subscriber_page_id_page_id_fk",
+ "tableFrom": "page_subscriber",
+ "tableTo": "page",
+ "columnsFrom": [
+ "page_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {
+ "page_subscriber_channel_check": {
+ "name": "page_subscriber_channel_check",
+ "value": "(\"page_subscriber\".\"channel_type\" = 'email' AND \"page_subscriber\".\"email\" IS NOT NULL AND \"page_subscriber\".\"webhook_url\" IS NULL) OR (\"page_subscriber\".\"channel_type\" = 'webhook' AND \"page_subscriber\".\"webhook_url\" IS NOT NULL AND \"page_subscriber\".\"email\" IS NULL)"
+ }
+ }
+ },
+ "page_subscriber_to_page_component": {
+ "name": "page_subscriber_to_page_component",
+ "columns": {
+ "page_subscriber_id": {
+ "name": "page_subscriber_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "page_component_id": {
+ "name": "page_component_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "page_subscriber_to_page_component_page_subscriber_id_page_subscriber_id_fk": {
+ "name": "page_subscriber_to_page_component_page_subscriber_id_page_subscriber_id_fk",
+ "tableFrom": "page_subscriber_to_page_component",
+ "tableTo": "page_subscriber",
+ "columnsFrom": [
+ "page_subscriber_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "page_subscriber_to_page_component_page_component_id_page_component_id_fk": {
+ "name": "page_subscriber_to_page_component_page_component_id_page_component_id_fk",
+ "tableFrom": "page_subscriber_to_page_component",
+ "tableTo": "page_component",
+ "columnsFrom": [
+ "page_component_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "page_subscriber_to_page_component_page_subscriber_id_page_component_id_pk": {
+ "columns": [
+ "page_subscriber_id",
+ "page_component_id"
+ ],
+ "name": "page_subscriber_to_page_component_page_subscriber_id_page_component_id_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "notification": {
+ "name": "notification",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "data": {
+ "name": "data",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'{}'"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "notification_workspace_id_idx": {
+ "name": "notification_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "notification_workspace_id_workspace_id_fk": {
+ "name": "notification_workspace_id_workspace_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "notification_trigger": {
+ "name": "notification_trigger",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "notification_id": {
+ "name": "notification_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "cron_timestamp": {
+ "name": "cron_timestamp",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "notification_id_monitor_id_crontimestampe": {
+ "name": "notification_id_monitor_id_crontimestampe",
+ "columns": [
+ "notification_id",
+ "monitor_id",
+ "cron_timestamp"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "notification_trigger_monitor_id_monitor_id_fk": {
+ "name": "notification_trigger_monitor_id_monitor_id_fk",
+ "tableFrom": "notification_trigger",
+ "tableTo": "monitor",
+ "columnsFrom": [
+ "monitor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notification_trigger_notification_id_notification_id_fk": {
+ "name": "notification_trigger_notification_id_notification_id_fk",
+ "tableFrom": "notification_trigger",
+ "tableTo": "notification",
+ "columnsFrom": [
+ "notification_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "notifications_to_monitors": {
+ "name": "notifications_to_monitors",
+ "columns": {
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "notification_id": {
+ "name": "notification_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "notifications_to_monitors_notification_id_idx": {
+ "name": "notifications_to_monitors_notification_id_idx",
+ "columns": [
+ "notification_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "notifications_to_monitors_monitor_id_monitor_id_fk": {
+ "name": "notifications_to_monitors_monitor_id_monitor_id_fk",
+ "tableFrom": "notifications_to_monitors",
+ "tableTo": "monitor",
+ "columnsFrom": [
+ "monitor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notifications_to_monitors_notification_id_notification_id_fk": {
+ "name": "notifications_to_monitors_notification_id_notification_id_fk",
+ "tableFrom": "notifications_to_monitors",
+ "tableTo": "notification",
+ "columnsFrom": [
+ "notification_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "notifications_to_monitors_monitor_id_notification_id_pk": {
+ "columns": [
+ "monitor_id",
+ "notification_id"
+ ],
+ "name": "notifications_to_monitors_monitor_id_notification_id_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "monitor_status": {
+ "name": "monitor_status",
+ "columns": {
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "region": {
+ "name": "region",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'active'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "monitor_status_idx": {
+ "name": "monitor_status_idx",
+ "columns": [
+ "monitor_id",
+ "region"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "monitor_status_monitor_id_monitor_id_fk": {
+ "name": "monitor_status_monitor_id_monitor_id_fk",
+ "tableFrom": "monitor_status",
+ "tableTo": "monitor",
+ "columnsFrom": [
+ "monitor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "monitor_status_monitor_id_region_pk": {
+ "columns": [
+ "monitor_id",
+ "region"
+ ],
+ "name": "monitor_status_monitor_id_region_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "invitation": {
+ "name": "invitation",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'member'"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "invitation_workspace_id_idx": {
+ "name": "invitation_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "incident": {
+ "name": "incident",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'triage'"
+ },
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "acknowledged_at": {
+ "name": "acknowledged_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "acknowledged_by": {
+ "name": "acknowledged_by",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "resolved_by": {
+ "name": "resolved_by",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "incident_screenshot_url": {
+ "name": "incident_screenshot_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "recovery_screenshot_url": {
+ "name": "recovery_screenshot_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "auto_resolved": {
+ "name": "auto_resolved",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "incident_workspace_id_idx": {
+ "name": "incident_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ },
+ "incident_monitor_id_started_at_unique": {
+ "name": "incident_monitor_id_started_at_unique",
+ "columns": [
+ "monitor_id",
+ "started_at"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "incident_monitor_id_monitor_id_fk": {
+ "name": "incident_monitor_id_monitor_id_fk",
+ "tableFrom": "incident",
+ "tableTo": "monitor",
+ "columnsFrom": [
+ "monitor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set default",
+ "onUpdate": "no action"
+ },
+ "incident_workspace_id_workspace_id_fk": {
+ "name": "incident_workspace_id_workspace_id_fk",
+ "tableFrom": "incident",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "incident_acknowledged_by_user_id_fk": {
+ "name": "incident_acknowledged_by_user_id_fk",
+ "tableFrom": "incident",
+ "tableTo": "user",
+ "columnsFrom": [
+ "acknowledged_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "incident_resolved_by_user_id_fk": {
+ "name": "incident_resolved_by_user_id_fk",
+ "tableFrom": "incident",
+ "tableTo": "user",
+ "columnsFrom": [
+ "resolved_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "monitor_tag": {
+ "name": "monitor_tag",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "monitor_tag_workspace_id_idx": {
+ "name": "monitor_tag_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "monitor_tag_workspace_id_workspace_id_fk": {
+ "name": "monitor_tag_workspace_id_workspace_id_fk",
+ "tableFrom": "monitor_tag",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "monitor_tag_to_monitor": {
+ "name": "monitor_tag_to_monitor",
+ "columns": {
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "monitor_tag_id": {
+ "name": "monitor_tag_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "monitor_tag_to_monitor_monitor_tag_id_idx": {
+ "name": "monitor_tag_to_monitor_monitor_tag_id_idx",
+ "columns": [
+ "monitor_tag_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "monitor_tag_to_monitor_monitor_id_monitor_id_fk": {
+ "name": "monitor_tag_to_monitor_monitor_id_monitor_id_fk",
+ "tableFrom": "monitor_tag_to_monitor",
+ "tableTo": "monitor",
+ "columnsFrom": [
+ "monitor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "monitor_tag_to_monitor_monitor_tag_id_monitor_tag_id_fk": {
+ "name": "monitor_tag_to_monitor_monitor_tag_id_monitor_tag_id_fk",
+ "tableFrom": "monitor_tag_to_monitor",
+ "tableTo": "monitor_tag",
+ "columnsFrom": [
+ "monitor_tag_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "monitor_tag_to_monitor_monitor_id_monitor_tag_id_pk": {
+ "columns": [
+ "monitor_id",
+ "monitor_tag_id"
+ ],
+ "name": "monitor_tag_to_monitor_monitor_id_monitor_tag_id_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "application": {
+ "name": "application",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "dsn": {
+ "name": "dsn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "application_dsn_unique": {
+ "name": "application_dsn_unique",
+ "columns": [
+ "dsn"
+ ],
+ "isUnique": true
+ },
+ "application_workspace_id_idx": {
+ "name": "application_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "application_workspace_id_workspace_id_fk": {
+ "name": "application_workspace_id_workspace_id_fk",
+ "tableFrom": "application",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "maintenance": {
+ "name": "maintenance",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "from": {
+ "name": "from",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "to": {
+ "name": "to",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "page_id": {
+ "name": "page_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "maintenance_page_id_idx": {
+ "name": "maintenance_page_id_idx",
+ "columns": [
+ "page_id"
+ ],
+ "isUnique": false
+ },
+ "maintenance_workspace_id_idx": {
+ "name": "maintenance_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "maintenance_workspace_id_workspace_id_fk": {
+ "name": "maintenance_workspace_id_workspace_id_fk",
+ "tableFrom": "maintenance",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "maintenance_page_id_page_id_fk": {
+ "name": "maintenance_page_id_page_id_fk",
+ "tableFrom": "maintenance",
+ "tableTo": "page",
+ "columnsFrom": [
+ "page_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "check": {
+ "name": "check",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "regions": {
+ "name": "regions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "url": {
+ "name": "url",
+ "type": "text(4096)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "headers": {
+ "name": "headers",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "method": {
+ "name": "method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'GET'"
+ },
+ "count_requests": {
+ "name": "count_requests",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 1
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "check_workspace_id_idx": {
+ "name": "check_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "check_workspace_id_workspace_id_fk": {
+ "name": "check_workspace_id_workspace_id_fk",
+ "tableFrom": "check",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "monitor_run": {
+ "name": "monitor_run",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "runned_at": {
+ "name": "runned_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "monitor_run_workspace_id_idx": {
+ "name": "monitor_run_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ },
+ "monitor_run_monitor_id_idx": {
+ "name": "monitor_run_monitor_id_idx",
+ "columns": [
+ "monitor_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "monitor_run_workspace_id_workspace_id_fk": {
+ "name": "monitor_run_workspace_id_workspace_id_fk",
+ "tableFrom": "monitor_run",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "monitor_run_monitor_id_monitor_id_fk": {
+ "name": "monitor_run_monitor_id_monitor_id_fk",
+ "tableFrom": "monitor_run",
+ "tableTo": "monitor",
+ "columnsFrom": [
+ "monitor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "private_location": {
+ "name": "private_location",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "last_seen_at": {
+ "name": "last_seen_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "private_location_workspace_id_idx": {
+ "name": "private_location_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "private_location_workspace_id_workspace_id_fk": {
+ "name": "private_location_workspace_id_workspace_id_fk",
+ "tableFrom": "private_location",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "private_location_to_monitor": {
+ "name": "private_location_to_monitor",
+ "columns": {
+ "private_location_id": {
+ "name": "private_location_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "private_location_to_monitor_private_location_id_idx": {
+ "name": "private_location_to_monitor_private_location_id_idx",
+ "columns": [
+ "private_location_id"
+ ],
+ "isUnique": false
+ },
+ "private_location_to_monitor_monitor_id_idx": {
+ "name": "private_location_to_monitor_monitor_id_idx",
+ "columns": [
+ "monitor_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "private_location_to_monitor_private_location_id_private_location_id_fk": {
+ "name": "private_location_to_monitor_private_location_id_private_location_id_fk",
+ "tableFrom": "private_location_to_monitor",
+ "tableTo": "private_location",
+ "columnsFrom": [
+ "private_location_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "private_location_to_monitor_monitor_id_monitor_id_fk": {
+ "name": "private_location_to_monitor_monitor_id_monitor_id_fk",
+ "tableFrom": "private_location_to_monitor",
+ "tableTo": "monitor",
+ "columnsFrom": [
+ "monitor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "monitor_group": {
+ "name": "monitor_group",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "page_id": {
+ "name": "page_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "monitor_group_workspace_id_idx": {
+ "name": "monitor_group_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ },
+ "monitor_group_page_id_idx": {
+ "name": "monitor_group_page_id_idx",
+ "columns": [
+ "page_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "monitor_group_workspace_id_workspace_id_fk": {
+ "name": "monitor_group_workspace_id_workspace_id_fk",
+ "tableFrom": "monitor_group",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "monitor_group_page_id_page_id_fk": {
+ "name": "monitor_group_page_id_page_id_fk",
+ "tableFrom": "monitor_group",
+ "tableTo": "page",
+ "columnsFrom": [
+ "page_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "viewer": {
+ "name": "viewer",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "viewer_email_unique": {
+ "name": "viewer_email_unique",
+ "columns": [
+ "email"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "viewer_accounts": {
+ "name": "viewer_accounts",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "viewer_accounts_user_id_viewer_id_fk": {
+ "name": "viewer_accounts_user_id_viewer_id_fk",
+ "tableFrom": "viewer_accounts",
+ "tableTo": "viewer",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "viewer_accounts_provider_providerAccountId_pk": {
+ "columns": [
+ "provider",
+ "providerAccountId"
+ ],
+ "name": "viewer_accounts_provider_providerAccountId_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "viewer_session": {
+ "name": "viewer_session",
+ "columns": {
+ "session_token": {
+ "name": "session_token",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires": {
+ "name": "expires",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "viewer_session_user_id_viewer_id_fk": {
+ "name": "viewer_session_user_id_viewer_id_fk",
+ "tableFrom": "viewer_session",
+ "tableTo": "viewer",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "api_key": {
+ "name": "api_key",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "prefix": {
+ "name": "prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "hashed_token": {
+ "name": "hashed_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_by_id": {
+ "name": "created_by_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[\"write\"]'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "api_key_prefix_unique": {
+ "name": "api_key_prefix_unique",
+ "columns": [
+ "prefix"
+ ],
+ "isUnique": true
+ },
+ "api_key_hashed_token_unique": {
+ "name": "api_key_hashed_token_unique",
+ "columns": [
+ "hashed_token"
+ ],
+ "isUnique": true
+ },
+ "api_key_prefix_idx": {
+ "name": "api_key_prefix_idx",
+ "columns": [
+ "prefix"
+ ],
+ "isUnique": false
+ },
+ "api_key_workspace_id_idx": {
+ "name": "api_key_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "api_key_workspace_id_workspace_id_fk": {
+ "name": "api_key_workspace_id_workspace_id_fk",
+ "tableFrom": "api_key",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "api_key_created_by_id_user_id_fk": {
+ "name": "api_key_created_by_id_user_id_fk",
+ "tableFrom": "api_key",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "maintenance_to_page_component": {
+ "name": "maintenance_to_page_component",
+ "columns": {
+ "maintenance_id": {
+ "name": "maintenance_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "page_component_id": {
+ "name": "page_component_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "maintenance_to_page_component_page_component_id_idx": {
+ "name": "maintenance_to_page_component_page_component_id_idx",
+ "columns": [
+ "page_component_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "maintenance_to_page_component_maintenance_id_maintenance_id_fk": {
+ "name": "maintenance_to_page_component_maintenance_id_maintenance_id_fk",
+ "tableFrom": "maintenance_to_page_component",
+ "tableTo": "maintenance",
+ "columnsFrom": [
+ "maintenance_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "maintenance_to_page_component_page_component_id_page_component_id_fk": {
+ "name": "maintenance_to_page_component_page_component_id_page_component_id_fk",
+ "tableFrom": "maintenance_to_page_component",
+ "tableTo": "page_component",
+ "columnsFrom": [
+ "page_component_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "maintenance_to_page_component_maintenance_id_page_component_id_pk": {
+ "columns": [
+ "maintenance_id",
+ "page_component_id"
+ ],
+ "name": "maintenance_to_page_component_maintenance_id_page_component_id_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "page_component": {
+ "name": "page_component",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "page_id": {
+ "name": "page_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'monitor'"
+ },
+ "monitor_id": {
+ "name": "monitor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "order": {
+ "name": "order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "group_order": {
+ "name": "group_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "page_component_workspace_id_idx": {
+ "name": "page_component_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ },
+ "page_component_page_id_monitor_id_unique": {
+ "name": "page_component_page_id_monitor_id_unique",
+ "columns": [
+ "page_id",
+ "monitor_id"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "page_component_workspace_id_workspace_id_fk": {
+ "name": "page_component_workspace_id_workspace_id_fk",
+ "tableFrom": "page_component",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "page_component_page_id_page_id_fk": {
+ "name": "page_component_page_id_page_id_fk",
+ "tableFrom": "page_component",
+ "tableTo": "page",
+ "columnsFrom": [
+ "page_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "page_component_monitor_id_monitor_id_fk": {
+ "name": "page_component_monitor_id_monitor_id_fk",
+ "tableFrom": "page_component",
+ "tableTo": "monitor",
+ "columnsFrom": [
+ "monitor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "page_component_group_id_page_component_groups_id_fk": {
+ "name": "page_component_group_id_page_component_groups_id_fk",
+ "tableFrom": "page_component",
+ "tableTo": "page_component_groups",
+ "columnsFrom": [
+ "group_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {
+ "page_component_type_check": {
+ "name": "page_component_type_check",
+ "value": "\"page_component\".\"type\" = 'monitor' AND \"page_component\".\"monitor_id\" IS NOT NULL OR \"page_component\".\"type\" = 'static' AND \"page_component\".\"monitor_id\" IS NULL"
+ }
+ }
+ },
+ "status_report_update_to_page_component": {
+ "name": "status_report_update_to_page_component",
+ "columns": {
+ "status_report_update_id": {
+ "name": "status_report_update_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "page_component_id": {
+ "name": "page_component_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "impact": {
+ "name": "impact",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "status_report_update_to_page_component_page_component_id_idx": {
+ "name": "status_report_update_to_page_component_page_component_id_idx",
+ "columns": [
+ "page_component_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "status_report_update_to_page_component_status_report_update_id_status_report_update_id_fk": {
+ "name": "status_report_update_to_page_component_status_report_update_id_status_report_update_id_fk",
+ "tableFrom": "status_report_update_to_page_component",
+ "tableTo": "status_report_update",
+ "columnsFrom": [
+ "status_report_update_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "status_report_update_to_page_component_page_component_id_page_component_id_fk": {
+ "name": "status_report_update_to_page_component_page_component_id_page_component_id_fk",
+ "tableFrom": "status_report_update_to_page_component",
+ "tableTo": "page_component",
+ "columnsFrom": [
+ "page_component_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "status_report_update_to_page_component_status_report_update_id_page_component_id_pk": {
+ "columns": [
+ "status_report_update_id",
+ "page_component_id"
+ ],
+ "name": "status_report_update_to_page_component_status_report_update_id_page_component_id_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "status_report_to_page_component": {
+ "name": "status_report_to_page_component",
+ "columns": {
+ "status_report_id": {
+ "name": "status_report_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "page_component_id": {
+ "name": "page_component_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "status_report_to_page_component_page_component_id_idx": {
+ "name": "status_report_to_page_component_page_component_id_idx",
+ "columns": [
+ "page_component_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "status_report_to_page_component_status_report_id_status_report_id_fk": {
+ "name": "status_report_to_page_component_status_report_id_status_report_id_fk",
+ "tableFrom": "status_report_to_page_component",
+ "tableTo": "status_report",
+ "columnsFrom": [
+ "status_report_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "status_report_to_page_component_page_component_id_page_component_id_fk": {
+ "name": "status_report_to_page_component_page_component_id_page_component_id_fk",
+ "tableFrom": "status_report_to_page_component",
+ "tableTo": "page_component",
+ "columnsFrom": [
+ "page_component_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "status_report_to_page_component_status_report_id_page_component_id_pk": {
+ "columns": [
+ "status_report_id",
+ "page_component_id"
+ ],
+ "name": "status_report_to_page_component_status_report_id_page_component_id_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "page_component_groups": {
+ "name": "page_component_groups",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "page_id": {
+ "name": "page_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "default_open": {
+ "name": "default_open",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "page_component_groups_page_id_idx": {
+ "name": "page_component_groups_page_id_idx",
+ "columns": [
+ "page_id"
+ ],
+ "isUnique": false
+ },
+ "page_component_groups_workspace_id_idx": {
+ "name": "page_component_groups_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "page_component_groups_workspace_id_workspace_id_fk": {
+ "name": "page_component_groups_workspace_id_workspace_id_fk",
+ "tableFrom": "page_component_groups",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "page_component_groups_page_id_page_id_fk": {
+ "name": "page_component_groups_page_id_page_id_fk",
+ "tableFrom": "page_component_groups",
+ "tableTo": "page",
+ "columnsFrom": [
+ "page_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "feedback": {
+ "name": "feedback",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "blocker": {
+ "name": "blocker",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "feedback_workspace_id_idx": {
+ "name": "feedback_workspace_id_idx",
+ "columns": [
+ "workspace_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "feedback_workspace_id_workspace_id_fk": {
+ "name": "feedback_workspace_id_workspace_id_fk",
+ "tableFrom": "feedback",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "feedback_user_id_user_id_fk": {
+ "name": "feedback_user_id_user_id_fk",
+ "tableFrom": "feedback",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "audit_log": {
+ "name": "audit_log",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "actor_type": {
+ "name": "actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "entity_type": {
+ "name": "entity_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "entity_id": {
+ "name": "entity_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "before": {
+ "name": "before",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "after": {
+ "name": "after",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "changed_fields": {
+ "name": "changed_fields",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "audit_log_workspace_created_idx": {
+ "name": "audit_log_workspace_created_idx",
+ "columns": [
+ "workspace_id",
+ "created_at"
+ ],
+ "isUnique": false
+ },
+ "audit_log_entity_idx": {
+ "name": "audit_log_entity_idx",
+ "columns": [
+ "workspace_id",
+ "entity_type",
+ "entity_id",
+ "created_at"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "external_service": {
+ "name": "external_service",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text(64)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "aliases": {
+ "name": "aliases",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(json_array())"
+ },
+ "name": {
+ "name": "name",
+ "type": "text(256)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status_page_url": {
+ "name": "status_page_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "industry": {
+ "name": "industry",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "api_config": {
+ "name": "api_config",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "external_service_slug_unique": {
+ "name": "external_service_slug_unique",
+ "columns": [
+ "slug"
+ ],
+ "isUnique": true
+ },
+ "external_service_deleted_at_idx": {
+ "name": "external_service_deleted_at_idx",
+ "columns": [
+ "deleted_at"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "external_service_component": {
+ "name": "external_service_component",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "external_service_id": {
+ "name": "external_service_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "upstream_component_id": {
+ "name": "upstream_component_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "aliases": {
+ "name": "aliases",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(json_array())"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "group_name": {
+ "name": "group_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "indicator": {
+ "name": "indicator",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "first_seen_at": {
+ "name": "first_seen_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "external_service_component_unique_idx": {
+ "name": "external_service_component_unique_idx",
+ "columns": [
+ "external_service_id",
+ "upstream_component_id"
+ ],
+ "isUnique": true
+ },
+ "external_service_component_slug_unique_idx": {
+ "name": "external_service_component_slug_unique_idx",
+ "columns": [
+ "external_service_id",
+ "slug"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "external_service_component_external_service_id_external_service_id_fk": {
+ "name": "external_service_component_external_service_id_external_service_id_fk",
+ "tableFrom": "external_service_component",
+ "tableTo": "external_service",
+ "columnsFrom": [
+ "external_service_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "external_service_incident": {
+ "name": "external_service_incident",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "external_service_id": {
+ "name": "external_service_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider_incident_id": {
+ "name": "provider_incident_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "impact": {
+ "name": "impact",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shortlink": {
+ "name": "shortlink",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "affected_component_ids": {
+ "name": "affected_component_ids",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ },
+ "raw_payload": {
+ "name": "raw_payload",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "raw_payload_purged_at": {
+ "name": "raw_payload_purged_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "first_seen_at": {
+ "name": "first_seen_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "external_service_incident_unique_idx": {
+ "name": "external_service_incident_unique_idx",
+ "columns": [
+ "external_service_id",
+ "provider_incident_id"
+ ],
+ "isUnique": true
+ },
+ "external_service_incident_started_at_idx": {
+ "name": "external_service_incident_started_at_idx",
+ "columns": [
+ "external_service_id",
+ "started_at"
+ ],
+ "isUnique": false
+ },
+ "external_service_incident_resolved_at_idx": {
+ "name": "external_service_incident_resolved_at_idx",
+ "columns": [
+ "resolved_at"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "external_service_incident_external_service_id_external_service_id_fk": {
+ "name": "external_service_incident_external_service_id_external_service_id_fk",
+ "tableFrom": "external_service_incident",
+ "tableTo": "external_service",
+ "columnsFrom": [
+ "external_service_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "chat_session": {
+ "name": "chat_session",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "messages": {
+ "name": "messages",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "chat_session_workspace_user_updated_idx": {
+ "name": "chat_session_workspace_user_updated_idx",
+ "columns": [
+ "workspace_id",
+ "user_id",
+ "updated_at"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "chat_session_workspace_id_workspace_id_fk": {
+ "name": "chat_session_workspace_id_workspace_id_fk",
+ "tableFrom": "chat_session",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "chat_session_user_id_user_id_fk": {
+ "name": "chat_session_user_id_user_id_fk",
+ "tableFrom": "chat_session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ }
+ },
+ "views": {},
+ "enums": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ },
+ "internal": {
+ "indexes": {
+ "page_lower_slug_idx": {
+ "columns": {
+ "LOWER(\"slug\")": {
+ "isExpression": true
+ }
+ }
+ },
+ "page_lower_custom_domain_idx": {
+ "columns": {
+ "LOWER(\"custom_domain\")": {
+ "isExpression": true
+ }
+ }
+ },
+ "idx_page_subscriber_email_page_active": {
+ "columns": {
+ "LOWER(\"email\")": {
+ "isExpression": true
+ }
+ }
+ },
+ "idx_page_subscriber_webhook_page_active": {
+ "columns": {
+ "LOWER(\"webhook_url\")": {
+ "isExpression": true
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.json
index f5d5fdcf1..cef3fa3a3 100644
--- a/packages/db/drizzle/meta/_journal.json
+++ b/packages/db/drizzle/meta/_journal.json
@@ -526,6 +526,13 @@
"when": 1780905377183,
"tag": "0074_chubby_ronan",
"breakpoints": true
+ },
+ {
+ "idx": 75,
+ "version": "6",
+ "when": 1781163353139,
+ "tag": "0075_yummy_ken_ellis",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/packages/db/src/schema/page_components/constants.ts b/packages/db/src/schema/page_components/constants.ts
index 42f7f5eaa..7f14c0de2 100644
--- a/packages/db/src/schema/page_components/constants.ts
+++ b/packages/db/src/schema/page_components/constants.ts
@@ -1,3 +1,74 @@
export const pageComponentTypes = ["static", "monitor"] as const;
export type PageComponentType = (typeof pageComponentTypes)[number];
+
+// ordered worst-last so worstImpact can compare by index
+export const pageComponentImpact = [
+ "operational",
+ "degraded_performance",
+ "partial_outage",
+ "major_outage",
+] as const;
+
+export type PageComponentImpact = (typeof pageComponentImpact)[number];
+
+// legacy report (no impact rows): keep pre-impact behavior — orange, full downtime
+export const LEGACY_IMPACT_WEIGHT = 1;
+
+// fraction of an interval counted as downtime in manual-mode uptime.
+// partial_outage counts half — some users affected, not all;
+// degraded_performance is 0: slow but available ≠ downtime.
+export function impactUptimeWeight(impact: PageComponentImpact): number {
+ if (impact === "major_outage") return 1;
+ if (impact === "partial_outage") return 0.5;
+ return 0;
+}
+
+// project an impact onto the status-page bar palette
+export function impactToStatusType(
+ impact: PageComponentImpact,
+): "success" | "degraded" | "error" {
+ if (impact === "major_outage") return "error";
+ if (impact === "operational") return "success";
+ return "degraded";
+}
+
+export function worstImpact(
+ impacts: Iterable<PageComponentImpact>,
+): PageComponentImpact {
+ let worst: PageComponentImpact = "operational";
+ for (const impact of impacts) {
+ if (
+ pageComponentImpact.indexOf(impact) > pageComponentImpact.indexOf(worst)
+ ) {
+ worst = impact;
+ }
+ }
+ return worst;
+}
+
+/**
+ * Current impact per component: the latest update (by date, ties by id)
+ * naming it wins. Empty map ⇒ legacy report (no impact rows).
+ */
+export function currentImpactsFromUpdates(
+ updates: ReadonlyArray<{
+ id: number;
+ date: Date;
+ componentImpacts: ReadonlyArray<{
+ pageComponentId: number;
+ impact: PageComponentImpact;
+ }>;
+ }>,
+): Map<number, PageComponentImpact> {
+ const sorted = [...updates].sort(
+ (a, b) => a.date.getTime() - b.date.getTime() || a.id - b.id,
+ );
+ const current = new Map<number, PageComponentImpact>();
+ for (const update of sorted) {
+ for (const row of update.componentImpacts) {
+ current.set(row.pageComponentId, row.impact);
+ }
+ }
+ return current;
+}
diff --git a/packages/db/src/schema/page_components/page_components.ts b/packages/db/src/schema/page_components/page_components.ts
index 7b0ed6ed3..693a9f3e4 100644
--- a/packages/db/src/schema/page_components/page_components.ts
+++ b/packages/db/src/schema/page_components/page_components.ts
@@ -13,9 +13,9 @@ import { maintenance } from "../maintenances";
import { monitor } from "../monitors";
import { pageComponentGroup } from "../page_component_groups";
import { page } from "../pages";
-import { statusReport } from "../status_reports";
+import { statusReport, statusReportUpdate } from "../status_reports";
import { workspace } from "../workspaces";
-import { pageComponentTypes } from "./constants";
+import { pageComponentImpact, pageComponentTypes } from "./constants";
export const pageComponent = sqliteTable(
"page_component",
@@ -82,6 +82,9 @@ export const pageComponentRelations = relations(
references: [pageComponentGroup.id],
}),
statusReportsToPageComponents: many(statusReportsToPageComponents),
+ statusReportUpdateToPageComponents: many(
+ statusReportUpdateToPageComponents,
+ ),
maintenancesToPageComponents: many(maintenancesToPageComponents),
}),
);
@@ -155,3 +158,41 @@ export const statusReportsToPageComponentsRelations = relations(
}),
}),
);
+
+// timeline: the impact each update set per component — the only place impact
+// is stored. `status_report_to_page_component` stays the membership source.
+export const statusReportUpdateToPageComponents = sqliteTable(
+ "status_report_update_to_page_component",
+ {
+ statusReportUpdateId: integer("status_report_update_id")
+ .notNull()
+ .references(() => statusReportUpdate.id, { onDelete: "cascade" }),
+ pageComponentId: integer("page_component_id")
+ .notNull()
+ .references(() => pageComponent.id, { onDelete: "cascade" }),
+ impact: text("impact", { enum: pageComponentImpact }).notNull(),
+ createdAt: integer("created_at", { mode: "timestamp" }).default(
+ sql`(strftime('%s', 'now'))`,
+ ),
+ },
+ (t) => [
+ primaryKey({ columns: [t.statusReportUpdateId, t.pageComponentId] }),
+ index("status_report_update_to_page_component_page_component_id_idx").on(
+ t.pageComponentId,
+ ),
+ ],
+);
+
+export const statusReportUpdateToPageComponentsRelations = relations(
+ statusReportUpdateToPageComponents,
+ ({ one }) => ({
+ statusReportUpdate: one(statusReportUpdate, {
+ fields: [statusReportUpdateToPageComponents.statusReportUpdateId],
+ references: [statusReportUpdate.id],
+ }),
+ pageComponent: one(pageComponent, {
+ fields: [statusReportUpdateToPageComponents.pageComponentId],
+ references: [pageComponent.id],
+ }),
+ }),
+);
diff --git a/packages/db/src/schema/page_components/validation.ts b/packages/db/src/schema/page_components/validation.ts
index 27ef50076..71188c429 100644
--- a/packages/db/src/schema/page_components/validation.ts
+++ b/packages/db/src/schema/page_components/validation.ts
@@ -1,7 +1,11 @@
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
-import type { z } from "zod";
+import { z } from "zod";
-import { pageComponent } from "./page_components";
+import { pageComponentImpact } from "./constants";
+import {
+ pageComponent,
+ statusReportUpdateToPageComponents,
+} from "./page_components";
export const selectPageComponentSchema = createSelectSchema(pageComponent);
@@ -27,3 +31,19 @@ export const insertPageComponentSchema = createInsertSchema(pageComponent, {
export type InsertPageComponent = z.infer<typeof insertPageComponentSchema>;
export type PageComponent = z.infer<typeof selectPageComponentSchema>;
+
+export const pageComponentImpactSchema = z.enum(pageComponentImpact);
+
+export const selectStatusReportUpdateToPageComponentSchema = createSelectSchema(
+ statusReportUpdateToPageComponents,
+ { impact: pageComponentImpactSchema },
+);
+
+export const insertStatusReportUpdateToPageComponentSchema = createInsertSchema(
+ statusReportUpdateToPageComponents,
+ { impact: pageComponentImpactSchema },
+);
+
+export type StatusReportUpdateToPageComponent = z.infer<
+ typeof selectStatusReportUpdateToPageComponentSchema
+>;
diff --git a/packages/db/src/schema/shared.ts b/packages/db/src/schema/shared.ts
index ae455d136..eba7cf99a 100644
--- a/packages/db/src/schema/shared.ts
+++ b/packages/db/src/schema/shared.ts
@@ -5,7 +5,10 @@ import { selectMaintenanceSchema } from "./maintenances";
import { selectMonitorGroupSchema } from "./monitor_groups";
import { selectMonitorSchema } from "./monitors";
import { selectPageComponentGroupSchema } from "./page_component_groups";
-import { selectPageComponentSchema } from "./page_components";
+import {
+ selectPageComponentSchema,
+ selectStatusReportUpdateToPageComponentSchema,
+} from "./page_components";
import { selectPageSchema } from "./pages";
import {
selectStatusReportSchema,
@@ -31,7 +34,15 @@ export const selectPublicMonitorSchema =
}));
export const selectStatusReportPageSchema = selectStatusReportSchema.extend({
- statusReportUpdates: z.array(selectStatusReportUpdateSchema).prefault([]),
+ statusReportUpdates: z
+ .array(
+ selectStatusReportUpdateSchema.extend({
+ statusReportUpdateToPageComponents: z
+ .array(selectStatusReportUpdateToPageComponentSchema)
+ .prefault([]),
+ }),
+ )
+ .prefault([]),
statusReportsToPageComponents: z
.array(
z.object({
diff --git a/packages/db/src/schema/status_reports/status_reports.ts b/packages/db/src/schema/status_reports/status_reports.ts
index 20d62370c..004a56cdf 100644
--- a/packages/db/src/schema/status_reports/status_reports.ts
+++ b/packages/db/src/schema/status_reports/status_reports.ts
@@ -1,7 +1,10 @@
import { relations, sql } from "drizzle-orm";
import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
-import { statusReportsToPageComponents } from "../page_components";
+import {
+ statusReportUpdateToPageComponents,
+ statusReportsToPageComponents,
+} from "../page_components";
import { page } from "../pages";
import { workspace } from "../workspaces";
@@ -80,10 +83,13 @@ export const StatusReportRelations = relations(
export const statusReportUpdateRelations = relations(
statusReportUpdate,
- ({ one }) => ({
+ ({ one, many }) => ({
statusReport: one(statusReport, {
fields: [statusReportUpdate.statusReportId],
references: [statusReport.id],
}),
+ statusReportUpdateToPageComponents: many(
+ statusReportUpdateToPageComponents,
+ ),
}),
);
diff --git a/packages/importers/src/index.ts b/packages/importers/src/index.ts
index ff91058de..0301c1e12 100644
--- a/packages/importers/src/index.ts
+++ b/packages/importers/src/index.ts
@@ -1,9 +1,11 @@
export type {
+ ComponentImpact,
ImportConfig,
ImportProvider,
ImportSummary,
PhaseResult,
ResourceResult,
+ UpdateComponentImpact,
} from "./types";
export { createStatuspageProvider } from "./providers/statuspage";
diff --git a/packages/importers/src/providers/betterstack/mapper.test.ts b/packages/importers/src/providers/betterstack/mapper.test.ts
index 06cf6e636..e4e238758 100644
--- a/packages/importers/src/providers/betterstack/mapper.test.ts
+++ b/packages/importers/src/providers/betterstack/mapper.test.ts
@@ -275,6 +275,26 @@ describe("mapReportToStatusReport", () => {
expect(result.updates).toHaveLength(1);
expect(result.updates[0].message).toBe("API Gateway Elevated Error Rates");
expect(result.report.pageId).toBeUndefined();
+ // synthetic update inherits the report-level affected resources
+ expect(result.updates[0].componentImpacts).toEqual([
+ { sourceComponentId: "bs_res_001", impact: "major_outage" },
+ ]);
+ });
+
+ test("maps per-update component impacts from affected_resources", () => {
+ const result = mapReportToStatusReport(
+ MOCK_STATUS_REPORTS[0],
+ MOCK_STATUS_UPDATES_REPORT_001,
+ 42,
+ 1,
+ );
+ expect(result.updates[0].componentImpacts).toEqual([
+ { sourceComponentId: "bs_res_001", impact: "major_outage" },
+ ]);
+ // resolving update clears to operational
+ expect(result.updates[2].componentImpacts).toEqual([
+ { sourceComponentId: "bs_res_001", impact: "operational" },
+ ]);
});
});
diff --git a/packages/importers/src/providers/betterstack/mapper.ts b/packages/importers/src/providers/betterstack/mapper.ts
index 14ebfb8b4..7dac8c219 100644
--- a/packages/importers/src/providers/betterstack/mapper.ts
+++ b/packages/importers/src/providers/betterstack/mapper.ts
@@ -1,3 +1,4 @@
+import type { ComponentImpact, UpdateComponentImpact } from "../../types";
import type {
BetterstackIncident,
BetterstackMonitor,
@@ -189,6 +190,26 @@ const REPORT_STATUS_MAP: Record<string, StatusReportStatus> = {
maintenance: "monitoring",
};
+// maintenance counts as available; unknown values are dropped, not guessed
+const COMPONENT_IMPACT_MAP: Record<string, ComponentImpact> = {
+ operational: "operational",
+ resolved: "operational",
+ downtime: "major_outage",
+ degraded: "degraded_performance",
+ maintenance: "operational",
+};
+
+function mapAffectedResourcesToImpacts(
+ resources: { status_page_resource_id: string; status: string }[],
+): UpdateComponentImpact[] {
+ return resources.flatMap((r) => {
+ const impact = COMPONENT_IMPACT_MAP[r.status.toLowerCase()];
+ return impact
+ ? [{ sourceComponentId: r.status_page_resource_id, impact }]
+ : [];
+ });
+}
+
export function mapReportAggregateState(
state: string | null,
): StatusReportStatus {
@@ -217,6 +238,9 @@ export function mapReportToStatusReport(
status: aggregateStatus,
message: u.attributes.message ?? "",
date: new Date(u.attributes.published_at),
+ componentImpacts: mapAffectedResourcesToImpacts(
+ u.attributes.affected_resources,
+ ),
};
});
@@ -226,6 +250,9 @@ export function mapReportToStatusReport(
status: mapReportAggregateState(report.attributes.aggregate_state),
message: report.attributes.title,
date: new Date(report.attributes.starts_at),
+ componentImpacts: mapAffectedResourcesToImpacts(
+ report.attributes.affected_resources,
+ ),
});
}
diff --git a/packages/importers/src/providers/statuspage/mapper.test.ts b/packages/importers/src/providers/statuspage/mapper.test.ts
index 8b7547ed2..40f162f27 100644
--- a/packages/importers/src/providers/statuspage/mapper.test.ts
+++ b/packages/importers/src/providers/statuspage/mapper.test.ts
@@ -109,6 +109,19 @@ describe("mapIncidentToStatusReport", () => {
expect(lastUpdate.message).toContain("---\n\n**Postmortem**\n\n");
expect(lastUpdate.message).toContain("## Summary");
});
+
+ it("maps per-update component impacts from affected_components", () => {
+ const result = mapIncidentToStatusReport(MOCK_INCIDENTS[0], 1, 10);
+ expect(result.updates[0].componentImpacts).toEqual([
+ { sourceComponentId: "sp_comp_001", impact: "major_outage" },
+ ]);
+ expect(result.updates[2].componentImpacts).toEqual([
+ { sourceComponentId: "sp_comp_001", impact: "degraded_performance" },
+ ]);
+ expect(result.updates[3].componentImpacts).toEqual([
+ { sourceComponentId: "sp_comp_001", impact: "operational" },
+ ]);
+ });
});
describe("mapIncidentUpdateStatus", () => {
diff --git a/packages/importers/src/providers/statuspage/mapper.ts b/packages/importers/src/providers/statuspage/mapper.ts
index e3609c0bd..01fa35a23 100644
--- a/packages/importers/src/providers/statuspage/mapper.ts
+++ b/packages/importers/src/providers/statuspage/mapper.ts
@@ -1,3 +1,4 @@
+import type { ComponentImpact, UpdateComponentImpact } from "../../types";
import type {
StatuspageComponent,
StatuspageGroupComponent,
@@ -12,6 +13,16 @@ export type StatusReportStatus =
| "monitoring"
| "resolved";
+// `under_maintenance` has no openstatus equivalent — treat as available.
+// Unknown values are dropped rather than guessed.
+const COMPONENT_IMPACT_MAP: Record<string, ComponentImpact> = {
+ operational: "operational",
+ degraded_performance: "degraded_performance",
+ partial_outage: "partial_outage",
+ major_outage: "major_outage",
+ under_maintenance: "operational",
+};
+
export function mapPage(page: StatuspagePage, workspaceId: number) {
return {
workspaceId,
@@ -85,6 +96,13 @@ export function mapIncidentToStatusReport(
status: mapIncidentUpdateStatus(u.status),
message: u.body ?? "",
date: new Date(u.created_at),
+ componentImpacts: (u.affected_components ?? []).flatMap(
+ (c): UpdateComponentImpact[] => {
+ const impact = COMPONENT_IMPACT_MAP[c.new_status];
+ // `code` is the component id `componentIdMap` is keyed on
+ return impact ? [{ sourceComponentId: c.code, impact }] : [];
+ },
+ ),
}));
if (incident.postmortem_body && mappedUpdates.length > 0) {
diff --git a/packages/importers/src/types.ts b/packages/importers/src/types.ts
index 1744666e2..0abea963c 100644
--- a/packages/importers/src/types.ts
+++ b/packages/importers/src/types.ts
@@ -1,3 +1,18 @@
+/**
+ * Per-component impact a status report update sets. Mirrors openstatus's
+ * `pageComponentImpact` taxonomy (this package doesn't depend on the db).
+ */
+export type ComponentImpact =
+ | "operational"
+ | "degraded_performance"
+ | "partial_outage"
+ | "major_outage";
+
+export type UpdateComponentImpact = {
+ sourceComponentId: string;
+ impact: ComponentImpact;
+};
+
/**
* Result of importing a single resource.
*/
diff --git a/packages/proto/api/openstatus/status_report/v1/service.proto b/packages/proto/api/openstatus/status_report/v1/service.proto
index 4152797d7..bd28f4224 100644
--- a/packages/proto/api/openstatus/status_report/v1/service.proto
+++ b/packages/proto/api/openstatus/status_report/v1/service.proto
@@ -72,6 +72,11 @@ message CreateStatusReportRequest {
// Whether to notify subscribers about this status report (optional, defaults to false).
optional bool notify = 7;
+
+ // Per-component impacts set by the initial update (optional). When provided,
+ // the named components are added to the report's affected set. Omitting this
+ // field creates a legacy report without impact tracking.
+ repeated ComponentImpact component_impacts = 8;
}
// CreateStatusReportResponse is the response after creating a status report.
@@ -167,6 +172,11 @@ message AddStatusReportUpdateRequest {
// Whether to notify subscribers about this update (optional, defaults to false).
optional bool notify = 5;
+
+ // Per-component impacts this update sets (optional). Components named here
+ // are added to the report's affected set; omitted components keep their
+ // prior impact.
+ repeated ComponentImpact component_impacts = 6;
}
// AddStatusReportUpdateResponse is the response after adding an update to a status report.
diff --git a/packages/proto/api/openstatus/status_report/v1/status_report.proto b/packages/proto/api/openstatus/status_report/v1/status_report.proto
index cb232bd69..65b59389b 100644
--- a/packages/proto/api/openstatus/status_report/v1/status_report.proto
+++ b/packages/proto/api/openstatus/status_report/v1/status_report.proto
@@ -13,6 +13,25 @@ enum StatusReportStatus {
STATUS_REPORT_STATUS_RESOLVED = 4;
}
+// PageComponentImpact is the per-component impact a status report update sets.
+// UNSPECIFIED means the caller doesn't speak impact (legacy) — it is NOT operational.
+enum PageComponentImpact {
+ PAGE_COMPONENT_IMPACT_UNSPECIFIED = 0;
+ PAGE_COMPONENT_IMPACT_OPERATIONAL = 1;
+ PAGE_COMPONENT_IMPACT_DEGRADED_PERFORMANCE = 2;
+ PAGE_COMPONENT_IMPACT_PARTIAL_OUTAGE = 3;
+ PAGE_COMPONENT_IMPACT_MAJOR_OUTAGE = 4;
+}
+
+// ComponentImpact pairs a page component with the impact an update set for it.
+message ComponentImpact {
+ // ID of the affected page component.
+ string page_component_id = 1;
+
+ // Impact set for the component.
+ PageComponentImpact impact = 2;
+}
+
// StatusReportUpdate represents a single update entry in a status report timeline.
message StatusReportUpdate {
// Unique identifier for the update.
@@ -29,6 +48,9 @@ message StatusReportUpdate {
// Timestamp when the update was created (RFC 3339 format).
string created_at = 5;
+
+ // Per-component impacts this update set (empty for legacy reports).
+ repeated ComponentImpact component_impacts = 6;
}
// StatusReportSummary represents metadata for a status report (used in list responses).
diff --git a/packages/proto/gen/openapi.yaml b/packages/proto/gen/openapi.yaml
index 42c62ee79..64df79e74 100644
--- a/packages/proto/gen/openapi.yaml
+++ b/packages/proto/gen/openapi.yaml
@@ -3603,6 +3603,15 @@ components:
- "null"
title: notify
description: Whether to notify subscribers about this update (optional, defaults to false).
+ componentImpacts:
+ type: array
+ items:
+ $ref: '#/components/schemas/openstatus.status_report.v1.ComponentImpact'
+ title: component_impacts
+ description: |-
+ Per-component impacts this update sets (optional). Components named here
+ are added to the report's affected set; omitted components keep their
+ prior impact.
title: AddStatusReportUpdateRequest
additionalProperties: false
description: AddStatusReportUpdateRequest is the request to add a new update to a status report.
@@ -3616,6 +3625,20 @@ components:
title: AddStatusReportUpdateResponse
additionalProperties: false
description: AddStatusReportUpdateResponse is the response after adding an update to a status report.
+ openstatus.status_report.v1.ComponentImpact:
+ type: object
+ properties:
+ pageComponentId:
+ type: string
+ title: page_component_id
+ description: ID of the affected page component.
+ impact:
+ title: impact
+ description: Impact set for the component.
+ $ref: '#/components/schemas/openstatus.status_report.v1.PageComponentImpact'
+ title: ComponentImpact
+ additionalProperties: false
+ description: ComponentImpact pairs a page component with the impact an update set for it.
openstatus.status_report.v1.CreateStatusReportRequest:
type: object
properties:
@@ -3661,6 +3684,15 @@ components:
- "null"
title: notify
description: Whether to notify subscribers about this status report (optional, defaults to false).
+ componentImpacts:
+ type: array
+ items:
+ $ref: '#/components/schemas/openstatus.status_report.v1.ComponentImpact'
+ title: component_impacts
+ description: |-
+ Per-component impacts set by the initial update (optional). When provided,
+ the named components are added to the report's affected set. Omitting this
+ field creates a legacy report without impact tracking.
title: CreateStatusReportRequest
additionalProperties: false
description: CreateStatusReportRequest is the request to create a new status report.
@@ -3762,6 +3794,18 @@ components:
title: ListStatusReportsResponse
additionalProperties: false
description: ListStatusReportsResponse is the response containing status report summaries.
+ openstatus.status_report.v1.PageComponentImpact:
+ type: string
+ title: PageComponentImpact
+ enum:
+ - PAGE_COMPONENT_IMPACT_UNSPECIFIED
+ - PAGE_COMPONENT_IMPACT_OPERATIONAL
+ - PAGE_COMPONENT_IMPACT_DEGRADED_PERFORMANCE
+ - PAGE_COMPONENT_IMPACT_PARTIAL_OUTAGE
+ - PAGE_COMPONENT_IMPACT_MAJOR_OUTAGE
+ description: |-
+ PageComponentImpact is the per-component impact a status report update sets.
+ UNSPECIFIED means the caller doesn't speak impact (legacy) — it is NOT operational.
openstatus.status_report.v1.StatusReport:
type: object
properties:
@@ -3865,6 +3909,12 @@ components:
type: string
title: created_at
description: Timestamp when the update was created (RFC 3339 format).
+ componentImpacts:
+ type: array
+ items:
+ $ref: '#/components/schemas/openstatus.status_report.v1.ComponentImpact'
+ title: component_impacts
+ description: Per-component impacts this update set (empty for legacy reports).
title: StatusReportUpdate
additionalProperties: false
description: StatusReportUpdate represents a single update entry in a status report timeline.
diff --git a/packages/proto/gen/ts/openstatus/status_report/v1/service_pb.ts b/packages/proto/gen/ts/openstatus/status_report/v1/service_pb.ts
index 92df0ef84..fc02c3197 100644
--- a/packages/proto/gen/ts/openstatus/status_report/v1/service_pb.ts
+++ b/packages/proto/gen/ts/openstatus/status_report/v1/service_pb.ts
@@ -6,7 +6,7 @@ import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegen
import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2";
import { file_buf_validate_validate } from "../../../buf/validate/validate_pb.ts";
import { file_gnostic_openapi_v3_annotations } from "../../../gnostic/openapi/v3/annotations_pb.ts";
-import type { StatusReport, StatusReportStatus, StatusReportSummary } from "./status_report_pb.ts";
+import type { ComponentImpact, StatusReport, StatusReportStatus, StatusReportSummary } from "./status_report_pb.ts";
import { file_openstatus_status_report_v1_status_report } from "./status_report_pb.ts";
import type { Message } from "@bufbuild/protobuf";
@@ -14,7 +14,7 @@ import type { Message } from "@bufbuild/protobuf";
* Describes the file openstatus/status_report/v1/service.proto.
*/
export const file_openstatus_status_report_v1_service: GenFile = /*@__PURE__*/
- fileDesc("CilvcGVuc3RhdHVzL3N0YXR1c19yZXBvcnQvdjEvc2VydmljZS5wcm90bxIbb3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxIsUDChlDcmVhdGVTdGF0dXNSZXBvcnRSZXF1ZXN0EjoKBXRpdGxlGAEgASgJQiu6RyE6HxIdQVBJIERlZ3JhZGF0aW9uIEludmVzdGlnYXRpb266SARyAhABEkkKBnN0YXR1cxgCIAEoDjIvLm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5TdGF0dXNSZXBvcnRTdGF0dXNCCLpIBYIBAhABElUKB21lc3NhZ2UYAyABKAlCRLpHOjo4EjZXZSBhcmUgaW52ZXN0aWdhdGluZyByZXBvcnRzIG9mIGluY3JlYXNlZCBBUEkgbGF0ZW5jeS66SARyAhABEnQKBGRhdGUYBCABKAlCZrpHGDoWEhQyMDI0LTAzLTE1VDEwOjMwOjAwWrpISHJGMkReXGR7NH0tXGR7Mn0tXGR7Mn1UXGR7Mn06XGR7Mn06XGR7Mn0oXC5cZHsxLDl9KT8oWnxbKy1dXGR7Mn06XGR7Mn0pJBIYCgdwYWdlX2lkGAUgASgJQge6SARyAhABEhoKEnBhZ2VfY29tcG9uZW50X2lkcxgGIAMoCRITCgZub3RpZnkYByABKAhIAIgBAUIJCgdfbm90aWZ5Il4KGkNyZWF0ZVN0YXR1c1JlcG9ydFJlc3BvbnNlEkAKDXN0YXR1c19yZXBvcnQYASABKAsyKS5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuU3RhdHVzUmVwb3J0Ii0KFkdldFN0YXR1c1JlcG9ydFJlcXVlc3QSEwoCaWQYASABKAlCB7pIBHICEAEiWwoXR2V0U3RhdHVzUmVwb3J0UmVzcG9uc2USQAoNc3RhdHVzX3JlcG9ydBgBIAEoCzIpLm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5TdGF0dXNSZXBvcnQirwEKGExpc3RTdGF0dXNSZXBvcnRzUmVxdWVzdBIdCgVsaW1pdBgBIAEoBUIJukgGGgQYZCgBSACIAQESHAoGb2Zmc2V0GAIgASgFQge6SAQaAigASAGIAQESQQoIc3RhdHVzZXMYAyADKA4yLy5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuU3RhdHVzUmVwb3J0U3RhdHVzQggKBl9saW1pdEIJCgdfb2Zmc2V0InkKGUxpc3RTdGF0dXNSZXBvcnRzUmVzcG9uc2USSAoOc3RhdHVzX3JlcG9ydHMYASADKAsyMC5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuU3RhdHVzUmVwb3J0U3VtbWFyeRISCgp0b3RhbF9zaXplGAIgASgFIrABChlVcGRhdGVTdGF0dXNSZXBvcnRSZXF1ZXN0EhMKAmlkGAEgASgJQge6SARyAhABEhIKBXRpdGxlGAIgASgJSACIAQESGgoScGFnZV9jb21wb25lbnRfaWRzGAMgAygJEiYKGXVwZGF0ZV9wYWdlX2NvbXBvbmVudF9pZHMYBCABKAhIAYgBAUIICgZfdGl0bGVCHAoaX3VwZGF0ZV9wYWdlX2NvbXBvbmVudF9pZHMiXgoaVXBkYXRlU3RhdHVzUmVwb3J0UmVzcG9uc2USQAoNc3RhdHVzX3JlcG9ydBgBIAEoCzIpLm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5TdGF0dXNSZXBvcnQiMAoZRGVsZXRlU3RhdHVzUmVwb3J0UmVxdWVzdBITCgJpZBgBIAEoCUIHukgEcgIQASItChpEZWxldGVTdGF0dXNSZXBvcnRSZXNwb25zZRIPCgdzdWNjZXNzGAEgASgIIq8CChxBZGRTdGF0dXNSZXBvcnRVcGRhdGVSZXF1ZXN0EiEKEHN0YXR1c19yZXBvcnRfaWQYASABKAlCB7pIBHICEAESSQoGc3RhdHVzGAIgASgOMi8ub3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxLlN0YXR1c1JlcG9ydFN0YXR1c0IIukgFggECEAESGAoHbWVzc2FnZRgDIAEoCUIHukgEcgIQARJeCgRkYXRlGAQgASgJQku6SEhyRjJEXlxkezR9LVxkezJ9LVxkezJ9VFxkezJ9OlxkezJ9OlxkezJ9KFwuXGR7MSw5fSk/KFp8WystXVxkezJ9OlxkezJ9KSRIAIgBARITCgZub3RpZnkYBSABKAhIAYgBAUIHCgVfZGF0ZUIJCgdfbm90aWZ5ImEKHUFkZFN0YXR1c1JlcG9ydFVwZGF0ZVJlc3BvbnNlEkAKDXN0YXR1c19yZXBvcnQYASABKAsyKS5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuU3RhdHVzUmVwb3J0Mr8LChNTdGF0dXNSZXBvcnRTZXJ2aWNlEs4DChJDcmVhdGVTdGF0dXNSZXBvcnQSNi5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuQ3JlYXRlU3RhdHVzUmVwb3J0UmVxdWVzdBo3Lm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5DcmVhdGVTdGF0dXNSZXBvcnRSZXNwb25zZSLGArpHwgIavwJDcmVhdGVzIGEgbmV3IHN0YXR1cyByZXBvcnQgd2l0aCBhbiBpbml0aWFsIHVwZGF0ZSBlbnRyeS4gVGhlIHJlcG9ydCBpcyBhc3NvY2lhdGVkIHdpdGggYSBzdGF0dXMgcGFnZSBhbmQgb3B0aW9uYWxseSBzcGVjaWZpYyBwYWdlIGNvbXBvbmVudHMuIEFuIGluaXRpYWwgU3RhdHVzUmVwb3J0VXBkYXRlIGlzIGNyZWF0ZWQgYXV0b21hdGljYWxseSB3aXRoIHRoZSBwcm92aWRlZCBzdGF0dXMsIG1lc3NhZ2UsIGFuZCBkYXRlLiBJZiBub3RpZnkgaXMgdHJ1ZSwgc3Vic2NyaWJlcnMgb2YgdGhlIGFzc29jaWF0ZWQgcGFnZSBhcmUgbm90aWZpZWQgYnkgZW1haWwuEoEBCg9HZXRTdGF0dXNSZXBvcnQSMy5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuR2V0U3RhdHVzUmVwb3J0UmVxdWVzdBo0Lm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5HZXRTdGF0dXNSZXBvcnRSZXNwb25zZSIDkAIBEocBChFMaXN0U3RhdHVzUmVwb3J0cxI1Lm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5MaXN0U3RhdHVzUmVwb3J0c1JlcXVlc3QaNi5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuTGlzdFN0YXR1c1JlcG9ydHNSZXNwb25zZSIDkAIBEoUBChJVcGRhdGVTdGF0dXNSZXBvcnQSNi5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuVXBkYXRlU3RhdHVzUmVwb3J0UmVxdWVzdBo3Lm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5VcGRhdGVTdGF0dXNSZXBvcnRSZXNwb25zZRKFAQoSRGVsZXRlU3RhdHVzUmVwb3J0EjYub3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxLkRlbGV0ZVN0YXR1c1JlcG9ydFJlcXVlc3QaNy5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuRGVsZXRlU3RhdHVzUmVwb3J0UmVzcG9uc2USuAMKFUFkZFN0YXR1c1JlcG9ydFVwZGF0ZRI5Lm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5BZGRTdGF0dXNSZXBvcnRVcGRhdGVSZXF1ZXN0Gjoub3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxLkFkZFN0YXR1c1JlcG9ydFVwZGF0ZVJlc3BvbnNlIqcCukejAhqgAkFkZHMgYSBuZXcgdXBkYXRlIGVudHJ5IHRvIGFuIGV4aXN0aW5nIHN0YXR1cyByZXBvcnQgYW5kIHRyYW5zaXRpb25zIHRoZSByZXBvcnQgdG8gdGhlIHNwZWNpZmllZCBzdGF0dXMuIFN0YXR1cyByZXBvcnRzIGZvbGxvdyBhIGxpZmVjeWNsZTogaW52ZXN0aWdhdGluZyAtPiBpZGVudGlmaWVkIC0+IG1vbml0b3JpbmcgLT4gcmVzb2x2ZWQuIElmIG5vdGlmeSBpcyB0cnVlLCBzdWJzY3JpYmVycyBvZiB0aGUgYXNzb2NpYXRlZCBwYWdlIGFyZSBub3RpZmllZCBieSBlbWFpbCBhYm91dCB0aGUgdXBkYXRlLkJeWlxnaXRodWIuY29tL29wZW5zdGF0dXNocS9vcGVuc3RhdHVzL3BhY2thZ2VzL3Byb3RvL29wZW5zdGF0dXMvc3RhdHVzX3JlcG9ydC92MTtzdGF0dXNyZXBvcnR2MWIGcHJvdG8z", [file_buf_validate_validate, file_gnostic_openapi_v3_annotations, file_openstatus_status_report_v1_status_report]);
+ fileDesc("CilvcGVuc3RhdHVzL3N0YXR1c19yZXBvcnQvdjEvc2VydmljZS5wcm90bxIbb3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxIo4EChlDcmVhdGVTdGF0dXNSZXBvcnRSZXF1ZXN0EjoKBXRpdGxlGAEgASgJQiu6RyE6HxIdQVBJIERlZ3JhZGF0aW9uIEludmVzdGlnYXRpb266SARyAhABEkkKBnN0YXR1cxgCIAEoDjIvLm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5TdGF0dXNSZXBvcnRTdGF0dXNCCLpIBYIBAhABElUKB21lc3NhZ2UYAyABKAlCRLpHOjo4EjZXZSBhcmUgaW52ZXN0aWdhdGluZyByZXBvcnRzIG9mIGluY3JlYXNlZCBBUEkgbGF0ZW5jeS66SARyAhABEnQKBGRhdGUYBCABKAlCZrpHGDoWEhQyMDI0LTAzLTE1VDEwOjMwOjAwWrpISHJGMkReXGR7NH0tXGR7Mn0tXGR7Mn1UXGR7Mn06XGR7Mn06XGR7Mn0oXC5cZHsxLDl9KT8oWnxbKy1dXGR7Mn06XGR7Mn0pJBIYCgdwYWdlX2lkGAUgASgJQge6SARyAhABEhoKEnBhZ2VfY29tcG9uZW50X2lkcxgGIAMoCRITCgZub3RpZnkYByABKAhIAIgBARJHChFjb21wb25lbnRfaW1wYWN0cxgIIAMoCzIsLm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5Db21wb25lbnRJbXBhY3RCCQoHX25vdGlmeSJeChpDcmVhdGVTdGF0dXNSZXBvcnRSZXNwb25zZRJACg1zdGF0dXNfcmVwb3J0GAEgASgLMikub3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxLlN0YXR1c1JlcG9ydCItChZHZXRTdGF0dXNSZXBvcnRSZXF1ZXN0EhMKAmlkGAEgASgJQge6SARyAhABIlsKF0dldFN0YXR1c1JlcG9ydFJlc3BvbnNlEkAKDXN0YXR1c19yZXBvcnQYASABKAsyKS5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuU3RhdHVzUmVwb3J0Iq8BChhMaXN0U3RhdHVzUmVwb3J0c1JlcXVlc3QSHQoFbGltaXQYASABKAVCCbpIBhoEGGQoAUgAiAEBEhwKBm9mZnNldBgCIAEoBUIHukgEGgIoAEgBiAEBEkEKCHN0YXR1c2VzGAMgAygOMi8ub3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxLlN0YXR1c1JlcG9ydFN0YXR1c0IICgZfbGltaXRCCQoHX29mZnNldCJ5ChlMaXN0U3RhdHVzUmVwb3J0c1Jlc3BvbnNlEkgKDnN0YXR1c19yZXBvcnRzGAEgAygLMjAub3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxLlN0YXR1c1JlcG9ydFN1bW1hcnkSEgoKdG90YWxfc2l6ZRgCIAEoBSKwAQoZVXBkYXRlU3RhdHVzUmVwb3J0UmVxdWVzdBITCgJpZBgBIAEoCUIHukgEcgIQARISCgV0aXRsZRgCIAEoCUgAiAEBEhoKEnBhZ2VfY29tcG9uZW50X2lkcxgDIAMoCRImChl1cGRhdGVfcGFnZV9jb21wb25lbnRfaWRzGAQgASgISAGIAQFCCAoGX3RpdGxlQhwKGl91cGRhdGVfcGFnZV9jb21wb25lbnRfaWRzIl4KGlVwZGF0ZVN0YXR1c1JlcG9ydFJlc3BvbnNlEkAKDXN0YXR1c19yZXBvcnQYASABKAsyKS5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuU3RhdHVzUmVwb3J0IjAKGURlbGV0ZVN0YXR1c1JlcG9ydFJlcXVlc3QSEwoCaWQYASABKAlCB7pIBHICEAEiLQoaRGVsZXRlU3RhdHVzUmVwb3J0UmVzcG9uc2USDwoHc3VjY2VzcxgBIAEoCCL4AgocQWRkU3RhdHVzUmVwb3J0VXBkYXRlUmVxdWVzdBIhChBzdGF0dXNfcmVwb3J0X2lkGAEgASgJQge6SARyAhABEkkKBnN0YXR1cxgCIAEoDjIvLm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5TdGF0dXNSZXBvcnRTdGF0dXNCCLpIBYIBAhABEhgKB21lc3NhZ2UYAyABKAlCB7pIBHICEAESXgoEZGF0ZRgEIAEoCUJLukhIckYyRF5cZHs0fS1cZHsyfS1cZHsyfVRcZHsyfTpcZHsyfTpcZHsyfShcLlxkezEsOX0pPyhafFsrLV1cZHsyfTpcZHsyfSkkSACIAQESEwoGbm90aWZ5GAUgASgISAGIAQESRwoRY29tcG9uZW50X2ltcGFjdHMYBiADKAsyLC5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuQ29tcG9uZW50SW1wYWN0QgcKBV9kYXRlQgkKB19ub3RpZnkiYQodQWRkU3RhdHVzUmVwb3J0VXBkYXRlUmVzcG9uc2USQAoNc3RhdHVzX3JlcG9ydBgBIAEoCzIpLm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5TdGF0dXNSZXBvcnQyvwsKE1N0YXR1c1JlcG9ydFNlcnZpY2USzgMKEkNyZWF0ZVN0YXR1c1JlcG9ydBI2Lm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5DcmVhdGVTdGF0dXNSZXBvcnRSZXF1ZXN0Gjcub3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxLkNyZWF0ZVN0YXR1c1JlcG9ydFJlc3BvbnNlIsYCukfCAhq/AkNyZWF0ZXMgYSBuZXcgc3RhdHVzIHJlcG9ydCB3aXRoIGFuIGluaXRpYWwgdXBkYXRlIGVudHJ5LiBUaGUgcmVwb3J0IGlzIGFzc29jaWF0ZWQgd2l0aCBhIHN0YXR1cyBwYWdlIGFuZCBvcHRpb25hbGx5IHNwZWNpZmljIHBhZ2UgY29tcG9uZW50cy4gQW4gaW5pdGlhbCBTdGF0dXNSZXBvcnRVcGRhdGUgaXMgY3JlYXRlZCBhdXRvbWF0aWNhbGx5IHdpdGggdGhlIHByb3ZpZGVkIHN0YXR1cywgbWVzc2FnZSwgYW5kIGRhdGUuIElmIG5vdGlmeSBpcyB0cnVlLCBzdWJzY3JpYmVycyBvZiB0aGUgYXNzb2NpYXRlZCBwYWdlIGFyZSBub3RpZmllZCBieSBlbWFpbC4SgQEKD0dldFN0YXR1c1JlcG9ydBIzLm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5HZXRTdGF0dXNSZXBvcnRSZXF1ZXN0GjQub3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxLkdldFN0YXR1c1JlcG9ydFJlc3BvbnNlIgOQAgEShwEKEUxpc3RTdGF0dXNSZXBvcnRzEjUub3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxLkxpc3RTdGF0dXNSZXBvcnRzUmVxdWVzdBo2Lm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5MaXN0U3RhdHVzUmVwb3J0c1Jlc3BvbnNlIgOQAgEShQEKElVwZGF0ZVN0YXR1c1JlcG9ydBI2Lm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5VcGRhdGVTdGF0dXNSZXBvcnRSZXF1ZXN0Gjcub3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxLlVwZGF0ZVN0YXR1c1JlcG9ydFJlc3BvbnNlEoUBChJEZWxldGVTdGF0dXNSZXBvcnQSNi5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuRGVsZXRlU3RhdHVzUmVwb3J0UmVxdWVzdBo3Lm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5EZWxldGVTdGF0dXNSZXBvcnRSZXNwb25zZRK4AwoVQWRkU3RhdHVzUmVwb3J0VXBkYXRlEjkub3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxLkFkZFN0YXR1c1JlcG9ydFVwZGF0ZVJlcXVlc3QaOi5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuQWRkU3RhdHVzUmVwb3J0VXBkYXRlUmVzcG9uc2UipwK6R6MCGqACQWRkcyBhIG5ldyB1cGRhdGUgZW50cnkgdG8gYW4gZXhpc3Rpbmcgc3RhdHVzIHJlcG9ydCBhbmQgdHJhbnNpdGlvbnMgdGhlIHJlcG9ydCB0byB0aGUgc3BlY2lmaWVkIHN0YXR1cy4gU3RhdHVzIHJlcG9ydHMgZm9sbG93IGEgbGlmZWN5Y2xlOiBpbnZlc3RpZ2F0aW5nIC0+IGlkZW50aWZpZWQgLT4gbW9uaXRvcmluZyAtPiByZXNvbHZlZC4gSWYgbm90aWZ5IGlzIHRydWUsIHN1YnNjcmliZXJzIG9mIHRoZSBhc3NvY2lhdGVkIHBhZ2UgYXJlIG5vdGlmaWVkIGJ5IGVtYWlsIGFib3V0IHRoZSB1cGRhdGUuQl5aXGdpdGh1Yi5jb20vb3BlbnN0YXR1c2hxL29wZW5zdGF0dXMvcGFja2FnZXMvcHJvdG8vb3BlbnN0YXR1cy9zdGF0dXNfcmVwb3J0L3YxO3N0YXR1c3JlcG9ydHYxYgZwcm90bzM", [file_buf_validate_validate, file_gnostic_openapi_v3_annotations, file_openstatus_status_report_v1_status_report]);
/**
* CreateStatusReportRequest is the request to create a new status report.
@@ -70,6 +70,15 @@ export type CreateStatusReportRequest = Message<"openstatus.status_report.v1.Cre
* @generated from field: optional bool notify = 7;
*/
notify?: boolean | undefined;
+
+ /**
+ * Per-component impacts set by the initial update (optional). When provided,
+ * the named components are added to the report's affected set. Omitting this
+ * field creates a legacy report without impact tracking.
+ *
+ * @generated from field: repeated openstatus.status_report.v1.ComponentImpact component_impacts = 8;
+ */
+ componentImpacts: ComponentImpact[];
};
/**
@@ -352,6 +361,15 @@ export type AddStatusReportUpdateRequest = Message<"openstatus.status_report.v1.
* @generated from field: optional bool notify = 5;
*/
notify?: boolean | undefined;
+
+ /**
+ * Per-component impacts this update sets (optional). Components named here
+ * are added to the report's affected set; omitted components keep their
+ * prior impact.
+ *
+ * @generated from field: repeated openstatus.status_report.v1.ComponentImpact component_impacts = 6;
+ */
+ componentImpacts: ComponentImpact[];
};
/**
diff --git a/packages/proto/gen/ts/openstatus/status_report/v1/status_report_pb.ts b/packages/proto/gen/ts/openstatus/status_report/v1/status_report_pb.ts
index 9919c6333..60d488c9c 100644
--- a/packages/proto/gen/ts/openstatus/status_report/v1/status_report_pb.ts
+++ b/packages/proto/gen/ts/openstatus/status_report/v1/status_report_pb.ts
@@ -10,7 +10,35 @@ import type { Message } from "@bufbuild/protobuf";
* Describes the file openstatus/status_report/v1/status_report.proto.
*/
export const file_openstatus_status_report_v1_status_report: GenFile = /*@__PURE__*/
- fileDesc("Ci9vcGVuc3RhdHVzL3N0YXR1c19yZXBvcnQvdjEvc3RhdHVzX3JlcG9ydC5wcm90bxIbb3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxIpQBChJTdGF0dXNSZXBvcnRVcGRhdGUSCgoCaWQYASABKAkSPwoGc3RhdHVzGAIgASgOMi8ub3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxLlN0YXR1c1JlcG9ydFN0YXR1cxIMCgRkYXRlGAMgASgJEg8KB21lc3NhZ2UYBCABKAkSEgoKY3JlYXRlZF9hdBgFIAEoCSK1AQoTU3RhdHVzUmVwb3J0U3VtbWFyeRIKCgJpZBgBIAEoCRI/CgZzdGF0dXMYAiABKA4yLy5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuU3RhdHVzUmVwb3J0U3RhdHVzEg0KBXRpdGxlGAMgASgJEhoKEnBhZ2VfY29tcG9uZW50X2lkcxgEIAMoCRISCgpjcmVhdGVkX2F0GAUgASgJEhIKCnVwZGF0ZWRfYXQYBiABKAki8AEKDFN0YXR1c1JlcG9ydBIKCgJpZBgBIAEoCRI/CgZzdGF0dXMYAiABKA4yLy5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuU3RhdHVzUmVwb3J0U3RhdHVzEg0KBXRpdGxlGAMgASgJEhoKEnBhZ2VfY29tcG9uZW50X2lkcxgEIAMoCRJACgd1cGRhdGVzGAUgAygLMi8ub3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxLlN0YXR1c1JlcG9ydFVwZGF0ZRISCgpjcmVhdGVkX2F0GAYgASgJEhIKCnVwZGF0ZWRfYXQYByABKAkqzwEKElN0YXR1c1JlcG9ydFN0YXR1cxIkCiBTVEFUVVNfUkVQT1JUX1NUQVRVU19VTlNQRUNJRklFRBAAEiYKIlNUQVRVU19SRVBPUlRfU1RBVFVTX0lOVkVTVElHQVRJTkcQARIjCh9TVEFUVVNfUkVQT1JUX1NUQVRVU19JREVOVElGSUVEEAISIwofU1RBVFVTX1JFUE9SVF9TVEFUVVNfTU9OSVRPUklORxADEiEKHVNUQVRVU19SRVBPUlRfU1RBVFVTX1JFU09MVkVEEARCXlpcZ2l0aHViLmNvbS9vcGVuc3RhdHVzaHEvb3BlbnN0YXR1cy9wYWNrYWdlcy9wcm90by9vcGVuc3RhdHVzL3N0YXR1c19yZXBvcnQvdjE7c3RhdHVzcmVwb3J0djFiBnByb3RvMw");
+ fileDesc("Ci9vcGVuc3RhdHVzL3N0YXR1c19yZXBvcnQvdjEvc3RhdHVzX3JlcG9ydC5wcm90bxIbb3BlbnN0YXR1cy5zdGF0dXNfcmVwb3J0LnYxIm4KD0NvbXBvbmVudEltcGFjdBIZChFwYWdlX2NvbXBvbmVudF9pZBgBIAEoCRJACgZpbXBhY3QYAiABKA4yMC5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuUGFnZUNvbXBvbmVudEltcGFjdCLdAQoSU3RhdHVzUmVwb3J0VXBkYXRlEgoKAmlkGAEgASgJEj8KBnN0YXR1cxgCIAEoDjIvLm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5TdGF0dXNSZXBvcnRTdGF0dXMSDAoEZGF0ZRgDIAEoCRIPCgdtZXNzYWdlGAQgASgJEhIKCmNyZWF0ZWRfYXQYBSABKAkSRwoRY29tcG9uZW50X2ltcGFjdHMYBiADKAsyLC5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuQ29tcG9uZW50SW1wYWN0IrUBChNTdGF0dXNSZXBvcnRTdW1tYXJ5EgoKAmlkGAEgASgJEj8KBnN0YXR1cxgCIAEoDjIvLm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5TdGF0dXNSZXBvcnRTdGF0dXMSDQoFdGl0bGUYAyABKAkSGgoScGFnZV9jb21wb25lbnRfaWRzGAQgAygJEhIKCmNyZWF0ZWRfYXQYBSABKAkSEgoKdXBkYXRlZF9hdBgGIAEoCSLwAQoMU3RhdHVzUmVwb3J0EgoKAmlkGAEgASgJEj8KBnN0YXR1cxgCIAEoDjIvLm9wZW5zdGF0dXMuc3RhdHVzX3JlcG9ydC52MS5TdGF0dXNSZXBvcnRTdGF0dXMSDQoFdGl0bGUYAyABKAkSGgoScGFnZV9jb21wb25lbnRfaWRzGAQgAygJEkAKB3VwZGF0ZXMYBSADKAsyLy5vcGVuc3RhdHVzLnN0YXR1c19yZXBvcnQudjEuU3RhdHVzUmVwb3J0VXBkYXRlEhIKCmNyZWF0ZWRfYXQYBiABKAkSEgoKdXBkYXRlZF9hdBgHIAEoCSrPAQoSU3RhdHVzUmVwb3J0U3RhdHVzEiQKIFNUQVRVU19SRVBPUlRfU1RBVFVTX1VOU1BFQ0lGSUVEEAASJgoiU1RBVFVTX1JFUE9SVF9TVEFUVVNfSU5WRVNUSUdBVElORxABEiMKH1NUQVRVU19SRVBPUlRfU1RBVFVTX0lERU5USUZJRUQQAhIjCh9TVEFUVVNfUkVQT1JUX1NUQVRVU19NT05JVE9SSU5HEAMSIQodU1RBVFVTX1JFUE9SVF9TVEFUVVNfUkVTT0xWRUQQBCrlAQoTUGFnZUNvbXBvbmVudEltcGFjdBIlCiFQQUdFX0NPTVBPTkVOVF9JTVBBQ1RfVU5TUEVDSUZJRUQQABIlCiFQQUdFX0NPTVBPTkVOVF9JTVBBQ1RfT1BFUkFUSU9OQUwQARIuCipQQUdFX0NPTVBPTkVOVF9JTVBBQ1RfREVHUkFERURfUEVSRk9STUFOQ0UQAhIoCiRQQUdFX0NPTVBPTkVOVF9JTVBBQ1RfUEFSVElBTF9PVVRBR0UQAxImCiJQQUdFX0NPTVBPTkVOVF9JTVBBQ1RfTUFKT1JfT1VUQUdFEARCXlpcZ2l0aHViLmNvbS9vcGVuc3RhdHVzaHEvb3BlbnN0YXR1cy9wYWNrYWdlcy9wcm90by9vcGVuc3RhdHVzL3N0YXR1c19yZXBvcnQvdjE7c3RhdHVzcmVwb3J0djFiBnByb3RvMw");
+
+/**
+ * ComponentImpact pairs a page component with the impact an update set for it.
+ *
+ * @generated from message openstatus.status_report.v1.ComponentImpact
+ */
+export type ComponentImpact = Message<"openstatus.status_report.v1.ComponentImpact"> & {
+ /**
+ * ID of the affected page component.
+ *
+ * @generated from field: string page_component_id = 1;
+ */
+ pageComponentId: string;
+
+ /**
+ * Impact set for the component.
+ *
+ * @generated from field: openstatus.status_report.v1.PageComponentImpact impact = 2;
+ */
+ impact: PageComponentImpact;
+};
+
+/**
+ * Describes the message openstatus.status_report.v1.ComponentImpact.
+ * Use `create(ComponentImpactSchema)` to create a new message.
+ */
+export const ComponentImpactSchema: GenMessage<ComponentImpact> = /*@__PURE__*/
+ messageDesc(file_openstatus_status_report_v1_status_report, 0);
/**
* StatusReportUpdate represents a single update entry in a status report timeline.
@@ -52,6 +80,13 @@ export type StatusReportUpdate = Message<"openstatus.status_report.v1.StatusRepo
* @generated from field: string created_at = 5;
*/
createdAt: string;
+
+ /**
+ * Per-component impacts this update set (empty for legacy reports).
+ *
+ * @generated from field: repeated openstatus.status_report.v1.ComponentImpact component_impacts = 6;
+ */
+ componentImpacts: ComponentImpact[];
};
/**
@@ -59,7 +94,7 @@ export type StatusReportUpdate = Message<"openstatus.status_report.v1.StatusRepo
* Use `create(StatusReportUpdateSchema)` to create a new message.
*/
export const StatusReportUpdateSchema: GenMessage<StatusReportUpdate> = /*@__PURE__*/
- messageDesc(file_openstatus_status_report_v1_status_report, 0);
+ messageDesc(file_openstatus_status_report_v1_status_report, 1);
/**
* StatusReportSummary represents metadata for a status report (used in list responses).
@@ -115,7 +150,7 @@ export type StatusReportSummary = Message<"openstatus.status_report.v1.StatusRep
* Use `create(StatusReportSummarySchema)` to create a new message.
*/
export const StatusReportSummarySchema: GenMessage<StatusReportSummary> = /*@__PURE__*/
- messageDesc(file_openstatus_status_report_v1_status_report, 1);
+ messageDesc(file_openstatus_status_report_v1_status_report, 2);
/**
* StatusReport represents an incident or maintenance report with full details.
@@ -178,7 +213,7 @@ export type StatusReport = Message<"openstatus.status_report.v1.StatusReport"> &
* Use `create(StatusReportSchema)` to create a new message.
*/
export const StatusReportSchema: GenMessage<StatusReport> = /*@__PURE__*/
- messageDesc(file_openstatus_status_report_v1_status_report, 2);
+ messageDesc(file_openstatus_status_report_v1_status_report, 3);
/**
* StatusReportStatus represents the current state of a status report.
@@ -218,3 +253,42 @@ export enum StatusReportStatus {
export const StatusReportStatusSchema: GenEnum<StatusReportStatus> = /*@__PURE__*/
enumDesc(file_openstatus_status_report_v1_status_report, 0);
+/**
+ * PageComponentImpact is the per-component impact a status report update sets.
+ * UNSPECIFIED means the caller doesn't speak impact (legacy) — it is NOT operational.
+ *
+ * @generated from enum openstatus.status_report.v1.PageComponentImpact
+ */
+export enum PageComponentImpact {
+ /**
+ * @generated from enum value: PAGE_COMPONENT_IMPACT_UNSPECIFIED = 0;
+ */
+ UNSPECIFIED = 0,
+
+ /**
+ * @generated from enum value: PAGE_COMPONENT_IMPACT_OPERATIONAL = 1;
+ */
+ OPERATIONAL = 1,
+
+ /**
+ * @generated from enum value: PAGE_COMPONENT_IMPACT_DEGRADED_PERFORMANCE = 2;
+ */
+ DEGRADED_PERFORMANCE = 2,
+
+ /**
+ * @generated from enum value: PAGE_COMPONENT_IMPACT_PARTIAL_OUTAGE = 3;
+ */
+ PARTIAL_OUTAGE = 3,
+
+ /**
+ * @generated from enum value: PAGE_COMPONENT_IMPACT_MAJOR_OUTAGE = 4;
+ */
+ MAJOR_OUTAGE = 4,
+}
+
+/**
+ * Describes the enum openstatus.status_report.v1.PageComponentImpact.
+ */
+export const PageComponentImpactSchema: GenEnum<PageComponentImpact> = /*@__PURE__*/
+ enumDesc(file_openstatus_status_report_v1_status_report, 1);
+
diff --git a/packages/services/package.json b/packages/services/package.json
index 33ea801c9..320e269c0 100644
--- a/packages/services/package.json
+++ b/packages/services/package.json
@@ -13,6 +13,10 @@
"import": "./src/status-report/index.ts",
"types": "./src/status-report/index.ts"
},
+ "./status-report/utils": {
+ "import": "./src/status-report/utils.ts",
+ "types": "./src/status-report/utils.ts"
+ },
"./maintenance": {
"import": "./src/maintenance/index.ts",
"types": "./src/maintenance/index.ts"
diff --git a/packages/services/src/agent-tools/__tests__/status-report-impacts.test.ts b/packages/services/src/agent-tools/__tests__/status-report-impacts.test.ts
new file mode 100644
index 000000000..890a6b980
--- /dev/null
+++ b/packages/services/src/agent-tools/__tests__/status-report-impacts.test.ts
@@ -0,0 +1,168 @@
+import { beforeAll, describe, expect, test } from "bun:test";
+
+import { page, pageComponent } from "@openstatus/db/src/schema";
+
+import { SEEDED_WORKSPACE_TEAM_ID } from "../../../test/fixtures";
+import {
+ loadSeededWorkspace,
+ makeUserCtx,
+ withTestTransaction,
+} from "../../../test/helpers";
+import type { DB, ServiceContext } from "../../context";
+import { getCurrentImpactsForReport } from "../../status-report/internal";
+import { agentTools } from "../index";
+
+const TEST_PREFIX = "agent-tools-impacts-test";
+
+let teamCtx: ServiceContext;
+
+beforeAll(async () => {
+ const team = await loadSeededWorkspace(SEEDED_WORKSPACE_TEAM_ID);
+ teamCtx = makeUserCtx(team, { userId: 1 });
+});
+
+async function seedPageWithComponents(tx: DB, workspaceId: number) {
+ const pageRow = await tx
+ .insert(page)
+ .values({
+ workspaceId,
+ title: `${TEST_PREFIX}-page`,
+ description: "test page",
+ slug: `${TEST_PREFIX}-page-slug`,
+ customDomain: "",
+ })
+ .returning()
+ .get();
+ const componentA = await tx
+ .insert(pageComponent)
+ .values({
+ workspaceId,
+ pageId: pageRow.id,
+ name: `${TEST_PREFIX}-component-a`,
+ type: "static",
+ })
+ .returning()
+ .get();
+ const componentB = await tx
+ .insert(pageComponent)
+ .values({
+ workspaceId,
+ pageId: pageRow.id,
+ name: `${TEST_PREFIX}-component-b`,
+ type: "static",
+ })
+ .returning()
+ .get();
+ return {
+ pageId: pageRow.id,
+ componentA: componentA.id,
+ componentB: componentB.id,
+ };
+}
+
+describe("status-report agent tools: componentImpacts round-trip", () => {
+ test("create_status_report writes impact rows and unions membership", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+ const { pageId, componentA, componentB } = await seedPageWithComponents(
+ tx,
+ ctx.workspace.id,
+ );
+
+ const tool = agentTools.create_status_report;
+ const input = tool.inputSchema.parse({
+ title: `${TEST_PREFIX}-create`,
+ status: "investigating",
+ message: "looking into it",
+ pageId,
+ // componentB appears only via impacts — create must union it in.
+ pageComponentIds: [componentA],
+ componentImpacts: [
+ { pageComponentId: componentA, impact: "major_outage" },
+ { pageComponentId: componentB, impact: "degraded_performance" },
+ ],
+ notify: false,
+ });
+ const out = await tool.run({ ctx, input });
+ expect(tool.outputSchema.safeParse(out).success).toBe(true);
+
+ const impacts = await getCurrentImpactsForReport(tx, out.statusReport.id);
+ expect(impacts.get(componentA)).toBe("major_outage");
+ expect(impacts.get(componentB)).toBe("degraded_performance");
+ });
+ });
+
+ test("add_status_report_update changes impact; resolve clears the rest to operational", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+ const { pageId, componentA, componentB } = await seedPageWithComponents(
+ tx,
+ ctx.workspace.id,
+ );
+
+ const created = await agentTools.create_status_report.run({
+ ctx,
+ input: agentTools.create_status_report.inputSchema.parse({
+ title: `${TEST_PREFIX}-lifecycle`,
+ status: "investigating",
+ message: "down",
+ pageId,
+ pageComponentIds: [],
+ componentImpacts: [
+ { pageComponentId: componentA, impact: "major_outage" },
+ { pageComponentId: componentB, impact: "partial_outage" },
+ ],
+ notify: false,
+ }),
+ });
+ const reportId = created.statusReport.id;
+
+ // Only componentA is named — componentB must keep its prior impact.
+ await agentTools.add_status_report_update.run({
+ ctx,
+ input: agentTools.add_status_report_update.inputSchema.parse({
+ statusReportId: reportId,
+ status: "monitoring",
+ message: "recovering",
+ componentImpacts: [
+ { pageComponentId: componentA, impact: "degraded_performance" },
+ ],
+ notify: false,
+ }),
+ });
+ const midway = await getCurrentImpactsForReport(tx, reportId);
+ expect(midway.get(componentA)).toBe("degraded_performance");
+ expect(midway.get(componentB)).toBe("partial_outage");
+
+ const resolved = await agentTools.resolve_status_report.run({
+ ctx,
+ input: agentTools.resolve_status_report.inputSchema.parse({
+ statusReportId: reportId,
+ message: "all good again",
+ notify: false,
+ }),
+ });
+ expect(resolved.statusReportUpdateId).toBeGreaterThan(0);
+
+ const final = await getCurrentImpactsForReport(tx, reportId);
+ expect(final.get(componentA)).toBe("operational");
+ expect(final.get(componentB)).toBe("operational");
+ });
+ });
+
+ test("input schema rejects duplicate pageComponentId in componentImpacts", () => {
+ const result = agentTools.create_status_report.inputSchema.safeParse({
+ title: "dup",
+ status: "investigating",
+ message: "msg",
+ pageId: 1,
+ pageComponentIds: [],
+ componentImpacts: [
+ { pageComponentId: 1, impact: "major_outage" },
+ { pageComponentId: 1, impact: "operational" },
+ ],
+ notify: false,
+ });
+ expect(result.success).toBe(false);
+ });
+});
diff --git a/packages/services/src/agent-tools/prompt.ts b/packages/services/src/agent-tools/prompt.ts
index 157c4f983..17e3c18b2 100644
--- a/packages/services/src/agent-tools/prompt.ts
+++ b/packages/services/src/agent-tools/prompt.ts
@@ -62,6 +62,7 @@ Anti-guess rules — these are absolute:
- Before referencing a notification channel: call list_notifications.
- pageId on create_status_report and create_maintenance MUST come from list_status_pages. Guessing will cause a NOT_FOUND error.
- pageComponentIds on create_status_report, create_maintenance, and update_status_report MUST come from list_page_components for that page. Guessing will cause a NOT_FOUND error.
+- componentImpacts on create_status_report and add_status_report_update reference components by id — those ids MUST also come from list_page_components.
Monitor diagnostics:
- get_monitor_status returns one row per configured region (active/degraded/error). Report at the worst region's level: "Healthy in 5/7 regions; failing in gru, fra." Do NOT invent a composite "overall: degraded" label — the per-region facts ARE the answer.
@@ -84,8 +85,15 @@ Inferring status from conversation:
- "we're watching it" → monitoring
- "it's fixed" → resolved
+Component impact:
+- create_status_report and add_status_report_update accept componentImpacts: a per-component impact level (operational | degraded_performance | partial_outage | major_outage).
+- When the user names affected components, include componentImpacts in the draft — map their wording to a level: "down"/"unreachable" → major_outage, "slow"/"degraded" → degraded_performance, "broken for some users" → partial_outage. Ask when the wording is ambiguous.
+- On follow-up updates, only name components whose impact CHANGED — omitted components keep their prior impact.
+- Recovery counts as a change: when a component is back to normal before the incident is resolved ("API is back up"), set it to operational in that update.
+- resolve_status_report clears every remaining impact back to operational automatically — never publish a manual "everything operational" update for that.
+
Draft → Ask → Confirm rubric (MANDATORY for every write tool):
-1. Draft the proposed change (title, status, message, time window, affected components).
+1. Draft the proposed change (title, status, message, time window, affected components and their impact levels).
2. Show the draft to the user before calling the tool.
${notifyStep}
5. Subscriber notifications dispatch only on the call that creates the update — there is no retroactive notify path.
diff --git a/packages/services/src/agent-tools/status-report.ts b/packages/services/src/agent-tools/status-report.ts
index 94a3ac4ca..0408db279 100644
--- a/packages/services/src/agent-tools/status-report.ts
+++ b/packages/services/src/agent-tools/status-report.ts
@@ -9,8 +9,16 @@ import {
updateStatusReport,
} from "../status-report";
import { createStatusReport } from "../status-report/create";
+import { componentImpactsSchema } from "../status-report/schemas";
+import { formatComponentImpacts } from "../status-report/utils";
import type { AgentTool } from "./types";
+const componentImpactsInputShape = componentImpactsSchema
+ .optional()
+ .describe(
+ "Per-component impact (operational | degraded_performance | partial_outage | major_outage). Component ids MUST come from list_page_components. Omit entirely for a report without impact tracking.",
+ );
+
const PER_PAGE_DEFAULT = 50;
const PER_PAGE_MAX = 200;
@@ -149,6 +157,7 @@ const CreateStatusReportInputShape = z.object({
.describe(
"Optional component ids affected by the incident. Resolve via list_page_components({ pageId }) — never guess. Must belong to pageId.",
),
+ componentImpacts: componentImpactsInputShape,
date: z.iso
.datetime()
.optional()
@@ -200,6 +209,16 @@ export const createStatusReportTool: AgentTool<
},
]
: []),
+ ...(input.componentImpacts?.length
+ ? [
+ {
+ label: "Impacts",
+ value: formatComponentImpacts(input.componentImpacts).join(
+ ", ",
+ ),
+ },
+ ]
+ : []),
{ label: "Message", value: input.message },
],
}),
@@ -214,6 +233,7 @@ export const createStatusReportTool: AgentTool<
message: input.message,
pageId: input.pageId,
pageComponentIds: input.pageComponentIds ?? [],
+ componentImpacts: input.componentImpacts,
date: input.date ? new Date(input.date) : new Date(),
},
});
@@ -258,6 +278,7 @@ const AddStatusReportUpdateInputShape = z.object({
.string()
.min(1)
.describe("Public update message customers will see."),
+ componentImpacts: componentImpactsInputShape,
date: z.iso
.datetime()
.optional()
@@ -299,6 +320,16 @@ export const addStatusReportUpdateTool: AgentTool<
lines: [
{ label: "Report ID", value: String(input.statusReportId) },
{ label: "New Status", value: input.status },
+ ...(input.componentImpacts?.length
+ ? [
+ {
+ label: "Impacts",
+ value: formatComponentImpacts(input.componentImpacts).join(
+ ", ",
+ ),
+ },
+ ]
+ : []),
{ label: "Message", value: input.message },
],
}),
@@ -311,6 +342,7 @@ export const addStatusReportUpdateTool: AgentTool<
statusReportId: input.statusReportId,
status: input.status,
message: input.message,
+ componentImpacts: input.componentImpacts,
date: input.date ? new Date(input.date) : undefined,
},
});
diff --git a/packages/services/src/import/__tests__/incidents-phase.test.ts b/packages/services/src/import/__tests__/incidents-phase.test.ts
new file mode 100644
index 000000000..7070bc570
--- /dev/null
+++ b/packages/services/src/import/__tests__/incidents-phase.test.ts
@@ -0,0 +1,390 @@
+import { beforeAll, describe, expect, test } from "bun:test";
+
+import { eq } from "@openstatus/db";
+import {
+ page,
+ pageComponent,
+ statusReport,
+ statusReportUpdate,
+ statusReportUpdateToPageComponents,
+ statusReportsToPageComponents,
+} from "@openstatus/db/src/schema";
+import type { PhaseResult } from "@openstatus/importers";
+
+import { SEEDED_WORKSPACE_TEAM_ID } from "../../../test/fixtures";
+import {
+ loadSeededWorkspace,
+ makeUserCtx,
+ withTestTransaction,
+} from "../../../test/helpers";
+import type { ServiceContext } from "../../context";
+import { writeIncidentsPhase } from "../phase-writers";
+
+const TEST_PREFIX = "svc-import-incidents-test";
+
+let teamCtx: ServiceContext;
+
+beforeAll(async () => {
+ const team = await loadSeededWorkspace(SEEDED_WORKSPACE_TEAM_ID);
+ teamCtx = makeUserCtx(team, { userId: 1 });
+});
+
+describe("writeIncidentsPhase componentImpacts", () => {
+ test("writes impact rows per update and unions membership", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+
+ const pageRow = await tx
+ .insert(page)
+ .values({
+ workspaceId: ctx.workspace.id,
+ title: `${TEST_PREFIX}-page`,
+ description: "",
+ slug: `${TEST_PREFIX}-page-slug`,
+ customDomain: "",
+ })
+ .returning()
+ .get();
+
+ const [compA, compB] = await Promise.all(
+ ["a", "b"].map((suffix) =>
+ tx
+ .insert(pageComponent)
+ .values({
+ workspaceId: ctx.workspace.id,
+ pageId: pageRow.id,
+ name: `${TEST_PREFIX}-component-${suffix}`,
+ type: "static",
+ })
+ .returning()
+ .get(),
+ ),
+ );
+
+ const componentIdMap = new Map([
+ ["src_a", compA.id],
+ ["src_b", compB.id],
+ ]);
+
+ const phase: PhaseResult = {
+ phase: "incidents",
+ status: "completed",
+ resources: [
+ {
+ sourceId: "inc_1",
+ name: `${TEST_PREFIX}-incident`,
+ status: "created",
+ data: {
+ report: {
+ title: `${TEST_PREFIX}-report`,
+ status: "resolved" as const,
+ workspaceId: ctx.workspace.id,
+ pageId: pageRow.id,
+ },
+ updates: [
+ {
+ status: "investigating" as const,
+ message: "m1",
+ date: new Date("2024-01-01T00:00:00Z"),
+ componentImpacts: [
+ {
+ sourceComponentId: "src_a",
+ impact: "major_outage" as const,
+ },
+ ],
+ },
+ {
+ status: "resolved" as const,
+ message: "m2",
+ date: new Date("2024-01-01T02:00:00Z"),
+ componentImpacts: [
+ {
+ sourceComponentId: "src_a",
+ impact: "operational" as const,
+ },
+ // not in componentIdMap: skipped without failing
+ {
+ sourceComponentId: "src_missing",
+ impact: "major_outage" as const,
+ },
+ ],
+ },
+ ],
+ sourceComponentIds: ["src_b"],
+ },
+ },
+ ],
+ };
+
+ await writeIncidentsPhase(
+ { ctx, tx, provider: "statuspage" },
+ phase,
+ pageRow.id,
+ componentIdMap,
+ );
+
+ expect(phase.resources[0].status).toBe("created");
+ const reportId = phase.resources[0].openstatusId;
+ expect(reportId).toBeGreaterThan(0);
+
+ const report = await tx
+ .select()
+ .from(statusReport)
+ .where(eq(statusReport.id, reportId as number))
+ .get();
+ expect(report?.title).toBe(`${TEST_PREFIX}-report`);
+
+ const updates = await tx
+ .select()
+ .from(statusReportUpdate)
+ .where(eq(statusReportUpdate.statusReportId, reportId as number))
+ .all();
+ expect(updates).toHaveLength(2);
+
+ const sorted = [...updates].sort(
+ (a, b) => a.date.getTime() - b.date.getTime(),
+ );
+ const impactRowsFor = async (updateId: number) =>
+ tx
+ .select()
+ .from(statusReportUpdateToPageComponents)
+ .where(
+ eq(
+ statusReportUpdateToPageComponents.statusReportUpdateId,
+ updateId,
+ ),
+ )
+ .all();
+
+ const firstRows = await impactRowsFor(sorted[0].id);
+ expect(firstRows).toHaveLength(1);
+ expect(firstRows[0].pageComponentId).toBe(compA.id);
+ expect(firstRows[0].impact).toBe("major_outage");
+
+ const lastRows = await impactRowsFor(sorted[1].id);
+ expect(lastRows).toHaveLength(1);
+ expect(lastRows[0].pageComponentId).toBe(compA.id);
+ expect(lastRows[0].impact).toBe("operational");
+
+ // membership = sourceComponentIds ∪ impact-named components
+ const membership = await tx
+ .select()
+ .from(statusReportsToPageComponents)
+ .where(
+ eq(statusReportsToPageComponents.statusReportId, reportId as number),
+ )
+ .all();
+ expect(membership.map((m) => m.pageComponentId).sort()).toEqual(
+ [compA.id, compB.id].sort(),
+ );
+ });
+ });
+
+ test("dedupes source ids collapsing onto one component (worst impact wins)", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+
+ const pageRow = await tx
+ .insert(page)
+ .values({
+ workspaceId: ctx.workspace.id,
+ title: `${TEST_PREFIX}-collapse-page`,
+ description: "",
+ slug: `${TEST_PREFIX}-collapse-page-slug`,
+ customDomain: "",
+ })
+ .returning()
+ .get();
+
+ const comp = await tx
+ .insert(pageComponent)
+ .values({
+ workspaceId: ctx.workspace.id,
+ pageId: pageRow.id,
+ name: `${TEST_PREFIX}-collapse-component`,
+ type: "static",
+ })
+ .returning()
+ .get();
+
+ // the components phase dedupes by (name, pageId): two source ids → one row
+ const componentIdMap = new Map([
+ ["src_a1", comp.id],
+ ["src_a2", comp.id],
+ ]);
+
+ const phase: PhaseResult = {
+ phase: "incidents",
+ status: "completed",
+ resources: [
+ {
+ sourceId: "inc_collapse",
+ name: `${TEST_PREFIX}-collapse-incident`,
+ status: "created",
+ data: {
+ report: {
+ title: `${TEST_PREFIX}-collapse-report`,
+ status: "investigating" as const,
+ workspaceId: ctx.workspace.id,
+ pageId: pageRow.id,
+ },
+ updates: [
+ {
+ status: "investigating" as const,
+ message: "m1",
+ date: new Date("2024-01-01T00:00:00Z"),
+ componentImpacts: [
+ {
+ sourceComponentId: "src_a1",
+ impact: "degraded_performance" as const,
+ },
+ {
+ sourceComponentId: "src_a2",
+ impact: "major_outage" as const,
+ },
+ ],
+ },
+ ],
+ sourceComponentIds: ["src_a1", "src_a2"],
+ },
+ },
+ ],
+ };
+
+ await writeIncidentsPhase(
+ { ctx, tx, provider: "statuspage" },
+ phase,
+ pageRow.id,
+ componentIdMap,
+ );
+
+ expect(phase.resources[0].status).toBe("created");
+ expect(phase.resources[0].error).toBeUndefined();
+ const reportId = phase.resources[0].openstatusId as number;
+
+ const updates = await tx
+ .select()
+ .from(statusReportUpdate)
+ .where(eq(statusReportUpdate.statusReportId, reportId))
+ .all();
+ expect(updates).toHaveLength(1);
+
+ const impactRows = await tx
+ .select()
+ .from(statusReportUpdateToPageComponents)
+ .where(
+ eq(
+ statusReportUpdateToPageComponents.statusReportUpdateId,
+ updates[0].id,
+ ),
+ )
+ .all();
+ expect(impactRows).toHaveLength(1);
+ expect(impactRows[0].pageComponentId).toBe(comp.id);
+ expect(impactRows[0].impact).toBe("major_outage");
+
+ const membership = await tx
+ .select()
+ .from(statusReportsToPageComponents)
+ .where(eq(statusReportsToPageComponents.statusReportId, reportId))
+ .all();
+ expect(membership).toHaveLength(1);
+ expect(membership[0].pageComponentId).toBe(comp.id);
+ });
+ });
+
+ test("skips impact rows on rerun (report already exists)", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+
+ const pageRow = await tx
+ .insert(page)
+ .values({
+ workspaceId: ctx.workspace.id,
+ title: `${TEST_PREFIX}-rerun-page`,
+ description: "",
+ slug: `${TEST_PREFIX}-rerun-page-slug`,
+ customDomain: "",
+ })
+ .returning()
+ .get();
+
+ const comp = await tx
+ .insert(pageComponent)
+ .values({
+ workspaceId: ctx.workspace.id,
+ pageId: pageRow.id,
+ name: `${TEST_PREFIX}-rerun-component`,
+ type: "static",
+ })
+ .returning()
+ .get();
+
+ const componentIdMap = new Map([["src_a", comp.id]]);
+ const makePhase = (): PhaseResult => ({
+ phase: "incidents",
+ status: "completed",
+ resources: [
+ {
+ sourceId: "inc_rerun",
+ name: `${TEST_PREFIX}-rerun-incident`,
+ status: "created",
+ data: {
+ report: {
+ title: `${TEST_PREFIX}-rerun-report`,
+ status: "investigating" as const,
+ workspaceId: ctx.workspace.id,
+ pageId: pageRow.id,
+ },
+ updates: [
+ {
+ status: "investigating" as const,
+ message: "m1",
+ date: new Date("2024-01-01T00:00:00Z"),
+ componentImpacts: [
+ {
+ sourceComponentId: "src_a",
+ impact: "partial_outage" as const,
+ },
+ ],
+ },
+ ],
+ sourceComponentIds: ["src_a"],
+ },
+ },
+ ],
+ });
+
+ const pc = { ctx, tx, provider: "statuspage" as const };
+ const firstRun = makePhase();
+ await writeIncidentsPhase(pc, firstRun, pageRow.id, componentIdMap);
+ expect(firstRun.resources[0].status).toBe("created");
+ const reportId = firstRun.resources[0].openstatusId as number;
+
+ const secondRun = makePhase();
+ await writeIncidentsPhase(pc, secondRun, pageRow.id, componentIdMap);
+ expect(secondRun.resources[0].status).toBe("skipped");
+
+ // updates and their impact rows are written only on the creating run
+ const updates = await tx
+ .select()
+ .from(statusReportUpdate)
+ .where(eq(statusReportUpdate.statusReportId, reportId))
+ .all();
+ expect(updates).toHaveLength(1);
+
+ const impactRows = await tx
+ .select()
+ .from(statusReportUpdateToPageComponents)
+ .where(
+ eq(
+ statusReportUpdateToPageComponents.statusReportUpdateId,
+ updates[0].id,
+ ),
+ )
+ .all();
+ expect(impactRows).toHaveLength(1);
+ expect(impactRows[0].impact).toBe("partial_outage");
+ });
+ });
+});
diff --git a/packages/services/src/import/phase-writers.ts b/packages/services/src/import/phase-writers.ts
index 5cf3b5672..8bdc66556 100644
--- a/packages/services/src/import/phase-writers.ts
+++ b/packages/services/src/import/phase-writers.ts
@@ -10,12 +10,19 @@ import {
pageSubscriberToPageComponent,
statusReport,
statusReportUpdate,
+ statusReportUpdateToPageComponents,
statusReportsToPageComponents,
+ worstImpact,
} from "@openstatus/db/src/schema";
-import type { PhaseResult } from "@openstatus/importers";
+import type { PageComponentImpact } from "@openstatus/db/src/schema";
+import type { PhaseResult, UpdateComponentImpact } from "@openstatus/importers";
import { emitAudit } from "../audit";
import type { DB, ServiceContext } from "../context";
+import {
+ withComponentImpacts,
+ withPageComponentIds,
+} from "../status-report/internal";
import type { ImportProviderName } from "./schemas";
import { clampPeriodicity, computePhaseStatus } from "./utils";
@@ -364,6 +371,7 @@ export async function writeIncidentsPhase(
status: "investigating" | "identified" | "monitoring" | "resolved";
message: string;
date: Date;
+ componentImpacts?: UpdateComponentImpact[];
}>;
sourceComponentIds: string[];
};
@@ -428,6 +436,26 @@ export async function writeIncidentsPhase(
continue;
}
+ // membership = sourceComponentIds ∪ impact-named components, upholding
+ // the invariant that every impact row's component is in the report set
+ const memberSourceIds = new Set([
+ ...data.sourceComponentIds,
+ ...data.updates.flatMap((u) =>
+ (u.componentImpacts ?? []).map((ci) => ci.sourceComponentId),
+ ),
+ ]);
+ // distinct source ids can collapse onto one internal component (the
+ // components phase dedupes by name+page) — dedupe to respect the PK
+ const memberComponentIds = new Set<number>();
+ for (const sourceCompId of memberSourceIds) {
+ const osCompId = componentIdMap.get(sourceCompId);
+ if (osCompId) memberComponentIds.add(osCompId);
+ }
+ const componentLinks = [...memberComponentIds].map((pageComponentId) => ({
+ statusReportId: insertedReport.id,
+ pageComponentId,
+ }));
+
await emitAudit(tx, ctx, {
action: "status_report.create",
entityType: "status_report",
@@ -437,51 +465,71 @@ export async function writeIncidentsPhase(
pageId,
title: data.report.title,
}),
- after: insertedReport,
+ after: withPageComponentIds(
+ insertedReport,
+ componentLinks.map((l) => l.pageComponentId),
+ ),
});
- // Batch the update rows with `.returning()` so per-update audit can
- // attribute the specific update ids.
- if (data.updates.length > 0) {
- const insertedUpdates = await tx
+ // Insert updates one-by-one so each inserted id pairs with its source
+ // update's componentImpacts deterministically (batch `.returning()`
+ // order is not a guarantee worth relying on).
+ for (const u of data.updates) {
+ const row = await tx
.insert(statusReportUpdate)
- .values(
- data.updates.map((u) => ({
- status: u.status,
- message: u.message,
- date: u.date,
- statusReportId: insertedReport.id,
- })),
- )
- .returning();
-
- for (const row of insertedUpdates) {
- await emitAudit(tx, ctx, {
- action: "status_report_update.create",
- entityType: "status_report_update",
- entityId: row.id,
- metadata: auditMeta(pc, {
- sourceId: resource.sourceId,
- statusReportId: insertedReport.id,
- }),
- after: row,
- });
+ .values({
+ status: u.status,
+ message: u.message,
+ date: u.date,
+ statusReportId: insertedReport.id,
+ })
+ .returning()
+ .get();
+
+ // ids missing from `componentIdMap` get no impact row — same
+ // partial-map caveat as the membership links. Collapsed source ids
+ // (same internal component) keep the worst impact.
+ const impactByComponent = new Map<number, PageComponentImpact>();
+ for (const ci of u.componentImpacts ?? []) {
+ const osCompId = componentIdMap.get(ci.sourceComponentId);
+ if (!osCompId) continue;
+ const prev = impactByComponent.get(osCompId);
+ impactByComponent.set(
+ osCompId,
+ prev ? worstImpact([prev, ci.impact]) : ci.impact,
+ );
+ }
+ const impactRows = [...impactByComponent].map(
+ ([pageComponentId, impact]) => ({
+ statusReportUpdateId: row.id,
+ pageComponentId,
+ impact,
+ }),
+ );
+ if (impactRows.length > 0) {
+ await tx
+ .insert(statusReportUpdateToPageComponents)
+ .values(impactRows);
}
- }
- const componentLinks: Array<{
- statusReportId: number;
- pageComponentId: number;
- }> = [];
- for (const sourceCompId of data.sourceComponentIds) {
- const osCompId = componentIdMap.get(sourceCompId);
- if (osCompId) {
- componentLinks.push({
+ await emitAudit(tx, ctx, {
+ action: "status_report_update.create",
+ entityType: "status_report_update",
+ entityId: row.id,
+ metadata: auditMeta(pc, {
+ sourceId: resource.sourceId,
statusReportId: insertedReport.id,
- pageComponentId: osCompId,
- });
- }
+ }),
+ after: withComponentImpacts(
+ row,
+ impactRows.map(({ pageComponentId, impact }) => ({
+ pageComponentId,
+ impact,
+ })),
+ ),
+ });
}
+
if (componentLinks.length > 0) {
await tx.insert(statusReportsToPageComponents).values(componentLinks);
}
diff --git a/packages/services/src/status-report/__tests__/status-report.test.ts b/packages/services/src/status-report/__tests__/status-report.test.ts
index 56b864d56..fb7bab4d0 100644
--- a/packages/services/src/status-report/__tests__/status-report.test.ts
+++ b/packages/services/src/status-report/__tests__/status-report.test.ts
@@ -14,6 +14,7 @@ import {
pageSubscriber,
statusReport,
statusReportUpdate,
+ statusReportUpdateToPageComponents,
statusReportsToPageComponents,
} from "@openstatus/db/src/schema";
@@ -27,13 +28,15 @@ import {
makeApiKeyCtx,
makeSlackCtx,
makeUserCtx,
+ readAuditLog,
withTestTransaction,
} from "../../../test/helpers";
-import type { ServiceContext } from "../../context";
-import { ForbiddenError, NotFoundError } from "../../errors";
+import type { DB, ServiceContext } from "../../context";
+import { ConflictError, ForbiddenError, NotFoundError } from "../../errors";
import { addStatusReportUpdate } from "../add-update";
import { createStatusReport } from "../create";
import { deleteStatusReport, deleteStatusReportUpdate } from "../delete";
+import { getCurrentImpactsForReport } from "../internal";
import { getStatusReport, listStatusReports } from "../list";
import { notifyStatusReport } from "../notify";
import { resolveStatusReport } from "../resolve";
@@ -62,6 +65,9 @@ let teamCtx: ServiceContext;
let freeCtx: ServiceContext;
let testPageId: number;
let testPageComponentId: number;
+let testPageComponentId2: number;
+let otherPageId: number;
+let otherPageComponentId: number;
beforeAll(async () => {
const team = await loadSeededWorkspace(SEEDED_WORKSPACE_TEAM_ID);
@@ -93,6 +99,43 @@ beforeAll(async () => {
.returning()
.get();
testPageComponentId = componentRow.id;
+
+ const componentRow2 = await db
+ .insert(pageComponent)
+ .values({
+ workspaceId: team.id,
+ pageId: testPageId,
+ name: `${TEST_PREFIX}-component-2`,
+ type: "static",
+ })
+ .returning()
+ .get();
+ testPageComponentId2 = componentRow2.id;
+
+ const otherPageRow = await db
+ .insert(page)
+ .values({
+ workspaceId: team.id,
+ title: `${TEST_PREFIX}-other-page`,
+ description: "test page",
+ slug: `${TEST_PREFIX}-other-page-slug`,
+ customDomain: "",
+ })
+ .returning()
+ .get();
+ otherPageId = otherPageRow.id;
+
+ const otherComponentRow = await db
+ .insert(pageComponent)
+ .values({
+ workspaceId: team.id,
+ pageId: otherPageId,
+ name: `${TEST_PREFIX}-other-component`,
+ type: "static",
+ })
+ .returning()
+ .get();
+ otherPageComponentId = otherComponentRow.id;
});
afterAll(async () => {
@@ -100,14 +143,22 @@ afterAll(async () => {
.delete(pageSubscriber)
.where(eq(pageSubscriber.pageId, testPageId))
.catch(() => undefined);
- await db
- .delete(pageComponent)
- .where(eq(pageComponent.id, testPageComponentId))
- .catch(() => undefined);
- await db
- .delete(page)
- .where(eq(page.id, testPageId))
- .catch(() => undefined);
+ for (const componentId of [
+ testPageComponentId,
+ testPageComponentId2,
+ otherPageComponentId,
+ ]) {
+ await db
+ .delete(pageComponent)
+ .where(eq(pageComponent.id, componentId))
+ .catch(() => undefined);
+ }
+ for (const pageId of [testPageId, otherPageId]) {
+ await db
+ .delete(page)
+ .where(eq(page.id, pageId))
+ .catch(() => undefined);
+ }
});
beforeEach(() => {
@@ -608,3 +659,491 @@ describe("slack actor path", () => {
});
});
});
+
+describe("componentImpacts", () => {
+ async function impactRowsForUpdate(tx: DB, statusReportUpdateId: number) {
+ return tx
+ .select()
+ .from(statusReportUpdateToPageComponents)
+ .where(
+ eq(
+ statusReportUpdateToPageComponents.statusReportUpdateId,
+ statusReportUpdateId,
+ ),
+ )
+ .all();
+ }
+
+ test("create writes impact rows for the initial update and unions membership", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+ const { statusReport: report, initialUpdate } = await createStatusReport({
+ ctx,
+ input: {
+ title: `${TEST_PREFIX}-impact-create`,
+ status: "investigating",
+ message: "initial",
+ date: new Date(),
+ pageId: testPageId,
+ pageComponentIds: [testPageComponentId],
+ componentImpacts: [
+ { pageComponentId: testPageComponentId2, impact: "major_outage" },
+ ],
+ },
+ });
+
+ const rows = await impactRowsForUpdate(tx, initialUpdate.id);
+ expect(rows).toHaveLength(1);
+ expect(rows[0].pageComponentId).toBe(testPageComponentId2);
+ expect(rows[0].impact).toBe("major_outage");
+
+ const membership = await tx
+ .select()
+ .from(statusReportsToPageComponents)
+ .where(eq(statusReportsToPageComponents.statusReportId, report.id))
+ .all();
+ expect(membership.map((m) => m.pageComponentId).sort()).toEqual(
+ [testPageComponentId, testPageComponentId2].sort(),
+ );
+
+ // impacts and membership surface in the audit snapshots (CHANGES UI)
+ const updateAuditRows = await readAuditLog({
+ workspaceId: teamCtx.workspace.id,
+ entityType: "status_report_update",
+ entityId: String(initialUpdate.id),
+ db: tx,
+ });
+ const updateHit = updateAuditRows.find(
+ (r) => r.action === "status_report_update.create",
+ );
+ expect(updateHit?.after).toMatchObject({
+ componentImpacts: [
+ { pageComponentId: testPageComponentId2, impact: "major_outage" },
+ ],
+ });
+
+ const reportAuditRows = await readAuditLog({
+ workspaceId: teamCtx.workspace.id,
+ entityType: "status_report",
+ entityId: String(report.id),
+ db: tx,
+ });
+ const reportHit = reportAuditRows.find(
+ (r) => r.action === "status_report.create",
+ );
+ expect(reportHit?.after).toMatchObject({
+ pageComponentIds: [testPageComponentId, testPageComponentId2].sort(
+ (a, b) => a - b,
+ ),
+ });
+ });
+ });
+
+ test("create without componentImpacts writes zero impact rows (legacy)", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+ const { initialUpdate } = await createStatusReport({
+ ctx,
+ input: {
+ title: `${TEST_PREFIX}-impact-legacy`,
+ status: "investigating",
+ message: "initial",
+ date: new Date(),
+ pageId: testPageId,
+ pageComponentIds: [testPageComponentId],
+ },
+ });
+
+ const rows = await impactRowsForUpdate(tx, initialUpdate.id);
+ expect(rows).toHaveLength(0);
+ });
+ });
+
+ test("add-update naming a new component syncs membership and writes its impact", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+ const { statusReport: report } = await createStatusReport({
+ ctx,
+ input: {
+ title: `${TEST_PREFIX}-impact-sync`,
+ status: "investigating",
+ message: "initial",
+ date: new Date(Date.now() - 60_000),
+ pageId: testPageId,
+ pageComponentIds: [],
+ componentImpacts: [
+ { pageComponentId: testPageComponentId, impact: "partial_outage" },
+ ],
+ },
+ });
+
+ const { statusReportUpdate: newUpdate } = await addStatusReportUpdate({
+ ctx,
+ input: {
+ statusReportId: report.id,
+ status: "identified",
+ message: "second component affected",
+ componentImpacts: [
+ {
+ pageComponentId: testPageComponentId2,
+ impact: "degraded_performance",
+ },
+ ],
+ },
+ });
+
+ const rows = await impactRowsForUpdate(tx, newUpdate.id);
+ expect(rows).toHaveLength(1);
+ expect(rows[0].pageComponentId).toBe(testPageComponentId2);
+
+ const membership = await tx
+ .select()
+ .from(statusReportsToPageComponents)
+ .where(eq(statusReportsToPageComponents.statusReportId, report.id))
+ .all();
+ expect(membership.map((m) => m.pageComponentId).sort()).toEqual(
+ [testPageComponentId, testPageComponentId2].sort(),
+ );
+
+ // omitted component keeps its prior impact via latest-update-naming-it
+ const current = await getCurrentImpactsForReport(tx, report.id);
+ expect(current.get(testPageComponentId)).toBe("partial_outage");
+ expect(current.get(testPageComponentId2)).toBe("degraded_performance");
+ });
+ });
+
+ test("resolve writes operational rows for still-affected components", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+ const { statusReport: report } = await createStatusReport({
+ ctx,
+ input: {
+ title: `${TEST_PREFIX}-impact-resolve`,
+ status: "investigating",
+ message: "initial",
+ date: new Date(Date.now() - 60_000),
+ pageId: testPageId,
+ pageComponentIds: [],
+ componentImpacts: [
+ { pageComponentId: testPageComponentId, impact: "major_outage" },
+ {
+ pageComponentId: testPageComponentId2,
+ impact: "degraded_performance",
+ },
+ ],
+ },
+ });
+
+ const { statusReportUpdate: resolving } = await resolveStatusReport({
+ ctx,
+ input: { statusReportId: report.id, message: "all clear" },
+ });
+
+ const rows = await impactRowsForUpdate(tx, resolving.id);
+ expect(rows).toHaveLength(2);
+ expect(rows.every((r) => r.impact === "operational")).toBe(true);
+
+ const current = await getCurrentImpactsForReport(tx, report.id);
+ expect(current.get(testPageComponentId)).toBe("operational");
+ expect(current.get(testPageComponentId2)).toBe("operational");
+ });
+ });
+
+ test("resolve on a legacy report stays legacy (zero rows)", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+ const { statusReport: report } = await createStatusReport({
+ ctx,
+ input: {
+ title: `${TEST_PREFIX}-impact-resolve-legacy`,
+ status: "investigating",
+ message: "initial",
+ date: new Date(Date.now() - 60_000),
+ pageId: testPageId,
+ pageComponentIds: [testPageComponentId],
+ },
+ });
+
+ const { statusReportUpdate: resolving } = await resolveStatusReport({
+ ctx,
+ input: { statusReportId: report.id, message: "all clear" },
+ });
+
+ const rows = await impactRowsForUpdate(tx, resolving.id);
+ expect(rows).toHaveLength(0);
+ expect((await getCurrentImpactsForReport(tx, report.id)).size).toBe(0);
+ });
+ });
+
+ test("membership replacement prunes impact rows for removed components", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+ const { statusReport: report, initialUpdate } = await createStatusReport({
+ ctx,
+ input: {
+ title: `${TEST_PREFIX}-impact-prune`,
+ status: "investigating",
+ message: "initial",
+ date: new Date(Date.now() - 60_000),
+ pageId: testPageId,
+ pageComponentIds: [],
+ componentImpacts: [
+ { pageComponentId: testPageComponentId, impact: "major_outage" },
+ {
+ pageComponentId: testPageComponentId2,
+ impact: "degraded_performance",
+ },
+ ],
+ },
+ });
+
+ await updateStatusReport({
+ ctx,
+ input: { id: report.id, pageComponentIds: [testPageComponentId] },
+ });
+
+ const rows = await impactRowsForUpdate(tx, initialUpdate.id);
+ expect(rows).toHaveLength(1);
+ expect(rows[0].pageComponentId).toBe(testPageComponentId);
+
+ // the fold must not resurrect the removed component
+ const current = await getCurrentImpactsForReport(tx, report.id);
+ expect(current.has(testPageComponentId2)).toBe(false);
+ expect(current.get(testPageComponentId)).toBe("major_outage");
+ });
+ });
+
+ test("clearing membership prunes all impact rows (report reads legacy)", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+ const { statusReport: report, initialUpdate } = await createStatusReport({
+ ctx,
+ input: {
+ title: `${TEST_PREFIX}-impact-prune-all`,
+ status: "investigating",
+ message: "initial",
+ date: new Date(Date.now() - 60_000),
+ pageId: testPageId,
+ pageComponentIds: [],
+ componentImpacts: [
+ { pageComponentId: testPageComponentId, impact: "partial_outage" },
+ ],
+ },
+ });
+
+ await updateStatusReport({
+ ctx,
+ input: { id: report.id, pageComponentIds: [] },
+ });
+
+ expect(await impactRowsForUpdate(tx, initialUpdate.id)).toHaveLength(0);
+ expect((await getCurrentImpactsForReport(tx, report.id)).size).toBe(0);
+ });
+ });
+
+ test("rejects impacts for components on a different page", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+ const { statusReport: report } = await createStatusReport({
+ ctx,
+ input: {
+ title: `${TEST_PREFIX}-impact-cross-page`,
+ status: "investigating",
+ message: "initial",
+ date: new Date(),
+ pageId: testPageId,
+ pageComponentIds: [testPageComponentId],
+ },
+ });
+
+ await expect(
+ addStatusReportUpdate({
+ ctx,
+ input: {
+ statusReportId: report.id,
+ status: "identified",
+ message: "wrong page",
+ componentImpacts: [
+ { pageComponentId: otherPageComponentId, impact: "major_outage" },
+ ],
+ },
+ }),
+ ).rejects.toBeInstanceOf(ConflictError);
+ });
+ });
+
+ test("updateStatusReportUpdate replaces the update's impact rows", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+ const { initialUpdate } = await createStatusReport({
+ ctx,
+ input: {
+ title: `${TEST_PREFIX}-impact-edit`,
+ status: "investigating",
+ message: "initial",
+ date: new Date(Date.now() - 60_000),
+ pageId: testPageId,
+ pageComponentIds: [],
+ componentImpacts: [
+ { pageComponentId: testPageComponentId, impact: "major_outage" },
+ ],
+ },
+ });
+
+ // edit without componentImpacts: rows untouched
+ await updateStatusReportUpdate({
+ ctx,
+ input: { id: initialUpdate.id, message: "edited message" },
+ });
+ let rows = await impactRowsForUpdate(tx, initialUpdate.id);
+ expect(rows).toHaveLength(1);
+ expect(rows[0].impact).toBe("major_outage");
+
+ // edit with componentImpacts: full replace + membership sync
+ await updateStatusReportUpdate({
+ ctx,
+ input: {
+ id: initialUpdate.id,
+ componentImpacts: [
+ {
+ pageComponentId: testPageComponentId2,
+ impact: "degraded_performance",
+ },
+ ],
+ },
+ });
+ rows = await impactRowsForUpdate(tx, initialUpdate.id);
+ expect(rows).toHaveLength(1);
+ expect(rows[0].pageComponentId).toBe(testPageComponentId2);
+ expect(rows[0].impact).toBe("degraded_performance");
+
+ const membership = await tx
+ .select()
+ .from(statusReportsToPageComponents)
+ .where(
+ eq(
+ statusReportsToPageComponents.statusReportId,
+ initialUpdate.statusReportId,
+ ),
+ )
+ .all();
+ expect(membership.map((m) => m.pageComponentId)).toContain(
+ testPageComponentId2,
+ );
+
+ const auditRows = await readAuditLog({
+ workspaceId: teamCtx.workspace.id,
+ entityType: "status_report_update",
+ entityId: String(initialUpdate.id),
+ db: tx,
+ });
+ const hit = auditRows.find(
+ (r) => r.action === "status_report_update.update",
+ );
+ expect(hit?.changedFields).toContain("componentImpacts");
+ expect(hit?.before).toMatchObject({
+ componentImpacts: [
+ { pageComponentId: testPageComponentId, impact: "major_outage" },
+ ],
+ });
+ expect(hit?.after).toMatchObject({
+ componentImpacts: [
+ {
+ pageComponentId: testPageComponentId2,
+ impact: "degraded_performance",
+ },
+ ],
+ });
+ });
+ });
+
+ test("membership-only updateStatusReport emits an audit diff", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+ const { statusReport: report } = await createStatusReport({
+ ctx,
+ input: {
+ title: `${TEST_PREFIX}-audit-membership`,
+ status: "investigating",
+ message: "initial",
+ date: new Date(),
+ pageId: testPageId,
+ pageComponentIds: [testPageComponentId],
+ },
+ });
+
+ await updateStatusReport({
+ ctx,
+ input: { id: report.id, pageComponentIds: [testPageComponentId2] },
+ });
+
+ const auditRows = await readAuditLog({
+ workspaceId: teamCtx.workspace.id,
+ entityType: "status_report",
+ entityId: String(report.id),
+ db: tx,
+ });
+ const hit = auditRows.find((r) => r.action === "status_report.update");
+ expect(hit).toBeDefined();
+ expect(hit?.changedFields).toContain("pageComponentIds");
+ expect(hit?.before).toMatchObject({
+ pageComponentIds: [testPageComponentId],
+ });
+ expect(hit?.after).toMatchObject({
+ pageComponentIds: [testPageComponentId2],
+ });
+ });
+ });
+
+ test("updateStatusReportUpdate rejects impacts on another page", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+ const { initialUpdate } = await createStatusReport({
+ ctx,
+ input: {
+ title: `${TEST_PREFIX}-impact-edit-cross`,
+ status: "investigating",
+ message: "initial",
+ date: new Date(),
+ pageId: testPageId,
+ pageComponentIds: [testPageComponentId],
+ },
+ });
+
+ await expect(
+ updateStatusReportUpdate({
+ ctx,
+ input: {
+ id: initialUpdate.id,
+ componentImpacts: [
+ { pageComponentId: otherPageComponentId, impact: "major_outage" },
+ ],
+ },
+ }),
+ ).rejects.toBeInstanceOf(ConflictError);
+ });
+ });
+
+ test("rejects duplicate component ids in componentImpacts", async () => {
+ await withTestTransaction(async (tx) => {
+ const ctx = { ...teamCtx, db: tx };
+ await expect(
+ createStatusReport({
+ ctx,
+ input: {
+ title: `${TEST_PREFIX}-impact-dupes`,
+ status: "investigating",
+ message: "initial",
+ date: new Date(),
+ pageId: testPageId,
+ pageComponentIds: [],
+ componentImpacts: [
+ { pageComponentId: testPageComponentId, impact: "major_outage" },
+ { pageComponentId: testPageComponentId, impact: "operational" },
+ ],
+ },
+ }),
+ ).rejects.toThrow();
+ });
+ });
+});
diff --git a/packages/services/src/status-report/add-update.ts b/packages/services/src/status-report/add-update.ts
index 7424c5a5f..feccf5c68 100644
--- a/packages/services/src/status-report/add-update.ts
+++ b/packages/services/src/status-report/add-update.ts
@@ -1,12 +1,22 @@
import { eq } from "@openstatus/db";
-import { statusReport, statusReportUpdate } from "@openstatus/db/src/schema";
+import {
+ statusReport,
+ statusReportUpdate,
+ statusReportsToPageComponents,
+} from "@openstatus/db/src/schema";
import { emitAudit } from "../audit";
import { requireScope } from "../auth";
import { type ServiceContext, withTransaction } from "../context";
-import { InternalServiceError } from "../errors";
+import { ConflictError, InternalServiceError } from "../errors";
import type { StatusReport, StatusReportUpdate } from "../types";
-import { getReportInWorkspace } from "./internal";
+import {
+ getCurrentImpactsForReport,
+ getReportInWorkspace,
+ insertUpdateComponentImpacts,
+ validatePageComponentIds,
+ withComponentImpacts,
+} from "./internal";
import { AddStatusReportUpdateInput } from "./schemas";
export type AddStatusReportUpdateResult = {
@@ -31,6 +41,54 @@ export async function addStatusReportUpdate(args: {
const date = input.date ?? new Date();
+ const componentImpacts = input.componentImpacts ?? [];
+ if (componentImpacts.length > 0) {
+ const validated = await validatePageComponentIds({
+ tx,
+ workspaceId: ctx.workspace.id,
+ pageComponentIds: componentImpacts.map((ci) => ci.pageComponentId),
+ });
+ if (
+ validated.pageId !== null &&
+ report.pageId !== null &&
+ validated.pageId !== report.pageId
+ ) {
+ throw new ConflictError(
+ `Components belong to page ${validated.pageId}, not the report's page ${report.pageId}.`,
+ );
+ }
+ // invariant: every impact row's component is in the report's membership
+ // set — an update is the only way to add a component after creation.
+ await tx
+ .insert(statusReportsToPageComponents)
+ .values(
+ validated.componentIds.map((pageComponentId) => ({
+ statusReportId: report.id,
+ pageComponentId,
+ })),
+ )
+ .onConflictDoNothing();
+ }
+
+ // resolve clears every still-non-operational component not named by this
+ // update, so the page clears deterministically. Computed before this
+ // update's rows are written; empty map (legacy report) stays legacy.
+ let writtenImpacts = componentImpacts;
+ if (input.status === "resolved") {
+ const current = await getCurrentImpactsForReport(tx, report.id);
+ const named = new Set(componentImpacts.map((ci) => ci.pageComponentId));
+ const clears = [...current]
+ .filter(
+ ([componentId, impact]) =>
+ impact !== "operational" && !named.has(componentId),
+ )
+ .map(([pageComponentId]) => ({
+ pageComponentId,
+ impact: "operational" as const,
+ }));
+ writtenImpacts = [...componentImpacts, ...clears];
+ }
+
const newUpdate = await tx
.insert(statusReportUpdate)
.values({
@@ -42,6 +100,12 @@ export async function addStatusReportUpdate(args: {
.returning()
.get();
+ await insertUpdateComponentImpacts({
+ tx,
+ statusReportUpdateId: newUpdate.id,
+ componentImpacts: writtenImpacts,
+ });
+
const updatedReport = await tx
.update(statusReport)
.set({ status: input.status, updatedAt: new Date() })
@@ -59,7 +123,7 @@ export async function addStatusReportUpdate(args: {
action: "status_report_update.create",
entityType: "status_report_update",
entityId: newUpdate.id,
- after: newUpdate,
+ after: withComponentImpacts(newUpdate, writtenImpacts),
metadata: { statusReportId: report.id },
});
diff --git a/packages/services/src/status-report/create.ts b/packages/services/src/status-report/create.ts
index c39a1ac47..8b9081253 100644
--- a/packages/services/src/status-report/create.ts
+++ b/packages/services/src/status-report/create.ts
@@ -11,8 +11,11 @@ import { type ServiceContext, withTransaction } from "../context";
import { ConflictError, NotFoundError } from "../errors";
import type { StatusReport, StatusReportUpdate } from "../types";
import {
+ insertUpdateComponentImpacts,
updatePageComponentAssociations,
validatePageComponentIds,
+ withComponentImpacts,
+ withPageComponentIds,
} from "./internal";
import { CreateStatusReportInput } from "./schemas";
@@ -39,10 +42,15 @@ export async function createStatusReport(args: {
.get();
if (!page_) throw new NotFoundError("page", input.pageId);
+ const componentImpacts = input.componentImpacts ?? [];
+ // membership = union of the explicit set and the impact-named components
const validated = await validatePageComponentIds({
tx,
workspaceId: ctx.workspace.id,
- pageComponentIds: input.pageComponentIds,
+ pageComponentIds: [
+ ...input.pageComponentIds,
+ ...componentImpacts.map((ci) => ci.pageComponentId),
+ ],
});
if (validated.pageId !== null && validated.pageId !== input.pageId) {
@@ -79,18 +87,26 @@ export async function createStatusReport(args: {
.returning()
.get();
+ await insertUpdateComponentImpacts({
+ tx,
+ statusReportUpdateId: initialUpdate.id,
+ componentImpacts,
+ });
+
+ // membership + impacts live in join tables — surface them in the
+ // snapshots so the audit diff/UI sees them alongside the entity fields
await emitAudit(tx, ctx, {
action: "status_report.create",
entityType: "status_report",
entityId: newReport.id,
- after: newReport,
+ after: withPageComponentIds(newReport, validated.componentIds),
});
await emitAudit(tx, ctx, {
action: "status_report_update.create",
entityType: "status_report_update",
entityId: initialUpdate.id,
- after: initialUpdate,
+ after: withComponentImpacts(initialUpdate, componentImpacts),
metadata: { statusReportId: newReport.id },
});
diff --git a/packages/services/src/status-report/index.ts b/packages/services/src/status-report/index.ts
index a3c9a9e57..9cec5a7e0 100644
--- a/packages/services/src/status-report/index.ts
+++ b/packages/services/src/status-report/index.ts
@@ -13,9 +13,12 @@ export {
export { notifyStatusReport } from "./notify";
export { resolveStatusReport } from "./resolve";
export { updateStatusReport, updateStatusReportUpdate } from "./update";
+export { formatComponentImpacts } from "./utils";
export {
AddStatusReportUpdateInput,
+ type ComponentImpacts,
+ componentImpactsSchema,
CreateStatusReportInput,
DeleteStatusReportInput,
DeleteStatusReportUpdateInput,
diff --git a/packages/services/src/status-report/internal.ts b/packages/services/src/status-report/internal.ts
index b43311a5f..409994566 100644
--- a/packages/services/src/status-report/internal.ts
+++ b/packages/services/src/status-report/internal.ts
@@ -1,8 +1,10 @@
-import { and, desc, eq, inArray } from "@openstatus/db";
+import { and, asc, desc, eq, inArray, notInArray } from "@openstatus/db";
import {
+ type PageComponentImpact,
pageComponent,
statusReport,
statusReportUpdate,
+ statusReportUpdateToPageComponents,
statusReportsToPageComponents,
} from "@openstatus/db/src/schema";
@@ -89,6 +91,41 @@ export async function updatePageComponentAssociations(args: {
}
}
+/**
+ * Drop impact rows across all of a report's updates for components outside
+ * the given membership set — upholds the invariant that every impact row's
+ * component is in the report's membership (folds would resurrect them).
+ */
+export async function pruneImpactRowsOutsideMembership(args: {
+ tx: DB;
+ statusReportId: number;
+ componentIds: ReadonlyArray<number>;
+}): Promise<void> {
+ const { tx, statusReportId, componentIds } = args;
+ const reportUpdateIds = tx
+ .select({ id: statusReportUpdate.id })
+ .from(statusReportUpdate)
+ .where(eq(statusReportUpdate.statusReportId, statusReportId));
+
+ const onReportUpdates = inArray(
+ statusReportUpdateToPageComponents.statusReportUpdateId,
+ reportUpdateIds,
+ );
+
+ await tx
+ .delete(statusReportUpdateToPageComponents)
+ .where(
+ componentIds.length === 0
+ ? onReportUpdates
+ : and(
+ onReportUpdates,
+ notInArray(statusReportUpdateToPageComponents.pageComponentId, [
+ ...componentIds,
+ ]),
+ ),
+ );
+}
+
/** Load a status report by id, scoped to the workspace. Throws on miss. */
export async function getReportInWorkspace(args: {
tx: DB;
@@ -148,6 +185,113 @@ export async function getUpdatesForReport(tx: DB, statusReportId: number) {
.all();
}
+/** Stable ordering for audit snapshots — diffing is array-order-sensitive. */
+export function sortComponentImpacts<T extends { pageComponentId: number }>(
+ impacts: ReadonlyArray<T>,
+): T[] {
+ return [...impacts].sort((a, b) => a.pageComponentId - b.pageComponentId);
+}
+
+/**
+ * Audit snapshot for an update row + its impact rows. Every emitAudit
+ * before/after must go through this so key name and ordering never drift
+ * between snapshots — `changed_fields` diffs them across verbs.
+ */
+export function withComponentImpacts<
+ Row extends object,
+ Impact extends { pageComponentId: number },
+>(
+ row: Row,
+ impacts: ReadonlyArray<Impact>,
+): Row & { componentImpacts: Impact[] } {
+ return { ...row, componentImpacts: sortComponentImpacts(impacts) };
+}
+
+/** Same contract as withComponentImpacts, for report-level membership snapshots. */
+export function withPageComponentIds<Row extends object>(
+ row: Row,
+ pageComponentIds: ReadonlyArray<number>,
+): Row & { pageComponentIds: number[] } {
+ return {
+ ...row,
+ pageComponentIds: [...pageComponentIds].sort((a, b) => a - b),
+ };
+}
+
+/** Fetch the impact rows a single update set, sorted for snapshots. */
+export async function getComponentImpactsForUpdate(
+ tx: DB,
+ statusReportUpdateId: number,
+): Promise<{ pageComponentId: number; impact: PageComponentImpact }[]> {
+ const rows = await tx
+ .select({
+ pageComponentId: statusReportUpdateToPageComponents.pageComponentId,
+ impact: statusReportUpdateToPageComponents.impact,
+ })
+ .from(statusReportUpdateToPageComponents)
+ .where(
+ eq(
+ statusReportUpdateToPageComponents.statusReportUpdateId,
+ statusReportUpdateId,
+ ),
+ )
+ .all();
+ return sortComponentImpacts(rows);
+}
+
+/** Insert the impact rows an update sets. No-op on empty. */
+export async function insertUpdateComponentImpacts(args: {
+ tx: DB;
+ statusReportUpdateId: number;
+ componentImpacts: ReadonlyArray<{
+ pageComponentId: number;
+ impact: PageComponentImpact;
+ }>;
+}): Promise<void> {
+ const { tx, statusReportUpdateId, componentImpacts } = args;
+ if (componentImpacts.length === 0) return;
+
+ await tx.insert(statusReportUpdateToPageComponents).values(
+ componentImpacts.map(({ pageComponentId, impact }) => ({
+ statusReportUpdateId,
+ pageComponentId,
+ impact,
+ })),
+ );
+}
+
+/**
+ * Current impact per component: the latest update (by `date`, ties by id)
+ * that names it wins. Empty map ⇒ legacy report (no impact rows).
+ */
+export async function getCurrentImpactsForReport(
+ tx: DB,
+ statusReportId: number,
+): Promise<Map<number, PageComponentImpact>> {
+ const rows = await tx
+ .select({
+ pageComponentId: statusReportUpdateToPageComponents.pageComponentId,
+ impact: statusReportUpdateToPageComponents.impact,
+ })
+ .from(statusReportUpdateToPageComponents)
+ .innerJoin(
+ statusReportUpdate,
+ eq(
+ statusReportUpdateToPageComponents.statusReportUpdateId,
+ statusReportUpdate.id,
+ ),
+ )
+ .where(eq(statusReportUpdate.statusReportId, statusReportId))
+ .orderBy(asc(statusReportUpdate.date), asc(statusReportUpdate.id))
+ .all();
+
+ const current = new Map<number, PageComponentImpact>();
+ for (const row of rows) {
+ current.set(row.pageComponentId, row.impact);
+ }
+ return current;
+}
+
/** Fetch the associated component ids for a report. */
export async function getPageComponentIdsForReport(
tx: DB,
diff --git a/packages/services/src/status-report/list.ts b/packages/services/src/status-report/list.ts
index 53a5789b8..865b02a80 100644
--- a/packages/services/src/status-report/list.ts
+++ b/packages/services/src/status-report/list.ts
@@ -10,12 +10,14 @@ import {
sql,
} from "@openstatus/db";
import {
+ type PageComponentImpact,
pageComponent,
page as pageTable,
selectPageComponentSchema,
selectPageSchema,
statusReport,
statusReportUpdate,
+ statusReportUpdateToPageComponents,
statusReportsToPageComponents,
} from "@openstatus/db/src/schema";
@@ -46,8 +48,13 @@ function periodToSince(period: StatusReportListPeriod): Date {
}
}
+export type StatusReportUpdateWithImpacts = StatusReportUpdate & {
+ /** Impacts this update set; empty for legacy reports. */
+ componentImpacts: { pageComponentId: number; impact: PageComponentImpact }[];
+};
+
export type StatusReportWithRelations = StatusReport & {
- updates: StatusReportUpdate[];
+ updates: StatusReportUpdateWithImpacts[];
pageComponents: PageComponent[];
/** Flat list of associated component ids. Convenience for proto conversion. */
pageComponentIds: number[];
@@ -87,11 +94,50 @@ async function enrichReportsBatch(
.where(inArray(statusReportUpdate.statusReportId, reportIds))
.orderBy(desc(statusReportUpdate.date))
.all();
- const updatesByReport = new Map<number, StatusReportUpdate[]>();
+
+ // One query: all impact rows for all updates.
+ const updateIds = allUpdates.map((u) => u.id);
+ const impactRows =
+ updateIds.length > 0
+ ? await db
+ .select({
+ statusReportUpdateId:
+ statusReportUpdateToPageComponents.statusReportUpdateId,
+ pageComponentId: statusReportUpdateToPageComponents.pageComponentId,
+ impact: statusReportUpdateToPageComponents.impact,
+ })
+ .from(statusReportUpdateToPageComponents)
+ .where(
+ inArray(
+ statusReportUpdateToPageComponents.statusReportUpdateId,
+ updateIds,
+ ),
+ )
+ .all()
+ : [];
+ const impactsByUpdate = new Map<
+ number,
+ { pageComponentId: number; impact: PageComponentImpact }[]
+ >();
+ for (const row of impactRows) {
+ const arr = impactsByUpdate.get(row.statusReportUpdateId);
+ const entry = {
+ pageComponentId: row.pageComponentId,
+ impact: row.impact,
+ };
+ if (arr) arr.push(entry);
+ else impactsByUpdate.set(row.statusReportUpdateId, [entry]);
+ }
+
+ const updatesByReport = new Map<number, StatusReportUpdateWithImpacts[]>();
for (const u of allUpdates) {
+ const withImpacts = {
+ ...u,
+ componentImpacts: impactsByUpdate.get(u.id) ?? [],
+ };
const arr = updatesByReport.get(u.statusReportId);
- if (arr) arr.push(u);
- else updatesByReport.set(u.statusReportId, [u]);
+ if (arr) arr.push(withImpacts);
+ else updatesByReport.set(u.statusReportId, [withImpacts]);
}
// One query: all component associations joined to their components.
diff --git a/packages/services/src/status-report/schemas.ts b/packages/services/src/status-report/schemas.ts
index 5aa0ca418..0536ac115 100644
--- a/packages/services/src/status-report/schemas.ts
+++ b/packages/services/src/status-report/schemas.ts
@@ -1,9 +1,26 @@
-import { statusReportStatusSchema } from "@openstatus/db/src/schema";
+import {
+ pageComponentImpactSchema,
+ statusReportStatusSchema,
+} from "@openstatus/db/src/schema";
import { z } from "zod";
export { statusReportStatusSchema };
export type StatusReportStatus = z.infer<typeof statusReportStatusSchema>;
+export const componentImpactsSchema = z
+ .array(
+ z.object({
+ pageComponentId: z.number().int(),
+ impact: pageComponentImpactSchema,
+ }),
+ )
+ .refine(
+ (impacts) =>
+ new Set(impacts.map((i) => i.pageComponentId)).size === impacts.length,
+ { message: "Duplicate pageComponentId in componentImpacts." },
+ );
+export type ComponentImpacts = z.infer<typeof componentImpactsSchema>;
+
/** Periods supported by the status-report list filter — matches tRPC today. */
export const statusReportListPeriods = ["1d", "7d", "14d"] as const;
export type StatusReportListPeriod = (typeof statusReportListPeriods)[number];
@@ -16,6 +33,8 @@ export const CreateStatusReportInput = z.object({
date: z.coerce.date(),
pageId: z.number().int(),
pageComponentIds: z.array(z.number().int()).default([]),
+ /** Per-component impact set by the initial update. Absent ⇒ legacy report. */
+ componentImpacts: componentImpactsSchema.optional(),
});
export type CreateStatusReportInput = z.infer<typeof CreateStatusReportInput>;
@@ -33,6 +52,11 @@ export const AddStatusReportUpdateInput = z.object({
status: statusReportStatusSchema,
message: z.string(),
date: z.coerce.date().optional(),
+ /**
+ * Impact changes this update sets. Omitted components keep their prior
+ * impact; naming a component not yet on the report adds it to the report.
+ */
+ componentImpacts: componentImpactsSchema.optional(),
});
export type AddStatusReportUpdateInput = z.infer<
typeof AddStatusReportUpdateInput
@@ -43,6 +67,8 @@ export const UpdateStatusReportUpdateInput = z.object({
status: statusReportStatusSchema.optional(),
message: z.string().optional(),
date: z.coerce.date().optional(),
+ /** When provided, replaces the update's full impact-row set; omitted ⇒ untouched. */
+ componentImpacts: componentImpactsSchema.optional(),
});
export type UpdateStatusReportUpdateInput = z.infer<
typeof UpdateStatusReportUpdateInput
diff --git a/packages/services/src/status-report/update.ts b/packages/services/src/status-report/update.ts
index b13e0ed8e..a89f2ca0f 100644
--- a/packages/services/src/status-report/update.ts
+++ b/packages/services/src/status-report/update.ts
@@ -1,16 +1,27 @@
import { eq } from "@openstatus/db";
-import { statusReport, statusReportUpdate } from "@openstatus/db/src/schema";
+import {
+ statusReport,
+ statusReportUpdate,
+ statusReportUpdateToPageComponents,
+ statusReportsToPageComponents,
+} from "@openstatus/db/src/schema";
import { emitAudit } from "../audit";
import { requireScope } from "../auth";
import { type ServiceContext, withTransaction } from "../context";
-import { InternalServiceError } from "../errors";
+import { ConflictError, InternalServiceError } from "../errors";
import type { StatusReport, StatusReportUpdate } from "../types";
import {
+ getComponentImpactsForUpdate,
+ getPageComponentIdsForReport,
getReportInWorkspace,
getReportUpdateInWorkspace,
+ insertUpdateComponentImpacts,
+ pruneImpactRowsOutsideMembership,
updatePageComponentAssociations,
validatePageComponentIds,
+ withComponentImpacts,
+ withPageComponentIds,
} from "./internal";
import {
UpdateStatusReportInput,
@@ -42,6 +53,14 @@ export async function updateStatusReport(args: {
workspaceId: ctx.workspace.id,
});
+ // snapshot membership before/after so association-only edits still
+ // produce a visible audit diff (join-table change, not an entity field)
+ const beforeComponentIds = await getPageComponentIdsForReport(
+ tx,
+ report.id,
+ );
+ let afterComponentIds = beforeComponentIds;
+
const updateValues: Record<string, unknown> = { updatedAt: new Date() };
if (input.title !== undefined) updateValues.title = input.title;
if (input.status !== undefined) updateValues.status = input.status;
@@ -62,6 +81,12 @@ export async function updateStatusReport(args: {
statusReportId: report.id,
componentIds: validated.componentIds,
});
+ await pruneImpactRowsOutsideMembership({
+ tx,
+ statusReportId: report.id,
+ componentIds: validated.componentIds,
+ });
+ afterComponentIds = validated.componentIds;
}
const updated = await tx
@@ -81,15 +106,15 @@ export async function updateStatusReport(args: {
action: "status_report.update",
entityType: "status_report",
entityId: updated.id,
- before: report,
- after: updated,
+ before: withPageComponentIds(report, beforeComponentIds),
+ after: withPageComponentIds(updated, afterComponentIds),
});
return updated;
});
}
-/** Edit a single status-report update row (message / date / status). */
+/** Edit a single status-report update row (message / date / status / impacts). */
export async function updateStatusReportUpdate(args: {
ctx: ServiceContext;
input: UpdateStatusReportUpdateInput;
@@ -105,11 +130,67 @@ export async function updateStatusReportUpdate(args: {
workspaceId: ctx.workspace.id,
});
+ const beforeImpacts = await getComponentImpactsForUpdate(tx, existing.id);
+ const afterImpacts = input.componentImpacts ?? beforeImpacts;
+
const updateValues: Record<string, unknown> = { updatedAt: new Date() };
if (input.status !== undefined) updateValues.status = input.status;
if (input.message !== undefined) updateValues.message = input.message;
if (input.date !== undefined) updateValues.date = input.date;
+ // replace the update's impact-row set; omitted ⇒ untouched (legacy stays legacy)
+ if (input.componentImpacts !== undefined) {
+ const report = await getReportInWorkspace({
+ tx,
+ id: existing.statusReportId,
+ workspaceId: ctx.workspace.id,
+ });
+
+ if (input.componentImpacts.length > 0) {
+ const validated = await validatePageComponentIds({
+ tx,
+ workspaceId: ctx.workspace.id,
+ pageComponentIds: input.componentImpacts.map(
+ (ci) => ci.pageComponentId,
+ ),
+ });
+ if (
+ validated.pageId !== null &&
+ report.pageId !== null &&
+ validated.pageId !== report.pageId
+ ) {
+ throw new ConflictError(
+ `Components belong to page ${validated.pageId}, not the report's page ${report.pageId}.`,
+ );
+ }
+ // invariant: every impact row's component is in the report's membership
+ // set — editing impacts intentionally extends it (same as add-update)
+ await tx
+ .insert(statusReportsToPageComponents)
+ .values(
+ validated.componentIds.map((pageComponentId) => ({
+ statusReportId: report.id,
+ pageComponentId,
+ })),
+ )
+ .onConflictDoNothing();
+ }
+
+ await tx
+ .delete(statusReportUpdateToPageComponents)
+ .where(
+ eq(
+ statusReportUpdateToPageComponents.statusReportUpdateId,
+ existing.id,
+ ),
+ );
+ await insertUpdateComponentImpacts({
+ tx,
+ statusReportUpdateId: existing.id,
+ componentImpacts: input.componentImpacts,
+ });
+ }
+
const updated = await tx
.update(statusReportUpdate)
.set(updateValues)
@@ -127,8 +208,8 @@ export async function updateStatusReportUpdate(args: {
action: "status_report_update.update",
entityType: "status_report_update",
entityId: updated.id,
- before: existing,
- after: updated,
+ before: withComponentImpacts(existing, beforeImpacts),
+ after: withComponentImpacts(updated, afterImpacts),
});
return updated;
diff --git a/packages/services/src/status-report/utils.ts b/packages/services/src/status-report/utils.ts
new file mode 100644
index 000000000..c0035d6a7
--- /dev/null
+++ b/packages/services/src/status-report/utils.ts
@@ -0,0 +1,6 @@
+// dependency-free: imported by client bundles via the package subpath export.
+export function formatComponentImpacts(
+ impacts: readonly { pageComponentId: number; impact: string }[],
+): string[] {
+ return impacts.map((ci) => `${ci.pageComponentId} → ${ci.impact}`);
+}
diff --git a/packages/ui/registry.json b/packages/ui/registry.json
index c005d2d8b..853f59cb3 100644
--- a/packages/ui/registry.json
+++ b/packages/ui/registry.json
@@ -248,6 +248,7 @@
"status-timestamp",
"status-i18n",
"badge",
+ "hover-card",
"separator",
"tooltip"
],
diff --git a/packages/ui/src/components/blocks/status-bar.tsx b/packages/ui/src/components/blocks/status-bar.tsx
index a8af54877..e923d41c7 100644
--- a/packages/ui/src/components/blocks/status-bar.tsx
+++ b/packages/ui/src/components/blocks/status-bar.tsx
@@ -4,6 +4,7 @@ import { useStatusBlocksLabels } from "@openstatus/ui/components/blocks/status-i
import type {
StatusBarData,
StatusEventType,
+ StatusReportImpact,
StatusType,
} from "@openstatus/ui/components/blocks/status.types";
import { statusColors } from "@openstatus/ui/components/blocks/status.utils";
@@ -630,6 +631,7 @@ export function StatusBarCard({
key={`${item.day}-card-${cardIndex}`}
status={cardItem.status}
value={cardItem.value}
+ impact={cardItem.impact}
/>
);
})}
@@ -652,6 +654,7 @@ export function StatusBarCard({
from={event.from}
to={event.to}
isAggregated={event.isAggregated}
+ status={event.status}
/>
);
})}
@@ -723,9 +726,11 @@ StatusBarSkeleton.displayName = "StatusBarSkeleton";
function StatusBarContent({
status,
value,
+ impact,
}: {
status: StatusType;
value: string;
+ impact?: StatusReportImpact;
}) {
const labels = useStatusBlocksLabels();
return (
@@ -737,7 +742,11 @@ function StatusBarContent({
backgroundColor: statusColors[status],
}}
/>
- <div className="text-sm">{labels.requestStatus[status]}</div>
+ <div className="text-sm">
+ {impact
+ ? labels.componentImpact[impact]
+ : labels.requestStatus[status]}
+ </div>
</div>
<div className="text-muted-foreground ml-auto font-mono text-xs tracking-tight">
{value}
@@ -756,10 +765,9 @@ StatusBarContent.displayName = "StatusBarContent";
* - Date range (formatted as "Since", "Until", or "Jan 15 - Jan 16")
* - Duration (formatted as "2 hours", "ongoing", or "across 3 days" for multiple incidents)
*
- * The component automatically determines the status color based on the event type:
- * - incident → error (red)
- * - report → degraded (yellow)
- * - maintenance → info (blue)
+ * The component automatically determines the status color based on the event type
+ * (incident → error, report → degraded, maintenance → info) unless an explicit
+ * `status` is passed, e.g. the day's worst report impact.
*
* Returns null if no start date is provided.
*
@@ -802,18 +810,22 @@ export function StatusBarEvent({
to,
type,
isAggregated,
+ status: statusProp,
}: {
name: string;
from?: Date | null;
to?: Date | null;
type: StatusEventType;
isAggregated?: boolean;
+ /** Overrides the type-derived dot color (e.g. the day's worst report impact). */
+ status?: Exclude<StatusType, "empty">;
}) {
const labels = useStatusBlocksLabels();
if (!from) return null;
const status =
- type === "incident" ? "error" : type === "report" ? "degraded" : "info";
+ statusProp ??
+ (type === "incident" ? "error" : type === "report" ? "degraded" : "info");
return (
<div className="group relative text-sm" data-slot="status-bar-event">
diff --git a/packages/ui/src/components/blocks/status-events.tsx b/packages/ui/src/components/blocks/status-events.tsx
index 10d20cbb9..089658112 100644
--- a/packages/ui/src/components/blocks/status-events.tsx
+++ b/packages/ui/src/components/blocks/status-events.tsx
@@ -2,8 +2,17 @@
import { useStatusBlocksLabels } from "@openstatus/ui/components/blocks/status-i18n";
import { StatusTimestamp } from "@openstatus/ui/components/blocks/status-timestamp";
-import type { StatusReportUpdateType } from "@openstatus/ui/components/blocks/status.types";
+import type {
+ StatusReportImpact,
+ StatusReportUpdate,
+} from "@openstatus/ui/components/blocks/status.types";
+import { worstStatusReportImpact } from "@openstatus/ui/components/blocks/status.utils";
import { Badge } from "@openstatus/ui/components/ui/badge";
+import {
+ HoverCard,
+ HoverCardContent,
+ HoverCardTrigger,
+} from "@openstatus/ui/components/ui/hover-card";
import { Separator } from "@openstatus/ui/components/ui/separator";
import {
Tooltip,
@@ -358,10 +367,66 @@ export function StatusEventAside({
);
}
-interface StatusReportUpdate {
- date: Date;
- message: string;
- status: StatusReportUpdateType;
+const impactTextClasses: Record<StatusReportImpact, string> = {
+ operational: "text-success",
+ degraded_performance: "text-warning",
+ partial_outage: "text-warning",
+ major_outage: "text-destructive",
+};
+
+/**
+ * StatusEventTimelineImpact - Worst impact label for a timeline update
+ *
+ * Shows the most severe impact among the update's component changes. The label
+ * is a hover card trigger listing each component's explicit impact.
+ */
+export function StatusEventTimelineImpact({
+ changes,
+ className,
+ ...props
+}: React.ComponentProps<"button"> & {
+ changes: { name: string; impact: StatusReportImpact }[];
+}) {
+ const labels = useStatusBlocksLabels();
+ const worst = worstStatusReportImpact(changes.map((c) => c.impact));
+ return (
+ <HoverCard openDelay={100} closeDelay={100}>
+ <HoverCardTrigger asChild>
+ <button
+ type="button"
+ data-slot="status-event-timeline-impact"
+ className={cn(
+ "decoration-muted-foreground/30 hover:decoration-muted-foreground/60 font-mono text-xs font-medium underline decoration-dashed underline-offset-4",
+ impactTextClasses[worst],
+ className,
+ )}
+ {...props}
+ >
+ {labels.componentImpact[worst]}
+ </button>
+ </HoverCardTrigger>
+ <HoverCardContent align="start" className="w-auto min-w-48 p-3">
+ <div className="flex flex-col gap-1.5">
+ {changes.map((change, i) => (
+ <div
+ key={i}
+ className="flex items-center justify-between gap-4 text-xs"
+ >
+ <span className="truncate">{change.name}</span>
+ <span
+ className={cn(
+ "shrink-0 font-mono",
+ impactTextClasses[change.impact],
+ )}
+ >
+ {labels.componentImpact[change.impact]}
+ </span>
+ </div>
+ ))}
+ </div>
+ </HoverCardContent>
+ </HoverCard>
+ );
}
// ============================================================================
@@ -545,7 +610,15 @@ export function StatusEventTimelineReportUpdate({
<div className={cn(isLast ? "mb-0" : "mb-2")}>
<StatusEventTimelineTitle>
<span>{labels.incidentStatus[report.status]}</span>{" "}
- <span className="text-muted-foreground/70">·</span>{" "}
+ {report.impactChanges?.length ? (
+ <>
+ <span className="text-muted-foreground/70 mx-0.5">·</span>{" "}
+ <StatusEventTimelineImpact
+ changes={report.impactChanges}
+ />{" "}
+ </>
+ ) : null}
+ <span className="text-muted-foreground/70 mx-0.5">·</span>{" "}
<span className="text-muted-foreground font-mono text-xs">
<StatusTimestamp date={report.date} variant="rich" asChild>
<span>{labels.formatDateTime(report.date)}</span>
diff --git a/packages/ui/src/components/blocks/status-i18n.tsx b/packages/ui/src/components/blocks/status-i18n.tsx
index d64936c28..0610dcbb0 100644
--- a/packages/ui/src/components/blocks/status-i18n.tsx
+++ b/packages/ui/src/components/blocks/status-i18n.tsx
@@ -1,6 +1,7 @@
"use client";
import type {
+ StatusReportImpact,
StatusReportUpdateType,
StatusType,
ThemeValue,
@@ -20,6 +21,7 @@ export type StatusBlocksLabels = {
systemStatus: Record<StatusType, { long: string; short: string }>;
incidentStatus: Record<StatusReportUpdateType, string>;
requestStatus: Record<StatusType, string>;
+ componentImpact: Record<StatusReportImpact, string>;
today: string;
ongoing: string;
diff --git a/packages/ui/src/components/blocks/status.types.ts b/packages/ui/src/components/blocks/status.types.ts
index c4baff58c..ce3d8e9d3 100644
--- a/packages/ui/src/components/blocks/status.types.ts
+++ b/packages/ui/src/components/blocks/status.types.ts
@@ -6,6 +6,13 @@ export type StatusReportUpdateType =
| "monitoring"
| "resolved";
+// mirrors openstatus's `pageComponentImpact` taxonomy (this package doesn't depend on the db)
+export type StatusReportImpact =
+ | "operational"
+ | "degraded_performance"
+ | "partial_outage"
+ | "major_outage";
+
export const THEME_VALUES = ["light", "dark", "system"] as const;
export type ThemeValue = (typeof THEME_VALUES)[number];
@@ -13,6 +20,8 @@ export interface StatusReportUpdate {
date: Date;
message: string;
status: StatusReportUpdateType;
+ /** Per-component impact changes this update set. */
+ impactChanges?: { name: string; impact: StatusReportImpact }[];
}
export interface StatusReport {
@@ -46,6 +55,8 @@ export type StatusBarData = {
card: {
status: StatusType;
value: string;
+ /** Worst report impact of the day — refines the generic status label. */
+ impact?: StatusReportImpact;
}[];
events: {
id: number | string;
@@ -54,5 +65,7 @@ export type StatusBarData = {
from: Date | null;
to: Date | null;
isAggregated?: boolean;
+ /** Overrides the type-derived dot color (e.g. the day's worst report impact). */
+ status?: Exclude<StatusType, "empty">;
}[];
};
diff --git a/packages/ui/src/components/blocks/status.utils.ts b/packages/ui/src/components/blocks/status.utils.ts
index b721b3d3c..2ce7b98fc 100644
--- a/packages/ui/src/components/blocks/status.utils.ts
+++ b/packages/ui/src/components/blocks/status.utils.ts
@@ -121,6 +121,7 @@ export function formatTime(date: Date, locale = "en-US") {
}
import type {
+ StatusReportImpact,
StatusReportUpdateType,
StatusType,
} from "@openstatus/ui/components/blocks/status.types";
@@ -194,6 +195,39 @@ export const requestStatusLabels: Record<StatusType, string> = {
*/
export const requests = requestStatusLabels;
+/**
+ * Component impact labels
+ * Used for displaying per-component report impacts
+ */
+export const componentImpactLabels: Record<StatusReportImpact, string> = {
+ operational: "Operational",
+ degraded_performance: "Degraded performance",
+ partial_outage: "Partial outage",
+ major_outage: "Major outage",
+} as const;
+
+// ordered worst-last so worstImpact can compare by index (mirrors the db's `pageComponentImpact`)
+export const statusReportImpacts: readonly StatusReportImpact[] = [
+ "operational",
+ "degraded_performance",
+ "partial_outage",
+ "major_outage",
+] as const;
+
+export function worstStatusReportImpact(
+ impacts: Iterable<StatusReportImpact>,
+): StatusReportImpact {
+ let worst: StatusReportImpact = "operational";
+ for (const impact of impacts) {
+ if (
+ statusReportImpacts.indexOf(impact) > statusReportImpacts.indexOf(worst)
+ ) {
+ worst = impact;
+ }
+ }
+ return worst;
+}
+
/**
* Incident status labels
* Used for displaying incident report update statuses
@@ -237,6 +271,7 @@ export const defaultStatusBlocksLabels = {
systemStatus: systemStatusLabels,
incidentStatus: incidentStatusLabels,
requestStatus: requestStatusLabels,
+ componentImpact: componentImpactLabels,
today: "Today",
ongoing: "Ongoing",