Use view filters operands in step filters + migrate to twenty-shared (#13137)

Step operand will more or less be the same as view filter operand. 

This PR:
- moves `ViewFilterOperand` to twenty-shared
- use it as step operand
- check what operand should be available based on the selected field
type in filter action
- rewrite the function that evaluates filters so it uses
ViewFilterOperand instead

ViewFilterOperand may be renamed in a future PR.
This commit is contained in:
Thomas Trompette
2025-07-10 10:36:37 +02:00
committed by GitHub
parent d808cbeed9
commit 50e402af07
55 changed files with 677 additions and 665 deletions
@@ -76,6 +76,7 @@ describe('searchVariableThroughOutputSchema', () => {
expect(result).toEqual({
variableLabel: undefined,
variablePathLabel: 'Step 1 > undefined',
variableType: 'unknown',
});
});
@@ -89,6 +90,7 @@ describe('searchVariableThroughOutputSchema', () => {
expect(result).toEqual({
variableLabel: 'Name',
variablePathLabel: 'Step 1 > Company > Name',
variableType: 'unknown',
});
});
@@ -102,6 +104,7 @@ describe('searchVariableThroughOutputSchema', () => {
expect(result).toEqual({
variableLabel: 'Email',
variablePathLabel: 'Step 1 > Person > Email',
variableType: 'unknown',
});
});
@@ -115,6 +118,7 @@ describe('searchVariableThroughOutputSchema', () => {
expect(result).toEqual({
variableLabel: 'Company',
variablePathLabel: 'Step 1 > Company > Company',
variableType: 'unknown',
});
});
@@ -128,6 +132,7 @@ describe('searchVariableThroughOutputSchema', () => {
expect(result).toEqual({
variableLabel: 'Person',
variablePathLabel: 'Step 1 > Person > Person',
variableType: 'unknown',
});
});
@@ -141,6 +146,7 @@ describe('searchVariableThroughOutputSchema', () => {
expect(result).toEqual({
variableLabel: 'Simple Data',
variablePathLabel: 'Step 1 > Simple Data',
variableType: 'unknown',
});
});
@@ -154,6 +160,7 @@ describe('searchVariableThroughOutputSchema', () => {
expect(result).toEqual({
variableLabel: 'Field 1',
variablePathLabel: 'Step 1 > Nested Data > Field 1',
variableType: 'unknown',
});
});
@@ -167,6 +174,7 @@ describe('searchVariableThroughOutputSchema', () => {
expect(result).toEqual({
variableLabel: undefined,
variablePathLabel: 'Step 1 > undefined',
variableType: 'unknown',
});
});
@@ -180,6 +188,7 @@ describe('searchVariableThroughOutputSchema', () => {
expect(result).toEqual({
variableLabel: undefined,
variablePathLabel: 'Step 1 > undefined',
variableType: 'unknown',
});
});
@@ -208,6 +217,7 @@ describe('searchVariableThroughOutputSchema', () => {
expect(result).toEqual({
variableLabel: 'Field 1',
variablePathLabel: 'Step 1 > Complex Field > Field 1',
variableType: 'unknown',
});
});
});
@@ -274,6 +284,7 @@ describe('searchVariableThroughOutputSchema', () => {
expect(result).toEqual({
variableLabel: 'Name',
variablePathLabel: 'Record is Created > Name',
variableType: FieldMetadataType.TEXT,
});
});
@@ -288,6 +299,7 @@ describe('searchVariableThroughOutputSchema', () => {
expect(result).toEqual({
variableLabel: ' Amount Micros',
variablePathLabel: 'Record is Created > ARR > Amount Micros',
variableType: FieldMetadataType.NUMERIC,
});
});
@@ -301,6 +313,7 @@ describe('searchVariableThroughOutputSchema', () => {
expect(result).toEqual({
variableLabel: 'Company',
variablePathLabel: 'Record is Created > Company',
variableType: 'unknown',
});
});
@@ -314,6 +327,7 @@ describe('searchVariableThroughOutputSchema', () => {
expect(result).toEqual({
variableLabel: undefined,
variablePathLabel: 'Record is Created > undefined',
variableType: 'unknown',
});
});
});
@@ -4,6 +4,7 @@ import {
StepOutputSchema,
} from '@/workflow/workflow-variables/types/StepOutputSchema';
import { isBaseOutputSchema } from '@/workflow/workflow-variables/utils/isBaseOutputSchema';
import { isLinkOutputSchema } from '@/workflow/workflow-variables/utils/isLinkOutputSchema';
import { isRecordOutputSchema } from '@/workflow/workflow-variables/utils/isRecordOutputSchema';
import { isDefined } from 'twenty-shared/utils';
@@ -30,6 +31,18 @@ const getDisplayedSubStepFieldLabel = (
return;
};
const getVariableType = (key: string, outputSchema: OutputSchema): string => {
if (isRecordOutputSchema(outputSchema)) {
return outputSchema.fields[key]?.type ?? 'unknown';
}
if (isLinkOutputSchema(outputSchema)) {
return 'unknown';
}
return outputSchema[key]?.type ?? 'unknown';
};
const searchCurrentStepOutputSchema = ({
stepOutputSchema,
path,
@@ -90,6 +103,7 @@ const searchCurrentStepOutputSchema = ({
return {
variableLabel: undefined,
variablePathLabel: undefined,
variableType: undefined,
};
}
@@ -102,6 +116,10 @@ const searchCurrentStepOutputSchema = ({
currentSubStep,
),
variablePathLabel,
variableType: getVariableType(
isSelectedFieldInNextKey ? nextKey : selectedField,
currentSubStep,
),
};
};
@@ -142,15 +160,17 @@ export const searchVariableThroughOutputSchema = ({
};
}
const { variableLabel, variablePathLabel } = searchCurrentStepOutputSchema({
stepOutputSchema,
path,
isFullRecord,
selectedField,
});
const { variableLabel, variablePathLabel, variableType } =
searchCurrentStepOutputSchema({
stepOutputSchema,
path,
isFullRecord,
selectedField,
});
return {
variableLabel,
variablePathLabel: `${variablePathLabel} > ${variableLabel}`,
variableType,
};
};