Skip to content

Commit 33184a8

Browse files
authored
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
1 parent 5611768 commit 33184a8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.changeset/fair-spiders-brake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/core": patch
3+
---
4+
5+
Add subtasks to the schema/types when getting an individual run

packages/core/src/schemas/runs.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ export const RunTaskSchema = z.object({
3333
completedAt: z.coerce.date().nullable(),
3434
});
3535

36+
export type RunTaskWithSubtasks = z.infer<typeof RunTaskSchema> & {
37+
/** The subtasks of the task */
38+
subtasks?: RunTaskWithSubtasks[];
39+
};
40+
41+
const RunTaskWithSubtasksSchema: z.ZodType<RunTaskWithSubtasks> = RunTaskSchema.extend({
42+
subtasks: z.lazy(() => RunTaskWithSubtasksSchema.array()).optional(),
43+
});
44+
3645
const GetRunOptionsSchema = z.object({
3746
/** Return subtasks, which appear in a `subtasks` array on a task. @default false */
3847
subtasks: z.boolean().optional(),
@@ -68,7 +77,7 @@ export const GetRunSchema = RunSchema.extend({
6877
/** The output of the run */
6978
output: z.any().optional(),
7079
/** The tasks from the run */
71-
tasks: z.array(RunTaskSchema),
80+
tasks: z.array(RunTaskWithSubtasksSchema),
7281
/** If there are more tasks, you can use this to get them */
7382
nextCursor: z.string().optional(),
7483
});

0 commit comments

Comments
 (0)