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

import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";
import { ClosedEnum } from "../../types/enums.js";
import * as components from "../components/index.js";

export const OrderBy = {
  Created: "created",
  MinusCreated: "-created",
} as const;
export type OrderBy = ClosedEnum<typeof OrderBy>;

export type JobsApiRoutesBatchGetBatchJobsRequest = {
  page?: number | undefined;
  pageSize?: number | undefined;
  model?: string | null | undefined;
  agentId?: string | null | undefined;
  metadata?: { [k: string]: any } | null | undefined;
  createdAfter?: Date | null | undefined;
  createdByMe?: boolean | undefined;
  status?: Array<components.BatchJobStatus> | null | undefined;
  orderBy?: OrderBy | undefined;
};

/** @internal */
export const OrderBy$outboundSchema: z.ZodNativeEnum<typeof OrderBy> = z
  .nativeEnum(OrderBy);

/** @internal */
export type JobsApiRoutesBatchGetBatchJobsRequest$Outbound = {
  page: number;
  page_size: number;
  model?: string | null | undefined;
  agent_id?: string | null | undefined;
  metadata?: { [k: string]: any } | null | undefined;
  created_after?: string | null | undefined;
  created_by_me: boolean;
  status?: Array<string> | null | undefined;
  order_by: string;
};

/** @internal */
export const JobsApiRoutesBatchGetBatchJobsRequest$outboundSchema: z.ZodType<
  JobsApiRoutesBatchGetBatchJobsRequest$Outbound,
  z.ZodTypeDef,
  JobsApiRoutesBatchGetBatchJobsRequest
> = z.object({
  page: z.number().int().default(0),
  pageSize: z.number().int().default(100),
  model: z.nullable(z.string()).optional(),
  agentId: z.nullable(z.string()).optional(),
  metadata: z.nullable(z.record(z.any())).optional(),
  createdAfter: z.nullable(z.date().transform(v => v.toISOString())).optional(),
  createdByMe: z.boolean().default(false),
  status: z.nullable(z.array(components.BatchJobStatus$outboundSchema))
    .optional(),
  orderBy: OrderBy$outboundSchema.default("-created"),
}).transform((v) => {
  return remap$(v, {
    pageSize: "page_size",
    agentId: "agent_id",
    createdAfter: "created_after",
    createdByMe: "created_by_me",
    orderBy: "order_by",
  });
});

export function jobsApiRoutesBatchGetBatchJobsRequestToJSON(
  jobsApiRoutesBatchGetBatchJobsRequest: JobsApiRoutesBatchGetBatchJobsRequest,
): string {
  return JSON.stringify(
    JobsApiRoutesBatchGetBatchJobsRequest$outboundSchema.parse(
      jobsApiRoutesBatchGetBatchJobsRequest,
    ),
  );
}
