/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

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

/**
 * A warning encountered during document processing that did not prevent overall success.
 */
export type DocumentWarning = {
  /**
   * Machine-readable warning code
   */
  code: string;
  /**
   * Human-readable warning summary
   */
  message: string;
  /**
   * Detailed diagnostic information about the warning
   */
  detail?: string | undefined;
  /**
   * Whether this warning can be remediated by the client
   */
  recoverable: boolean;
  /**
   * Key referencing an action in `_actions` that can resolve this warning
   */
  remedy?: string | undefined;
};

/** @internal */
export const DocumentWarning$inboundSchema: z.ZodType<
  DocumentWarning,
  z.ZodTypeDef,
  unknown
> = z.object({
  code: types.string(),
  message: types.string(),
  detail: types.optional(types.string()),
  recoverable: types.boolean(),
  remedy: types.optional(types.string()),
});

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