Files
core/website/src/content/docs/concepts/flow.md
T
chrnx 654c0563fc
CI / build (pull_request) Has been cancelled
docs: honest README + quickstart, and a Starlight documentation site
Bring the README in line with what shipped and fill the gaps a technical
reader comparing frameworks needs: the busboy peer dep and dual build, a
Routing section with its limits, an explicit "bring your own auth" scope
note, why legacy decorators is a design choice (not laziness), and CalVer
beta versioning.

Add a full Astro Starlight docs site under website/ — getting started,
concepts, per-feature guides, and an API reference — migrated from the
tested quickstart so the examples stay accurate.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-07 12:02:17 -05:00

1.4 KiB

title, description
title description
The typed flow core The functional flow API where the compile-time dependency guarantee lives.

The decorator layer validates the graph at boot. The functional core, flow, validates it in the type checker — before the program ever runs.

import { flow } from '@green-tea/core';

const pipeline = flow()
  .step('db', () => ({ find: (id: string) => id }))
  .step('user', (ctx) => ctx.db.find('u1')); // referencing a missing 'db' would not compile

Each .step(name, fn) adds its output to the accumulated context type (Acc & Out). The next step's ctx is typed with everything produced so far — so reading ctx.db compiles only because a previous step provided db. Reference a key nothing produced and it is a compile error, not a runtime undefined.

This is the strongest guarantee green-tea offers: the type is the dependency contract, checked statically. The decorator layer gives you the same graph with boot-time validation and the ergonomics of classes and decorators; flow gives you compile-time proof.

:::note npm run typecheck in the repo includes a type-level test that asserts this accumulation behaves — a step that reads a missing key is expected to fail compilation. :::

See The dependency graph for how both layers describe the same model.