31 lines
882 B
TypeScript
31 lines
882 B
TypeScript
/**
|
|
* Delay Step — wait N milliseconds before continuing.
|
|
* Config: {
|
|
* duration_ms: number | string // can be a number or a template like "{{settings.autotask_update_delay_ms}}"
|
|
* }
|
|
*/
|
|
|
|
import { registerWorkflowStepExecutor } from '../ticket-workflow-engine';
|
|
import { TicketWorkflowStep, WorkflowStepContext, WorkflowStepResult } from '../../types/ticket-workflow';
|
|
|
|
async function executeDelay(
|
|
step: TicketWorkflowStep,
|
|
_context: WorkflowStepContext,
|
|
_executionId: number
|
|
): Promise<WorkflowStepResult> {
|
|
const durationMs = Number(step.config.duration_ms) || 0;
|
|
|
|
if (durationMs > 0) {
|
|
console.log(`[WORKFLOW:delay] Waiting ${durationMs}ms`);
|
|
await new Promise(resolve => setTimeout(resolve, durationMs));
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
delayed_ms: durationMs
|
|
}
|
|
};
|
|
}
|
|
|
|
registerWorkflowStepExecutor('delay', executeDelay);
|