101 featch available variables from previous steps (#8062)
- add outputSchema in workflow step settings - use outputSchemas to compute step available variables https://github.com/user-attachments/assets/6b851d8e-625c-49ff-b29c-074cd86cbfee
This commit is contained in:
@ -48,7 +48,7 @@ export const WorkflowEditActionFormServerlessFunction = (
|
||||
value={props.action.settings.input.serverlessFunctionId}
|
||||
options={availableFunctions}
|
||||
disabled={props.readonly}
|
||||
onChange={(updatedFunction) => {
|
||||
onChange={(serverlessFunctionId) => {
|
||||
if (props.readonly === true) {
|
||||
return;
|
||||
}
|
||||
@ -58,7 +58,10 @@ export const WorkflowEditActionFormServerlessFunction = (
|
||||
settings: {
|
||||
...props.action.settings,
|
||||
input: {
|
||||
serverlessFunctionId: updatedFunction,
|
||||
serverlessFunctionId,
|
||||
serverlessFunctionVersion:
|
||||
serverlessFunctions.find((f) => f.id === serverlessFunctionId)
|
||||
?.latestVersion || 'latest',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@ -134,6 +134,7 @@ export const WorkflowEditTriggerDatabaseEventForm = ({
|
||||
type: 'DATABASE_EVENT',
|
||||
settings: {
|
||||
eventName: `${updatedRecordType}.${OBJECT_EVENT_TRIGGERS[0].value}`,
|
||||
outputSchema: {},
|
||||
},
|
||||
},
|
||||
);
|
||||
@ -165,6 +166,7 @@ export const WorkflowEditTriggerDatabaseEventForm = ({
|
||||
type: 'DATABASE_EVENT',
|
||||
settings: {
|
||||
eventName: `${availableMetadata[0].value}.${updatedEvent}`,
|
||||
outputSchema: {},
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const COMPUTE_STEP_OUTPUT_SCHEMA = gql`
|
||||
mutation ComputeStepOutputSchema($input: ComputeStepOutputSchemaInput!) {
|
||||
computeStepOutputSchema(input: $input)
|
||||
}
|
||||
`;
|
||||
@ -4,7 +4,7 @@ import { ApolloClient, useApolloClient, useMutation } from '@apollo/client';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { modifyRecordFromCache } from '@/object-record/cache/utils/modifyRecordFromCache';
|
||||
import { ACTIVATE_WORKFLOW_VERSION } from '@/workflow/graphql/activateWorkflowVersion';
|
||||
import { ACTIVATE_WORKFLOW_VERSION } from '@/workflow/graphql/mutations/activateWorkflowVersion';
|
||||
import { WorkflowVersion } from '@/workflow/types/Workflow';
|
||||
import {
|
||||
ActivateWorkflowVersionMutation,
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
import { capitalize } from '~/utils/string/capitalize';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { workflowIdState } from '@/workflow/states/workflowIdState';
|
||||
import { useWorkflowWithCurrentVersion } from '@/workflow/hooks/useWorkflowWithCurrentVersion';
|
||||
import { workflowSelectedNodeState } from '@/workflow/states/workflowSelectedNodeState';
|
||||
import { getStepDefinitionOrThrow } from '@/workflow/utils/getStepDefinitionOrThrow';
|
||||
import { isDefined } from 'twenty-ui';
|
||||
import { StepOutputSchema } from '@/workflow/search-variables/types/StepOutputSchema';
|
||||
|
||||
export const useAvailableVariablesInWorkflowStep = (): StepOutputSchema[] => {
|
||||
const workflowId = useRecoilValue(workflowIdState);
|
||||
const workflow = useWorkflowWithCurrentVersion(workflowId);
|
||||
const workflowSelectedNode = useRecoilValue(workflowSelectedNodeState);
|
||||
|
||||
if (!isDefined(workflowSelectedNode) || !isDefined(workflow)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const stepDefinition = getStepDefinitionOrThrow({
|
||||
stepId: workflowSelectedNode,
|
||||
workflowVersion: workflow.currentVersion,
|
||||
});
|
||||
|
||||
if (
|
||||
!isDefined(stepDefinition) ||
|
||||
stepDefinition.type === 'trigger' ||
|
||||
!isDefined(workflow.currentVersion.steps)
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const previousSteps = [];
|
||||
|
||||
for (const step of workflow.currentVersion.steps) {
|
||||
if (step.id === workflowSelectedNode) {
|
||||
break;
|
||||
}
|
||||
previousSteps.push(step);
|
||||
}
|
||||
|
||||
const result = [];
|
||||
|
||||
if (
|
||||
workflow.currentVersion.trigger?.type === 'DATABASE_EVENT' &&
|
||||
isDefined(workflow.currentVersion.trigger?.settings?.outputSchema)
|
||||
) {
|
||||
const [object, action] =
|
||||
workflow.currentVersion.trigger.settings.eventName.split('.');
|
||||
result.push({
|
||||
id: 'trigger',
|
||||
name: `${capitalize(object)} is ${capitalize(action)}`,
|
||||
outputSchema: workflow.currentVersion.trigger.settings.outputSchema,
|
||||
});
|
||||
}
|
||||
|
||||
previousSteps.forEach((previousStep) => {
|
||||
if (isDefined(previousStep.settings.outputSchema)) {
|
||||
result.push({
|
||||
id: previousStep.id,
|
||||
name: previousStep.name,
|
||||
outputSchema: previousStep.settings.outputSchema,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
@ -0,0 +1,26 @@
|
||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
||||
import { ApolloClient, useMutation } from '@apollo/client';
|
||||
import {
|
||||
ComputeStepOutputSchemaInput,
|
||||
ComputeStepOutputSchemaMutation,
|
||||
ComputeStepOutputSchemaMutationVariables,
|
||||
} from '~/generated/graphql';
|
||||
import { COMPUTE_STEP_OUTPUT_SCHEMA } from '@/workflow/graphql/mutations/computeStepOutputSchema';
|
||||
|
||||
export const useComputeStepOutputSchema = () => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
const [mutate] = useMutation<
|
||||
ComputeStepOutputSchemaMutation,
|
||||
ComputeStepOutputSchemaMutationVariables
|
||||
>(COMPUTE_STEP_OUTPUT_SCHEMA, {
|
||||
client: apolloMetadataClient ?? ({} as ApolloClient<any>),
|
||||
});
|
||||
|
||||
const computeStepOutputSchema = async (
|
||||
input: ComputeStepOutputSchemaInput,
|
||||
) => {
|
||||
return await mutate({ variables: { input } });
|
||||
};
|
||||
|
||||
return { computeStepOutputSchema };
|
||||
};
|
||||
@ -16,6 +16,7 @@ import { getStepDefaultDefinition } from '@/workflow/utils/getStepDefaultDefinit
|
||||
import { insertStep } from '@/workflow/utils/insertStep';
|
||||
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
||||
import { isDefined } from 'twenty-ui';
|
||||
import { useComputeStepOutputSchema } from '@/workflow/hooks/useComputeStepOutputSchema';
|
||||
|
||||
export const useCreateStep = ({
|
||||
workflow,
|
||||
@ -40,6 +41,8 @@ export const useCreateStep = ({
|
||||
|
||||
const { createNewWorkflowVersion } = useCreateNewWorkflowVersion();
|
||||
|
||||
const { computeStepOutputSchema } = useComputeStepOutputSchema();
|
||||
|
||||
const insertNodeAndSave = async ({
|
||||
parentNodeId,
|
||||
nodeToAdd,
|
||||
@ -85,6 +88,17 @@ export const useCreateStep = ({
|
||||
|
||||
const newStep = getStepDefaultDefinition(newStepType);
|
||||
|
||||
const outputSchema = (
|
||||
await computeStepOutputSchema({
|
||||
step: newStep,
|
||||
})
|
||||
)?.data?.computeStepOutputSchema;
|
||||
|
||||
newStep.settings = {
|
||||
...newStep.settings,
|
||||
outputSchema: outputSchema || {},
|
||||
};
|
||||
|
||||
await insertNodeAndSave({
|
||||
parentNodeId: workflowCreateStepFromParentStepId,
|
||||
nodeToAdd: newStep,
|
||||
|
||||
@ -4,7 +4,7 @@ import { ApolloClient, useApolloClient, useMutation } from '@apollo/client';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { modifyRecordFromCache } from '@/object-record/cache/utils/modifyRecordFromCache';
|
||||
import { DEACTIVATE_WORKFLOW_VERSION } from '@/workflow/graphql/deactivateWorkflowVersion';
|
||||
import { DEACTIVATE_WORKFLOW_VERSION } from '@/workflow/graphql/mutations/deactivateWorkflowVersion';
|
||||
import {
|
||||
ActivateWorkflowVersionMutation,
|
||||
ActivateWorkflowVersionMutationVariables,
|
||||
|
||||
@ -8,6 +8,7 @@ import {
|
||||
} from '@/workflow/types/Workflow';
|
||||
import { replaceStep } from '@/workflow/utils/replaceStep';
|
||||
import { isDefined } from 'twenty-ui';
|
||||
import { useComputeStepOutputSchema } from '@/workflow/hooks/useComputeStepOutputSchema';
|
||||
|
||||
export const useUpdateWorkflowVersionStep = ({
|
||||
workflow,
|
||||
@ -22,12 +23,24 @@ export const useUpdateWorkflowVersionStep = ({
|
||||
});
|
||||
|
||||
const { createNewWorkflowVersion } = useCreateNewWorkflowVersion();
|
||||
const { computeStepOutputSchema } = useComputeStepOutputSchema();
|
||||
|
||||
const updateStep = async <T extends WorkflowStep>(updatedStep: T) => {
|
||||
if (!isDefined(workflow.currentVersion)) {
|
||||
throw new Error('Can not update an undefined workflow version.');
|
||||
}
|
||||
|
||||
const outputSchema = (
|
||||
await computeStepOutputSchema({
|
||||
step: updatedStep,
|
||||
})
|
||||
)?.data?.computeStepOutputSchema;
|
||||
|
||||
updatedStep.settings = {
|
||||
...updatedStep.settings,
|
||||
outputSchema: outputSchema || {},
|
||||
};
|
||||
|
||||
const updatedSteps = replaceStep({
|
||||
steps: workflow.currentVersion.steps ?? [],
|
||||
stepId,
|
||||
|
||||
@ -7,6 +7,7 @@ import {
|
||||
WorkflowWithCurrentVersion,
|
||||
} from '@/workflow/types/Workflow';
|
||||
import { isDefined } from 'twenty-ui';
|
||||
import { useComputeStepOutputSchema } from '@/workflow/hooks/useComputeStepOutputSchema';
|
||||
|
||||
export const useUpdateWorkflowVersionTrigger = ({
|
||||
workflow,
|
||||
@ -20,12 +21,25 @@ export const useUpdateWorkflowVersionTrigger = ({
|
||||
|
||||
const { createNewWorkflowVersion } = useCreateNewWorkflowVersion();
|
||||
|
||||
const { computeStepOutputSchema } = useComputeStepOutputSchema();
|
||||
|
||||
const updateTrigger = async (updatedTrigger: WorkflowTrigger) => {
|
||||
if (!isDefined(workflow.currentVersion)) {
|
||||
throw new Error('Can not update an undefined workflow version.');
|
||||
}
|
||||
|
||||
if (workflow.currentVersion.status === 'DRAFT') {
|
||||
const outputSchema = (
|
||||
await computeStepOutputSchema({
|
||||
step: updatedTrigger,
|
||||
})
|
||||
)?.data?.computeStepOutputSchema;
|
||||
|
||||
updatedTrigger.settings = {
|
||||
...updatedTrigger.settings,
|
||||
outputSchema: outputSchema || {},
|
||||
};
|
||||
|
||||
await updateOneWorkflowVersion({
|
||||
idToUpdate: workflow.currentVersion.id,
|
||||
updateOneRecordInput: {
|
||||
|
||||
@ -5,14 +5,14 @@ import { StyledDropdownButtonContainer } from '@/ui/layout/dropdown/components/S
|
||||
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
||||
import { SearchVariablesDropdownStepItem } from '@/workflow/search-variables/components/SearchVariablesDropdownStepItem';
|
||||
import SearchVariablesDropdownStepSubItem from '@/workflow/search-variables/components/SearchVariablesDropdownStepSubItem';
|
||||
import { AVAILABLE_VARIABLES_MOCK } from '@/workflow/search-variables/constants/AvailableVariablesMock';
|
||||
import { SEARCH_VARIABLES_DROPDOWN_ID } from '@/workflow/search-variables/constants/SearchVariablesDropdownId';
|
||||
import { WorkflowStepMock } from '@/workflow/search-variables/types/WorkflowStepMock';
|
||||
import { StepOutputSchema } from '@/workflow/search-variables/types/StepOutputSchema';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { Editor } from '@tiptap/react';
|
||||
import { useState } from 'react';
|
||||
import { IconVariable } from 'twenty-ui';
|
||||
import { useAvailableVariablesInWorkflowStep } from '@/workflow/hooks/useAvailableVariablesInWorkflowStep';
|
||||
|
||||
const StyledDropdownVariableButtonContainer = styled(
|
||||
StyledDropdownButtonContainer,
|
||||
@ -34,8 +34,11 @@ const SearchVariablesDropdown = ({
|
||||
|
||||
const dropdownId = `${SEARCH_VARIABLES_DROPDOWN_ID}-${inputId}`;
|
||||
const { isDropdownOpen } = useDropdown(dropdownId);
|
||||
const availableVariablesInWorkflowStep =
|
||||
useAvailableVariablesInWorkflowStep();
|
||||
|
||||
const [selectedStep, setSelectedStep] = useState<
|
||||
WorkflowStepMock | undefined
|
||||
StepOutputSchema | undefined
|
||||
>(undefined);
|
||||
|
||||
const insertVariableTag = (variable: string) => {
|
||||
@ -44,7 +47,7 @@ const SearchVariablesDropdown = ({
|
||||
|
||||
const handleStepSelect = (stepId: string) => {
|
||||
setSelectedStep(
|
||||
AVAILABLE_VARIABLES_MOCK.find((step) => step.id === stepId),
|
||||
availableVariablesInWorkflowStep.find((step) => step.id === stepId),
|
||||
);
|
||||
};
|
||||
|
||||
@ -78,7 +81,7 @@ const SearchVariablesDropdown = ({
|
||||
/>
|
||||
) : (
|
||||
<SearchVariablesDropdownStepItem
|
||||
steps={AVAILABLE_VARIABLES_MOCK}
|
||||
steps={availableVariablesInWorkflowStep}
|
||||
onSelect={handleStepSelect}
|
||||
/>
|
||||
)}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { MenuItemSelect } from '@/ui/navigation/menu-item/components/MenuItemSelect';
|
||||
import { WorkflowStepMock } from '@/workflow/search-variables/types/WorkflowStepMock';
|
||||
import { StepOutputSchema } from '@/workflow/search-variables/types/StepOutputSchema';
|
||||
|
||||
type SearchVariablesDropdownStepItemProps = {
|
||||
steps: WorkflowStepMock[];
|
||||
steps: StepOutputSchema[];
|
||||
onSelect: (value: string) => void;
|
||||
};
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader';
|
||||
import { MenuItemSelect } from '@/ui/navigation/menu-item/components/MenuItemSelect';
|
||||
import { WorkflowStepMock } from '@/workflow/search-variables/types/WorkflowStepMock';
|
||||
import { StepOutputSchema } from '@/workflow/search-variables/types/StepOutputSchema';
|
||||
import { isObject } from '@sniptt/guards';
|
||||
import { useState } from 'react';
|
||||
import { IconChevronLeft } from 'twenty-ui';
|
||||
|
||||
type SearchVariablesDropdownStepSubItemProps = {
|
||||
step: WorkflowStepMock;
|
||||
step: StepOutputSchema;
|
||||
onSelect: (value: string) => void;
|
||||
onBack: () => void;
|
||||
};
|
||||
@ -19,7 +19,7 @@ const SearchVariablesDropdownStepSubItem = ({
|
||||
const [currentPath, setCurrentPath] = useState<string[]>([]);
|
||||
|
||||
const getSelectedObject = () => {
|
||||
let selected = step.output;
|
||||
let selected = step.outputSchema;
|
||||
for (const key of currentPath) {
|
||||
selected = selected[key];
|
||||
}
|
||||
@ -28,6 +28,7 @@ const SearchVariablesDropdownStepSubItem = ({
|
||||
|
||||
const handleSelect = (key: string) => {
|
||||
const selectedObject = getSelectedObject();
|
||||
|
||||
if (isObject(selectedObject[key])) {
|
||||
setCurrentPath([...currentPath, key]);
|
||||
} else {
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
import { WorkflowStepMock } from '@/workflow/search-variables/types/WorkflowStepMock';
|
||||
|
||||
export const AVAILABLE_VARIABLES_MOCK: WorkflowStepMock[] = [
|
||||
{
|
||||
id: '1',
|
||||
name: 'Person is Created',
|
||||
output: {
|
||||
userId: '1',
|
||||
recordId: '123',
|
||||
objectMetadataItem: {
|
||||
id: '1234',
|
||||
nameSingular: 'person',
|
||||
namePlural: 'people',
|
||||
},
|
||||
properties: {
|
||||
after: {
|
||||
name: 'John Doe',
|
||||
email: 'john.doe@email.com',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
name: 'Send Email',
|
||||
output: {
|
||||
success: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
@ -0,0 +1,5 @@
|
||||
export type StepOutputSchema = {
|
||||
id: string;
|
||||
name: string;
|
||||
outputSchema: Record<string, any>;
|
||||
};
|
||||
@ -1,5 +0,0 @@
|
||||
export type WorkflowStepMock = {
|
||||
id: string;
|
||||
name: string;
|
||||
output: Record<string, any>;
|
||||
};
|
||||
@ -1,4 +1,6 @@
|
||||
type BaseWorkflowStepSettings = {
|
||||
input: object;
|
||||
outputSchema: object;
|
||||
errorHandlingOptions: {
|
||||
retryOnFailure: {
|
||||
value: boolean;
|
||||
@ -12,6 +14,7 @@ type BaseWorkflowStepSettings = {
|
||||
export type WorkflowCodeStepSettings = BaseWorkflowStepSettings & {
|
||||
input: {
|
||||
serverlessFunctionId: string;
|
||||
serverlessFunctionVersion: string;
|
||||
};
|
||||
};
|
||||
|
||||
@ -57,6 +60,8 @@ export type WorkflowDatabaseEventTrigger = BaseTrigger & {
|
||||
type: 'DATABASE_EVENT';
|
||||
settings: {
|
||||
eventName: string;
|
||||
input?: object;
|
||||
outputSchema: object;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ describe('addCreateStepNodes', () => {
|
||||
type: 'DATABASE_EVENT',
|
||||
settings: {
|
||||
eventName: 'company.created',
|
||||
outputSchema: {},
|
||||
},
|
||||
};
|
||||
const steps: WorkflowStep[] = [
|
||||
@ -23,7 +24,9 @@ describe('addCreateStepNodes', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -38,7 +41,9 @@ describe('addCreateStepNodes', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@ -7,6 +7,7 @@ describe('generateWorkflowDiagram', () => {
|
||||
type: 'DATABASE_EVENT',
|
||||
settings: {
|
||||
eventName: 'company.created',
|
||||
outputSchema: {},
|
||||
},
|
||||
};
|
||||
const steps: WorkflowStep[] = [];
|
||||
@ -29,6 +30,7 @@ describe('generateWorkflowDiagram', () => {
|
||||
type: 'DATABASE_EVENT',
|
||||
settings: {
|
||||
eventName: 'company.created',
|
||||
outputSchema: {},
|
||||
},
|
||||
};
|
||||
const steps: WorkflowStep[] = [
|
||||
@ -44,7 +46,9 @@ describe('generateWorkflowDiagram', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -59,7 +63,9 @@ describe('generateWorkflowDiagram', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
},
|
||||
];
|
||||
@ -87,6 +93,7 @@ describe('generateWorkflowDiagram', () => {
|
||||
type: 'DATABASE_EVENT',
|
||||
settings: {
|
||||
eventName: 'company.created',
|
||||
outputSchema: {},
|
||||
},
|
||||
};
|
||||
const steps: WorkflowStep[] = [
|
||||
@ -102,7 +109,9 @@ describe('generateWorkflowDiagram', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -117,7 +126,9 @@ describe('generateWorkflowDiagram', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@ -42,7 +42,7 @@ describe('getWorkflowVersionDiagram', () => {
|
||||
name: '',
|
||||
steps: null,
|
||||
trigger: {
|
||||
settings: { eventName: 'company.created' },
|
||||
settings: { eventName: 'company.created', outputSchema: {} },
|
||||
type: 'DATABASE_EVENT',
|
||||
},
|
||||
updatedAt: '',
|
||||
@ -83,14 +83,16 @@ describe('getWorkflowVersionDiagram', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
},
|
||||
],
|
||||
trigger: {
|
||||
settings: { eventName: 'company.created' },
|
||||
settings: { eventName: 'company.created', outputSchema: {} },
|
||||
type: 'DATABASE_EVENT',
|
||||
},
|
||||
updatedAt: '',
|
||||
|
||||
@ -11,7 +11,7 @@ describe('insertStep', () => {
|
||||
name: '',
|
||||
steps: [],
|
||||
trigger: {
|
||||
settings: { eventName: 'company.created' },
|
||||
settings: { eventName: 'company.created', outputSchema: {} },
|
||||
type: 'DATABASE_EVENT',
|
||||
},
|
||||
updatedAt: '',
|
||||
@ -27,7 +27,9 @@ describe('insertStep', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
@ -51,7 +53,7 @@ describe('insertStep', () => {
|
||||
name: '',
|
||||
steps: [],
|
||||
trigger: {
|
||||
settings: { eventName: 'company.created' },
|
||||
settings: { eventName: 'company.created', outputSchema: {} },
|
||||
type: 'DATABASE_EVENT',
|
||||
},
|
||||
updatedAt: '',
|
||||
@ -67,7 +69,9 @@ describe('insertStep', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
@ -101,7 +105,9 @@ describe('insertStep', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
@ -116,14 +122,16 @@ describe('insertStep', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
},
|
||||
],
|
||||
trigger: {
|
||||
settings: { eventName: 'company.created' },
|
||||
settings: { eventName: 'company.created', outputSchema: {} },
|
||||
type: 'DATABASE_EVENT',
|
||||
},
|
||||
updatedAt: '',
|
||||
@ -139,7 +147,9 @@ describe('insertStep', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
@ -177,7 +187,9 @@ describe('insertStep', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
@ -192,14 +204,16 @@ describe('insertStep', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
},
|
||||
],
|
||||
trigger: {
|
||||
settings: { eventName: 'company.created' },
|
||||
settings: { eventName: 'company.created', outputSchema: {} },
|
||||
type: 'DATABASE_EVENT',
|
||||
},
|
||||
updatedAt: '',
|
||||
@ -215,7 +229,9 @@ describe('insertStep', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
|
||||
@ -12,7 +12,9 @@ it('returns a deep copy of the provided steps array instead of mutating it', ()
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'first',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
@ -25,7 +27,7 @@ it('returns a deep copy of the provided steps array instead of mutating it', ()
|
||||
name: '',
|
||||
steps: [stepToBeRemoved],
|
||||
trigger: {
|
||||
settings: { eventName: 'company.created' },
|
||||
settings: { eventName: 'company.created', outputSchema: {} },
|
||||
type: 'DATABASE_EVENT',
|
||||
},
|
||||
updatedAt: '',
|
||||
@ -51,7 +53,9 @@ it('removes a step in a non-empty steps array', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
@ -73,7 +77,9 @@ it('removes a step in a non-empty steps array', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
@ -89,14 +95,16 @@ it('removes a step in a non-empty steps array', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
},
|
||||
],
|
||||
trigger: {
|
||||
settings: { eventName: 'company.created' },
|
||||
settings: { eventName: 'company.created', outputSchema: {} },
|
||||
type: 'DATABASE_EVENT',
|
||||
},
|
||||
updatedAt: '',
|
||||
|
||||
@ -13,7 +13,9 @@ describe('replaceStep', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'first',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
@ -26,7 +28,7 @@ describe('replaceStep', () => {
|
||||
name: '',
|
||||
steps: [stepToBeReplaced],
|
||||
trigger: {
|
||||
settings: { eventName: 'company.created' },
|
||||
settings: { eventName: 'company.created', outputSchema: {} },
|
||||
type: 'DATABASE_EVENT',
|
||||
},
|
||||
updatedAt: '',
|
||||
@ -43,7 +45,9 @@ describe('replaceStep', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'second',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
},
|
||||
stepId: stepToBeReplaced.id,
|
||||
@ -63,7 +67,9 @@ describe('replaceStep', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
@ -85,7 +91,9 @@ describe('replaceStep', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
@ -101,14 +109,19 @@ describe('replaceStep', () => {
|
||||
},
|
||||
input: {
|
||||
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
|
||||
serverlessFunctionVersion: '1',
|
||||
},
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'CODE',
|
||||
valid: true,
|
||||
},
|
||||
],
|
||||
trigger: {
|
||||
settings: { eventName: 'company.created' },
|
||||
settings: {
|
||||
eventName: 'company.created',
|
||||
outputSchema: {},
|
||||
},
|
||||
type: 'DATABASE_EVENT',
|
||||
},
|
||||
updatedAt: '',
|
||||
|
||||
@ -17,7 +17,9 @@ export const getStepDefaultDefinition = (
|
||||
settings: {
|
||||
input: {
|
||||
serverlessFunctionId: '',
|
||||
serverlessFunctionVersion: '',
|
||||
},
|
||||
outputSchema: {},
|
||||
errorHandlingOptions: {
|
||||
continueOnFailure: {
|
||||
value: false,
|
||||
@ -42,6 +44,7 @@ export const getStepDefaultDefinition = (
|
||||
subject: '',
|
||||
body: '',
|
||||
},
|
||||
outputSchema: {},
|
||||
errorHandlingOptions: {
|
||||
continueOnFailure: {
|
||||
value: false,
|
||||
|
||||
@ -26,6 +26,7 @@ export const getTriggerDefaultDefinition = ({
|
||||
type,
|
||||
settings: {
|
||||
eventName: `${activeObjectMetadataItems[0].nameSingular}.${OBJECT_EVENT_TRIGGERS[0].value}`,
|
||||
outputSchema: {},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user