2023-10-26 05:35:38 -07:00
|
|
|
import config from '@/config';
|
|
|
|
import type { IWorkflowSettings } from 'n8n-workflow';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return whether a workflow execution is configured to be saved or not,
|
|
|
|
* for error executions, success executions, and manual executions.
|
|
|
|
*/
|
|
|
|
export function toSaveSettings(workflowSettings: IWorkflowSettings = {}) {
|
2023-11-07 07:26:55 -08:00
|
|
|
const DEFAULTS = {
|
|
|
|
ERROR: config.getEnv('executions.saveDataOnError'),
|
|
|
|
SUCCESS: config.getEnv('executions.saveDataOnSuccess'),
|
|
|
|
MANUAL: config.getEnv('executions.saveDataManualExecutions'),
|
|
|
|
};
|
|
|
|
|
2023-10-26 05:35:38 -07:00
|
|
|
return {
|
2023-11-07 07:26:55 -08:00
|
|
|
error: workflowSettings.saveDataErrorExecution
|
|
|
|
? workflowSettings.saveDataErrorExecution !== 'none'
|
|
|
|
: DEFAULTS.ERROR !== 'none',
|
|
|
|
success: workflowSettings.saveDataSuccessExecution
|
|
|
|
? workflowSettings.saveDataSuccessExecution !== 'none'
|
|
|
|
: DEFAULTS.SUCCESS !== 'none',
|
2023-10-26 05:35:38 -07:00
|
|
|
manual: workflowSettings?.saveManualExecutions ?? DEFAULTS.MANUAL,
|
|
|
|
};
|
|
|
|
}
|