/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { remap as remap$ } from "../lib/primitives.js"; 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"; /** * Current author status */ export const Status = { Enabled: "enabled", Suspended: "suspended", Blocked: "blocked", } as const; /** * Current author status */ export type Status = OpenEnum; export type TrustLevel = { /** * Author trust level (-1, 0, 1, 2, 3, or 4) */ level: number; /** * True if the trust level was set manually by a moderator */ manual: boolean; }; export type Block = { /** * The timestamp until which they are blocked if the author is suspended. */ until?: number | null | undefined; /** * The moderators reason why the author was blocked or suspended. */ reason?: string | null | undefined; }; export type RiskEvaluation = { /** * Calculated risk level based on more than 10 behavioral signals. */ riskLevel?: number | null | undefined; }; export type Metrics = { /** * Total pieces of content */ totalContent: number; /** * Number of flagged content pieces */ flaggedContent: number; /** * Average sentiment score of content (-1 to 1). Requires a sentiment model in your project. */ averageSentiment?: number | null | undefined; }; /** * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. */ export type Metadata = { /** * Whether the author's email is verified */ emailVerified?: boolean | null | undefined; /** * Whether the author's phone number is verified */ phoneVerified?: boolean | null | undefined; /** * Whether the author's identity is verified */ identityVerified?: boolean | null | undefined; /** * Whether the author is a paying customer */ isPayingCustomer?: boolean | null | undefined; [additionalProperties: string]: unknown; }; export type PublicAuthor = { /** * Author ID in Moderation API */ id: string; /** * The author's ID from your system */ externalId?: string | null | undefined; /** * URL of the author's profile picture */ profilePicture?: string | null | undefined; /** * URL of the author's external profile */ externalLink?: string | null | undefined; /** * Author name or identifier */ name?: string | null | undefined; /** * Author email address */ email?: string | null | undefined; /** * The author's company or organization */ company?: string | null | undefined; /** * Timestamp when author first appeared */ firstSeen: number; /** * Timestamp of last activity */ lastSeen: number; /** * Timestamp of last incident */ lastIncident?: number | null | undefined; /** * Current author status */ status: Status; trustLevel: TrustLevel; /** * Block or suspension details, if applicable. Null if the author is enabled. */ block: Block | null; /** * Risk assessment details, if available. */ riskEvaluation: RiskEvaluation | null; metrics: Metrics; /** * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. */ metadata: Metadata; }; /** @internal */ export const Status$inboundSchema: z.ZodMiniType = openEnums .inboundSchema(Status); /** @internal */ export const TrustLevel$inboundSchema: z.ZodMiniType = z .object({ level: types.number(), manual: types.boolean(), }); export function trustLevelFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TrustLevel$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TrustLevel' from JSON`, ); } /** @internal */ export const Block$inboundSchema: z.ZodMiniType = z.object({ until: z.optional(z.nullable(types.number())), reason: z.optional(z.nullable(types.string())), }); export function blockFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Block$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Block' from JSON`, ); } /** @internal */ export const RiskEvaluation$inboundSchema: z.ZodMiniType< RiskEvaluation, unknown > = z.pipe( z.object({ risk_level: z.optional(z.nullable(types.number())), }), z.transform((v) => { return remap$(v, { "risk_level": "riskLevel", }); }), ); export function riskEvaluationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RiskEvaluation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RiskEvaluation' from JSON`, ); } /** @internal */ export const Metrics$inboundSchema: z.ZodMiniType = z.pipe( z.object({ total_content: types.number(), flagged_content: types.number(), average_sentiment: z.optional(z.nullable(types.number())), }), z.transform((v) => { return remap$(v, { "total_content": "totalContent", "flagged_content": "flaggedContent", "average_sentiment": "averageSentiment", }); }), ); export function metricsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Metrics$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Metrics' from JSON`, ); } /** @internal */ export const Metadata$inboundSchema: z.ZodMiniType = z.pipe( z.catchall( z.object({ email_verified: z.optional(z.nullable(types.boolean())), phone_verified: z.optional(z.nullable(types.boolean())), identity_verified: z.optional(z.nullable(types.boolean())), is_paying_customer: z.optional(z.nullable(types.boolean())), }), z.any(), ), z.transform((v) => { return remap$(v, { "email_verified": "emailVerified", "phone_verified": "phoneVerified", "identity_verified": "identityVerified", "is_paying_customer": "isPayingCustomer", }); }), ); export function metadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Metadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Metadata' from JSON`, ); } /** @internal */ export const PublicAuthor$inboundSchema: z.ZodMiniType = z.pipe( z.object({ id: types.string(), external_id: z.optional(z.nullable(types.string())), profile_picture: z.optional(z.nullable(types.string())), external_link: z.optional(z.nullable(types.string())), name: z.optional(z.nullable(types.string())), email: z.optional(z.nullable(types.string())), company: z.optional(z.nullable(types.string())), first_seen: types.number(), last_seen: types.number(), last_incident: z.optional(z.nullable(types.number())), status: Status$inboundSchema, trust_level: z.lazy(() => TrustLevel$inboundSchema), block: types.nullable(z.lazy(() => Block$inboundSchema)), risk_evaluation: types.nullable( z.lazy(() => RiskEvaluation$inboundSchema), ), metrics: z.lazy(() => Metrics$inboundSchema), metadata: z.lazy(() => Metadata$inboundSchema), }), z.transform((v) => { return remap$(v, { "external_id": "externalId", "profile_picture": "profilePicture", "external_link": "externalLink", "first_seen": "firstSeen", "last_seen": "lastSeen", "last_incident": "lastIncident", "trust_level": "trustLevel", "risk_evaluation": "riskEvaluation", }); }), ); export function publicAuthorFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PublicAuthor$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PublicAuthor' from JSON`, ); }