/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: ea31fd796d04 */ import * as z from "zod/v4"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { smartUnion } from "../../types/smartUnion.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ActivityTaskCompletedResponse, ActivityTaskCompletedResponse$inboundSchema, } from "./activitytaskcompletedresponse.js"; import { ActivityTaskFailedResponse, ActivityTaskFailedResponse$inboundSchema, } from "./activitytaskfailedresponse.js"; import { ActivityTaskRetryingResponse, ActivityTaskRetryingResponse$inboundSchema, } from "./activitytaskretryingresponse.js"; import { ActivityTaskStartedResponse, ActivityTaskStartedResponse$inboundSchema, } from "./activitytaskstartedresponse.js"; import { CustomTaskCanceledResponse, CustomTaskCanceledResponse$inboundSchema, } from "./customtaskcanceledresponse.js"; import { CustomTaskCompletedResponse, CustomTaskCompletedResponse$inboundSchema, } from "./customtaskcompletedresponse.js"; import { CustomTaskFailedResponse, CustomTaskFailedResponse$inboundSchema, } from "./customtaskfailedresponse.js"; import { CustomTaskInProgressResponse, CustomTaskInProgressResponse$inboundSchema, } from "./customtaskinprogressresponse.js"; import { CustomTaskStartedResponse, CustomTaskStartedResponse$inboundSchema, } from "./customtaskstartedresponse.js"; import { CustomTaskTimedOutResponse, CustomTaskTimedOutResponse$inboundSchema, } from "./customtasktimedoutresponse.js"; import { StreamEventWorkflowContext, StreamEventWorkflowContext$inboundSchema, } from "./streameventworkflowcontext.js"; import { WorkflowExecutionCanceledResponse, WorkflowExecutionCanceledResponse$inboundSchema, } from "./workflowexecutioncanceledresponse.js"; import { WorkflowExecutionCompletedResponse, WorkflowExecutionCompletedResponse$inboundSchema, } from "./workflowexecutioncompletedresponse.js"; import { WorkflowExecutionContinuedAsNewResponse, WorkflowExecutionContinuedAsNewResponse$inboundSchema, } from "./workflowexecutioncontinuedasnewresponse.js"; import { WorkflowExecutionFailedResponse, WorkflowExecutionFailedResponse$inboundSchema, } from "./workflowexecutionfailedresponse.js"; import { WorkflowExecutionStartedResponse, WorkflowExecutionStartedResponse$inboundSchema, } from "./workflowexecutionstartedresponse.js"; import { WorkflowTaskFailedResponse, WorkflowTaskFailedResponse$inboundSchema, } from "./workflowtaskfailedresponse.js"; import { WorkflowTaskTimedOutResponse, WorkflowTaskTimedOutResponse$inboundSchema, } from "./workflowtasktimedoutresponse.js"; export type StreamEventSsePayloadData = | WorkflowExecutionStartedResponse | WorkflowExecutionCompletedResponse | WorkflowExecutionFailedResponse | WorkflowExecutionCanceledResponse | WorkflowExecutionContinuedAsNewResponse | WorkflowTaskTimedOutResponse | WorkflowTaskFailedResponse | CustomTaskStartedResponse | CustomTaskInProgressResponse | CustomTaskCompletedResponse | CustomTaskFailedResponse | CustomTaskTimedOutResponse | CustomTaskCanceledResponse | ActivityTaskStartedResponse | ActivityTaskCompletedResponse | ActivityTaskRetryingResponse | ActivityTaskFailedResponse; export type StreamEventSsePayload = { stream: string; timestamp?: Date | undefined; data: | WorkflowExecutionStartedResponse | WorkflowExecutionCompletedResponse | WorkflowExecutionFailedResponse | WorkflowExecutionCanceledResponse | WorkflowExecutionContinuedAsNewResponse | WorkflowTaskTimedOutResponse | WorkflowTaskFailedResponse | CustomTaskStartedResponse | CustomTaskInProgressResponse | CustomTaskCompletedResponse | CustomTaskFailedResponse | CustomTaskTimedOutResponse | CustomTaskCanceledResponse | ActivityTaskStartedResponse | ActivityTaskCompletedResponse | ActivityTaskRetryingResponse | ActivityTaskFailedResponse; workflowContext: StreamEventWorkflowContext; metadata?: { [k: string]: any } | undefined; brokerSequence: number; }; /** @internal */ export const StreamEventSsePayloadData$inboundSchema: z.ZodType< StreamEventSsePayloadData, unknown > = smartUnion([ WorkflowExecutionStartedResponse$inboundSchema, WorkflowExecutionCompletedResponse$inboundSchema, WorkflowExecutionFailedResponse$inboundSchema, WorkflowExecutionCanceledResponse$inboundSchema, WorkflowExecutionContinuedAsNewResponse$inboundSchema, WorkflowTaskTimedOutResponse$inboundSchema, WorkflowTaskFailedResponse$inboundSchema, CustomTaskStartedResponse$inboundSchema, CustomTaskInProgressResponse$inboundSchema, CustomTaskCompletedResponse$inboundSchema, CustomTaskFailedResponse$inboundSchema, CustomTaskTimedOutResponse$inboundSchema, CustomTaskCanceledResponse$inboundSchema, ActivityTaskStartedResponse$inboundSchema, ActivityTaskCompletedResponse$inboundSchema, ActivityTaskRetryingResponse$inboundSchema, ActivityTaskFailedResponse$inboundSchema, ]); export function streamEventSsePayloadDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => StreamEventSsePayloadData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'StreamEventSsePayloadData' from JSON`, ); } /** @internal */ export const StreamEventSsePayload$inboundSchema: z.ZodType< StreamEventSsePayload, unknown > = z.object({ stream: z.string(), timestamp: z.iso.datetime({ offset: true }).transform(v => new Date(v)) .optional(), data: smartUnion([ WorkflowExecutionStartedResponse$inboundSchema, WorkflowExecutionCompletedResponse$inboundSchema, WorkflowExecutionFailedResponse$inboundSchema, WorkflowExecutionCanceledResponse$inboundSchema, WorkflowExecutionContinuedAsNewResponse$inboundSchema, WorkflowTaskTimedOutResponse$inboundSchema, WorkflowTaskFailedResponse$inboundSchema, CustomTaskStartedResponse$inboundSchema, CustomTaskInProgressResponse$inboundSchema, CustomTaskCompletedResponse$inboundSchema, CustomTaskFailedResponse$inboundSchema, CustomTaskTimedOutResponse$inboundSchema, CustomTaskCanceledResponse$inboundSchema, ActivityTaskStartedResponse$inboundSchema, ActivityTaskCompletedResponse$inboundSchema, ActivityTaskRetryingResponse$inboundSchema, ActivityTaskFailedResponse$inboundSchema, ]), workflow_context: StreamEventWorkflowContext$inboundSchema, metadata: z.record(z.string(), z.any()).optional(), broker_sequence: z.int(), }).transform((v) => { return remap$(v, { "workflow_context": "workflowContext", "broker_sequence": "brokerSequence", }); }); export function streamEventSsePayloadFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => StreamEventSsePayload$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'StreamEventSsePayload' from JSON`, ); }