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

budget-control-fm-core

v0.5.0

Published

Core functionality for the budget control financial management system

Readme

budget-control-fm-core

Shared domain logic and application primitives for the Budget Control Financial Management ecosystem.

This package provides reusable value objects, entities, and use cases consumed by services such as ingestion pipelines, classification engines, and API adapters. It is designed around hexagonal architecture: domain logic is pure and infrastructure-free; adapters are implemented by the consuming service, not here.

This package is ESM-only.


Requirements

  • Node.js 24 or later
  • An ESM-compatible environment ("type": "module" in your package.json, or .mjs files)

If your project still uses CommonJS, you must migrate to ESM before using this library.


Installation

npm install budget-control-fm-core

Import model

This package exposes a subpath-only API. There is no root budget-control-fm-core entry point. Every import must target a named subpath:

// ✅ correct
import { RegisterUserUseCase } from "budget-control-fm-core/user";

// ❌ will throw ERR_PACKAGE_PATH_NOT_EXPORTED
import { ... } from "budget-control-fm-core";

This is intentional. As the library grows across domains (user, transaction, budget, ...), each subpath forms an independent module boundary. Only import the domain you actually depend on.

Available subpaths

| Subpath | Contents | | ----------------------------- | ------------------------------------------------------------ | | budget-control-fm-core/user | RegisterUserUseCase, command/result types, port interfaces |


API

budget-control-fm-core/user

RegisterUserUseCase

Orchestrates new user registration. Validates domain rules, delegates credential creation to an auth service, and persists the user profile.

import { RegisterUserUseCase } from "budget-control-fm-core/user";
import type {
  RegisterUserCommand,
  RegisterUserResult,
  AuthServicePort,
  UserProfileRepositoryPort,
} from "budget-control-fm-core/user";

Constructor

new RegisterUserUseCase(
  idGenerator: IdGeneratorPort,
  clock: ClockPort,
  authService: AuthServicePort,
  userProfileRepository: UserProfileRepositoryPort,
)

Dependencies are injected by the consuming service. None of these ports are implemented here; you provide concrete adapters.

execute(command: RegisterUserCommand): Promise<RegisterUserResult>

const result = await useCase.execute({
  fullName: "Jane Doe",
  email: "[email protected]",
  password: "secret",
  birthDate: "1990-06-15", // YYYY-MM-DD
});

console.log(result.userId); // UUID string

Throws TypeError if:

  • fullName is fewer than 3 characters, or has no space (first + last name required)
  • email is not a valid email address
  • birthDate is not a valid YYYY-MM-DD date
  • the user is under 18 years old on the registration date

Port interfaces

Your service must implement these interfaces and inject them:

AuthServicePort

interface AuthServicePort {
  registerUser(user: User, password: string): Promise<void>;
}

UserProfileRepositoryPort

interface UserProfileRepositoryPort {
  save(user: User): Promise<void>;
}

IdGeneratorPort

interface IdGeneratorPort {
  generate(): string; // must return a valid UUIDv4
}

ClockPort

interface ClockPort {
  today(): string; // must return YYYY-MM-DD
}

Command and result types

interface RegisterUserCommand {
  fullName: string;
  email: string;
  password: string;
  birthDate: string; // YYYY-MM-DD
}

interface RegisterUserResult {
  userId: string; // UUIDv4
}

TypeScript path aliases

For normal package consumption, always use the published subpath import:

import { RegisterUserUseCase } from "budget-control-fm-core/user";

Only use TypeScript paths overrides for local monorepo development.

If needed, align them with the current source structure:

{
  "compilerOptions": {
    "paths": {
      "budget-control-fm-core/user": [
        "../budget-control-fm-core/src/user/index.ts"
      ]
    }
  }
}

Current source entrypoint:

src/user/index.ts

Do not reference outdated paths such as src/application/... or dist/application/....


Development

git clone https://github.com/budget-control-fm/budget-control-fm-core.git
cd budget-control-fm-core
npm install

Scripts

| Command | Description | | ----------------------- | --------------------------------------------- | | npm run lint | Lint with Biome | | npm run lint:fix | Auto-fix lint issues | | npm run format | Format source files | | npm run typecheck | TypeScript type check (no emit) | | npm test | Run unit tests | | npm run test:coverage | Tests with coverage report | | npm run build | Compile publishable output to dist/ | | npm run clean | Remove dist/ | | npm run smoke | Validate the packed ESM package as a consumer | | npm run sonar | Run SonarQube analysis |

Repository structure

src/user/index.ts
dist/user/index.js
dist/user/index.d.ts

Adding a new domain module

  1. Create src/<domain>/index.ts as the barrel for that domain.
  2. Add the subpath to the exports map in package.json:
"./transaction": {
  "import": "./dist/transaction/index.js",
  "types": "./dist/transaction/index.d.ts"
}
  1. If using local TS path aliases:
{
  "compilerOptions": {
    "paths": {
      "budget-control-fm-core/transaction": ["./src/transaction/index.ts"]
    }
  }
}
  1. Export only what downstream consumers need.
  2. Add/update smoke tests for the new subpath.

Release process

This project uses Changesets.

npm run lint && npm run typecheck && npm test && npm run smoke

Contributing

  • Follow kebab-case with suffixes (.vo.ts, .entity.ts, .use-case.ts, etc.)
  • Use private constructor + Object.freeze(this)
  • Throw TypeError for invalid domain input
  • Keep domain free of infrastructure dependencies
  • Expose public API via src/<domain>/index.ts

License

ISC