/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 4c2f628fdb8e
 */

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type ModerationObject = {
  /**
   * Moderation result thresholds
   */
  categories?: { [k: string]: boolean } | undefined;
  /**
   * Moderation result
   */
  categoryScores?: { [k: string]: number } | undefined;
};

/** @internal */
export const ModerationObject$inboundSchema: z.ZodType<
  ModerationObject,
  unknown
> = z.object({
  categories: z.record(z.string(), z.boolean()).optional(),
  category_scores: z.record(z.string(), z.number()).optional(),
}).transform((v) => {
  return remap$(v, {
    "category_scores": "categoryScores",
  });
});

export function moderationObjectFromJSON(
  jsonString: string,
): SafeParseResult<ModerationObject, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ModerationObject$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ModerationObject' from JSON`,
  );
}
