diff --git a/packages/cli/src/util/validate-plan.ts b/packages/cli/src/util/validate-plan.ts index 9e134101b..87f6d2c49 100644 --- a/packages/cli/src/util/validate-plan.ts +++ b/packages/cli/src/util/validate-plan.ts @@ -1,50 +1,65 @@ -import { ExecutionPlan, Step, WorkflowOptions } from "@openfn/lexicon"; -import { Logger } from "@openfn/logger"; +import { ExecutionPlan, Step, WorkflowOptions } from '@openfn/lexicon'; +import { Logger } from '@openfn/logger'; const assertWorkflowStructure = (plan: ExecutionPlan, logger: Logger) => { - const { workflow, options } = plan; + const { workflow, options } = plan; - if (!workflow || typeof workflow !== 'object') { - throw new Error(`Missing or invalid "workflow" key in execution plan`); - } + if (!workflow || typeof workflow !== 'object') { + throw new Error(`Missing or invalid "workflow" key in execution plan`); + } - if (!Array.isArray(workflow.steps)) { - throw new Error('The workflow.steps key must be an array'); - } + if (!Array.isArray(workflow.steps)) { + throw new Error('The workflow.steps key must be an array'); + } - if (workflow.steps.length === 0) { - logger.warn('The workflow.steps array is empty'); - } + if (workflow.steps.length === 0) { + logger.warn('The workflow.steps array is empty'); + } - workflow.steps.forEach((step, index) => { - assertStepStructure(step, index); - }); + workflow.steps.forEach((step, index) => { + assertStepStructure(step, index); + }); - assertOptionsStructure(options, logger); + assertOptionsStructure(options, logger); }; const assertStepStructure = (step: Step, index: number) => { - const allowedKeys = ['id', 'name', 'next', 'previous', 'adaptor', 'expression', 'state', 'configuration', 'linker']; + const allowedKeys = [ + 'id', + 'name', + 'next', + 'previous', + 'adaptor', + 'expression', + 'state', + 'configuration', + 'linker', + ]; - for (const key in step) { - if (!allowedKeys.includes(key)) { - throw new Error(`Invalid key "${key}" in step ${step.id || index}`); - } + for (const key in step) { + if (!allowedKeys.includes(key)) { + throw new Error(`Invalid key "${key}" in step ${step.id || index}`); } + } - if ('adaptor' in step && !('expression' in step)) { - throw new Error(`Step ${step.id ?? index} with an adaptor must also have an expression`); - } + if ('adaptor' in step && !('expression' in step)) { + throw new Error( + `Step ${step.id ?? index} with an adaptor must also have an expression` + ); + } }; -const assertOptionsStructure = (options: WorkflowOptions = {}, logger: Logger) => { - const allowedKeys = ['timeout', 'stepTimeout', 'start', 'end', 'sanitize']; +const assertOptionsStructure = ( + options: WorkflowOptions = {}, + logger: Logger +) => { + const allowedKeys = ['timeout', 'stepTimeout', 'start', 'end', 'sanitize']; - for (const key in options) { - if (!allowedKeys.includes(key)) { - logger.warn(`Unrecognized option "${key}" in options object`); - } + for (const key in options) { + if (!allowedKeys.includes(key)) { + logger.warn(`Unrecognized option "${key}" in options object`); } + } }; -export default assertWorkflowStructure; \ No newline at end of file +export default assertWorkflowStructure; diff --git a/packages/runtime/src/execute/plan.ts b/packages/runtime/src/execute/plan.ts index f5da4e94a..d87940714 100644 --- a/packages/runtime/src/execute/plan.ts +++ b/packages/runtime/src/execute/plan.ts @@ -91,4 +91,4 @@ const executePlan = async ( return Object.values(leaves)[0]; }; -export default executePlan; \ No newline at end of file +export default executePlan; diff --git a/packages/runtime/src/util/validate-plan.ts b/packages/runtime/src/util/validate-plan.ts index 25a32acb9..737424d7b 100644 --- a/packages/runtime/src/util/validate-plan.ts +++ b/packages/runtime/src/util/validate-plan.ts @@ -116,4 +116,4 @@ const assertSingletonDependencies = (model: Model) => { throw new ValidationError(`Multiple dependencies detected for: ${id}`); } } -}; \ No newline at end of file +};