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

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

/**
 * First-page sort order: 'asc' (oldest first) or 'desc'. Ignored when `cursor` is set.
 */
export const GetWorkflowExecutionLogsOrder = {
  Asc: "asc",
  Desc: "desc",
} as const;
/**
 * First-page sort order: 'asc' (oldest first) or 'desc'. Ignored when `cursor` is set.
 */
export type GetWorkflowExecutionLogsOrder = ClosedEnum<
  typeof GetWorkflowExecutionLogsOrder
>;

export type GetWorkflowExecutionLogsRequest = {
  executionId: string;
  /**
   * Filter logs by workflow run ID
   */
  runId?: string | null | undefined;
  /**
   * Filter logs by activity ID
   */
  activityId?: string | null | undefined;
  /**
   * Only return logs at or after this timestamp
   */
  after?: Date | null | undefined;
  /**
   * Only return logs before this timestamp
   */
  before?: Date | null | undefined;
  /**
   * First-page sort order: 'asc' (oldest first) or 'desc'. Ignored when `cursor` is set.
   */
  order?: GetWorkflowExecutionLogsOrder | undefined;
  /**
   * Pagination cursor from a previous response's `next_cursor`; carries the window and order
   */
  cursor?: string | null | undefined;
  /**
   * Maximum number of logs to return
   */
  limit?: number | undefined;
};

/** @internal */
export const GetWorkflowExecutionLogsOrder$outboundSchema: z.ZodEnum<
  typeof GetWorkflowExecutionLogsOrder
> = z.enum(GetWorkflowExecutionLogsOrder);

/** @internal */
export type GetWorkflowExecutionLogsRequest$Outbound = {
  execution_id: string;
  run_id?: string | null | undefined;
  activity_id?: string | null | undefined;
  after?: string | null | undefined;
  before?: string | null | undefined;
  order: string;
  cursor?: string | null | undefined;
  limit: number;
};

/** @internal */
export const GetWorkflowExecutionLogsRequest$outboundSchema: z.ZodType<
  GetWorkflowExecutionLogsRequest$Outbound,
  GetWorkflowExecutionLogsRequest
> = z.object({
  executionId: z.string(),
  runId: z.nullable(z.string()).optional(),
  activityId: z.nullable(z.string()).optional(),
  after: z.nullable(z.date().transform(v => v.toISOString())).optional(),
  before: z.nullable(z.date().transform(v => v.toISOString())).optional(),
  order: GetWorkflowExecutionLogsOrder$outboundSchema.default("asc"),
  cursor: z.nullable(z.string()).optional(),
  limit: z.int().default(50),
}).transform((v) => {
  return remap$(v, {
    executionId: "execution_id",
    runId: "run_id",
    activityId: "activity_id",
  });
});

export function getWorkflowExecutionLogsRequestToJSON(
  getWorkflowExecutionLogsRequest: GetWorkflowExecutionLogsRequest,
): string {
  return JSON.stringify(
    GetWorkflowExecutionLogsRequest$outboundSchema.parse(
      getWorkflowExecutionLogsRequest,
    ),
  );
}
