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 🙏

© 2025 – Pkg Stats / Ryan Hefner

interface-forge

v2.6.3

Published

A TypeScript library for creating strongly typed mock data factories using Faker.js for test data generation

Downloads

11,204

Readme

Interface-Forge

npm version License: MIT TypeScript Downloads

A TypeScript library for creating strongly typed mock data factories. Built on Faker.js with advanced composition patterns, database persistence, fixture caching, and optional Zod schema integration.

Support This Project

If you find interface-forge helpful, please consider sponsoring the development:

Your support helps maintain and improve this library for the community! 🚀

Features

  • 🔒 Type-Safe: Full TypeScript support with compile-time validation
  • 🚀 Zero Learning Curve: Extends Faker.js - all Faker methods work out of the box
  • 🔄 Advanced Composition: Build complex object relationships with compose() and extend()
  • 🗄️ Database Integration: Built-in persistence with Mongoose, Prisma, TypeORM adapters
  • 📁 Fixture Caching: Cache generated data for consistent test scenarios
  • 📐 Zod Integration: Generate data directly from schemas with validation
  • 🔗 Hooks & Transforms: Pre/post-build data transformation and validation
  • 🎲 Deterministic: Seed generators for reproducible test data

📚 Complete Documentation | 📂 Examples

Installation

# npm
npm install --save-dev interface-forge

# yarn
yarn add --dev interface-forge

# pnpm
pnpm add --save-dev interface-forge

# For Zod integration (optional)
npm install zod

Quick Start

Basic Factory

import { Factory } from 'interface-forge';

interface User {
    id: string;
    name: string;
    email: string;
    age: number;
}

const userFactory = new Factory<User>((faker) => ({
    id: faker.string.uuid(),
    name: faker.person.fullName(),
    email: faker.internet.email(),
    age: faker.number.int({ min: 18, max: 65 }),
}));

// Generate single object
const user = userFactory.build();

// Generate multiple objects
const users = userFactory.batch(5);

// Override properties
const admin = userFactory.build({ name: 'Admin User' });

Zod Integration

import { z } from 'zod/v4';
import { ZodFactory } from 'interface-forge/zod';

const userSchema = z.object({
    id: z.string().uuid(),
    name: z.string().min(2),
    email: z.string().email(),
    age: z.number().min(18).max(65),
});

const userFactory = new ZodFactory(userSchema);
const user = userFactory.build(); // Automatically validates against schema

Database Persistence

import { MongooseAdapter } from './adapters/mongoose';

const userFactory = new Factory<User>(factoryFn).withAdapter(
    new MongooseAdapter(UserModel),
);

// Create and save to database
const user = await userFactory.create();
const users = await userFactory.createMany(10);

Advanced Composition

const enhancedUserFactory = userFactory.compose<EnhancedUser>({
    profile: profileFactory, // Use another factory
    posts: postFactory.batch(3), // Generate related data
    isActive: true, // Static values
});

Core Features

Factory Methods

  • build() / buildAsync() - Generate single objects
  • batch() / batchAsync() - Generate multiple objects
  • extend() - Create factory variations
  • compose() - Combine multiple factories
  • create() / createMany() - Database persistence

Hooks & Validation

  • beforeBuild() - Transform data before generation
  • afterBuild() - Transform data after generation
  • Full async support for external API calls

Fixture Caching

  • Cache generated data for consistent tests
  • Signature validation for factory changes
  • Node.js only (browser fallback available)

Utility Generators

  • CycleGenerator - Predictable value cycling
  • SampleGenerator - Random sampling without repeats

Documentation

📚 Complete Documentation

Examples

All examples are available in the ./examples directory:

| Feature | Example | | -------------------- | --------------------------------------------------------------------- | | Basic Usage | 01-basic-usage.ts | | Factory Composition | 02-advanced-composition.ts | | Testing Integration | 03-testing-examples.ts | | Zod Schemas | 07-zod-basic.ts | | Database Persistence | adapters/ |

Contributing

We welcome contributions! Please read our contributing guidelines.

License

MIT License - see LICENSE for details.