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

@structure-ai/domain

v0.0.7

Published

DDD tactical bindings: branded ids, value objects, aggregates (decide/evolve), domain events, repository port, error taxonomy.

Readme

@structure-ai/domain

DDD tactical building blocks. An aggregate is a decider: decide accepts or rejects a command against current state and emits events; evolve folds an event into state. The same definition drives state-stored persistence and event sourcing (@structure-ai/eventsourcing).

Usage

import { Aggregate, DomainEvent, EntityId, InvariantViolation, ValueObject } from "@structure-ai/domain";
import { Effect, Schema } from "effect";

const InvoiceId = EntityId.define("InvoiceId");
const Money = ValueObject.define("Money", Schema.Struct({
  amount: Schema.Number.pipe(Schema.nonNegative()),
  currency: Schema.Literal("EUR", "USD"),
}));

const InvoiceApproved = DomainEvent.define("InvoiceApproved", {
  invoiceId: InvoiceId.schema,
  approver: Schema.String,
});

const Invoice = Aggregate.define({
  name: "Invoice",
  initial: { status: "pending" as const },
  decide: (state, command: { _tag: "ApproveInvoice"; id: EntityId.Of<typeof InvoiceId>; approver: string }) =>
    state.status === "pending"
      ? Effect.succeed([InvoiceApproved.make({ invoiceId: command.id, approver: command.approver })])
      : Effect.fail(new InvariantViolation({ rule: "only a pending invoice can be approved" })),
  evolve: (state, event) => (event._tag === "InvoiceApproved" ? { status: "approved" as const } : state),
});

Exports

| Export | What it is | | --- | --- | | EntityId.define(name) | Branded, validated string id: schema, make(raw), generate(); EntityId.Of<typeof X> is its type. | | ValueObject.define(name, schema) | Self-validating immutable value: from(unknown)Either<A, ValidationFailed> (all issues), make, is. | | Aggregate.define / rehydrate / execute | Decider definition; fold history; run one command returning { state, events }. | | DomainEvent.define(tag, fields) | Past-tense event schema (Schema.TaggedStruct). | | EventMetadata / Envelope<E> | Persisted/published event envelope: eventId, occurredAt, aggregate identity + version, correlation/causation. | | Repository | Load/save port with Versioned<A> and optimistic version checks. | | InvariantViolation, NotFound, ConcurrencyConflict, ValidationFailed | Tagged errors with classification: FailureClass (transient/permanent/conflict). |

Events record accepted facts only — a failed validation is not a domain event. Keep decide/evolve pure; effects belong in application services.