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

import * as z from "zod";
import { safeParse } from "../../lib/schemas.js";
import { ClosedEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.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 SupportedOperation$outboundSchema: z.ZodNativeEnum<
  typeof SupportedOperation
> = SupportedOperation$inboundSchema;

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace SupportedOperation$ {
  /** @deprecated use `SupportedOperation$inboundSchema` instead. */
  export const inboundSchema = SupportedOperation$inboundSchema;
  /** @deprecated use `SupportedOperation$outboundSchema` instead. */
  export const outboundSchema = SupportedOperation$outboundSchema;
}

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

/** @internal */
export type TabConnectedFieldsData$Outbound = {
  typeSystemNamespace: string;
  typeName: string;
  supportedOperation: string;
  propertyName: string;
  supportedUri: string;
};

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

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace TabConnectedFieldsData$ {
  /** @deprecated use `TabConnectedFieldsData$inboundSchema` instead. */
  export const inboundSchema = TabConnectedFieldsData$inboundSchema;
  /** @deprecated use `TabConnectedFieldsData$outboundSchema` instead. */
  export const outboundSchema = TabConnectedFieldsData$outboundSchema;
  /** @deprecated use `TabConnectedFieldsData$Outbound` instead. */
  export type Outbound = TabConnectedFieldsData$Outbound;
}

export function tabConnectedFieldsDataToJSON(
  tabConnectedFieldsData: TabConnectedFieldsData,
): string {
  return JSON.stringify(
    TabConnectedFieldsData$outboundSchema.parse(tabConnectedFieldsData),
  );
}

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