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

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";

/**
 * Binary contents of a resource.
 */
export type BlobResourceContents = {
  uri: string;
  mimeType?: string | null | undefined;
  meta?: { [k: string]: any } | null | undefined;
  blob: string;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const BlobResourceContents$inboundSchema: z.ZodType<
  BlobResourceContents,
  unknown
> = z.object({
  uri: z.string(),
  mimeType: z.nullable(z.string()).optional(),
  _meta: z.nullable(z.record(z.string(), z.any())).optional(),
  blob: z.string(),
}).catchall(z.any()).transform((v) => {
  return remap$(v, {
    "_meta": "meta",
  });
});

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