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

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import * as components from "../components/index.js";

export type SearchSpansV1ObservabilitySpansSearchPostRequest = {
  from?: Date | null | undefined;
  to?: Date | null | undefined;
  pageSize?: number | undefined;
  cursor?: string | null | undefined;
  spansRequest: components.SpansRequest;
};

/** @internal */
export type SearchSpansV1ObservabilitySpansSearchPostRequest$Outbound = {
  from?: string | null | undefined;
  to?: string | null | undefined;
  page_size: number;
  cursor?: string | null | undefined;
  SpansRequest: components.SpansRequest$Outbound;
};

/** @internal */
export const SearchSpansV1ObservabilitySpansSearchPostRequest$outboundSchema:
  z.ZodType<
    SearchSpansV1ObservabilitySpansSearchPostRequest$Outbound,
    SearchSpansV1ObservabilitySpansSearchPostRequest
  > = z.object({
    from: z.nullable(z.date().transform(v => v.toISOString())).optional(),
    to: z.nullable(z.date().transform(v => v.toISOString())).optional(),
    pageSize: z.int().default(50),
    cursor: z.nullable(z.string()).optional(),
    spansRequest: components.SpansRequest$outboundSchema,
  }).transform((v) => {
    return remap$(v, {
      pageSize: "page_size",
      spansRequest: "SpansRequest",
    });
  });

export function searchSpansV1ObservabilitySpansSearchPostRequestToJSON(
  searchSpansV1ObservabilitySpansSearchPostRequest:
    SearchSpansV1ObservabilitySpansSearchPostRequest,
): string {
  return JSON.stringify(
    SearchSpansV1ObservabilitySpansSearchPostRequest$outboundSchema.parse(
      searchSpansV1ObservabilitySpansSearchPostRequest,
    ),
  );
}
