Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
2.3 kB ยท 66 lines
TypeScript
at incident-api
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667import { z } from "zod";
export const importProviders = [ "statuspage", "betterstack", "instatus", "checkly",] as const;export type ImportProviderName = (typeof importProviders)[number];
/** * `nullish().transform(v => v ?? undefined)` preserves the legacy * router contract (which accepted `null` for every provider page-id * field via `.nullish()`) while normalising the value to `undefined` * inside the service โ downstream `buildProviderConfig` expects * `string | undefined` and doesn't want to learn about `null`. * Switching these to plain `.optional()` would've silently rejected * every client still sending `null`. */const nullishString = z .string() .nullish() .transform((v) => v ?? undefined);
const providerFields = { provider: z.enum(importProviders), apiKey: z.string().min(1), statuspagePageId: nullishString, betterstackStatusPageId: nullishString, instatusPageId: nullishString, checklyAccountId: nullishString, checklyStatusPageId: nullishString,};
export const ImportOptions = z.object({ includeStatusReports: z.boolean().default(true), includeSubscribers: z.boolean().default(false), includeComponents: z.boolean().default(true), includeMonitors: z.boolean().default(true),});export type ImportOptions = z.infer<typeof ImportOptions>;
export const PreviewImportInput = z.object({ ...providerFields, /** * Target an existing status page โ when provided the preview is scoped * against that page's current component count so the remaining-capacity * warnings line up with what `run` will actually do. */ pageId: z.number().int().optional(), /** * Optional same-shape `options` as `RunImportInput`. Exposed on preview * so warning generation can match what the actual run would do โ e.g. * a user planning `includeSubscribers: false` shouldn't see a * "subscribers cannot be imported" warning here. */ options: ImportOptions.partial().optional(),});export type PreviewImportInput = z.infer<typeof PreviewImportInput>;
export const RunImportInput = z.object({ ...providerFields, pageId: z.number().int().optional(), options: ImportOptions.partial().optional(),});export type RunImportInput = z.infer<typeof RunImportInput>;