@adonis-agora/filter
Version:
Server-side query filtering/sorting/pagination for AdonisJS — Spatie-style input, a Lucid adapter, and field allow-listing. Part of the Agora ecosystem.
36 lines • 1.82 kB
TypeScript
import type { FilterRequestContext } from './apply_from_request.js';
import type { BaseFilter } from './base_filter.js';
import type { FilterInput } from './types.js';
/**
* A filter class over a custom backend, as the container hands it back: constructible, extending
* {@link BaseFilter} — the model form's {@link FilterClass} for drafts.
*/
export type CustomFilterClass<D> = new (...args: any[]) => BaseFilter<D>;
/** Options for {@link applyCustomFilter}. */
export interface ApplyCustomFilterOptions {
/**
* Pre-parsed input to use instead of reading `ctx.request.qs()`. Useful for non-HTTP callers
* and tests; when omitted the query string is parsed via {@link parseFilterRequest}.
*/
input?: FilterInput;
}
/**
* Run a custom filter class against a caller-created draft from a request context: bind the
* per-request state onto the instance, run `setup()`, then hand each filter to its owning method
* as `(value, operator, field)`.
*
* The custom-backend counterpart of
* {@link import('./apply_from_request.js').applyFilterFromRequest}: that helper ends in SQL (a
* `QueryBuilderLike`), this one ends in whatever the draft accumulates — a `RunQuery`, an engine
* client query, an in-memory predicate. The wire format, the parsing, the method dispatch and the
* error shapes are shared, so a console can move between a Lucid listing and a custom-backend one
* without relearning the spelling.
*
* ```ts
* const draft = new RunQueryDraft();
* await applyCustomFilter(draft, RunFilter, ctx);
* const runs = await engine.listRuns(draft.query);
* ```
*/
export declare function applyCustomFilter<D>(draft: D, cls: CustomFilterClass<D>, ctx: FilterRequestContext | undefined, options?: ApplyCustomFilterOptions): Promise<void>;
//# sourceMappingURL=custom_filter.d.ts.map