/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { catchUnrecognizedEnum, OpenEnum, Unrecognized, } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The deadline for a previous year contribution. Previous year contributions are allowed when requested on or before this deadline. This field will be unset when previous year contributions are not allowed. */ export type PreviousYearDeadline = { /** * Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant. */ day?: number | undefined; /** * Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day. */ month?: number | undefined; /** * Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year. */ year?: number | undefined; }; /** * Retirement contribution type */ export enum ContributionConstraintsContributionTypeInfoType { TypeUnspecified = "TYPE_UNSPECIFIED", Regular = "REGULAR", Employee = "EMPLOYEE", Employer = "EMPLOYER", Recharacterization = "RECHARACTERIZATION", Rollover60Day = "ROLLOVER_60_DAY", RolloverDirect = "ROLLOVER_DIRECT", Transfer = "TRANSFER", TrusteeFee = "TRUSTEE_FEE", Conversion = "CONVERSION", Repayment = "REPAYMENT", ContributionNonReportable = "CONTRIBUTION_NON_REPORTABLE", } /** * Retirement contribution type */ export type ContributionConstraintsContributionTypeInfoTypeOpen = OpenEnum< typeof ContributionConstraintsContributionTypeInfoType >; /** * Retirement contribution type info */ export type ContributionConstraintsContributionTypeInfo = { /** * Whether this specific retirement contribution may be allowed for the previous year, without consideration of the tax deadline */ previousYearAllowed?: boolean | undefined; /** * The deadline for a previous year contribution. Previous year contributions are allowed when requested on or before this deadline. This field will be unset when previous year contributions are not allowed. */ previousYearDeadline?: PreviousYearDeadline | null | undefined; /** * Retirement contribution type */ type?: ContributionConstraintsContributionTypeInfoTypeOpen | undefined; }; /** @internal */ export const PreviousYearDeadline$inboundSchema: z.ZodType< PreviousYearDeadline, z.ZodTypeDef, unknown > = z.object({ day: z.number().int().optional(), month: z.number().int().optional(), year: z.number().int().optional(), }); /** @internal */ export type PreviousYearDeadline$Outbound = { day?: number | undefined; month?: number | undefined; year?: number | undefined; }; /** @internal */ export const PreviousYearDeadline$outboundSchema: z.ZodType< PreviousYearDeadline$Outbound, z.ZodTypeDef, PreviousYearDeadline > = z.object({ day: z.number().int().optional(), month: z.number().int().optional(), year: z.number().int().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace PreviousYearDeadline$ { /** @deprecated use `PreviousYearDeadline$inboundSchema` instead. */ export const inboundSchema = PreviousYearDeadline$inboundSchema; /** @deprecated use `PreviousYearDeadline$outboundSchema` instead. */ export const outboundSchema = PreviousYearDeadline$outboundSchema; /** @deprecated use `PreviousYearDeadline$Outbound` instead. */ export type Outbound = PreviousYearDeadline$Outbound; } export function previousYearDeadlineToJSON( previousYearDeadline: PreviousYearDeadline, ): string { return JSON.stringify( PreviousYearDeadline$outboundSchema.parse(previousYearDeadline), ); } export function previousYearDeadlineFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PreviousYearDeadline$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PreviousYearDeadline' from JSON`, ); } /** @internal */ export const ContributionConstraintsContributionTypeInfoType$inboundSchema: z.ZodType< ContributionConstraintsContributionTypeInfoTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(ContributionConstraintsContributionTypeInfoType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const ContributionConstraintsContributionTypeInfoType$outboundSchema: z.ZodType< ContributionConstraintsContributionTypeInfoTypeOpen, z.ZodTypeDef, ContributionConstraintsContributionTypeInfoTypeOpen > = z.union([ z.nativeEnum(ContributionConstraintsContributionTypeInfoType), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ContributionConstraintsContributionTypeInfoType$ { /** @deprecated use `ContributionConstraintsContributionTypeInfoType$inboundSchema` instead. */ export const inboundSchema = ContributionConstraintsContributionTypeInfoType$inboundSchema; /** @deprecated use `ContributionConstraintsContributionTypeInfoType$outboundSchema` instead. */ export const outboundSchema = ContributionConstraintsContributionTypeInfoType$outboundSchema; } /** @internal */ export const ContributionConstraintsContributionTypeInfo$inboundSchema: z.ZodType< ContributionConstraintsContributionTypeInfo, z.ZodTypeDef, unknown > = z.object({ previous_year_allowed: z.boolean().optional(), previous_year_deadline: z.nullable( z.lazy(() => PreviousYearDeadline$inboundSchema), ).optional(), type: ContributionConstraintsContributionTypeInfoType$inboundSchema .optional(), }).transform((v) => { return remap$(v, { "previous_year_allowed": "previousYearAllowed", "previous_year_deadline": "previousYearDeadline", }); }); /** @internal */ export type ContributionConstraintsContributionTypeInfo$Outbound = { previous_year_allowed?: boolean | undefined; previous_year_deadline?: PreviousYearDeadline$Outbound | null | undefined; type?: string | undefined; }; /** @internal */ export const ContributionConstraintsContributionTypeInfo$outboundSchema: z.ZodType< ContributionConstraintsContributionTypeInfo$Outbound, z.ZodTypeDef, ContributionConstraintsContributionTypeInfo > = z.object({ previousYearAllowed: z.boolean().optional(), previousYearDeadline: z.nullable( z.lazy(() => PreviousYearDeadline$outboundSchema), ).optional(), type: ContributionConstraintsContributionTypeInfoType$outboundSchema .optional(), }).transform((v) => { return remap$(v, { previousYearAllowed: "previous_year_allowed", previousYearDeadline: "previous_year_deadline", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ContributionConstraintsContributionTypeInfo$ { /** @deprecated use `ContributionConstraintsContributionTypeInfo$inboundSchema` instead. */ export const inboundSchema = ContributionConstraintsContributionTypeInfo$inboundSchema; /** @deprecated use `ContributionConstraintsContributionTypeInfo$outboundSchema` instead. */ export const outboundSchema = ContributionConstraintsContributionTypeInfo$outboundSchema; /** @deprecated use `ContributionConstraintsContributionTypeInfo$Outbound` instead. */ export type Outbound = ContributionConstraintsContributionTypeInfo$Outbound; } export function contributionConstraintsContributionTypeInfoToJSON( contributionConstraintsContributionTypeInfo: ContributionConstraintsContributionTypeInfo, ): string { return JSON.stringify( ContributionConstraintsContributionTypeInfo$outboundSchema.parse( contributionConstraintsContributionTypeInfo, ), ); } export function contributionConstraintsContributionTypeInfoFromJSON( jsonString: string, ): SafeParseResult< ContributionConstraintsContributionTypeInfo, SDKValidationError > { return safeParse( jsonString, (x) => ContributionConstraintsContributionTypeInfo$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'ContributionConstraintsContributionTypeInfo' from JSON`, ); }