mongoose-query-find 3.0.6 → 3.0.7
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/README.md +468 -0
- package/dist/aggregate.d.ts +177 -0
- package/dist/aggregate.d.ts.map +1 -0
- package/dist/aggregate.js +733 -0
- package/dist/aggregate.js.map +1 -0
- package/dist/find.d.ts +243 -0
- package/dist/find.d.ts.map +1 -0
- package/dist/find.js +740 -0
- package/dist/find.js.map +1 -0
- package/dist/index.d.ts +2 -242
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -737
- package/dist/index.js.map +1 -1
- package/package.json +78 -65
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ A fluent, chainable query builder for Mongoose that handles filtering, global se
|
|
|
10
10
|
|
|
11
11
|
## Table of Contents
|
|
12
12
|
|
|
13
|
+
**QueryFind**
|
|
14
|
+
|
|
13
15
|
- [Installation](#installation)
|
|
14
16
|
- [Quick Start](#quick-start)
|
|
15
17
|
- [Constructor](#constructor)
|
|
@@ -30,6 +32,32 @@ A fluent, chainable query builder for Mongoose that handles filtering, global se
|
|
|
30
32
|
- [Links](#links)
|
|
31
33
|
- [License](#license)
|
|
32
34
|
|
|
35
|
+
**QueryAggregate**
|
|
36
|
+
|
|
37
|
+
- [Overview](#queryaggregate-overview)
|
|
38
|
+
- [When to use QueryAggregate vs QueryFind](#when-to-use-queryaggregate-vs-queryfind)
|
|
39
|
+
- [Installation](#installation-1)
|
|
40
|
+
- [Quick Start](#quick-start-1)
|
|
41
|
+
- [Constructor & Options](#constructor--options-1)
|
|
42
|
+
- [Timezone Handling](#timezone-handling)
|
|
43
|
+
- [Builder Methods](#builder-methods-1)
|
|
44
|
+
- [.allowFields()](#allowfieldsfields-string-1)
|
|
45
|
+
- [.dateFields()](#datefieldsfields-string)
|
|
46
|
+
- [.filter()](#filter-1)
|
|
47
|
+
- [.where()](#whereconditions-1)
|
|
48
|
+
- [.range()](#rangefield-string-preset-rangepreset)
|
|
49
|
+
- [.globalSearch()](#globalsearchfields-string-1)
|
|
50
|
+
- [.sort()](#sort-1)
|
|
51
|
+
- [.project()](#projectdefaultprojection-string--recordstring-0--1)
|
|
52
|
+
- [.lookup()](#lookupopts-lookupoptions)
|
|
53
|
+
- [.addStage()](#addstagestage-pipelinestage)
|
|
54
|
+
- [Terminal Method](#terminal-method-1)
|
|
55
|
+
- [.paginate()](#paginatecachedtotal-number)
|
|
56
|
+
- [Recipes](#recipes)
|
|
57
|
+
- [Pipeline Stage Ordering](#pipeline-stage-ordering)
|
|
58
|
+
- [Security](#security-1)
|
|
59
|
+
- [TypeScript Types](#typescript-types-1)
|
|
60
|
+
|
|
33
61
|
---
|
|
34
62
|
|
|
35
63
|
## Installation
|
|
@@ -405,3 +433,443 @@ interface QueryFindOptions {
|
|
|
405
433
|
## License
|
|
406
434
|
|
|
407
435
|
ISC © [jsdev.robin@gmail.com](mailto:jsdev.robin@gmail.com)
|
|
436
|
+
|
|
437
|
+
<br>
|
|
438
|
+
<br>
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
---
|
|
443
|
+
|
|
444
|
+
# QueryAggregate
|
|
445
|
+
|
|
446
|
+
A fluent, allowlisted **aggregation-pipeline** builder for Mongoose (`^8 || ^9`), built on `Model.aggregate()`. It mirrors the same safety model as `QueryFind` — allowlisted filter fields, sanitized/rejected operators, capped pagination — but adds `$lookup` joins, `$group`, and any other pipeline-only stage, plus timezone-aware date filtering.
|
|
447
|
+
|
|
448
|
+
## QueryAggregate Overview
|
|
449
|
+
|
|
450
|
+
`QueryFind` is built on `Model.find()` and can't express joins or grouping. `QueryAggregate` solves that while keeping the same guardrails:
|
|
451
|
+
|
|
452
|
+
- Allowlisted filter/sort/projection fields
|
|
453
|
+
- Recursive sanitization of client input (drops class instances, functions, over-deep nesting)
|
|
454
|
+
- Banned-operator rejection (`$where`, `$expr`, `$function`, `$accumulator`, `$map`, `$reduce`, `$filter`)
|
|
455
|
+
- Capped pagination (`limit`, `page`)
|
|
456
|
+
- **New:** timezone-aware date coercion, `$lookup` joins, arbitrary developer-authored pipeline stages via `.addStage()`, and single-round-trip pagination via `$facet`
|
|
457
|
+
|
|
458
|
+
## When to use QueryAggregate vs QueryFind
|
|
459
|
+
|
|
460
|
+
| Need | Use |
|
|
461
|
+
| ------------------------------------------------------------- | ---------------- |
|
|
462
|
+
| Simple filter/sort/paginate on one collection | `QueryFind` |
|
|
463
|
+
| Joining another collection (`$lookup`) | `QueryAggregate` |
|
|
464
|
+
| Grouping / rollups / computed fields (`$group`, `$addFields`) | `QueryAggregate` |
|
|
465
|
+
| Client filters need to respect the caller's local timezone | `QueryAggregate` |
|
|
466
|
+
| You need a custom developer-defined pipeline stage | `QueryAggregate` |
|
|
467
|
+
|
|
468
|
+
## Installation
|
|
469
|
+
|
|
470
|
+
Ships from the same package as `QueryFind`:
|
|
471
|
+
|
|
472
|
+
```bash
|
|
473
|
+
npm install mongoose-query-find
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
## Quick Start
|
|
477
|
+
|
|
478
|
+
```ts
|
|
479
|
+
import { QueryAggregate } from 'mongoose-query-find';
|
|
480
|
+
import CategoryModel from './models/category';
|
|
481
|
+
|
|
482
|
+
const timezone = (req.headers['x-timezone'] as string) ?? 'Asia/Dhaka';
|
|
483
|
+
|
|
484
|
+
const result = await new QueryAggregate(CategoryModel, req.query, { timezone })
|
|
485
|
+
.allowFields(['name', 'status', 'createdAt'])
|
|
486
|
+
.dateFields(['createdAt'])
|
|
487
|
+
.where({ branchId: req.self.linkedTo, status: { $ne: 'ARCHIVED' } })
|
|
488
|
+
.filter()
|
|
489
|
+
.globalSearch(['name'])
|
|
490
|
+
.sort()
|
|
491
|
+
.project('name status createdAt updatedAt')
|
|
492
|
+
.paginate();
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
`result` shape is identical to `QueryFind`'s `PaginatedResult<T>`:
|
|
496
|
+
|
|
497
|
+
```json
|
|
498
|
+
{
|
|
499
|
+
"data": [...],
|
|
500
|
+
"total": 84,
|
|
501
|
+
"page": 2,
|
|
502
|
+
"totalPages": 9,
|
|
503
|
+
"limit": 10,
|
|
504
|
+
"hasNextPage": true,
|
|
505
|
+
"hasPrevPage": true
|
|
506
|
+
}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
## Constructor & Options
|
|
510
|
+
|
|
511
|
+
```ts
|
|
512
|
+
new QueryAggregate<T>(model, queryString, options?);
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
| Parameter | Type | Description |
|
|
516
|
+
| ------------- | ----------------------- | ----------------------------------------------- |
|
|
517
|
+
| `model` | `Model<T>` | A Mongoose model |
|
|
518
|
+
| `queryString` | `QueryParams` | Parsed URL query object, e.g. `req.query` |
|
|
519
|
+
| `options` | `QueryAggregateOptions` | Configuration options (see below), all optional |
|
|
520
|
+
|
|
521
|
+
### `QueryAggregateOptions`
|
|
522
|
+
|
|
523
|
+
| Option | Type | Default | Description |
|
|
524
|
+
| ---------------------- | ---------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
525
|
+
| `timezone` | `string` | `'Asia/Dhaka'` | IANA timezone for interpreting client-supplied local dates. Invalid values fall back to the default (validated once at construction, never throws mid-query). |
|
|
526
|
+
| `maxTimeMS` | `number` | `5000` | Max time MongoDB may spend per query. `0` disables. |
|
|
527
|
+
| `slowQueryThresholdMS` | `number` | `maxTimeMS` | Threshold above which `onSlowQuery` fires. |
|
|
528
|
+
| `maxLimit` | `number` | `100` | Hard cap on `?limit=`. |
|
|
529
|
+
| `allowDiskUse` | `boolean` | `false` | Forwarded to `.allowDiskUse()` — enable for large sort/group pipelines. |
|
|
530
|
+
| `weekStartsOn` | `0–6` | `6` (Saturday) | Used by `.range('thisWeek')`. |
|
|
531
|
+
| `onSlowQuery` | `(info: SlowQueryInfo) => void` | — | Callback fired when a query exceeds `slowQueryThresholdMS`. |
|
|
532
|
+
| `onSanitizeDrop` | `(path: string, value: unknown) => void` | — | Callback fired whenever sanitization drops a value (bad nesting, non-plain value). |
|
|
533
|
+
|
|
534
|
+
## Timezone Handling
|
|
535
|
+
|
|
536
|
+
MongoDB always stores/compares dates in UTC. Clients think and filter in local time — `?createdAt=2026-09-01` means "Sept 1st in the caller's timezone," not UTC midnight.
|
|
537
|
+
|
|
538
|
+
- `fromZonedTime(localString, tz)` → exact UTC instant for a wall-clock time in `tz`. Used to turn a client-supplied local date into the correct `$gte`/`$lt` UTC range in `$match`.
|
|
539
|
+
- `toZonedTime(utcDate, tz)` → wall-clock `Date` for `tz`. Used to compute "what day is it right now, in the caller's timezone" for `.range()` presets.
|
|
540
|
+
|
|
541
|
+
The timezone is a **per-request** value, typically sourced from a header:
|
|
542
|
+
|
|
543
|
+
```ts
|
|
544
|
+
const timezone = (req.headers['x-timezone'] as string) ?? 'Asia/Dhaka';
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
An invalid/unknown IANA timezone string (bad header, typo) never throws — it's validated once at construction (`resolveTimezone`) and silently falls back to the default.
|
|
548
|
+
|
|
549
|
+
Plain `YYYY-MM-DD` filter values are expanded into a `$gte`/`$lt` range spanning that local day; values with an explicit offset (`Z`, `+06:00`) are treated as absolute instants and passed through as-is.
|
|
550
|
+
|
|
551
|
+
## Builder Methods
|
|
552
|
+
|
|
553
|
+
All builder methods return `this` and are fully chainable. Recommended call order:
|
|
554
|
+
|
|
555
|
+
```
|
|
556
|
+
allowFields → dateFields → where → range → filter → globalSearch → sort → project → lookup/addStage → paginate
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
---
|
|
560
|
+
|
|
561
|
+
### `.allowFields(fields: string[])`
|
|
562
|
+
|
|
563
|
+
Same role as in `QueryFind`: declares which fields the client may filter, sort, and project. Case-insensitive. Call before `.filter()`, `.sort()`, `.project()`.
|
|
564
|
+
|
|
565
|
+
```ts
|
|
566
|
+
.allowFields(['name', 'status', 'createdAt'])
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
---
|
|
570
|
+
|
|
571
|
+
### `.dateFields(fields: string[])`
|
|
572
|
+
|
|
573
|
+
Explicit list of fields treated as dates for timezone-aware coercion. When omitted, falls back to a name heuristic matching `createdAt`, `updatedAt`, `deletedAt`, `archivedAt`, `expiresAt`, `date`, `birthDate` (only when that word is the _last_ path segment, e.g. `user.updatedAt` matches, `updatedAtSomething` doesn't).
|
|
574
|
+
|
|
575
|
+
```ts
|
|
576
|
+
.dateFields(['createdAt', 'updatedAt'])
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
---
|
|
580
|
+
|
|
581
|
+
### `.filter()`
|
|
582
|
+
|
|
583
|
+
Parses `req.query` into the aggregation `$match` stage's client-derived portion. Runs, in order:
|
|
584
|
+
|
|
585
|
+
1. Strips reserved keys (`page`, `sort`, `limit`, `fields`, `q`)
|
|
586
|
+
2. `sanitize()` — recursively drops non-plain values (class instances, functions), capped at nesting depth 5
|
|
587
|
+
3. `coerceAll()` — timezone-aware date coercion + boolean coercion + operator-name coercion (`gt` → `$gt`, etc.)
|
|
588
|
+
4. `enforceAllowlist()` — strips any non-operator key not in `.allowFields()`
|
|
589
|
+
5. `rejectDisallowedOperators()` — throws `QueryAggregateValidationError` on `$where`, `$expr`, `$function`, `$accumulator`, `$map`, `$reduce`, `$filter`, or any unexpected top-level `$` operator
|
|
590
|
+
|
|
591
|
+
```
|
|
592
|
+
GET /categories?createdAt=2026-09-01&status=ACTIVE
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
```ts
|
|
596
|
+
.filter()
|
|
597
|
+
// → { createdAt: { $gte: <UTC midnight in tz>, $lt: <next UTC midnight in tz> }, status: 'ACTIVE' }
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
---
|
|
601
|
+
|
|
602
|
+
### `.where(conditions)`
|
|
603
|
+
|
|
604
|
+
Mandatory server-side conditions the client **cannot override** — kept in a separate internal bucket (`_serverConditions`) and merged last via `$and`, so URL params can never win against it.
|
|
605
|
+
|
|
606
|
+
```ts
|
|
607
|
+
.where({ branchId: req.self.linkedTo, status: { $ne: 'ARCHIVED' } })
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
---
|
|
611
|
+
|
|
612
|
+
### `.range(field: string, preset: RangePreset)`
|
|
613
|
+
|
|
614
|
+
Adds a hard, server-defined UTC date range on `field`, computed in this instance's timezone. Not client-overridable (goes into `_serverConditions`, same as `.where()`).
|
|
615
|
+
|
|
616
|
+
**Presets:** `'today'`, `'yesterday'`, `'last7Days'`, `'last30Days'`, `'thisWeek'`, `'thisMonth'`
|
|
617
|
+
|
|
618
|
+
```ts
|
|
619
|
+
.range('createdAt', 'last7Days')
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
`.range('thisWeek')` respects the `weekStartsOn` constructor option (defaults to Saturday).
|
|
623
|
+
|
|
624
|
+
---
|
|
625
|
+
|
|
626
|
+
### `.globalSearch(fields: string[])`
|
|
627
|
+
|
|
628
|
+
Identical behavior to `QueryFind`: case-insensitive `$or` regex search across the given fields when `?q=` is present (max 200 chars). Regex-escaped to prevent ReDoS. Fields are filtered against the allowlist first.
|
|
629
|
+
|
|
630
|
+
```ts
|
|
631
|
+
.globalSearch(['name'])
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
---
|
|
635
|
+
|
|
636
|
+
### `.sort()`
|
|
637
|
+
|
|
638
|
+
Parses `?sort=` (e.g. `-createdAt,name`), capped at 5 fields, dropping any field not in the allowlist. Falls back to `{ createdAt: -1 }` when absent.
|
|
639
|
+
|
|
640
|
+
```ts
|
|
641
|
+
.sort()
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
---
|
|
645
|
+
|
|
646
|
+
### `.project(defaultProjection?: string | Record<string, 0 | 1>)`
|
|
647
|
+
|
|
648
|
+
Controls the `$project` stage. Accepts a space-separated string (`"name status -_id"`) or a raw `{ field: 0 | 1 }` object.
|
|
649
|
+
|
|
650
|
+
- `?fields=` (when present) is parsed and filtered through the allowlist.
|
|
651
|
+
- If **every** requested field is blocked, falls back to `defaultProjection` rather than silently returning everything.
|
|
652
|
+
- `_id` and `__v` are always allowed through even if not in `allowFields()`.
|
|
653
|
+
|
|
654
|
+
```ts
|
|
655
|
+
.project('name status createdAt updatedAt')
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
> ⚠️ If a preceding `.addStage()` (e.g. `$group`) reshapes documents, `.project()`'s allowlist still only knows about the fields passed to `.allowFields()` — new computed fields may be silently dropped. Use `.addStage({ $project: {...} })` instead when you need full control post-reshape.
|
|
659
|
+
|
|
660
|
+
---
|
|
661
|
+
|
|
662
|
+
### `.lookup(opts: LookupOptions)`
|
|
663
|
+
|
|
664
|
+
Adds a `$lookup` (join) stage, optionally followed by `$unwind`.
|
|
665
|
+
|
|
666
|
+
| Field | Type | Description |
|
|
667
|
+
| -------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
668
|
+
| `from` | `string` | Collection name (not the model name) to join against. |
|
|
669
|
+
| `as` | `string` | Output array field name. |
|
|
670
|
+
| `localField` | `string?` | Local join field. |
|
|
671
|
+
| `foreignField` | `string?` | Foreign join field. |
|
|
672
|
+
| `pipeline` | `PipelineStage[]?` | Sub-pipeline form of `$lookup`, for complex/correlated joins. Cannot contain `$out`/`$merge`. |
|
|
673
|
+
| `single` | `boolean?` | When `true`, `$unwind`s the joined array (`preserveNullAndEmptyArrays: true`) so `as` becomes a single object instead of an array. |
|
|
674
|
+
|
|
675
|
+
```ts
|
|
676
|
+
.lookup({
|
|
677
|
+
from: 'branches',
|
|
678
|
+
as: 'branch',
|
|
679
|
+
localField: 'branchId',
|
|
680
|
+
foreignField: '_id',
|
|
681
|
+
single: true,
|
|
682
|
+
})
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
---
|
|
686
|
+
|
|
687
|
+
### `.addStage(stage: PipelineStage)`
|
|
688
|
+
|
|
689
|
+
Escape hatch for any other developer-authored stage: `$addFields`, `$group`, a post-join `$match`, a custom `$sort`, etc.
|
|
690
|
+
|
|
691
|
+
- Blocks **only** `$out` / `$merge` (destructive stages).
|
|
692
|
+
- **Does not** run the client-input sanitizer/allowlist/operator-rejection — that only applies to `.filter()`/`.where()`, which parse untrusted `req.query`/`req.body` values.
|
|
693
|
+
- **Never pass raw client input directly into `.addStage()`.** It's for stages _you_ author server-side. If you need a client-supplied value inside a custom stage, validate/whitelist it yourself first.
|
|
694
|
+
|
|
695
|
+
```ts
|
|
696
|
+
.addStage({
|
|
697
|
+
$group: {
|
|
698
|
+
_id: '$status',
|
|
699
|
+
count: { $sum: 1 },
|
|
700
|
+
totalAmount: { $sum: '$amount' },
|
|
701
|
+
},
|
|
702
|
+
})
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
## Terminal Method
|
|
706
|
+
|
|
707
|
+
### `.paginate(cachedTotal?: number)`
|
|
708
|
+
|
|
709
|
+
Executes the pipeline and returns `Promise<PaginatedResult<T>>`.
|
|
710
|
+
|
|
711
|
+
- Uses `$facet` to fetch the data page and total count in a **single round trip**.
|
|
712
|
+
- Pass a prior page-1 `total` as `cachedTotal` on later pages to **skip the count stage entirely**.
|
|
713
|
+
- `maxTimeMS` / `allowDiskUse` from constructor options are applied to the aggregation.
|
|
714
|
+
- If the requested `page` exceeds `totalPages`, page `1` is returned automatically (with the real `total`/`totalPages` still reported).
|
|
715
|
+
- `onSlowQuery` (if configured) fires with `{ elapsedMs, pipeline, sort, page, limit }` when the query exceeds `slowQueryThresholdMS`.
|
|
716
|
+
|
|
717
|
+
> **Note:** `$facet` buffers both branches in memory per query. For very large collections with expensive pre-facet stages (heavy `$lookup`/`$group` before pagination), pass `cachedTotal` on subsequent pages, or run count/data as two separate calls instead.
|
|
718
|
+
|
|
719
|
+
```ts
|
|
720
|
+
const page1 = await builder.paginate();
|
|
721
|
+
const page2 = await builder.paginate(page1.total); // skips re-counting
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
## Recipes
|
|
725
|
+
|
|
726
|
+
**Join + post-join filter + group + paginate:**
|
|
727
|
+
|
|
728
|
+
```ts
|
|
729
|
+
const result = await new QueryAggregate(OrderModel, req.query, { timezone })
|
|
730
|
+
.allowFields(['status', 'createdAt'])
|
|
731
|
+
.dateFields(['createdAt'])
|
|
732
|
+
.filter()
|
|
733
|
+
.lookup({
|
|
734
|
+
from: 'customers',
|
|
735
|
+
as: 'customer',
|
|
736
|
+
localField: 'customerId',
|
|
737
|
+
foreignField: '_id',
|
|
738
|
+
single: true,
|
|
739
|
+
})
|
|
740
|
+
.addStage({ $match: { 'customer.vip': true } }) // server-defined, not client-controlled
|
|
741
|
+
.addStage({
|
|
742
|
+
$group: {
|
|
743
|
+
_id: '$customer._id',
|
|
744
|
+
customerName: { $first: '$customer.name' },
|
|
745
|
+
orderCount: { $sum: 1 },
|
|
746
|
+
},
|
|
747
|
+
})
|
|
748
|
+
.sort()
|
|
749
|
+
.paginate();
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
**Relative date range preset (server-enforced, not client-overridable):**
|
|
753
|
+
|
|
754
|
+
```ts
|
|
755
|
+
const result = await new QueryAggregate(OrderModel, req.query, { timezone })
|
|
756
|
+
.allowFields(['status'])
|
|
757
|
+
.where({ branchId: req.self.linkedTo })
|
|
758
|
+
.range('createdAt', 'last30Days')
|
|
759
|
+
.filter()
|
|
760
|
+
.sort()
|
|
761
|
+
.paginate();
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
**Correlated sub-pipeline `$lookup` (needs `let`):**
|
|
765
|
+
|
|
766
|
+
The built-in `LookupOptions` type doesn't expose `let` for correlated sub-pipelines. For that case, drop to `.addStage()` directly:
|
|
767
|
+
|
|
768
|
+
```ts
|
|
769
|
+
.addStage({
|
|
770
|
+
$lookup: {
|
|
771
|
+
from: 'orderItems',
|
|
772
|
+
let: { orderId: '$_id' },
|
|
773
|
+
pipeline: [
|
|
774
|
+
{ $match: { $expr: { $eq: ['$orderId', '$$orderId'] } } },
|
|
775
|
+
{ $project: { name: 1, qty: 1 } },
|
|
776
|
+
],
|
|
777
|
+
as: 'items',
|
|
778
|
+
},
|
|
779
|
+
})
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
## Pipeline Stage Ordering
|
|
783
|
+
|
|
784
|
+
The final pipeline is always assembled in this fixed order:
|
|
785
|
+
|
|
786
|
+
```
|
|
787
|
+
$match (from .where() + .filter() + .range() + .globalSearch(), merged via $and)
|
|
788
|
+
↓
|
|
789
|
+
[.lookup() / .addStage() calls, in the order you called them]
|
|
790
|
+
↓
|
|
791
|
+
$project (from .project(), if set)
|
|
792
|
+
↓
|
|
793
|
+
$sort (from .sort())
|
|
794
|
+
↓
|
|
795
|
+
[pagination: $skip/$limit, or $facet — added internally by .paginate()]
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
Implications:
|
|
799
|
+
|
|
800
|
+
- Anything added via `.addStage()` runs **after** the base filter match and **before** projection/sort.
|
|
801
|
+
- If you `$group`/reshape documents, do it before `.project()` — or skip `.project()` and use `.addStage({ $project: {...} })` for full control over the new shape.
|
|
802
|
+
- If you add your own `$sort` via `.addStage()` _and_ also call `.sort()`, both stages are included (the builder's `.sort()` stage is always appended last in the base pipeline) — harmless but redundant. Prefer one or the other.
|
|
803
|
+
|
|
804
|
+
## Security
|
|
805
|
+
|
|
806
|
+
| Protection | Detail |
|
|
807
|
+
| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
808
|
+
| **NoSQL injection** | Allowlist enforced on `.filter()`/`.sort()`/`.project()` via `.allowFields()` |
|
|
809
|
+
| **Banned operators** | `$where`, `$expr`, `$function`, `$accumulator`, `$map`, `$reduce`, `$filter` rejected recursively, any depth, in client input |
|
|
810
|
+
| **Destructive stages** | `$out` / `$merge` rejected in `.addStage()` / `.lookup()` sub-pipelines |
|
|
811
|
+
| **ReDoS** | `.globalSearch()` terms are regex-escaped before compilation |
|
|
812
|
+
| **Oversized search** | `?q=` capped at 200 characters |
|
|
813
|
+
| **Deep nesting DoS** | Client filter object nesting capped at depth 5 (`sanitize()`) |
|
|
814
|
+
| **Page size DoS** | `limit` hard-capped at `maxLimit` (default 100) |
|
|
815
|
+
| **Sort abuse** | Sort fields hard-capped at 5 |
|
|
816
|
+
| **Runaway queries** | `maxTimeMS` applied to the aggregation; `onSlowQuery` for observability |
|
|
817
|
+
| **Bad timezone input** | Invalid IANA zone validated once at construction, falls back to default, never throws mid-query |
|
|
818
|
+
| **Server condition override** | `.where()` / `.range()` conditions are merged last via `$and` — URL params can never override them |
|
|
819
|
+
| **Untrusted `.addStage()` input** | Not sanitized/allowlisted by design — documented as a trusted, developer-authored-only escape hatch |
|
|
820
|
+
|
|
821
|
+
> **Important:** `.addStage()` and the `pipeline` option in `.lookup()` are for **server-defined stages only**. They skip the sanitizer/allowlist/operator-rejection that protects `.filter()`/`.where()`. Never interpolate raw `req.query`/`req.body` values into an `.addStage()` call without validating them yourself first.
|
|
822
|
+
|
|
823
|
+
## TypeScript Types
|
|
824
|
+
|
|
825
|
+
```ts
|
|
826
|
+
import {
|
|
827
|
+
QueryAggregate,
|
|
828
|
+
QueryAggregateOptions,
|
|
829
|
+
QueryAggregateError,
|
|
830
|
+
QueryAggregateValidationError,
|
|
831
|
+
LookupOptions,
|
|
832
|
+
RangePreset,
|
|
833
|
+
SlowQueryInfo,
|
|
834
|
+
QueryParams,
|
|
835
|
+
PaginatedResult,
|
|
836
|
+
} from 'mongoose-query-find';
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
```ts
|
|
840
|
+
interface QueryAggregateOptions {
|
|
841
|
+
timezone?: string;
|
|
842
|
+
maxTimeMS?: number;
|
|
843
|
+
slowQueryThresholdMS?: number;
|
|
844
|
+
maxLimit?: number;
|
|
845
|
+
allowDiskUse?: boolean;
|
|
846
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
847
|
+
onSlowQuery?: (info: SlowQueryInfo) => void;
|
|
848
|
+
onSanitizeDrop?: (path: string, value: unknown) => void;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
interface LookupOptions {
|
|
852
|
+
from: string;
|
|
853
|
+
as: string;
|
|
854
|
+
localField?: string;
|
|
855
|
+
foreignField?: string;
|
|
856
|
+
pipeline?: PipelineStage[];
|
|
857
|
+
single?: boolean;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
type RangePreset =
|
|
861
|
+
| 'today'
|
|
862
|
+
| 'yesterday'
|
|
863
|
+
| 'last7Days'
|
|
864
|
+
| 'last30Days'
|
|
865
|
+
| 'thisWeek'
|
|
866
|
+
| 'thisMonth';
|
|
867
|
+
|
|
868
|
+
interface SlowQueryInfo {
|
|
869
|
+
elapsedMs: number;
|
|
870
|
+
pipeline: PipelineStage[];
|
|
871
|
+
sort: Record<string, 1 | -1>;
|
|
872
|
+
page: number;
|
|
873
|
+
limit: number;
|
|
874
|
+
}
|
|
875
|
+
```
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QueryAggregate - Fluent, allowlisted aggregation-pipeline builder for Mongoose (v8/v9)
|
|
3
|
+
*
|
|
4
|
+
* `QueryFind` (mongoose-query-find) is built on `Model.find()` and can't express
|
|
5
|
+
* `$lookup` joins, `$group`, or other pipeline-only stages. QueryAggregate mirrors
|
|
6
|
+
* the same safety model (allowlisted filter fields, sanitized operators, capped
|
|
7
|
+
* pagination) but is built on `Model.aggregate()`.
|
|
8
|
+
*
|
|
9
|
+
* ── Timezone handling ───────────────────────────────────────────────────────
|
|
10
|
+
* MongoDB always stores/compares dates in UTC. Clients think and filter in local
|
|
11
|
+
* time (e.g. ?createdAt=2026-09-01 means "Sept 1st in the caller's timezone",
|
|
12
|
+
* not UTC midnight). This builder resolves that with `date-fns-tz`:
|
|
13
|
+
*
|
|
14
|
+
* - fromZonedTime(localString, tz) -> the exact UTC instant for a wall-clock
|
|
15
|
+
* time in `tz`. Used to turn a client-supplied local date into the correct
|
|
16
|
+
* $gte/$lt UTC range for the pipeline's $match stage.
|
|
17
|
+
* - toZonedTime(utcDate, tz) -> the wall-clock Date for `tz`. Used to
|
|
18
|
+
* work out "what day is it right now, in the caller's timezone" for
|
|
19
|
+
* relative presets like .range('today').
|
|
20
|
+
*
|
|
21
|
+
* The timezone itself is a per-request value, passed in via constructor
|
|
22
|
+
* options rather than hardcoded, typically sourced from a header:
|
|
23
|
+
*
|
|
24
|
+
* const timezone = (req.headers['x-timezone'] as string) ?? 'Asia/Dhaka';
|
|
25
|
+
*
|
|
26
|
+
* const result = await new QueryAggregate(CategoryModel, req.query, { timezone })
|
|
27
|
+
* .allowFields(['name', 'status', 'createdAt'])
|
|
28
|
+
* .dateFields(['createdAt', 'updatedAt'])
|
|
29
|
+
* .where({ branchId: req.self.linkedTo, status: { $ne: CategoryStatus.ARCHIVED } })
|
|
30
|
+
* .filter()
|
|
31
|
+
* .globalSearch(['name'])
|
|
32
|
+
* .sort()
|
|
33
|
+
* .project('name status createdAt updatedAt')
|
|
34
|
+
* .paginate();
|
|
35
|
+
*
|
|
36
|
+
* An invalid/unknown IANA timezone string (bad header, typo, etc.) never
|
|
37
|
+
* throws mid-query — it's validated once at construction time and falls back
|
|
38
|
+
* to the default.
|
|
39
|
+
*
|
|
40
|
+
* ── Joins ────────────────────────────────────────────────────────────────────
|
|
41
|
+
* Use .lookup() for $lookup (+ optional $unwind), or .addStage() to inject any
|
|
42
|
+
* other developer-authored stage. .addStage() is for trusted, server-defined
|
|
43
|
+
* stages — it only blocks destructive stage types ($out/$merge). It does NOT
|
|
44
|
+
* run the client-input sanitizer; that only applies to .filter()/.where(),
|
|
45
|
+
* which parse untrusted req.query / req.body values.
|
|
46
|
+
*/
|
|
47
|
+
import { Model, PipelineStage } from 'mongoose';
|
|
48
|
+
export interface QueryParams {
|
|
49
|
+
page?: string;
|
|
50
|
+
limit?: string;
|
|
51
|
+
sort?: string;
|
|
52
|
+
fields?: string;
|
|
53
|
+
q?: string;
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
export interface PaginatedResult<T> {
|
|
57
|
+
data: T[];
|
|
58
|
+
total: number;
|
|
59
|
+
page: number;
|
|
60
|
+
totalPages: number;
|
|
61
|
+
limit: number;
|
|
62
|
+
hasNextPage: boolean;
|
|
63
|
+
hasPrevPage: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface SlowQueryInfo {
|
|
66
|
+
elapsedMs: number;
|
|
67
|
+
pipeline: PipelineStage[];
|
|
68
|
+
sort: Record<string, 1 | -1>;
|
|
69
|
+
page: number;
|
|
70
|
+
limit: number;
|
|
71
|
+
}
|
|
72
|
+
export type RangePreset = 'today' | 'yesterday' | 'last7Days' | 'last30Days' | 'thisWeek' | 'thisMonth';
|
|
73
|
+
export interface LookupOptions {
|
|
74
|
+
/** Collection name (not the model name) to join against. */
|
|
75
|
+
from: string;
|
|
76
|
+
/** Output array field name. */
|
|
77
|
+
as: string;
|
|
78
|
+
localField?: string;
|
|
79
|
+
foreignField?: string;
|
|
80
|
+
/** Sub-pipeline form of $lookup — use instead of localField/foreignField for complex joins. */
|
|
81
|
+
pipeline?: Exclude<PipelineStage, PipelineStage.Merge | PipelineStage.Out>[];
|
|
82
|
+
/** When true, $unwind the joined array (preserveNullAndEmptyArrays: true) so `as` becomes a single object. */
|
|
83
|
+
single?: boolean;
|
|
84
|
+
}
|
|
85
|
+
export interface QueryAggregateOptions {
|
|
86
|
+
/** IANA timezone used to interpret client-supplied local dates, e.g. "Asia/Dhaka". Validated at construction; invalid values fall back to the default. */
|
|
87
|
+
timezone?: string;
|
|
88
|
+
maxTimeMS?: number;
|
|
89
|
+
/** Threshold in ms above which onSlowQuery fires. Defaults to maxTimeMS. */
|
|
90
|
+
slowQueryThresholdMS?: number;
|
|
91
|
+
/** Maximum allowed `limit` per page. Defaults to 100. */
|
|
92
|
+
maxLimit?: number;
|
|
93
|
+
/** Forwarded to .allowDiskUse() — enable for large sort/group-heavy pipelines. */
|
|
94
|
+
allowDiskUse?: boolean;
|
|
95
|
+
/** 0 (Sun) – 6 (Sat). Used by range('thisWeek'). Defaults to 6 (Saturday). */
|
|
96
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
97
|
+
onSlowQuery?: (info: SlowQueryInfo) => void;
|
|
98
|
+
onSanitizeDrop?: (path: string, value: unknown) => void;
|
|
99
|
+
}
|
|
100
|
+
export declare class QueryAggregateError extends Error {
|
|
101
|
+
constructor(message: string);
|
|
102
|
+
}
|
|
103
|
+
export declare class QueryAggregateValidationError extends QueryAggregateError {
|
|
104
|
+
constructor(message: string);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Fluent aggregation-pipeline builder / paginator for Mongoose 8/9, with
|
|
108
|
+
* timezone-aware date filtering.
|
|
109
|
+
*/
|
|
110
|
+
export declare class QueryAggregate<T> {
|
|
111
|
+
private readonly model;
|
|
112
|
+
private readonly qs;
|
|
113
|
+
private readonly options;
|
|
114
|
+
private _allowedLookup;
|
|
115
|
+
private _canonicalMap;
|
|
116
|
+
private _dateFieldsLookup;
|
|
117
|
+
/** URL-derived filter and server conditions are kept separate so server
|
|
118
|
+
* conditions (merged last) can never be overridden by URL params. */
|
|
119
|
+
private _urlFilter;
|
|
120
|
+
private _serverConditions;
|
|
121
|
+
private _searchOr;
|
|
122
|
+
private _sort;
|
|
123
|
+
private _projection;
|
|
124
|
+
private _defaultProjection;
|
|
125
|
+
/** $lookup/$unwind/addStage() stages, in call order, spliced in after the base $match. */
|
|
126
|
+
private _stages;
|
|
127
|
+
private readonly _page;
|
|
128
|
+
private readonly _limit;
|
|
129
|
+
constructor(model: Model<T>, queryString: QueryParams, options?: QueryAggregateOptions);
|
|
130
|
+
/** The resolved (validated) timezone this instance is using. */
|
|
131
|
+
get timezone(): string;
|
|
132
|
+
/** Fields the client may filter, sort, and project. Case-insensitive. Call before filter()/sort()/project(). */
|
|
133
|
+
allowFields(fields: string[]): this;
|
|
134
|
+
/** Explicit list of fields treated as dates for timezone-aware coercion. Falls back to a name heuristic (createdAt/updatedAt/...) when omitted. */
|
|
135
|
+
dateFields(fields: string[]): this;
|
|
136
|
+
/** Parses URL query params (req.query) into a Mongoose filter. Only allowlisted fields pass through. */
|
|
137
|
+
filter(): this;
|
|
138
|
+
/** Mandatory server-side conditions the client cannot override — merged into the final $match last. */
|
|
139
|
+
where(conditions: Partial<Record<keyof T, unknown>>): this;
|
|
140
|
+
/** Adds a hard, server-defined UTC date range (in this instance's timezone) on `field`. Not client-overridable. */
|
|
141
|
+
range(field: string, preset: RangePreset): this;
|
|
142
|
+
/** Case-insensitive full-text search across the given fields when ?q= is present. */
|
|
143
|
+
globalSearch(fields: string[]): this;
|
|
144
|
+
/** Parses ?sort= (e.g. "-createdAt,name"). Fields not in allowFields() are dropped; falls back to DEFAULT_SORT. */
|
|
145
|
+
sort(): this;
|
|
146
|
+
/**
|
|
147
|
+
* Controls the $project stage. Accepts a space-separated string ("name status -_id")
|
|
148
|
+
* or a raw { field: 0|1 } object. When ?fields= is present it's parsed and
|
|
149
|
+
* filtered through the allowlist; if every requested field is blocked, falls
|
|
150
|
+
* back to `defaultProjection` instead of silently selecting everything.
|
|
151
|
+
*/
|
|
152
|
+
project(defaultProjection?: string | Record<string, 0 | 1>): this;
|
|
153
|
+
/** Adds a $lookup (join) stage, optionally followed by $unwind when `single` is true. */
|
|
154
|
+
lookup(opts: LookupOptions): this;
|
|
155
|
+
/** Escape hatch for any other developer-authored stage ($addFields, $group, post-join $match, ...). Blocks $out/$merge only — this path is for trusted, server-defined stages, not client input. */
|
|
156
|
+
addStage(stage: PipelineStage): this;
|
|
157
|
+
private resolveRangePreset;
|
|
158
|
+
/** [start of fromStr, start of (toStr + 1 day)) in this instance's timezone — an inclusive local-date range. */
|
|
159
|
+
private utcRangeForLocalDates;
|
|
160
|
+
private buildMatchStage;
|
|
161
|
+
/** Base pipeline shared by every execution path: match -> lookups/custom stages -> project -> sort. */
|
|
162
|
+
private buildBasePipeline;
|
|
163
|
+
private execAggregate;
|
|
164
|
+
private wrapTimed;
|
|
165
|
+
/**
|
|
166
|
+
* Executes the pipeline and returns a paginated result via $facet (single
|
|
167
|
+
* round trip: data page + total count together). Pass a prior page-1
|
|
168
|
+
* `total` as `cachedTotal` on later pages to skip the count entirely.
|
|
169
|
+
*
|
|
170
|
+
* Note: $facet buffers both branches in memory per query — for very large
|
|
171
|
+
* collections with expensive pre-facet stages, consider passing
|
|
172
|
+
* `cachedTotal` on subsequent pages, or run count/data as two calls.
|
|
173
|
+
*/
|
|
174
|
+
paginate(cachedTotal?: number): Promise<PaginatedResult<T>>;
|
|
175
|
+
}
|
|
176
|
+
export default QueryAggregate;
|
|
177
|
+
//# sourceMappingURL=aggregate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregate.d.ts","sourceRoot":"","sources":["../src/aggregate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAIH,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAoDhD,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,IAAI,EA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