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

@diby/openset-codegen

v1.1.1

Published

Fluent TypeScript builder for constructing valid OpenSet documents

Downloads

18

Readme

@diby/openset-codegen

A fluent TypeScript builder for constructing valid OpenSet documents with full type safety, autocompletion, and optional runtime validation.

Installation

npm install @diby/openset-codegen

For validated builds, also install the validator:

npm install @diby/openset-codegen @diby/openset-validator

Quick Start

import { workout, set, fixed, range, amrap } from '@diby/openset-codegen';

const doc = workout('Upper Body Push')
  .date('2024-01-15')
  .sports('strength')
  .block('Warm-Up', b => b
    .series('SEQUENTIAL', s => s
      .exercise('push_up', e => e
        .set(set({ reps: fixed(15) }))
      )
    )
  )
  .block('Main Work', b => b
    .series('SEQUENTIAL', s => s
      .exercise('bench_press', e => e
        .set(set({ reps: fixed(5), load: fixed(100, 'kg') }))
        .set(set({ reps: fixed(5), load: fixed(100, 'kg') }))
        .set(set({ reps: amrap(), load: fixed(100, 'kg'), rpe: fixed(9) }))
      )
      .rest(180, 's')
    )
  )
  .build();

Value Helpers

Shorthand functions for creating value objects:

| Function | Output | Example | |----------|--------|---------| | fixed(value, unit?) | { type: 'fixed', value, unit } | fixed(100, 'kg') | | range(min, max, unit?) | { type: 'range', min, max, unit } | range(8, 12) | | min(value, unit?) | { type: 'min', value, unit } | min(5) | | amrap() | { type: 'amrap' } | amrap() | | max() | { type: 'max' } | max() | | any() | { type: 'any' } | any() |

The range() function validates that min < max at construction time.

Set Builder

The set() function accepts an object of dimension key-value pairs and automatically infers the dimensions array from the keys you provide.

set({ reps: fixed(5), load: fixed(100, 'kg') })
// produces: { dimensions: ["reps", "load"], reps: { ... }, load: { ... } }

Non-dimension fields (rest_after, note) are supported but excluded from the inferred dimensions array.

Document Builders

workout(name?)

Creates a standalone workout document.

workout('Morning Workout')
  .id('w-001')
  .date('2024-01-15')
  .sports('strength')
  .note('Focus on form')
  .block('Block Name', b => { /* ... */ })
  .build()

program(name)

Creates a multi-phase program document.

program('4-Week Strength')
  .description('Progressive overload program')
  .sports('strength')
  .duration(4, 'week') // or .durationWeeks(4)
  .author('Coach')
  .phase('Base Building', p => p
    .weeks(1, 2)
    .goal('Build work capacity')
    .workout('Day 1', s => { /* ... */ })
  )
  .build()

Hierarchy Builders

Builders use callback-based nesting that mirrors the document hierarchy:

workout → block → series → exercise → set
program → phase → workout → block → series → exercise → set

Series

.series('CIRCUIT', s => s
  .rounds(fixed(3))
  .rest(120, 's')
  .exercise('push_up', e => { /* ... */ })
  .namedExercise('Custom Drill', e => { /* ... */ })
)

Exercise

.exercise('bench_press', e => e
  .group('pair_a')            // for CLUSTER mode
  .note('Control the eccentric')
  .set(set({ reps: fixed(5), load: fixed(100, 'kg') }))
  .sets(3, set({ reps: fixed(8), load: fixed(80, 'kg') }))  // 3 identical sets
)

Validated Builds

The .buildValidated() method runs @diby/openset-validator on the built document and throws a ValidationError if there are errors:

import { workout, set, fixed, ValidationError } from '@diby/openset-codegen';

try {
  const doc = await workout('Test')
    .block('A', b => b
      .series('SEQUENTIAL', s => s
        .exercise('bench_press', e => e
          .set(set({ reps: fixed(5), load: fixed(100, 'kg') }))
        )
      )
    )
    .buildValidated();
} catch (err) {
  if (err instanceof ValidationError) {
    console.log(err.result.errors);
  }
}

buildValidated() is async and requires @diby/openset-validator as a peer dependency.

License

MIT