Afora 0.0.7
I launched Afora: domain modeling for TypeScript on TypeBox, with entities that keep their invariants, masked sensitive data and the whole application describable in JSON.

I launched Afora: domain modeling for TypeScript, built on TypeBox. Model the domain. Keep the invariants.
Afora is not a general-purpose validator. It is for code that models a domain, and it plugs into the validators your framework already accepts.
Records with invariants
Properties like Email, Slug, Password (or your own) validate and normalize every value; blueprints compose them; and a record (class User extends recordOf(...)) holds the handled value and rejects undeclared keys at any depth. With change: ["password"] you get a typed user.change.password(value) that re-validates before changing.
Sensitive data masking
A property declared sensitive is masked by toJSON() at any depth, so JSON.stringify(user) cannot leak the password. Password only accepts an argon2id hash, made with Bun.password on Bun or native argon2 on Node.
Entities, repositories and use cases
entityOfadds identity, timestamps and domain events;repositoryOfgenerates only the actions you choose, with typedfindBy<Key>for unique keys only, cursor pagination and soft deletion;- the provider is in memory by default, or Drizzle ORM (SQLite and Postgres) with
@afora/drizzle; - use cases inject repositories and environments, and there are ready-made use cases (
create,get,list,update,publish,login...) that follow the repository and its entity.
Exceptions that know their layer
Each error carries the layer it was raised in (Property, Record, UseCase, Output...) and a trace that grows as it goes up.
From the domain outwards
Every field is Standard Schema V1, so it works as is in Hono, tRPC and TanStack Form. Commands group use cases behind one execution boundary (context, transactions, events), and outputs turn them into an HTTP API with @afora/hono, an OpenAPI 3.1 document or MCP tools, with problem+json errors and masked responses.
The whole application in JSON
An afora.json describes the application, use cases included, and @afora/codegen generates the code; extractSpec(app) goes the other way. @afora/mcp lets an AI agent discover the catalog, write and validate the spec, generate the code and check the result.
How it's built
TypeScript, running on Bun (>= 1.4.4) and Node (>= 22), and loading in browsers and Workers too. Published on npm with provenance, under the MIT license. Besides the tests, the project snapshots its public API, checks type compatibility from TypeScript 5.5 to 7 and budgets the type cost of each edit in the editor.
bun add @afora/core typebox
Website · Docs · Code on GitHub · npm