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

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 DeploymentWorkerResponse = {
  /**
   * Worker name
   */
  name: string;
  /**
   * When the worker first registered
   */
  createdAt: Date;
  /**
   * When the worker last registered
   */
  updatedAt: Date;
  /**
   * Whether this worker's liveness key is currently alive
   */
  isActive: boolean;
};

/** @internal */
export const DeploymentWorkerResponse$inboundSchema: z.ZodType<
  DeploymentWorkerResponse,
  unknown
> = z.object({
  name: z.string(),
  created_at: z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  updated_at: z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  is_active: z.boolean(),
}).transform((v) => {
  return remap$(v, {
    "created_at": "createdAt",
    "updated_at": "updatedAt",
    "is_active": "isActive",
  });
});

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