/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ActionDto, ActionDto$inboundSchema } from "./actiondto.js"; import { InAppControlsMetadataResponseDto, InAppControlsMetadataResponseDto$inboundSchema, } from "./inappcontrolsmetadataresponsedto.js"; import { RedirectDto, RedirectDto$inboundSchema } from "./redirectdto.js"; import { ResourceOriginEnum, ResourceOriginEnum$inboundSchema, } from "./resourceoriginenum.js"; import { StepIssuesDto, StepIssuesDto$inboundSchema } from "./stepissuesdto.js"; /** * Control values for the in-app step */ export type InAppStepResponseDtoControlValues = { /** * 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; /** * Content/body of the in-app message. Required if subject is empty. */ body?: string | undefined; /** * Subject/title of the in-app message. Required if body is empty. */ subject?: string | undefined; /** * URL for an avatar image. Must be a valid URL or start with / or {{ variable }}. */ avatar?: string | undefined; /** * Primary action button details. */ primaryAction?: ActionDto | undefined; /** * Secondary action button details. */ secondaryAction?: ActionDto | undefined; /** * Redirection URL configuration for the main content click (if no actions defined/clicked).. */ redirect?: RedirectDto | undefined; /** * Disable sanitization of the output. */ disableOutputSanitization: boolean; /** * Additional data payload for the step. */ data?: { [k: string]: any } | undefined; additionalProperties?: { [k: string]: any } | undefined; }; export type InAppStepResponseDto = { /** * Controls metadata for the in-app step */ controls: InAppControlsMetadataResponseDto; /** * Control values for the in-app step */ controlValues?: InAppStepResponseDtoControlValues | 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: "in_app"; /** * 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 InAppStepResponseDtoControlValues$inboundSchema: z.ZodType< InAppStepResponseDtoControlValues, z.ZodTypeDef, unknown > = collectExtraKeys$( z.object({ skip: z.record(z.any()).optional(), body: z.string().optional(), subject: z.string().optional(), avatar: z.string().optional(), primaryAction: ActionDto$inboundSchema.optional(), secondaryAction: ActionDto$inboundSchema.optional(), redirect: RedirectDto$inboundSchema.optional(), disableOutputSanitization: z.boolean().default(false), data: z.record(z.any()).optional(), }).catchall(z.any()), "additionalProperties", true, ); export function inAppStepResponseDtoControlValuesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => InAppStepResponseDtoControlValues$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InAppStepResponseDtoControlValues' from JSON`, ); } /** @internal */ export const InAppStepResponseDto$inboundSchema: z.ZodType< InAppStepResponseDto, z.ZodTypeDef, unknown > = z.object({ controls: InAppControlsMetadataResponseDto$inboundSchema, controlValues: z.lazy(() => InAppStepResponseDtoControlValues$inboundSchema) .optional(), variables: z.record(z.any()), stepId: z.string(), _id: z.string(), name: z.string(), slug: z.string(), type: z.literal("in_app"), 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 inAppStepResponseDtoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => InAppStepResponseDto$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InAppStepResponseDto' from JSON`, ); }