npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@shirudo/ddd-kit

v2.0.0

Published

Composable TypeScript toolkit for tactical DDD

Downloads

1,695

Readme

@shirudo/ddd-kit

Composable TypeScript toolkit for tactical Domain-Driven Design. Ships the canonical building blocks (Value Objects, Entities, Aggregate Roots, Domain Events, Repositories, and CQRS handlers) without a framework or runtime lock-in. ESM-only; runs on Node 18+, Cloudflare Workers, Vercel Edge, Deno, and Bun.

Stable: 1.0

The public API is stable and follows Semantic Versioning. Breaking changes bump the major and ship with a migration path in the CHANGELOG.

npm version license

Features

  • Value Objects: deep-frozen, by-attribute equality (vo, ValueObject, voEquals).
  • Entities: identity + lifecycle, with collection helpers branded by Id<Tag>.
  • Aggregate Roots: state-stored (AggregateRoot) and event-sourced (EventSourcedAggregate), with optimistic-concurrency versioning.
  • Domain Events: typed, deeply frozen, carry metadata for traceability and schema evolution.
  • Repositories: technology-agnostic persistence ports with an Identity-Map contract and OCC.
  • CQRS: zero-config in-memory CommandBus / QueryBus, plus CommandHandler / QueryHandler types for external brokers.
  • Unit of Work: opt-in UnitOfWork facade with tx-bound repositories, repository-side enrollment, a per-operation Identity Map, and aggregate-level dirty tracking (changedKeys / hasChanges) for partial writes. Honestly speaking: a transaction coordinator with registration and Identity Map; writes stay explicit by design (no auto-flush).
  • Outbox: withCommit harvests pending events inside the transaction, stamps them with the aggregate's commit version, and publishes them atomically.
  • Repository contract tests: @shirudo/ddd-kit/testing ships the suite every adapter must pass: OCC is a testable contract, not a documented pattern.
  • Result-first boundary: a typed error hierarchy on @shirudo/base-error and Result from @shirudo/result; voValidated collects field violations and renders RFC 9457 via the opt-in @shirudo/ddd-kit/http entry.

Installation

pnpm add @shirudo/ddd-kit @shirudo/result @shirudo/base-error

@shirudo/result and @shirudo/base-error are peer dependencies; install them once in the consuming app.

Quick start

import { vo, type VO } from "@shirudo/ddd-kit";

type EmailAddress = VO<{ value: string }>;

function createEmail(value: string): EmailAddress {
  if (!value.includes("@")) throw new Error("Invalid email address");
  return vo({ value }); // deeply frozen, immutable
}

const email = createEmail("[email protected]");

For a complete walkthrough (a minimal Order aggregate with typed events, commit(), and the App-Service boundary), see Getting Started.

Core concepts

Each building block has a dedicated guide. Start with Design Decisions for the non-obvious calls (Result at the App boundary, no Specification pattern, the TransactionScope/Unit-of-Work layering, class-based aggregates).

| Concept | Guide | |---|---| | Value Objects (vo, ValueObject, voWithValidation, voValidated) | Value Objects | | Entities and identity | Entities | | Aggregate Roots, factories, reconstitution | Aggregate Roots | | Event sourcing (apply, replay, snapshots) | Event Sourcing | | Domain Events (createDomainEvent, metadata) | Domain Events | | Errors: throw vs Result, ValidationError, RFC 9457 | Result vs Throw | | Commands, queries, buses | CQRS & Buses | | Repositories, Identity Map, OCC | Repository | | Unit of Work, enrollment, contract test suite | Unit of Work | | Outbox, withCommit, transactions | Outbox & Transactions | | Read-side projections | Projections | | Concurrency & operation-scoped aggregates | Concurrency | | Edge runtimes (Workers, Deno, Bun) | Edge Runtimes |

Documentation

  • LLM.md: hand-curated, high-signal guide for LLM coding tools and a fast human skim of the whole surface.
  • Common Mistakes: the footgun catalogue; read it before writing consumer code.
  • API reference: full type definitions ship with the package (node_modules/@shirudo/ddd-kit/dist/index.d.ts); the @shirudo/ddd-kit/http subpath exports the RFC 9457 presenter.
  • CHANGELOG: release history with a migration path for every breaking change.

TypeScript support

Requires TypeScript 5.9+. The kit leans on branded, conditional, and mapped types for a type-safe DDD experience; all APIs are fully typed.

Contributing

Contributions are welcome. For bugs and feature requests, use the issue tracker; open a pull request against main.

License

MIT.

Author

Shirudo: @shi-rudo · npm · repo