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

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 Event = {
  /**
   * The name of the event.
   */
  name: string;
  data?: { [k: string]: any } | null | undefined;
  /**
   * The UNIX timestamp (in seconds) of the event.
   */
  createdAt: number;
};

/** @internal */
export const Event$inboundSchema: z.ZodType<Event, unknown> = z.object({
  name: z.string(),
  data: z.nullable(z.record(z.string(), z.any())).optional(),
  created_at: z.int(),
}).transform((v) => {
  return remap$(v, {
    "created_at": "createdAt",
  });
});

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