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

@dudousxd/nestjs-filter-client

v1.33.0

Published

Client-side query builder for @dudousxd/nestjs-filter.

Downloads

1,106

Readme

@dudousxd/nestjs-filter-client

Client-side query builder for @dudousxd/nestjs-filter. Zero dependencies, runs in browser and Node.js.

Installation

npm install @dudousxd/nestjs-filter-client

Usage

import { filterQuery } from '@dudousxd/nestjs-filter-client';

// Build a filter query
const query = filterQuery()
  .where('name', 'contains', 'fleet')
  .where('status', ['COMPLETED', 'FAILED'])
  .where('age', 'gte', 18)
  .build();
// → { where: [
//     { field: 'name', operator: 'contains', value: 'fleet' },
//     { field: 'status', operator: 'in', value: ['COMPLETED', 'FAILED'] },
//     { field: 'age', operator: 'gte', value: 18 },
//   ] }

Convenience methods

filterQuery()
  .equals('status', 'active')
  .contains('name', 'fleet')
  .in('role', ['admin', 'editor'])
  .between('age', 18, 65)
  .gte('createdAt', '2026-01-01')
  .isNull('deletedAt')
  .set('page', 1)
  .set('size', 25)
  .build();

Composing with OR / AND

filterQuery()
  .where('status', 'active')
  .or(q => q
    .where('name', 'contains', 'sync')
    .where('email', 'contains', 'sync')
  )
  .build();

Query string output

const qs = filterQuery()
  .where('name', 'contains', 'fleet')
  .where('status', ['COMPLETED', 'FAILED'])
  .toQueryString();
// → "name[contains]=fleet&status[]=COMPLETED&status[]=FAILED"

Using with fetch

const qs = filterQuery()
  .contains('name', 'fleet')
  .gte('createdAt', '2026-01-01')
  .set('page', 1)
  .toQueryString();

const res = await fetch(`/api/users?${qs}`);

Using as POST body

const body = filterQuery()
  .where('name', 'contains', 'fleet')
  .or(q => q
    .where('role', 'admin')
    .where('role', 'editor')
  )
  .build();

const res = await fetch('/api/users', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify(body),
});

API

| Method | Description | |---|---| | where(field, value) | Equals filter (arrays auto-detect as in) | | where(field, operator, value) | Filter with explicit operator | | equals(field, value) | Shorthand for equals | | contains(field, value) | Shorthand for contains | | in(field, values) | Shorthand for in | | between(field, low, high) | Shorthand for between | | gt / gte / lt / lte | Comparison shorthands | | isNull / isNotNull | Null check shorthands | | isEmpty / isNotEmpty | Empty check shorthands | | startsWith / endsWith | String match shorthands | | or(callback) | OR group | | and(callback) | AND group | | set(key, value) | Add extra keys (e.g. page, size) | | build() | Returns FilterQueryResult object | | toQueryString() | Returns URL query string | | toFlatObject() | Returns flat object for auto-fields |

Types

| Type | What it is | |---|---| | FilterQueryResult | What build() returns: the whole envelope, paging included | | UnpagedFilterQuery | The same envelope without paginateFilterQueryResult extends it | | ColumnFilter | One predicate: field + operator (+ value) | | ColumnFilterGroup | A pure boolean group: { OR: [...] } / { AND: [...] }, no field, no operator | | ColumnFilterClause | ColumnFilter \| ColumnFilterGroup — what one entry of filter.where may be |

UnpagedFilterQuery — the query minus the page

An export that hands the paging window to the server (a CSV export, a report), a count-only request, a prefetch, or a cache key all want the query that says which rows without saying which slice. That is UnpagedFilterQuery:

import type { UnpagedFilterQuery } from '@dudousxd/nestjs-filter-client';

function exportBody(query: UnpagedFilterQuery) {
  return JSON.stringify(query); // the server decides how much it streams
}

const { paginate, ...unpaged } = filterQuery().contains('name', 'fleet').page(0, 25).build();
exportBody(unpaged);

Do not reach for Omit<FilterQueryResult, 'paginate'> instead. FilterQueryResult carries [key: string]: unknown so set() extras survive, and Omit rebuilds a type from keyof — which for an index-signature type is just string | number. The Omit therefore collapses to { [x: string]: unknown }: every named key gone, every typo accepted, and no compile error to tell you. UnpagedFilterQuery is declared as the base FilterQueryResult extends, so the two cannot drift.

ColumnFilterClause — predicates and group-only clauses

A clause is either a predicate or a group that only composes other clauses. Both are valid on the wire (the server's validator has an explicit group-node branch), so both are typed:

import type { ColumnFilterClause } from '@dudousxd/nestjs-filter-client';

const where: ColumnFilterClause[] = [
  { field: 'status', operator: 'equals', value: 'active' },   // predicate
  { OR: [                                                      // group — no field, no operator
    { field: 'name', operator: 'contains', value: 'sync' },
    { field: 'email', operator: 'contains', value: 'sync' },
  ] },
];

ColumnFilter itself is unchanged and still requires field and operator: a group is a separate member of the union rather than a loosening, so { field: 'status', value: 'active' } — a predicate whose operator was forgotten — is still a compile error.

License

MIT