/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 4e2617d53d6d */ import * as z from "zod/v4"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { smartUnion } from "../../types/smartUnion.js"; import * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Filter by workflow status */ export type ListRunsV1WorkflowsRunsGetStatus = | components.WorkflowExecutionStatus | Array; /** * Field to sort by */ export const SortBy = { StartTime: "start_time", EndTime: "end_time", } as const; /** * Field to sort by */ export type SortBy = ClosedEnum; /** * Sort direction */ export const ListRunsV1WorkflowsRunsGetOrder = { Asc: "asc", Desc: "desc", } as const; /** * Sort direction */ export type ListRunsV1WorkflowsRunsGetOrder = ClosedEnum< typeof ListRunsV1WorkflowsRunsGetOrder >; export type ListRunsV1WorkflowsRunsGetRequest = { /** * Filter by workflow name or id */ workflowIdentifier?: string | null | undefined; /** * Filter by root execution id; returns the whole execution tree (the root and all its descendant sub-workflows). */ rootExecutionId?: string | null | undefined; /** * Search by workflow name, display name, or ID */ search?: string | null | undefined; /** * Filter by workflow status */ status?: | components.WorkflowExecutionStatus | Array | null | undefined; /** * Filter by deployment name */ deploymentName?: string | null | undefined; /** * Field to sort by */ sortBy?: SortBy | null | undefined; /** * Sort direction */ order?: ListRunsV1WorkflowsRunsGetOrder | undefined; /** * Include runs with start_time >= value */ startTimeAfter?: Date | null | undefined; /** * Include runs with start_time <= value */ startTimeBefore?: Date | null | undefined; /** * Include runs with end_time >= value. Running executions (no end_time) are excluded; use the status filter to include them. */ endTimeAfter?: Date | null | undefined; /** * Include runs with end_time <= value. Running executions (no end_time) are excluded; use the status filter to include them. */ endTimeBefore?: Date | null | undefined; /** * Filter by user id. Use 'current' to filter by the authenticated user */ userId?: string | null | undefined; /** * Include runs of internal/technical workflows (e.g. parallel-execution) */ includeInternal?: boolean | undefined; /** * Number of items per page */ pageSize?: number | undefined; /** * Token for the next page of results */ nextPageToken?: string | null | undefined; }; export type ListRunsV1WorkflowsRunsGetResponse = { result: components.WorkflowExecutionListResponse; }; /** @internal */ export type ListRunsV1WorkflowsRunsGetStatus$Outbound = string | Array; /** @internal */ export const ListRunsV1WorkflowsRunsGetStatus$outboundSchema: z.ZodType< ListRunsV1WorkflowsRunsGetStatus$Outbound, ListRunsV1WorkflowsRunsGetStatus > = smartUnion([ components.WorkflowExecutionStatus$outboundSchema, z.array(components.WorkflowExecutionStatus$outboundSchema), ]); export function listRunsV1WorkflowsRunsGetStatusToJSON( listRunsV1WorkflowsRunsGetStatus: ListRunsV1WorkflowsRunsGetStatus, ): string { return JSON.stringify( ListRunsV1WorkflowsRunsGetStatus$outboundSchema.parse( listRunsV1WorkflowsRunsGetStatus, ), ); } /** @internal */ export const SortBy$outboundSchema: z.ZodEnum = z.enum(SortBy); /** @internal */ export const ListRunsV1WorkflowsRunsGetOrder$outboundSchema: z.ZodEnum< typeof ListRunsV1WorkflowsRunsGetOrder > = z.enum(ListRunsV1WorkflowsRunsGetOrder); /** @internal */ export type ListRunsV1WorkflowsRunsGetRequest$Outbound = { workflow_identifier?: string | null | undefined; root_execution_id?: string | null | undefined; search?: string | null | undefined; status?: string | Array | null | undefined; deployment_name?: string | null | undefined; sort_by?: string | null | undefined; order: string; start_time_after?: string | null | undefined; start_time_before?: string | null | undefined; end_time_after?: string | null | undefined; end_time_before?: string | null | undefined; user_id?: string | null | undefined; include_internal: boolean; page_size: number; next_page_token?: string | null | undefined; }; /** @internal */ export const ListRunsV1WorkflowsRunsGetRequest$outboundSchema: z.ZodType< ListRunsV1WorkflowsRunsGetRequest$Outbound, ListRunsV1WorkflowsRunsGetRequest > = z.object({ workflowIdentifier: z.nullable(z.string()).optional(), rootExecutionId: z.nullable(z.string()).optional(), search: z.nullable(z.string()).optional(), status: z.nullable( smartUnion([ components.WorkflowExecutionStatus$outboundSchema, z.array(components.WorkflowExecutionStatus$outboundSchema), ]), ).optional(), deploymentName: z.nullable(z.string()).optional(), sortBy: z.nullable(SortBy$outboundSchema).optional(), order: ListRunsV1WorkflowsRunsGetOrder$outboundSchema.default("desc"), startTimeAfter: z.nullable(z.date().transform(v => v.toISOString())) .optional(), startTimeBefore: z.nullable(z.date().transform(v => v.toISOString())) .optional(), endTimeAfter: z.nullable(z.date().transform(v => v.toISOString())).optional(), endTimeBefore: z.nullable(z.date().transform(v => v.toISOString())) .optional(), userId: z.nullable(z.string()).optional(), includeInternal: z.boolean().default(true), pageSize: z.int().default(50), nextPageToken: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { workflowIdentifier: "workflow_identifier", rootExecutionId: "root_execution_id", deploymentName: "deployment_name", sortBy: "sort_by", startTimeAfter: "start_time_after", startTimeBefore: "start_time_before", endTimeAfter: "end_time_after", endTimeBefore: "end_time_before", userId: "user_id", includeInternal: "include_internal", pageSize: "page_size", nextPageToken: "next_page_token", }); }); export function listRunsV1WorkflowsRunsGetRequestToJSON( listRunsV1WorkflowsRunsGetRequest: ListRunsV1WorkflowsRunsGetRequest, ): string { return JSON.stringify( ListRunsV1WorkflowsRunsGetRequest$outboundSchema.parse( listRunsV1WorkflowsRunsGetRequest, ), ); } /** @internal */ export const ListRunsV1WorkflowsRunsGetResponse$inboundSchema: z.ZodType< ListRunsV1WorkflowsRunsGetResponse, unknown > = z.object({ Result: components.WorkflowExecutionListResponse$inboundSchema, }).transform((v) => { return remap$(v, { "Result": "result", }); }); export function listRunsV1WorkflowsRunsGetResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListRunsV1WorkflowsRunsGetResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListRunsV1WorkflowsRunsGetResponse' from JSON`, ); }