Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
private location: metadata + status (#2415)
Thibault Le Ouay7aea98d866fc
diff --git a/apps/dashboard/src/app/(dashboard)/settings/private-locations/client.tsx b/apps/dashboard/src/app/(dashboard)/settings/private-locations/client.tsxindex 231f1d473..88624caa7 100644--- a/apps/dashboard/src/app/(dashboard)/settings/private-locations/client.tsx+++ b/apps/dashboard/src/app/(dashboard)/settings/private-locations/client.tsx@@ -28,6 +28,8 @@ const EXAMPLES = [id: 1,name: "Private Location 1",token: "my-secret-token",+ status: "active",+ metadata: null,createdAt: new Date("2025-01-01"),updatedAt: new Date("2025-01-01"),workspaceId: 1,@@ -39,6 +41,8 @@ const EXAMPLES = [id: 2,name: "Private Location 2",token: "my-secret-token",+ status: "error",+ metadata: null,createdAt: new Date("2025-01-01"),updatedAt: new Date("2025-01-01"),workspaceId: 1,diff --git a/apps/dashboard/src/app/(dashboard)/settings/private-locations/nav-actions.tsx b/apps/dashboard/src/app/(dashboard)/settings/private-locations/nav-actions.tsxindex ee8def266..f68f0a309 100644--- a/apps/dashboard/src/app/(dashboard)/settings/private-locations/nav-actions.tsx+++ b/apps/dashboard/src/app/(dashboard)/settings/private-locations/nav-actions.tsx@@ -49,6 +49,9 @@ export function NavActions() {name: values.name,monitors: values.monitors,token: values.token,+ metadata: Object.fromEntries(+ values.metadata.map((m) => [m.key, m.value]),+ ),});}}>diff --git a/apps/dashboard/src/components/data-table/private-locations/columns.tsx b/apps/dashboard/src/components/data-table/private-locations/columns.tsxindex 19feb6dd6..38d4c6554 100644--- a/apps/dashboard/src/components/data-table/private-locations/columns.tsx+++ b/apps/dashboard/src/components/data-table/private-locations/columns.tsx@@ -1,6 +1,7 @@"use client";import type { RouterOutputs } from "@openstatus/api";+import { Badge } from "@openstatus/ui/components/ui/badge";import type { ColumnDef } from "@tanstack/react-table";import Link from "next/link";@@ -20,6 +21,25 @@ export const columns: ColumnDef<PrivateLocation>[] = [),enableHiding: false,},+ {+ accessorKey: "status",+ header: ({ column }) => (+ <DataTableColumnHeader column={column} title="Status" />+ ),+ enableHiding: false,+ cell: ({ row }) => {+ const status = row.getValue("status");+ const isError = status === "error";+ return (+ <Badge+ variant={isError ? "destructive" : "outline"}+ className={isError ? undefined : "border-green-500/40 text-green-600"}+ >+ {isError ? "Error" : "Active"}+ </Badge>+ );+ },+ },{accessorKey: "lastSeenAt",header: ({ column }) => (diff --git a/apps/dashboard/src/components/data-table/private-locations/data-table-row-actions.tsx b/apps/dashboard/src/components/data-table/private-locations/data-table-row-actions.tsxindex c7c7f229f..59ae3d0cb 100644--- a/apps/dashboard/src/components/data-table/private-locations/data-table-row-actions.tsx+++ b/apps/dashboard/src/components/data-table/private-locations/data-table-row-actions.tsx@@ -61,6 +61,9 @@ export function DataTableRowActions(props: DataTableRowActionsProps) {name: props.row.original.name,token: props.row.original.token.toString(),monitors: props.row.original.monitors.map((m) => m.id),+ metadata: Object.entries(props.row.original.metadata ?? {}).map(+ ([key, value]) => ({ key, value }),+ ),}}monitors={monitors ?? []}onSubmit={async (values) => {@@ -68,6 +71,9 @@ export function DataTableRowActions(props: DataTableRowActionsProps) {id: props.row.original.id,name: values.name,monitors: values.monitors,+ metadata: Object.fromEntries(+ values.metadata.map((m) => [m.key, m.value]),+ ),});}}>diff --git a/apps/dashboard/src/components/forms/private-location/form.tsx b/apps/dashboard/src/components/forms/private-location/form.tsxindex b2bce7302..006206861 100644--- a/apps/dashboard/src/components/forms/private-location/form.tsx+++ b/apps/dashboard/src/components/forms/private-location/form.tsx@@ -1,6 +1,7 @@"use client";import { zodResolver } from "@hookform/resolvers/zod";+import { Button } from "@openstatus/ui/components/ui/button";import {Form,FormControl,@@ -20,7 +21,7 @@ import {import { useCopyToClipboard } from "@openstatus/ui/hooks/use-copy-to-clipboard";import { cn } from "@openstatus/ui/lib/utils";import { isTRPCClientError } from "@trpc/client";-import { Check, Copy } from "lucide-react";+import { Check, Copy, Plus, X } from "lucide-react";import React, { useTransition } from "react";import { useForm } from "react-hook-form";import { toast } from "sonner";@@ -41,6 +42,18 @@ const schema = z.object({name: z.string().min(1, "Name is required"),token: z.string(),monitors: z.array(z.number()),+ metadata: z+ .array(+ z.object({+ key: z.string().min(1, "Key is required").max(64),+ value: z.string().max(256),+ }),+ )+ .max(20, "At most 20 metadata entries")+ .refine(+ (rows) => new Set(rows.map((r) => r.key)).size === rows.length,+ "Metadata keys must be unique",+ ),});export type FormValues = z.infer<typeof schema>;@@ -62,6 +75,7 @@ export function FormPrivateLocation({name: "",token: crypto.randomUUID(),monitors: [],+ metadata: [],},});const [isPending, startTransition] = useTransition();@@ -193,6 +207,74 @@ export function FormPrivateLocation({)}/></FormCardContent>+ <FormCardSeparator />+ <FormCardContent>+ <FormField+ control={form.control}+ name="metadata"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Metadata</FormLabel>+ <FormDescription>+ Optional key/value labels to store custom information about+ this location.+ </FormDescription>+ {field.value.map((entry, index) => (+ <div key={index} className="grid gap-2 sm:grid-cols-5">+ <Input+ placeholder="Key"+ className="col-span-2"+ value={entry.key}+ onChange={(e) => {+ const next = [...field.value];+ next[index] = { ...next[index], key: e.target.value };+ field.onChange(next);+ }}+ />+ <Input+ placeholder="Value"+ className="col-span-2"+ value={entry.value}+ onChange={(e) => {+ const next = [...field.value];+ next[index] = { ...next[index], value: e.target.value };+ field.onChange(next);+ }}+ />+ <Button+ size="icon"+ variant="ghost"+ type="button"+ aria-label="Remove metadata entry"+ onClick={() => {+ field.onChange(+ field.value.filter((_, i) => i !== index),+ );+ }}+ >+ <X />+ </Button>+ </div>+ ))}+ <div>+ <Button+ size="sm"+ variant="outline"+ type="button"+ disabled={field.value.length >= 20}+ onClick={() => {+ field.onChange([...field.value, { key: "", value: "" }]);+ }}+ >+ <Plus />+ Add Metadata+ </Button>+ </div>+ <FormMessage />+ </FormItem>+ )}+ />+ </FormCardContent></form></Form>);diff --git a/apps/server/src/routes/rpc/handlers/private-location/__tests__/private-location.test.ts b/apps/server/src/routes/rpc/handlers/private-location/__tests__/private-location.test.tsindex b9ac28664..791c79d61 100644--- a/apps/server/src/routes/rpc/handlers/private-location/__tests__/private-location.test.ts+++ b/apps/server/src/routes/rpc/handlers/private-location/__tests__/private-location.test.ts@@ -208,6 +208,30 @@ describe("PrivateLocationService.CreatePrivateLocation", () => {.where(eq(privateLocation.id, Number(data.privateLocation.id)));});+ test("roundtrips metadata and defaults status to error", async () => {+ const res = await connectRequest(+ "CreatePrivateLocation",+ {+ name: `${TEST_PREFIX}-metadata`,+ metadata: { datacenter: "eu-west", rack: "A3" },+ },+ { "x-openstatus-key": authKey },+ );++ expect(res.status).toBe(200);++ const data = await res.json();+ expect(data.privateLocation.metadata).toEqual({+ datacenter: "eu-west",+ rack: "A3",+ });+ expect(data.privateLocation.status).toBe("PRIVATE_LOCATION_STATUS_ERROR");++ await db+ .delete(privateLocation)+ .where(eq(privateLocation.id, Number(data.privateLocation.id)));+ });+test("returns 403 for a workspace without the entitlement", async () => {const res = await connectRequest("CreatePrivateLocation",@@ -352,6 +376,20 @@ describe("PrivateLocationService.ListPrivateLocations", () => {expect(ids).toContain(String(testLocationId));});+ test("includes status on summaries", async () => {+ const res = await connectRequest(+ "ListPrivateLocations",+ {},+ { "x-openstatus-key": authKey },+ );++ const data = await res.json();+ const found = data.privateLocations.find(+ (l: { id: string }) => l.id === String(testLocationId),+ );+ expect(found.status).toBe("PRIVATE_LOCATION_STATUS_ERROR");+ });+test("reports monitorCount for an attached location", async () => {const res = await connectRequest("ListPrivateLocations",@@ -488,6 +526,75 @@ describe("PrivateLocationService.UpdatePrivateLocation", () => {await db.delete(privateLocation).where(eq(privateLocation.id, target));});+ test("replaces metadata when updateMetadata is true", async () => {+ const target = await mkLocation(+ `${TEST_PREFIX}-meta-update`,+ entitledWorkspaceId,+ );++ const res = await connectRequest(+ "UpdatePrivateLocation",+ {+ id: String(target),+ metadata: { env: "prod" },+ updateMetadata: true,+ },+ { "x-openstatus-key": authKey },+ );++ expect(res.status).toBe(200);+ const data = await res.json();+ expect(data.privateLocation.metadata).toEqual({ env: "prod" });++ await db.delete(privateLocation).where(eq(privateLocation.id, target));+ });++ test("ignores metadata when updateMetadata is absent", async () => {+ const target = await mkLocation(+ `${TEST_PREFIX}-meta-preserve`,+ entitledWorkspaceId,+ );+ await db+ .update(privateLocation)+ .set({ metadata: { keep: "yes" } })+ .where(eq(privateLocation.id, target));++ const res = await connectRequest(+ "UpdatePrivateLocation",+ { id: String(target), metadata: { env: "prod" } },+ { "x-openstatus-key": authKey },+ );++ expect(res.status).toBe(200);+ const data = await res.json();+ expect(data.privateLocation.metadata).toEqual({ keep: "yes" });++ await db.delete(privateLocation).where(eq(privateLocation.id, target));+ });++ test("clears metadata with an empty map and the flag set", async () => {+ const target = await mkLocation(+ `${TEST_PREFIX}-meta-clear`,+ entitledWorkspaceId,+ );+ await db+ .update(privateLocation)+ .set({ metadata: { drop: "me" } })+ .where(eq(privateLocation.id, target));++ const res = await connectRequest(+ "UpdatePrivateLocation",+ { id: String(target), metadata: {}, updateMetadata: true },+ { "x-openstatus-key": authKey },+ );++ expect(res.status).toBe(200);+ const data = await res.json();+ expect(data.privateLocation.metadata ?? {}).toEqual({});++ await db.delete(privateLocation).where(eq(privateLocation.id, target));+ });+test("returns 403 for a workspace without the entitlement", async () => {const res = await connectRequest("UpdatePrivateLocation",diff --git a/apps/server/src/routes/rpc/handlers/private-location/converters.ts b/apps/server/src/routes/rpc/handlers/private-location/converters.tsindex 70555f90b..6a7a2d07d 100644--- a/apps/server/src/routes/rpc/handlers/private-location/converters.ts+++ b/apps/server/src/routes/rpc/handlers/private-location/converters.ts@@ -1,17 +1,26 @@-import type {- PrivateLocation,- PrivateLocationSummary,+import {+ type PrivateLocation,+ PrivateLocationStatus,+ type PrivateLocationSummary,} from "@openstatus/proto/private_location/v1";type DBPrivateLocation = {id: number;name: string;token: string;+ status: "active" | "error";+ metadata: Record<string, string> | null;lastSeenAt: Date | null;createdAt: Date | null;updatedAt: Date | null;};+function toProtoStatus(status: "active" | "error"): PrivateLocationStatus {+ return status === "error"+ ? PrivateLocationStatus.ERROR+ : PrivateLocationStatus.ACTIVE;+}+export function dbPrivateLocationToProto(location: DBPrivateLocation,monitorIds: string[],@@ -25,6 +34,8 @@ export function dbPrivateLocationToProto(lastSeenAt: location.lastSeenAt?.toISOString() ?? "",createdAt: location.createdAt?.toISOString() ?? "",updatedAt: location.updatedAt?.toISOString() ?? "",+ metadata: location.metadata ?? {},+ status: toProtoStatus(location.status),};}@@ -41,5 +52,7 @@ export function dbPrivateLocationToProtoSummary(lastSeenAt: location.lastSeenAt?.toISOString() ?? "",createdAt: location.createdAt?.toISOString() ?? "",updatedAt: location.updatedAt?.toISOString() ?? "",+ status: toProtoStatus(location.status),+ metadata: location.metadata ?? {},};}diff --git a/apps/server/src/routes/rpc/handlers/private-location/index.ts b/apps/server/src/routes/rpc/handlers/private-location/index.tsindex b2e7df351..7baf2d1da 100644--- a/apps/server/src/routes/rpc/handlers/private-location/index.ts+++ b/apps/server/src/routes/rpc/handlers/private-location/index.ts@@ -67,6 +67,7 @@ export const privateLocationServiceImpl: ServiceImpl<input: {name: req.name,monitors: parseMonitorIds(req.monitorIds),+ metadata: req.metadata,},});@@ -145,6 +146,7 @@ export const privateLocationServiceImpl: ServiceImpl<monitors: req.updateMonitorIds? parseMonitorIds(req.monitorIds): undefined,+ metadata: req.updateMetadata ? req.metadata : undefined,},});diff --git a/apps/server/static/openapi.yaml b/apps/server/static/openapi.yamlindex 324d1369a..2099c29f6 100644--- a/apps/server/static/openapi.yaml+++ b/apps/server/static/openapi.yaml@@ -2342,9 +2342,29 @@ components:type: stringtitle: monitor_idsdescription: IDs of monitors this private location should run (optional).+ metadata:+ type: object+ title: metadata+ maxProperties: 20+ additionalProperties:+ type: string+ title: value+ maxLength: 256+ description: User-defined key/value labels (optional, up to 20 entries).title: CreatePrivateLocationRequestadditionalProperties: falsedescription: CreatePrivateLocationRequest is the request to create a new private location.+ openstatus.private_location.v1.CreatePrivateLocationRequest.MetadataEntry:+ type: object+ properties:+ key:+ type: string+ title: key+ value:+ type: string+ title: value+ title: MetadataEntry+ additionalProperties: falseopenstatus.private_location.v1.CreatePrivateLocationResponse:type: objectproperties:@@ -2472,9 +2492,41 @@ components:type: stringtitle: updated_atdescription: Timestamp when the private location was last updated (RFC 3339 format).+ metadata:+ type: object+ title: metadata+ additionalProperties:+ type: string+ title: value+ description: User-defined key/value labels attached to this private location.+ status:+ title: status+ description: Computed health of the agent. Read-only.+ $ref: '#/components/schemas/openstatus.private_location.v1.PrivateLocationStatus'title: PrivateLocationadditionalProperties: falsedescription: PrivateLocation represents a self-hosted checker agent with full details.+ openstatus.private_location.v1.PrivateLocation.MetadataEntry:+ type: object+ properties:+ key:+ type: string+ title: key+ value:+ type: string+ title: value+ title: MetadataEntry+ additionalProperties: false+ openstatus.private_location.v1.PrivateLocationStatus:+ type: string+ title: PrivateLocationStatus+ enum:+ - PRIVATE_LOCATION_STATUS_UNSPECIFIED+ - PRIVATE_LOCATION_STATUS_ACTIVE+ - PRIVATE_LOCATION_STATUS_ERROR+ description: |-+ PrivateLocationStatus is the computed health of a private location, derived+ from the agent heartbeat. Read-only — it cannot be set through the API.openstatus.private_location.v1.PrivateLocationSummary:type: objectproperties:@@ -2503,11 +2555,33 @@ components:type: stringtitle: updated_atdescription: Timestamp when the private location was last updated (RFC 3339 format).+ status:+ title: status+ description: Computed health of the agent. Read-only.+ $ref: '#/components/schemas/openstatus.private_location.v1.PrivateLocationStatus'+ metadata:+ type: object+ title: metadata+ additionalProperties:+ type: string+ title: value+ description: User-defined key/value labels attached to this private location.title: PrivateLocationSummaryadditionalProperties: falsedescription: |-PrivateLocationSummary represents metadata for a private location (used inlist responses). The agent token is intentionally omitted.+ openstatus.private_location.v1.PrivateLocationSummary.MetadataEntry:+ type: object+ properties:+ key:+ type: string+ title: key+ value:+ type: string+ title: value+ title: MetadataEntry+ additionalProperties: falseopenstatus.private_location.v1.UpdatePrivateLocationRequest:type: objectproperties:@@ -2539,9 +2613,37 @@ components:When true, monitor_ids replaces the current associations (an empty listclears all). When false or unset, monitor_ids is ignored and existingassociations are preserved.+ metadata:+ type: object+ title: metadata+ maxProperties: 20+ additionalProperties:+ type: string+ title: value+ maxLength: 256+ description: New key/value labels. Only applied when update_metadata is true.+ updateMetadata:+ type:+ - boolean+ - "null"+ title: update_metadata+ description: |-+ When true, metadata replaces the current labels (an empty map clears all).+ When false or unset, metadata is ignored and existing labels are preserved.title: UpdatePrivateLocationRequestadditionalProperties: falsedescription: UpdatePrivateLocationRequest is the request to update a private location.+ openstatus.private_location.v1.UpdatePrivateLocationRequest.MetadataEntry:+ type: object+ properties:+ key:+ type: string+ title: key+ value:+ type: string+ title: value+ title: MetadataEntry+ additionalProperties: falseopenstatus.private_location.v1.UpdatePrivateLocationResponse:type: objectproperties:diff --git a/apps/workflows/src/cron/index.ts b/apps/workflows/src/cron/index.tsindex f6444ddc5..3a9a9caa2 100644--- a/apps/workflows/src/cron/index.ts+++ b/apps/workflows/src/cron/index.ts@@ -16,6 +16,7 @@ import {StepPaused,workflowStepSchema,} from "./monitor";+import { handlePrivateLocationHealthCron } from "./private-location-health";import { handleUptimeFreezeCron } from "./uptime-freeze";const app = new Hono({ strict: false });@@ -98,6 +99,10 @@ app.get("/uptime-freeze", async (c) => {return handleUptimeFreezeCron(c);});+app.get("/private-location-health", async (c) => {+ return handlePrivateLocationHealthCron(c);+});+app.get("/emails/follow-up", async (c) => {try {await sendFollowUpEmails();diff --git a/apps/workflows/src/cron/private-location-health.test.ts b/apps/workflows/src/cron/private-location-health.test.tsnew file mode 100644index 000000000..01aa47c86--- /dev/null+++ b/apps/workflows/src/cron/private-location-health.test.ts@@ -0,0 +1,126 @@+import { db, eq } from "@openstatus/db";+import { auditLog, privateLocation } from "@openstatus/db/src/schema";+import {+ afterEach,+ assertSpyCalls,+ beforeEach,+ describe,+ expect,+ type Stub,+ stub,+ test,+} from "@openstatus/test-utils";++import {+ emailClient,+ runPrivateLocationHealth,+ STALE_THRESHOLD_MS,+} from "./private-location-health";++const TEST_LOCATION_ID = 9301;+const TEST_WORKSPACE_ID = 1;+const NOW = new Date("2026-07-23T12:00:00Z");+const FRESH = new Date(NOW.getTime() - 60 * 1000);+const STALE = new Date(NOW.getTime() - STALE_THRESHOLD_MS - 60 * 1000);++// biome-ignore lint/suspicious/noExplicitAny: email stub+type AnyStub = Stub<any>;++async function seedLocation(+ status: "active" | "error",+ lastSeenAt: Date | null,+) {+ await db+ .delete(privateLocation)+ .where(eq(privateLocation.id, TEST_LOCATION_ID));+ await db+ .insert(privateLocation)+ .values({+ id: TEST_LOCATION_ID,+ name: "health-test-location",+ token: "health-test-token",+ status,+ lastSeenAt,+ workspaceId: TEST_WORKSPACE_ID,+ createdAt: new Date(),+ })+ .run();+}++function readStatus() {+ return db+ .select({ status: privateLocation.status })+ .from(privateLocation)+ .where(eq(privateLocation.id, TEST_LOCATION_ID))+ .get();+}++describe("runPrivateLocationHealth", () => {+ let mockEmail: AnyStub;++ beforeEach(() => {+ mockEmail = stub(emailClient, "sendPrivateLocationAlert", () =>+ Promise.resolve(),+ ) as AnyStub;+ });++ afterEach(async () => {+ mockEmail.restore();+ await db+ .delete(auditLog)+ .where(eq(auditLog.entityId, String(TEST_LOCATION_ID)));+ await db+ .delete(privateLocation)+ .where(eq(privateLocation.id, TEST_LOCATION_ID));+ });++ test("active + stale → error + email", async () => {+ await seedLocation("active", STALE);++ await runPrivateLocationHealth(NOW);++ expect((await readStatus())?.status).toBe("error");+ assertSpyCalls(mockEmail, 1);+ expect(mockEmail.calls[0].args[0].status).toBe("error");+ expect(mockEmail.calls[0].args[0].locationName).toBe(+ "health-test-location",+ );+ });++ test("error + fresh → active + email", async () => {+ await seedLocation("error", FRESH);++ await runPrivateLocationHealth(NOW);++ expect((await readStatus())?.status).toBe("active");+ assertSpyCalls(mockEmail, 1);+ expect(mockEmail.calls[0].args[0].status).toBe("recovered");+ });++ test("active + fresh → untouched, no email", async () => {+ await seedLocation("active", FRESH);++ await runPrivateLocationHealth(NOW);++ expect((await readStatus())?.status).toBe("active");+ assertSpyCalls(mockEmail, 0);+ });++ test("error + stale → untouched, no email", async () => {+ await seedLocation("error", STALE);++ await runPrivateLocationHealth(NOW);++ expect((await readStatus())?.status).toBe("error");+ assertSpyCalls(mockEmail, 0);+ });++ test("lastSeenAt NULL → skipped regardless of status", async () => {+ await seedLocation("error", null);++ await runPrivateLocationHealth(NOW);++ expect((await readStatus())?.status).toBe("error");+ assertSpyCalls(mockEmail, 0);+ });+});diff --git a/apps/workflows/src/cron/private-location-health.ts b/apps/workflows/src/cron/private-location-health.tsnew file mode 100644index 000000000..b6a56fa22--- /dev/null+++ b/apps/workflows/src/cron/private-location-health.ts@@ -0,0 +1,158 @@+import { getLogger } from "@logtape/logtape";+import { db, eq, isNotNull } from "@openstatus/db";+import {+ privateLocation,+ selectWorkspaceSchema,+ user,+ usersToWorkspaces,+ workspace,+} from "@openstatus/db/src/schema";+import { EmailClient } from "@openstatus/emails";+import { setPrivateLocationStatus } from "@openstatus/services/private-location";+import type { Context } from "hono";++import { env } from "../env";+import { reportBackgroundError, runSentryCron } from "../lib/sentry";++const logger = getLogger(["workflow", "private-location-health"]);++export const emailClient = new EmailClient({ apiKey: env().RESEND_API_KEY });++export const STALE_THRESHOLD_MS = 15 * 60 * 1000;++type HealthSummary = { checked: number; toError: number; toActive: number };++/**+ * Flip private-location status from the agent heartbeat and email members on+ * every transition. Locations that have never reported (`lastSeenAt IS NULL`)+ * stay `active` and are skipped.+ */+export async function runPrivateLocationHealth(+ now: Date = new Date(),+): Promise<HealthSummary> {+ const locations = await db+ .select({+ id: privateLocation.id,+ name: privateLocation.name,+ status: privateLocation.status,+ lastSeenAt: privateLocation.lastSeenAt,+ workspaceId: privateLocation.workspaceId,+ })+ .from(privateLocation)+ .where(isNotNull(privateLocation.lastSeenAt))+ .all();++ const summary: HealthSummary = {+ checked: locations.length,+ toError: 0,+ toActive: 0,+ };++ for (const location of locations) {+ if (location.lastSeenAt === null || location.workspaceId === null) continue;++ const stale =+ now.getTime() - location.lastSeenAt.getTime() > STALE_THRESHOLD_MS;+ const nextStatus =+ location.status === "active" && stale+ ? "error"+ : location.status === "error" && !stale+ ? "active"+ : null;++ if (nextStatus === null) continue;++ const workspaceRow = await db+ .select()+ .from(workspace)+ .where(eq(workspace.id, location.workspaceId))+ .get();+ if (!workspaceRow) continue;++ await setPrivateLocationStatus({+ ctx: {+ workspace: selectWorkspaceSchema.parse(workspaceRow),+ actor: { type: "system", job: "private-location-health" },+ },+ input: { id: location.id, status: nextStatus },+ });++ if (nextStatus === "error") summary.toError++;+ else summary.toActive++;++ await notifyMembers({+ workspaceId: location.workspaceId,+ locationName: location.name,+ status: nextStatus === "error" ? "error" : "recovered",+ lastSeenAt: location.lastSeenAt,+ });+ }++ return summary;+}++async function notifyMembers(args: {+ workspaceId: number;+ locationName: string;+ status: "error" | "recovered";+ lastSeenAt: Date;+}) {+ const members = await db+ .select({ email: user.email })+ .from(usersToWorkspaces)+ .innerJoin(user, eq(usersToWorkspaces.userId, user.id))+ .where(eq(usersToWorkspaces.workspaceId, args.workspaceId))+ .all();++ const to = members+ .map((m) => m.email)+ .filter((email): email is string => !!email && email.trim() !== "");++ if (to.length === 0) return;++ try {+ await emailClient.sendPrivateLocationAlert({+ to,+ locationName: args.locationName,+ status: args.status,+ lastSeenAt: args.lastSeenAt,+ });+ } catch (error) {+ logger.error("Failed to send private location alert", {+ workspace_id: args.workspaceId,+ location_name: args.locationName,+ error_message: error instanceof Error ? error.message : String(error),+ });+ void reportBackgroundError(+ `private-location-health: email failed for ${args.locationName}`,+ );+ }+}++export async function handlePrivateLocationHealthCron(c: Context) {+ const { cronCompleted, cronFailed } = runSentryCron(+ "private-location-health",+ );++ // Background chain: must not capture `c` — the handler returns 200 before+ // this resolves (see uptime-freeze.ts).+ void runPrivateLocationHealth()+ .then((summary) => {+ logger.info(+ "private-location-health complete: checked={checked} toError={toError} toActive={toActive}",+ summary,+ );+ void cronCompleted();+ })+ .catch((error) => {+ logger.error("private-location-health errored: {message}", {+ message: error instanceof Error ? error.message : String(error),+ });+ void reportBackgroundError(+ `private-location-health failed: ${error instanceof Error ? error.message : String(error)}`,+ );+ void cronFailed();+ });++ return c.json({ success: true }, 200);+}diff --git a/packages/api/src/router/privateLocation.test.ts b/packages/api/src/router/privateLocation.test.tsindex c621f3514..9c0737d21 100644--- a/packages/api/src/router/privateLocation.test.ts+++ b/packages/api/src/router/privateLocation.test.ts@@ -201,3 +201,33 @@ test("privateLocation.update rejects monitors from another workspace", async ()expect((e as TRPCError).code).toBe("FORBIDDEN");}});++test("privateLocation.new persists metadata and defaults status", async () => {+ const caller = callerFor();++ const result = await caller.privateLocation.new({+ name: "Metadata Location",+ token: "test-token-metadata",+ monitors: [],+ metadata: { datacenter: "eu-west" },+ });++ expect(result.metadata).toEqual({ datacenter: "eu-west" });+ expect(result.status).toBe("error");++ await db.delete(privateLocation).where(eq(privateLocation.id, result.id));+});++test("privateLocation.update replaces metadata", async () => {+ const caller = callerFor();++ const result = await caller.privateLocation.update({+ id: ownWorkspaceLocationId,+ name: "Metadata Update",+ monitors: [ownMonitorId],+ metadata: { env: "prod" },+ });++ expect(result.metadata).toEqual({ env: "prod" });+ expect(result.status).toBe("error");+});diff --git a/packages/api/src/router/privateLocation.ts b/packages/api/src/router/privateLocation.tsindex 0ae5f821b..cef0f2844 100644--- a/packages/api/src/router/privateLocation.ts+++ b/packages/api/src/router/privateLocation.ts@@ -31,6 +31,7 @@ export const privateLocationRouter = createTRPCRouter({name: z.string(),monitors: z.array(z.number()),token: z.string(),+ metadata: z.record(z.string(), z.string()).optional(),}),).mutation(async ({ ctx, input }) => {@@ -41,6 +42,7 @@ export const privateLocationRouter = createTRPCRouter({name: input.name,token: input.token,monitors: input.monitors,+ metadata: input.metadata,},});} catch (err) {@@ -54,6 +56,7 @@ export const privateLocationRouter = createTRPCRouter({id: z.number(),name: z.string(),monitors: z.array(z.number()),+ metadata: z.record(z.string(), z.string()).optional(),}),).mutation(async ({ ctx, input }) => {diff --git a/packages/db/drizzle/0081_charming_unus.sql b/packages/db/drizzle/0081_charming_unus.sqlnew file mode 100644index 000000000..809068d5b--- /dev/null+++ b/packages/db/drizzle/0081_charming_unus.sql@@ -0,0 +1,2 @@+ALTER TABLE `private_location` ADD `status` text DEFAULT 'error' NOT NULL;--> statement-breakpoint+ALTER TABLE `private_location` ADD `metadata` text;\ No newline at end of filediff --git a/packages/db/drizzle/meta/0081_snapshot.json b/packages/db/drizzle/meta/0081_snapshot.jsonnew file mode 100644index 000000000..454c88621--- /dev/null+++ b/packages/db/drizzle/meta/0081_snapshot.json@@ -0,0 +1,4832 @@+{+ "version": "6",+ "dialect": "sqlite",+ "id": "a48b4954-9494-47cd-97ef-c71992f445ad",+ "prevId": "dd6a23ac-b31e-45b7-ad9a-d4a3929c3382",+ "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'"+ },+ "custom_theme": {+ "name": "custom_theme",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "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+ },+ "slack_channel_id": {+ "name": "slack_channel_id",+ "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'"+ },+ "idx_page_subscriber_slack_channel_page_active": {+ "name": "idx_page_subscriber_slack_channel_page_active",+ "columns": [+ "slack_channel_id",+ "page_id"+ ],+ "isUnique": true,+ "where": "\"page_subscriber\".\"unsubscribed_at\" IS NULL AND \"page_subscriber\".\"channel_type\" = 'slack'"+ }+ },+ "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) OR (\"page_subscriber\".\"channel_type\" = 'slack' AND \"page_subscriber\".\"slack_channel_id\" IS NOT NULL AND \"page_subscriber\".\"email\" IS NULL AND \"page_subscriber\".\"webhook_url\" 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_monitor_status": {+ "name": "private_location_monitor_status",+ "columns": {+ "monitor_id": {+ "name": "monitor_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "private_location_id": {+ "name": "private_location_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'active'"+ },+ "cron_timestamp": {+ "name": "cron_timestamp",+ "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": {+ "private_location_monitor_status_pl_id_idx": {+ "name": "private_location_monitor_status_pl_id_idx",+ "columns": [+ "private_location_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "private_location_monitor_status_monitor_id_monitor_id_fk": {+ "name": "private_location_monitor_status_monitor_id_monitor_id_fk",+ "tableFrom": "private_location_monitor_status",+ "tableTo": "monitor",+ "columnsFrom": [+ "monitor_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "private_location_monitor_status_private_location_id_private_location_id_fk": {+ "name": "private_location_monitor_status_private_location_id_private_location_id_fk",+ "tableFrom": "private_location_monitor_status",+ "tableTo": "private_location",+ "columnsFrom": [+ "private_location_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "private_location_monitor_status_monitor_id_private_location_id_pk": {+ "columns": [+ "monitor_id",+ "private_location_id"+ ],+ "name": "private_location_monitor_status_monitor_id_private_location_id_pk"+ }+ },+ "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+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'error'"+ },+ "metadata": {+ "name": "metadata",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "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": {}+ },+ "frozen_monitor_uptime": {+ "name": "frozen_monitor_uptime",+ "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+ },+ "monitor_id": {+ "name": "monitor_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "month": {+ "name": "month",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "days": {+ "name": "days",+ "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": {+ "frozen_monitor_uptime_workspace_id_idx": {+ "name": "frozen_monitor_uptime_workspace_id_idx",+ "columns": [+ "workspace_id"+ ],+ "isUnique": false+ },+ "frozen_monitor_uptime_monitor_id_month_unique": {+ "name": "frozen_monitor_uptime_monitor_id_month_unique",+ "columns": [+ "monitor_id",+ "month"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "frozen_monitor_uptime_workspace_id_workspace_id_fk": {+ "name": "frozen_monitor_uptime_workspace_id_workspace_id_fk",+ "tableFrom": "frozen_monitor_uptime",+ "tableTo": "workspace",+ "columnsFrom": [+ "workspace_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "frozen_monitor_uptime_monitor_id_monitor_id_fk": {+ "name": "frozen_monitor_uptime_monitor_id_monitor_id_fk",+ "tableFrom": "frozen_monitor_uptime",+ "tableTo": "monitor",+ "columnsFrom": [+ "monitor_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 filediff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.jsonindex a7653aa83..ec8427483 100644--- a/packages/db/drizzle/meta/_journal.json+++ b/packages/db/drizzle/meta/_journal.json@@ -568,6 +568,13 @@"when": 1784059243113,"tag": "0080_soft_norman_osborn","breakpoints": true+ },+ {+ "idx": 81,+ "version": "6",+ "when": 1784808228044,+ "tag": "0081_charming_unus",+ "breakpoints": true}]}\ No newline at end of filediff --git a/packages/db/src/schema/private_locations/private_locations.ts b/packages/db/src/schema/private_locations/private_locations.tsindex 996269ca4..0fc6e0554 100644--- a/packages/db/src/schema/private_locations/private_locations.ts+++ b/packages/db/src/schema/private_locations/private_locations.ts@@ -5,12 +5,20 @@ import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";import { monitor } from "../monitors/monitor";import { workspace } from "../workspaces";+export const privateLocationStatus = ["active", "error"] as const;+export const privateLocation = sqliteTable("private_location",{id: integer("id").primaryKey(),name: text("name").notNull(),token: text("token").notNull(),+ status: text("status", { enum: privateLocationStatus })+ .default("error")+ .notNull(),+ metadata: text("metadata", { mode: "json" }).$type<+ Record<string, string>+ >(),lastSeenAt: integer("last_seen_at", { mode: "timestamp" }),workspaceId: integer("workspace_id").references(() => workspace.id),createdAt: integer("created_at", { mode: "timestamp" }).default(diff --git a/packages/db/src/schema/private_locations/validation.ts b/packages/db/src/schema/private_locations/validation.tsindex 3c8f542d3..30296fbef 100644--- a/packages/db/src/schema/private_locations/validation.ts+++ b/packages/db/src/schema/private_locations/validation.ts@@ -1,12 +1,22 @@import { createInsertSchema, createSelectSchema } from "drizzle-zod";-import type { z } from "zod";+import { z } from "zod";import { privateLocationMonitorStatus } from "./private_location_monitor_status";-import { privateLocation } from "./private_locations";+import { privateLocation, privateLocationStatus } from "./private_locations";-export const insertPrivateLocationSchema = createInsertSchema(privateLocation);+export const privateLocationStatusSchema = z.enum(privateLocationStatus);-export const selectPrivateLocationSchema = createSelectSchema(privateLocation);+const privateLocationMetadataSchema = z.record(z.string(), z.string());++export const insertPrivateLocationSchema = createInsertSchema(privateLocation, {+ status: privateLocationStatusSchema.prefault("error"),+ metadata: privateLocationMetadataSchema.nullish(),+});++export const selectPrivateLocationSchema = createSelectSchema(privateLocation, {+ status: privateLocationStatusSchema,+ metadata: privateLocationMetadataSchema.nullable(),+});export type InsertPrivateLocation = z.infer<typeof insertPrivateLocationSchema>;export type PrivateLocation = z.infer<typeof selectPrivateLocationSchema>;diff --git a/packages/emails/emails/private-location-alert.tsx b/packages/emails/emails/private-location-alert.tsxnew file mode 100644index 000000000..37e4eee7a--- /dev/null+++ b/packages/emails/emails/private-location-alert.tsx@@ -0,0 +1,76 @@+/** @jsxRuntime automatic @jsxImportSource react */++import { Body, Button, Head, Heading, Html, Preview, Text } from "react-email";+import { z } from "zod";++import { Layout } from "./_components/layout";+import { colors, styles } from "./_components/styles";++const PrivateLocationAlertSchema = z.object({+ locationName: z.string(),+ status: z.enum(["error", "recovered"]),+ lastSeenAt: z.string(),+});++export type PrivateLocationAlertProps = z.infer<+ typeof PrivateLocationAlertSchema+>;++const PrivateLocationAlertEmail = (props: PrivateLocationAlertProps) => {+ const isError = props.status === "error";+ const preview = isError+ ? `Your private location "${props.locationName}" is unhealthy`+ : `Your private location "${props.locationName}" is healthy again`;++ return (+ <Html>+ <Head />+ <Preview>{preview}</Preview>+ <Body style={styles.main}>+ <Layout>+ <Heading+ as="h4"+ style={{ color: isError ? colors.danger : colors.success }}+ >+ {preview}+ </Heading>+ {isError ? (+ <Text>+ The agent for <strong>{props.locationName}</strong> has not+ reported a result in over 15 minutes, so checks scheduled on this+ location are not running. It was last seen at {props.lastSeenAt}.+ </Text>+ ) : (+ <Text>+ The agent for <strong>{props.locationName}</strong> is reporting+ again and checks on this location have resumed. It was last seen+ at {props.lastSeenAt}.+ </Text>+ )}+ <Text>+ {isError+ ? "Check that the agent is running and can reach OpenStatus, then verify its token and network access."+ : "No action is needed."}+ </Text>+ <Text style={{ textAlign: "center" }}>+ <Button+ style={styles.button}+ href="https://www.openstatus.dev/app/settings/private-locations"+ >+ View private locations+ </Button>+ </Text>+ <Text>If you have any questions, please reply to this email.</Text>+ </Layout>+ </Body>+ </Html>+ );+};++PrivateLocationAlertEmail.PreviewProps = {+ locationName: "eu-west-agent",+ status: "error",+ lastSeenAt: "2026-07-23T10:00:00Z",+} satisfies PrivateLocationAlertProps;++export default PrivateLocationAlertEmail;diff --git a/packages/emails/src/client.tsx b/packages/emails/src/client.tsxindex 721671f86..d14664815 100644--- a/packages/emails/src/client.tsx+++ b/packages/emails/src/client.tsx@@ -8,6 +8,8 @@ import FollowUpEmail from "../emails/followup";import type { MonitorAlertProps } from "../emails/monitor-alert";import PageSubscriptionEmail from "../emails/page-subscription";import type { PageSubscriptionProps } from "../emails/page-subscription";+import PrivateLocationAlertEmail from "../emails/private-location-alert";+import type { PrivateLocationAlertProps } from "../emails/private-location-alert";import SlackFeedbackEmail from "../emails/slack-feedback";import StatusPageMagicLinkEmail from "../emails/status-page-magic-link";import type { StatusPageMagicLinkProps } from "../emails/status-page-magic-link";@@ -445,4 +447,59 @@ export class EmailClient {`Sent maintenance notification email to ${req.subscribers.length} subscribers`,);}++ public async sendPrivateLocationAlert(+ req: Omit<PrivateLocationAlertProps, "lastSeenAt"> & {+ to: string[];+ lastSeenAt: Date;+ },+ ) {+ if (req.to.length === 0) return;++ const subject =+ req.status === "error"+ ? `Your private location "${req.locationName}" is unhealthy`+ : `Your private location "${req.locationName}" is healthy again`;++ if (process.env.NODE_ENV === "development") {+ console.log(+ `Sending private location ${req.status} email to ${req.to.join(", ")}`,+ );+ return;+ }++ try {+ const html = await render(+ <PrivateLocationAlertEmail+ locationName={req.locationName}+ status={req.status}+ lastSeenAt={req.lastSeenAt.toISOString()}+ />,+ );+ const result = await this.client.batch.send(+ req.to.map((to) => ({+ from: "OpenStatus <[email protected]>",+ subject,+ to,+ html,+ })),+ );++ if (result.error) {+ if (result.error?.name === "rate_limit_exceeded") {+ throw result.error;+ }+ console.error(+ `Error sending private location alert to ${req.to}: ${result.error}`,+ );+ return;+ }++ console.log(`Sent private location ${req.status} email to ${req.to}`);+ } catch (err) {+ console.error(+ `Error sending private location alert to ${req.to}: ${err}`,+ );+ }+ }}diff --git a/packages/emails/src/index.ts b/packages/emails/src/index.tsindex d8c9f0ddd..b77c282c0 100644--- a/packages/emails/src/index.ts+++ b/packages/emails/src/index.ts@@ -7,6 +7,7 @@ export { default as WelcomeEmail } from "../emails/welcome";export { default as TeamInvitationEmail } from "../emails/team-invitation";export { default as MonitorPausedEmail } from "../emails/monitor-paused";export { default as MonitorDeactivationEmail } from "../emails/monitor-deactivation";+export { default as PrivateLocationAlertEmail } from "../emails/private-location-alert";export { default as StatusPageMagicLinkEmail } from "../emails/status-page-magic-link";export { monitorDeactivationEmail } from "../hotfix/monitor-deactivation";diff --git a/packages/proto/api/openstatus/private_location/v1/private_location.proto b/packages/proto/api/openstatus/private_location/v1/private_location.protoindex cb0c63e30..4e27cf0a8 100644--- a/packages/proto/api/openstatus/private_location/v1/private_location.proto+++ b/packages/proto/api/openstatus/private_location/v1/private_location.proto@@ -4,6 +4,19 @@ package openstatus.private_location.v1;option go_package = "github.com/openstatushq/openstatus/packages/proto/openstatus/private_location/v1;privatelocationv1";+// PrivateLocationStatus is the computed health of a private location, derived+// from the agent heartbeat. Read-only — it cannot be set through the API.+enum PrivateLocationStatus {+ // PRIVATE_LOCATION_STATUS_UNSPECIFIED indicates an unknown status.+ PRIVATE_LOCATION_STATUS_UNSPECIFIED = 0;++ // PRIVATE_LOCATION_STATUS_ACTIVE means the agent is reporting normally.+ PRIVATE_LOCATION_STATUS_ACTIVE = 1;++ // PRIVATE_LOCATION_STATUS_ERROR means the agent has stopped reporting.+ PRIVATE_LOCATION_STATUS_ERROR = 2;+}+// PrivateLocation represents a self-hosted checker agent with full details.message PrivateLocation {// Unique identifier for the private location.@@ -27,6 +40,12 @@ message PrivateLocation {// Timestamp when the private location was last updated (RFC 3339 format).string updated_at = 7;++ // User-defined key/value labels attached to this private location.+ map<string, string> metadata = 8;++ // Computed health of the agent. Read-only.+ PrivateLocationStatus status = 9;}// PrivateLocationSummary represents metadata for a private location (used in@@ -49,4 +68,10 @@ message PrivateLocationSummary {// Timestamp when the private location was last updated (RFC 3339 format).string updated_at = 6;++ // Computed health of the agent. Read-only.+ PrivateLocationStatus status = 7;++ // User-defined key/value labels attached to this private location.+ map<string, string> metadata = 8;}diff --git a/packages/proto/api/openstatus/private_location/v1/service.proto b/packages/proto/api/openstatus/private_location/v1/service.protoindex 6f80c5783..25c5fc997 100644--- a/packages/proto/api/openstatus/private_location/v1/service.proto+++ b/packages/proto/api/openstatus/private_location/v1/service.proto@@ -51,6 +51,13 @@ message CreatePrivateLocationRequest {// IDs of monitors this private location should run (optional).repeated string monitor_ids = 2;++ // User-defined key/value labels (optional, up to 20 entries).+ map<string, string> metadata = 3 [(buf.validate.field).map = {+ max_pairs: 20+ keys: {string: {min_len: 1, max_len: 64}}+ values: {string: {max_len: 256}}+ }];}// CreatePrivateLocationResponse is the response after creating a private location.@@ -110,6 +117,17 @@ message UpdatePrivateLocationRequest {// clears all). When false or unset, monitor_ids is ignored and existing// associations are preserved.optional bool update_monitor_ids = 4;++ // New key/value labels. Only applied when update_metadata is true.+ map<string, string> metadata = 5 [(buf.validate.field).map = {+ max_pairs: 20+ keys: {string: {min_len: 1, max_len: 64}}+ values: {string: {max_len: 256}}+ }];++ // When true, metadata replaces the current labels (an empty map clears all).+ // When false or unset, metadata is ignored and existing labels are preserved.+ optional bool update_metadata = 6;}// UpdatePrivateLocationResponse is the response after updating a private location.diff --git a/packages/proto/gen/openapi.yaml b/packages/proto/gen/openapi.yamlindex 324d1369a..2099c29f6 100644--- a/packages/proto/gen/openapi.yaml+++ b/packages/proto/gen/openapi.yaml@@ -2342,9 +2342,29 @@ components:type: stringtitle: monitor_idsdescription: IDs of monitors this private location should run (optional).+ metadata:+ type: object+ title: metadata+ maxProperties: 20+ additionalProperties:+ type: string+ title: value+ maxLength: 256+ description: User-defined key/value labels (optional, up to 20 entries).title: CreatePrivateLocationRequestadditionalProperties: falsedescription: CreatePrivateLocationRequest is the request to create a new private location.+ openstatus.private_location.v1.CreatePrivateLocationRequest.MetadataEntry:+ type: object+ properties:+ key:+ type: string+ title: key+ value:+ type: string+ title: value+ title: MetadataEntry+ additionalProperties: falseopenstatus.private_location.v1.CreatePrivateLocationResponse:type: objectproperties:@@ -2472,9 +2492,41 @@ components:type: stringtitle: updated_atdescription: Timestamp when the private location was last updated (RFC 3339 format).+ metadata:+ type: object+ title: metadata+ additionalProperties:+ type: string+ title: value+ description: User-defined key/value labels attached to this private location.+ status:+ title: status+ description: Computed health of the agent. Read-only.+ $ref: '#/components/schemas/openstatus.private_location.v1.PrivateLocationStatus'title: PrivateLocationadditionalProperties: falsedescription: PrivateLocation represents a self-hosted checker agent with full details.+ openstatus.private_location.v1.PrivateLocation.MetadataEntry:+ type: object+ properties:+ key:+ type: string+ title: key+ value:+ type: string+ title: value+ title: MetadataEntry+ additionalProperties: false+ openstatus.private_location.v1.PrivateLocationStatus:+ type: string+ title: PrivateLocationStatus+ enum:+ - PRIVATE_LOCATION_STATUS_UNSPECIFIED+ - PRIVATE_LOCATION_STATUS_ACTIVE+ - PRIVATE_LOCATION_STATUS_ERROR+ description: |-+ PrivateLocationStatus is the computed health of a private location, derived+ from the agent heartbeat. Read-only — it cannot be set through the API.openstatus.private_location.v1.PrivateLocationSummary:type: objectproperties:@@ -2503,11 +2555,33 @@ components:type: stringtitle: updated_atdescription: Timestamp when the private location was last updated (RFC 3339 format).+ status:+ title: status+ description: Computed health of the agent. Read-only.+ $ref: '#/components/schemas/openstatus.private_location.v1.PrivateLocationStatus'+ metadata:+ type: object+ title: metadata+ additionalProperties:+ type: string+ title: value+ description: User-defined key/value labels attached to this private location.title: PrivateLocationSummaryadditionalProperties: falsedescription: |-PrivateLocationSummary represents metadata for a private location (used inlist responses). The agent token is intentionally omitted.+ openstatus.private_location.v1.PrivateLocationSummary.MetadataEntry:+ type: object+ properties:+ key:+ type: string+ title: key+ value:+ type: string+ title: value+ title: MetadataEntry+ additionalProperties: falseopenstatus.private_location.v1.UpdatePrivateLocationRequest:type: objectproperties:@@ -2539,9 +2613,37 @@ components:When true, monitor_ids replaces the current associations (an empty listclears all). When false or unset, monitor_ids is ignored and existingassociations are preserved.+ metadata:+ type: object+ title: metadata+ maxProperties: 20+ additionalProperties:+ type: string+ title: value+ maxLength: 256+ description: New key/value labels. Only applied when update_metadata is true.+ updateMetadata:+ type:+ - boolean+ - "null"+ title: update_metadata+ description: |-+ When true, metadata replaces the current labels (an empty map clears all).+ When false or unset, metadata is ignored and existing labels are preserved.title: UpdatePrivateLocationRequestadditionalProperties: falsedescription: UpdatePrivateLocationRequest is the request to update a private location.+ openstatus.private_location.v1.UpdatePrivateLocationRequest.MetadataEntry:+ type: object+ properties:+ key:+ type: string+ title: key+ value:+ type: string+ title: value+ title: MetadataEntry+ additionalProperties: falseopenstatus.private_location.v1.UpdatePrivateLocationResponse:type: objectproperties:diff --git a/packages/proto/gen/ts/openstatus/private_location/v1/private_location_pb.ts b/packages/proto/gen/ts/openstatus/private_location/v1/private_location_pb.tsindex 1618cef8f..0c81780c1 100644--- a/packages/proto/gen/ts/openstatus/private_location/v1/private_location_pb.ts+++ b/packages/proto/gen/ts/openstatus/private_location/v1/private_location_pb.ts@@ -2,15 +2,15 @@// @generated from file openstatus/private_location/v1/private_location.proto (package openstatus.private_location.v1, syntax proto3)/* eslint-disable */-import type { GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2";-import { fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2";+import type { GenEnum, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2";+import { enumDesc, fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2";import type { Message } from "@bufbuild/protobuf";/*** Describes the file openstatus/private_location/v1/private_location.proto.*/export const file_openstatus_private_location_v1_private_location: GenFile = /*@__PURE__*/- fileDesc("CjVvcGVuc3RhdHVzL3ByaXZhdGVfbG9jYXRpb24vdjEvcHJpdmF0ZV9sb2NhdGlvbi5wcm90bxIeb3BlbnN0YXR1cy5wcml2YXRlX2xvY2F0aW9uLnYxIo0BCg9Qcml2YXRlTG9jYXRpb24SCgoCaWQYASABKAkSDAoEbmFtZRgCIAEoCRINCgV0b2tlbhgDIAEoCRITCgttb25pdG9yX2lkcxgEIAMoCRIUCgxsYXN0X3NlZW5fYXQYBSABKAkSEgoKY3JlYXRlZF9hdBgGIAEoCRISCgp1cGRhdGVkX2F0GAcgASgJIocBChZQcml2YXRlTG9jYXRpb25TdW1tYXJ5EgoKAmlkGAEgASgJEgwKBG5hbWUYAiABKAkSFQoNbW9uaXRvcl9jb3VudBgDIAEoBRIUCgxsYXN0X3NlZW5fYXQYBCABKAkSEgoKY3JlYXRlZF9hdBgFIAEoCRISCgp1cGRhdGVkX2F0GAYgASgJQmRaYmdpdGh1Yi5jb20vb3BlbnN0YXR1c2hxL29wZW5zdGF0dXMvcGFja2FnZXMvcHJvdG8vb3BlbnN0YXR1cy9wcml2YXRlX2xvY2F0aW9uL3YxO3ByaXZhdGVsb2NhdGlvbnYxYgZwcm90bzM");+ fileDesc("CjVvcGVuc3RhdHVzL3ByaXZhdGVfbG9jYXRpb24vdjEvcHJpdmF0ZV9sb2NhdGlvbi5wcm90bxIeb3BlbnN0YXR1cy5wcml2YXRlX2xvY2F0aW9uLnYxItYCCg9Qcml2YXRlTG9jYXRpb24SCgoCaWQYASABKAkSDAoEbmFtZRgCIAEoCRINCgV0b2tlbhgDIAEoCRITCgttb25pdG9yX2lkcxgEIAMoCRIUCgxsYXN0X3NlZW5fYXQYBSABKAkSEgoKY3JlYXRlZF9hdBgGIAEoCRISCgp1cGRhdGVkX2F0GAcgASgJEk8KCG1ldGFkYXRhGAggAygLMj0ub3BlbnN0YXR1cy5wcml2YXRlX2xvY2F0aW9uLnYxLlByaXZhdGVMb2NhdGlvbi5NZXRhZGF0YUVudHJ5EkUKBnN0YXR1cxgJIAEoDjI1Lm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5Qcml2YXRlTG9jYXRpb25TdGF0dXMaLwoNTWV0YWRhdGFFbnRyeRILCgNrZXkYASABKAkSDQoFdmFsdWUYAiABKAk6AjgBItcCChZQcml2YXRlTG9jYXRpb25TdW1tYXJ5EgoKAmlkGAEgASgJEgwKBG5hbWUYAiABKAkSFQoNbW9uaXRvcl9jb3VudBgDIAEoBRIUCgxsYXN0X3NlZW5fYXQYBCABKAkSEgoKY3JlYXRlZF9hdBgFIAEoCRISCgp1cGRhdGVkX2F0GAYgASgJEkUKBnN0YXR1cxgHIAEoDjI1Lm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5Qcml2YXRlTG9jYXRpb25TdGF0dXMSVgoIbWV0YWRhdGEYCCADKAsyRC5vcGVuc3RhdHVzLnByaXZhdGVfbG9jYXRpb24udjEuUHJpdmF0ZUxvY2F0aW9uU3VtbWFyeS5NZXRhZGF0YUVudHJ5Gi8KDU1ldGFkYXRhRW50cnkSCwoDa2V5GAEgASgJEg0KBXZhbHVlGAIgASgJOgI4ASqHAQoVUHJpdmF0ZUxvY2F0aW9uU3RhdHVzEicKI1BSSVZBVEVfTE9DQVRJT05fU1RBVFVTX1VOU1BFQ0lGSUVEEAASIgoeUFJJVkFURV9MT0NBVElPTl9TVEFUVVNfQUNUSVZFEAESIQodUFJJVkFURV9MT0NBVElPTl9TVEFUVVNfRVJST1IQAkJkWmJnaXRodWIuY29tL29wZW5zdGF0dXNocS9vcGVuc3RhdHVzL3BhY2thZ2VzL3Byb3RvL29wZW5zdGF0dXMvcHJpdmF0ZV9sb2NhdGlvbi92MTtwcml2YXRlbG9jYXRpb252MWIGcHJvdG8z");/*** PrivateLocation represents a self-hosted checker agent with full details.@@ -67,6 +67,20 @@ export type PrivateLocation = Message<"openstatus.private_location.v1.PrivateLoc* @generated from field: string updated_at = 7;*/updatedAt: string;++ /**+ * User-defined key/value labels attached to this private location.+ *+ * @generated from field: map<string, string> metadata = 8;+ */+ metadata: { [key: string]: string };++ /**+ * Computed health of the agent. Read-only.+ *+ * @generated from field: openstatus.private_location.v1.PrivateLocationStatus status = 9;+ */+ status: PrivateLocationStatus;};/**@@ -124,6 +138,20 @@ export type PrivateLocationSummary = Message<"openstatus.private_location.v1.Pri* @generated from field: string updated_at = 6;*/updatedAt: string;++ /**+ * Computed health of the agent. Read-only.+ *+ * @generated from field: openstatus.private_location.v1.PrivateLocationStatus status = 7;+ */+ status: PrivateLocationStatus;++ /**+ * User-defined key/value labels attached to this private location.+ *+ * @generated from field: map<string, string> metadata = 8;+ */+ metadata: { [key: string]: string };};/**@@ -133,3 +161,38 @@ export type PrivateLocationSummary = Message<"openstatus.private_location.v1.Priexport const PrivateLocationSummarySchema: GenMessage<PrivateLocationSummary> = /*@__PURE__*/messageDesc(file_openstatus_private_location_v1_private_location, 1);+/**+ * PrivateLocationStatus is the computed health of a private location, derived+ * from the agent heartbeat. Read-only — it cannot be set through the API.+ *+ * @generated from enum openstatus.private_location.v1.PrivateLocationStatus+ */+export enum PrivateLocationStatus {+ /**+ * PRIVATE_LOCATION_STATUS_UNSPECIFIED indicates an unknown status.+ *+ * @generated from enum value: PRIVATE_LOCATION_STATUS_UNSPECIFIED = 0;+ */+ UNSPECIFIED = 0,++ /**+ * PRIVATE_LOCATION_STATUS_ACTIVE means the agent is reporting normally.+ *+ * @generated from enum value: PRIVATE_LOCATION_STATUS_ACTIVE = 1;+ */+ ACTIVE = 1,++ /**+ * PRIVATE_LOCATION_STATUS_ERROR means the agent has stopped reporting.+ *+ * @generated from enum value: PRIVATE_LOCATION_STATUS_ERROR = 2;+ */+ ERROR = 2,+}++/**+ * Describes the enum openstatus.private_location.v1.PrivateLocationStatus.+ */+export const PrivateLocationStatusSchema: GenEnum<PrivateLocationStatus> = /*@__PURE__*/+ enumDesc(file_openstatus_private_location_v1_private_location, 0);+diff --git a/packages/proto/gen/ts/openstatus/private_location/v1/service_pb.ts b/packages/proto/gen/ts/openstatus/private_location/v1/service_pb.tsindex a8d4c7395..32d98ad17 100644--- a/packages/proto/gen/ts/openstatus/private_location/v1/service_pb.ts+++ b/packages/proto/gen/ts/openstatus/private_location/v1/service_pb.ts@@ -14,7 +14,7 @@ import type { Message } from "@bufbuild/protobuf";* Describes the file openstatus/private_location/v1/service.proto.*/export const file_openstatus_private_location_v1_service: GenFile = /*@__PURE__*/- fileDesc("CixvcGVuc3RhdHVzL3ByaXZhdGVfbG9jYXRpb24vdjEvc2VydmljZS5wcm90bxIeb3BlbnN0YXR1cy5wcml2YXRlX2xvY2F0aW9uLnYxImEKHENyZWF0ZVByaXZhdGVMb2NhdGlvblJlcXVlc3QSLAoEbmFtZRgBIAEoCUIeukcROg8SDWV1LXdlc3QtYWdlbnS6SAdyBRABGIACEhMKC21vbml0b3JfaWRzGAIgAygJImoKHUNyZWF0ZVByaXZhdGVMb2NhdGlvblJlc3BvbnNlEkkKEHByaXZhdGVfbG9jYXRpb24YASABKAsyLy5vcGVuc3RhdHVzLnByaXZhdGVfbG9jYXRpb24udjEuUHJpdmF0ZUxvY2F0aW9uIjAKGUdldFByaXZhdGVMb2NhdGlvblJlcXVlc3QSEwoCaWQYASABKAlCB7pIBHICEAEiZwoaR2V0UHJpdmF0ZUxvY2F0aW9uUmVzcG9uc2USSQoQcHJpdmF0ZV9sb2NhdGlvbhgBIAEoCzIvLm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5Qcml2YXRlTG9jYXRpb24ibwobTGlzdFByaXZhdGVMb2NhdGlvbnNSZXF1ZXN0Eh0KBWxpbWl0GAEgASgFQgm6SAYaBBhkKAFIAIgBARIcCgZvZmZzZXQYAiABKAVCB7pIBBoCKABIAYgBAUIICgZfbGltaXRCCQoHX29mZnNldCKFAQocTGlzdFByaXZhdGVMb2NhdGlvbnNSZXNwb25zZRJRChFwcml2YXRlX2xvY2F0aW9ucxgBIAMoCzI2Lm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5Qcml2YXRlTG9jYXRpb25TdW1tYXJ5EhIKCnRvdGFsX3NpemUYAiABKAUiqAEKHFVwZGF0ZVByaXZhdGVMb2NhdGlvblJlcXVlc3QSEwoCaWQYASABKAlCB7pIBHICEAESHQoEbmFtZRgCIAEoCUIKukgHcgUQARiAAkgAiAEBEhMKC21vbml0b3JfaWRzGAMgAygJEh8KEnVwZGF0ZV9tb25pdG9yX2lkcxgEIAEoCEgBiAEBQgcKBV9uYW1lQhUKE191cGRhdGVfbW9uaXRvcl9pZHMiagodVXBkYXRlUHJpdmF0ZUxvY2F0aW9uUmVzcG9uc2USSQoQcHJpdmF0ZV9sb2NhdGlvbhgBIAEoCzIvLm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5Qcml2YXRlTG9jYXRpb24iMwocRGVsZXRlUHJpdmF0ZUxvY2F0aW9uUmVxdWVzdBITCgJpZBgBIAEoCUIHukgEcgIQASIwCh1EZWxldGVQcml2YXRlTG9jYXRpb25SZXNwb25zZRIPCgdzdWNjZXNzGAEgASgIMvIHChZQcml2YXRlTG9jYXRpb25TZXJ2aWNlEv0CChVDcmVhdGVQcml2YXRlTG9jYXRpb24SPC5vcGVuc3RhdHVzLnByaXZhdGVfbG9jYXRpb24udjEuQ3JlYXRlUHJpdmF0ZUxvY2F0aW9uUmVxdWVzdBo9Lm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5DcmVhdGVQcml2YXRlTG9jYXRpb25SZXNwb25zZSLmAbpH4gEa3wFDcmVhdGVzIGEgcHJpdmF0ZSBsb2NhdGlvbi4gVGhlIGFnZW50IHRva2VuIGlzIGdlbmVyYXRlZCBieSB0aGUgc2VydmVyIGFuZCByZXR1cm5lZCBpbiB0aGUgcmVzcG9uc2UgLSBpdCBjYW5ub3QgYmUgc3VwcGxpZWQgYnkgdGhlIGNhbGxlci4gVXNlIHRoZSB0b2tlbiB0byBjb25maWd1cmUgdGhlIGFnZW50IHNvIGl0IGNhbiBwdWxsIGl0cyBtb25pdG9ycyBhbmQgcmVwb3J0IHJlc3VsdHMuEpABChJHZXRQcml2YXRlTG9jYXRpb24SOS5vcGVuc3RhdHVzLnByaXZhdGVfbG9jYXRpb24udjEuR2V0UHJpdmF0ZUxvY2F0aW9uUmVxdWVzdBo6Lm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5HZXRQcml2YXRlTG9jYXRpb25SZXNwb25zZSIDkAIBEpYBChRMaXN0UHJpdmF0ZUxvY2F0aW9ucxI7Lm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5MaXN0UHJpdmF0ZUxvY2F0aW9uc1JlcXVlc3QaPC5vcGVuc3RhdHVzLnByaXZhdGVfbG9jYXRpb24udjEuTGlzdFByaXZhdGVMb2NhdGlvbnNSZXNwb25zZSIDkAIBEpQBChVVcGRhdGVQcml2YXRlTG9jYXRpb24SPC5vcGVuc3RhdHVzLnByaXZhdGVfbG9jYXRpb24udjEuVXBkYXRlUHJpdmF0ZUxvY2F0aW9uUmVxdWVzdBo9Lm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5VcGRhdGVQcml2YXRlTG9jYXRpb25SZXNwb25zZRKUAQoVRGVsZXRlUHJpdmF0ZUxvY2F0aW9uEjwub3BlbnN0YXR1cy5wcml2YXRlX2xvY2F0aW9uLnYxLkRlbGV0ZVByaXZhdGVMb2NhdGlvblJlcXVlc3QaPS5vcGVuc3RhdHVzLnByaXZhdGVfbG9jYXRpb24udjEuRGVsZXRlUHJpdmF0ZUxvY2F0aW9uUmVzcG9uc2VCZFpiZ2l0aHViLmNvbS9vcGVuc3RhdHVzaHEvb3BlbnN0YXR1cy9wYWNrYWdlcy9wcm90by9vcGVuc3RhdHVzL3ByaXZhdGVfbG9jYXRpb24vdjE7cHJpdmF0ZWxvY2F0aW9udjFiBnByb3RvMw", [file_buf_validate_validate, file_gnostic_openapi_v3_annotations, file_openstatus_private_location_v1_private_location]);+ fileDesc("CixvcGVuc3RhdHVzL3ByaXZhdGVfbG9jYXRpb24vdjEvc2VydmljZS5wcm90bxIeb3BlbnN0YXR1cy5wcml2YXRlX2xvY2F0aW9uLnYxIokCChxDcmVhdGVQcml2YXRlTG9jYXRpb25SZXF1ZXN0EiwKBG5hbWUYASABKAlCHrpHEToPEg1ldS13ZXN0LWFnZW50ukgHcgUQARiAAhITCgttb25pdG9yX2lkcxgCIAMoCRJ1CghtZXRhZGF0YRgDIAMoCzJKLm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5DcmVhdGVQcml2YXRlTG9jYXRpb25SZXF1ZXN0Lk1ldGFkYXRhRW50cnlCF7pIFJoBERAUIgZyBBABGEAqBXIDGIACGi8KDU1ldGFkYXRhRW50cnkSCwoDa2V5GAEgASgJEg0KBXZhbHVlGAIgASgJOgI4ASJqCh1DcmVhdGVQcml2YXRlTG9jYXRpb25SZXNwb25zZRJJChBwcml2YXRlX2xvY2F0aW9uGAEgASgLMi8ub3BlbnN0YXR1cy5wcml2YXRlX2xvY2F0aW9uLnYxLlByaXZhdGVMb2NhdGlvbiIwChlHZXRQcml2YXRlTG9jYXRpb25SZXF1ZXN0EhMKAmlkGAEgASgJQge6SARyAhABImcKGkdldFByaXZhdGVMb2NhdGlvblJlc3BvbnNlEkkKEHByaXZhdGVfbG9jYXRpb24YASABKAsyLy5vcGVuc3RhdHVzLnByaXZhdGVfbG9jYXRpb24udjEuUHJpdmF0ZUxvY2F0aW9uIm8KG0xpc3RQcml2YXRlTG9jYXRpb25zUmVxdWVzdBIdCgVsaW1pdBgBIAEoBUIJukgGGgQYZCgBSACIAQESHAoGb2Zmc2V0GAIgASgFQge6SAQaAigASAGIAQFCCAoGX2xpbWl0QgkKB19vZmZzZXQihQEKHExpc3RQcml2YXRlTG9jYXRpb25zUmVzcG9uc2USUQoRcHJpdmF0ZV9sb2NhdGlvbnMYASADKAsyNi5vcGVuc3RhdHVzLnByaXZhdGVfbG9jYXRpb24udjEuUHJpdmF0ZUxvY2F0aW9uU3VtbWFyeRISCgp0b3RhbF9zaXplGAIgASgFIoIDChxVcGRhdGVQcml2YXRlTG9jYXRpb25SZXF1ZXN0EhMKAmlkGAEgASgJQge6SARyAhABEh0KBG5hbWUYAiABKAlCCrpIB3IFEAEYgAJIAIgBARITCgttb25pdG9yX2lkcxgDIAMoCRIfChJ1cGRhdGVfbW9uaXRvcl9pZHMYBCABKAhIAYgBARJ1CghtZXRhZGF0YRgFIAMoCzJKLm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5VcGRhdGVQcml2YXRlTG9jYXRpb25SZXF1ZXN0Lk1ldGFkYXRhRW50cnlCF7pIFJoBERAUIgZyBBABGEAqBXIDGIACEhwKD3VwZGF0ZV9tZXRhZGF0YRgGIAEoCEgCiAEBGi8KDU1ldGFkYXRhRW50cnkSCwoDa2V5GAEgASgJEg0KBXZhbHVlGAIgASgJOgI4AUIHCgVfbmFtZUIVChNfdXBkYXRlX21vbml0b3JfaWRzQhIKEF91cGRhdGVfbWV0YWRhdGEiagodVXBkYXRlUHJpdmF0ZUxvY2F0aW9uUmVzcG9uc2USSQoQcHJpdmF0ZV9sb2NhdGlvbhgBIAEoCzIvLm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5Qcml2YXRlTG9jYXRpb24iMwocRGVsZXRlUHJpdmF0ZUxvY2F0aW9uUmVxdWVzdBITCgJpZBgBIAEoCUIHukgEcgIQASIwCh1EZWxldGVQcml2YXRlTG9jYXRpb25SZXNwb25zZRIPCgdzdWNjZXNzGAEgASgIMvIHChZQcml2YXRlTG9jYXRpb25TZXJ2aWNlEv0CChVDcmVhdGVQcml2YXRlTG9jYXRpb24SPC5vcGVuc3RhdHVzLnByaXZhdGVfbG9jYXRpb24udjEuQ3JlYXRlUHJpdmF0ZUxvY2F0aW9uUmVxdWVzdBo9Lm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5DcmVhdGVQcml2YXRlTG9jYXRpb25SZXNwb25zZSLmAbpH4gEa3wFDcmVhdGVzIGEgcHJpdmF0ZSBsb2NhdGlvbi4gVGhlIGFnZW50IHRva2VuIGlzIGdlbmVyYXRlZCBieSB0aGUgc2VydmVyIGFuZCByZXR1cm5lZCBpbiB0aGUgcmVzcG9uc2UgLSBpdCBjYW5ub3QgYmUgc3VwcGxpZWQgYnkgdGhlIGNhbGxlci4gVXNlIHRoZSB0b2tlbiB0byBjb25maWd1cmUgdGhlIGFnZW50IHNvIGl0IGNhbiBwdWxsIGl0cyBtb25pdG9ycyBhbmQgcmVwb3J0IHJlc3VsdHMuEpABChJHZXRQcml2YXRlTG9jYXRpb24SOS5vcGVuc3RhdHVzLnByaXZhdGVfbG9jYXRpb24udjEuR2V0UHJpdmF0ZUxvY2F0aW9uUmVxdWVzdBo6Lm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5HZXRQcml2YXRlTG9jYXRpb25SZXNwb25zZSIDkAIBEpYBChRMaXN0UHJpdmF0ZUxvY2F0aW9ucxI7Lm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5MaXN0UHJpdmF0ZUxvY2F0aW9uc1JlcXVlc3QaPC5vcGVuc3RhdHVzLnByaXZhdGVfbG9jYXRpb24udjEuTGlzdFByaXZhdGVMb2NhdGlvbnNSZXNwb25zZSIDkAIBEpQBChVVcGRhdGVQcml2YXRlTG9jYXRpb24SPC5vcGVuc3RhdHVzLnByaXZhdGVfbG9jYXRpb24udjEuVXBkYXRlUHJpdmF0ZUxvY2F0aW9uUmVxdWVzdBo9Lm9wZW5zdGF0dXMucHJpdmF0ZV9sb2NhdGlvbi52MS5VcGRhdGVQcml2YXRlTG9jYXRpb25SZXNwb25zZRKUAQoVRGVsZXRlUHJpdmF0ZUxvY2F0aW9uEjwub3BlbnN0YXR1cy5wcml2YXRlX2xvY2F0aW9uLnYxLkRlbGV0ZVByaXZhdGVMb2NhdGlvblJlcXVlc3QaPS5vcGVuc3RhdHVzLnByaXZhdGVfbG9jYXRpb24udjEuRGVsZXRlUHJpdmF0ZUxvY2F0aW9uUmVzcG9uc2VCZFpiZ2l0aHViLmNvbS9vcGVuc3RhdHVzaHEvb3BlbnN0YXR1cy9wYWNrYWdlcy9wcm90by9vcGVuc3RhdHVzL3ByaXZhdGVfbG9jYXRpb24vdjE7cHJpdmF0ZWxvY2F0aW9udjFiBnByb3RvMw", [file_buf_validate_validate, file_gnostic_openapi_v3_annotations, file_openstatus_private_location_v1_private_location]);/*** CreatePrivateLocationRequest is the request to create a new private location.@@ -35,6 +35,13 @@ export type CreatePrivateLocationRequest = Message<"openstatus.private_location.* @generated from field: repeated string monitor_ids = 2;*/monitorIds: string[];++ /**+ * User-defined key/value labels (optional, up to 20 entries).+ *+ * @generated from field: map<string, string> metadata = 3;+ */+ metadata: { [key: string]: string };};/**@@ -198,6 +205,21 @@ export type UpdatePrivateLocationRequest = Message<"openstatus.private_location.* @generated from field: optional bool update_monitor_ids = 4;*/updateMonitorIds?: boolean | undefined;++ /**+ * New key/value labels. Only applied when update_metadata is true.+ *+ * @generated from field: map<string, string> metadata = 5;+ */+ metadata: { [key: string]: string };++ /**+ * When true, metadata replaces the current labels (an empty map clears all).+ * When false or unset, metadata is ignored and existing labels are preserved.+ *+ * @generated from field: optional bool update_metadata = 6;+ */+ updateMetadata?: boolean | undefined;};/**diff --git a/packages/services/src/agent-tools/private-location.ts b/packages/services/src/agent-tools/private-location.tsindex 003cda944..c1d74103d 100644--- a/packages/services/src/agent-tools/private-location.ts+++ b/packages/services/src/agent-tools/private-location.ts@@ -31,6 +31,8 @@ const ListPrivateLocationsOutput = z.object({z.object({id: z.number().int(),name: z.string(),+ status: z.enum(["active", "error"]),+ metadata: z.record(z.string(), z.string()).nullable(),monitorIds: z.array(z.number().int()),lastSeenAt: z.string().nullable(),createdAt: z.string().nullable(),@@ -51,7 +53,7 @@ export const listPrivateLocationsTool: AgentTool<> = {name: "list_private_locations",description:- "List private locations (self-hosted checker agents) in this workspace, with the monitors each one runs and when it last reported in. Read-only — agent tokens are NOT exposed. Use `lastSeenAt` to tell whether an agent is still alive before blaming a monitor for missing checks.",+ 'List private locations (self-hosted checker agents) in this workspace, with the monitors each one runs and when it last reported in. Read-only — agent tokens are NOT exposed. `status: "error"` means the agent is not currently healthy (it may not have reported yet or may have a stale heartbeat); use `lastSeenAt` to tell whether an agent is still alive before blaming a monitor for missing checks. `metadata` holds user-defined key/value labels.',scope: "read",destructive: false,inputSchema: ListPrivateLocationsInputShape,@@ -69,6 +71,8 @@ export const listPrivateLocationsTool: AgentTool<items: result.items.map((location) => ({id: location.id,name: location.name,+ status: location.status,+ metadata: location.metadata ?? null,monitorIds: location.monitors.map((m) => m.id),lastSeenAt: location.lastSeenAt?.toISOString() ?? null,createdAt: location.createdAt?.toISOString() ?? null,diff --git a/packages/services/src/private-location/__tests__/private-location.test.ts b/packages/services/src/private-location/__tests__/private-location.test.tsindex 93e3cafd6..08c0fd585 100644--- a/packages/services/src/private-location/__tests__/private-location.test.ts+++ b/packages/services/src/private-location/__tests__/private-location.test.ts@@ -25,6 +25,7 @@ import { createPrivateLocation } from "../create";import { deletePrivateLocation } from "../delete";import { getPrivateLocation } from "../get";import { listPrivateLocations } from "../list";+import { setPrivateLocationStatus } from "../set-status";import { updatePrivateLocation } from "../update";const TEST_PREFIX = "svc-private-location-test";@@ -217,6 +218,84 @@ describe("createPrivateLocation", () => {});});+ test("persists metadata and audits it", async () => {+ await withTestTransaction(async (tx) => {+ const row = await createPrivateLocation({+ ctx: { ...teamCtx, db: tx },+ input: {+ name: `${TEST_PREFIX}-metadata`,+ monitors: [],+ metadata: { datacenter: "eu-west", rack: "A3" },+ },+ });++ expect(row.metadata).toEqual({ datacenter: "eu-west", rack: "A3" });++ const audit = await readAuditLog({+ workspaceId: teamCtx.workspace.id,+ entityType: "private_location",+ entityId: String(row.id),+ db: tx,+ });+ const created = audit.find((r) => r.action === "private_location.create");+ expect(+ (created?.after as { metadata?: Record<string, string> } | undefined)+ ?.metadata,+ ).toEqual({ datacenter: "eu-west", rack: "A3" });+ });+ });++ test("stores null metadata when none is supplied", async () => {+ await withTestTransaction(async (tx) => {+ const row = await createPrivateLocation({+ ctx: { ...teamCtx, db: tx },+ input: { name: `${TEST_PREFIX}-no-metadata`, monitors: [] },+ });++ expect(row.metadata).toBeNull();+ });+ });++ test("rejects metadata beyond the allowed limits", async () => {+ await withTestTransaction(async (tx) => {+ const tooMany = Object.fromEntries(+ Array.from({ length: 21 }, (_, i) => [`k${i}`, "v"]),+ );+ await expect(+ createPrivateLocation({+ ctx: { ...teamCtx, db: tx },+ input: {+ name: `${TEST_PREFIX}-too-many`,+ monitors: [],+ metadata: tooMany,+ },+ }),+ ).rejects.toBeTruthy();++ await expect(+ createPrivateLocation({+ ctx: { ...teamCtx, db: tx },+ input: {+ name: `${TEST_PREFIX}-long-value`,+ monitors: [],+ metadata: { k: "x".repeat(257) },+ },+ }),+ ).rejects.toBeTruthy();+ });+ });++ test("defaults status to error until the agent reports in", async () => {+ await withTestTransaction(async (tx) => {+ const row = await createPrivateLocation({+ ctx: { ...teamCtx, db: tx },+ input: { name: `${TEST_PREFIX}-status-default`, monitors: [] },+ });++ expect(row.status).toBe("error");+ });+ });+test("rejects read-only actor", async () => {await withTestTransaction(async (tx) => {const ctx = {@@ -370,6 +449,75 @@ describe("updatePrivateLocation", () => {});});+ test("replaces metadata and audits the change", async () => {+ await withTestTransaction(async (tx) => {+ const ctx = { ...teamCtx, db: tx };+ const created = await createPrivateLocation({+ ctx,+ input: {+ name: `${TEST_PREFIX}-meta-seed`,+ monitors: [],+ metadata: { a: "1" },+ },+ });++ const updated = await updatePrivateLocation({+ ctx,+ input: { id: created.id, metadata: { b: "2", c: "3" } },+ });+ expect(updated.metadata).toEqual({ b: "2", c: "3" });++ const audit = await readAuditLog({+ workspaceId: teamCtx.workspace.id,+ entityType: "private_location",+ entityId: String(created.id),+ db: tx,+ });+ const row = audit.find((r) => r.action === "private_location.update");+ expect(row?.changedFields).toContain("metadata");+ });+ });++ test("clears metadata when given an empty object", async () => {+ await withTestTransaction(async (tx) => {+ const ctx = { ...teamCtx, db: tx };+ const created = await createPrivateLocation({+ ctx,+ input: {+ name: `${TEST_PREFIX}-meta-clear`,+ monitors: [],+ metadata: { a: "1" },+ },+ });++ const updated = await updatePrivateLocation({+ ctx,+ input: { id: created.id, metadata: {} },+ });+ expect(updated.metadata).toBeNull();+ });+ });++ test("preserves metadata when the field is omitted", async () => {+ await withTestTransaction(async (tx) => {+ const ctx = { ...teamCtx, db: tx };+ const created = await createPrivateLocation({+ ctx,+ input: {+ name: `${TEST_PREFIX}-meta-preserve`,+ monitors: [],+ metadata: { a: "1" },+ },+ });++ const updated = await updatePrivateLocation({+ ctx,+ input: { id: created.id, name: `${TEST_PREFIX}-meta-renamed` },+ });+ expect(updated.metadata).toEqual({ a: "1" });+ });+ });+test("rejects read-only actor", async () => {await withTestTransaction(async (tx) => {const ctx = {@@ -387,6 +535,99 @@ describe("updatePrivateLocation", () => {});});+describe("setPrivateLocationStatus", () => {+ test("flips status and audits the change", async () => {+ await withTestTransaction(async (tx) => {+ const ctx = { ...teamCtx, db: tx };+ const created = await createPrivateLocation({+ ctx,+ input: { name: `${TEST_PREFIX}-set-status`, monitors: [] },+ });+ expect(created.status).toBe("error");++ const updated = await setPrivateLocationStatus({+ ctx,+ input: { id: created.id, status: "active" },+ });+ expect(updated.status).toBe("active");++ const audit = await readAuditLog({+ workspaceId: teamCtx.workspace.id,+ entityType: "private_location",+ entityId: String(created.id),+ db: tx,+ });+ const row = audit.find((r) => r.action === "private_location.update");+ expect(row?.changedFields).toContain("status");+ });+ });++ test("is a no-op when the status is unchanged", async () => {+ await withTestTransaction(async (tx) => {+ const ctx = { ...teamCtx, db: tx };+ const created = await createPrivateLocation({+ ctx,+ input: { name: `${TEST_PREFIX}-set-status-noop`, monitors: [] },+ });++ await setPrivateLocationStatus({+ ctx,+ input: { id: created.id, status: "error" },+ });++ const rows = await readAuditLog({+ workspaceId: teamCtx.workspace.id,+ entityType: "private_location",+ entityId: String(created.id),+ db: tx,+ });+ expect(rows.some((r) => r.action === "private_location.update")).toBe(+ false,+ );+ });+ });++ test("throws NotFoundError for another workspace's location", async () => {+ await withTestTransaction(async (tx) => {+ const other = await tx+ .insert(privateLocation)+ .values({+ name: `${TEST_PREFIX}-set-status-foreign`,+ token: "foreign-token-status",+ workspaceId: otherWorkspaceId,+ })+ .returning()+ .get();++ await expect(+ setPrivateLocationStatus({+ ctx: { ...teamCtx, db: tx },+ input: { id: other.id, status: "error" },+ }),+ ).rejects.toBeInstanceOf(NotFoundError);+ });+ });++ test("rejects read-only actor", async () => {+ await withTestTransaction(async (tx) => {+ const ctx = {+ ...makeApiKeyCtx(teamCtx.workspace, {+ keyId: "k",+ userId: 1,+ scopes: ["read"],+ }),+ db: tx,+ };+ await expect(+ setPrivateLocationStatus({+ ctx,+ input: { id: 1, status: "error" },+ }),+ ).rejects.toBeInstanceOf(ForbiddenError);+ });+ });+});+describe("getPrivateLocation", () => {test("returns the location with its monitors", async () => {await withTestTransaction(async (tx) => {diff --git a/packages/services/src/private-location/create.ts b/packages/services/src/private-location/create.tsindex 22d2e98d2..a8e5339e8 100644--- a/packages/services/src/private-location/create.ts+++ b/packages/services/src/private-location/create.ts@@ -48,6 +48,10 @@ export async function createPrivateLocation(args: {.values({name: input.name,token,+ metadata:+ input.metadata && Object.keys(input.metadata).length > 0+ ? input.metadata+ : null,workspaceId: ctx.workspace.id,}).returning()diff --git a/packages/services/src/private-location/index.ts b/packages/services/src/private-location/index.tsindex 83fb2d5ec..fd393e6b9 100644--- a/packages/services/src/private-location/index.ts+++ b/packages/services/src/private-location/index.ts@@ -2,11 +2,14 @@ export { createPrivateLocation } from "./create";export { deletePrivateLocation } from "./delete";export { getPrivateLocation } from "./get";export { listPrivateLocations } from "./list";+export { setPrivateLocationStatus } from "./set-status";export { updatePrivateLocation } from "./update";export {CreatePrivateLocationInput,DeletePrivateLocationInput,GetPrivateLocationInput,ListPrivateLocationsInput,+ PrivateLocationMetadata,+ SetPrivateLocationStatusInput,UpdatePrivateLocationInput,} from "./schemas";diff --git a/packages/services/src/private-location/schemas.ts b/packages/services/src/private-location/schemas.tsindex 1db4ae5c6..6cb07a625 100644--- a/packages/services/src/private-location/schemas.ts+++ b/packages/services/src/private-location/schemas.ts@@ -12,10 +12,16 @@ export type ListPrivateLocationsInput = z.infer<const monitorIds = z.array(z.number().int().positive());+export const PrivateLocationMetadata = z+ .record(z.string().min(1).max(64), z.string().max(256))+ .refine((m) => Object.keys(m).length <= 20, "max 20 metadata entries");+export type PrivateLocationMetadata = z.infer<typeof PrivateLocationMetadata>;+export const CreatePrivateLocationInput = z.object({name: z.string().min(1),token: z.string().min(1).optional(),monitors: monitorIds,+ metadata: PrivateLocationMetadata.optional(),});export type CreatePrivateLocationInput = z.infer<typeof CreatePrivateLocationInput@@ -25,11 +31,20 @@ export const UpdatePrivateLocationInput = z.object({id: z.number().int(),name: z.string().min(1).optional(),monitors: monitorIds.optional(),+ metadata: PrivateLocationMetadata.optional(),});export type UpdatePrivateLocationInput = z.infer<typeof UpdatePrivateLocationInput>;+export const SetPrivateLocationStatusInput = z.object({+ id: z.number().int(),+ status: z.enum(["active", "error"]),+});+export type SetPrivateLocationStatusInput = z.infer<+ typeof SetPrivateLocationStatusInput+>;+export const GetPrivateLocationInput = z.object({ id: z.number().int() });export type GetPrivateLocationInput = z.infer<typeof GetPrivateLocationInput>;diff --git a/packages/services/src/private-location/set-status.ts b/packages/services/src/private-location/set-status.tsnew file mode 100644index 000000000..0c707094c--- /dev/null+++ b/packages/services/src/private-location/set-status.ts@@ -0,0 +1,70 @@+import { and, eq } from "@openstatus/db";+import {+ privateLocation,+ selectPrivateLocationSchema,+} from "@openstatus/db/src/schema";++import { emitAudit } from "../audit";+import { requireScope } from "../auth";+import { type ServiceContext, withTransaction } from "../context";+import { NotFoundError } from "../errors";+import type { PrivateLocation } from "../types";+import { SetPrivateLocationStatusInput } from "./schemas";++/**+ * Set a private location's health status. Cron-only writer — the value is+ * derived from the agent heartbeat, never from user input. Returns early+ * without a write or audit row when the status is unchanged.+ */+export async function setPrivateLocationStatus(args: {+ ctx: ServiceContext;+ input: SetPrivateLocationStatusInput;+}): Promise<PrivateLocation> {+ const { ctx } = args;+ requireScope(ctx, "write");+ const input = SetPrivateLocationStatusInput.parse(args.input);++ return withTransaction(ctx, async (tx) => {+ const existing = await tx.query.privateLocation.findFirst({+ where: and(+ eq(privateLocation.id, input.id),+ eq(privateLocation.workspaceId, ctx.workspace.id),+ ),+ });++ if (!existing) {+ throw new NotFoundError("private_location", input.id);+ }++ const beforeParsed = selectPrivateLocationSchema.parse(existing);+ if (beforeParsed.status === input.status) {+ return beforeParsed;+ }++ const row = await tx+ .update(privateLocation)+ .set({ status: input.status, updatedAt: new Date() })+ .where(+ and(+ eq(privateLocation.id, input.id),+ eq(privateLocation.workspaceId, ctx.workspace.id),+ ),+ )+ .returning()+ .get();++ if (!row) throw new NotFoundError("private_location", input.id);++ const afterParsed = selectPrivateLocationSchema.parse(row);++ await emitAudit(tx, ctx, {+ action: "private_location.update",+ entityType: "private_location",+ entityId: afterParsed.id,+ before: beforeParsed,+ after: afterParsed,+ });++ return afterParsed;+ });+}diff --git a/packages/services/src/private-location/update.ts b/packages/services/src/private-location/update.tsindex adc335611..53047b344 100644--- a/packages/services/src/private-location/update.ts+++ b/packages/services/src/private-location/update.ts@@ -32,6 +32,11 @@ export async function updatePrivateLocation(args: {? Array.from(new Set(input.monitors)): undefined;+ const metadataUpdate =+ input.metadata !== undefined+ ? { metadata: Object.keys(input.metadata).length ? input.metadata : null }+ : undefined;+return withTransaction(ctx, async (tx) => {const existing = await tx.query.privateLocation.findFirst({where: and(@@ -57,11 +62,11 @@ export async function updatePrivateLocation(args: {const row = await tx.update(privateLocation)- .set(- input.name !== undefined- ? { name: input.name, updatedAt: new Date() }- : { updatedAt: new Date() },- )+ .set({+ ...(input.name !== undefined ? { name: input.name } : {}),+ ...metadataUpdate,+ updatedAt: new Date(),+ }).where(and(eq(privateLocation.id, input.id),