Add record picker with variables (#8813)
- Add update actions - Create a folder for workflow actions - Add a SingleRecordPicker with variables handler https://github.com/user-attachments/assets/9fd57ce1-1b8d-424a-8aa1-69468d684fa1
This commit is contained in:
@ -92,6 +92,37 @@ it('returns a valid definition for RECORD_CRUD.CREATE actions', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('returns a valid definition for RECORD_CRUD.UPDATE actions', () => {
|
||||
expect(
|
||||
getStepDefaultDefinition({
|
||||
type: 'RECORD_CRUD.UPDATE',
|
||||
activeObjectMetadataItems: generatedMockObjectMetadataItems,
|
||||
}),
|
||||
).toStrictEqual({
|
||||
id: expect.any(String),
|
||||
name: 'Update Record',
|
||||
type: 'RECORD_CRUD',
|
||||
valid: false,
|
||||
settings: {
|
||||
input: {
|
||||
type: 'UPDATE',
|
||||
objectName: generatedMockObjectMetadataItems[0].nameSingular,
|
||||
objectRecord: {},
|
||||
objectRecordId: '',
|
||||
},
|
||||
outputSchema: {},
|
||||
errorHandlingOptions: {
|
||||
continueOnFailure: {
|
||||
value: false,
|
||||
},
|
||||
retryOnFailure: {
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("throws for RECORD_CRUD.DELETE actions as it's not implemented yet", () => {
|
||||
expect(() => {
|
||||
getStepDefaultDefinition({
|
||||
@ -101,15 +132,6 @@ it("throws for RECORD_CRUD.DELETE actions as it's not implemented yet", () => {
|
||||
}).toThrow('Not implemented yet');
|
||||
});
|
||||
|
||||
it("throws for RECORD_CRUD.UPDATE actions as it's not implemented yet", () => {
|
||||
expect(() => {
|
||||
getStepDefaultDefinition({
|
||||
type: 'RECORD_CRUD.UPDATE',
|
||||
activeObjectMetadataItems: generatedMockObjectMetadataItems,
|
||||
});
|
||||
}).toThrow('Not implemented yet');
|
||||
});
|
||||
|
||||
it('throws when providing an unknown type', () => {
|
||||
expect(() => {
|
||||
getStepDefaultDefinition({
|
||||
|
||||
@ -3,6 +3,18 @@ import { WorkflowStep, WorkflowStepType } from '@/workflow/types/Workflow';
|
||||
import { assertUnreachable } from '@/workflow/utils/assertUnreachable';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
const BASE_DEFAULT_STEP_SETTINGS = {
|
||||
outputSchema: {},
|
||||
errorHandlingOptions: {
|
||||
continueOnFailure: {
|
||||
value: false,
|
||||
},
|
||||
retryOnFailure: {
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const getStepDefaultDefinition = ({
|
||||
type,
|
||||
activeObjectMetadataItems,
|
||||
@ -25,15 +37,7 @@ export const getStepDefaultDefinition = ({
|
||||
serverlessFunctionVersion: '',
|
||||
serverlessFunctionInput: {},
|
||||
},
|
||||
outputSchema: {},
|
||||
errorHandlingOptions: {
|
||||
continueOnFailure: {
|
||||
value: false,
|
||||
},
|
||||
retryOnFailure: {
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
...BASE_DEFAULT_STEP_SETTINGS,
|
||||
},
|
||||
};
|
||||
}
|
||||
@ -50,15 +54,7 @@ export const getStepDefaultDefinition = ({
|
||||
subject: '',
|
||||
body: '',
|
||||
},
|
||||
outputSchema: {},
|
||||
errorHandlingOptions: {
|
||||
continueOnFailure: {
|
||||
value: false,
|
||||
},
|
||||
retryOnFailure: {
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
...BASE_DEFAULT_STEP_SETTINGS,
|
||||
},
|
||||
};
|
||||
}
|
||||
@ -74,20 +70,27 @@ export const getStepDefaultDefinition = ({
|
||||
objectName: activeObjectMetadataItems[0].nameSingular,
|
||||
objectRecord: {},
|
||||
},
|
||||
outputSchema: {},
|
||||
errorHandlingOptions: {
|
||||
continueOnFailure: {
|
||||
value: false,
|
||||
},
|
||||
retryOnFailure: {
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
...BASE_DEFAULT_STEP_SETTINGS,
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'RECORD_CRUD.DELETE':
|
||||
case 'RECORD_CRUD.UPDATE': {
|
||||
case 'RECORD_CRUD.UPDATE':
|
||||
return {
|
||||
id: newStepId,
|
||||
name: 'Update Record',
|
||||
type: 'RECORD_CRUD',
|
||||
valid: false,
|
||||
settings: {
|
||||
input: {
|
||||
type: 'UPDATE',
|
||||
objectName: activeObjectMetadataItems[0].nameSingular,
|
||||
objectRecordId: '',
|
||||
objectRecord: {},
|
||||
},
|
||||
...BASE_DEFAULT_STEP_SETTINGS,
|
||||
},
|
||||
};
|
||||
case 'RECORD_CRUD.DELETE': {
|
||||
throw new Error('Not implemented yet');
|
||||
}
|
||||
default: {
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
import {
|
||||
WorkflowAction,
|
||||
WorkflowRecordUpdateAction,
|
||||
} from '@/workflow/types/Workflow';
|
||||
|
||||
export const isWorkflowRecordUpdateAction = (
|
||||
action: WorkflowAction,
|
||||
): action is WorkflowRecordUpdateAction => {
|
||||
return (
|
||||
action.type === 'RECORD_CRUD' && action.settings.input.type === 'UPDATE'
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user