/* * 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 { ChatStepUpsertDto, ChatStepUpsertDto$Outbound, ChatStepUpsertDto$outboundSchema, } from "./chatstepupsertdto.js"; import { CustomStepUpsertDto, CustomStepUpsertDto$Outbound, CustomStepUpsertDto$outboundSchema, } from "./customstepupsertdto.js"; import { DelayStepUpsertDto, DelayStepUpsertDto$Outbound, DelayStepUpsertDto$outboundSchema, } from "./delaystepupsertdto.js"; import { DigestStepUpsertDto, DigestStepUpsertDto$Outbound, DigestStepUpsertDto$outboundSchema, } from "./digeststepupsertdto.js"; import { EmailStepUpsertDto, EmailStepUpsertDto$Outbound, EmailStepUpsertDto$outboundSchema, } from "./emailstepupsertdto.js"; import { HttpRequestStepUpsertDto, HttpRequestStepUpsertDto$Outbound, HttpRequestStepUpsertDto$outboundSchema, } from "./httprequeststepupsertdto.js"; import { InAppStepUpsertDto, InAppStepUpsertDto$Outbound, InAppStepUpsertDto$outboundSchema, } from "./inappstepupsertdto.js"; import { PreferencesRequestDto, PreferencesRequestDto$Outbound, PreferencesRequestDto$outboundSchema, } from "./preferencesrequestdto.js"; import { PushStepUpsertDto, PushStepUpsertDto$Outbound, PushStepUpsertDto$outboundSchema, } from "./pushstepupsertdto.js"; import { SeverityLevelEnum, SeverityLevelEnum$outboundSchema, } from "./severitylevelenum.js"; import { SmsStepUpsertDto, SmsStepUpsertDto$Outbound, SmsStepUpsertDto$outboundSchema, } from "./smsstepupsertdto.js"; import { ThrottleStepUpsertDto, ThrottleStepUpsertDto$Outbound, ThrottleStepUpsertDto$outboundSchema, } from "./throttlestepupsertdto.js"; import { WorkflowCreationSourceEnum, WorkflowCreationSourceEnum$outboundSchema, } from "./workflowcreationsourceenum.js"; export type Steps = | InAppStepUpsertDto | EmailStepUpsertDto | SmsStepUpsertDto | PushStepUpsertDto | ChatStepUpsertDto | DelayStepUpsertDto | DigestStepUpsertDto | ThrottleStepUpsertDto | CustomStepUpsertDto | HttpRequestStepUpsertDto; export type CreateWorkflowDto = { /** * Name of the workflow */ name: string; /** * Description of the workflow */ description?: string | undefined; /** * Tags associated with the workflow */ tags?: Array | undefined; /** * Whether the workflow is active */ active?: boolean | undefined; /** * Enable or disable payload schema validation */ validatePayload?: boolean | undefined; /** * The payload JSON Schema for the workflow */ payloadSchema?: { [k: string]: any } | null | undefined; /** * Enable or disable translations for this workflow */ isTranslationEnabled?: boolean | undefined; /** * Unique identifier for the workflow */ workflowId: string; /** * Steps of the workflow */ steps: Array< | InAppStepUpsertDto | EmailStepUpsertDto | SmsStepUpsertDto | PushStepUpsertDto | ChatStepUpsertDto | DelayStepUpsertDto | DigestStepUpsertDto | ThrottleStepUpsertDto | CustomStepUpsertDto | HttpRequestStepUpsertDto >; /** * Source of workflow creation */ source?: WorkflowCreationSourceEnum | undefined; /** * Workflow preferences */ preferences?: PreferencesRequestDto | undefined; /** * Severity of the workflow */ severity?: SeverityLevelEnum | undefined; }; /** @internal */ export type Steps$Outbound = | InAppStepUpsertDto$Outbound | EmailStepUpsertDto$Outbound | SmsStepUpsertDto$Outbound | PushStepUpsertDto$Outbound | ChatStepUpsertDto$Outbound | DelayStepUpsertDto$Outbound | DigestStepUpsertDto$Outbound | ThrottleStepUpsertDto$Outbound | CustomStepUpsertDto$Outbound | HttpRequestStepUpsertDto$Outbound; /** @internal */ export const Steps$outboundSchema: z.ZodType< Steps$Outbound, z.ZodTypeDef, Steps > = z.union([ InAppStepUpsertDto$outboundSchema, EmailStepUpsertDto$outboundSchema, SmsStepUpsertDto$outboundSchema, PushStepUpsertDto$outboundSchema, ChatStepUpsertDto$outboundSchema, DelayStepUpsertDto$outboundSchema, DigestStepUpsertDto$outboundSchema, ThrottleStepUpsertDto$outboundSchema, CustomStepUpsertDto$outboundSchema, HttpRequestStepUpsertDto$outboundSchema, ]); export function stepsToJSON(steps: Steps): string { return JSON.stringify(Steps$outboundSchema.parse(steps)); } /** @internal */ export type CreateWorkflowDto$Outbound = { name: string; description?: string | undefined; tags?: Array | undefined; active: boolean; validatePayload?: boolean | undefined; payloadSchema?: { [k: string]: any } | null | undefined; isTranslationEnabled: boolean; workflowId: string; steps: Array< | InAppStepUpsertDto$Outbound | EmailStepUpsertDto$Outbound | SmsStepUpsertDto$Outbound | PushStepUpsertDto$Outbound | ChatStepUpsertDto$Outbound | DelayStepUpsertDto$Outbound | DigestStepUpsertDto$Outbound | ThrottleStepUpsertDto$Outbound | CustomStepUpsertDto$Outbound | HttpRequestStepUpsertDto$Outbound >; __source: string; preferences?: PreferencesRequestDto$Outbound | undefined; severity?: string | undefined; }; /** @internal */ export const CreateWorkflowDto$outboundSchema: z.ZodType< CreateWorkflowDto$Outbound, z.ZodTypeDef, CreateWorkflowDto > = z.object({ name: z.string(), description: z.string().optional(), tags: z.array(z.string()).optional(), active: z.boolean().default(false), validatePayload: z.boolean().optional(), payloadSchema: z.nullable(z.record(z.any())).optional(), isTranslationEnabled: z.boolean().default(false), workflowId: z.string(), steps: z.array( z.union([ InAppStepUpsertDto$outboundSchema, EmailStepUpsertDto$outboundSchema, SmsStepUpsertDto$outboundSchema, PushStepUpsertDto$outboundSchema, ChatStepUpsertDto$outboundSchema, DelayStepUpsertDto$outboundSchema, DigestStepUpsertDto$outboundSchema, ThrottleStepUpsertDto$outboundSchema, CustomStepUpsertDto$outboundSchema, HttpRequestStepUpsertDto$outboundSchema, ]), ), source: WorkflowCreationSourceEnum$outboundSchema.default("editor"), preferences: PreferencesRequestDto$outboundSchema.optional(), severity: SeverityLevelEnum$outboundSchema.optional(), }).transform((v) => { return remap$(v, { source: "__source", }); }); export function createWorkflowDtoToJSON( createWorkflowDto: CreateWorkflowDto, ): string { return JSON.stringify( CreateWorkflowDto$outboundSchema.parse(createWorkflowDto), ); }