gate.ts
This file
Path
packages/gate/src/gate.ts
56 lines · 1.5 KiB · TypeScript
Last changed by
Merge observability into mainoscabrielbefore adoption1985111
History of this fileTake it
The walk stopped after 200 commits: lines older than 678c8b8 point at it.
Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 1why, one step back1/**Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503
lines 2–3why, one step back2 * Stops after the first stage that refuses, so a push never pays for a stage3 * past its cheapest problem.Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
line 4why, one step back4 */Merge observability into mainoscabrielbefore adoption1985111
line 5why, one step back5import type { StageName } from "@repo/protocol/domain/outcome";Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 6–13why, one step back6import type { Refusal } from "@repo/protocol/refusal";7import { Array, Effect, Option } from "effect";89import type { PushFacts } from "./facts.ts";10import type { Stage } from "./stage.ts";11import { parse } from "./stages/parse.ts";12import { scan } from "./stages/shape.ts";13Merge observability into mainoscabrielbefore adoption1985111
lines 14–20why, one step back14/** What the first stage that refused a push refused it for. */15export interface StageRefusal {16 readonly refusals: Array.NonEmptyReadonlyArray<Refusal>;17 readonly stage: StageName;18}1920export const refusingStage = <R>(Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 21–22why, one step back21 stages: readonly Stage<R>[],22 facts: PushFactsMerge observability into mainoscabrielbefore adoption1985111
line 23why, one step back23): Effect.Effect<Option.Option<StageRefusal>, never, R> =>Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 24–25why, one step back24 Effect.gen(function* () {25 for (const stage of stages) {Merge observability into mainoscabrielbefore adoption1985111
lines 26–28why, one step back26 const refusals = yield* stage27 .run(facts)28 .pipe(Effect.withSpan(`Gate.${stage.name}`));Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 29–30why, one step back2930 if (Array.isReadonlyArrayNonEmpty(refusals)) {Merge observability into mainoscabrielbefore adoption1985111
lines 31–36why, one step back31 return Option.some({32 refusals: stage.accumulate33 ? refusals34 : Array.of(Array.headNonEmpty(refusals)),35 stage: stage.name,36 });Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 37–41why, one step back37 }38 }3940 return Option.none();41 });Merge observability into mainoscabrielbefore adoption1985111
lines 42–54why, one step back4243export const runGate = <R>(44 stages: readonly Stage<R>[],45 facts: PushFacts46): Effect.Effect<47 Option.Option<Array.NonEmptyReadonlyArray<Refusal>>,48 never,49 R50> =>51 Effect.map(52 refusingStage(stages, facts),53 Option.map(({ refusals }) => refusals)54 );Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 55–56why, one step back5556export const pushStages: readonly Stage<never>[] = [parse, scan];