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

@damatjs/module

v0.3.6

Published

Damatjs module system — manifest contract, standalone dev/test harness, and registry tooling for self-contained modules

Readme

@damatjs/module

The Damat module system in one package: authoring surface, the portable module.json contract, a standalone dev/test harness, module-as-app runtime, and registry tooling.

A Damat module is a self-contained vertical slice — models + migrations + service + config + workflows + routes. This package is the heart of Damat's composability: it lets you author, run, and test a module on its own (no backend app), ship it with a module.json manifest, and install it into any Damat app with damat module add (and, later, straight from a module registry). It is the single dependency a module package needs — it re-exports everything from defining a module to running it as a live HTTP app.

Part of the Damat monorepo · Full guide · Internals

Install

bun add @damatjs/module

Inside the Damat monorepo it is a workspace package — depend on it with the * version range:

{ "dependencies": { "@damatjs/module": "*" } }

When to use

Use it when:

  • You are authoring a module package — import the contract/config/runtime/tooling from here; the authoring symbols come from their real packages (defineModule/ModuleService from @damatjs/services, model/columns from @damatjs/orm-model, createStep/… from @damatjs/workflow-engine, z from @damatjs/deps/zod).
  • You are relating modules to each otherdefineLink / collectLinkModels / defineLinkModule are re-exported here so the app's src/links/ can declare cross-module relationships from the same surface (the runtime service is getModule("link")). See @damatjs/link.
  • You want to develop or test a module standalone against a real Postgres, without spinning up a backend (bootModule / withModule).
  • You want to run one module as a live app — full framework HTTP stack, just this module registered (startModuleApp, what damat module dev boots).
  • You build tooling: generate a module's types or create a diff migration with no damat.config.ts (generateModuleTypes, createModuleMigration).
  • You implement module distribution: parse/format module refs, read & validate module.json, check registry-readiness, resolve & verify entries against a registry index.

Skip it when:

  • You're building app-level wiring that isn't a module — use @damatjs/framework directly.
  • You only need workflows — depend on @damatjs/workflow-engine directly.

Quick start

Author a module (import each symbol from its real package):

// src/index.ts
import { defineModule, ModuleService } from "@damatjs/services";
import { model, columns } from "@damatjs/orm-model";
import { loadCredentials } from "./credentials";

const models = { users: model("users", { id: columns.uuid().primaryKey() }) };

export class UserModuleService extends ModuleService({ models }) {}

export default defineModule("user", {
  service: UserModuleService,
  credentials: loadCredentials,
});

Develop & test it standalone (real Postgres, no server):

import { bootModule, withModule } from "@damatjs/module";
import userModule from "./index";

// playground / scripts
const booted = await bootModule(userModule, { moduleDir: import.meta.dir });
const user = await booted.service.user.create({ data: { email: "[email protected]" } });
await booted.teardown();

// tests — boot, run, always tear down
await withModule(userModule, { moduleDir: import.meta.dir }, async ({ service }) => {
  expect(await service.user.exists({ where: { email: "[email protected]" } })).toBe(true);
});

Run it as a live app, or address it for a registry:

import { startModuleApp, parseModuleRef, validateModuleDir } from "@damatjs/module";

const app = await startModuleApp({ port: 0 });   // full HTTP stack, this module only
await app.stop();

parseModuleRef("damatjs/[email protected]"); // → { namespace: "damatjs", name: "user", version: "0.2.0" }
validateModuleDir("./src");           // → { valid, errors, warnings, manifest }

Requires Postgres (DATABASE_URL, or { databaseUrl } / { database }) for the harness and for the runtime when serving. In test suites gate DB tests with describe.skipIf(!process.env.DATABASE_URL).

API

| Export | Kind | Summary | | --- | --- | --- | | defineModule, ModuleService | re-export | Define a module and its service base (from @damatjs/services). | | model, columns | re-export | ORM model DSL (from @damatjs/orm-model). | | createStep, createWorkflow, executeStep, parallel, when, ifElse, RetryPolicies, Effect, … | re-export | Workflow engine (from @damatjs/workflow-engine). | | getModule, hasModule, registerModule | re-export | App-side registry access (from @damatjs/framework). | | defineLink, collectLinkModels, defineLinkModule | re-export | Cross-module links: relate this module to another through a junction table; getModule("link") exposes create/dismiss/fetch/graph. | | z | re-export | Zod validation. | | defineModuleConfig | function | Type-safe helper for module.config.ts. | | loadModuleConfig | function | Load a package's module.config.ts (empty config if absent). | | readModuleManifest, validateModuleManifest | function | Read / validate a module.json into a ModuleManifest. | | bootModule, withModule | function | Boot a module standalone (with migrations) for dev/test; auto-teardown variant. | | startModuleApp, runModuleEntry | function | Run one module as a live HTTP app; damat module dev entry. | | createModuleMigration, generateModuleTypes | function | Diff-migration & codegen for a standalone module package. | | parseModuleRef, formatModuleRef | function | Parse / format refs like damatjs/[email protected]. | | validateModuleDir | function | Registry-readiness report (errors block install, warnings block publish). | | resolveRegistryEntry, resolveRegistryRef | function | Resolve a ref against a registry index → source + owner + verification. | | evaluateVerification, verificationPolicy | function | Install-time trust gate (DAMAT_MODULE_VERIFY / DAMAT_MODULE_REGISTRY). | | normalizeVersionEntry | function | Coerce a registry version value (string or object) to RegistryVersionEntry. | | MODULE_MANIFEST_FILENAME, DEFAULT_MODULE_PATHS, DEFAULT_MODULE_PORT, VERIFICATION_STATUSES | const | Constants for the contract / runtime / registry. |

Key types: ModuleManifest (+ ModuleEnvVar, ModuleAuthor, ModuleManifestPaths, ModuleRegistryMeta), ModuleAppConfig, BootModuleOptions / BootedModule, StartModuleAppOptions / RunningModuleApp, ModuleRef, ModuleValidationReport, RegistryIndex / RegistryModuleEntry (back-compat alias RegistryIndexEntry) / RegistryVersionEntry / RegistryOwner / RegistryAuthor / RegistryVerification, ResolvedRegistryModule, VerificationStatus / VerificationPolicy, LinkService / LinkDefinition / LinkEndpoint / LinkOptions / LinkRowRef / LinkModelRef.

See the module.json reference for the full manifest contract.

How it fits

Depends on (all @damatjs/* workspace packages):

  • @damatjs/servicesdefineModule, ModuleService, PoolManager.
  • @damatjs/framework — bootstrap, initializeServices, app-side module registry.
  • @damatjs/orm-connector / orm-migration / orm-model / codegen / orm-type — connection, migrations, model DSL, codegen.
  • @damatjs/workflow-engine — workflow authoring surface.
  • @damatjs/logger, @damatjs/deps — logging, bundled deps (Hono, Zod).

Depended on by (in-repo):

  • @damatjs/damat-cli — the damat CLI (module add / module dev / migrations / codegen).

Documentation

License

MIT