/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { collectExtraKeys as collectExtraKeys$, 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 { DigestControlsMetadataResponseDto, DigestControlsMetadataResponseDto$inboundSchema, } from "./digestcontrolsmetadataresponsedto.js"; import { LookBackWindowDto, LookBackWindowDto$inboundSchema, } from "./lookbackwindowdto.js"; import { ResourceOriginEnum, ResourceOriginEnum$inboundSchema, } from "./resourceoriginenum.js"; import { StepIssuesDto, StepIssuesDto$inboundSchema } from "./stepissuesdto.js"; /** * The type of digest strategy. Determines which fields are applicable. */ export const DigestStepResponseDtoType = { Regular: "regular", Timed: "timed", } as const; /** * The type of digest strategy. Determines which fields are applicable. */ export type DigestStepResponseDtoType = ClosedEnum< typeof DigestStepResponseDtoType >; /** * The unit of time for the digest interval (for REGULAR type). */ export const DigestStepResponseDtoUnit = { 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 DigestStepResponseDtoUnit = ClosedEnum< typeof DigestStepResponseDtoUnit >; /** * Control values for the digest step */ export type DigestStepResponseDtoControlValues = { /** * 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?: DigestStepResponseDtoType | 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?: DigestStepResponseDtoUnit | 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; additionalProperties?: { [k: string]: any } | undefined; }; export type DigestStepResponseDto = { /** * Controls metadata for the digest step */ controls: DigestControlsMetadataResponseDto; /** * Control values for the digest step */ controlValues?: DigestStepResponseDtoControlValues | undefined; /** * JSON Schema for variables, follows the JSON Schema standard */ variables: { [k: string]: any }; /** * Unique identifier of the step */ stepId: string; /** * Database identifier of the step */ id: string; /** * Name of the step */ name: string; /** * Slug of the step */ slug: string; /** * Type of the step */ type: "digest"; /** * Origin of the layout */ origin: ResourceOriginEnum; /** * Workflow identifier */ workflowId: string; /** * Workflow database identifier */ workflowDatabaseId: string; /** * Issues associated with the step */ issues?: StepIssuesDto | undefined; /** * Hash identifying the deployed Cloudflare Worker for this step */ stepResolverHash?: string | undefined; }; /** @internal */ export const DigestStepResponseDtoType$inboundSchema: z.ZodNativeEnum< typeof DigestStepResponseDtoType > = z.nativeEnum(DigestStepResponseDtoType); /** @internal */ export const DigestStepResponseDtoUnit$inboundSchema: z.ZodNativeEnum< typeof DigestStepResponseDtoUnit > = z.nativeEnum(DigestStepResponseDtoUnit); /** @internal */ export const DigestStepResponseDtoControlValues$inboundSchema: z.ZodType< DigestStepResponseDtoControlValues, z.ZodTypeDef, unknown > = collectExtraKeys$( z.object({ skip: z.record(z.any()).optional(), type: DigestStepResponseDtoType$inboundSchema.optional(), amount: z.number().optional(), unit: DigestStepResponseDtoUnit$inboundSchema.optional(), lookBackWindow: LookBackWindowDto$inboundSchema.optional(), cron: z.string().optional(), digestKey: z.string().optional(), }).catchall(z.any()), "additionalProperties", true, ); export function digestStepResponseDtoControlValuesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DigestStepResponseDtoControlValues$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DigestStepResponseDtoControlValues' from JSON`, ); } /** @internal */ export const DigestStepResponseDto$inboundSchema: z.ZodType< DigestStepResponseDto, z.ZodTypeDef, unknown > = z.object({ controls: DigestControlsMetadataResponseDto$inboundSchema, controlValues: z.lazy(() => DigestStepResponseDtoControlValues$inboundSchema) .optional(), variables: z.record(z.any()), stepId: z.string(), _id: z.string(), name: z.string(), slug: z.string(), type: z.literal("digest"), origin: ResourceOriginEnum$inboundSchema, workflowId: z.string(), workflowDatabaseId: z.string(), issues: StepIssuesDto$inboundSchema.optional(), stepResolverHash: z.string().optional(), }).transform((v) => { return remap$(v, { "_id": "id", }); }); export function digestStepResponseDtoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DigestStepResponseDto$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DigestStepResponseDto' from JSON`, ); }