/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 5f56a5cac68a
 */

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 { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type StreamEventWorkflowContext = {
  namespace: string;
  workflowName: string;
  workflowExecId: string;
  parentWorkflowExecId?: string | null | undefined;
  rootWorkflowExecId?: string | null | undefined;
};

/** @internal */
export const StreamEventWorkflowContext$inboundSchema: z.ZodType<
  StreamEventWorkflowContext,
  unknown
> = z.object({
  namespace: z.string(),
  workflow_name: z.string(),
  workflow_exec_id: z.string(),
  parent_workflow_exec_id: z.nullable(z.string()).optional(),
  root_workflow_exec_id: z.nullable(z.string()).optional(),
}).transform((v) => {
  return remap$(v, {
    "workflow_name": "workflowName",
    "workflow_exec_id": "workflowExecId",
    "parent_workflow_exec_id": "parentWorkflowExecId",
    "root_workflow_exec_id": "rootWorkflowExecId",
  });
});

export function streamEventWorkflowContextFromJSON(
  jsonString: string,
): SafeParseResult<StreamEventWorkflowContext, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => StreamEventWorkflowContext$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'StreamEventWorkflowContext' from JSON`,
  );
}
