| 189 | |
| 190 | /** @internal */ |
| 191 | export const scheduleFromStep = <Provides, In, PlanE, PlanR>( |
| 192 | step: Api.ExecutionPlan<{ |
| 193 | provides: Provides |
| 194 | input: In |
| 195 | error: PlanE |
| 196 | requirements: PlanR |
| 197 | }>["steps"][number], |
| 198 | first: boolean |
| 199 | ) => { |
| 200 | if (!first) { |
| 201 | return internalSchedule.buildFromOptions({ |
| 202 | schedule: step.schedule ? step.schedule : step.attempts ? undefined : scheduleOnce, |
| 203 | times: step.attempts, |
| 204 | while: step.while |
| 205 | }) |
| 206 | } else if (step.attempts === 1 || !(step.schedule || step.attempts)) { |
| 207 | return undefined |
| 208 | } |
| 209 | return internalSchedule.buildFromOptions({ |
| 210 | schedule: step.schedule, |
| 211 | while: step.while, |
| 212 | times: step.attempts ? step.attempts - 1 : undefined |
| 213 | }) |
| 214 | } |
| 215 | |
| 216 | const scheduleOnce = Schedule.recurs(1) |