@nestjs-filter-grammar/core 0.0.1
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 +170 -0
- package/dist/coerce.d.ts +7 -0
- package/dist/coerce.d.ts.map +1 -0
- package/dist/coerce.js +123 -0
- package/dist/coerce.js.map +1 -0
- package/dist/decorators/constants.d.ts +4 -0
- package/dist/decorators/constants.d.ts.map +1 -0
- package/dist/decorators/constants.js +7 -0
- package/dist/decorators/constants.js.map +1 -0
- package/dist/decorators/filterable-column.decorator.d.ts +7 -0
- package/dist/decorators/filterable-column.decorator.d.ts.map +1 -0
- package/dist/decorators/filterable-column.decorator.js +17 -0
- package/dist/decorators/filterable-column.decorator.js.map +1 -0
- package/dist/decorators/filterable.decorator.d.ts +3 -0
- package/dist/decorators/filterable.decorator.d.ts.map +1 -0
- package/dist/decorators/filterable.decorator.js +11 -0
- package/dist/decorators/filterable.decorator.js.map +1 -0
- package/dist/decorators/index.d.ts +5 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +14 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/metadata.d.ts +6 -0
- package/dist/decorators/metadata.d.ts.map +1 -0
- package/dist/decorators/metadata.js +44 -0
- package/dist/decorators/metadata.js.map +1 -0
- package/dist/decorators/sortable-column.decorator.d.ts +3 -0
- package/dist/decorators/sortable-column.decorator.d.ts.map +1 -0
- package/dist/decorators/sortable-column.decorator.js +13 -0
- package/dist/decorators/sortable-column.decorator.js.map +1 -0
- package/dist/errors/filter-parse-exception.d.ts +7 -0
- package/dist/errors/filter-parse-exception.d.ts.map +1 -0
- package/dist/errors/filter-parse-exception.js +15 -0
- package/dist/errors/filter-parse-exception.js.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +6 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/lexer/index.d.ts +5 -0
- package/dist/lexer/index.d.ts.map +1 -0
- package/dist/lexer/index.js +28 -0
- package/dist/lexer/index.js.map +1 -0
- package/dist/lexer/tokens.d.ts +23 -0
- package/dist/lexer/tokens.d.ts.map +1 -0
- package/dist/lexer/tokens.js +63 -0
- package/dist/lexer/tokens.js.map +1 -0
- package/dist/param/filter.decorator.d.ts +7 -0
- package/dist/param/filter.decorator.d.ts.map +1 -0
- package/dist/param/filter.decorator.js +140 -0
- package/dist/param/filter.decorator.js.map +1 -0
- package/dist/parse.d.ts +3 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +37 -0
- package/dist/parse.js.map +1 -0
- package/dist/parser/filter-parser.d.ts +11 -0
- package/dist/parser/filter-parser.d.ts.map +1 -0
- package/dist/parser/filter-parser.js +64 -0
- package/dist/parser/filter-parser.js.map +1 -0
- package/dist/sort/sort-parser.d.ts +3 -0
- package/dist/sort/sort-parser.d.ts.map +1 -0
- package/dist/sort/sort-parser.js +50 -0
- package/dist/sort/sort-parser.js.map +1 -0
- package/dist/sort/sort-validator.d.ts +3 -0
- package/dist/sort/sort-validator.d.ts.map +1 -0
- package/dist/sort/sort-validator.js +19 -0
- package/dist/sort/sort-validator.js.map +1 -0
- package/dist/swagger/swagger.util.d.ts +4 -0
- package/dist/swagger/swagger.util.d.ts.map +1 -0
- package/dist/swagger/swagger.util.js +41 -0
- package/dist/swagger/swagger.util.js.map +1 -0
- package/dist/types/index.d.ts +88 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +44 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/sort.d.ts +15 -0
- package/dist/types/sort.d.ts.map +1 -0
- package/dist/types/sort.js +11 -0
- package/dist/types/sort.js.map +1 -0
- package/dist/validate.d.ts +3 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +53 -0
- package/dist/validate.js.map +1 -0
- package/dist/visitor/filter-visitor.d.ts +46 -0
- package/dist/visitor/filter-visitor.d.ts.map +1 -0
- package/dist/visitor/filter-visitor.js +81 -0
- package/dist/visitor/filter-visitor.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# @nestjs-filter-grammar/core
|
|
2
|
+
|
|
3
|
+
Core package for nestjs-filter-grammar. Provides the Chevrotain-based filter/sort parser, NestJS decorators, validation, and Swagger description generation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @nestjs-filter-grammar/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Peer Dependencies
|
|
12
|
+
|
|
13
|
+
- `@nestjs/common` >= 10.0.0
|
|
14
|
+
- `@nestjs/core` >= 10.0.0
|
|
15
|
+
- `reflect-metadata` >= 0.1.13
|
|
16
|
+
- `@nestjs/swagger` >= 7.0.0 (optional — for Swagger descriptions)
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
### Decorators
|
|
21
|
+
|
|
22
|
+
#### `@Filterable()`
|
|
23
|
+
|
|
24
|
+
Class decorator — marks a query DTO as filterable.
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
@Filterable()
|
|
28
|
+
class UserQuery { ... }
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
#### `@FilterableColumn(operators, options?)`
|
|
32
|
+
|
|
33
|
+
Property decorator — declares which filter operators a column supports.
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
@FilterableColumn([FilterOperator.eq, FilterOperator.neq, FilterOperator.iContains])
|
|
37
|
+
name!: string;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The optional `options.type` parameter controls value coercion and validation. By default, values are strings.
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
// Number — coerces "30" to 30, rejects "abc"
|
|
44
|
+
@FilterableColumn([FilterOperator.gte, FilterOperator.lte], { type: 'number' })
|
|
45
|
+
age!: number;
|
|
46
|
+
|
|
47
|
+
// Boolean — accepts "true"/"false" only
|
|
48
|
+
@FilterableColumn([FilterOperator.eq], { type: 'boolean' })
|
|
49
|
+
active!: boolean;
|
|
50
|
+
|
|
51
|
+
// Enum — validates value is one of the enum members
|
|
52
|
+
enum Status { active = 'active', inactive = 'inactive', pending = 'pending' }
|
|
53
|
+
@FilterableColumn([FilterOperator.eq, FilterOperator.neq], { type: Status })
|
|
54
|
+
status!: Status;
|
|
55
|
+
|
|
56
|
+
// String array — same as enum but without defining one
|
|
57
|
+
@FilterableColumn([FilterOperator.eq], { type: ['red', 'green', 'blue'] })
|
|
58
|
+
color!: string;
|
|
59
|
+
|
|
60
|
+
// Numeric enum — coerces "1" to 1, validates against allowed values
|
|
61
|
+
enum Priority { low = 0, medium = 1, high = 2 }
|
|
62
|
+
@FilterableColumn([FilterOperator.eq], { type: Priority })
|
|
63
|
+
priority!: Priority;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Quoted values (`field="123"`) are never coerced and always stay as strings, regardless of the declared type.
|
|
67
|
+
|
|
68
|
+
#### `@SortableColumn()`
|
|
69
|
+
|
|
70
|
+
Property decorator — marks a column as sortable.
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
@SortableColumn()
|
|
74
|
+
name!: string;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### `@Filter(queryClass, options?)`
|
|
78
|
+
|
|
79
|
+
NestJS parameter decorator — parses and validates filter/sort from query params.
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
@Get()
|
|
83
|
+
findAll(@Filter(UserQuery) result: FilterResult) {
|
|
84
|
+
const { filter, sort, query } = result;
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Options:
|
|
89
|
+
|
|
90
|
+
| Option | Type | Default | Description |
|
|
91
|
+
|--------|------|---------|-------------|
|
|
92
|
+
| `queryParam` | `string` | `'filter'` | Name of the filter query parameter |
|
|
93
|
+
| `sortParam` | `string` | `'sort'` | Name of the sort query parameter |
|
|
94
|
+
| `optional` | `boolean` | `false` | Whether the filter param is optional |
|
|
95
|
+
|
|
96
|
+
### Parser
|
|
97
|
+
|
|
98
|
+
#### `parseFilter(input: string): FilterTree`
|
|
99
|
+
|
|
100
|
+
Parses a filter string into a `FilterTree` (AST). Throws on syntax errors.
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { parseFilter } from '@nestjs-filter-grammar/core';
|
|
104
|
+
|
|
105
|
+
const tree = parseFilter('status=active;age>=18');
|
|
106
|
+
// { type: 'AND', conditions: [
|
|
107
|
+
// { field: 'status', operator: '=', values: [{ type: 'string', value: 'active' }], ... },
|
|
108
|
+
// { field: 'age', operator: '>=', values: [{ type: 'string', value: '18' }], ... },
|
|
109
|
+
// ]}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### `parseSortString(input: string): SortEntry[]`
|
|
113
|
+
|
|
114
|
+
Parses a sort string into an array of sort entries.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { parseSortString } from '@nestjs-filter-grammar/core';
|
|
118
|
+
|
|
119
|
+
const entries = parseSortString('+name,-age');
|
|
120
|
+
// [{ field: 'name', direction: 'asc' }, { field: 'age', direction: 'desc' }]
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Validation
|
|
124
|
+
|
|
125
|
+
#### `validateFilter(tree, metadata): FilterError[]`
|
|
126
|
+
|
|
127
|
+
Validates a `FilterTree` against column metadata. Returns an array of errors (empty if valid).
|
|
128
|
+
|
|
129
|
+
#### `validateSort(entries, metadata): FilterError[]`
|
|
130
|
+
|
|
131
|
+
Validates sort entries against sortable column metadata.
|
|
132
|
+
|
|
133
|
+
### Types
|
|
134
|
+
|
|
135
|
+
#### `FilterOperator`
|
|
136
|
+
|
|
137
|
+
Enum of all supported operators: `eq`, `neq`, `gt`, `lt`, `gte`, `lte`, `iEq`, `iNeq`, `startsWith`, `endsWith`, `contains`, `iStartsWith`, `iEndsWith`, `iContains`.
|
|
138
|
+
|
|
139
|
+
#### `FilterTree`
|
|
140
|
+
|
|
141
|
+
Union of `FilterGroup | FilterCondition` — the parsed AST.
|
|
142
|
+
|
|
143
|
+
#### `FilterResult<T>`
|
|
144
|
+
|
|
145
|
+
Returned by the `@Filter()` decorator:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
interface FilterResult<T = Record<string, never>> {
|
|
149
|
+
filter?: FilterTree;
|
|
150
|
+
sort?: SortEntry[];
|
|
151
|
+
query: T;
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### `SortDirection`
|
|
156
|
+
|
|
157
|
+
Enum: `asc`, `desc`.
|
|
158
|
+
|
|
159
|
+
#### `SortEntry`
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
interface SortEntry {
|
|
163
|
+
field: string;
|
|
164
|
+
direction: SortDirection;
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Swagger
|
|
169
|
+
|
|
170
|
+
When `@nestjs/swagger` is installed, `@Filter()` automatically adds `@ApiQuery` decorators with generated descriptions listing available columns and operators.
|
package/dist/coerce.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FilterTree, FilterError, ColumnMetadata } from './types';
|
|
2
|
+
export interface CoerceResult {
|
|
3
|
+
tree: FilterTree;
|
|
4
|
+
errors: FilterError[];
|
|
5
|
+
}
|
|
6
|
+
export declare function coerceFilterValues(tree: FilterTree, metadata: ColumnMetadata[]): CoerceResult;
|
|
7
|
+
//# sourceMappingURL=coerce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce.d.ts","sourceRoot":"","sources":["../src/coerce.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,WAAW,EACX,cAAc,EAEf,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,cAAc,EAAE,GACzB,YAAY,CAKd"}
|
package/dist/coerce.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.coerceFilterValues = coerceFilterValues;
|
|
4
|
+
function coerceFilterValues(tree, metadata) {
|
|
5
|
+
const columnMap = new Map(metadata.map((m) => [m.propertyKey, m]));
|
|
6
|
+
const errors = [];
|
|
7
|
+
const result = coerceNode(tree, columnMap, errors);
|
|
8
|
+
return { tree: result, errors };
|
|
9
|
+
}
|
|
10
|
+
function coerceNode(node, columnMap, errors) {
|
|
11
|
+
if ('field' in node) {
|
|
12
|
+
return coerceCondition(node, columnMap, errors);
|
|
13
|
+
}
|
|
14
|
+
return coerceGroup(node, columnMap, errors);
|
|
15
|
+
}
|
|
16
|
+
function coerceGroup(group, columnMap, errors) {
|
|
17
|
+
return {
|
|
18
|
+
...group,
|
|
19
|
+
conditions: group.conditions.map((c) => coerceNode(c, columnMap, errors)),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function isEnumType(valueType) {
|
|
23
|
+
return typeof valueType === 'object';
|
|
24
|
+
}
|
|
25
|
+
function resolveEnumValues(valueType) {
|
|
26
|
+
if (Array.isArray(valueType))
|
|
27
|
+
return valueType;
|
|
28
|
+
// For TS numeric enums, Object.values returns both forward and reverse mappings:
|
|
29
|
+
// enum E { a=0 } → { a: 0, '0': 'a' } → Object.values = ['a', 0]
|
|
30
|
+
// We want the values that were explicitly assigned (the non-reverse-mapped ones).
|
|
31
|
+
// The forward mapping has string keys → string|number values.
|
|
32
|
+
// The reverse mapping has numeric-string keys → string values.
|
|
33
|
+
// Keep only values from non-numeric keys (the forward mappings).
|
|
34
|
+
const entries = Object.entries(valueType);
|
|
35
|
+
return entries
|
|
36
|
+
.filter(([key]) => isNaN(Number(key)))
|
|
37
|
+
.map(([, value]) => value);
|
|
38
|
+
}
|
|
39
|
+
function coerceCondition(condition, columnMap, errors) {
|
|
40
|
+
const meta = columnMap.get(condition.field);
|
|
41
|
+
if (!meta || meta.valueType === 'string') {
|
|
42
|
+
return condition;
|
|
43
|
+
}
|
|
44
|
+
if (isEnumType(meta.valueType)) {
|
|
45
|
+
const allowed = resolveEnumValues(meta.valueType);
|
|
46
|
+
return validateEnum(condition, allowed, errors);
|
|
47
|
+
}
|
|
48
|
+
const coercedValues = condition.values.map((v) => coerceValue(v, meta.valueType, condition.field, condition.fieldOffset, errors));
|
|
49
|
+
return { ...condition, values: coercedValues };
|
|
50
|
+
}
|
|
51
|
+
function validateEnum(condition, allowed, errors) {
|
|
52
|
+
const coercedValues = [];
|
|
53
|
+
for (const v of condition.values) {
|
|
54
|
+
if (v.type === 'null') {
|
|
55
|
+
coercedValues.push(v);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (v.type !== 'string') {
|
|
59
|
+
coercedValues.push(v);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const raw = v.value;
|
|
63
|
+
// Check if the raw string matches a string enum value
|
|
64
|
+
if (allowed.includes(raw)) {
|
|
65
|
+
coercedValues.push(v);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
// Check if it matches a numeric enum value
|
|
69
|
+
const num = Number(raw);
|
|
70
|
+
if (!isNaN(num) && allowed.includes(num)) {
|
|
71
|
+
coercedValues.push({ type: 'number', value: num });
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
errors.push({
|
|
75
|
+
message: `Invalid value '${raw}' for field '${condition.field}': expected one of ${allowed.join(', ')}`,
|
|
76
|
+
offset: condition.fieldOffset,
|
|
77
|
+
length: raw.length,
|
|
78
|
+
field: condition.field,
|
|
79
|
+
});
|
|
80
|
+
coercedValues.push(v);
|
|
81
|
+
}
|
|
82
|
+
return { ...condition, values: coercedValues };
|
|
83
|
+
}
|
|
84
|
+
function coerceValue(value, targetType, field, offset, errors) {
|
|
85
|
+
if (value.type === 'null') {
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
// Only coerce unquoted string values
|
|
89
|
+
if (value.type !== 'string' || value.quoted) {
|
|
90
|
+
return value;
|
|
91
|
+
}
|
|
92
|
+
const raw = value.value;
|
|
93
|
+
if (targetType === 'number') {
|
|
94
|
+
const num = Number(raw);
|
|
95
|
+
if (isNaN(num)) {
|
|
96
|
+
errors.push({
|
|
97
|
+
message: `Invalid value '${raw}' for field '${field}': expected a number`,
|
|
98
|
+
offset,
|
|
99
|
+
length: raw.length,
|
|
100
|
+
field,
|
|
101
|
+
});
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
return { type: 'number', value: num };
|
|
105
|
+
}
|
|
106
|
+
if (targetType === 'boolean') {
|
|
107
|
+
if (raw === 'true') {
|
|
108
|
+
return { type: 'boolean', value: true };
|
|
109
|
+
}
|
|
110
|
+
if (raw === 'false') {
|
|
111
|
+
return { type: 'boolean', value: false };
|
|
112
|
+
}
|
|
113
|
+
errors.push({
|
|
114
|
+
message: `Invalid value '${raw}' for field '${field}': expected a boolean (true or false)`,
|
|
115
|
+
offset,
|
|
116
|
+
length: raw.length,
|
|
117
|
+
field,
|
|
118
|
+
});
|
|
119
|
+
return value;
|
|
120
|
+
}
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=coerce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce.js","sourceRoot":"","sources":["../src/coerce.ts"],"names":[],"mappings":";;AAeA,gDAQC;AARD,SAAgB,kBAAkB,CAChC,IAAgB,EAChB,QAA0B;IAE1B,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CA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|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SORTABLE_COLUMNS_KEY = exports.FILTERABLE_COLUMNS_KEY = exports.FILTERABLE_KEY = void 0;
|
|
4
|
+
exports.FILTERABLE_KEY = Symbol('filterable');
|
|
5
|
+
exports.FILTERABLE_COLUMNS_KEY = Symbol('filterable-columns');
|
|
6
|
+
exports.SORTABLE_COLUMNS_KEY = Symbol('sortable-columns');
|
|
7
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/decorators/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AACtC,QAAA,sBAAsB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACtD,QAAA,oBAAoB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { FilterOperator, FilterValueType } from '../types';
|
|
3
|
+
export interface FilterableColumnOptions {
|
|
4
|
+
type?: FilterValueType;
|
|
5
|
+
}
|
|
6
|
+
export declare function FilterableColumn(operators: FilterOperator[], options?: FilterableColumnOptions): PropertyDecorator;
|
|
7
|
+
//# sourceMappingURL=filterable-column.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterable-column.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/filterable-column.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAkB,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3E,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,eAAe,CAAC;CACxB;AAED,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,cAAc,EAAE,EAC3B,OAAO,CAAC,EAAE,uBAAuB,GAChC,iBAAiB,CAanB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilterableColumn = FilterableColumn;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
function FilterableColumn(operators, options) {
|
|
7
|
+
return (target, propertyKey) => {
|
|
8
|
+
const existing = Reflect.getOwnMetadata(constants_1.FILTERABLE_COLUMNS_KEY, target.constructor) ?? [];
|
|
9
|
+
existing.push({
|
|
10
|
+
propertyKey: String(propertyKey),
|
|
11
|
+
operators,
|
|
12
|
+
valueType: options?.type ?? 'string',
|
|
13
|
+
});
|
|
14
|
+
Reflect.defineMetadata(constants_1.FILTERABLE_COLUMNS_KEY, existing, target.constructor);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=filterable-column.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterable-column.decorator.js","sourceRoot":"","sources":["../../src/decorators/filterable-column.decorator.ts"],"names":[],"mappings":";;AAQA,4CAgBC;AAxBD,4BAA0B;AAC1B,2CAAqD;AAOrD,SAAgB,gBAAgB,CAC9B,SAA2B,EAC3B,OAAiC;IAEjC,OAAO,CAAC,MAAc,EAAE,WAA4B,EAAE,EAAE;QACtD,MAAM,QAAQ,GACZ,OAAO,CAAC,cAAc,CAAC,kCAAsB,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAE3E,QAAQ,CAAC,IAAI,CAAC;YACZ,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;YAChC,SAAS;YACT,SAAS,EAAE,OAAO,EAAE,IAAI,IAAI,QAAQ;SACrC,CAAC,CAAC;QAEH,OAAO,CAAC,cAAc,CAAC,kCAAsB,EAAE,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAC/E,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterable.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/filterable.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAG1B,wBAAgB,UAAU,IAAI,cAAc,CAI3C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Filterable = Filterable;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
function Filterable() {
|
|
7
|
+
return (target) => {
|
|
8
|
+
Reflect.defineMetadata(constants_1.FILTERABLE_KEY, true, target);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=filterable.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterable.decorator.js","sourceRoot":"","sources":["../../src/decorators/filterable.decorator.ts"],"names":[],"mappings":";;AAGA,gCAIC;AAPD,4BAA0B;AAC1B,2CAA6C;AAE7C,SAAgB,UAAU;IACxB,OAAO,CAAC,MAAgB,EAAE,EAAE;QAC1B,OAAO,CAAC,cAAc,CAAC,0BAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Filterable } from './filterable.decorator';
|
|
2
|
+
export { FilterableColumn } from './filterable-column.decorator';
|
|
3
|
+
export { SortableColumn } from './sortable-column.decorator';
|
|
4
|
+
export { getFilterableMetadata, getSortableMetadata, isFilterable } from './metadata';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFilterable = exports.getSortableMetadata = exports.getFilterableMetadata = exports.SortableColumn = exports.FilterableColumn = exports.Filterable = void 0;
|
|
4
|
+
var filterable_decorator_1 = require("./filterable.decorator");
|
|
5
|
+
Object.defineProperty(exports, "Filterable", { enumerable: true, get: function () { return filterable_decorator_1.Filterable; } });
|
|
6
|
+
var filterable_column_decorator_1 = require("./filterable-column.decorator");
|
|
7
|
+
Object.defineProperty(exports, "FilterableColumn", { enumerable: true, get: function () { return filterable_column_decorator_1.FilterableColumn; } });
|
|
8
|
+
var sortable_column_decorator_1 = require("./sortable-column.decorator");
|
|
9
|
+
Object.defineProperty(exports, "SortableColumn", { enumerable: true, get: function () { return sortable_column_decorator_1.SortableColumn; } });
|
|
10
|
+
var metadata_1 = require("./metadata");
|
|
11
|
+
Object.defineProperty(exports, "getFilterableMetadata", { enumerable: true, get: function () { return metadata_1.getFilterableMetadata; } });
|
|
12
|
+
Object.defineProperty(exports, "getSortableMetadata", { enumerable: true, get: function () { return metadata_1.getSortableMetadata; } });
|
|
13
|
+
Object.defineProperty(exports, "isFilterable", { enumerable: true, get: function () { return metadata_1.isFilterable; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,+DAAoD;AAA3C,kHAAA,UAAU,OAAA;AACnB,6EAAiE;AAAxD,+HAAA,gBAAgB,OAAA;AACzB,yEAA6D;AAApD,2HAAA,cAAc,OAAA;AACvB,uCAAsF;AAA7E,iHAAA,qBAAqB,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAAE,wGAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { ColumnMetadata, SortableColumnMetadata } from '../types';
|
|
3
|
+
export declare function isFilterable(target: Function): boolean;
|
|
4
|
+
export declare function getFilterableMetadata(target: Function): ColumnMetadata[];
|
|
5
|
+
export declare function getSortableMetadata(target: Function): SortableColumnMetadata[];
|
|
6
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/decorators/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElE,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAEtD;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,QAAQ,GAAG,cAAc,EAAE,CAqBxE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,GAAG,sBAAsB,EAAE,CAgB9E"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFilterable = isFilterable;
|
|
4
|
+
exports.getFilterableMetadata = getFilterableMetadata;
|
|
5
|
+
exports.getSortableMetadata = getSortableMetadata;
|
|
6
|
+
require("reflect-metadata");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
function isFilterable(target) {
|
|
9
|
+
return Reflect.getOwnMetadata(constants_1.FILTERABLE_KEY, target) === true;
|
|
10
|
+
}
|
|
11
|
+
function getFilterableMetadata(target) {
|
|
12
|
+
const result = [];
|
|
13
|
+
const seen = new Set();
|
|
14
|
+
// Walk the prototype chain to collect inherited columns
|
|
15
|
+
let current = target;
|
|
16
|
+
while (current && current !== Function.prototype) {
|
|
17
|
+
const columns = Reflect.getOwnMetadata(constants_1.FILTERABLE_COLUMNS_KEY, current) ?? [];
|
|
18
|
+
for (const col of columns) {
|
|
19
|
+
if (!seen.has(col.propertyKey)) {
|
|
20
|
+
seen.add(col.propertyKey);
|
|
21
|
+
result.push(col);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
current = Object.getPrototypeOf(current);
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
function getSortableMetadata(target) {
|
|
29
|
+
const result = [];
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
let current = target;
|
|
32
|
+
while (current && current !== Function.prototype) {
|
|
33
|
+
const columns = Reflect.getOwnMetadata(constants_1.SORTABLE_COLUMNS_KEY, current) ?? [];
|
|
34
|
+
for (const col of columns) {
|
|
35
|
+
if (!seen.has(col.propertyKey)) {
|
|
36
|
+
seen.add(col.propertyKey);
|
|
37
|
+
result.push(col);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
current = Object.getPrototypeOf(current);
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/decorators/metadata.ts"],"names":[],"mappings":";;AAIA,oCAEC;AAED,sDAqBC;AAED,kDAgBC;AA/CD,4BAA0B;AAC1B,2CAA2F;AAG3F,SAAgB,YAAY,CAAC,MAAgB;IAC3C,OAAO,OAAO,CAAC,cAAc,CAAC,0BAAc,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;AACjE,CAAC;AAED,SAAgB,qBAAqB,CAAC,MAAgB;IACpD,MAAM,MAAM,GAAqB,EAAE,CAAC;IACpC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,wDAAwD;IAC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AAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortable-column.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/sortable-column.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAI1B,wBAAgB,cAAc,IAAI,iBAAiB,CAOlD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SortableColumn = SortableColumn;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
function SortableColumn() {
|
|
7
|
+
return (target, propertyKey) => {
|
|
8
|
+
const existing = Reflect.getOwnMetadata(constants_1.SORTABLE_COLUMNS_KEY, target.constructor) ?? [];
|
|
9
|
+
existing.push({ propertyKey: String(propertyKey) });
|
|
10
|
+
Reflect.defineMetadata(constants_1.SORTABLE_COLUMNS_KEY, existing, target.constructor);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=sortable-column.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortable-column.decorator.js","sourceRoot":"","sources":["../../src/decorators/sortable-column.decorator.ts"],"names":[],"mappings":";;AAIA,wCAOC;AAXD,4BAA0B;AAC1B,2CAAmD;AAGnD,SAAgB,cAAc;IAC5B,OAAO,CAAC,MAAc,EAAE,WAA4B,EAAE,EAAE;QACtD,MAAM,QAAQ,GACZ,OAAO,CAAC,cAAc,CAAC,gCAAoB,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACzE,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,cAAc,CAAC,gCAAoB,EAAE,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAC7E,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BadRequestException } from '@nestjs/common';
|
|
2
|
+
import { FilterError } from '../types';
|
|
3
|
+
export declare class FilterParseException extends BadRequestException {
|
|
4
|
+
readonly errors: FilterError[];
|
|
5
|
+
constructor(errors: FilterError[]);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=filter-parse-exception.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-parse-exception.d.ts","sourceRoot":"","sources":["../../src/errors/filter-parse-exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,qBAAa,oBAAqB,SAAQ,mBAAmB;aAC/B,MAAM,EAAE,WAAW,EAAE;gBAArB,MAAM,EAAE,WAAW,EAAE;CAMlD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilterParseException = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
class FilterParseException extends common_1.BadRequestException {
|
|
6
|
+
constructor(errors) {
|
|
7
|
+
super({
|
|
8
|
+
message: 'Invalid filter expression',
|
|
9
|
+
errors,
|
|
10
|
+
});
|
|
11
|
+
this.errors = errors;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.FilterParseException = FilterParseException;
|
|
15
|
+
//# sourceMappingURL=filter-parse-exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-parse-exception.js","sourceRoot":"","sources":["../../src/errors/filter-parse-exception.ts"],"names":[],"mappings":";;;AAAA,2CAAqD;AAGrD,MAAa,oBAAqB,SAAQ,4BAAmB;IAC3D,YAA4B,MAAqB;QAC/C,KAAK,CAAC;YACJ,OAAO,EAAE,2BAA2B;YACpC,MAAM;SACP,CAAC,CAAC;QAJuB,WAAM,GAAN,MAAM,CAAe;IAKjD,CAAC;CACF;AAPD,oDAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilterParseException = void 0;
|
|
4
|
+
var filter_parse_exception_1 = require("./filter-parse-exception");
|
|
5
|
+
Object.defineProperty(exports, "FilterParseException", { enumerable: true, get: function () { return filter_parse_exception_1.FilterParseException; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";;;AAAA,mEAAgE;AAAvD,8HAAA,oBAAoB,OAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { FilterOperator, EQUALITY_OPERATORS, FilterTree, FilterGroup, FilterCondition, FilterValue, FilterValueType, FilterEnum, FilterResult, FilterError, FilterAdapter, ColumnMetadata, SortDirection, SortEntry, SortableColumnMetadata, } from './types';
|
|
2
|
+
export { parseFilter } from './parse';
|
|
3
|
+
export { validateFilter } from './validate';
|
|
4
|
+
export { Filterable } from './decorators/filterable.decorator';
|
|
5
|
+
export { FilterableColumn, FilterableColumnOptions } from './decorators/filterable-column.decorator';
|
|
6
|
+
export { getFilterableMetadata, getSortableMetadata, isFilterable } from './decorators/metadata';
|
|
7
|
+
export { Filter, FilterOptions } from './param/filter.decorator';
|
|
8
|
+
export { FilterParseException } from './errors/filter-parse-exception';
|
|
9
|
+
export { coerceFilterValues } from './coerce';
|
|
10
|
+
export { buildSwaggerDescription } from './swagger/swagger.util';
|
|
11
|
+
export { parseSortString } from './sort/sort-parser';
|
|
12
|
+
export { validateSort } from './sort/sort-validator';
|
|
13
|
+
export { SortableColumn } from './decorators/sortable-column.decorator';
|
|
14
|
+
export { buildSortSwaggerDescription } from './swagger/swagger.util';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,eAAe,EACf,WAAW,EACX,eAAe,EACf,UAAU,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,cAAc,EACd,aAAa,EACb,SAAS,EACT,sBAAsB,GACvB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACrG,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGjG,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAGvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildSortSwaggerDescription = exports.SortableColumn = exports.validateSort = exports.parseSortString = exports.buildSwaggerDescription = exports.coerceFilterValues = exports.FilterParseException = exports.Filter = exports.isFilterable = exports.getSortableMetadata = exports.getFilterableMetadata = exports.FilterableColumn = exports.Filterable = exports.validateFilter = exports.parseFilter = exports.SortDirection = exports.EQUALITY_OPERATORS = exports.FilterOperator = void 0;
|
|
4
|
+
// Types
|
|
5
|
+
var types_1 = require("./types");
|
|
6
|
+
Object.defineProperty(exports, "FilterOperator", { enumerable: true, get: function () { return types_1.FilterOperator; } });
|
|
7
|
+
Object.defineProperty(exports, "EQUALITY_OPERATORS", { enumerable: true, get: function () { return types_1.EQUALITY_OPERATORS; } });
|
|
8
|
+
Object.defineProperty(exports, "SortDirection", { enumerable: true, get: function () { return types_1.SortDirection; } });
|
|
9
|
+
// Parser
|
|
10
|
+
var parse_1 = require("./parse");
|
|
11
|
+
Object.defineProperty(exports, "parseFilter", { enumerable: true, get: function () { return parse_1.parseFilter; } });
|
|
12
|
+
// Validation
|
|
13
|
+
var validate_1 = require("./validate");
|
|
14
|
+
Object.defineProperty(exports, "validateFilter", { enumerable: true, get: function () { return validate_1.validateFilter; } });
|
|
15
|
+
// Decorators
|
|
16
|
+
var filterable_decorator_1 = require("./decorators/filterable.decorator");
|
|
17
|
+
Object.defineProperty(exports, "Filterable", { enumerable: true, get: function () { return filterable_decorator_1.Filterable; } });
|
|
18
|
+
var filterable_column_decorator_1 = require("./decorators/filterable-column.decorator");
|
|
19
|
+
Object.defineProperty(exports, "FilterableColumn", { enumerable: true, get: function () { return filterable_column_decorator_1.FilterableColumn; } });
|
|
20
|
+
var metadata_1 = require("./decorators/metadata");
|
|
21
|
+
Object.defineProperty(exports, "getFilterableMetadata", { enumerable: true, get: function () { return metadata_1.getFilterableMetadata; } });
|
|
22
|
+
Object.defineProperty(exports, "getSortableMetadata", { enumerable: true, get: function () { return metadata_1.getSortableMetadata; } });
|
|
23
|
+
Object.defineProperty(exports, "isFilterable", { enumerable: true, get: function () { return metadata_1.isFilterable; } });
|
|
24
|
+
// Parameter decorator
|
|
25
|
+
var filter_decorator_1 = require("./param/filter.decorator");
|
|
26
|
+
Object.defineProperty(exports, "Filter", { enumerable: true, get: function () { return filter_decorator_1.Filter; } });
|
|
27
|
+
// Errors
|
|
28
|
+
var filter_parse_exception_1 = require("./errors/filter-parse-exception");
|
|
29
|
+
Object.defineProperty(exports, "FilterParseException", { enumerable: true, get: function () { return filter_parse_exception_1.FilterParseException; } });
|
|
30
|
+
// Coercion
|
|
31
|
+
var coerce_1 = require("./coerce");
|
|
32
|
+
Object.defineProperty(exports, "coerceFilterValues", { enumerable: true, get: function () { return coerce_1.coerceFilterValues; } });
|
|
33
|
+
// Swagger
|
|
34
|
+
var swagger_util_1 = require("./swagger/swagger.util");
|
|
35
|
+
Object.defineProperty(exports, "buildSwaggerDescription", { enumerable: true, get: function () { return swagger_util_1.buildSwaggerDescription; } });
|
|
36
|
+
// Sort
|
|
37
|
+
var sort_parser_1 = require("./sort/sort-parser");
|
|
38
|
+
Object.defineProperty(exports, "parseSortString", { enumerable: true, get: function () { return sort_parser_1.parseSortString; } });
|
|
39
|
+
var sort_validator_1 = require("./sort/sort-validator");
|
|
40
|
+
Object.defineProperty(exports, "validateSort", { enumerable: true, get: function () { return sort_validator_1.validateSort; } });
|
|
41
|
+
var sortable_column_decorator_1 = require("./decorators/sortable-column.decorator");
|
|
42
|
+
Object.defineProperty(exports, "SortableColumn", { enumerable: true, get: function () { return sortable_column_decorator_1.SortableColumn; } });
|
|
43
|
+
var swagger_util_2 = require("./swagger/swagger.util");
|
|
44
|
+
Object.defineProperty(exports, "buildSortSwaggerDescription", { enumerable: true, get: function () { return swagger_util_2.buildSortSwaggerDescription; } });
|
|
45
|
+
//# sourceMappingURL=index.js.map
|