/* * 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 { EmailControlsMetadataResponseDto, EmailControlsMetadataResponseDto$inboundSchema, } from "./emailcontrolsmetadataresponsedto.js"; import { ResourceOriginEnum, ResourceOriginEnum$inboundSchema, } from "./resourceoriginenum.js"; import { StepIssuesDto, StepIssuesDto$inboundSchema } from "./stepissuesdto.js"; /** * Type of editor to use for the body. */ export const EmailStepResponseDtoEditorType = { Block: "block", Html: "html", } as const; /** * Type of editor to use for the body. */ export type EmailStepResponseDtoEditorType = ClosedEnum< typeof EmailStepResponseDtoEditorType >; /** * Control values for the email step */ export type EmailStepResponseDtoControlValues = { /** * 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; /** * Subject of the email. */ subject: string; /** * Body content of the email, either a valid Maily JSON object, or html string. */ body: string; /** * Type of editor to use for the body. */ editorType: EmailStepResponseDtoEditorType; /** * Disable sanitization of the output. */ disableOutputSanitization: boolean; /** * Layout ID to use for the email. Null means no layout, undefined means default layout. */ layoutId?: string | null | undefined; additionalProperties?: { [k: string]: any } | undefined; }; export type EmailStepResponseDto = { /** * Controls metadata for the email step */ controls: EmailControlsMetadataResponseDto; /** * Control values for the email step */ controlValues?: EmailStepResponseDtoControlValues | 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: "email"; /** * 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 EmailStepResponseDtoEditorType$inboundSchema: z.ZodNativeEnum< typeof EmailStepResponseDtoEditorType > = z.nativeEnum(EmailStepResponseDtoEditorType); /** @internal */ export const EmailStepResponseDtoControlValues$inboundSchema: z.ZodType< EmailStepResponseDtoControlValues, z.ZodTypeDef, unknown > = collectExtraKeys$( z.object({ skip: z.record(z.any()).optional(), subject: z.string(), body: z.string().default(""), editorType: EmailStepResponseDtoEditorType$inboundSchema.default("block"), disableOutputSanitization: z.boolean().default(false), layoutId: z.nullable(z.string()).optional(), }).catchall(z.any()), "additionalProperties", true, ); export function emailStepResponseDtoControlValuesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EmailStepResponseDtoControlValues$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EmailStepResponseDtoControlValues' from JSON`, ); } /** @internal */ export const EmailStepResponseDto$inboundSchema: z.ZodType< EmailStepResponseDto, z.ZodTypeDef, unknown > = z.object({ controls: EmailControlsMetadataResponseDto$inboundSchema, controlValues: z.lazy(() => EmailStepResponseDtoControlValues$inboundSchema) .optional(), variables: z.record(z.any()), stepId: z.string(), _id: z.string(), name: z.string(), slug: z.string(), type: z.literal("email"), 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 emailStepResponseDtoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EmailStepResponseDto$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EmailStepResponseDto' from JSON`, ); }