|
1 | 1 | import { |
2 | 2 | type ListRunResponse, |
3 | 3 | type ListRunResponseItem, |
| 4 | + MachinePresetName, |
4 | 5 | parsePacket, |
5 | 6 | RunStatus, |
6 | 7 | } from "@trigger.dev/core/v3"; |
@@ -106,6 +107,34 @@ export const ApiRunListSearchParams = z.object({ |
106 | 107 | "filter[createdAt][to]": CoercedDate, |
107 | 108 | "filter[createdAt][period]": z.string().optional(), |
108 | 109 | "filter[batch]": z.string().optional(), |
| 110 | + "filter[queue]": z |
| 111 | + .string() |
| 112 | + .optional() |
| 113 | + .transform((value) => { |
| 114 | + return value ? value.split(",") : undefined; |
| 115 | + }), |
| 116 | + "filter[machine]": z |
| 117 | + .string() |
| 118 | + .optional() |
| 119 | + .transform((value, ctx) => { |
| 120 | + const values = value ? value.split(",") : undefined; |
| 121 | + if (!values) { |
| 122 | + return undefined; |
| 123 | + } |
| 124 | + |
| 125 | + const parsedValues = values.map((v) => MachinePresetName.safeParse(v)); |
| 126 | + const invalidValues = parsedValues.filter((result) => !result.success); |
| 127 | + if (invalidValues.length > 0) { |
| 128 | + ctx.addIssue({ |
| 129 | + code: z.ZodIssueCode.custom, |
| 130 | + message: `Invalid machine values: ${invalidValues.join(", ")}`, |
| 131 | + }); |
| 132 | + |
| 133 | + return z.NEVER; |
| 134 | + } |
| 135 | + |
| 136 | + return parsedValues.map((result) => result.data).filter(Boolean); |
| 137 | + }), |
109 | 138 | }); |
110 | 139 |
|
111 | 140 | type ApiRunListSearchParams = z.infer<typeof ApiRunListSearchParams>; |
@@ -213,6 +242,14 @@ export class ApiRunListPresenter extends BasePresenter { |
213 | 242 | options.batchId = searchParams["filter[batch]"]; |
214 | 243 | } |
215 | 244 |
|
| 245 | + if (searchParams["filter[queue]"]) { |
| 246 | + options.queues = searchParams["filter[queue]"]; |
| 247 | + } |
| 248 | + |
| 249 | + if (searchParams["filter[machine]"]) { |
| 250 | + options.machines = searchParams["filter[machine]"]; |
| 251 | + } |
| 252 | + |
216 | 253 | const presenter = new NextRunListPresenter(this._prisma, clickhouseClient); |
217 | 254 |
|
218 | 255 | logger.debug("Calling RunListPresenter", { options }); |
|
0 commit comments