/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: d93f865786bc */ 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 * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type StreamV1WorkflowsExecutionsExecutionIdStreamGetRequest = { executionId: string; eventSource?: components.EventSource | null | undefined; lastEventId?: string | null | undefined; }; export type StreamV1WorkflowsExecutionsExecutionIdStreamGetData = | components.StreamEventSsePayload | components.WorkflowStreamError; /** * Stream of Server-Sent Events (SSE) */ export type StreamV1WorkflowsExecutionsExecutionIdStreamGetResponseBody = { /** * SSE event name. `error` indicates the stream failed after HTTP 200. */ event?: string | undefined; data?: | components.StreamEventSsePayload | components.WorkflowStreamError | undefined; id?: string | undefined; retry?: number | undefined; }; /** @internal */ export type StreamV1WorkflowsExecutionsExecutionIdStreamGetRequest$Outbound = { execution_id: string; event_source?: string | null | undefined; last_event_id?: string | null | undefined; }; /** @internal */ export const StreamV1WorkflowsExecutionsExecutionIdStreamGetRequest$outboundSchema: z.ZodType< StreamV1WorkflowsExecutionsExecutionIdStreamGetRequest$Outbound, StreamV1WorkflowsExecutionsExecutionIdStreamGetRequest > = z.object({ executionId: z.string(), eventSource: z.nullable(components.EventSource$outboundSchema).optional(), lastEventId: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { executionId: "execution_id", eventSource: "event_source", lastEventId: "last_event_id", }); }); export function streamV1WorkflowsExecutionsExecutionIdStreamGetRequestToJSON( streamV1WorkflowsExecutionsExecutionIdStreamGetRequest: StreamV1WorkflowsExecutionsExecutionIdStreamGetRequest, ): string { return JSON.stringify( StreamV1WorkflowsExecutionsExecutionIdStreamGetRequest$outboundSchema.parse( streamV1WorkflowsExecutionsExecutionIdStreamGetRequest, ), ); } /** @internal */ export const StreamV1WorkflowsExecutionsExecutionIdStreamGetData$inboundSchema: z.ZodType = smartUnion([ components.StreamEventSsePayload$inboundSchema, components.WorkflowStreamError$inboundSchema, ]); export function streamV1WorkflowsExecutionsExecutionIdStreamGetDataFromJSON( jsonString: string, ): SafeParseResult< StreamV1WorkflowsExecutionsExecutionIdStreamGetData, SDKValidationError > { return safeParse( jsonString, (x) => StreamV1WorkflowsExecutionsExecutionIdStreamGetData$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'StreamV1WorkflowsExecutionsExecutionIdStreamGetData' from JSON`, ); } /** @internal */ export const StreamV1WorkflowsExecutionsExecutionIdStreamGetResponseBody$inboundSchema: z.ZodType< StreamV1WorkflowsExecutionsExecutionIdStreamGetResponseBody, unknown > = z.object({ event: z.string().optional(), data: z.string().optional().transform((v, ctx) => { if (v === undefined) return undefined; try { return JSON.parse(v); } catch (err) { ctx.addIssue({ input: v, code: "custom", message: `malformed json: ${err}`, }); return z.NEVER; } }).pipe( smartUnion([ components.StreamEventSsePayload$inboundSchema, components.WorkflowStreamError$inboundSchema, ]).optional(), ), id: z.string().optional(), retry: z.int().optional(), }); export function streamV1WorkflowsExecutionsExecutionIdStreamGetResponseBodyFromJSON( jsonString: string, ): SafeParseResult< StreamV1WorkflowsExecutionsExecutionIdStreamGetResponseBody, SDKValidationError > { return safeParse( jsonString, (x) => StreamV1WorkflowsExecutionsExecutionIdStreamGetResponseBody$inboundSchema .parse(JSON.parse(x)), `Failed to parse 'StreamV1WorkflowsExecutionsExecutionIdStreamGetResponseBody' from JSON`, ); }