|
| 1 | +import { z } from "zod"; |
1 | 2 | import { type ClickHouse, type LogsListResult } from "@internal/clickhouse"; |
2 | 3 | import { MachinePresetName } from "@trigger.dev/core/v3"; |
3 | 4 | import { |
4 | 5 | type PrismaClient, |
5 | 6 | type PrismaClientOrTransaction, |
6 | 7 | type TaskRunStatus, |
| 8 | + TaskRunStatus as TaskRunStatusEnum, |
7 | 9 | TaskTriggerSource, |
8 | 10 | } from "@trigger.dev/database"; |
| 11 | + |
| 12 | +// Create a schema that validates TaskRunStatus enum values |
| 13 | +const TaskRunStatusSchema = z.array(z.string()).refine( |
| 14 | + (val) => val.every((v) => Object.values(TaskRunStatusEnum).includes(v)), |
| 15 | + { message: "Invalid TaskRunStatus values" } |
| 16 | +) as unknown as z.ZodSchema<TaskRunStatus[]>; |
9 | 17 | import parseDuration from "parse-duration"; |
10 | 18 | import { type Direction } from "~/components/ListPagination"; |
11 | 19 | import { timeFilters } from "~/components/runs/v3/SharedFilters"; |
@@ -57,6 +65,32 @@ export type LogsListOptions = { |
57 | 65 | pageSize?: number; |
58 | 66 | }; |
59 | 67 |
|
| 68 | +export const LogsListOptionsSchema = z.object({ |
| 69 | + userId: z.string().optional(), |
| 70 | + projectId: z.string(), |
| 71 | + tasks: z.array(z.string()).optional(), |
| 72 | + versions: z.array(z.string()).optional(), |
| 73 | + statuses: TaskRunStatusSchema.optional(), |
| 74 | + tags: z.array(z.string()).optional(), |
| 75 | + scheduleId: z.string().optional(), |
| 76 | + period: z.string().optional(), |
| 77 | + bulkId: z.string().optional(), |
| 78 | + from: z.number().int().nonnegative().optional(), |
| 79 | + to: z.number().int().nonnegative().optional(), |
| 80 | + isTest: z.boolean().optional(), |
| 81 | + rootOnly: z.boolean().optional(), |
| 82 | + batchId: z.string().optional(), |
| 83 | + runId: z.array(z.string()).optional(), |
| 84 | + queues: z.array(z.string()).optional(), |
| 85 | + machines: z.array(z.string()).optional(), |
| 86 | + levels: z.array(z.enum(["TRACE", "DEBUG", "INFO", "WARN", "ERROR", "CANCELLED"])).optional(), |
| 87 | + search: z.string().max(1000).optional(), |
| 88 | + includeDebugLogs: z.boolean().optional(), |
| 89 | + direction: z.enum(["forward", "backward"]).optional(), |
| 90 | + cursor: z.string().optional(), |
| 91 | + pageSize: z.number().int().positive().max(1000).optional(), |
| 92 | +}); |
| 93 | + |
60 | 94 | const DEFAULT_PAGE_SIZE = 50; |
61 | 95 | const MAX_RUN_IDS = 5000; |
62 | 96 |
|
|
0 commit comments