/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { safeParse } from "../lib/schemas.js"; import * as openEnums from "../types/enums.js"; import { OpenEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import * as types from "../types/primitives.js"; import { SDKValidationError } from "./errors/sdk-validation-error.js"; export const Severity = { Low: "low", Warning: "warning", High: "high", } as const; export type Severity = OpenEnum; export type Rule = { id: string; type: string; name: string; }; export type ViolationUser = { id: string; username: string; /** * Avatar path from media server */ thumbUrl: string | null; /** * Proxied avatar URL */ avatarUrl: string | null; }; export type Violation = { id: string; serverId: string; serverName: string; severity: Severity; acknowledged: boolean; /** * Rule-specific violation data */ data: { [k: string]: any | null }; createdAt: Date; rule: Rule; user: ViolationUser; }; /** @internal */ export const Severity$inboundSchema: z.ZodMiniType = openEnums.inboundSchema(Severity); /** @internal */ export const Rule$inboundSchema: z.ZodMiniType = z.object({ id: types.string(), type: types.string(), name: types.string(), }); export function ruleFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Rule$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Rule' from JSON`, ); } /** @internal */ export const ViolationUser$inboundSchema: z.ZodMiniType< ViolationUser, unknown > = z.object({ id: types.string(), username: types.string(), thumbUrl: types.nullable(types.string()), avatarUrl: types.nullable(types.string()), }); export function violationUserFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ViolationUser$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ViolationUser' from JSON`, ); } /** @internal */ export const Violation$inboundSchema: z.ZodMiniType = z .object({ id: types.string(), serverId: types.string(), serverName: types.string(), severity: Severity$inboundSchema, acknowledged: types.boolean(), data: z.record(z.string(), types.nullable(z.any())), createdAt: types.date(), rule: z.lazy(() => Rule$inboundSchema), user: z.lazy(() => ViolationUser$inboundSchema), }); export function violationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Violation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Violation' from JSON`, ); }