@comradeweb/ag-grid-ssr-to-query
v1.0.0
Published
Adapter to convert ag-Grid server-side row requests into @comradeweb/db-query-dsl QueryOptions.
Maintainers
Readme
ag-grid-ssr-to-query
Adapter that converts ag-Grid Server-Side Row Model requests into type-safe QueryOptions<T> from @comradeweb/db-query-dsl. Use it to bridge ag-Grid filters/sorting/pagination to your DB/ORM adapter that already understands the Query DSL.
Installation
pnpm add @comradeweb/ag-grid-ssr-to-query
# or
npm i @comradeweb/ag-grid-ssr-to-query
# or
yarn add @comradeweb/ag-grid-ssr-to-queryQuick start
import {
AgGridRequestToQueryDSL,
ServerSideGetRowsRequest,
} from '@comradeweb/ag-grid-ssr-to-query';
import type { QueryOptions } from '@comradeweb/db-query-dsl';
type User = {
id: string;
email: string;
name: string;
age: number;
createdAt: Date;
};
declare const request: ServerSideGetRowsRequest;
const queryOptions: QueryOptions<User> = AgGridRequestToQueryDSL.convert<User>(
request,
{
// optional: override quick filter fields (dot-notation supported)
quickFilterFields: ['name', 'email'],
},
);
// pass QueryOptions<User> to your @comradeweb/db-query-dsl adapterWhat it does
- Converts ag-Grid
filterModel(including compound filters) toWhere<T>. - Converts
sortModeltoSortOptions<T>. - Derives pagination (
offset/limit) fromstartRow/endRow. - Builds quick filter OR-query across configurable fields.
Date filter semantics
date+equalsis treated as a calendar day match, not timestamp equality.- Internally it is converted to a half-open range:
gte = startOfDayUTC(dateFrom)lt = startOfNextDayUTC(dateFrom)
- This avoids millisecond edge cases and correctly matches any timestamp within that day.
API
AgGridRequestToQueryDSL.convert<T>(request, options?) => QueryOptions<T>options.quickFilterFields?: QuickFilterFields<T>— override fields used for quick filter. Defaults to['name', 'email', 'title', 'description'].
- Types:
QuickFilterFields<T>— readonly array of field paths (dot-notation allowed) from your domain typeT.ConvertOptions<T>— options bag forconvert.
Development
- Install deps:
pnpm install - Scripts:
pnpm run type:checkpnpm run type:test(tsd)pnpm run build
License
MIT © Vyacheslav D.
Contributing
See CONTRIBUTING.md for workflow, scripts, and release process.
