Remove useless columns (#13312)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { FieldContext } from '@/object-record/record-field/contexts/FieldContext';
|
||||
import { orderWorkflowRunOutput } from '@/object-record/record-field/meta-types/utils/orderWorkflowRunOutput';
|
||||
import { orderWorkflowRunState } from '@/object-record/record-field/meta-types/utils/orderWorkflowRunState';
|
||||
import { FieldJsonValue } from '@/object-record/record-field/types/FieldMetadata';
|
||||
import { useContext } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
@ -15,10 +15,10 @@ export const useFormattedJsonFieldValue = ({
|
||||
if (
|
||||
fieldDefinition.metadata.objectMetadataNameSingular ===
|
||||
CoreObjectNameSingular.WorkflowRun &&
|
||||
fieldDefinition.metadata.fieldName === 'output' &&
|
||||
fieldDefinition.metadata.fieldName === 'state' &&
|
||||
isDefined(fieldValue)
|
||||
) {
|
||||
return orderWorkflowRunOutput(fieldValue) as FieldJsonValue;
|
||||
return orderWorkflowRunState(fieldValue) as FieldJsonValue;
|
||||
}
|
||||
|
||||
return fieldValue;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { FieldContext } from '@/object-record/record-field/contexts/FieldContext';
|
||||
import { orderWorkflowRunOutput } from '@/object-record/record-field/meta-types/utils/orderWorkflowRunOutput';
|
||||
import { orderWorkflowRunState } from '@/object-record/record-field/meta-types/utils/orderWorkflowRunState';
|
||||
import { useContext } from 'react';
|
||||
import { isDefined, parseJson } from 'twenty-shared/utils';
|
||||
import { JsonObject, JsonValue } from 'type-fest';
|
||||
@ -19,10 +19,10 @@ export const usePrecomputedJsonDraftValue = ({
|
||||
if (
|
||||
fieldDefinition.metadata.objectMetadataNameSingular ===
|
||||
CoreObjectNameSingular.WorkflowRun &&
|
||||
fieldDefinition.metadata.fieldName === 'output' &&
|
||||
fieldDefinition.metadata.fieldName === 'state' &&
|
||||
isDefined(draftValue)
|
||||
) {
|
||||
return orderWorkflowRunOutput(parsedJsonValue) as JsonObject;
|
||||
return orderWorkflowRunState(parsedJsonValue) as JsonObject;
|
||||
}
|
||||
|
||||
return parsedJsonValue;
|
||||
|
||||
@ -10,6 +10,6 @@ export const isWorkflowRunJsonField = ({
|
||||
}) => {
|
||||
return (
|
||||
objectMetadataNameSingular === CoreObjectNameSingular.WorkflowRun &&
|
||||
(fieldName === 'output' || fieldName === 'context')
|
||||
fieldName === 'state'
|
||||
);
|
||||
};
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
import { WorkflowRunOutput } from '@/workflow/types/Workflow';
|
||||
import { workflowRunOutputSchema } from '@/workflow/validation-schemas/workflowSchema';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { JsonValue } from 'type-fest';
|
||||
|
||||
export const orderWorkflowRunOutput = (value: JsonValue) => {
|
||||
const parsedValue = workflowRunOutputSchema.safeParse(value);
|
||||
if (!parsedValue.success) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const orderedWorkflowRunOutput: WorkflowRunOutput = {
|
||||
...(isDefined(parsedValue.data.error)
|
||||
? {
|
||||
error: parsedValue.data.error,
|
||||
}
|
||||
: {}),
|
||||
...(isDefined(parsedValue.data.stepsOutput)
|
||||
? {
|
||||
stepsOutput: parsedValue.data.stepsOutput,
|
||||
}
|
||||
: {}),
|
||||
flow: parsedValue.data.flow,
|
||||
};
|
||||
|
||||
return orderedWorkflowRunOutput;
|
||||
};
|
||||
@ -0,0 +1,23 @@
|
||||
import { WorkflowRunState } from '@/workflow/types/Workflow';
|
||||
import { workflowRunStateSchema } from '@/workflow/validation-schemas/workflowSchema';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { JsonValue } from 'type-fest';
|
||||
|
||||
export const orderWorkflowRunState = (value: JsonValue) => {
|
||||
const parsedValue = workflowRunStateSchema.safeParse(value);
|
||||
if (!parsedValue.success) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const orderedWorkflowRunState: WorkflowRunState = {
|
||||
...(isDefined(parsedValue.data.workflowRunError)
|
||||
? {
|
||||
workflowRunError: parsedValue.data.workflowRunError,
|
||||
}
|
||||
: {}),
|
||||
stepInfos: parsedValue.data.stepInfos,
|
||||
flow: parsedValue.data.flow,
|
||||
};
|
||||
|
||||
return orderedWorkflowRunState;
|
||||
};
|
||||
@ -80,8 +80,6 @@ export const useRunWorkflowVersion = () => {
|
||||
const recordInput: Partial<WorkflowRun> = {
|
||||
name: '#0',
|
||||
status: 'NOT_STARTED',
|
||||
output: null,
|
||||
context: null,
|
||||
workflowVersionId,
|
||||
workflowId,
|
||||
createdAt: new Date().toISOString(),
|
||||
|
||||
@ -1,63 +1,26 @@
|
||||
import {
|
||||
workflowAiAgentActionSchema,
|
||||
workflowAiAgentActionSettingsSchema,
|
||||
workflowCodeActionSchema,
|
||||
workflowCodeActionSettingsSchema,
|
||||
workflowCreateRecordActionSchema,
|
||||
workflowCreateRecordActionSettingsSchema,
|
||||
workflowCronTriggerSchema,
|
||||
workflowDatabaseEventTriggerSchema,
|
||||
workflowDeleteRecordActionSchema,
|
||||
workflowDeleteRecordActionSettingsSchema,
|
||||
workflowExecutorOutputSchema,
|
||||
workflowFilterActionSchema,
|
||||
workflowFilterActionSettingsSchema,
|
||||
workflowFindRecordsActionSchema,
|
||||
workflowFindRecordsActionSettingsSchema,
|
||||
workflowFormActionSchema,
|
||||
workflowFormActionSettingsSchema,
|
||||
workflowHttpRequestActionSchema,
|
||||
workflowManualTriggerSchema,
|
||||
workflowRunOutputSchema,
|
||||
workflowRunOutputStepsOutputSchema,
|
||||
workflowRunSchema,
|
||||
workflowRunStateSchema,
|
||||
workflowRunStatusSchema,
|
||||
workflowRunStepStatusSchema,
|
||||
workflowSendEmailActionSchema,
|
||||
workflowSendEmailActionSettingsSchema,
|
||||
workflowTriggerSchema,
|
||||
workflowUpdateRecordActionSchema,
|
||||
workflowUpdateRecordActionSettingsSchema,
|
||||
workflowWebhookTriggerSchema,
|
||||
} from '@/workflow/validation-schemas/workflowSchema';
|
||||
import { z } from 'zod';
|
||||
|
||||
export type WorkflowCodeActionSettings = z.infer<
|
||||
typeof workflowCodeActionSettingsSchema
|
||||
>;
|
||||
export type WorkflowSendEmailActionSettings = z.infer<
|
||||
typeof workflowSendEmailActionSettingsSchema
|
||||
>;
|
||||
export type WorkflowCreateRecordActionSettings = z.infer<
|
||||
typeof workflowCreateRecordActionSettingsSchema
|
||||
>;
|
||||
export type WorkflowUpdateRecordActionSettings = z.infer<
|
||||
typeof workflowUpdateRecordActionSettingsSchema
|
||||
>;
|
||||
export type WorkflowDeleteRecordActionSettings = z.infer<
|
||||
typeof workflowDeleteRecordActionSettingsSchema
|
||||
>;
|
||||
export type WorkflowFindRecordsActionSettings = z.infer<
|
||||
typeof workflowFindRecordsActionSettingsSchema
|
||||
>;
|
||||
export type WorkflowFilterActionSettings = z.infer<
|
||||
typeof workflowFilterActionSettingsSchema
|
||||
>;
|
||||
export type WorkflowFormActionSettings = z.infer<
|
||||
typeof workflowFormActionSettingsSchema
|
||||
>;
|
||||
|
||||
export type WorkflowCodeAction = z.infer<typeof workflowCodeActionSchema>;
|
||||
export type WorkflowSendEmailAction = z.infer<
|
||||
typeof workflowSendEmailActionSchema
|
||||
@ -80,10 +43,6 @@ export type WorkflowHttpRequestAction = z.infer<
|
||||
typeof workflowHttpRequestActionSchema
|
||||
>;
|
||||
|
||||
export type WorkflowAiAgentActionSettings = z.infer<
|
||||
typeof workflowAiAgentActionSettingsSchema
|
||||
>;
|
||||
|
||||
export type WorkflowAiAgentAction = z.infer<typeof workflowAiAgentActionSchema>;
|
||||
|
||||
export type WorkflowAction =
|
||||
@ -143,14 +102,6 @@ export type ManualTriggerWorkflowVersion = WorkflowVersion & {
|
||||
trigger: WorkflowManualTrigger | null;
|
||||
};
|
||||
|
||||
export type WorkflowRunOutput = z.infer<typeof workflowRunOutputSchema>;
|
||||
export type WorkflowExecutorOutput = z.infer<
|
||||
typeof workflowExecutorOutputSchema
|
||||
>;
|
||||
export type WorkflowRunOutputStepsOutput = z.infer<
|
||||
typeof workflowRunOutputStepsOutputSchema
|
||||
>;
|
||||
|
||||
export type WorkflowRunStatus = z.infer<typeof workflowRunStatusSchema>;
|
||||
|
||||
export type WorkflowRun = z.infer<typeof workflowRunSchema>;
|
||||
|
||||
@ -297,27 +297,6 @@ export const workflowTriggerSchema = z.discriminatedUnion('type', [
|
||||
workflowWebhookTriggerSchema,
|
||||
]);
|
||||
|
||||
// Step output schemas
|
||||
export const workflowExecutorOutputSchema = z.object({
|
||||
result: z.any().optional(),
|
||||
error: z.any().optional(),
|
||||
pendingEvent: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const workflowRunOutputStepsOutputSchema = z.record(
|
||||
workflowExecutorOutputSchema,
|
||||
);
|
||||
|
||||
// Final workflow run output schema
|
||||
export const workflowRunOutputSchema = z.object({
|
||||
flow: z.object({
|
||||
trigger: workflowTriggerSchema,
|
||||
steps: z.array(workflowActionSchema),
|
||||
}),
|
||||
stepsOutput: workflowRunOutputStepsOutputSchema.optional(),
|
||||
error: z.any().optional(),
|
||||
});
|
||||
|
||||
export const workflowRunStepStatusSchema = z.nativeEnum(StepStatus);
|
||||
|
||||
export const workflowRunStateStepInfoSchema = z.object({
|
||||
@ -339,8 +318,6 @@ export const workflowRunStateSchema = z.object({
|
||||
workflowRunError: z.any().optional(),
|
||||
});
|
||||
|
||||
export const workflowRunContextSchema = z.record(z.any());
|
||||
|
||||
export const workflowRunStatusSchema = z.enum([
|
||||
'NOT_STARTED',
|
||||
'RUNNING',
|
||||
@ -355,8 +332,6 @@ export const workflowRunSchema = z
|
||||
id: z.string(),
|
||||
workflowVersionId: z.string(),
|
||||
workflowId: z.string(),
|
||||
output: workflowRunOutputSchema.nullable(),
|
||||
context: workflowRunContextSchema.nullable(),
|
||||
state: workflowRunStateSchema.nullable(),
|
||||
status: workflowRunStatusSchema,
|
||||
createdAt: z.string(),
|
||||
|
||||
@ -35,6 +35,8 @@ export const WorkflowRunStepOutputDetail = ({ stepId }: { stepId: string }) => {
|
||||
|
||||
const stepInfo = workflowRun.state.stepInfos[stepId];
|
||||
|
||||
const { status: _, ...stepInfoWithoutStatus } = stepInfo ?? {};
|
||||
|
||||
const stepDefinition = getStepDefinitionOrThrow({
|
||||
stepId,
|
||||
trigger: workflowRun.state.flow.trigger,
|
||||
@ -84,7 +86,7 @@ export const WorkflowRunStepOutputDetail = ({ stepId }: { stepId: string }) => {
|
||||
|
||||
<WorkflowRunStepJsonContainer>
|
||||
<JsonTree
|
||||
value={stepInfo ?? t`No output available`}
|
||||
value={stepInfoWithoutStatus ?? t`No output available`}
|
||||
shouldExpandNodeInitially={isTwoFirstDepths}
|
||||
emptyArrayLabel={t`Empty Array`}
|
||||
emptyObjectLabel={t`Empty Object`}
|
||||
|
||||
@ -25,8 +25,6 @@ export const useSubmitFormStep = () => {
|
||||
id: true,
|
||||
name: true,
|
||||
status: true,
|
||||
output: true,
|
||||
context: true,
|
||||
startedAt: true,
|
||||
endedAt: true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user