|
1 | | -import { parsePacket, RunStatus } from "@trigger.dev/core/v3"; |
| 1 | +import { |
| 2 | + type ListRunResponse, |
| 3 | + type ListRunResponseItem, |
| 4 | + MachinePresetName, |
| 5 | + parsePacket, |
| 6 | + RunStatus, |
| 7 | +} from "@trigger.dev/core/v3"; |
2 | 8 | import { type Project, type RuntimeEnvironment, type TaskRunStatus } from "@trigger.dev/database"; |
3 | 9 | import assertNever from "assert-never"; |
4 | 10 | import { z } from "zod"; |
@@ -104,6 +110,34 @@ export const ApiRunListSearchParams = z.object({ |
104 | 110 | "filter[createdAt][to]": CoercedDate, |
105 | 111 | "filter[createdAt][period]": z.string().optional(), |
106 | 112 | "filter[batch]": z.string().optional(), |
| 113 | + "filter[queue]": z |
| 114 | + .string() |
| 115 | + .optional() |
| 116 | + .transform((value) => { |
| 117 | + return value ? value.split(",") : undefined; |
| 118 | + }), |
| 119 | + "filter[machine]": z |
| 120 | + .string() |
| 121 | + .optional() |
| 122 | + .transform((value, ctx) => { |
| 123 | + const values = value ? value.split(",") : undefined; |
| 124 | + if (!values) { |
| 125 | + return undefined; |
| 126 | + } |
| 127 | + |
| 128 | + const parsedValues = values.map((v) => MachinePresetName.safeParse(v)); |
| 129 | + const invalidValues = parsedValues.filter((result) => !result.success); |
| 130 | + if (invalidValues.length > 0) { |
| 131 | + ctx.addIssue({ |
| 132 | + code: z.ZodIssueCode.custom, |
| 133 | + message: `Invalid machine values: ${invalidValues.join(", ")}`, |
| 134 | + }); |
| 135 | + |
| 136 | + return z.NEVER; |
| 137 | + } |
| 138 | + |
| 139 | + return parsedValues.map((result) => result.data).filter(Boolean); |
| 140 | + }), |
107 | 141 | }); |
108 | 142 |
|
109 | 143 | type ApiRunListSearchParams = z.infer<typeof ApiRunListSearchParams>; |
|
0 commit comments