/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 6c11f6c5701a */ import * as z from "zod/v4"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.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 StreamDeploymentLogsRequest = { name: string; /** * Filter logs by worker name */ workerName?: string | null | undefined; /** * Filter logs by workflow name */ workflowName?: string | null | undefined; /** * Start a fresh stream at this timestamp (ignored when resuming via last_event_id) */ after?: Date | null | undefined; /** * Resume from this cursor (a prior response's SSE id) */ lastEventId?: string | null | undefined; }; export const StreamDeploymentLogsEvent = { Log: "log", Error: "error", } as const; export type StreamDeploymentLogsEvent = OpenEnum< typeof StreamDeploymentLogsEvent >; export type StreamDeploymentLogsData = | components.DeploymentLogRecord | components.StreamError; /** * Stream of Server-Sent Events (SSE): `log` events carry a DeploymentLogRecord; `error` events carry a StreamError payload. */ export type StreamDeploymentLogsResponseBody = { event?: StreamDeploymentLogsEvent | undefined; id?: string | undefined; data?: components.DeploymentLogRecord | components.StreamError | undefined; }; /** @internal */ export type StreamDeploymentLogsRequest$Outbound = { name: string; worker_name?: string | null | undefined; workflow_name?: string | null | undefined; after?: string | null | undefined; last_event_id?: string | null | undefined; }; /** @internal */ export const StreamDeploymentLogsRequest$outboundSchema: z.ZodType< StreamDeploymentLogsRequest$Outbound, StreamDeploymentLogsRequest > = z.object({ name: z.string(), workerName: z.nullable(z.string()).optional(), workflowName: z.nullable(z.string()).optional(), after: z.nullable(z.date().transform(v => v.toISOString())).optional(), lastEventId: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { workerName: "worker_name", workflowName: "workflow_name", lastEventId: "last_event_id", }); }); export function streamDeploymentLogsRequestToJSON( streamDeploymentLogsRequest: StreamDeploymentLogsRequest, ): string { return JSON.stringify( StreamDeploymentLogsRequest$outboundSchema.parse( streamDeploymentLogsRequest, ), ); } /** @internal */ export const StreamDeploymentLogsEvent$inboundSchema: z.ZodType< StreamDeploymentLogsEvent, unknown > = openEnums.inboundSchema(StreamDeploymentLogsEvent); /** @internal */ export const StreamDeploymentLogsData$inboundSchema: z.ZodType< StreamDeploymentLogsData, unknown > = smartUnion([ components.DeploymentLogRecord$inboundSchema, components.StreamError$inboundSchema, ]); export function streamDeploymentLogsDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => StreamDeploymentLogsData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'StreamDeploymentLogsData' from JSON`, ); } /** @internal */ export const StreamDeploymentLogsResponseBody$inboundSchema: z.ZodType< StreamDeploymentLogsResponseBody, unknown > = z.object({ event: StreamDeploymentLogsEvent$inboundSchema.optional(), id: 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.DeploymentLogRecord$inboundSchema, components.StreamError$inboundSchema, ]).optional(), ), }); export function streamDeploymentLogsResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => StreamDeploymentLogsResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'StreamDeploymentLogsResponseBody' from JSON`, ); }