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

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

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

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

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