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

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

/**
 * MCP-specific result metadata (isError, structuredContent, _meta).
 */
export type ConnectorToolResultMetadata = {
  isError: boolean;
  structuredContent?: { [k: string]: any } | null | undefined;
  meta?: { [k: string]: any } | null | undefined;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const ConnectorToolResultMetadata$inboundSchema: z.ZodType<
  ConnectorToolResultMetadata,
  unknown
> = z.object({
  isError: z.boolean().default(false),
  structuredContent: z.nullable(z.record(z.string(), z.any())).optional(),
  _meta: z.nullable(z.record(z.string(), z.any())).optional(),
}).catchall(z.any()).transform((v) => {
  return remap$(v, {
    "_meta": "meta",
  });
});

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