draft-steps.ts
This file
Path
apps/platform/src/workflows/draft-steps.ts
33 lines · 1.1 KiB · TypeScript
Last changed by
Merge build/comments-platform into mainoscabrielbefore adoptionddf09e8
History of this fileTake it
Merge branch 'build/910-draft-workflow'oscabrielbefore adoptiona0c8f4f
lines 1–33why, one step back1import type { RepoHost } from "@repo/artifacts/repo-host";2import type { Drafter } from "@repo/drafting/drafter";3import { runDraft } from "@repo/drafting/run";4import type { Projects } from "@repo/project/projects";5import type { WorkflowTimeoutDuration } from "cloudflare:workers";6import type { Effect, Schema } from "effect";78import type { DraftParams } from "../answer-runs.ts";9import { StepRunner } from "./step.ts";10import type { WorkflowStepRetries, WorkflowSteps } from "./step.ts";1112export const DRAFT_STEP_TIMEOUT = "10 minutes";1314export interface EngineSteps {15 readonly do: (16 name: string,17 config: {18 readonly retries?: WorkflowStepRetries;19 readonly timeout?: WorkflowTimeoutDuration;20 },21 body: () => Promise<Schema.Json>22 ) => Promise<Schema.Json>;23}2425export const timedSteps = (engine: EngineSteps): WorkflowSteps => ({26 do: (name, config, body) =>27 engine.do(name, { ...config, timeout: DRAFT_STEP_TIMEOUT }, body),28});2930export const draftSteps = (31 params: DraftParams32): Effect.Effect<void, never, StepRunner | Projects | Drafter | RepoHost> =>33 StepRunner.use((runner) => runDraft(params, { step: runner.step }));