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

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";
import { Annotations, Annotations$inboundSchema } from "./annotations.js";
import { MCPServerIcon, MCPServerIcon$inboundSchema } from "./mcpservericon.js";

export type MCPResource = {
  name: string;
  title?: string | null | undefined;
  uri: string;
  description?: string | null | undefined;
  mimeType?: string | null | undefined;
  size?: number | null | undefined;
  icons?: Array<MCPServerIcon> | null | undefined;
  annotations?: Annotations | null | undefined;
  meta?: { [k: string]: any } | null | undefined;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const MCPResource$inboundSchema: z.ZodType<MCPResource, unknown> = z
  .object({
    name: z.string(),
    title: z.nullable(z.string()).optional(),
    uri: z.string(),
    description: z.nullable(z.string()).optional(),
    mimeType: z.nullable(z.string()).optional(),
    size: z.nullable(z.int()).optional(),
    icons: z.nullable(z.array(MCPServerIcon$inboundSchema)).optional(),
    annotations: z.nullable(Annotations$inboundSchema).optional(),
    _meta: z.nullable(z.record(z.string(), z.any())).optional(),
  }).catchall(z.any()).transform((v) => {
    return remap$(v, {
      "_meta": "meta",
    });
  });

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