Skip to content

The open alternative to Salesforce, designed for AI.

Keep code step outputs when the code is saved and remove the link output schema (#28432)

Mahmoud Ghazy5f305d11198b
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowDropdownStepOutputItems.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowDropdownStepOutputItems.tsx
index 820bb974df6..fc7513071ce 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowDropdownStepOutputItems.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowDropdownStepOutputItems.tsx
@@ -3,6 +3,7 @@ import { SelectOptionIcon } from '@/ui/input/components/SelectOptionIcon';
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
import { useUpdateStepFilterFromVariable } from '@/workflow/workflow-steps/filters/hooks/useUpdateStepFilterFromVariable';
import { WorkflowVariableSearchResultItems } from '@/workflow/workflow-variables/components/WorkflowVariableSearchResultItems';
+import { WorkflowVariablesDropdownTestStepItem } from '@/workflow/workflow-variables/components/WorkflowVariablesDropdownTestStepItem';
import { useVariableDropdown } from '@/workflow/workflow-variables/hooks/useVariableDropdown';
import { isRecordOutputSchemaV2 } from '@/workflow/workflow-variables/types/guards/isRecordOutputSchemaV2';
import { type StepOutputSchemaV2 } from '@/workflow/workflow-variables/types/StepOutputSchemaV2';
@@ -11,6 +12,7 @@ import { getCurrentSubStepFromPath } from '@/workflow/workflow-variables/utils/g
import { getStepHeaderLabel } from '@/workflow/workflow-variables/utils/getStepHeaderLabel';
import { getStepItemIcon } from '@/workflow/workflow-variables/utils/getStepItemIcon';
import { getVariableTemplateFromPath } from '@/workflow/workflow-variables/utils/getVariableTemplateFromPath';
+import { shouldSuggestTestingStep } from '@/workflow/workflow-variables/utils/shouldSuggestTestingStep';
import { getWorkflowVariableRecordObjectDisplay } from '@/workflow/workflow-variables/utils/getWorkflowVariableRecordObjectDisplay';
import { useLingui } from '@lingui/react/macro';
import { isNonEmptyString } from '@sniptt/guards';
@@ -136,6 +138,9 @@ export const WorkflowDropdownStepOutputItems = ({
/>
<Dropdown.Separator />
<Dropdown.Section scrollable>
+ {shouldSuggestTestingStep({ step, currentPath }) && (
+ <WorkflowVariablesDropdownTestStepItem step={step} />
+ )}
{isSearching ? (
<WorkflowVariableSearchResultItems
searchResults={searchResults}
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowRunStepExecutionStatus.test.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowRunStepExecutionStatus.test.ts
index d19cb893d03..35775741dc9 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowRunStepExecutionStatus.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/utils/__tests__/getWorkflowRunStepExecutionStatus.test.ts
@@ -32,15 +32,7 @@ describe('getWorkflowRunStepExecutionStatus', () => {
b: null,
},
},
- outputSchema: {
- link: {
- tab: 'test',
- icon: 'IconVariable',
- label: 'Generate Function Output',
- isLeaf: true,
- },
- _outputSchemaType: 'LINK',
- },
+ outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
value: 0,
@@ -96,15 +88,7 @@ describe('getWorkflowRunStepExecutionStatus', () => {
b: null,
},
},
- outputSchema: {
- link: {
- tab: 'test',
- icon: 'IconVariable',
- label: 'Generate Function Output',
- isLeaf: true,
- },
- _outputSchemaType: 'LINK',
- },
+ outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
value: 0,
@@ -161,15 +145,7 @@ describe('getWorkflowRunStepExecutionStatus', () => {
b: null,
},
},
- outputSchema: {
- link: {
- tab: 'test',
- icon: 'IconVariable',
- label: 'Generate Function Output',
- isLeaf: true,
- },
- _outputSchemaType: 'LINK',
- },
+ outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
value: 0,
@@ -193,15 +169,7 @@ describe('getWorkflowRunStepExecutionStatus', () => {
b: null,
},
},
- outputSchema: {
- link: {
- tab: 'test',
- icon: 'IconVariable',
- label: 'Generate Function Output',
- isLeaf: true,
- },
- _outputSchemaType: 'LINK',
- },
+ outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
value: 0,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx
index 3ef9e022212..f0c2e0c3c94 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/code-action/components/WorkflowEditActionCode.tsx
@@ -180,15 +180,6 @@ export const WorkflowEditActionCode = ({
...action,
settings: {
...action.settings,
- outputSchema: {
- link: {
- isLeaf: true,
- icon: 'IconVariable',
- tab: 'test',
- label: t`Generate Function Output`,
- },
- _outputSchemaType: 'LINK',
- },
input: {
...action.settings.input,
logicFunctionId: targetLogicFunctionId,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/components/WorkflowVariablesDropdownStepItems.tsx b/packages/twenty-front/src/modules/workflow/workflow-variables/components/WorkflowVariablesDropdownStepItems.tsx
index 5be55f352cf..d668816926e 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/components/WorkflowVariablesDropdownStepItems.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/components/WorkflowVariablesDropdownStepItems.tsx
@@ -2,6 +2,7 @@ import { SelectOptionIcon } from '@/ui/input/components/SelectOptionIcon';
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
import { WorkflowVariableSearchResultItems } from '@/workflow/workflow-variables/components/WorkflowVariableSearchResultItems';
+import { WorkflowVariablesDropdownTestStepItem } from '@/workflow/workflow-variables/components/WorkflowVariablesDropdownTestStepItem';
import { useVariableDropdown } from '@/workflow/workflow-variables/hooks/useVariableDropdown';
import { isRecordOutputSchemaV2 } from '@/workflow/workflow-variables/types/guards/isRecordOutputSchemaV2';
import { type StepOutputSchemaV2 } from '@/workflow/workflow-variables/types/StepOutputSchemaV2';
@@ -9,6 +10,7 @@ import { getCurrentSubStepFromPath } from '@/workflow/workflow-variables/utils/g
import { getStepHeaderLabel } from '@/workflow/workflow-variables/utils/getStepHeaderLabel';
import { getStepItemIcon } from '@/workflow/workflow-variables/utils/getStepItemIcon';
import { getVariableTemplateFromPath } from '@/workflow/workflow-variables/utils/getVariableTemplateFromPath';
+import { shouldSuggestTestingStep } from '@/workflow/workflow-variables/utils/shouldSuggestTestingStep';
import { getWorkflowVariableRecordObjectDisplay } from '@/workflow/workflow-variables/utils/getWorkflowVariableRecordObjectDisplay';
import {
getWorkflowVariableSpecialItems,
@@ -140,6 +142,9 @@ export const WorkflowVariablesDropdownStepItems = ({
/>
<Dropdown.Separator />
<Dropdown.Section scrollable>
+ {shouldSuggestTestingStep({ step, currentPath }) && (
+ <WorkflowVariablesDropdownTestStepItem step={step} />
+ )}
{isSearching ? (
<WorkflowVariableSearchResultItems
searchResults={searchResults}
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/components/WorkflowVariablesDropdownTestStepItem.tsx b/packages/twenty-front/src/modules/workflow/workflow-variables/components/WorkflowVariablesDropdownTestStepItem.tsx
new file mode 100644
index 00000000000..25a07934b7e
--- /dev/null
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/components/WorkflowVariablesDropdownTestStepItem.tsx
@@ -0,0 +1,27 @@
+import { SelectOptionIcon } from '@/ui/input/components/SelectOptionIcon';
+import { useOpenWorkflowStepTestTab } from '@/workflow/workflow-variables/hooks/useOpenWorkflowStepTestTab';
+import { type StepOutputSchemaV2 } from '@/workflow/workflow-variables/types/StepOutputSchemaV2';
+import { useLingui } from '@lingui/react/macro';
+import { IconPlayerPlay } from 'twenty-ui/icon';
+import { Dropdown } from 'twenty-ui/components/navigation';
+
+type WorkflowVariablesDropdownTestStepItemProps = {
+ step: Pick<StepOutputSchemaV2, 'id' | 'name' | 'icon' | 'type'>;
+};
+
+export const WorkflowVariablesDropdownTestStepItem = ({
+ step,
+}: WorkflowVariablesDropdownTestStepItemProps) => {
+ const { t } = useLingui();
+ const { openWorkflowStepTestTab } = useOpenWorkflowStepTestTab();
+
+ return (
+ <Dropdown.OptionItem
+ onSelect={() => openWorkflowStepTestTab(step)}
+ hasSubmenu={false}
+ startIcon={<SelectOptionIcon Icon={IconPlayerPlay} />}
+ >
+ {t`Test this step to see its outputs`}
+ </Dropdown.OptionItem>
+ );
+};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/components/__stories__/WorkflowVariablesDropdownStepItems.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-variables/components/__stories__/WorkflowVariablesDropdownStepItems.stories.tsx
index e2ab46956f0..001e2002d1c 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/components/__stories__/WorkflowVariablesDropdownStepItems.stories.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/components/__stories__/WorkflowVariablesDropdownStepItems.stories.tsx
@@ -78,3 +78,30 @@ export const NestedFieldSearch: Story = {
expect(args.onSelect).toHaveBeenCalledWith('{{code.result.employees}}');
},
};
+
+export const UntestedCodeStep: Story = {
+ args: {
+ step: {
+ id: 'code',
+ name: 'Run code',
+ type: 'CODE',
+ outputSchema: {},
+ },
+ },
+ play: async ({ canvasElement }) => {
+ await userEvent.click(
+ await within(canvasElement).findByRole('button', {
+ name: 'Open variables',
+ }),
+ );
+ const canvas = within(canvasElement.ownerDocument.body);
+
+ expect(
+ await canvas.findByText(
+ 'Test this step to see its outputs',
+ undefined,
+ ASYNC_DECORATOR_WAIT_OPTIONS,
+ ),
+ ).toBeInTheDocument();
+ },
+};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/constants/WorkflowStepTestTabListComponentIdByStepType.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/constants/WorkflowStepTestTabListComponentIdByStepType.ts
new file mode 100644
index 00000000000..af1d119f745
--- /dev/null
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/constants/WorkflowStepTestTabListComponentIdByStepType.ts
@@ -0,0 +1,10 @@
+import { WORKFLOW_LOGIC_FUNCTION_TAB_LIST_COMPONENT_ID } from '@/workflow/workflow-steps/workflow-actions/code-action/constants/WorkflowLogicFunctionTabListComponentId';
+import { WORKFLOW_LOGIC_FUNCTION_ACTION_TAB_LIST_COMPONENT_ID } from '@/workflow/workflow-steps/workflow-actions/logic-function-action/constants/WorkflowLogicFunctionActionTabListComponentId';
+import { type StepOutputSchemaV2 } from '@/workflow/workflow-variables/types/StepOutputSchemaV2';
+
+export const WORKFLOW_STEP_TEST_TAB_LIST_COMPONENT_ID_BY_STEP_TYPE: Partial<
+ Record<StepOutputSchemaV2['type'], string>
+> = {
+ CODE: WORKFLOW_LOGIC_FUNCTION_TAB_LIST_COMPONENT_ID,
+ LOGIC_FUNCTION: WORKFLOW_LOGIC_FUNCTION_ACTION_TAB_LIST_COMPONENT_ID,
+};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useAvailableVariablesInWorkflowStep.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useAvailableVariablesInWorkflowStep.ts
index 20a43060c9e..539515b44b5 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useAvailableVariablesInWorkflowStep.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useAvailableVariablesInWorkflowStep.ts
@@ -10,6 +10,7 @@ import { workflowSelectedNodeComponentState } from '@/workflow/workflow-diagram/
import { getPreviousSteps } from '@/workflow/workflow-steps/utils/getWorkflowPreviousSteps';
import { type StepOutputSchemaV2 } from '@/workflow/workflow-variables/types/StepOutputSchemaV2';
import { filterOutputSchema } from '@/workflow/workflow-variables/utils/filterOutputSchema';
+import { shouldSuggestTestingStep } from '@/workflow/workflow-variables/utils/shouldSuggestTestingStep';
import { isDefined, isEmptyObject } from 'twenty-shared/utils';
export const useAvailableVariablesInWorkflowStep = ({
@@ -47,7 +48,14 @@ export const useAvailableVariablesInWorkflowStep = ({
fieldTypesToExclude,
});
- if (!isDefined(outputSchema) || isEmptyObject(outputSchema)) {
+ if (
+ !isDefined(outputSchema) ||
+ (isEmptyObject(outputSchema) &&
+ !shouldSuggestTestingStep({
+ step: stepOutputSchema,
+ currentPath: [],
+ }))
+ ) {
return undefined;
}
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useOpenWorkflowStepTestTab.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useOpenWorkflowStepTestTab.ts
new file mode 100644
index 00000000000..daf2645edcb
--- /dev/null
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useOpenWorkflowStepTestTab.ts
@@ -0,0 +1,77 @@
+import { useSidePanelWorkflowNavigation } from '@/side-panel/pages/workflow/hooks/useSidePanelWorkflowNavigation';
+import { sidePanelNavigationStackState } from '@/side-panel/states/sidePanelNavigationStackState';
+import { useCloseDropdown } from '@/ui/layout/dropdown/hooks/useCloseDropdown';
+import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
+import { useSetAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useSetAtomComponentState';
+import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
+import { workflowVisualizerWorkflowIdComponentState } from '@/workflow/states/workflowVisualizerWorkflowIdComponentState';
+import { workflowDiagramComponentState } from '@/workflow/workflow-diagram/states/workflowDiagramComponentState';
+import { workflowSelectedNodeComponentState } from '@/workflow/workflow-diagram/states/workflowSelectedNodeComponentState';
+import { WorkflowLogicFunctionTabId } from '@/workflow/workflow-steps/workflow-actions/code-action/types/WorkflowLogicFunctionTabId';
+import { WORKFLOW_STEP_TEST_TAB_LIST_COMPONENT_ID_BY_STEP_TYPE } from '@/workflow/workflow-variables/constants/WorkflowStepTestTabListComponentIdByStepType';
+import { type StepOutputSchemaV2 } from '@/workflow/workflow-variables/types/StepOutputSchemaV2';
+import { doNotTranslate } from 'twenty-shared/i18n';
+import { isDefined } from 'twenty-shared/utils';
+import { useIcons } from 'twenty-ui/icon';
+
+export const useOpenWorkflowStepTestTab = () => {
+ const { getIcon } = useIcons();
+ const { openWorkflowEditStepInSidePanel } = useSidePanelWorkflowNavigation();
+ const { closeDropdown } = useCloseDropdown();
+
+ const workflowVisualizerWorkflowId = useAtomComponentStateValue(
+ workflowVisualizerWorkflowIdComponentState,
+ );
+ const setWorkflowSelectedNode = useSetAtomComponentState(
+ workflowSelectedNodeComponentState,
+ );
+ const setWorkflowDiagram = useSetAtomComponentState(
+ workflowDiagramComponentState,
+ );
+ const setSidePanelNavigationStack = useSetAtomState(
+ sidePanelNavigationStackState,
+ );
+
+ const openWorkflowStepTestTab = (
+ step: Pick<StepOutputSchemaV2, 'id' | 'name' | 'icon' | 'type'>,
+ ) => {
+ if (!isDefined(workflowVisualizerWorkflowId)) {
+ throw new Error(doNotTranslate('Workflow ID must be configured'));
+ }
+
+ setWorkflowSelectedNode(step.id);
+
+ setWorkflowDiagram((diagram) => {
+ if (!isDefined(diagram)) {
+ throw new Error(doNotTranslate('Workflow diagram must be defined'));
+ }
+
+ return {
+ ...diagram,
+ nodes: diagram.nodes.map((node) => ({
+ ...node,
+ selected: node.id === step.id,
+ })),
+ };
+ });
+
+ setSidePanelNavigationStack([]);
+
+ const tabListComponentId =
+ WORKFLOW_STEP_TEST_TAB_LIST_COMPONENT_ID_BY_STEP_TYPE[step.type];
+
+ openWorkflowEditStepInSidePanel({
+ workflowId: workflowVisualizerWorkflowId,
+ title: step.name,
+ icon: getIcon(step.icon),
+ stepId: step.id,
+ initialStepTab: isDefined(tabListComponentId)
+ ? { tabListComponentId, tabId: WorkflowLogicFunctionTabId.TEST }
+ : undefined,
+ });
+
+ closeDropdown();
+ };
+
+ return { openWorkflowStepTestTab };
+};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useVariableDropdown.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useVariableDropdown.ts
index b86753ec645..e3161e7ef38 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useVariableDropdown.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/hooks/useVariableDropdown.ts
@@ -1,31 +1,17 @@
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
-import { useSidePanelWorkflowNavigation } from '@/side-panel/pages/workflow/hooks/useSidePanelWorkflowNavigation';
-import { sidePanelNavigationStackState } from '@/side-panel/states/sidePanelNavigationStackState';
-import { WORKFLOW_LOGIC_FUNCTION_TAB_LIST_COMPONENT_ID } from '@/workflow/workflow-steps/workflow-actions/code-action/constants/WorkflowLogicFunctionTabListComponentId';
-import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
-import { useSetAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useSetAtomComponentState';
-import { workflowVisualizerWorkflowIdComponentState } from '@/workflow/states/workflowVisualizerWorkflowIdComponentState';
-import { workflowDiagramComponentState } from '@/workflow/workflow-diagram/states/workflowDiagramComponentState';
-import { workflowSelectedNodeComponentState } from '@/workflow/workflow-diagram/states/workflowSelectedNodeComponentState';
-import { type LinkOutputSchema } from '@/workflow/workflow-variables/types/LinkOutputSchema';
import { type FieldOutputSchemaV2 } from '@/workflow/workflow-variables/types/RecordOutputSchemaV2';
import { type StepOutputSchemaV2 } from '@/workflow/workflow-variables/types/StepOutputSchemaV2';
import { type WorkflowVariableSearchResult } from '@/workflow/workflow-variables/types/WorkflowVariableSearchResult';
import { type WorkflowVariableSelection } from '@/workflow/workflow-variables/types/WorkflowVariableSelection';
import { getVariableTemplateFromPath } from '@/workflow/workflow-variables/utils/getVariableTemplateFromPath';
-import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
-import { useCloseDropdown } from '@/ui/layout/dropdown/hooks/useCloseDropdown';
import { useState } from 'react';
import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';
-import { doNotTranslate } from 'twenty-shared/i18n';
import { isNonEmptyString } from '@sniptt/guards';
import {
type BaseOutputSchemaV2,
type InputSchemaPropertyType,
} from 'twenty-shared/workflow';
-import { useIcons } from 'twenty-ui/icon';
import { isBaseOutputSchemaV2 } from '@/workflow/workflow-variables/types/guards/isBaseOutputSchemaV2';
-import { isLinkOutputSchema } from '@/workflow/workflow-variables/types/guards/isLinkOutputSchema';
import { isRecordOutputSchemaV2 } from '@/workflow/workflow-variables/types/guards/isRecordOutputSchemaV2';
import { getCurrentSubStepFromPath } from '@/workflow/workflow-variables/utils/getCurrentSubStepFromPath';
import { getWorkflowVariableSelectionFromSearchResult } from '@/workflow/workflow-variables/utils/getWorkflowVariableSelectionFromSearchResult';
@@ -70,36 +56,14 @@ export const useVariableDropdown = ({
shouldDisplayRecordObjects,
objectNameSingularsToSelect,
}: UseVariableDropdownProps): UseVariableDropdownReturn => {
- const { getIcon } = useIcons();
const { objectMetadataItems } = useObjectMetadataItems();
const [currentPath, setCurrentPath] = useState<string[]>(initialPath);
const [searchInputValue, setSearchInputValue] = useState('');
- const { openWorkflowEditStepInSidePanel } = useSidePanelWorkflowNavigation();
- const { closeDropdown } = useCloseDropdown();
-
- const workflowVisualizerWorkflowId = useAtomComponentStateValue(
- workflowVisualizerWorkflowIdComponentState,
- );
-
- const setWorkflowSelectedNode = useSetAtomComponentState(
- workflowSelectedNodeComponentState,
- );
- const setWorkflowDiagram = useSetAtomComponentState(
- workflowDiagramComponentState,
- );
- const setSidePanelNavigationStack = useSetAtomState(
- sidePanelNavigationStackState,
- );
-
const getDisplayedSubStepFields = () => {
const currentSubStep = getCurrentSubStepFromPath(step, currentPath);
- if (isLinkOutputSchema(currentSubStep)) {
- return { link: currentSubStep.link };
- }
-
if (isRecordOutputSchemaV2(currentSubStep)) {
return currentSubStep.fields;
}
@@ -133,50 +97,6 @@ export const useVariableDropdown = ({
});
};
- const handleSelectLinkOutputSchema = (
- linkOutputSchema: LinkOutputSchema,
- ) => {
- if (!isDefined(workflowVisualizerWorkflowId)) {
- throw new Error(doNotTranslate('Workflow ID must be configured'));
- }
-
- setWorkflowSelectedNode(step.id);
-
- setWorkflowDiagram((diagram) => {
- if (!isDefined(diagram)) {
- throw new Error(doNotTranslate('Workflow diagram must be defined'));
- }
-
- return {
- ...diagram,
- nodes: diagram.nodes.map((node) => ({
- ...node,
- selected: node.id === step.id,
- })),
- };
- });
-
- setSidePanelNavigationStack([]);
-
- openWorkflowEditStepInSidePanel({
- workflowId: workflowVisualizerWorkflowId,
- title: step.name,
- icon: getIcon(step.icon),
- stepId: step.id,
- initialStepTab: isDefined(linkOutputSchema.link.tab)
- ? {
- tabListComponentId: WORKFLOW_LOGIC_FUNCTION_TAB_LIST_COMPONENT_ID,
- tabId: linkOutputSchema.link.tab,
- }
- : undefined,
- });
- closeDropdown();
- };
-
- if (isLinkOutputSchema(currentSubStep)) {
- handleSelectLinkOutputSchema(currentSubStep);
- }
-
if (isRecordOutputSchemaV2(currentSubStep)) {
handleSelectBaseOutputSchema(currentSubStep.fields);
}
@@ -218,11 +138,6 @@ export const useVariableDropdown = ({
return;
}
- if (isLinkOutputSchema(getCurrentSubStepFromPath(step, currentPath))) {
- handleSelectField('link');
- return;
- }
-
setCurrentPath(result.path);
setSearchInputValue('');
};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/types/CodeOutputSchema.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/types/CodeOutputSchema.ts
index f4c81640cf6..8a95d99caa1 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/types/CodeOutputSchema.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/types/CodeOutputSchema.ts
@@ -1,4 +1,3 @@
-import { type LinkOutputSchema } from '@/workflow/workflow-variables/types/LinkOutputSchema';
import { type BaseOutputSchemaV2 } from 'twenty-shared/workflow';
-export type CodeOutputSchema = LinkOutputSchema | BaseOutputSchemaV2;
+export type CodeOutputSchema = BaseOutputSchemaV2;
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/types/LinkOutputSchema.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/types/LinkOutputSchema.ts
deleted file mode 100644
index 0e065fe4f47..00000000000
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/types/LinkOutputSchema.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-type Link = {
- isLeaf: true;
- tab?: string;
- label?: string;
-};
-
-export type LinkOutputSchema = {
- link: Link;
- _outputSchemaType: 'LINK';
-};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/types/guards/isLinkOutputSchema.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/types/guards/isLinkOutputSchema.ts
deleted file mode 100644
index 573b2fa39d1..00000000000
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/types/guards/isLinkOutputSchema.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { type LinkOutputSchema } from '@/workflow/workflow-variables/types/LinkOutputSchema';
-import { type OutputSchemaV2 } from '@/workflow/workflow-variables/types/StepOutputSchemaV2';
-import { isObject } from '@sniptt/guards';
-
-export const isLinkOutputSchema = (
- outputSchema: OutputSchemaV2,
-): outputSchema is LinkOutputSchema => {
- return (
- isObject(outputSchema) &&
- '_outputSchemaType' in outputSchema &&
- outputSchema._outputSchemaType === 'LINK'
- );
-};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/__tests__/resolvePersistedStepOutputSchema.test.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/__tests__/resolvePersistedStepOutputSchema.test.ts
new file mode 100644
index 00000000000..cbbc871b273
--- /dev/null
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/__tests__/resolvePersistedStepOutputSchema.test.ts
@@ -0,0 +1,44 @@
+import { resolvePersistedStepOutputSchema } from '@/workflow/workflow-variables/utils/resolvePersistedStepOutputSchema';
+
+const LEGACY_LINK_PLACEHOLDER = {
+ link: { isLeaf: true, tab: 'test', label: 'Generate Function Output' },
+ _outputSchemaType: 'LINK',
+};
+
+describe('resolvePersistedStepOutputSchema', () => {
+ it('returns a tested output schema', () => {
+ const outputSchema = {
+ prefix: { isLeaf: true, type: 'string', label: 'Prefix', value: 'ABC' },
+ };
+
+ expect(
+ resolvePersistedStepOutputSchema({
+ stepType: 'CODE',
+ settings: { outputSchema },
+ }),
+ ).toEqual(outputSchema);
+ });
+
+ it('falls back to the expected output over a stored link placeholder', () => {
+ expect(
+ resolvePersistedStepOutputSchema({
+ stepType: 'CODE',
+ settings: {
+ outputSchema: LEGACY_LINK_PLACEHOLDER,
+ expectedOutputSchema: { result: 42 },
+ },
+ }),
+ ).toEqual({
+ result: { isLeaf: true, type: 'number', value: 42, label: 'result' },
+ });
+ });
+
+ it('treats a stored link placeholder as no output schema', () => {
+ expect(
+ resolvePersistedStepOutputSchema({
+ stepType: 'CODE',
+ settings: { outputSchema: LEGACY_LINK_PLACEHOLDER },
+ }),
+ ).toEqual({});
+ });
+});
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/__tests__/searchWorkflowVariables.test.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/__tests__/searchWorkflowVariables.test.ts
index 9d61cfde6f5..d655c0e343b 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/__tests__/searchWorkflowVariables.test.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/__tests__/searchWorkflowVariables.test.ts
@@ -230,32 +230,6 @@ describe('searchWorkflowVariables', () => {
).toEqual(['find']);
});
- it('does not generate variable values for links to configure missing outputs', () => {
- expect(
- searchWorkflowVariables({
- steps: [
- {
- id: 'code',
- name: 'Run code',
- type: 'CODE',
- outputSchema: {
- _outputSchemaType: 'LINK',
- link: { isLeaf: true, label: 'Test code', tab: 'test' },
- },
- },
- ],
- searchInputValue: 'test',
- }),
- ).toEqual([
- expect.objectContaining({
- stepId: 'code',
- path: [],
- label: 'Test code',
- isLeaf: false,
- }),
- ]);
- });
-
it('finds whole lists and retains numeric array paths', () => {
const step: StepOutputSchemaV2 = {
id: 'code',
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/__tests__/shouldSuggestTestingStep.test.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/__tests__/shouldSuggestTestingStep.test.ts
new file mode 100644
index 00000000000..fe98a972dc5
--- /dev/null
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/__tests__/shouldSuggestTestingStep.test.ts
@@ -0,0 +1,55 @@
+import { shouldSuggestTestingStep } from '@/workflow/workflow-variables/utils/shouldSuggestTestingStep';
+
+describe('shouldSuggestTestingStep', () => {
+ it('suggests testing an untested code or logic function step', () => {
+ expect(
+ shouldSuggestTestingStep({
+ step: { type: 'CODE', outputSchema: {} },
+ currentPath: [],
+ }),
+ ).toBe(true);
+ expect(
+ shouldSuggestTestingStep({
+ step: { type: 'LOGIC_FUNCTION', outputSchema: {} },
+ currentPath: [],
+ }),
+ ).toBe(true);
+ });
+
+ it('does not suggest testing a step that has outputs', () => {
+ expect(
+ shouldSuggestTestingStep({
+ step: {
+ type: 'CODE',
+ outputSchema: {
+ prefix: {
+ isLeaf: true,
+ type: 'string',
+ label: 'Prefix',
+ value: 'A',
+ },
+ },
+ },
+ currentPath: [],
+ }),
+ ).toBe(false);
+ });
+
+ it('does not suggest testing a step type without a Test tab', () => {
+ expect(
+ shouldSuggestTestingStep({
+ step: { type: 'HTTP_REQUEST', outputSchema: {} },
+ currentPath: [],
+ }),
+ ).toBe(false);
+ });
+
+ it('does not suggest testing inside a nested path', () => {
+ expect(
+ shouldSuggestTestingStep({
+ step: { type: 'CODE', outputSchema: {} },
+ currentPath: ['data'],
+ }),
+ ).toBe(false);
+ });
+});
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/filterOutputSchema.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/filterOutputSchema.ts
index d2659bc2839..168e3b19e8f 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/filterOutputSchema.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/filterOutputSchema.ts
@@ -9,7 +9,6 @@ import {
} from '@/workflow/workflow-variables/types/RecordOutputSchemaV2';
import { type OutputSchemaV2 } from '@/workflow/workflow-variables/types/StepOutputSchemaV2';
import { isBaseOutputSchemaV2 } from '@/workflow/workflow-variables/types/guards/isBaseOutputSchemaV2';
-import { isLinkOutputSchema } from '@/workflow/workflow-variables/types/guards/isLinkOutputSchema';
import { isRecordOutputSchemaV2 } from '@/workflow/workflow-variables/types/guards/isRecordOutputSchemaV2';
import { isFieldTypeCompatibleWithRecordId } from '@/workflow/workflow-variables/utils/isFieldTypeCompatibleWithRecordId';
import { isObject } from '@sniptt/guards';
@@ -254,10 +253,6 @@ const filterOutputSchemaFieldsByType = ({
});
}
- if (isLinkOutputSchema(outputSchema)) {
- return outputSchema;
- }
-
return filterNonRecordOutputSchemaFieldsByType({
outputSchema,
fieldTypesToExclude,
@@ -290,9 +285,7 @@ export const filterOutputSchema = ({
return filteredOutputSchema;
}
- if (isLinkOutputSchema(filteredOutputSchema)) {
- return filteredOutputSchema;
- } else if (isRecordOutputSchemaV2(filteredOutputSchema)) {
+ if (isRecordOutputSchemaV2(filteredOutputSchema)) {
return filterRecordOutputSchema({
outputSchema: filteredOutputSchema,
shouldDisplayRecordFields,
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/searchWorkflowVariables.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/searchWorkflowVariables.ts
index 4747e9db84a..e8d4fb07394 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/searchWorkflowVariables.ts
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/searchWorkflowVariables.ts
@@ -1,6 +1,5 @@
import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';
import { isBaseOutputSchemaV2 } from '@/workflow/workflow-variables/types/guards/isBaseOutputSchemaV2';
-import { isLinkOutputSchema } from '@/workflow/workflow-variables/types/guards/isLinkOutputSchema';
import { isRecordOutputSchemaV2 } from '@/workflow/workflow-variables/types/guards/isRecordOutputSchemaV2';
import {
type OutputSchemaV2,
@@ -104,22 +103,6 @@ export const searchWorkflowVariables = ({
});
}
- if (isLinkOutputSchema(outputSchema)) {
- const label = outputSchema.link.label;
-
- if (isDefined(label) && label.toLowerCase().includes(search)) {
- results.push({
- stepId: step.id,
- path,
- label,
- breadcrumb,
- isLeaf: false,
- });
- }
-
- return;
- }
-
const fields = (() => {
if (isRecordOutputSchemaV2(outputSchema)) {
return outputSchema.fields;
diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/shouldSuggestTestingStep.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/shouldSuggestTestingStep.ts
new file mode 100644
index 00000000000..1665f6acc19
--- /dev/null
+++ b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/shouldSuggestTestingStep.ts
@@ -0,0 +1,14 @@
+import { WORKFLOW_STEP_TEST_TAB_LIST_COMPONENT_ID_BY_STEP_TYPE } from '@/workflow/workflow-variables/constants/WorkflowStepTestTabListComponentIdByStepType';
+import { type StepOutputSchemaV2 } from '@/workflow/workflow-variables/types/StepOutputSchemaV2';
+import { isDefined, isEmptyObject, isNonEmptyArray } from 'twenty-shared/utils';
+
+export const shouldSuggestTestingStep = ({
+ step,
+ currentPath,
+}: {
+ step: Pick<StepOutputSchemaV2, 'type' | 'outputSchema'>;
+ currentPath: string[];
+}): boolean =>
+ !isNonEmptyArray(currentPath) &&
+ isDefined(WORKFLOW_STEP_TEST_TAB_LIST_COMPONENT_ID_BY_STEP_TYPE[step.type]) &&
+ isEmptyObject(step.outputSchema);
diff --git a/packages/twenty-front/src/testing/mock-data/workflow-run.ts b/packages/twenty-front/src/testing/mock-data/workflow-run.ts
index 9f42fbee04e..4ae6771283f 100644
--- a/packages/twenty-front/src/testing/mock-data/workflow-run.ts
+++ b/packages/twenty-front/src/testing/mock-data/workflow-run.ts
@@ -26,15 +26,7 @@ export const oneSucceededWorkflowRunQueryResult = {
userId: '{{trigger.userId}}',
},
},
- outputSchema: {
- link: {
- tab: 'test',
- icon: 'IconVariable',
- label: 'Generate Function Output',
- isLeaf: true,
- },
- _outputSchemaType: 'LINK',
- },
+ outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
value: 0,
@@ -55,15 +47,7 @@ export const oneSucceededWorkflowRunQueryResult = {
logicFunctionId: '605efcda-6689-43b3-b24c-2eb76948f523',
logicFunctionInput: {},
},
- outputSchema: {
- link: {
- tab: 'test',
- icon: 'IconVariable',
- label: 'Generate Function Output',
- isLeaf: true,
- },
- _outputSchemaType: 'LINK',
- },
+ outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
value: 0,
@@ -4500,15 +4484,7 @@ export const oneSucceededWorkflowRunQueryResult = {
userId: '{{trigger.userId}}',
},
},
- outputSchema: {
- link: {
- tab: 'test',
- icon: 'IconVariable',
- label: 'Generate Function Output',
- isLeaf: true,
- },
- _outputSchemaType: 'LINK',
- },
+ outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
value: 0,
@@ -4529,15 +4505,7 @@ export const oneSucceededWorkflowRunQueryResult = {
logicFunctionId: '605efcda-6689-43b3-b24c-2eb76948f523',
logicFunctionInput: {},
},
- outputSchema: {
- link: {
- tab: 'test',
- icon: 'IconVariable',
- label: 'Generate Function Output',
- isLeaf: true,
- },
- _outputSchemaType: 'LINK',
- },
+ outputSchema: {},
errorHandlingOptions: {
retryOnFailure: {
value: 0,
diff --git a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-schema/types/output-schema.type.ts b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-schema/types/output-schema.type.ts
index 583916d0680..952743a220b 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-schema/types/output-schema.type.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-schema/types/output-schema.type.ts
@@ -20,13 +20,6 @@ export type Node = {
value: OutputSchema;
};
-type Link = {
- isLeaf: true;
- tab?: string;
- icon?: string;
- label?: string;
-};
-
export type BaseOutputSchema = Record<string, Leaf | Node>;
export type FieldOutputSchema =
@@ -44,12 +37,4 @@ export type RecordOutputSchema = {
_outputSchemaType: 'RECORD';
};
-export type LinkOutputSchema = {
- link: Link;
- _outputSchemaType: 'LINK';
-};
-
-export type OutputSchema =
- | BaseOutputSchema
- | RecordOutputSchema
- | LinkOutputSchema;
+export type OutputSchema = BaseOutputSchema | RecordOutputSchema;
diff --git a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-validation/utils/__tests__/has-workflow-output-schema.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-validation/utils/__tests__/has-workflow-output-schema.util.spec.ts
index 97079839eaf..1f96019b1b8 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-validation/utils/__tests__/has-workflow-output-schema.util.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-validation/utils/__tests__/has-workflow-output-schema.util.spec.ts
@@ -30,26 +30,6 @@ describe('hasWorkflowOutputSchema', () => {
expect(hasWorkflowOutputSchema({ outputSchema: {} })).toBe(false);
});
- it('should reject a LINK output schema as not being a real schema', () => {
- expect(
- hasWorkflowOutputSchema({
- outputSchema: {
- _outputSchemaType: 'LINK',
- href: 'https://example.com',
- },
- }),
- ).toBe(false);
- });
-
- it('should prefer expectedOutputSchema over a LINK output schema', () => {
- expect(
- hasWorkflowOutputSchema({
- expectedOutputSchema: { field: 'value' },
- outputSchema: { _outputSchemaType: 'LINK' },
- }),
- ).toBe(true);
- });
-
it('should return false for non-object schema values', () => {
expect(hasWorkflowOutputSchema({ outputSchema: 'not-an-object' })).toBe(
false,
diff --git a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-validation/utils/has-workflow-output-schema.util.ts b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-validation/utils/has-workflow-output-schema.util.ts
index 30849efa038..b4bc2bc5363 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-validation/utils/has-workflow-output-schema.util.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-validation/utils/has-workflow-output-schema.util.ts
@@ -17,12 +17,5 @@ export const hasWorkflowOutputSchema = (
const outputSchema = settings?.outputSchema;
- return (
- isObject(outputSchema) &&
- Object.keys(outputSchema).length > 0 &&
- !(
- '_outputSchemaType' in outputSchema &&
- outputSchema._outputSchemaType === 'LINK'
- )
- );
+ return isObject(outputSchema) && Object.keys(outputSchema).length > 0;
};
diff --git a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts
index b6d76fb6466..01e6fa44466 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts
@@ -216,15 +216,7 @@ export class WorkflowVersionStepOperationsWorkspaceService {
type: WorkflowActionType.CODE,
settings: {
...BASE_STEP_DEFINITION,
- outputSchema: {
- link: {
- isLeaf: true,
- icon: 'IconVariable',
- tab: 'test',
- label: 'Generate Function Output',
- },
- _outputSchemaType: 'LINK',
- },
+ outputSchema: {},
expectedOutputSchema: {},
input: {
logicFunctionId: newLogicFunction.id,
@@ -279,15 +271,7 @@ export class WorkflowVersionStepOperationsWorkspaceService {
declaredOutputSchema,
)
? inputSchemaToOutputSchema(declaredOutputSchema)
- : {
- link: {
- isLeaf: true,
- icon: 'IconVariable',
- tab: 'test',
- label: 'Generate Function Output',
- },
- _outputSchemaType: 'LINK',
- };
+ : {};
return {
builtStep: {
diff --git a/packages/twenty-shared/src/workflow/index.ts b/packages/twenty-shared/src/workflow/index.ts
index 55b0947d5ce..16b6c6f9a64 100644
--- a/packages/twenty-shared/src/workflow/index.ts
+++ b/packages/twenty-shared/src/workflow/index.ts
@@ -220,7 +220,6 @@ export type {
FormFieldLeaf,
FormFieldNode,
FormOutputSchema,
- LinkOutputSchema,
CodeOutputSchema,
ManualTriggerOutputSchema,
OutputSchemaV2,
diff --git a/packages/twenty-shared/src/workflow/workflow-schema/index.ts b/packages/twenty-shared/src/workflow/workflow-schema/index.ts
index c40a9b81a98..e3321b2cfcd 100644
--- a/packages/twenty-shared/src/workflow/workflow-schema/index.ts
+++ b/packages/twenty-shared/src/workflow/workflow-schema/index.ts
@@ -29,7 +29,6 @@ export type {
FormFieldNode,
FormOutputSchema,
IteratorOutputSchema,
- LinkOutputSchema,
ManualTriggerOutputSchema,
OutputSchemaV2,
RecordFieldLeaf,
diff --git a/packages/twenty-shared/src/workflow/workflow-schema/types/OutputSchema.ts b/packages/twenty-shared/src/workflow/workflow-schema/types/OutputSchema.ts
index 979d71459fc..d9a12c5b465 100644
--- a/packages/twenty-shared/src/workflow/workflow-schema/types/OutputSchema.ts
+++ b/packages/twenty-shared/src/workflow/workflow-schema/types/OutputSchema.ts
@@ -77,12 +77,7 @@ export type FormFieldNode = {
export type FormOutputSchema = Record<string, FormFieldLeaf | FormFieldNode>;
-export type LinkOutputSchema = {
- link: { isLeaf: true; tab?: string; label?: string };
- _outputSchemaType: 'LINK';
-};
-
-export type CodeOutputSchema = LinkOutputSchema | BaseOutputSchemaV2;
+export type CodeOutputSchema = BaseOutputSchemaV2;
export type ManualTriggerOutputSchema = {
payload?: RecordNode | Node;
diff --git a/packages/twenty-shared/src/workflow/workflow-schema/utils/__tests__/search-variable-in-output-schema.code.test.ts b/packages/twenty-shared/src/workflow/workflow-schema/utils/__tests__/search-variable-in-output-schema.code.test.ts
index b0a58b6ef3a..9d0c30d00a2 100644
--- a/packages/twenty-shared/src/workflow/workflow-schema/utils/__tests__/search-variable-in-output-schema.code.test.ts
+++ b/packages/twenty-shared/src/workflow/workflow-schema/utils/__tests__/search-variable-in-output-schema.code.test.ts
@@ -1,5 +1,4 @@
import { type BaseOutputSchemaV2 } from '../../types/BaseOutputSchema';
-import { type CodeOutputSchema } from '../../types/OutputSchema';
import { searchVariableInOutputSchema } from '../search-variable-in-output-schema';
const searchVariableThroughCodeOutputSchema = ({
@@ -8,7 +7,7 @@ const searchVariableThroughCodeOutputSchema = ({
rawVariableName,
}: {
stepName: string;
- codeOutputSchema: CodeOutputSchema;
+ codeOutputSchema: unknown;
rawVariableName: string;
}) =>
searchVariableInOutputSchema({
@@ -20,20 +19,18 @@ const searchVariableThroughCodeOutputSchema = ({
});
describe('searchVariableInOutputSchema - code output schema', () => {
- describe('LinkOutputSchema tests', () => {
- const mockLinkSchema: CodeOutputSchema = {
- link: {
- isLeaf: true,
- tab: 'main',
- label: 'External Link',
- },
- _outputSchemaType: 'LINK',
- };
-
+ describe('stored link placeholder', () => {
it('should return undefined', () => {
const result = searchVariableThroughCodeOutputSchema({
stepName: 'Code Step',
- codeOutputSchema: mockLinkSchema,
+ codeOutputSchema: {
+ link: {
+ isLeaf: true,
+ tab: 'test',
+ label: 'Generate Function Output',
+ },
+ _outputSchemaType: 'LINK',
+ },
rawVariableName: '{{step1.link}}',
});
diff --git a/packages/twenty-shared/src/workflow/workflow-schema/utils/search-variable-in-output-schema.ts b/packages/twenty-shared/src/workflow/workflow-schema/utils/search-variable-in-output-schema.ts
index dac0ff91cb1..cd72f0c2e66 100644
--- a/packages/twenty-shared/src/workflow/workflow-schema/utils/search-variable-in-output-schema.ts
+++ b/packages/twenty-shared/src/workflow/workflow-schema/utils/search-variable-in-output-schema.ts
@@ -16,6 +16,7 @@ import {
type RecordOutputSchemaV2,
type VariableSearchResult,
} from '../types/OutputSchema';
+import { isBaseOutputSchemaV2 } from '../guards/isBaseOutputSchemaV2';
import { isFlattenedArrayOutputSchema } from './flattened-array-output-schema';
const EMPTY_RESULT: VariableSearchResult = {
@@ -473,24 +474,13 @@ const searchThroughCodeOutputSchema = ({
codeOutputSchema: unknown;
rawVariableName: string;
}): VariableSearchResult => {
- if (!isDefined(codeOutputSchema)) {
- return EMPTY_RESULT;
- }
-
- if (
- isObject(codeOutputSchema) &&
- '_outputSchemaType' in codeOutputSchema &&
- codeOutputSchema._outputSchemaType === 'LINK'
- ) {
+ if (!isBaseOutputSchemaV2(codeOutputSchema)) {
return EMPTY_RESULT;
}
const parts = parseVariablePath(stripBrackets(rawVariableName));
- if (
- parts.length === 1 &&
- isFlattenedArrayOutputSchema(codeOutputSchema as BaseOutputSchemaV2)
- ) {
+ if (parts.length === 1 && isFlattenedArrayOutputSchema(codeOutputSchema)) {
return {
variableLabel: stepName,
variablePathLabel: stepName,
@@ -500,7 +490,7 @@ const searchThroughCodeOutputSchema = ({
return searchThroughBaseOutputSchema({
stepName,
- baseOutputSchema: codeOutputSchema as BaseOutputSchemaV2,
+ baseOutputSchema: codeOutputSchema,
rawVariableName,
});
};