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

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

/**
 * The operation that the field supports.
 */
export const SupportedOperation = {
  VerifyType: "VerifyType",
} as const;
/**
 * The operation that the field supports.
 */
export type SupportedOperation = ClosedEnum<typeof SupportedOperation>;

export type TabConnectedFieldsData = {
  /**
   * The fully qualified namespace for the type system being verified.
   */
  typeSystemNamespace: string;
  /**
   * Name of the type being verified.
   */
  typeName: string;
  /**
   * The operation that the field supports.
   */
  supportedOperation: SupportedOperation;
  /**
   * The name of the individual field being verified.
   */
  propertyName: string;
  /**
   * Indicates the type verification url of the field.
   */
  supportedUri: string;
};

/** @internal */
export const SupportedOperation$inboundSchema: z.ZodNativeEnum<
  typeof SupportedOperation
> = z.nativeEnum(SupportedOperation);

/** @internal */
export const TabConnectedFieldsData$inboundSchema: z.ZodType<
  TabConnectedFieldsData,
  z.ZodTypeDef,
  unknown
> = z.object({
  typeSystemNamespace: types.string(),
  typeName: types.string(),
  supportedOperation: SupportedOperation$inboundSchema,
  propertyName: types.string(),
  supportedUri: types.string(),
});

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