/* * 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"; import { LookBackWindowDto, LookBackWindowDto$inboundSchema, LookBackWindowDto$Outbound, LookBackWindowDto$outboundSchema, } from "./lookbackwindowdto.js"; /** * The type of digest strategy. Determines which fields are applicable. */ export const DigestControlDtoType = { Regular: "regular", Timed: "timed", } as const; /** * The type of digest strategy. Determines which fields are applicable. */ export type DigestControlDtoType = ClosedEnum; /** * The unit of time for the digest interval (for REGULAR type). */ export const DigestControlDtoUnit = { Seconds: "seconds", Minutes: "minutes", Hours: "hours", Days: "days", Weeks: "weeks", Months: "months", } as const; /** * The unit of time for the digest interval (for REGULAR type). */ export type DigestControlDtoUnit = ClosedEnum; export type DigestControlDto = { /** * 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 digest strategy. Determines which fields are applicable. */ type?: DigestControlDtoType | undefined; /** * The amount of time for the digest interval (for REGULAR type). Min 1. */ amount?: number | undefined; /** * The unit of time for the digest interval (for REGULAR type). */ unit?: DigestControlDtoUnit | undefined; /** * Configuration for look-back window (for REGULAR type). */ lookBackWindow?: LookBackWindowDto | undefined; /** * Cron expression for TIMED digest. Min length 1. */ cron?: string | undefined; /** * Specify a custom key for digesting events instead of the default event key. */ digestKey?: string | undefined; }; /** @internal */ export const DigestControlDtoType$inboundSchema: z.ZodNativeEnum< typeof DigestControlDtoType > = z.nativeEnum(DigestControlDtoType); /** @internal */ export const DigestControlDtoType$outboundSchema: z.ZodNativeEnum< typeof DigestControlDtoType > = DigestControlDtoType$inboundSchema; /** @internal */ export const DigestControlDtoUnit$inboundSchema: z.ZodNativeEnum< typeof DigestControlDtoUnit > = z.nativeEnum(DigestControlDtoUnit); /** @internal */ export const DigestControlDtoUnit$outboundSchema: z.ZodNativeEnum< typeof DigestControlDtoUnit > = DigestControlDtoUnit$inboundSchema; /** @internal */ export const DigestControlDto$inboundSchema: z.ZodType< DigestControlDto, z.ZodTypeDef, unknown > = z.object({ skip: z.record(z.any()).optional(), type: DigestControlDtoType$inboundSchema.optional(), amount: z.number().optional(), unit: DigestControlDtoUnit$inboundSchema.optional(), lookBackWindow: LookBackWindowDto$inboundSchema.optional(), cron: z.string().optional(), digestKey: z.string().optional(), }); /** @internal */ export type DigestControlDto$Outbound = { skip?: { [k: string]: any } | undefined; type?: string | undefined; amount?: number | undefined; unit?: string | undefined; lookBackWindow?: LookBackWindowDto$Outbound | undefined; cron?: string | undefined; digestKey?: string | undefined; }; /** @internal */ export const DigestControlDto$outboundSchema: z.ZodType< DigestControlDto$Outbound, z.ZodTypeDef, DigestControlDto > = z.object({ skip: z.record(z.any()).optional(), type: DigestControlDtoType$outboundSchema.optional(), amount: z.number().optional(), unit: DigestControlDtoUnit$outboundSchema.optional(), lookBackWindow: LookBackWindowDto$outboundSchema.optional(), cron: z.string().optional(), digestKey: z.string().optional(), }); export function digestControlDtoToJSON( digestControlDto: DigestControlDto, ): string { return JSON.stringify( DigestControlDto$outboundSchema.parse(digestControlDto), ); } export function digestControlDtoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DigestControlDto$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DigestControlDto' from JSON`, ); }