Skip to content

feat: add JavaScript query builder library for Dappi - #380

Open
francedermaz wants to merge 5 commits into
codechem:mainfrom
francedermaz:feat/js-query-builder
Open

feat: add JavaScript query builder library for Dappi#380
francedermaz wants to merge 5 commits into
codechem:mainfrom
francedermaz:feat/js-query-builder

Conversation

@francedermaz

@francedermaz francedermaz commented Aug 7, 2026

Copy link
Copy Markdown

What Changed?

Added dappi-query-js, a dependency-free TypeScript library that builds Dappi-compatible query strings with a fluent API. It covers filtering, sorting, pagination, search and field shaping, mapping directly to what the generated list endpoints expect (filter[...], SortBy/SortDirection, Offset/Limit, SearchTerm, fields, include).

import { createQuery, field } from 'dappi-query';

const qs = createQuery()
  .or(field('title').containsIgnoreCase('breaking'))
  .and(field('author.name').eq('john'))
  .and(field('views').gt(100))
  .sort('publishedAt', 'desc')
  .page(2, 20)
  .select('id', 'title')
  .toQueryString();

// filter[0][$or][title][$cic]=breaking&filter[1][$and][author][name][$eq]=john
//   &filter[2][$and][views][$gt]=100&Offset=20&Limit=20&SortBy=publishedAt&SortDirection=Descending&fields=id%2Ctitle

Why?

Building these query strings by hand is error-prone: the bracket syntax, operation tokens and nested field paths are easy to get wrong, and there was no client-side helper for it. This gives consumers a typed, ergonomic way to construct filters that matches the server-side parsing exactly.

Closes #351

Type of Change

  • ✨ New feature (adds new functionality without breaking existing features)

How Did You Test This?

What I tested:

  • 18 unit tests covering every operation, nested field paths, sorting, pagination, search, field selection, URL building and value serialization.
  • A round-trip test that parses the generated query strings with a JS port of CollectionFilter, asserting each key decodes back to the intended filter (fields, operator, operation, value).
  • tsc type-check and build pass with strict mode.

How to test it:

  1. cd dappi-query-js
  2. npm install
  3. npm test

Review Checklist

  • My code follows the project's style and conventions
  • I've reviewed my own code for obvious issues
  • I've added comments where the code might be confusing
  • I've updated relevant documentation (if needed)
  • I've tested my changes and they work as expected

Screenshots / Additional Context

Placed at the repo root as dappi-query-js/ (alongside CCUI.DAPPI), since packages/ is git-ignored. Ships as TypeScript with a README.md documenting the full operation set and usage. Zero runtime dependencies; vitest and typescript are the only dev dependencies.

@francedermaz
francedermaz marked this pull request as ready for review August 7, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create Javascript library for query building for Dappi

1 participant