/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: aa05b4aa9186 */ import * as z from "zod/v4"; import { safeParse } from "../../lib/schemas.js"; import * as discriminatedUnionTypes from "../../types/discriminatedUnion.js"; import { discriminatedUnion } from "../../types/discriminatedUnion.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { JSONPatchAdd, JSONPatchAdd$inboundSchema } from "./jsonpatchadd.js"; import { JSONPatchAppend, JSONPatchAppend$inboundSchema, } from "./jsonpatchappend.js"; import { JSONPatchRemove, JSONPatchRemove$inboundSchema, } from "./jsonpatchremove.js"; import { JSONPatchReplace, JSONPatchReplace$inboundSchema, } from "./jsonpatchreplace.js"; export type JSONPatchPayloadResponseValue = | JSONPatchAdd | JSONPatchAppend | JSONPatchRemove | JSONPatchReplace | discriminatedUnionTypes.Unknown<"op">; /** * A payload containing a list of JSON Patch operations. * * @remarks * * Used for streaming incremental updates to workflow state. */ export type JSONPatchPayloadResponse = { /** * Discriminator indicating this is a JSON Patch payload. */ type: "json_patch"; /** * The list of JSON Patch operations to apply in order. */ value: Array< | JSONPatchAdd | JSONPatchAppend | JSONPatchRemove | JSONPatchReplace | discriminatedUnionTypes.Unknown<"op"> >; }; /** @internal */ export const JSONPatchPayloadResponseValue$inboundSchema: z.ZodType< JSONPatchPayloadResponseValue, unknown > = discriminatedUnion("op", { add: JSONPatchAdd$inboundSchema, append: JSONPatchAppend$inboundSchema, remove: JSONPatchRemove$inboundSchema, replace: JSONPatchReplace$inboundSchema, }); export function jsonPatchPayloadResponseValueFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => JSONPatchPayloadResponseValue$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'JSONPatchPayloadResponseValue' from JSON`, ); } /** @internal */ export const JSONPatchPayloadResponse$inboundSchema: z.ZodType< JSONPatchPayloadResponse, unknown > = z.object({ type: z.literal("json_patch"), value: z.array( discriminatedUnion("op", { add: JSONPatchAdd$inboundSchema, append: JSONPatchAppend$inboundSchema, remove: JSONPatchRemove$inboundSchema, replace: JSONPatchReplace$inboundSchema, }), ), }); export function jsonPatchPayloadResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => JSONPatchPayloadResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'JSONPatchPayloadResponse' from JSON`, ); }