Add subtasks to the schema/types when getting an individual run (#343)

* Add subtasks to the schema/types when getting an individual run

* Added a changeset
This commit is contained in:
Matt Aitken
2023-08-16 15:49:08 +01:00
committed by GitHub
parent 5611768854
commit 33184a8130
2 changed files with 15 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@trigger.dev/core": patch
---
Add subtasks to the schema/types when getting an individual run
+10 -1
View File
@@ -33,6 +33,15 @@ export const RunTaskSchema = z.object({
completedAt: z.coerce.date().nullable(),
});
export type RunTaskWithSubtasks = z.infer<typeof RunTaskSchema> & {
/** The subtasks of the task */
subtasks?: RunTaskWithSubtasks[];
};
const RunTaskWithSubtasksSchema: z.ZodType<RunTaskWithSubtasks> = RunTaskSchema.extend({
subtasks: z.lazy(() => RunTaskWithSubtasksSchema.array()).optional(),
});
const GetRunOptionsSchema = z.object({
/** Return subtasks, which appear in a `subtasks` array on a task. @default false */
subtasks: z.boolean().optional(),
@@ -68,7 +77,7 @@ export const GetRunSchema = RunSchema.extend({
/** The output of the run */
output: z.any().optional(),
/** The tasks from the run */
tasks: z.array(RunTaskSchema),
tasks: z.array(RunTaskWithSubtasksSchema),
/** If there are more tasks, you can use this to get them */
nextCursor: z.string().optional(),
});