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

import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  CoreLink,
  CoreLink$inboundSchema,
  CoreLink$Outbound,
  CoreLink$outboundSchema,
} from "./corelink.js";

export type ParentLink = {
  parent: CoreLink;
};

/** @internal */
export const ParentLink$inboundSchema: z.ZodType<
  ParentLink,
  z.ZodTypeDef,
  unknown
> = z.object({
  parent: CoreLink$inboundSchema,
});
/** @internal */
export type ParentLink$Outbound = {
  parent: CoreLink$Outbound;
};

/** @internal */
export const ParentLink$outboundSchema: z.ZodType<
  ParentLink$Outbound,
  z.ZodTypeDef,
  ParentLink
> = z.object({
  parent: CoreLink$outboundSchema,
});

export function parentLinkToJSON(parentLink: ParentLink): string {
  return JSON.stringify(ParentLink$outboundSchema.parse(parentLink));
}
export function parentLinkFromJSON(
  jsonString: string,
): SafeParseResult<ParentLink, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ParentLink$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ParentLink' from JSON`,
  );
}
