Make the frontend resilient to old workflow run output formats (#10522)

- Create zod schemas for everything related to a workflow run
- Update the types to be inferred from the zod schemas
- Improper workflow run outputs will render a blank screen; we could
show an error in the future



https://github.com/user-attachments/assets/8e666c3e-82b0-4ab5-8804-2f70130ea257
This commit is contained in:
Baptiste Devessier
2025-02-27 10:36:19 +01:00
committed by GitHub
parent 5a39903d42
commit 8bd9bc9d31
7 changed files with 324 additions and 411 deletions

View File

@ -1,16 +1,23 @@
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord';
import { WorkflowRun } from '@/workflow/types/Workflow';
import { workflowRunSchema } from '@/workflow/validation-schemas/workflowSchema';
export const useWorkflowRun = ({
workflowRunId,
}: {
workflowRunId: string;
}) => {
const { record } = useFindOneRecord<WorkflowRun>({
}): WorkflowRun | undefined => {
const { record: rawRecord } = useFindOneRecord({
objectNameSingular: CoreObjectNameSingular.WorkflowRun,
objectRecordId: workflowRunId,
});
const { success, data: record } = workflowRunSchema.safeParse(rawRecord);
if (!success) {
return undefined;
}
return record;
};

View File

@ -0,0 +1,16 @@
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord';
import { WorkflowRun } from '@/workflow/types/Workflow';
export const useWorkflowRunUnsafe = ({
workflowRunId,
}: {
workflowRunId: string;
}) => {
const { record } = useFindOneRecord<WorkflowRun>({
objectNameSingular: CoreObjectNameSingular.WorkflowRun,
objectRecordId: workflowRunId,
});
return record;
};