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

@themeparks/typelib

v1.1.3

Published

TypeScript definitions for ThemeParks.wiki API

Readme

@themeparks/typelib

TypeScript definition system for ThemeParks.wiki

Overview

@themeparks/typelib is a TypeScript types package that generates types from JSON schemas and provides runtime type validation. It is designed for the internal ThemeParks.wiki systems and generating client libraries. You likely do not want to interact with this library directly.

Requirements

  • Node.js >= 18.0.0

Installation

npm install @themeparks/typelib

Basic Usage

Using pre-built types

import { Entity, LiveData, EntitySchedule } from '@themeparks/typelib';

// Use generated types
const entity: Entity = {
    id: 'park-123',
    name: 'Example Park',
    entityType: 'PARK',
    timezone: 'America/New_York',
};

const liveData: LiveData = {
    id: 'attraction-456',
    status: 'OPERATING',
};

Enums and conversion functions

import { EntityTypeEnum, StringToEntityType } from '@themeparks/typelib';

// Native TypeScript enums
const type = EntityTypeEnum.ATTRACTION;

// Convert strings to enum values
const parsed = StringToEntityType('attraction');

Runtime Schema Registry

registerTypeSchema(name: string, schema: any) Register a schema for runtime use.

getTypeSchema(name: string): any Retrieve a registered schema.

import { registerTypeSchema, getTypeSchema } from '@themeparks/typelib';

// Schemas are automatically registered when importing types
import { Entity } from '@themeparks/typelib';

// Access the schema at runtime
const schema = getTypeSchema('Entity');

Deterministic Object Hashing

import { hashObject } from '@themeparks/typelib/hash';

// Returns a 64-character hex SHA-256 hash
const hash = hashObject({ name: 'Example', id: 123 });

// Deterministic — key order doesn't matter
hashObject({ b: 2, a: 1 }) === hashObject({ a: 1, b: 2 }); // true

Generating types from schemas

import { generateTypes } from '@themeparks/typelib/generate';
import { resolve } from 'path';

await generateTypes({
    schemaDirs: [resolve('./typesrc')],
    outputDir: './src/types'
});

Schema Format

Schemas follow JSON Schema Draft 7 specification. Each file defines top-level types as properties:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Entities",
  "type": "object",
  "properties": {
    "LanguageCode": {
      "type": "string",
      "enum": ["en", "en-gb", "de", "fr", "es", "ja", "ko", "zh"],
      "description": "Supported language codes for ThemeParks.wiki"
    },
    "Entity": {
      "type": "object",
      "required": ["id", "name", "entityType", "timezone"],
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique identifier for this entity"
        },
        "name": {
          "description": "Entity name",
          "$ref": "#/properties/LocalisedString"
        },
        "entityType": {
          "$ref": "#/properties/EntityType"
        },
        "timezone": {
          "type": "string",
          "description": "Timezone of this entity (IANA)"
        }
      }
    }
  }
}

Types can reference each other within the same file using $ref, and the generator resolves cross-file references automatically.

Generated Output

The generator creates:

  • Type definitions — TypeScript interfaces and types
  • Enum types — Native TypeScript enums with StringTo* conversion functions
  • Runtime registration — Automatic schema registration via registerTypeSchema
  • Re-export index — Convenient imports from a single file

Package Exports

  • @themeparks/typelib — Types, enums, and schema registry functions
  • @themeparks/typelib/generate — Type generation from JSON schemas
  • @themeparks/typelib/hash — Deterministic SHA-256 object hashing

Publishing

Builds and publishes to npm automatically via prepublishOnly:

# Bump version in package.json, then:
npm publish --access public

This runs npm run build (which regenerates types from schemas, then compiles TypeScript) before publishing. The published package includes dist/, typesrc/, and src/.