Openstatus www.openstatus.dev
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 75 lines 2.0 kB view raw
1import { z } from "zod"; 2 3/** 4 * The schema for the monitor.recovered action. 5 * It represents the event when a monitor has recovered from a failure. 6 */ 7export const monitorRecoveredSchema = z.object({ 8 action: z.literal("monitor.recovered"), 9 metadata: z.object({ 10 region: z.string(), 11 statusCode: z.number(), 12 latency: z.number().optional(), 13 cronTimestamp: z.number().optional(), 14 }), 15}); 16 17/** 18 * The schema for the monitor.recovered action. 19 * It represents the event when a monitor has recovered from a failure. 20 */ 21export const monitorDegradedSchema = z.object({ 22 action: z.literal("monitor.degraded"), 23 metadata: z.object({ 24 region: z.string(), 25 statusCode: z.number(), 26 cronTimestamp: z.number().optional(), 27 latency: z.number().optional(), 28 }), 29}); 30 31/** 32 * The schema for the monitor.failed action. 33 * It represents the event when a monitor has failed. 34 */ 35export const monitorFailedSchema = z.object({ 36 action: z.literal("monitor.failed"), 37 metadata: z.object({ 38 region: z.string(), 39 statusCode: z.number().optional(), 40 message: z.string().optional(), 41 latency: z.number().optional(), 42 cronTimestamp: z.number().optional(), 43 }), 44}); 45 46/** 47 * The schema for the notification.send action. 48 * 49 */ 50export const notificationSentSchema = z.object({ 51 action: z.literal("notification.sent"), 52 metadata: z.object({ 53 // we could use the notificationProviderSchema for more type safety 54 provider: z.string(), 55 cronTimestamp: z.number().optional(), 56 type: z.enum(["alert", "recovery", "degraded"]).optional(), 57 notificationId: z.number().optional(), 58 }), 59}); 60 61export const incidentCreatedSchema = z.object({ 62 action: z.literal("incident.created"), 63 metadata: z.object({ 64 cronTimestamp: z.number().optional(), 65 incidentId: z.number().optional(), 66 }), 67}); 68 69export const incidentResolvedSchema = z.object({ 70 action: z.literal("incident.resolved"), 71 metadata: z.object({ 72 cronTimestamp: z.number().optional(), 73 incidentId: z.number().optional(), 74 }), 75});