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

@alchemy.run/domain

v2.0.0-beta.87

Published

Domain-driven backends for Alchemy: aggregates, commands, events, projections, sagas and stories over Effect.

Readme

@alchemy.run/domain

A domain-driven design framework for Effect, part of Alchemy. Model your business as commands, aggregates, events, views, and policies. Test it in memory, then run it on Cloudflare Durable Objects without changing the model.

npm install @alchemy.run/domain effect

Commands ask for a change, the aggregate decides it, and events record what happened:

// src/account.ts
import * as Domain from "@alchemy.run/domain";
import * as Schema from "effect/Schema";

export class MoneyDeposited extends Domain.Event("MoneyDeposited", {
  amount: Schema.Int,
  balanceAfter: Schema.Int,
}) {}

export class TooLarge extends Domain.Rejection("TooLarge", { max: Schema.Int }) {}

export class DepositMoney extends Domain.Command("DepositMoney", {
  target: Schema.String,
  input: { amount: Schema.Int },
  events: [MoneyDeposited],
  rejects: [TooLarge],
  reply: { balance: Schema.Int },
}) {}

export class Account extends Domain.Aggregate("Account", {
  id: Schema.String,
  state: Schema.Struct({ balance: Schema.Int }),
  initial: { balance: 0 },
  commands: [DepositMoney],
  decide: {
    DepositMoney: (s, cmd) =>
      cmd.amount > 10_000
        ? new TooLarge({ max: 10_000 })
        : [new MoneyDeposited({ amount: cmd.amount, balanceAfter: s.balance + cmd.amount })],
  },
  evolve: {
    MoneyDeposited: (s, e) => ({ balance: e.balanceAfter }),
  },
  reply: {
    DepositMoney: (s) => ({ balance: s.balance }),
  },
}) {}

export class Bank extends Domain.Model("Bank", { aggregates: [Account] }) {}

Behaviour is tested as a story: given these events, when this command, then these events:

// test/account.test.ts
import { Story } from "@alchemy.run/domain/Story";
import { it } from "@effect/vitest";
import { Account, Bank, DepositMoney, MoneyDeposited, TooLarge } from "../src/account.ts";

const story = Story.make(Bank, {});
const account = Account.ref("a-1");

it.effect("deposits and replies with the balance", () =>
  story(
    Story.given(account, new MoneyDeposited({ amount: 50, balanceAfter: 50 })),
    Story.when(account, new DepositMoney({ amount: 100 })),
    Story.then(account, new MoneyDeposited({ amount: 100, balanceAfter: 150 })),
    Story.replied({ balance: 150 }),
  ),
);

it.effect("rejects large deposits", () =>
  story(
    Story.when(account, new DepositMoney({ amount: 20_000 })),
    Story.rejected(new TooLarge({ max: 10_000 })),
  ),
);

Learn more