Skip to content

Open-source status page, incident response and uptime monitoring

feat: add user reports for external statuses (#2254)

Colin Ozanne32d4876a4096
diff --git a/apps/web/src/app/(landing)/status/[id]/[component]/component-detail.tsx b/apps/web/src/app/(landing)/status/[id]/[component]/component-detail.tsx
index 0af5a4d57..6e6d88db9 100644
--- a/apps/web/src/app/(landing)/status/[id]/[component]/component-detail.tsx
+++ b/apps/web/src/app/(landing)/status/[id]/[component]/component-detail.tsx
@@ -1,5 +1,7 @@
"use client";
+import { REPORT_WINDOW_MINUTES } from "@openstatus/api/src/router/effective-status";
+
import {
ContentBoxDescription,
ContentBoxLink,
@@ -19,6 +21,7 @@ import { api } from "@/trpc/rq-client";
import { ExternalServicePill } from "../../external-service-pill";
import { formatRelative } from "../../utils";
import { HistoryBars } from "../history-bars";
+import { ReportIssue } from "../report-issue";
function answerFor(args: {
fullName: string;
@@ -28,7 +31,7 @@ function answerFor(args: {
}): string {
const { fullName, indicator, status, stale } = args;
if (stale) {
- return `We don't have live data for ${fullName} right now — check the official status page below.`;
+ return `We don't have live data for ${fullName} right now. Check the official status page below.`;
}
if (status === "under_maintenance") {
return `${fullName} is currently undergoing scheduled maintenance.`;
@@ -41,9 +44,9 @@ function answerFor(args: {
case "major":
return `Yes, ${fullName} is experiencing a partial outage right now.`;
case "critical":
- return `Yes, ${fullName} is down — a major outage is currently affecting it.`;
+ return `Yes, ${fullName} is down. A major outage is currently affecting it.`;
default:
- return `The current status of ${fullName} is unknown — check the official status page below.`;
+ return `The current status of ${fullName} is unknown. Check the official status page below.`;
}
}
@@ -107,7 +110,7 @@ function OtherComponents({
serviceName: string;
currentSlug: string;
}) {
- // days:1 — this sibling nav only uses slug/name, so fetch the minimum history.
+ // days:1 keeps history minimal; this sibling nav only uses slug/name.
const { data } = api.externalService.components.useQuery({
slug: serviceSlug,
days: 1,
@@ -187,6 +190,7 @@ export function ComponentDetail({
indicator={component.indicator}
status={component.status}
statusMessage={component.description ?? undefined}
+ escalated={component.escalated}
/>
{component.lastFetchedAt > 0 ? (
<span className="text-muted-foreground text-sm">
@@ -208,10 +212,25 @@ export function ComponentDetail({
</a>
</div>
+ <div className="not-prose mt-6 flex flex-col gap-2">
+ <ReportIssue
+ slug={service.slug}
+ name={`${service.name} ${component.name}`}
+ componentSlug={component.slug}
+ />
+ {component.reporters > 0 ? (
+ <p className="text-muted-foreground text-sm">
+ {component.reporters} user{" "}
+ {component.reporters === 1 ? "report" : "reports"} for{" "}
+ {component.name} in the last {REPORT_WINDOW_MINUTES} minutes.
+ </p>
+ ) : null}
+ </div>
+
{component.description ? <p>{component.description}</p> : null}
<h2>
- {component.name} uptime — last {days} days
+ {component.name} uptime over the last {days} days
</h2>
<div className="not-prose">
<HistoryBars daily={history} days={days} />
diff --git a/apps/web/src/app/(landing)/status/[id]/page.tsx b/apps/web/src/app/(landing)/status/[id]/page.tsx
index 1f84ec7f5..004704c5e 100644
--- a/apps/web/src/app/(landing)/status/[id]/page.tsx
+++ b/apps/web/src/app/(landing)/status/[id]/page.tsx
@@ -1,9 +1,11 @@
+import { REPORT_WINDOW_MINUTES } from "@openstatus/api/src/router/effective-status";
import type { Metadata } from "next";
import { notFound, permanentRedirect } from "next/navigation";
import { Suspense } from "react";
import { ButtonLink } from "@/content/mdx-components/button-link";
import { CustomLink } from "@/content/mdx-components/custom-link";
+import { getServiceEscalation } from "@/lib/external-report-escalation";
import { cachedGetExternalServiceBySlug } from "@/lib/external-service-cache";
import {
APP_URL,
@@ -34,8 +36,14 @@ export async function generateMetadata(args: {
const service = await cachedGetExternalServiceBySlug(id);
if (!service) return { ...defaultMetadata, title: "Not Found" };
- const title = `Is ${service.name} Down? ${service.name} Status & Incidents`;
- const description = `Is ${service.name} down right now? Check the live ${service.name} status, uptime over the last ${HISTORY_DAYS} days, and recent ${service.name} incidents tracked by OpenStatus.`;
+ const { escalated } = await getServiceEscalation(service);
+
+ const title = escalated
+ ? `Users reporting issues with ${service.name}. ${service.name} Status & Incidents`
+ : `Is ${service.name} Down? ${service.name} Status & Incidents`;
+ const description = escalated
+ ? `Users are reporting problems with ${service.name} in the last ${REPORT_WINDOW_MINUTES} minutes. Check the live ${service.name} status, uptime over the last ${HISTORY_DAYS} days, and recent ${service.name} incidents tracked by OpenStatus.`
+ : `Is ${service.name} down right now? Check the live ${service.name} status, uptime over the last ${HISTORY_DAYS} days, and recent ${service.name} incidents tracked by OpenStatus.`;
const canonicalUrl = `${BASE_URL}/status/${service.slug}`;
const ogImage = `${BASE_URL}/api/og/external-service?slug=${encodeURIComponent(service.slug)}`;
const indexable = service.deletedAt == null;
@@ -86,6 +94,10 @@ export default async function Page(args: { params: Promise<RouteParams> }) {
slug: service.slug,
days: HISTORY_DAYS,
}),
+ api.externalService.reports.prefetch({
+ slug: service.slug,
+ days: HISTORY_DAYS,
+ }),
]);
return (
diff --git a/apps/web/src/app/(landing)/status/[id]/report-issue.tsx b/apps/web/src/app/(landing)/status/[id]/report-issue.tsx
new file mode 100644
index 000000000..183ebea88
--- /dev/null
+++ b/apps/web/src/app/(landing)/status/[id]/report-issue.tsx
@@ -0,0 +1,117 @@
+"use client";
+
+import { Button } from "@openstatus/ui/components/ui/button";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@openstatus/ui/components/ui/select";
+import { useState } from "react";
+
+import { api } from "@/trpc/rq-client";
+
+const WHOLE_SERVICE = "all";
+
+function Box({ children }: { children: React.ReactNode }) {
+ return (
+ <div className="not-prose bg-muted/20 flex flex-col gap-3 border px-4 py-3 lg:flex-row lg:items-center lg:justify-between">
+ {children}
+ </div>
+ );
+}
+
+export function ReportIssue({
+ slug,
+ name,
+ days,
+ componentSlug,
+ allowComponentSelect,
+}: {
+ slug: string;
+ name: string;
+ days?: number;
+ componentSlug?: string;
+ allowComponentSelect?: boolean;
+}) {
+ const utils = api.useUtils();
+ const [selected, setSelected] = useState<string>(WHOLE_SERVICE);
+ const mutation = api.externalService.report.useMutation({
+ onSuccess: () => {
+ utils.externalService.reports.invalidate({ slug });
+ utils.externalService.detail.invalidate({ slug });
+ utils.externalService.component.invalidate({ serviceSlug: slug });
+ utils.externalService.grid.invalidate();
+ },
+ });
+
+ const components = api.externalService.components.useQuery(
+ { slug, days },
+ { enabled: Boolean(allowComponentSelect) },
+ );
+ const componentOptions =
+ allowComponentSelect && components.data?.supported
+ ? components.data.components
+ : [];
+
+ if (mutation.isSuccess) {
+ return (
+ <Box>
+ <p className="text-muted-foreground m-0! text-sm" role="status">
+ {mutation.data.alreadyReported
+ ? "You've already reported this recently. Thanks!"
+ : `Thanks! Your report for ${name} was recorded.`}
+ </p>
+ </Box>
+ );
+ }
+
+ const onClick = () => {
+ const component =
+ componentSlug ?? (selected === WHOLE_SERVICE ? undefined : selected);
+ mutation.mutate({ slug, componentSlug: component });
+ };
+
+ return (
+ <Box>
+ <div className="text-sm">
+ <p className="m-0! font-medium">Seeing problems with {name}?</p>
+ <p className="text-muted-foreground m-0!">
+ Report it so other users know. We'll flag it when enough people do.
+ </p>
+ </div>
+ <div className="flex flex-wrap items-center gap-2 lg:shrink-0">
+ {componentOptions.length > 0 ? (
+ <Select value={selected} onValueChange={setSelected}>
+ <SelectTrigger className="w-[200px] rounded-none">
+ <SelectValue placeholder="Which area? (optional)" />
+ </SelectTrigger>
+ <SelectContent className="rounded-none">
+ <SelectItem value={WHOLE_SERVICE} className="rounded-none">
+ Whole service
+ </SelectItem>
+ {componentOptions.map((c) => (
+ <SelectItem
+ key={c.slug}
+ value={c.slug}
+ className="rounded-none"
+ >
+ {c.name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ ) : null}
+ <Button
+ variant="default"
+ className="rounded-none"
+ disabled={mutation.isPending}
+ onClick={onClick}
+ >
+ {mutation.isPending ? "Reporting…" : "Report a problem"}
+ </Button>
+ </div>
+ </Box>
+ );
+}
diff --git a/apps/web/src/app/(landing)/status/[id]/service-detail.tsx b/apps/web/src/app/(landing)/status/[id]/service-detail.tsx
index a5037b127..7a92deb7d 100644
--- a/apps/web/src/app/(landing)/status/[id]/service-detail.tsx
+++ b/apps/web/src/app/(landing)/status/[id]/service-detail.tsx
@@ -17,7 +17,9 @@ import { ExternalServicePill } from "../external-service-pill";
import { formatRelative, getStatusAnswer, isStale } from "../utils";
import { HistoryBars } from "./history-bars";
import { Incidents } from "./incidents";
+import { ReportIssue } from "./report-issue";
import { ServiceComponents } from "./service-components";
+import { UserReports } from "./user-reports";
function jsonLd(args: {
serviceName: string;
@@ -43,10 +45,11 @@ function jsonLd(args: {
export function ServiceDetail({ slug, days }: { slug: string; days: number }) {
const [data] = api.externalService.detail.useSuspenseQuery({ slug, days });
- const { service, latest, history } = data;
+ const { service, latest, history, effective } = data;
- const indicator = latest?.indicator ?? "";
- const status = latest?.status ?? "";
+ const indicator = effective.indicator;
+ const status = effective.status;
+ const escalated = effective.escalated;
const statusMessage = latest?.statusMessage || undefined;
const fetchedAt = latest?.lastFetchedAt ?? 0;
const stale = fetchedAt > 0 && isStale(fetchedAt);
@@ -79,6 +82,7 @@ export function ServiceDetail({ slug, days }: { slug: string; days: number }) {
indicator={indicator}
status={status}
statusMessage={statusMessage}
+ escalated={escalated}
/>
{fetchedAt > 0 ? (
<span className="text-muted-foreground text-sm">
@@ -91,7 +95,7 @@ export function ServiceDetail({ slug, days }: { slug: string; days: number }) {
</span>
) : (
<span className="text-muted-foreground text-sm">
- No data yet — tracking begins after first poll.
+ No data yet. Tracking begins after the first poll.
</span>
)}
<a
@@ -104,8 +108,25 @@ export function ServiceDetail({ slug, days }: { slug: string; days: number }) {
</a>
</div>
+ <div className="not-prose mt-6">
+ <ReportIssue
+ slug={service.slug}
+ name={service.name}
+ days={days}
+ allowComponentSelect
+ />
+ </div>
+
+ <Suspense fallback={null}>
+ <UserReports
+ slug={service.slug}
+ serviceName={service.name}
+ days={days}
+ />
+ </Suspense>
+
<h2>
- {service.name} uptime — last {days} days
+ {service.name} uptime over the last {days} days
</h2>
<div className="not-prose">
<HistoryBars daily={history} days={days} />
diff --git a/apps/web/src/app/(landing)/status/[id]/user-reports.tsx b/apps/web/src/app/(landing)/status/[id]/user-reports.tsx
new file mode 100644
index 000000000..dd7c92915
--- /dev/null
+++ b/apps/web/src/app/(landing)/status/[id]/user-reports.tsx
@@ -0,0 +1,110 @@
+"use client";
+
+import { REPORT_WINDOW_MINUTES } from "@openstatus/api/src/router/effective-status";
+import {
+ type ChartConfig,
+ ChartContainer,
+ ChartTooltip,
+ ChartTooltipContent,
+} from "@openstatus/ui/components/ui/chart";
+import { Bar, BarChart, XAxis } from "recharts";
+
+import { api } from "@/trpc/rq-client";
+
+const chartConfig = {
+ total: { label: "Reports", color: "var(--color-warning)" },
+} satisfies ChartConfig;
+
+function countries(n: number): string {
+ if (n <= 0) return "";
+ return ` from ${n} ${n === 1 ? "country" : "countries"}`;
+}
+
+function buildSeries(
+ daily: { day: string; total: number }[],
+ days: number,
+): { day: string; total: number }[] {
+ const byDay = new Map(daily.map((d) => [d.day.slice(0, 10), d.total]));
+ const today = new Date();
+ today.setUTCHours(0, 0, 0, 0);
+ return Array.from({ length: days }, (_, i) => {
+ const d = new Date(today);
+ d.setUTCDate(d.getUTCDate() - (days - 1 - i));
+ const key = d.toISOString().slice(0, 10);
+ return { day: key, total: byDay.get(key) ?? 0 };
+ });
+}
+
+export function UserReports({
+ slug,
+ serviceName,
+ days,
+}: {
+ slug: string;
+ serviceName: string;
+ days: number;
+}) {
+ const [data] = api.externalService.reports.useSuspenseQuery({ slug, days });
+ const { window: win, threshold, daily, topCountries } = data;
+
+ const series = buildSeries(daily, days);
+ const hasDaily = daily.some((d) => d.total > 0);
+
+ if (win.reporters === 0 && !hasDaily) return null;
+
+ const active = win.reporters >= threshold;
+
+ return (
+ <>
+ <h2>{serviceName} user reports</h2>
+ <div className="not-prose flex flex-col gap-3">
+ {active ? (
+ <div className="border-warning/30 bg-warning/10 text-warning border px-3 py-2 text-sm">
+ Users are reporting problems with {serviceName}: {win.reporters} in
+ the last {REPORT_WINDOW_MINUTES} minutes{countries(win.countries)}.
+ </div>
+ ) : (
+ <p className="text-muted-foreground m-0! text-sm">
+ {win.reporters} user {win.reporters === 1 ? "report" : "reports"} in
+ the last {REPORT_WINDOW_MINUTES} minutes{countries(win.countries)}.
+ </p>
+ )}
+
+ {hasDaily ? (
+ <ChartContainer config={chartConfig} className="h-9 w-full">
+ <BarChart
+ accessibilityLayer
+ data={series}
+ barCategoryGap={1}
+ margin={{ top: 1, right: 0, bottom: 0, left: 0 }}
+ >
+ <ChartTooltip
+ cursor={false}
+ content={
+ <ChartTooltipContent indicator="line" labelKey="day" />
+ }
+ />
+ <Bar
+ dataKey="total"
+ fill="var(--color-total)"
+ fillOpacity={0.7}
+ minPointSize={(value) => ((value ?? 0) > 0 ? 2 : 1)}
+ />
+ <XAxis dataKey="day" hide />
+ </BarChart>
+ </ChartContainer>
+ ) : null}
+
+ {topCountries.length > 0 ? (
+ <div className="text-muted-foreground flex flex-wrap gap-2 text-xs">
+ {topCountries.map((c) => (
+ <span key={c.country} className="inline-flex border px-2 py-0.5">
+ {c.country} · {c.total}
+ </span>
+ ))}
+ </div>
+ ) : null}
+ </div>
+ </>
+ );
+}
diff --git a/apps/web/src/app/(landing)/status/external-service-components.tsx b/apps/web/src/app/(landing)/status/external-service-components.tsx
index 527488b75..c000140b7 100644
--- a/apps/web/src/app/(landing)/status/external-service-components.tsx
+++ b/apps/web/src/app/(landing)/status/external-service-components.tsx
@@ -62,8 +62,8 @@ function isIssue(component: ExternalServiceComponentItem): boolean {
return severityOf(component.indicator) > 0;
}
-// Maintenance maps to indicator "none" (severity 0), so it is not an issue —
-// count it separately or a maintenance-only section reads "All operational".
+// Maintenance maps to indicator "none" (severity 0), so it is not an issue.
+// Count it separately or a maintenance-only section reads "All operational".
function isMaintenance(component: ExternalServiceComponentItem): boolean {
return component.status === "under_maintenance";
}
diff --git a/apps/web/src/app/(landing)/status/external-service-pill.tsx b/apps/web/src/app/(landing)/status/external-service-pill.tsx
index 2c23a9ea6..e5bcb8616 100644
--- a/apps/web/src/app/(landing)/status/external-service-pill.tsx
+++ b/apps/web/src/app/(landing)/status/external-service-pill.tsx
@@ -9,9 +9,13 @@ export type ExternalServicePillProps = {
indicator: string;
status: string;
statusMessage?: string;
+ escalated?: boolean;
className?: string;
};
+const ESCALATED_TITLE =
+ "This status is raised by user reports; the provider has not reported an issue.";
+
type PillStyle = {
label: string;
className: string;
@@ -58,10 +62,11 @@ export function ExternalServicePill({
indicator,
status,
statusMessage,
+ escalated,
className,
}: ExternalServicePillProps) {
const pill = getPillStyle({ indicator, status });
- const body = (
+ const pillSpan = (
<span
className={cn(
"inline-flex items-center rounded-none border px-2.5 py-0.5 text-xs font-medium",
@@ -73,12 +78,26 @@ export function ExternalServicePill({
</span>
);
- if (!statusMessage) return body;
-
- return (
+ const pillWithMessage = statusMessage ? (
<Tooltip>
- <TooltipTrigger asChild>{body}</TooltipTrigger>
+ <TooltipTrigger asChild>{pillSpan}</TooltipTrigger>
<TooltipContent className="rounded-none">{statusMessage}</TooltipContent>
</Tooltip>
+ ) : (
+ pillSpan
+ );
+
+ if (!escalated) return pillWithMessage;
+
+ return (
+ <span className="inline-flex items-center gap-1.5">
+ {pillWithMessage}
+ <span
+ title={ESCALATED_TITLE}
+ className="border-warning/30 text-warning inline-flex items-center rounded-none border px-1.5 py-0.5 text-[10px] font-medium tracking-wide uppercase"
+ >
+ user-reported
+ </span>
+ </span>
);
}
diff --git a/apps/web/src/app/(landing)/status/external-status-grid.tsx b/apps/web/src/app/(landing)/status/external-status-grid.tsx
index a4f1a6d0d..070b4dcb3 100644
--- a/apps/web/src/app/(landing)/status/external-status-grid.tsx
+++ b/apps/web/src/app/(landing)/status/external-status-grid.tsx
@@ -43,6 +43,7 @@ export function ExternalStatusGrid() {
indicator={service.indicator}
status={service.status}
statusMessage={service.statusMessage || undefined}
+ escalated={service.escalated}
className="self-start"
/>
</ContentBoxLink>
diff --git a/apps/web/src/app/(landing)/status/utils.ts b/apps/web/src/app/(landing)/status/utils.ts
index 554639598..bdcfd5d25 100644
--- a/apps/web/src/app/(landing)/status/utils.ts
+++ b/apps/web/src/app/(landing)/status/utils.ts
@@ -17,7 +17,7 @@ export function isStale(fetchedAtMs: number): boolean {
return Date.now() - fetchedAtMs > STALE_THRESHOLD_MS;
}
-// Natural-language answer to "Is <name> down?" — used both as on-page lead copy
+// Natural-language answer to "Is <name> down?", used both as on-page lead copy
// and as the FAQPage answer in JSON-LD. Mirrors getPillStyle semantics.
export function getStatusAnswer(args: {
name: string;
@@ -27,7 +27,7 @@ export function getStatusAnswer(args: {
}): string {
const { name, indicator, status, hasLiveData } = args;
if (!hasLiveData) {
- return `We don't have live data for ${name} right now — check the official ${name} status page below.`;
+ return `We don't have live data for ${name} right now. Check the official ${name} status page below.`;
}
if (status === "under_maintenance") {
return `${name} is currently undergoing scheduled maintenance.`;
@@ -40,8 +40,8 @@ export function getStatusAnswer(args: {
case "major":
return `Yes, ${name} is experiencing a partial outage right now.`;
case "critical":
- return `Yes, ${name} is down — a major outage is currently affecting ${name}.`;
+ return `Yes, ${name} is down. A major outage is currently affecting ${name}.`;
default:
- return `The current status of ${name} is unknown — check the official ${name} status page below.`;
+ return `The current status of ${name} is unknown. Check the official ${name} status page below.`;
}
}
diff --git a/apps/web/src/app/api/og/external-service/route.tsx b/apps/web/src/app/api/og/external-service/route.tsx
index e148fb146..e89a7c307 100644
--- a/apps/web/src/app/api/og/external-service/route.tsx
+++ b/apps/web/src/app/api/og/external-service/route.tsx
@@ -2,7 +2,10 @@ import { OSTinybird, safePipeData } from "@openstatus/tinybird";
import { ImageResponse } from "next/og";
import { isStale } from "@/app/(landing)/status/utils";
-import { env } from "@/env";
+import {
+ getComponentEscalation,
+ getServiceEscalation,
+} from "@/lib/external-report-escalation";
import {
cachedGetExternalComponentBySlug,
cachedGetExternalServiceBySlug,
@@ -111,15 +114,20 @@ export async function GET(req: Request) {
if (componentResult?.service && componentResult.component) {
const { service, component } = componentResult;
isDetail = true;
+ const esc = await getComponentEscalation({
+ serviceId: service.id,
+ componentId: component.id,
+ indicator: component.indicator,
+ status: component.status,
+ });
const content = component.stale
? UNKNOWN
- : getStatus({
- indicator: component.indicator,
- status: component.status,
- });
+ : getStatus({ indicator: esc.indicator, status: esc.status });
category = content.label;
categoryDot = content.bg;
- title = `Is ${service.name} ${component.name} down?`;
+ title = esc.escalated
+ ? `Users reporting issues with ${service.name} ${component.name}`
+ : `Is ${service.name} ${component.name} down?`;
description = "";
footer = `${FOOTER}/${service.slug}/${component.slug}`;
} else {
@@ -131,34 +139,21 @@ export async function GET(req: Request) {
const services = await cachedListExternalServices();
category = "external status";
title = INDEX_TITLE;
- description = `${services.length} providers monitored — ${INDEX_DESCRIPTION}`;
+ description = `${services.length} providers monitored. ${INDEX_DESCRIPTION}`;
footer = FOOTER;
} else {
isDetail = true;
- const aliasSlugs = Array.isArray(service.aliases) ? service.aliases : [];
- const slugChain = [service.slug, ...aliasSlugs];
-
- const tb = new OSTinybird(env.TINY_BIRD_API_KEY);
- const latestRes = await safePipeData(
- tb.externalStatusLatest({ ids: slugChain }),
- "externalStatusLatest (og)",
- );
- const latestRows = Array.isArray(latestRes.data) ? latestRes.data : [];
- latestRows.sort((a, b) => b.last_fetched_at - a.last_fetched_at);
- const latest = latestRows[0];
-
- const fetchedAt = latest?.last_fetched_at ?? 0;
- const stale = fetchedAt === 0 || isStale(fetchedAt);
+ const esc = await getServiceEscalation(service);
+ const stale = esc.lastFetchedAt === 0 || isStale(esc.lastFetchedAt);
const content = stale
? UNKNOWN
- : getStatus({
- indicator: latest?.indicator ?? "",
- status: latest?.status ?? "",
- });
+ : getStatus({ indicator: esc.indicator, status: esc.status });
category = content.label;
categoryDot = content.bg;
- title = `Is ${service.name} down?`;
+ title = esc.escalated
+ ? `Users reporting issues with ${service.name}`
+ : `Is ${service.name} down?`;
description = "";
footer = `${FOOTER}/${service.slug}`;
}
diff --git a/apps/web/src/lib/external-report-escalation.ts b/apps/web/src/lib/external-report-escalation.ts
new file mode 100644
index 000000000..3c6b07166
--- /dev/null
+++ b/apps/web/src/lib/external-report-escalation.ts
@@ -0,0 +1,105 @@
+import {
+ REPORT_THRESHOLD,
+ REPORT_WINDOW_MS,
+ computeEffectiveStatus,
+} from "@openstatus/api/src/router/effective-status";
+import {
+ getComponentReportWindows,
+ getServiceReportWindows,
+} from "@openstatus/services/external-service-report";
+import { OSTinybird, safePipeData } from "@openstatus/tinybird";
+
+import { env } from "@/env";
+
+const tb = new OSTinybird(env.TINY_BIRD_API_KEY);
+
+type EscalationInput = {
+ id: number;
+ slug: string;
+ aliases: unknown;
+};
+
+export type ServiceEscalation = {
+ indicator: string;
+ status: string;
+ escalated: boolean;
+ reporters: number;
+ threshold: number;
+ lastFetchedAt: number;
+};
+
+async function serviceReporters(
+ serviceId: number,
+ since: Date,
+): Promise<number> {
+ try {
+ const rows = await getServiceReportWindows({
+ serviceIds: [serviceId],
+ since,
+ });
+ return rows[0]?.reporters ?? 0;
+ } catch (err) {
+ console.error("[escalation] service reporters read failed:", err);
+ return 0;
+ }
+}
+
+export async function getServiceEscalation(
+ service: EscalationInput,
+): Promise<ServiceEscalation> {
+ const aliasSlugs = Array.isArray(service.aliases) ? service.aliases : [];
+ const slugChain = [service.slug, ...aliasSlugs];
+ const since = new Date(Date.now() - REPORT_WINDOW_MS);
+
+ const [latestRes, reporters] = await Promise.all([
+ safePipeData(
+ tb.externalStatusLatest({ ids: slugChain }),
+ "externalStatusLatest (escalation)",
+ ),
+ serviceReporters(service.id, since),
+ ]);
+
+ const latestRows = [...latestRes.data].sort(
+ (a, b) => b.last_fetched_at - a.last_fetched_at,
+ );
+ const latest = latestRows[0];
+ const effective = computeEffectiveStatus({
+ providerIndicator: latest?.indicator ?? "",
+ providerStatus: latest?.status ?? "",
+ reporters,
+ threshold: REPORT_THRESHOLD,
+ });
+
+ return {
+ ...effective,
+ reporters,
+ threshold: REPORT_THRESHOLD,
+ lastFetchedAt: latest?.last_fetched_at ?? 0,
+ };
+}
+
+export async function getComponentEscalation(args: {
+ serviceId: number;
+ componentId: number;
+ indicator: string;
+ status: string;
+}): Promise<{ indicator: string; status: string; escalated: boolean }> {
+ const since = new Date(Date.now() - REPORT_WINDOW_MS);
+ let reporters = 0;
+ try {
+ const rows = await getComponentReportWindows({
+ serviceId: args.serviceId,
+ since,
+ });
+ reporters =
+ rows.find((r) => r.componentId === args.componentId)?.reporters ?? 0;
+ } catch (err) {
+ console.error("[escalation] component reporters read failed:", err);
+ }
+ return computeEffectiveStatus({
+ providerIndicator: args.indicator,
+ providerStatus: args.status,
+ reporters,
+ threshold: REPORT_THRESHOLD,
+ });
+}
diff --git a/packages/api/src/env.ts b/packages/api/src/env.ts
index 6d995fa2d..a7c67f813 100644
--- a/packages/api/src/env.ts
+++ b/packages/api/src/env.ts
@@ -13,6 +13,7 @@ export const env = createEnv({
UNKEY_TOKEN: z.string(),
UNKEY_API_ID: z.string(),
SLACK_FEEDBACK_WEBHOOK_URL: z.string().optional(),
+ EXTERNAL_REPORT_SALT: z.string().optional(),
},
runtimeEnv: {
@@ -26,6 +27,7 @@ export const env = createEnv({
UNKEY_TOKEN: process.env.UNKEY_TOKEN,
UNKEY_API_ID: process.env.UNKEY_API_ID,
SLACK_FEEDBACK_WEBHOOK_URL: process.env.SLACK_FEEDBACK_WEBHOOK_URL,
+ EXTERNAL_REPORT_SALT: process.env.EXTERNAL_REPORT_SALT,
},
skipValidation: process.env.NODE_ENV === "test",
});
diff --git a/packages/api/src/router/effective-status.test.ts b/packages/api/src/router/effective-status.test.ts
new file mode 100644
index 000000000..fcd2fcec6
--- /dev/null
+++ b/packages/api/src/router/effective-status.test.ts
@@ -0,0 +1,55 @@
+import { describe, expect, test } from "bun:test";
+
+import { computeEffectiveStatus } from "./effective-status";
+
+describe("computeEffectiveStatus", () => {
+ test("escalates operational to minor at/above threshold", () => {
+ const result = computeEffectiveStatus({
+ providerIndicator: "none",
+ providerStatus: "operational",
+ reporters: 7,
+ threshold: 7,
+ });
+ expect(result).toEqual({
+ indicator: "minor",
+ status: "operational",
+ escalated: true,
+ });
+ });
+
+ test("does not escalate below threshold", () => {
+ const result = computeEffectiveStatus({
+ providerIndicator: "none",
+ providerStatus: "operational",
+ reporters: 6,
+ threshold: 7,
+ });
+ expect(result.escalated).toBe(false);
+ expect(result.indicator).toBe("none");
+ });
+
+ test("never lowers or alters a provider status already at/above minor", () => {
+ const result = computeEffectiveStatus({
+ providerIndicator: "major",
+ providerStatus: "partial_outage",
+ reporters: 100,
+ threshold: 7,
+ });
+ expect(result).toEqual({
+ indicator: "major",
+ status: "partial_outage",
+ escalated: false,
+ });
+ });
+
+ test("does not escalate during maintenance", () => {
+ const result = computeEffectiveStatus({
+ providerIndicator: "none",
+ providerStatus: "under_maintenance",
+ reporters: 100,
+ threshold: 7,
+ });
+ expect(result.escalated).toBe(false);
+ expect(result.indicator).toBe("none");
+ });
+});
diff --git a/packages/api/src/router/effective-status.ts b/packages/api/src/router/effective-status.ts
new file mode 100644
index 000000000..edb451c5c
--- /dev/null
+++ b/packages/api/src/router/effective-status.ts
@@ -0,0 +1,28 @@
+export const REPORT_THRESHOLD = 7;
+export const REPORT_WINDOW_MS = 15 * 60 * 1000;
+export const REPORT_WINDOW_MINUTES = REPORT_WINDOW_MS / 60_000;
+
+export type EffectiveStatus = {
+ indicator: string;
+ status: string;
+ escalated: boolean;
+};
+
+export function computeEffectiveStatus(args: {
+ providerIndicator: string;
+ providerStatus: string;
+ reporters: number;
+ threshold: number;
+}): EffectiveStatus {
+ const { providerIndicator, providerStatus, reporters, threshold } = args;
+ const canEscalate =
+ providerIndicator === "none" && providerStatus !== "under_maintenance";
+ if (canEscalate && reporters >= threshold) {
+ return { indicator: "minor", status: providerStatus, escalated: true };
+ }
+ return {
+ indicator: providerIndicator,
+ status: providerStatus,
+ escalated: false,
+ };
+}
diff --git a/packages/api/src/router/externalService.ts b/packages/api/src/router/externalService.ts
index f5595899b..be5c80804 100644
--- a/packages/api/src/router/externalService.ts
+++ b/packages/api/src/router/externalService.ts
@@ -11,22 +11,94 @@ import {
listExternalIncidentsByComponent,
listExternalIncidentsBySlug,
} from "@openstatus/services/external-service-incident";
+import {
+ getComponentReportWindows,
+ getServiceReportCountries,
+ getServiceReportDaily,
+ getServiceReportWindows,
+ recordExternalServiceReport,
+} from "@openstatus/services/external-service-report";
import { OSTinybird } from "@openstatus/tinybird";
+import { redis } from "@openstatus/upstash";
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { env } from "../env";
+import { toTRPCError } from "../service-adapter";
import { createTRPCRouter, publicProcedure } from "../trpc";
+import {
+ REPORT_THRESHOLD,
+ REPORT_WINDOW_MS,
+ computeEffectiveStatus,
+} from "./effective-status";
const tb = new OSTinybird(env.TINY_BIRD_API_KEY);
const DEFAULT_HISTORY_DAYS = 45;
const INCIDENTS_LIMIT = 5;
+const REPORT_COUNTRIES_LIMIT = 5;
+const REPORT_COOLDOWN_SECONDS = REPORT_WINDOW_MS / 1000;
+const REPORT_RATELIMIT_TIMEOUT_MS = 1000;
+
+function getClientIp(headers: Headers | undefined): string {
+ if (!headers) return "";
+ const realIp = headers.get("x-real-ip");
+ if (realIp) return realIp;
+ const forwardedFor = headers.get("x-forwarded-for");
+ if (forwardedFor) return forwardedFor.split(",")[0].trim();
+ return "";
+}
+
+async function hashReporter(ip: string): Promise<string> {
+ const salt = env.EXTERNAL_REPORT_SALT ?? "";
+ const data = new TextEncoder().encode(`${salt}:${ip}`);
+ const digest = await crypto.subtle.digest("SHA-256", data);
+ return Array.from(new Uint8Array(digest))
+ .map((b) => b.toString(16).padStart(2, "0"))
+ .join("");
+}
+
+async function reportAlreadyLimited(key: string): Promise<boolean> {
+ let timer: ReturnType<typeof setTimeout> | undefined;
+ const work = (async () => {
+ const count = await redis.incr(key);
+ if (count === 1) await redis.expire(key, REPORT_COOLDOWN_SECONDS);
+ return count > 1;
+ })();
+ work.catch(() => {});
+ try {
+ return await Promise.race([
+ work,
+ new Promise<boolean>((_, reject) => {
+ timer = setTimeout(
+ () => reject(new Error("redis timeout")),
+ REPORT_RATELIMIT_TIMEOUT_MS,
+ );
+ }),
+ ]);
+ } catch (err) {
+ console.warn(
+ `[external-service report] rate-limit skipped: ${err instanceof Error ? err.message : String(err)}`,
+ );
+ return false;
+ } finally {
+ if (timer) clearTimeout(timer);
+ }
+}
// Logging here uses `console.*`, not `@logtape/logtape`: this router runs on the
// Next.js Edge runtime and `@openstatus/api` (like the edge-safe `services`
// package) deliberately takes no logtape dependency. The logtape-based logger is
// for Node contexts such as the `apps/workflows` cron. Matches every sibling router.
+async function safeRows<T>(promise: Promise<T[]>, label: string): Promise<T[]> {
+ try {
+ return await promise;
+ } catch (err) {
+ console.error(`[external-service] ${label} failed, returning empty:`, err);
+ return [];
+ }
+}
+
async function safeData<T>(
promise: Promise<{ data: T[] }>,
label: string,
@@ -48,6 +120,31 @@ const gridItemSchema = z.object({
indicator: z.string(),
status: z.string(),
statusMessage: z.string(),
+ escalated: z.boolean(),
+ reporters: z.number(),
+});
+
+const effectiveSchema = z.object({
+ indicator: z.string(),
+ status: z.string(),
+ escalated: z.boolean(),
+});
+
+const reportsSummarySchema = z.object({
+ window: z.object({
+ reporters: z.number(),
+ countries: z.number(),
+ total: z.number(),
+ }),
+ threshold: z.number(),
+ daily: z.array(
+ z.object({
+ day: z.string(),
+ reporters: z.number(),
+ total: z.number(),
+ }),
+ ),
+ topCountries: z.array(z.object({ country: z.string(), total: z.number() })),
});
const detailServiceSchema = z.object({
@@ -113,6 +210,8 @@ const componentDetailSchema = z.object({
status: z.string(),
lastFetchedAt: z.number(),
stale: z.boolean(),
+ escalated: z.boolean(),
+ reporters: z.number(),
})
.nullable(),
history: z.array(historyRowSchema),
@@ -155,19 +254,40 @@ export const externalServiceRouter = createTRPCRouter({
safeData(tb.externalStatusLatest({}), "externalStatusLatest (grid)"),
]);
+ const reportRows = await safeRows(
+ getServiceReportWindows({
+ serviceIds: services.map((s) => s.id),
+ since: new Date(Date.now() - REPORT_WINDOW_MS),
+ }),
+ "getServiceReportWindows (grid)",
+ );
+
const byId = new Map<string, (typeof latestRows)[number]>();
for (const row of latestRows) byId.set(row.id, row);
+ const reportersByServiceId = new Map<number, number>();
+ for (const row of reportRows) {
+ reportersByServiceId.set(row.externalServiceId, row.reporters);
+ }
return services.map((s) => {
const snap = byId.get(s.slug);
+ const reporters = reportersByServiceId.get(s.id) ?? 0;
+ const effective = computeEffectiveStatus({
+ providerIndicator: snap?.indicator ?? "",
+ providerStatus: snap?.status ?? "",
+ reporters,
+ threshold: REPORT_THRESHOLD,
+ });
return {
slug: s.slug,
name: s.name,
url: s.url,
aliases: Array.isArray(s.aliases) ? s.aliases : [],
- indicator: snap?.indicator ?? "",
- status: snap?.status ?? "",
+ indicator: effective.indicator,
+ status: effective.status,
statusMessage: snap?.status_message ?? "Status unavailable",
+ escalated: effective.escalated,
+ reporters,
};
});
}),
@@ -184,6 +304,8 @@ export const externalServiceRouter = createTRPCRouter({
service: detailServiceSchema,
latest: latestSchema.nullable(),
history: z.array(historyRowSchema),
+ effective: effectiveSchema,
+ reports: z.object({ reporters: z.number(), threshold: z.number() }),
}),
)
.query(async ({ input }) => {
@@ -198,8 +320,9 @@ export const externalServiceRouter = createTRPCRouter({
const aliasSlugs = Array.isArray(service.aliases) ? service.aliases : [];
const slugChain = [service.slug, ...aliasSlugs];
const days = input.days ?? DEFAULT_HISTORY_DAYS;
+ const since = new Date(Date.now() - REPORT_WINDOW_MS);
- const [latestRows, historyRows] = await Promise.all([
+ const [latestRows, historyRows, reportRows] = await Promise.all([
safeData(
tb.externalStatusLatest({ ids: slugChain }),
"externalStatusLatest",
@@ -208,6 +331,10 @@ export const externalServiceRouter = createTRPCRouter({
tb.externalStatusHistory({ ids: slugChain, days }),
"externalStatusHistory",
),
+ safeRows(
+ getServiceReportWindows({ serviceIds: [service.id], since }),
+ "getServiceReportWindows (detail)",
+ ),
]);
const newest = [...latestRows].sort(
@@ -224,6 +351,15 @@ export const externalServiceRouter = createTRPCRouter({
}
: null;
+ const reporters = reportRows[0]?.reporters ?? 0;
+ const threshold = REPORT_THRESHOLD;
+ const effective = computeEffectiveStatus({
+ providerIndicator: latest?.indicator ?? "",
+ providerStatus: latest?.status ?? "",
+ reporters,
+ threshold,
+ });
+
return {
service: {
slug: service.slug,
@@ -235,6 +371,8 @@ export const externalServiceRouter = createTRPCRouter({
},
latest,
history: historyRows.map(toHistoryRow),
+ effective,
+ reports: { reporters, threshold },
};
}),
@@ -360,7 +498,8 @@ export const externalServiceRouter = createTRPCRouter({
if (!service || !component) return empty;
const days = input.days ?? DEFAULT_HISTORY_DAYS;
- const [historyRows, incidents] = await Promise.all([
+ const since = new Date(Date.now() - REPORT_WINDOW_MS);
+ const [historyRows, incidents, reportRows] = await Promise.all([
safeData(
tb.externalStatusComponentHistory({
component_ids: [String(component.id)],
@@ -373,8 +512,22 @@ export const externalServiceRouter = createTRPCRouter({
upstreamComponentId: component.upstreamComponentId,
limit: INCIDENTS_LIMIT,
}),
+ safeRows(
+ getComponentReportWindows({ serviceId: service.id, since }),
+ "getComponentReportWindows (component)",
+ ),
]);
+ const reporters =
+ reportRows.find((r) => r.componentId === component.id)?.reporters ??
+ 0;
+ const effective = computeEffectiveStatus({
+ providerIndicator: component.indicator,
+ providerStatus: component.status,
+ reporters,
+ threshold: REPORT_THRESHOLD,
+ });
+
return {
found: true,
service: {
@@ -388,10 +541,12 @@ export const externalServiceRouter = createTRPCRouter({
name: component.name,
description: component.description,
groupName: component.groupName,
- indicator: component.indicator,
- status: component.status,
+ indicator: effective.indicator,
+ status: effective.status,
lastFetchedAt: component.lastFetchedAt ?? 0,
stale: component.stale,
+ escalated: effective.escalated,
+ reporters,
},
history: historyRows.map(toHistoryRow),
incidents: incidents.map(toIncidentDTO),
@@ -404,4 +559,106 @@ export const externalServiceRouter = createTRPCRouter({
return empty;
}
}),
+
+ report: publicProcedure
+ .input(
+ z.object({
+ slug: z.string(),
+ componentSlug: z.string().nullish(),
+ }),
+ )
+ .output(z.object({ ok: z.boolean(), alreadyReported: z.boolean() }))
+ .mutation(async ({ ctx, input }) => {
+ const ip = getClientIp(ctx.req?.headers);
+ if (!ip) {
+ throw new TRPCError({
+ code: "BAD_REQUEST",
+ message: "Could not determine the reporter's origin",
+ });
+ }
+
+ const reporterHash = await hashReporter(ip);
+ const limited = await reportAlreadyLimited(
+ `extreport:${input.slug}:${reporterHash}`,
+ );
+ if (limited) {
+ return { ok: true, alreadyReported: true };
+ }
+
+ try {
+ await recordExternalServiceReport({
+ input: {
+ slug: input.slug,
+ componentSlug: input.componentSlug ?? undefined,
+ reporterHash,
+ country: ctx.req?.headers.get("x-vercel-ip-country") ?? "",
+ },
+ });
+ } catch (err) {
+ toTRPCError(err);
+ }
+
+ return { ok: true, alreadyReported: false };
+ }),
+
+ reports: publicProcedure
+ .input(
+ z.object({
+ slug: z.string(),
+ days: z.number().int().min(1).max(90).optional(),
+ }),
+ )
+ .output(reportsSummarySchema)
+ .query(async ({ input }) => {
+ const service = await getExternalServiceBySlug({ slug: input.slug });
+ if (!service) {
+ throw new TRPCError({
+ code: "NOT_FOUND",
+ message: "External service not found",
+ });
+ }
+
+ const days = input.days ?? DEFAULT_HISTORY_DAYS;
+ const since = new Date(Date.now() - REPORT_WINDOW_MS);
+ const dailySince = new Date(Date.now() - days * 24 * 60 * 60 * 1000);
+ const threshold = REPORT_THRESHOLD;
+
+ const [windowRows, dailyRows, countryRows] = await Promise.all([
+ safeRows(
+ getServiceReportWindows({ serviceIds: [service.id], since }),
+ "getServiceReportWindows (reports)",
+ ),
+ safeRows(
+ getServiceReportDaily({ serviceId: service.id, since: dailySince }),
+ "getServiceReportDaily",
+ ),
+ safeRows(
+ getServiceReportCountries({
+ serviceId: service.id,
+ since,
+ limit: REPORT_COUNTRIES_LIMIT,
+ }),
+ "getServiceReportCountries",
+ ),
+ ]);
+
+ const win = windowRows[0];
+ return {
+ window: {
+ reporters: win?.reporters ?? 0,
+ countries: win?.countries ?? 0,
+ total: win?.total ?? 0,
+ },
+ threshold,
+ daily: dailyRows.map((r) => ({
+ day: r.day,
+ reporters: r.reporters,
+ total: r.total,
+ })),
+ topCountries: countryRows.map((r) => ({
+ country: r.country,
+ total: r.total,
+ })),
+ };
+ }),
});
diff --git a/packages/db/drizzle/0076_tense_night_thrasher.sql b/packages/db/drizzle/0076_tense_night_thrasher.sql
new file mode 100644
index 000000000..0f568bf2b
--- /dev/null
+++ b/packages/db/drizzle/0076_tense_night_thrasher.sql
@@ -0,0 +1,13 @@
+CREATE TABLE `external_service_report` (
+ `id` integer PRIMARY KEY NOT NULL,
+ `external_service_id` integer NOT NULL,
+ `external_service_component_id` integer,
+ `reporter_hash` text(64) NOT NULL,
+ `country` text(2) DEFAULT '' NOT NULL,
+ `created_at` integer DEFAULT (strftime('%s', 'now')) NOT NULL,
+ FOREIGN KEY (`external_service_id`) REFERENCES `external_service`(`id`) ON UPDATE no action ON DELETE no action,
+ FOREIGN KEY (`external_service_component_id`) REFERENCES `external_service_component`(`id`) ON UPDATE no action ON DELETE no action
+);
+--> statement-breakpoint
+CREATE INDEX `external_service_report_service_idx` ON `external_service_report` (`external_service_id`,`created_at`);--> statement-breakpoint
+CREATE INDEX `external_service_report_component_idx` ON `external_service_report` (`external_service_component_id`,`created_at`);
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0076_snapshot.json b/packages/db/drizzle/meta/0076_snapshot.json
new file mode 100644
index 000000000..f72c39e48
--- /dev/null
+++ b/packages/db/drizzle/meta/0076_snapshot.json
@@ -0,0 +1,4600 @@
+{
+ "version": "6",
+ "dialect": "sqlite",
+ "id": "bcbfadc8-aa40-4d0c-ad3b-eb3f3caa61ea",
+ "prevId": "38652d73-0c5d-4a06-8dda-e5fe7f7f008a",
+ "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": {}
+ },
+ "external_service_report": {
+ "name": "external_service_report",
+ "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
+ },
+ "external_service_component_id": {
+ "name": "external_service_component_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "reporter_hash": {
+ "name": "reporter_hash",
+ "type": "text(64)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "country": {
+ "name": "country",
+ "type": "text(2)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(strftime('%s', 'now'))"
+ }
+ },
+ "indexes": {
+ "external_service_report_service_idx": {
+ "name": "external_service_report_service_idx",
+ "columns": [
+ "external_service_id",
+ "created_at"
+ ],
+ "isUnique": false
+ },
+ "external_service_report_component_idx": {
+ "name": "external_service_report_component_idx",
+ "columns": [
+ "external_service_component_id",
+ "created_at"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "external_service_report_external_service_id_external_service_id_fk": {
+ "name": "external_service_report_external_service_id_external_service_id_fk",
+ "tableFrom": "external_service_report",
+ "tableTo": "external_service",
+ "columnsFrom": [
+ "external_service_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "external_service_report_external_service_component_id_external_service_component_id_fk": {
+ "name": "external_service_report_external_service_component_id_external_service_component_id_fk",
+ "tableFrom": "external_service_report",
+ "tableTo": "external_service_component",
+ "columnsFrom": [
+ "external_service_component_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 cef3fa3a3..28d7004fb 100644
--- a/packages/db/drizzle/meta/_journal.json
+++ b/packages/db/drizzle/meta/_journal.json
@@ -533,6 +533,13 @@
"when": 1781163353139,
"tag": "0075_yummy_ken_ellis",
"breakpoints": true
+ },
+ {
+ "idx": 76,
+ "version": "6",
+ "when": 1781258845086,
+ "tag": "0076_tense_night_thrasher",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/packages/db/src/schema/external_services/external_service_report.ts b/packages/db/src/schema/external_services/external_service_report.ts
new file mode 100644
index 000000000..cd2c19b11
--- /dev/null
+++ b/packages/db/src/schema/external_services/external_service_report.ts
@@ -0,0 +1,33 @@
+import { sql } from "drizzle-orm";
+import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
+
+import { externalService } from "./external_service";
+import { externalServiceComponent } from "./external_service_component";
+
+export const externalServiceReport = sqliteTable(
+ "external_service_report",
+ {
+ id: integer("id").primaryKey(),
+ externalServiceId: integer("external_service_id")
+ .notNull()
+ .references(() => externalService.id),
+ externalServiceComponentId: integer(
+ "external_service_component_id",
+ ).references(() => externalServiceComponent.id),
+ reporterHash: text("reporter_hash", { length: 64 }).notNull(),
+ country: text("country", { length: 2 }).notNull().default(""),
+ createdAt: integer("created_at", { mode: "timestamp" })
+ .notNull()
+ .default(sql`(strftime('%s', 'now'))`),
+ },
+ (t) => [
+ index("external_service_report_service_idx").on(
+ t.externalServiceId,
+ t.createdAt,
+ ),
+ index("external_service_report_component_idx").on(
+ t.externalServiceComponentId,
+ t.createdAt,
+ ),
+ ],
+);
diff --git a/packages/db/src/schema/external_services/index.ts b/packages/db/src/schema/external_services/index.ts
index 72b1a4a51..8982708c9 100644
--- a/packages/db/src/schema/external_services/index.ts
+++ b/packages/db/src/schema/external_services/index.ts
@@ -2,4 +2,5 @@ export * from "./constants";
export * from "./external_service";
export * from "./external_service_component";
export * from "./external_service_incident";
+export * from "./external_service_report";
export * from "./validation";
diff --git a/packages/db/src/schema/external_services/validation.ts b/packages/db/src/schema/external_services/validation.ts
index d147b1c63..1676bc42a 100644
--- a/packages/db/src/schema/external_services/validation.ts
+++ b/packages/db/src/schema/external_services/validation.ts
@@ -4,6 +4,7 @@ import { z } from "zod";
import { externalService } from "./external_service";
import { externalServiceComponent } from "./external_service_component";
import { externalServiceIncident } from "./external_service_incident";
+import { externalServiceReport } from "./external_service_report";
export const externalServiceSlugRegex = /^[a-z0-9](-?[a-z0-9])*$/;
export const externalServiceSlugSchema = z
@@ -51,3 +52,18 @@ export type ExternalServiceComponent = z.infer<
export type InsertExternalServiceComponent = z.infer<
typeof insertExternalServiceComponentSchema
>;
+
+export const selectExternalServiceReportSchema = createSelectSchema(
+ externalServiceReport,
+);
+
+export const insertExternalServiceReportSchema = createInsertSchema(
+ externalServiceReport,
+);
+
+export type ExternalServiceReport = z.infer<
+ typeof selectExternalServiceReportSchema
+>;
+export type InsertExternalServiceReport = z.infer<
+ typeof insertExternalServiceReportSchema
+>;
diff --git a/packages/services/package.json b/packages/services/package.json
index 320e269c0..e80d54203 100644
--- a/packages/services/package.json
+++ b/packages/services/package.json
@@ -109,6 +109,10 @@
"import": "./src/external-service-component/index.ts",
"types": "./src/external-service-component/index.ts"
},
+ "./external-service-report": {
+ "import": "./src/external-service-report/index.ts",
+ "types": "./src/external-service-report/index.ts"
+ },
"./test/helpers": {
"import": "./test/helpers.ts",
"types": "./test/helpers.ts"
diff --git a/packages/services/src/external-service-report/__tests__/record.test.ts b/packages/services/src/external-service-report/__tests__/record.test.ts
new file mode 100644
index 000000000..43a9524ca
--- /dev/null
+++ b/packages/services/src/external-service-report/__tests__/record.test.ts
@@ -0,0 +1,370 @@
+import { afterEach, describe, expect, test } from "bun:test";
+
+import { db, eq, inArray, like } from "@openstatus/db";
+import {
+ externalService,
+ externalServiceComponent,
+ externalServiceReport,
+} from "@openstatus/db/src/schema";
+
+import { NotFoundError } from "../../errors";
+import {
+ getComponentReportWindows,
+ getServiceReportCountries,
+ getServiceReportDaily,
+ getServiceReportWindows,
+} from "../read";
+import { recordExternalServiceReport } from "../record";
+
+const TEST_PREFIX = "svc-extreport-test";
+
+afterEach(async () => {
+ const services = await db
+ .select({ id: externalService.id })
+ .from(externalService)
+ .where(like(externalService.slug, `${TEST_PREFIX}-%`))
+ .all();
+ const ids = services.map((s) => s.id);
+ if (ids.length > 0) {
+ await db
+ .delete(externalServiceReport)
+ .where(inArray(externalServiceReport.externalServiceId, ids))
+ .run();
+ await db
+ .delete(externalServiceComponent)
+ .where(inArray(externalServiceComponent.externalServiceId, ids))
+ .run();
+ }
+ await db
+ .delete(externalService)
+ .where(like(externalService.slug, `${TEST_PREFIX}-%`))
+ .run();
+});
+
+async function seedService(args: {
+ slug: string;
+ aliases?: string[];
+ deletedAt?: Date | null;
+}) {
+ const [row] = await db
+ .insert(externalService)
+ .values({
+ slug: args.slug,
+ aliases: args.aliases ?? [],
+ name: "Report svc",
+ url: "https://example.com",
+ statusPageUrl: "https://status.example.com",
+ provider: "atlassian-statuspage",
+ industry: [],
+ deletedAt: args.deletedAt ?? null,
+ })
+ .returning();
+ return row;
+}
+
+async function seedComponent(serviceId: number, slug: string) {
+ const [row] = await db
+ .insert(externalServiceComponent)
+ .values({
+ externalServiceId: serviceId,
+ upstreamComponentId: `upstream-${slug}`,
+ slug,
+ name: slug,
+ indicator: "none",
+ status: "operational",
+ })
+ .returning();
+ return row;
+}
+
+async function insertReports(
+ rows: {
+ externalServiceId: number;
+ externalServiceComponentId?: number | null;
+ reporterHash: string;
+ country?: string;
+ createdAt: Date;
+ }[],
+) {
+ await db
+ .insert(externalServiceReport)
+ .values(
+ rows.map((r) => ({
+ externalServiceId: r.externalServiceId,
+ externalServiceComponentId: r.externalServiceComponentId ?? null,
+ reporterHash: r.reporterHash,
+ country: r.country ?? "",
+ createdAt: r.createdAt,
+ })),
+ )
+ .run();
+}
+
+describe("recordExternalServiceReport", () => {
+ test("inserts a service-level report row", async () => {
+ const service = await seedService({ slug: `${TEST_PREFIX}-live` });
+ const result = await recordExternalServiceReport({
+ input: {
+ slug: `${TEST_PREFIX}-live`,
+ reporterHash: "hash",
+ country: "FR",
+ },
+ });
+ expect(result).toEqual({
+ serviceSlug: `${TEST_PREFIX}-live`,
+ componentId: null,
+ });
+ const rows = await db
+ .select()
+ .from(externalServiceReport)
+ .where(eq(externalServiceReport.externalServiceId, service.id))
+ .all();
+ expect(rows.length).toBe(1);
+ expect(rows[0].externalServiceComponentId).toBeNull();
+ expect(rows[0].country).toBe("FR");
+ });
+
+ test("resolves an alias slug to the canonical service", async () => {
+ const service = await seedService({
+ slug: `${TEST_PREFIX}-canonical`,
+ aliases: [`${TEST_PREFIX}-old`],
+ });
+ const result = await recordExternalServiceReport({
+ input: { slug: `${TEST_PREFIX}-old`, reporterHash: "hash", country: "" },
+ });
+ expect(result.serviceSlug).toBe(`${TEST_PREFIX}-canonical`);
+ const rows = await db
+ .select()
+ .from(externalServiceReport)
+ .where(eq(externalServiceReport.externalServiceId, service.id))
+ .all();
+ expect(rows.length).toBe(1);
+ });
+
+ test("throws for an unknown service", async () => {
+ await expect(
+ recordExternalServiceReport({
+ input: {
+ slug: `${TEST_PREFIX}-missing`,
+ reporterHash: "hash",
+ country: "",
+ },
+ }),
+ ).rejects.toBeInstanceOf(NotFoundError);
+ });
+
+ test("throws for a soft-deleted service", async () => {
+ await seedService({ slug: `${TEST_PREFIX}-gone`, deletedAt: new Date() });
+ await expect(
+ recordExternalServiceReport({
+ input: {
+ slug: `${TEST_PREFIX}-gone`,
+ reporterHash: "hash",
+ country: "",
+ },
+ }),
+ ).rejects.toBeInstanceOf(NotFoundError);
+ });
+
+ test("inserts a component-level report keyed by the component id", async () => {
+ const service = await seedService({ slug: `${TEST_PREFIX}-withcomp` });
+ const component = await seedComponent(service.id, "api");
+ const result = await recordExternalServiceReport({
+ input: {
+ slug: `${TEST_PREFIX}-withcomp`,
+ componentSlug: "api",
+ reporterHash: "hash",
+ country: "DE",
+ },
+ });
+ expect(result.componentId).toBe(component.id);
+ const rows = await db
+ .select()
+ .from(externalServiceReport)
+ .where(eq(externalServiceReport.externalServiceId, service.id))
+ .all();
+ expect(rows[0].externalServiceComponentId).toBe(component.id);
+ });
+
+ test("throws for an unknown component", async () => {
+ await seedService({ slug: `${TEST_PREFIX}-nocomp` });
+ await expect(
+ recordExternalServiceReport({
+ input: {
+ slug: `${TEST_PREFIX}-nocomp`,
+ componentSlug: "does-not-exist",
+ reporterHash: "hash",
+ country: "",
+ },
+ }),
+ ).rejects.toBeInstanceOf(NotFoundError);
+ });
+});
+
+describe("report aggregation reads", () => {
+ test("getServiceReportWindows counts distinct reporters + countries", async () => {
+ const service = await seedService({ slug: `${TEST_PREFIX}-agg` });
+ const now = new Date();
+ await insertReports([
+ {
+ externalServiceId: service.id,
+ reporterHash: "a",
+ country: "US",
+ createdAt: now,
+ },
+ {
+ externalServiceId: service.id,
+ reporterHash: "a",
+ country: "US",
+ createdAt: now,
+ },
+ {
+ externalServiceId: service.id,
+ reporterHash: "b",
+ country: "FR",
+ createdAt: now,
+ },
+ {
+ externalServiceId: service.id,
+ reporterHash: "c",
+ country: "",
+ createdAt: now,
+ },
+ ]);
+ const [row] = await getServiceReportWindows({
+ serviceIds: [service.id],
+ since: new Date(now.getTime() - 60_000),
+ });
+ expect(row.reporters).toBe(3);
+ expect(row.total).toBe(4);
+ expect(row.countries).toBe(2);
+ });
+
+ test("getServiceReportWindows excludes rows before `since`", async () => {
+ const service = await seedService({ slug: `${TEST_PREFIX}-window` });
+ const now = new Date();
+ await insertReports([
+ { externalServiceId: service.id, reporterHash: "a", createdAt: now },
+ {
+ externalServiceId: service.id,
+ reporterHash: "b",
+ createdAt: new Date(now.getTime() - 60 * 60 * 1000),
+ },
+ ]);
+ const [row] = await getServiceReportWindows({
+ serviceIds: [service.id],
+ since: new Date(now.getTime() - 15 * 60 * 1000),
+ });
+ expect(row.reporters).toBe(1);
+ });
+
+ test("getComponentReportWindows groups by component, ignoring service-level", async () => {
+ const service = await seedService({ slug: `${TEST_PREFIX}-comp` });
+ const api = await seedComponent(service.id, "api");
+ const web = await seedComponent(service.id, "web");
+ const now = new Date();
+ await insertReports([
+ {
+ externalServiceId: service.id,
+ externalServiceComponentId: api.id,
+ reporterHash: "a",
+ createdAt: now,
+ },
+ {
+ externalServiceId: service.id,
+ externalServiceComponentId: api.id,
+ reporterHash: "b",
+ createdAt: now,
+ },
+ {
+ externalServiceId: service.id,
+ externalServiceComponentId: web.id,
+ reporterHash: "a",
+ createdAt: now,
+ },
+ {
+ externalServiceId: service.id,
+ externalServiceComponentId: null,
+ reporterHash: "z",
+ createdAt: now,
+ },
+ ]);
+ const rows = await getComponentReportWindows({
+ serviceId: service.id,
+ since: new Date(now.getTime() - 60_000),
+ });
+ const byComponent = new Map(rows.map((r) => [r.componentId, r.reporters]));
+ expect(byComponent.get(api.id)).toBe(2);
+ expect(byComponent.get(web.id)).toBe(1);
+ expect(rows.length).toBe(2);
+ });
+
+ test("getServiceReportDaily buckets by day", async () => {
+ const service = await seedService({ slug: `${TEST_PREFIX}-daily` });
+ await insertReports([
+ {
+ externalServiceId: service.id,
+ reporterHash: "a",
+ createdAt: new Date("2026-06-01T10:00:00Z"),
+ },
+ {
+ externalServiceId: service.id,
+ reporterHash: "b",
+ createdAt: new Date("2026-06-01T12:00:00Z"),
+ },
+ {
+ externalServiceId: service.id,
+ reporterHash: "c",
+ createdAt: new Date("2026-06-02T09:00:00Z"),
+ },
+ ]);
+ const rows = await getServiceReportDaily({
+ serviceId: service.id,
+ since: new Date("2026-05-01T00:00:00Z"),
+ });
+ expect(rows).toEqual([
+ { day: "2026-06-01", reporters: 2, total: 2 },
+ { day: "2026-06-02", reporters: 1, total: 1 },
+ ]);
+ });
+
+ test("getServiceReportCountries ranks non-empty countries", async () => {
+ const service = await seedService({ slug: `${TEST_PREFIX}-countries` });
+ const now = new Date();
+ await insertReports([
+ {
+ externalServiceId: service.id,
+ reporterHash: "a",
+ country: "US",
+ createdAt: now,
+ },
+ {
+ externalServiceId: service.id,
+ reporterHash: "b",
+ country: "US",
+ createdAt: now,
+ },
+ {
+ externalServiceId: service.id,
+ reporterHash: "c",
+ country: "FR",
+ createdAt: now,
+ },
+ {
+ externalServiceId: service.id,
+ reporterHash: "d",
+ country: "",
+ createdAt: now,
+ },
+ ]);
+ const rows = await getServiceReportCountries({
+ serviceId: service.id,
+ since: new Date(now.getTime() - 60_000),
+ limit: 5,
+ });
+ expect(rows).toEqual([
+ { country: "US", total: 2 },
+ { country: "FR", total: 1 },
+ ]);
+ });
+});
diff --git a/packages/services/src/external-service-report/index.ts b/packages/services/src/external-service-report/index.ts
new file mode 100644
index 000000000..d41ca9162
--- /dev/null
+++ b/packages/services/src/external-service-report/index.ts
@@ -0,0 +1,15 @@
+export {
+ type RecordExternalReportInput,
+ type RecordExternalReportResult,
+ recordExternalServiceReport,
+} from "./record";
+export {
+ type ComponentReportWindow,
+ type CountryReport,
+ type DailyReport,
+ type ServiceReportWindow,
+ getComponentReportWindows,
+ getServiceReportCountries,
+ getServiceReportDaily,
+ getServiceReportWindows,
+} from "./read";
diff --git a/packages/services/src/external-service-report/read.ts b/packages/services/src/external-service-report/read.ts
new file mode 100644
index 000000000..c1cfadf49
--- /dev/null
+++ b/packages/services/src/external-service-report/read.ts
@@ -0,0 +1,148 @@
+import {
+ and,
+ asc,
+ db as defaultDb,
+ desc,
+ eq,
+ gte,
+ inArray,
+ isNotNull,
+ sql,
+} from "@openstatus/db";
+import { externalServiceReport } from "@openstatus/db/src/schema";
+
+import type { GlobalReadContext } from "../external-service/internal";
+
+export type ServiceReportWindow = {
+ externalServiceId: number;
+ reporters: number;
+ total: number;
+ countries: number;
+};
+
+export type ComponentReportWindow = {
+ componentId: number;
+ reporters: number;
+ total: number;
+};
+
+export type DailyReport = { day: string; reporters: number; total: number };
+
+export type CountryReport = { country: string; total: number };
+
+const distinctReporters = sql<number>`count(distinct ${externalServiceReport.reporterHash})`;
+const totalReports = sql<number>`count(*)`;
+const distinctCountries = sql<number>`count(distinct case when ${externalServiceReport.country} != '' then ${externalServiceReport.country} end)`;
+const dayBucket = sql<string>`strftime('%Y-%m-%d', ${externalServiceReport.createdAt}, 'unixepoch')`;
+
+export async function getServiceReportWindows(args: {
+ ctx?: GlobalReadContext;
+ serviceIds: number[];
+ since: Date;
+}): Promise<ServiceReportWindow[]> {
+ const { ctx, serviceIds, since } = args;
+ if (serviceIds.length === 0) return [];
+ const db = ctx?.db ?? defaultDb;
+ return db
+ .select({
+ externalServiceId: externalServiceReport.externalServiceId,
+ reporters: distinctReporters,
+ total: totalReports,
+ countries: distinctCountries,
+ })
+ .from(externalServiceReport)
+ .where(
+ and(
+ inArray(externalServiceReport.externalServiceId, serviceIds),
+ gte(externalServiceReport.createdAt, since),
+ ),
+ )
+ .groupBy(externalServiceReport.externalServiceId)
+ .all();
+}
+
+export async function getComponentReportWindows(args: {
+ ctx?: GlobalReadContext;
+ serviceId: number;
+ since: Date;
+}): Promise<ComponentReportWindow[]> {
+ const { ctx, serviceId, since } = args;
+ const db = ctx?.db ?? defaultDb;
+ const rows = await db
+ .select({
+ componentId: externalServiceReport.externalServiceComponentId,
+ reporters: distinctReporters,
+ total: totalReports,
+ })
+ .from(externalServiceReport)
+ .where(
+ and(
+ eq(externalServiceReport.externalServiceId, serviceId),
+ isNotNull(externalServiceReport.externalServiceComponentId),
+ gte(externalServiceReport.createdAt, since),
+ ),
+ )
+ .groupBy(externalServiceReport.externalServiceComponentId)
+ .all();
+ return rows.flatMap((r) =>
+ r.componentId == null
+ ? []
+ : [
+ {
+ componentId: r.componentId,
+ reporters: r.reporters,
+ total: r.total,
+ },
+ ],
+ );
+}
+
+export async function getServiceReportDaily(args: {
+ ctx?: GlobalReadContext;
+ serviceId: number;
+ since: Date;
+}): Promise<DailyReport[]> {
+ const { ctx, serviceId, since } = args;
+ const db = ctx?.db ?? defaultDb;
+ return db
+ .select({
+ day: dayBucket,
+ reporters: distinctReporters,
+ total: totalReports,
+ })
+ .from(externalServiceReport)
+ .where(
+ and(
+ eq(externalServiceReport.externalServiceId, serviceId),
+ gte(externalServiceReport.createdAt, since),
+ ),
+ )
+ .groupBy(dayBucket)
+ .orderBy(asc(dayBucket))
+ .all();
+}
+
+export async function getServiceReportCountries(args: {
+ ctx?: GlobalReadContext;
+ serviceId: number;
+ since: Date;
+ limit: number;
+}): Promise<CountryReport[]> {
+ const { ctx, serviceId, since } = args;
+ const limit = Math.max(0, Math.trunc(args.limit));
+ const db = ctx?.db ?? defaultDb;
+ return db
+ .select({ country: externalServiceReport.country, total: totalReports })
+ .from(externalServiceReport)
+ .where(
+ and(
+ eq(externalServiceReport.externalServiceId, serviceId),
+ gte(externalServiceReport.createdAt, since),
+ sql`${externalServiceReport.country} != ''`,
+ ),
+ )
+ .groupBy(externalServiceReport.country)
+ .orderBy(desc(totalReports), asc(externalServiceReport.country))
+ .limit(limit)
+ .all();
+}
diff --git a/packages/services/src/external-service-report/record.ts b/packages/services/src/external-service-report/record.ts
new file mode 100644
index 000000000..4644e1182
--- /dev/null
+++ b/packages/services/src/external-service-report/record.ts
@@ -0,0 +1,62 @@
+import { db as defaultDb } from "@openstatus/db";
+import { externalServiceReport } from "@openstatus/db/src/schema";
+
+import { NotFoundError } from "../errors";
+import { getExternalServiceBySlug } from "../external-service";
+import { getExternalComponentBySlug } from "../external-service-component";
+import type { GlobalReadContext } from "../external-service/internal";
+import { withBusyRetry } from "../retry";
+
+export type RecordExternalReportInput = {
+ slug: string;
+ componentSlug?: string;
+ reporterHash: string;
+ country: string;
+ now?: Date;
+};
+
+export type RecordExternalReportResult = {
+ serviceSlug: string;
+ componentId: number | null;
+};
+
+export async function recordExternalServiceReport(args: {
+ ctx?: GlobalReadContext;
+ input: RecordExternalReportInput;
+}): Promise<RecordExternalReportResult> {
+ const { ctx, input } = args;
+ const db = ctx?.db ?? defaultDb;
+
+ const service = await getExternalServiceBySlug({ ctx, slug: input.slug });
+ if (!service || service.deletedAt != null) {
+ throw new NotFoundError("External service");
+ }
+
+ let componentId: number | null = null;
+ if (input.componentSlug) {
+ const { component } = await getExternalComponentBySlug({
+ ctx,
+ serviceSlug: service.slug,
+ componentSlug: input.componentSlug,
+ });
+ if (!component) {
+ throw new NotFoundError("External service component");
+ }
+ componentId = component.id;
+ }
+
+ await withBusyRetry(() =>
+ db
+ .insert(externalServiceReport)
+ .values({
+ externalServiceId: service.id,
+ externalServiceComponentId: componentId,
+ reporterHash: input.reporterHash,
+ country: input.country,
+ createdAt: input.now ?? new Date(),
+ })
+ .run(),
+ );
+
+ return { serviceSlug: service.slug, componentId };
+}