2023-10-26 05:35:38 -07:00
|
|
|
import type { IWorkflowSettings } from 'n8n-workflow';
|
|
|
|
|
2024-09-12 09:07:18 -07:00
|
|
|
import config from '@/config';
|
|
|
|
|
2023-10-26 05:35:38 -07:00
|
|
|
/**
|
2023-11-21 08:33:44 -08:00
|
|
|
* Return whether a workflow execution is configured to be saved or not:
|
|
|
|
*
|
|
|
|
* - `error`: Whether to save failed executions in production.
|
|
|
|
* - `success`: Whether to successful executions in production.
|
|
|
|
* - `manual`: Whether to save successful or failed manual executions.
|
|
|
|
* - `progress`: Whether to save execution progress, i.e. after each node's execution.
|
2023-10-26 05:35:38 -07:00
|
|
|
*/
|
|
|
|
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-11-21 08:33:44 -08:00
|
|
|
PROGRESS: config.getEnv('executions.saveExecutionProgress'),
|
2023-11-07 07:26:55 -08:00
|
|
|
};
|
|
|
|
|
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-11-21 08:33:44 -08:00
|
|
|
manual:
|
|
|
|
workflowSettings === undefined || workflowSettings.saveManualExecutions === 'DEFAULT'
|
|
|
|
? DEFAULTS.MANUAL
|
2024-09-17 05:10:22 -07:00
|
|
|
: (workflowSettings.saveManualExecutions ?? DEFAULTS.MANUAL),
|
2023-11-21 08:33:44 -08:00
|
|
|
progress:
|
|
|
|
workflowSettings === undefined || workflowSettings.saveExecutionProgress === 'DEFAULT'
|
|
|
|
? DEFAULTS.PROGRESS
|
2024-09-17 05:10:22 -07:00
|
|
|
: (workflowSettings.saveExecutionProgress ?? DEFAULTS.PROGRESS),
|
2023-10-26 05:35:38 -07:00
|
|
|
};
|
|
|
|
}
|