/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of throttle window. */ export const ThrottleControlDtoType = { Fixed: "fixed", Dynamic: "dynamic", } as const; /** * The type of throttle window. */ export type ThrottleControlDtoType = ClosedEnum; /** * The unit of time for the throttle window (required for fixed type). */ export const ThrottleControlDtoUnit = { Minutes: "minutes", Hours: "hours", Days: "days", } as const; /** * The unit of time for the throttle window (required for fixed type). */ export type ThrottleControlDtoUnit = ClosedEnum; export type ThrottleControlDto = { /** * JSONLogic filter conditions for conditionally skipping the step execution. Supports complex logical operations with AND, OR, and comparison operators. See https://jsonlogic.com/ for full typing reference. */ skip?: { [k: string]: any } | undefined; /** * The type of throttle window. */ type?: ThrottleControlDtoType | undefined; /** * The amount of time for the throttle window (required for fixed type). */ amount?: number | undefined; /** * The unit of time for the throttle window (required for fixed type). */ unit?: ThrottleControlDtoUnit | undefined; /** * Key path to retrieve dynamic window value (required for dynamic type). */ dynamicKey?: string | undefined; /** * The maximum number of executions allowed within the window. Defaults to 1. */ threshold?: number | undefined; /** * Optional key for grouping throttle rules. If not provided, defaults to workflow and subscriber combination. */ throttleKey?: string | undefined; }; /** @internal */ export const ThrottleControlDtoType$inboundSchema: z.ZodNativeEnum< typeof ThrottleControlDtoType > = z.nativeEnum(ThrottleControlDtoType); /** @internal */ export const ThrottleControlDtoType$outboundSchema: z.ZodNativeEnum< typeof ThrottleControlDtoType > = ThrottleControlDtoType$inboundSchema; /** @internal */ export const ThrottleControlDtoUnit$inboundSchema: z.ZodNativeEnum< typeof ThrottleControlDtoUnit > = z.nativeEnum(ThrottleControlDtoUnit); /** @internal */ export const ThrottleControlDtoUnit$outboundSchema: z.ZodNativeEnum< typeof ThrottleControlDtoUnit > = ThrottleControlDtoUnit$inboundSchema; /** @internal */ export const ThrottleControlDto$inboundSchema: z.ZodType< ThrottleControlDto, z.ZodTypeDef, unknown > = z.object({ skip: z.record(z.any()).optional(), type: ThrottleControlDtoType$inboundSchema.default("fixed"), amount: z.number().optional(), unit: ThrottleControlDtoUnit$inboundSchema.optional(), dynamicKey: z.string().optional(), threshold: z.number().default(1), throttleKey: z.string().optional(), }); /** @internal */ export type ThrottleControlDto$Outbound = { skip?: { [k: string]: any } | undefined; type: string; amount?: number | undefined; unit?: string | undefined; dynamicKey?: string | undefined; threshold: number; throttleKey?: string | undefined; }; /** @internal */ export const ThrottleControlDto$outboundSchema: z.ZodType< ThrottleControlDto$Outbound, z.ZodTypeDef, ThrottleControlDto > = z.object({ skip: z.record(z.any()).optional(), type: ThrottleControlDtoType$outboundSchema.default("fixed"), amount: z.number().optional(), unit: ThrottleControlDtoUnit$outboundSchema.optional(), dynamicKey: z.string().optional(), threshold: z.number().default(1), throttleKey: z.string().optional(), }); export function throttleControlDtoToJSON( throttleControlDto: ThrottleControlDto, ): string { return JSON.stringify( ThrottleControlDto$outboundSchema.parse(throttleControlDto), ); } export function throttleControlDtoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ThrottleControlDto$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ThrottleControlDto' from JSON`, ); }