/* * 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 { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatStepResponseDto, ChatStepResponseDto$inboundSchema, } from "./chatstepresponsedto.js"; import { CustomStepResponseDto, CustomStepResponseDto$inboundSchema, } from "./customstepresponsedto.js"; import { DelayStepResponseDto, DelayStepResponseDto$inboundSchema, } from "./delaystepresponsedto.js"; import { DigestStepResponseDto, DigestStepResponseDto$inboundSchema, } from "./digeststepresponsedto.js"; import { EmailStepResponseDto, EmailStepResponseDto$inboundSchema, } from "./emailstepresponsedto.js"; import { HttpRequestStepResponseDto, HttpRequestStepResponseDto$inboundSchema, } from "./httprequeststepresponsedto.js"; import { InAppStepResponseDto, InAppStepResponseDto$inboundSchema, } from "./inappstepresponsedto.js"; import { PushStepResponseDto, PushStepResponseDto$inboundSchema, } from "./pushstepresponsedto.js"; import { ResourceOriginEnum, ResourceOriginEnum$inboundSchema, } from "./resourceoriginenum.js"; import { RuntimeIssueDto, RuntimeIssueDto$inboundSchema, } from "./runtimeissuedto.js"; import { SeverityLevelEnum, SeverityLevelEnum$inboundSchema, } from "./severitylevelenum.js"; import { SmsStepResponseDto, SmsStepResponseDto$inboundSchema, } from "./smsstepresponsedto.js"; import { ThrottleStepResponseDto, ThrottleStepResponseDto$inboundSchema, } from "./throttlestepresponsedto.js"; import { WorkflowPreferencesResponseDto, WorkflowPreferencesResponseDto$inboundSchema, } from "./workflowpreferencesresponsedto.js"; import { WorkflowStatusEnum, WorkflowStatusEnum$inboundSchema, } from "./workflowstatusenum.js"; /** * User who last updated the workflow */ export type WorkflowResponseDtoUpdatedBy = { /** * User ID */ id: string; /** * User first name */ firstName?: string | null | undefined; /** * User last name */ lastName?: string | null | undefined; /** * User external ID */ externalId?: string | null | undefined; }; /** * User who last published the workflow */ export type LastPublishedBy = { /** * User ID */ id: string; /** * User first name */ firstName?: string | null | undefined; /** * User last name */ lastName?: string | null | undefined; /** * User external ID */ externalId?: string | null | undefined; }; export type WorkflowResponseDtoSteps = | InAppStepResponseDto | EmailStepResponseDto | SmsStepResponseDto | PushStepResponseDto | ChatStepResponseDto | DelayStepResponseDto | DigestStepResponseDto | CustomStepResponseDto | ThrottleStepResponseDto | HttpRequestStepResponseDto; export type WorkflowResponseDto = { /** * 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; /** * 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; /** * Database identifier of the workflow */ id: string; /** * Workflow identifier */ workflowId: string; /** * Slug of the workflow */ slug: string; /** * Last updated timestamp */ updatedAt: string; /** * Creation timestamp */ createdAt: string; /** * User who last updated the workflow */ updatedBy?: WorkflowResponseDtoUpdatedBy | null | undefined; /** * Timestamp of the last workflow publication */ lastPublishedAt?: string | null | undefined; /** * User who last published the workflow */ lastPublishedBy?: LastPublishedBy | null | undefined; /** * Steps of the workflow */ steps: Array< | InAppStepResponseDto | EmailStepResponseDto | SmsStepResponseDto | PushStepResponseDto | ChatStepResponseDto | DelayStepResponseDto | DigestStepResponseDto | CustomStepResponseDto | ThrottleStepResponseDto | HttpRequestStepResponseDto >; /** * Origin of the layout */ origin: ResourceOriginEnum; /** * Preferences for the workflow */ preferences: WorkflowPreferencesResponseDto; /** * Status of the workflow */ status: WorkflowStatusEnum; /** * Runtime issues for workflow creation and update */ issues?: { [k: string]: RuntimeIssueDto } | undefined; /** * Timestamp of the last workflow trigger */ lastTriggeredAt?: string | null | undefined; /** * Generated payload example based on the payload schema */ payloadExample?: { [k: string]: any } | null | undefined; /** * Severity of the workflow */ severity: SeverityLevelEnum; }; /** @internal */ export const WorkflowResponseDtoUpdatedBy$inboundSchema: z.ZodType< WorkflowResponseDtoUpdatedBy, z.ZodTypeDef, unknown > = z.object({ _id: z.string(), firstName: z.nullable(z.string()).optional(), lastName: z.nullable(z.string()).optional(), externalId: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "_id": "id", }); }); export function workflowResponseDtoUpdatedByFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WorkflowResponseDtoUpdatedBy$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WorkflowResponseDtoUpdatedBy' from JSON`, ); } /** @internal */ export const LastPublishedBy$inboundSchema: z.ZodType< LastPublishedBy, z.ZodTypeDef, unknown > = z.object({ _id: z.string(), firstName: z.nullable(z.string()).optional(), lastName: z.nullable(z.string()).optional(), externalId: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "_id": "id", }); }); export function lastPublishedByFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => LastPublishedBy$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LastPublishedBy' from JSON`, ); } /** @internal */ export const WorkflowResponseDtoSteps$inboundSchema: z.ZodType< WorkflowResponseDtoSteps, z.ZodTypeDef, unknown > = z.union([ InAppStepResponseDto$inboundSchema, EmailStepResponseDto$inboundSchema, SmsStepResponseDto$inboundSchema, PushStepResponseDto$inboundSchema, ChatStepResponseDto$inboundSchema, DelayStepResponseDto$inboundSchema, DigestStepResponseDto$inboundSchema, CustomStepResponseDto$inboundSchema, ThrottleStepResponseDto$inboundSchema, HttpRequestStepResponseDto$inboundSchema, ]); export function workflowResponseDtoStepsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WorkflowResponseDtoSteps$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WorkflowResponseDtoSteps' from JSON`, ); } /** @internal */ export const WorkflowResponseDto$inboundSchema: z.ZodType< WorkflowResponseDto, z.ZodTypeDef, unknown > = 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), _id: z.string(), workflowId: z.string(), slug: z.string(), updatedAt: z.string(), createdAt: z.string(), updatedBy: z.nullable( z.lazy(() => WorkflowResponseDtoUpdatedBy$inboundSchema), ).optional(), lastPublishedAt: z.nullable(z.string()).optional(), lastPublishedBy: z.nullable(z.lazy(() => LastPublishedBy$inboundSchema)) .optional(), steps: z.array( z.union([ InAppStepResponseDto$inboundSchema, EmailStepResponseDto$inboundSchema, SmsStepResponseDto$inboundSchema, PushStepResponseDto$inboundSchema, ChatStepResponseDto$inboundSchema, DelayStepResponseDto$inboundSchema, DigestStepResponseDto$inboundSchema, CustomStepResponseDto$inboundSchema, ThrottleStepResponseDto$inboundSchema, HttpRequestStepResponseDto$inboundSchema, ]), ), origin: ResourceOriginEnum$inboundSchema, preferences: WorkflowPreferencesResponseDto$inboundSchema, status: WorkflowStatusEnum$inboundSchema, issues: z.record(RuntimeIssueDto$inboundSchema).optional(), lastTriggeredAt: z.nullable(z.string()).optional(), payloadExample: z.nullable(z.record(z.any())).optional(), severity: SeverityLevelEnum$inboundSchema, }).transform((v) => { return remap$(v, { "_id": "id", }); }); export function workflowResponseDtoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WorkflowResponseDto$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WorkflowResponseDto' from JSON`, ); }