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

@opencharts/core

v0.0.1

Published

Core canonical models and utilities for OpenCharts

Readme

@opencharts/core

Foundational zero-dependency primitives for the OpenCharts ecosystem.

npm License: MIT

Overview

@opencharts/core contains the shared building blocks that every other OpenCharts package depends on. It has no runtime dependencies and no side effects on import.

  • Entity — base class providing typed validation helpers and serialization utilities for all domain entities.
  • deepFreeze — recursively freeze objects so published registry definitions are genuinely immutable.
  • OUTCOMES — canonical outcome vocabulary shared across adapters and integrations.
  • DEPENDENCY_RELATIONS / DEPENDENCY_REQUIRES — canonical enums for workflow step dependency expressions.

Installation

npm install @opencharts/core

Usage

Entity base class

Extend Entity to build validated, serializable domain objects.

import { Entity } from '@opencharts/core';

class PatientName extends Entity {
  static REQUIRED_FIELDS = ['family'];

  #data = {};

  constructor(data = {}) {
    super();
    if (data.family != null) this.family = data.family;
    if (data.given != null)  this.given  = data.given;
  }

  get family() { return this.#data.family; }
  set family(value) { this.#data.family = this.string(value, 'family'); }

  get given() { return this.#data.given; }
  set given(value) { this.#data.given = this.stringArray(value, 'given'); }

  validate() {
    this.validateRequired(this.#data, PatientName.REQUIRED_FIELDS);
    return this;
  }

  toJSON() { return this.serialize(this.#data); }
}

const name = new PatientName({ family: 'Smith', given: ['John', 'Paul'] });
name.validate();
console.log(name.toJSON());
// { family: 'Smith', given: ['John', 'Paul'] }

Built-in validators:

| Method | Description | |---|---| | string(value, field) | Non-empty string | | date(value, field) | Valid date (returns Date) | | integer(value, field, { min }) | Integer ≥ min | | number(value, field, { min, max }) | Finite number in range | | enumValue(value, values, field) | One of the allowed values | | object(value, field) | Plain object (deep-cloned) | | array(value, field) | Array (deep-cloned) | | stringArray(value, field) | Array of strings | | mapOfNumbers(value, field) | Map or plain object of string→number | | subStructure(value, Class, field) | Instance of Class or plain object (auto-constructed) | | validateRequired(data, fields) | Throws if any field is null/undefined | | serialize(data) | Converts Map, Date, nested toJSON to plain object |

deepFreeze

import { deepFreeze } from '@opencharts/core';

const catalog = deepFreeze({
  name: 'Patient',
  parameters: { identifiers: { type: 'array' } },
});

// All nested objects are frozen — mutations throw in strict mode
catalog.parameters.identifiers.type = 'string'; // throws TypeError

OUTCOMES

import { OUTCOMES } from '@opencharts/core';

console.log(OUTCOMES);
// ['success', 'empty', 'not_ready', 'throttled', 'unauthorized', ...]

function handleResult(outcome) {
  if (!OUTCOMES.includes(outcome)) {
    throw new Error(`Unknown outcome: ${outcome}`);
  }
  // ...
}

Workflow vocabulary

import { DEPENDENCY_RELATIONS, DEPENDENCY_REQUIRES } from '@opencharts/core';

// DEPENDENCY_RELATIONS: ['case', 'same_resource', 'referenced_resource', 'parent_output']
// DEPENDENCY_REQUIRES:  ['succeeded', 'settled', 'output_accepted', 'succeeded_or_skipped']

API Reference

Entity (class)

Base class for all domain entities. See src/Entity.js for full documentation.

deepFreeze(obj)obj

Recursively freezes obj in place. Primitives and null are returned unchanged. Already-frozen objects are short-circuited. Returns the same reference.

OUTCOMES (string[])

Canonical outcome values: 'success', 'empty', 'not_ready', 'throttled', 'unauthorized', 'forbidden', 'not_found', 'invalid', 'ambiguous', 'transient_error', 'permanent_error', 'duplicate_work', 'cancelled', 'unknown'.

DEPENDENCY_RELATIONS (string[])

'case' | 'same_resource' | 'referenced_resource' | 'parent_output'

DEPENDENCY_REQUIRES (string[])

'succeeded' | 'settled' | 'output_accepted' | 'succeeded_or_skipped'

License

MIT