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

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 ScheduleRecentExecution = {
  /**
   * Time the execution was scheduled to run.
   */
  scheduledAt: Date;
  /**
   * Actual time the execution started.
   */
  startedAt: Date;
  /**
   * ID of the workflow execution that was started.
   */
  executionId: string;
};

/** @internal */
export const ScheduleRecentExecution$inboundSchema: z.ZodType<
  ScheduleRecentExecution,
  unknown
> = z.object({
  scheduled_at: z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  started_at: z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  execution_id: z.string(),
}).transform((v) => {
  return remap$(v, {
    "scheduled_at": "scheduledAt",
    "started_at": "startedAt",
    "execution_id": "executionId",
  });
});

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