@dudousxd/nestjs-filter 1.11.1 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/dist/adapter/adapter.d.ts +40 -11
- package/dist/adapter/adapter.d.ts.map +1 -1
- package/dist/decorator/aliases.d.ts +19 -0
- package/dist/decorator/aliases.d.ts.map +1 -0
- package/dist/decorator/aliases.js +40 -0
- package/dist/decorator/aliases.js.map +1 -0
- package/dist/decorator/computed.decorator.d.ts +25 -0
- package/dist/decorator/computed.decorator.d.ts.map +1 -0
- package/dist/decorator/computed.decorator.js +53 -0
- package/dist/decorator/computed.decorator.js.map +1 -0
- package/dist/decorator/filterable.decorator.d.ts.map +1 -1
- package/dist/decorator/filterable.decorator.js +4 -0
- package/dist/decorator/filterable.decorator.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/runner.d.ts +58 -1
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +168 -18
- package/dist/runner.js.map +1 -1
- package/dist/tokens.d.ts +2 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +2 -0
- package/dist/tokens.js.map +1 -1
- package/dist/types.d.ts +79 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @dudousxd/nestjs-filter
|
|
2
2
|
|
|
3
|
+
## 1.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#45](https://github.com/DavideCarvalho/nestjs-filter/pull/45) [`99c7010`](https://github.com/DavideCarvalho/nestjs-filter/commit/99c70105fc667085e59a81b8441cdcc990b8a275) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Computed fields now accept three source forms — a SQL string, a function
|
|
8
|
+
(`(ctx) => string | raw`), or an ORM query-builder callback — via the inline
|
|
9
|
+
`computed` map or the new `@Computed` method decorator. Both attachment styles
|
|
10
|
+
are surfaced as typed fields by the codegen (`@Computed`/`{ source, type }`
|
|
11
|
+
carry value types; bare map entries type the field name). Adapter hook
|
|
12
|
+
signatures `applyComputedField`/`applyComputedSort` now receive the raw
|
|
13
|
+
`ComputedSource` (internal change; only bundled adapters implement them).
|
|
14
|
+
|
|
15
|
+
## 1.12.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [#41](https://github.com/DavideCarvalho/nestjs-filter/pull/41) [`1c6bd97`](https://github.com/DavideCarvalho/nestjs-filter/commit/1c6bd9751108030a752fd3917ae7ec356ca63633) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `@Filterable` now accepts an optional `aliases: Record<string, string>` — a declarative map from a client-supplied field name to the real entity path (a column, a relation path like `"base"`, a dotted relation field like `"unit.name"`, or a JSON sub-path) it should resolve to.
|
|
20
|
+
|
|
21
|
+
Motivating case: `@FilterFor` methods only run for structured `filter` input — the `where[]` column-filter path resolves field names straight against entity columns/JSON sub-paths, before and separately from `@FilterFor` dispatch. A legacy client sending `where[]` filters on `baseId` when the entity relation is actually named `base` therefore had no server-side way to remap that name; the filter was silently dropped (dynamic mode) or reached the ORM as an unknown column (static mode). `aliases: { baseId: "base" }` closes that gap.
|
|
22
|
+
|
|
23
|
+
Resolution is applied at every point a client field name is resolved against the entity — `where[]` column filters, structured `filter` keys, `sort`, `distinct`, and `select` — for both the static (`@Filterable`-class-driven `apply()`) and dynamic (`applyDynamic`/`findAndCount`/`findPage`) entry points. Resolution always runs first: the allowlist (`allowed`/`blocked`), the `SAFE_FIELD` path check, entity-metadata checks, and the `throwOnInvalid` policy all evaluate the resolved target, never the alias key. An alias key that collides with a real column name wins (an explicit consumer decision), and aliases never cascade (an alias's target is never re-run through the alias map, so cycles are structurally impossible). Declaring no `aliases` is a zero-behavior-change no-op — the full pre-existing test suite passes untouched.
|
|
24
|
+
|
|
25
|
+
- [#41](https://github.com/DavideCarvalho/nestjs-filter/pull/41) [`1c6bd97`](https://github.com/DavideCarvalho/nestjs-filter/commit/1c6bd9751108030a752fd3917ae7ec356ca63633) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Make DISTINCT projections executable end-to-end via `FilterRunner.findAndCount`. Previously, `applyDistinct` built a `SELECT DISTINCT` query but execution broke: `findAndCount` always routed through `getResultAndCount`, which hydrates rows into entities — a PK-less DISTINCT projection has no identifier to hydrate around, so MikroORM threw `"cannot merge entity without identifier"` (and the equivalent TypeORM path was likewise broken).
|
|
26
|
+
|
|
27
|
+
Adds a new optional adapter method, `getDistinctResultAndCount(qb, fields, entity)`, which executes an already-built DISTINCT projection without entity hydration, returning plain rows keyed by the requested fields plus the total count of distinct tuples (ignoring limit/offset). `findAndCount` now routes to it automatically whenever the structured input carries `distinct` fields, and skips the to-many `populate` phase for distinct queries (there is no entity identity to attach relations to). If the active adapter doesn't implement it, `findAndCount` throws a descriptive error, mirroring the existing `getResultAndCount` contract.
|
|
28
|
+
|
|
29
|
+
Both bundled adapters implement it:
|
|
30
|
+
|
|
31
|
+
- **MikroORM** — rows via `qb.execute('all')` (raw, driver-mapped column names, no identity-map hydration); total via MikroORM's own `getCount(fields, true)`, which is already dialect-aware for multi-column DISTINCT (native `COUNT(DISTINCT a, b)` on MySQL, a `COUNT(*) FROM (SELECT DISTINCT ...)` subquery wrapper elsewhere).
|
|
32
|
+
- **TypeORM** — rows via `getRawMany()` with the `<alias>_<field>` prefix stripped back to property names; total via a dialect-neutral `SELECT COUNT(*) FROM (SELECT DISTINCT ...) t` subquery, which runs identically on Postgres, MySQL and SQLite for both single- and multi-field distinct.
|
|
33
|
+
|
|
34
|
+
- [#41](https://github.com/DavideCarvalho/nestjs-filter/pull/41) [`1c6bd97`](https://github.com/DavideCarvalho/nestjs-filter/commit/1c6bd9751108030a752fd3917ae7ec356ca63633) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `nestjsFilterCodegen({ maxDepth })` caps relation-path recursion depth in the generated `filterFields` union, guarding against the union blowing up on `autoFields: true` entities with deep/wide relation graphs. Overridable per filter via `@Filterable({ codegen: { maxDepth } })`, which takes precedence over the global option. Default stays uncapped (unchanged behavior).
|
|
35
|
+
|
|
36
|
+
`@Filterable` now accepts an optional `codegen: { maxDepth }` field on `FilterableOptions`/`FilterMetadata` — metadata only, read statically by `@dudousxd/nestjs-filter-codegen`; the core runtime ignores it.
|
|
37
|
+
|
|
3
38
|
## 1.11.1
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Type } from '@nestjs/common';
|
|
2
2
|
import type { ColumnFilter } from '../operators/types.js';
|
|
3
|
-
import type { SortItem } from '../types.js';
|
|
3
|
+
import type { ComputedSource, SortItem } from '../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Describes a single scalar field on an entity, as reported by the ORM's
|
|
6
6
|
* metadata layer. Used by `autoFields: true` to validate that incoming
|
|
@@ -257,31 +257,31 @@ export interface FilterAdapter {
|
|
|
257
257
|
applySort?(qb: unknown, sorts: SortItem[]): void;
|
|
258
258
|
/**
|
|
259
259
|
* Applies a WHERE condition on a **computed/virtual field** — a developer-
|
|
260
|
-
* provided SQL expression declared via `@Filterable.computed
|
|
261
|
-
* {@link applyAutoField} (scalar →
|
|
262
|
-
* those operators) but evaluates the
|
|
263
|
-
* reference. The
|
|
264
|
-
* always parameterized.
|
|
260
|
+
* provided SQL expression or function declared via `@Filterable.computed`
|
|
261
|
+
* or an `@Computed` method. Behaves like {@link applyAutoField} (scalar →
|
|
262
|
+
* equals, array → IN, operator object → those operators) but evaluates the
|
|
263
|
+
* raw `source` instead of a column reference. The source is dev-provided
|
|
264
|
+
* (never client input); values are always parameterized.
|
|
265
265
|
*
|
|
266
266
|
* Optional — adapters that don't support computed fields should not
|
|
267
267
|
* implement this.
|
|
268
268
|
*
|
|
269
269
|
* @param qb - The query builder instance.
|
|
270
|
-
* @param
|
|
270
|
+
* @param source - The computed source (string | function).
|
|
271
271
|
* @param value - The filter value (scalar, array, or operator object).
|
|
272
272
|
*/
|
|
273
|
-
applyComputedField?(qb: unknown,
|
|
273
|
+
applyComputedField?(qb: unknown, source: ComputedSource, value: unknown): void;
|
|
274
274
|
/**
|
|
275
|
-
* Applies an ORDER BY on a computed/virtual field's
|
|
275
|
+
* Applies an ORDER BY on a computed/virtual field's source.
|
|
276
276
|
*
|
|
277
277
|
* Optional — adapters that don't support computed fields should not
|
|
278
278
|
* implement this.
|
|
279
279
|
*
|
|
280
280
|
* @param qb - The query builder instance.
|
|
281
|
-
* @param
|
|
281
|
+
* @param source - The computed source (string | function).
|
|
282
282
|
* @param direction - Sort direction.
|
|
283
283
|
*/
|
|
284
|
-
applyComputedSort?(qb: unknown,
|
|
284
|
+
applyComputedSort?(qb: unknown, source: ComputedSource, direction: 'asc' | 'desc'): void;
|
|
285
285
|
/**
|
|
286
286
|
* Applies offset-based pagination to the query builder.
|
|
287
287
|
*
|
|
@@ -303,6 +303,35 @@ export interface FilterAdapter {
|
|
|
303
303
|
rows: unknown[];
|
|
304
304
|
total: number;
|
|
305
305
|
}>;
|
|
306
|
+
/**
|
|
307
|
+
* Executes an already-built DISTINCT projection (filters/sort/pagination —
|
|
308
|
+
* and {@link applyDistinct} itself — already applied to `qb`) WITHOUT entity
|
|
309
|
+
* hydration, returning plain rows containing exactly the distinct-projected
|
|
310
|
+
* `fields`, plus the total count of distinct tuples (ignoring limit/offset,
|
|
311
|
+
* consistent with how {@link getResultAndCount}'s total is computed).
|
|
312
|
+
*
|
|
313
|
+
* A DISTINCT projection selects no primary key column, so hydrating rows
|
|
314
|
+
* into entity instances (what {@link getResultAndCount} does) throws — e.g.
|
|
315
|
+
* MikroORM's "cannot merge entity without identifier". This method executes
|
|
316
|
+
* the raw projection instead, mapping DB columns back to the requested
|
|
317
|
+
* property names.
|
|
318
|
+
*
|
|
319
|
+
* Optional — required only when `FilterRunner.findAndCount` is called with a
|
|
320
|
+
* `distinct` projection; `findAndCount` throws if the adapter doesn't
|
|
321
|
+
* implement it.
|
|
322
|
+
*
|
|
323
|
+
* @param qb - The query builder instance, with the distinct projection
|
|
324
|
+
* (and filters/sort/pagination) already applied.
|
|
325
|
+
* @param fields - The distinct-projected field names (already validated
|
|
326
|
+
* against the entity's allowlist/metadata).
|
|
327
|
+
* @param entity - The root entity class.
|
|
328
|
+
* @returns The distinct rows (plain objects keyed by `fields`) and the
|
|
329
|
+
* total distinct-tuple count (limit/offset-independent).
|
|
330
|
+
*/
|
|
331
|
+
getDistinctResultAndCount?(qb: unknown, fields: string[], entity: Type<unknown>): Promise<{
|
|
332
|
+
rows: Record<string, unknown>[];
|
|
333
|
+
total: number;
|
|
334
|
+
}>;
|
|
306
335
|
/**
|
|
307
336
|
* Executes the query builder and returns the matching rows (no count). Used
|
|
308
337
|
* by `FilterRunner.findPage` for cursor/keyset pagination, where a total
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb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CAAC,OAAO,EAAE,CAAC,CAAC;IAE5C;;;;;;;;OAQG;IACH,aAAa,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IAErD;;;;;;;;;;;;;;;;OAgBG;IACH,qBAAqB,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEjF;;;;;;;;;;;OAWG;IACH,wBAAwB,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhF;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FilterMetadata } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a client-supplied field name to its declared `@Filterable`
|
|
4
|
+
* `aliases` target, or returns `field` unchanged when no alias applies.
|
|
5
|
+
*
|
|
6
|
+
* This is the single choke point for alias resolution — call it at every
|
|
7
|
+
* point where a client-supplied field name is about to be resolved against
|
|
8
|
+
* the entity (`where[]` column filters, structured `filter` keys, `sort`,
|
|
9
|
+
* `distinct`, `select`). It must run FIRST, before any validation (allowlist,
|
|
10
|
+
* `SAFE_FIELD` path check, entity-metadata lookup, `@FilterFor`/computed/
|
|
11
|
+
* auto-field dispatch) — those all evaluate the resolved target, never the
|
|
12
|
+
* alias key.
|
|
13
|
+
*
|
|
14
|
+
* Aliases do not cascade: the returned target is never re-run through the
|
|
15
|
+
* alias map, even when it happens to also be a declared alias key itself —
|
|
16
|
+
* this is what makes alias cycles structurally impossible.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveFieldAlias(meta: FilterMetadata | undefined, field: string): string;
|
|
19
|
+
//# sourceMappingURL=aliases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aliases.d.ts","sourceRoot":"","sources":["../../src/decorator/aliases.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAmBlD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMzF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field names that would resolve to inherited `Object.prototype` members
|
|
3
|
+
* (`__proto__`, `constructor`, `prototype`, `toString`, `valueOf`) if looked
|
|
4
|
+
* up on a plain-object `aliases` map without an own-property check. Mirrors
|
|
5
|
+
* the `BLOCKED_KEYS` guard in `input/normalizer.ts` — a client-supplied
|
|
6
|
+
* field name is never trusted as an alias-map lookup key without this check,
|
|
7
|
+
* even though `Object.hasOwn` below already excludes inherited properties;
|
|
8
|
+
* kept as explicit defense-in-depth.
|
|
9
|
+
*/
|
|
10
|
+
const BLOCKED_ALIAS_KEYS = new Set([
|
|
11
|
+
'__proto__',
|
|
12
|
+
'constructor',
|
|
13
|
+
'prototype',
|
|
14
|
+
'toString',
|
|
15
|
+
'valueOf',
|
|
16
|
+
]);
|
|
17
|
+
/**
|
|
18
|
+
* Resolves a client-supplied field name to its declared `@Filterable`
|
|
19
|
+
* `aliases` target, or returns `field` unchanged when no alias applies.
|
|
20
|
+
*
|
|
21
|
+
* This is the single choke point for alias resolution — call it at every
|
|
22
|
+
* point where a client-supplied field name is about to be resolved against
|
|
23
|
+
* the entity (`where[]` column filters, structured `filter` keys, `sort`,
|
|
24
|
+
* `distinct`, `select`). It must run FIRST, before any validation (allowlist,
|
|
25
|
+
* `SAFE_FIELD` path check, entity-metadata lookup, `@FilterFor`/computed/
|
|
26
|
+
* auto-field dispatch) — those all evaluate the resolved target, never the
|
|
27
|
+
* alias key.
|
|
28
|
+
*
|
|
29
|
+
* Aliases do not cascade: the returned target is never re-run through the
|
|
30
|
+
* alias map, even when it happens to also be a declared alias key itself —
|
|
31
|
+
* this is what makes alias cycles structurally impossible.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveFieldAlias(meta, field) {
|
|
34
|
+
const aliases = meta?.aliases;
|
|
35
|
+
if (!aliases || BLOCKED_ALIAS_KEYS.has(field) || !Object.hasOwn(aliases, field)) {
|
|
36
|
+
return field;
|
|
37
|
+
}
|
|
38
|
+
return aliases[field] ?? field;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=aliases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aliases.js","sourceRoot":"","sources":["../../src/decorator/aliases.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,WAAW;IACX,aAAa;IACb,WAAW;IACX,UAAU;IACV,SAAS;CACV,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAgC,EAAE,KAAa;IAC/E,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,CAAC;IAC9B,IAAI,CAAC,OAAO,IAAI,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;QAChF,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import type { FilterFieldTypeHint } from './filter-for.decorator.js';
|
|
3
|
+
/** Options for `@Computed`. */
|
|
4
|
+
export interface ComputedOptions {
|
|
5
|
+
/** Codegen-only value-type hint for filtering the computed field. No runtime
|
|
6
|
+
* effect. Same shape as `@FilterFor`'s `type`. */
|
|
7
|
+
type?: FilterFieldTypeHint;
|
|
8
|
+
}
|
|
9
|
+
/** Declares a computed/virtual field whose SQL source is the decorated method's
|
|
10
|
+
* return value (a string, raw fragment, or ORM query builder). The alias
|
|
11
|
+
* defaults to the method name.
|
|
12
|
+
*
|
|
13
|
+
* Supports both an explicit alias and an opts-first form (opts object as the
|
|
14
|
+
* sole/first argument), matching the approved spec's primary usage of
|
|
15
|
+
* `@Computed({ type: 'number' })` with no alias:
|
|
16
|
+
* - `@Computed()` — alias = method name, no opts
|
|
17
|
+
* - `@Computed({ type: 'number' })` — alias = method name, opts first
|
|
18
|
+
* - `@Computed('openSubwos')` — explicit alias
|
|
19
|
+
* - `@Computed('openSubwos', { type: 'number' })` — alias + opts
|
|
20
|
+
*/
|
|
21
|
+
export declare function Computed(opts?: ComputedOptions): MethodDecorator;
|
|
22
|
+
export declare function Computed(alias: string, opts?: ComputedOptions): MethodDecorator;
|
|
23
|
+
export declare function getComputedMap(target: object): Map<string, string>;
|
|
24
|
+
export declare function getComputedOptsMap(target: object): Map<string, ComputedOptions>;
|
|
25
|
+
//# sourceMappingURL=computed.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed.decorator.d.ts","sourceRoot":"","sources":["../../src/decorator/computed.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,+BAA+B;AAC/B,MAAM,WAAW,eAAe;IAC9B;sDACkD;IAClD,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,eAAe,CAAC;AAClE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,eAAe,CAAC;AA2BjF,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAclE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAW/E"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { COMPUTED_METADATA, COMPUTED_OPTS_METADATA } from '../tokens.js';
|
|
3
|
+
export function Computed(aliasOrOpts, maybeOpts) {
|
|
4
|
+
const alias = typeof aliasOrOpts === 'string' ? aliasOrOpts : undefined;
|
|
5
|
+
const opts = typeof aliasOrOpts === 'string' ? maybeOpts : aliasOrOpts;
|
|
6
|
+
return (target, propertyKey) => {
|
|
7
|
+
const methodName = String(propertyKey);
|
|
8
|
+
const key = alias ?? methodName;
|
|
9
|
+
const ctor = target.constructor;
|
|
10
|
+
const existing = (Reflect.getOwnMetadata(COMPUTED_METADATA, ctor) ??
|
|
11
|
+
new Map());
|
|
12
|
+
existing.set(key, methodName);
|
|
13
|
+
Reflect.defineMetadata(COMPUTED_METADATA, existing, ctor);
|
|
14
|
+
if (opts !== undefined) {
|
|
15
|
+
const existingOpts = (Reflect.getOwnMetadata(COMPUTED_OPTS_METADATA, ctor) ??
|
|
16
|
+
new Map());
|
|
17
|
+
existingOpts.set(key, opts);
|
|
18
|
+
Reflect.defineMetadata(COMPUTED_OPTS_METADATA, existingOpts, ctor);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const computedMapCache = new WeakMap();
|
|
23
|
+
export function getComputedMap(target) {
|
|
24
|
+
const cached = computedMapCache.get(target);
|
|
25
|
+
if (cached)
|
|
26
|
+
return cached;
|
|
27
|
+
const result = new Map();
|
|
28
|
+
let current = target;
|
|
29
|
+
while (current && current !== Function.prototype && current !== Object) {
|
|
30
|
+
const own = Reflect.getOwnMetadata(COMPUTED_METADATA, current);
|
|
31
|
+
if (own)
|
|
32
|
+
for (const [key, method] of own)
|
|
33
|
+
if (!result.has(key))
|
|
34
|
+
result.set(key, method);
|
|
35
|
+
current = Object.getPrototypeOf(current);
|
|
36
|
+
}
|
|
37
|
+
computedMapCache.set(target, result);
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
export function getComputedOptsMap(target) {
|
|
41
|
+
const result = new Map();
|
|
42
|
+
let current = target;
|
|
43
|
+
while (current && current !== Function.prototype && current !== Object) {
|
|
44
|
+
const own = Reflect.getOwnMetadata(COMPUTED_OPTS_METADATA, current);
|
|
45
|
+
if (own)
|
|
46
|
+
for (const [key, o] of own)
|
|
47
|
+
if (!result.has(key))
|
|
48
|
+
result.set(key, o);
|
|
49
|
+
current = Object.getPrototypeOf(current);
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=computed.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed.decorator.js","sourceRoot":"","sources":["../../src/decorator/computed.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAwBzE,MAAM,UAAU,QAAQ,CACtB,WAAsC,EACtC,SAA2B;IAE3B,MAAM,KAAK,GAAG,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,MAAM,IAAI,GAAG,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;IACvE,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;QAC7B,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QACvC,MAAM,GAAG,GAAG,KAAK,IAAI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GAAG,CAAC,GAAG,CAAC;oBAAE,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACxF,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IACD,gBAAgB,CAAC,GAAG,CAAC,MAAkB,EAAE,MAAM,CAAC,CAAC;IACjD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,MAAM,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAC;IAClD,IAAI,OAAO,GAAkB,MAAM,CAAC;IACpC,OAAO,OAAO,IAAI,OAAO,KAAK,QAAQ,CAAC,SAAS,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvE,MAAM,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC,sBAAsB,EAAE,OAAO,CAErD,CAAC;QACd,IAAI,GAAG;YAAE,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,GAAG;gBAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;oBAAE,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAC9E,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterable.decorator.d.ts","sourceRoot":"","sources":["../../src/decorator/filterable.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErE,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"filterable.decorator.d.ts","sourceRoot":"","sources":["../../src/decorator/filterable.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErE,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,cAAc,CAuBrE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAEhF"}
|
|
@@ -17,6 +17,10 @@ export function Filterable(options) {
|
|
|
17
17
|
...(options.throwOnInvalid !== undefined && { throwOnInvalid: options.throwOnInvalid }),
|
|
18
18
|
...(options.defaultSort !== undefined && { defaultSort: options.defaultSort }),
|
|
19
19
|
...(options.computed !== undefined && { computed: options.computed }),
|
|
20
|
+
...(options.aliases !== undefined && { aliases: options.aliases }),
|
|
21
|
+
// Metadata only — consumed statically (ts-morph AST) by
|
|
22
|
+
// @dudousxd/nestjs-filter-codegen; the runtime never reads this.
|
|
23
|
+
...(options.codegen !== undefined && { codegen: options.codegen }),
|
|
20
24
|
};
|
|
21
25
|
Reflect.defineMetadata(FILTERABLE_METADATA, meta, target);
|
|
22
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterable.decorator.js","sourceRoot":"","sources":["../../src/decorator/filterable.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,MAAM,UAAU,UAAU,CAAC,OAA0B;IACnD,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YAChC,MAAM,IAAI,4BAA4B,CAAC,MAAM,CAAC,IAAI,IAAI,iBAAiB,CAAC,CAAC;QAC3E,CAAC;QACD,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACvC,MAAM,IAA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EntityFieldInfo, EntityRelationInfo, VectorSearchOp
|
|
|
4
4
|
export { Filterable, getFilterableMetadata } from './decorator/filterable.decorator.js';
|
|
5
5
|
export { normalizeAllowed, allowedFieldNames } from './decorator/allowed.js';
|
|
6
6
|
export type { NormalizedAllowed } from './decorator/allowed.js';
|
|
7
|
+
export { resolveFieldAlias } from './decorator/aliases.js';
|
|
7
8
|
export { FilterFor, getFilterForMap, getFilterForOptsMap, } from './decorator/filter-for.decorator.js';
|
|
8
9
|
export type { FilterFieldTypeHint, FilterForOptions, } from './decorator/filter-for.decorator.js';
|
|
10
|
+
export { Computed, getComputedMap, getComputedOptsMap } from './decorator/computed.decorator.js';
|
|
11
|
+
export type { ComputedOptions } from './decorator/computed.decorator.js';
|
|
12
|
+
export type { ComputedContext, ComputedReturn, ComputedSource, ComputedEntry, ComputedMap, } from './types.js';
|
|
9
13
|
export { ApplyFilter, getApplyFilterMetadata } from './decorator/apply-filter.decorator.js';
|
|
10
14
|
export { Relations, getRelationsMap, resolveRelation } from './decorator/relations.decorator.js';
|
|
11
15
|
export type { RelationConfig, RelationsMap } from './decorator/relations.decorator.js';
|
|
@@ -16,7 +20,7 @@ export { FilterExceptionFilter } from './filter/filter-exception.filter.js';
|
|
|
16
20
|
export { FilterRunner } from './runner.js';
|
|
17
21
|
export { FilterModule } from './module.js';
|
|
18
22
|
export { FilterException, FilterNotRegisteredException, FilterMissingEntityException, FilterStateUnavailableException, UnknownFilterKeyException, FilterValidationException, FilterMissingAdapterException, FilterMethodException, } from './errors/exceptions.js';
|
|
19
|
-
export { FILTER_MODULE_OPTIONS, FILTER_ADAPTER, FILTERABLE_METADATA, FILTER_FOR_METADATA, FILTER_FOR_OPTS_METADATA, FILTER_RELATIONS_METADATA, APPLY_FILTER_METADATA, APPLY_FILTER_REQ_KEY, TENANT_SCOPED_METADATA, CONTEXT_ACCESSOR, } from './tokens.js';
|
|
23
|
+
export { FILTER_MODULE_OPTIONS, FILTER_ADAPTER, FILTERABLE_METADATA, FILTER_FOR_METADATA, FILTER_FOR_OPTS_METADATA, COMPUTED_METADATA, COMPUTED_OPTS_METADATA, FILTER_RELATIONS_METADATA, APPLY_FILTER_METADATA, APPLY_FILTER_REQ_KEY, TENANT_SCOPED_METADATA, CONTEXT_ACCESSOR, } from './tokens.js';
|
|
20
24
|
export type { AllowedFieldEntry, ApplyFilterOptions, CursorPage, CursorPagination, EntityDescription, FieldMeta, FilterableOptions, FilterContext, FilterInput, FilterInputStrict, FilterInputLoose, FilterMetadata, FilterModuleOptions, FilterModuleOptionsFactory, FilterModuleAsyncOptions, InputFormat, InputNormalizer, InputSource, OffsetPagination, OnUnknownKey, RelationMeta, SortItem, StructuredInput, ValidationMode, } from './types.js';
|
|
21
25
|
export { resolveInputFromRequest } from './input/source-resolver.js';
|
|
22
26
|
export { normalizeInput } from './input/normalizer.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EACV,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EACL,SAAS,EACT,eAAe,EACf,mBAAmB,GACpB,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EACV,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE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 @@ export const VERSION = '0.0.0';
|
|
|
2
2
|
export { BaseFilter } from './base-filter.js';
|
|
3
3
|
export { Filterable, getFilterableMetadata } from './decorator/filterable.decorator.js';
|
|
4
4
|
export { normalizeAllowed, allowedFieldNames } from './decorator/allowed.js';
|
|
5
|
+
export { resolveFieldAlias } from './decorator/aliases.js';
|
|
5
6
|
export { FilterFor, getFilterForMap, getFilterForOptsMap, } from './decorator/filter-for.decorator.js';
|
|
7
|
+
export { Computed, getComputedMap, getComputedOptsMap } from './decorator/computed.decorator.js';
|
|
6
8
|
export { ApplyFilter, getApplyFilterMetadata } from './decorator/apply-filter.decorator.js';
|
|
7
9
|
export { Relations, getRelationsMap, resolveRelation } from './decorator/relations.decorator.js';
|
|
8
10
|
export { TenantScoped, getTenantScopedField, } from './decorator/tenant-scoped.decorator.js';
|
|
@@ -11,7 +13,7 @@ export { FilterExceptionFilter } from './filter/filter-exception.filter.js';
|
|
|
11
13
|
export { FilterRunner } from './runner.js';
|
|
12
14
|
export { FilterModule } from './module.js';
|
|
13
15
|
export { FilterException, FilterNotRegisteredException, FilterMissingEntityException, FilterStateUnavailableException, UnknownFilterKeyException, FilterValidationException, FilterMissingAdapterException, FilterMethodException, } from './errors/exceptions.js';
|
|
14
|
-
export { FILTER_MODULE_OPTIONS, FILTER_ADAPTER, FILTERABLE_METADATA, FILTER_FOR_METADATA, FILTER_FOR_OPTS_METADATA, FILTER_RELATIONS_METADATA, APPLY_FILTER_METADATA, APPLY_FILTER_REQ_KEY, TENANT_SCOPED_METADATA, CONTEXT_ACCESSOR, } from './tokens.js';
|
|
16
|
+
export { FILTER_MODULE_OPTIONS, FILTER_ADAPTER, FILTERABLE_METADATA, FILTER_FOR_METADATA, FILTER_FOR_OPTS_METADATA, COMPUTED_METADATA, COMPUTED_OPTS_METADATA, FILTER_RELATIONS_METADATA, APPLY_FILTER_METADATA, APPLY_FILTER_REQ_KEY, TENANT_SCOPED_METADATA, CONTEXT_ACCESSOR, } from './tokens.js';
|
|
15
17
|
export { resolveInputFromRequest } from './input/source-resolver.js';
|
|
16
18
|
export { normalizeInput } from './input/normalizer.js';
|
|
17
19
|
export { parseSpatieInput } from './input/spatie-parser.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAO9C,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE7E,OAAO,EACL,SAAS,EACT,eAAe,EACf,mBAAmB,GACpB,MAAM,qCAAqC,CAAC;AAK7C,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAEjG,OAAO,EACL,YAAY,EACZ,oBAAoB,GACrB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,eAAe,EACf,4BAA4B,EAC5B,4BAA4B,EAC5B,+BAA+B,EAC/B,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB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gB,EAChB,gBAAgB,EAChB,cAAc,EACd,mBAAmB,GACpB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/runner.d.ts
CHANGED
|
@@ -2,7 +2,23 @@ import { type Type } from '@nestjs/common';
|
|
|
2
2
|
import { ModuleRef } from '@nestjs/core';
|
|
3
3
|
import type { FilterAdapter } from './adapter/adapter.js';
|
|
4
4
|
import type { ContextAccessor } from './context-accessor.js';
|
|
5
|
-
import type { CursorPage, EntityDescription, FilterContext, FilterModuleOptions, SortItem } from './types.js';
|
|
5
|
+
import type { ComputedSource, CursorPage, EntityDescription, FilterContext, FilterModuleOptions, SortItem } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Merges the inline `@Filterable.computed` map and `@Computed`-decorated
|
|
8
|
+
* methods into a single alias → {@link ComputedSource} registry.
|
|
9
|
+
*
|
|
10
|
+
* - Inline map entries are unwrapped: `{ source, type }` → `.source` (the
|
|
11
|
+
* `type` is a codegen-only hint, never read at runtime).
|
|
12
|
+
* - `@Computed` methods are bound to `instance` and wrapped so they satisfy
|
|
13
|
+
* the `ComputedSource` function shape (`(ctx) => ComputedReturn`).
|
|
14
|
+
* - On an alias clash between the inline map and a decorator method, the
|
|
15
|
+
* decorator wins — it is the more specific, closer-to-usage declaration.
|
|
16
|
+
*
|
|
17
|
+
* `FilterClass` (the constructor) is the metadata target — matching
|
|
18
|
+
* `getFilterableMetadata`/`getFilterForMap`'s convention — while `instance` is
|
|
19
|
+
* used only to bind decorated methods.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildComputedRegistry(FilterClass: Function, instance: object): Map<string, ComputedSource>;
|
|
6
22
|
export declare class FilterRunner {
|
|
7
23
|
private readonly moduleRef;
|
|
8
24
|
private readonly options;
|
|
@@ -43,6 +59,38 @@ export declare class FilterRunner {
|
|
|
43
59
|
* gate reports skips in one consistent format.
|
|
44
60
|
*/
|
|
45
61
|
private warnUnsupported;
|
|
62
|
+
/**
|
|
63
|
+
* Remaps a parsed field list through `@Filterable.aliases`. Used by
|
|
64
|
+
* `distinct`/`select` (via {@link applyProjection}) and the pre-execution
|
|
65
|
+
* distinct-field resolution `findAndCount` does ahead of `applyDynamic`.
|
|
66
|
+
* A no-op when `meta` declares no aliases.
|
|
67
|
+
*/
|
|
68
|
+
private remapFieldAliases;
|
|
69
|
+
/**
|
|
70
|
+
* Remaps `SortItem.field` through `@Filterable.aliases`. Only the
|
|
71
|
+
* client-supplied sort is ever passed through this — `defaultSort` is
|
|
72
|
+
* developer-declared server config, already written in real entity-path
|
|
73
|
+
* terms, so it never needs (or gets) alias resolution.
|
|
74
|
+
*/
|
|
75
|
+
private remapSortAliases;
|
|
76
|
+
/**
|
|
77
|
+
* Remaps every input key through `@Filterable.aliases`. Called right after
|
|
78
|
+
* normalization and BEFORE class-validator (`validateInput`) and
|
|
79
|
+
* @FilterFor/relation/computed/auto-field dispatch, so decorators and
|
|
80
|
+
* dispatch logic keyed by the real entity path see the resolved key, never
|
|
81
|
+
* the alias — an alias pointing at a computed field name resolves to that
|
|
82
|
+
* computed field, an alias pointing at a `@FilterFor` key dispatches to
|
|
83
|
+
* that method, etc.
|
|
84
|
+
*/
|
|
85
|
+
private remapAliasedKeys;
|
|
86
|
+
/**
|
|
87
|
+
* Remaps every `field` in a `where[]` ColumnFilter tree through
|
|
88
|
+
* `@Filterable.aliases`, recursing into AND/OR groups. Run BEFORE operator-
|
|
89
|
+
* allowlist enforcement, `validateColumnFilters`, and (in dynamic mode)
|
|
90
|
+
* `pruneUnknownColumnFilters` — those all validate the resolved target,
|
|
91
|
+
* never the alias key.
|
|
92
|
+
*/
|
|
93
|
+
private remapColumnFilterAliases;
|
|
46
94
|
/**
|
|
47
95
|
* Describes an entity's filterable/sortable scalar fields and its one-hop
|
|
48
96
|
* relations, read entirely from the ORM's metadata (via the adapter) — no
|
|
@@ -180,6 +228,15 @@ export declare class FilterRunner {
|
|
|
180
228
|
rows: E[];
|
|
181
229
|
total: number;
|
|
182
230
|
}>;
|
|
231
|
+
/**
|
|
232
|
+
* Resolves and validates dynamic-mode (no filter-class allowlist) distinct
|
|
233
|
+
* fields from raw structured input, mirroring the validation `applyProjection`
|
|
234
|
+
* performs when it applies distinct to the query builder inside `applyDynamic`.
|
|
235
|
+
* Used by `findAndCount` to decide — before mutating the query builder —
|
|
236
|
+
* whether to route execution to `getDistinctResultAndCount`, and with which
|
|
237
|
+
* exact (already-validated) field list.
|
|
238
|
+
*/
|
|
239
|
+
private resolveDynamicDistinctFields;
|
|
183
240
|
/**
|
|
184
241
|
* Runs a dynamic query with **keyset (cursor) pagination** and executes it,
|
|
185
242
|
* returning a stable, non-overlapping page plus opaque forward/backward
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,IAAI,EACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,IAAI,EACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA8B7D,OAAO,KAAK,EAEV,cAAc,EACd,UAAU,EACV,iBAAiB,EAEjB,aAAa,EAEb,mBAAmB,EAEnB,QAAQ,EACT,MAAM,YAAY,CAAC;AAWpB;;;;;;;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