ShapeWire
ShapeWire — Type-safe pipelines for turning API responses into UI-ready data.
ShapeWire is a small, framework-agnostic transformation layer between an API response and the code that renders it. It turns repeated mapping logic into declarative, reusable transforms.
import {defaults, normalize, pipe, rename} from 'shapewire';
const toUser = pipe(
rename({user_id: 'id', full_name: 'name', created_at: 'createdAt'}),
defaults({role: 'viewer', verified: false}),
normalize({createdAt: 'isoDate', balance: 'number'}),
);
const user = toUser(apiResponse);
What it handles
- Field renaming without mutating the input.
- Nullish defaults that preserve valid falsy values.
- Date, number, boolean, and currency normalization.
- Shallow merging from another source.
- Applying the same transform to every item in a list.
- TypeScript inference across composed transforms.
Design boundaries
Transforms are shallow and synchronous. They return new objects and do not validate business rules or fetch data. pipe uses variadic tuple inference so longer pipelines retain their output types and validate every adjacent stage. See Scope and non-goals for the boundary between transport normalization and validation, business logic, or presentation formatting.
Continue with Installation, review Failure behavior, or explore complete Real-world patterns.