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

@hero-dynamic-form/typeorm-inspector

v1.0.49

Published

TypeORM entity inspector adapter for @hero-dynamic-form/core

Downloads

38

Readme

@hero-dynamic-form/typeorm-inspector

TypeORM entity inspector adapter for @hero-dynamic-form/core. This package provides both a library for runtime entity inspection and a CLI tool for generating/syncing TypeORM entities from your PostgreSQL database.

Installation

npm install @hero-dynamic-form/typeorm-inspector
# or
pnpm add @hero-dynamic-form/typeorm-inspector

CLI Usage

Setup

Create a .env file in your project root with database connection settings:

# Option 1: Use DATABASE_URL (connection string)
DATABASE_URL=postgres://postgres:[email protected]:5432/your_database

# Option 2: Use individual env vars (if DATABASE_URL is not set)
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASS=postgres
DB_NAME=your_database

Commands

List all tables

npx typeorm-inspector generate

Output:

Available tables:
  - users
  - posts
  - comments

Generate entity from table

npx typeorm-inspector generate <table_name> [options]

Options:

  • --output, -o <path> - Output directory (default: ./src/entity)
  • --force, -f - Overwrite existing files
  • --env <path> - Path to .env file (default: .env)

Example:

# Generate User entity from 'users' table
npx typeorm-inspector generate users -o ./src/datasource/entity

# Overwrite existing entity
npx typeorm-inspector generate users -o ./src/entity --force

Features:

  • Automatically detects PostgreSQL enums and generates proper TypeORM enum decorators
  • Checks for actual NULL values in data (not just schema) to correctly set nullable: true
  • Converts snake_case column names to camelCase property names
  • Handles special columns: id (PrimaryGeneratedColumn), created_at, updated_at

Sync entity with database

npx typeorm-inspector sync <entity_path> [options]

Options:

  • --apply - Auto-apply fixes to entity file
  • --dry-run - Preview changes without applying
  • --env <path> - Path to .env file (default: .env)

Example:

# Compare entity with database schema
npx typeorm-inspector sync ./src/entity/User.ts

# Preview and apply fixes
npx typeorm-inspector sync ./src/entity/User.ts --apply

Generated Entity Example

import {
  BaseEntity,
  Column,
  Entity,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn,
} from "typeorm";

@Entity({ name: "users" })
export class User extends BaseEntity {
  @PrimaryGeneratedColumn()
  id!: number;

  @Column({ type: "text" })
  username!: string;

  @Column({ type: "enum", enum: ["ADMIN", "USER"], enumName: "users_role" })
  role!: string;

  @Column({ type: "text", nullable: true })
  description?: string;

  @CreateDateColumn({ type: "timestamp", name: "created_at" })
  createdAt!: Date;

  @UpdateDateColumn({ type: "timestamp", name: "updated_at" })
  updatedAt!: Date;
}

Library Usage

import { DynamicFormCore } from "@hero-dynamic-form/core";
import { TypeORMEntityInspector } from "@hero-dynamic-form/typeorm-inspector";
import { User } from "./entities/User";

const inspector = new TypeORMEntityInspector();

const config = {
  resources: [
    {
      name: "users",
      entity: User,
    },
  ],
  entityInspector: inspector,
};

const core = new DynamicFormCore(config);
await core.init();
await core.start();

Features

  • Extracts TypeORM column metadata (type, nullable, enum, etc.)
  • Generates validation rules from TypeORM decorators
  • Supports class-validator decorators
  • Works with all TypeORM column types
  • CLI for generating entities from database schema
  • CLI for syncing entities with database schema

Environment Variables

Supports both DATABASE_URL connection string and individual environment variables:

| Variable | Description | Default | | -------------- | ---------------------------------------- | ----------- | | DATABASE_URL | Full connection string (takes priority) | - | | DB_HOST | Database host | localhost | | DB_PORT | Database port | 5432 | | DB_USER | Database user | postgres | | DB_PASS | Database password | postgres | | DB_NAME | Database name | (required) |

Note: If DATABASE_URL is set, it takes priority over individual variables.

License

MIT