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

@iappx/entity-repo

v3.0.0

Published

A TypeScript library that abstracts data sources and provides a unified context-based access to entities, queries, and transports.

Downloads

25

Readme

NPM Version Issues License

About The Project

Entity Repo is a lightweight and flexible TypeScript library designed to abstract your data source and make entity access seamless through a unified context system.

It provides a clean way to describe entities, register transports (data providers), and build queries with a builder-like pattern.

Here's why Entity Repo might be useful:

  • Decouple your business logic from the actual data source
  • Keep your codebase consistent by accessing data only through contexts
  • Extendable by custom transports, queries, and contexts

Core Concepts

The main components of Entity Repo are EntitySet, Entity, Context, and Transport.

RepoEntity

Base class for declaring entities.
Example:

export class Book extends RepoEntityBase<Book> {
  @RepoEntityField({ isPrimaryKey: true })
  id: number

  @RepoEntityField()
  name: string
}

export class Account extends RepoEntityBase<Account> {
  @RepoEntityField({ isPrimaryKey: true })
  id: string

  @RepoEntityField()
  email: string

  @RepoEntityField({ nestedType: () => Book })
  books: Book[]
}

Transport

A transport handles communication with the data source and must implement the ITransport interface.
Example Axios transport:

export class AxiosTransport implements ITransport<AxiosRequestConfig> {
  protected client: Axios

  constructor(config?: AxiosRequestConfig) {
    this.client = new Axios(config)
  }

  async send<TRes>(config: AxiosRequestConfig): Promise<TRes> {
    return this.client.request(config)
  }
}

EntityQuery

Represents entity access logic and can implement custom query methods. It inherits from the base EntityQuery and can be used as a builder.

export type TRestEntitySetQueryParams = {
    endpoint: string
}

export type TQueryParams = {
    appId: string
}

export class RestEntityQuery<T extends RepoEntityBase> extends EntityQuery<T, AxiosTransport, TRestEntitySetQueryParams> {

    private queryParams: TQueryParams

    public addQueryParams(params: TQueryParams): RestEntityQuery<T> {
        this.queryParams = {
            ...this.queryParams,
            ...params,
        }
        return this
    }

    public async getAll(): Promise<T[]> {
        const response = await this.transport.send<any[]>({
            url: this.options.endpoint,
        })
        return response.map(p => this.entityConstructor.build(p))
    }

    public async create(entity: T): Promise<T> {
        const response = await this.transport.send<Record<string, any>>({
            url: this.options.endpoint,
            method: 'POST',
            data: entity.getDataValues(),
        })
        return this.entityConstructor.build(response)
    }
}

EntityContext

Combines entities into a single access point, without direct dependency on repositories or other services.

export class EntityContext extends EntityContextBase<AxiosTransport> {
  @RepoEntitySet(() => Account, () => RestEntityQuery, { endpoint: '/api/account' })
  public accounts: RestEntityQuery<Account>
}

Getting Started

Prerequisites

  • Node.js >= 18
  • npm or yarn
npm install npm@latest -g

Installation

npm install @iappx/entity-repo
# or
yarn add @iappx/entity-repo

Usage

Here’s an example of how to combine everything:

const repo = EntityRepo.create()
  .use(EntityContext, new AxiosTransport({ baseURL: 'https://api.your.app' }))

const context = repo.getContext(EntityContext)

const accounts = await context.accounts
  .addQueryParams({ appId: 'test-app' })
  .getAll()
console.log('accounts', accounts)

const newAccount = Account.build({ email: '[email protected]' })
await context.accounts
  .addQueryParams({ appId: 'test-app' })
  .create(newAccount)

License

Distributed under the MIT License. See LICENSE for more information.