@recursyve/nestjs-data-filter 11.0.0 → 11.1.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.
Files changed (48) hide show
  1. package/lib/data-filter.repository.d.ts +3 -2
  2. package/lib/data-filter.repository.js +39 -9
  3. package/lib/decorators/index.d.ts +1 -0
  4. package/lib/decorators/index.js +1 -0
  5. package/lib/decorators/searchable-translation-attributes.decorator.d.ts +1 -0
  6. package/lib/decorators/searchable-translation-attributes.decorator.js +21 -0
  7. package/lib/filter/controllers/dynamic-filter.controller.d.ts +8 -8
  8. package/lib/filter/controllers/dynamic-filter.controller.js +27 -25
  9. package/lib/filter/controllers/filter.controller.d.ts +7 -7
  10. package/lib/filter/controllers/filter.controller.js +24 -22
  11. package/lib/filter/controllers/open-api-filter.controller.d.ts +4 -0
  12. package/lib/filter/controllers/open-api-filter.controller.js +123 -0
  13. package/lib/filter/filter.service.d.ts +20 -5
  14. package/lib/filter/filter.service.js +47 -55
  15. package/lib/filter/filters/filter.d.ts +4 -1
  16. package/lib/filter/filters/options.filter.d.ts +3 -2
  17. package/lib/filter/filters/options.filter.js +23 -1
  18. package/lib/filter/filters/select.filter.d.ts +1 -1
  19. package/lib/filter/filters/select.filter.js +22 -1
  20. package/lib/filter/index.d.ts +1 -0
  21. package/lib/filter/index.js +1 -0
  22. package/lib/filter/models/filter-configuration-search.model.d.ts +1 -1
  23. package/lib/filter/models/filter-configuration-search.model.js +30 -0
  24. package/lib/filter/models/filter-configuration.model.d.ts +6 -6
  25. package/lib/filter/models/filter-configuration.model.js +115 -0
  26. package/lib/filter/models/filter-resource-value.model.d.ts +1 -1
  27. package/lib/filter/models/filter-resource-value.model.js +22 -0
  28. package/lib/filter/models/query.model.d.ts +5 -3
  29. package/lib/filter/models/query.model.js +39 -0
  30. package/lib/filter/models/rule.model.d.ts +3 -3
  31. package/lib/filter/models/rule.model.js +25 -0
  32. package/lib/filter/order-rules/enum.order-rule.js +1 -1
  33. package/lib/filter/order-rules/index.d.ts +2 -1
  34. package/lib/filter/order-rules/index.js +2 -1
  35. package/lib/filter/order-rules/json.order-rule.d.ts +11 -0
  36. package/lib/filter/order-rules/json.order-rule.js +15 -0
  37. package/lib/filter/order-rules/order-rule.d.ts +7 -2
  38. package/lib/models/attributes.model.d.ts +4 -1
  39. package/lib/models/attributes.model.js +8 -1
  40. package/lib/models/data-filter.model.d.ts +5 -1
  41. package/lib/models/data-filter.model.js +25 -6
  42. package/lib/models/filter.model.d.ts +15 -6
  43. package/lib/models/filter.model.js +120 -0
  44. package/lib/models/include.model.d.ts +2 -0
  45. package/lib/models/search-attributes.model.d.ts +1 -0
  46. package/lib/scanners/sequelize-model.scanner.d.ts +1 -1
  47. package/lib/scanners/sequelize-model.scanner.js +20 -13
  48. package/package.json +2 -1
@@ -15,7 +15,6 @@ const common_1 = require("@nestjs/common");
15
15
  const sequelize_1 = require("sequelize");
16
16
  const access_control_adapter_1 = require("../adapters/access-control.adapter");
17
17
  const translate_adapter_1 = require("../adapters/translate.adapter");
18
- const data_filter_repository_1 = require("../data-filter.repository");
19
18
  const data_filter_service_1 = require("../data-filter.service");
20
19
  const sequelize_model_scanner_1 = require("../scanners/sequelize-model.scanner");
21
20
  const sequelize_utils_1 = require("../sequelize.utils");
@@ -93,60 +92,61 @@ let FilterService = FilterService_1 = class FilterService {
93
92
  }
94
93
  return null;
95
94
  }
96
- async count(...args) {
97
- const [userOrOpt, opt] = args;
98
- const options = opt ? opt : userOrOpt;
99
- const user = opt ? userOrOpt : null;
95
+ async count(params) {
96
+ var _a, _b;
97
+ const { options } = params;
98
+ const user = (_a = params.user) !== null && _a !== void 0 ? _a : null;
100
99
  const countOptions = await this.getFindOptions(this.repository.model, options.query);
101
100
  if (options.search) {
102
- this.addSearchCondition(options.search, countOptions);
101
+ this.addSearchCondition(options.search, countOptions, (_b = user === null || user === void 0 ? void 0 : user.language) !== null && _b !== void 0 ? _b : null);
103
102
  }
104
- return user ? this.countTotalValues(user, countOptions) : this.countTotalValues(countOptions);
103
+ return this.countTotalValues({ options: countOptions, user });
105
104
  }
106
- async filter(...args) {
107
- const [userOrOpt, opt] = args;
108
- const options = opt ? opt : userOrOpt;
109
- const user = opt ? userOrOpt : null;
105
+ async filter(params) {
106
+ var _a, _b;
107
+ const { options, request } = params;
108
+ const user = (_a = params.user) !== null && _a !== void 0 ? _a : null;
110
109
  if (options.order) {
111
110
  options.order = this.normalizeOrder(options.order);
112
111
  }
113
112
  const countOptions = await this.getFindOptions(this.repository.model, options.query, options.data);
114
113
  if (options.search) {
115
- this.addSearchCondition(options.search, countOptions);
114
+ this.addSearchCondition(options.search, countOptions, (_b = user === null || user === void 0 ? void 0 : user.language) !== null && _b !== void 0 ? _b : null);
116
115
  }
117
116
  if (options.order) {
118
117
  this.addOrderCondition(options.order, countOptions, options.data);
119
118
  }
120
119
  this.addGroupOption(options, countOptions);
121
- const total = await (user ? this.countTotalValues(user, countOptions) : this.countTotalValues(countOptions));
122
- const values = await (user ? this.findValues(user, options, countOptions) : this.findValues(options, countOptions));
120
+ const total = await this.countTotalValues({ options: countOptions, user });
121
+ const values = await this.findValues({ filter: options, options: countOptions, request, user });
123
122
  return {
124
123
  total,
125
124
  page: options.page,
126
125
  values
127
126
  };
128
127
  }
129
- async downloadData(user, type, options, exportOptions) {
130
- var _a, _b;
128
+ async downloadData(params) {
129
+ var _a, _b, _c;
130
+ const { exportOptions, options, request, type, user } = params;
131
131
  const findOptions = await this.getFindOptions(this.exportRepository.model, options.query);
132
132
  if (options.order) {
133
133
  options.order = this.normalizeOrder(options.order);
134
134
  }
135
135
  if (options.search) {
136
- this.addSearchCondition(options.search, findOptions);
136
+ this.addSearchCondition(options.search, findOptions, (_a = user === null || user === void 0 ? void 0 : user.language) !== null && _a !== void 0 ? _a : null);
137
137
  }
138
138
  if (options.order) {
139
139
  this.addOrderCondition(options.order, findOptions, options.data);
140
140
  }
141
141
  delete options.page;
142
- const values = await (user ? this.findValues(user, options, findOptions, this.exportRepository) : this.findValues(options, findOptions, this.exportRepository));
142
+ const values = await this.findValues({ filter: options, options: findOptions, repository: this.exportRepository, request, user });
143
143
  const headers = await this.model.getExportedFieldsKeys(type);
144
144
  if (headers.length) {
145
145
  const data = await Promise.all(values.map((value) => { var _a; return this.model.getExportedFields(value, (_a = user === null || user === void 0 ? void 0 : user.language) !== null && _a !== void 0 ? _a : "fr", type); }));
146
- return await this.repository.downloadData(headers, data, type, (_a = user === null || user === void 0 ? void 0 : user.language) !== null && _a !== void 0 ? _a : "fr", exportOptions);
146
+ return await this.repository.downloadData(headers, data, type, (_b = user === null || user === void 0 ? void 0 : user.language) !== null && _b !== void 0 ? _b : "fr", exportOptions);
147
147
  }
148
148
  else {
149
- return await this.repository.downloadData(values, type, (_b = user === null || user === void 0 ? void 0 : user.language) !== null && _b !== void 0 ? _b : "fr", exportOptions);
149
+ return await this.repository.downloadData(values, type, (_c = user === null || user === void 0 ? void 0 : user.language) !== null && _c !== void 0 ? _c : "fr", exportOptions);
150
150
  }
151
151
  }
152
152
  async getFindOptions(model, query, data) {
@@ -308,13 +308,13 @@ let FilterService = FilterService_1 = class FilterService {
308
308
  }
309
309
  }
310
310
  }
311
- addSearchCondition(search, options) {
311
+ addSearchCondition(search, options, language) {
312
312
  var _a;
313
313
  const value = (_a = search === null || search === void 0 ? void 0 : search.value) === null || _a === void 0 ? void 0 : _a.toString();
314
314
  if (!(value === null || value === void 0 ? void 0 : value.length)) {
315
315
  return;
316
316
  }
317
- this.repository.addSearchCondition(search.value, options);
317
+ this.repository.addSearchCondition(search.value, options, language);
318
318
  }
319
319
  addOrderCondition(orders, options, data) {
320
320
  if (orders.every(order => !order.direction)) {
@@ -365,14 +365,12 @@ let FilterService = FilterService_1 = class FilterService {
365
365
  }
366
366
  }
367
367
  }
368
- async countTotalValues(...args) {
369
- const [userOrOpt, opt] = args;
370
- const options = opt ? opt : userOrOpt;
371
- /**
372
- * This means that countTotalValues was called with a user
373
- */
374
- if (opt) {
375
- options.where = await this.getAccessControlWhereCondition(options.where, userOrOpt);
368
+ async countTotalValues(params) {
369
+ var _a;
370
+ const { options } = params;
371
+ const user = (_a = params.user) !== null && _a !== void 0 ? _a : null;
372
+ if (user) {
373
+ options.where = await this.getAccessControlWhereCondition(options.where, user);
376
374
  }
377
375
  if (options.having) {
378
376
  const data = await this.repository.model.findAll({
@@ -395,20 +393,15 @@ let FilterService = FilterService_1 = class FilterService {
395
393
  }
396
394
  }
397
395
  }
398
- async findValues(...args) {
399
- var _a, _b, _c, _d;
400
- const [userOrOFilter, filterOrOpt, optOrRepo, repo] = args;
401
- const optOrRepoIsRepo = optOrRepo instanceof data_filter_repository_1.DataFilterRepository;
402
- const options = optOrRepo && !optOrRepoIsRepo ? optOrRepo : filterOrOpt;
403
- const filter = optOrRepo && !optOrRepoIsRepo ? filterOrOpt : userOrOFilter;
404
- const repository = repo !== null && repo !== void 0 ? repo : (optOrRepoIsRepo ? optOrRepo : this.repository);
405
- /**
406
- * This means that findValues was called with a user
407
- */
408
- if (repo) {
409
- options.where = await this.getAccessControlWhereCondition(options.where, userOrOFilter);
410
- }
411
- const order = this.getOrderOptions((_a = filter.order) !== null && _a !== void 0 ? _a : []);
396
+ async findValues(params) {
397
+ var _a, _b, _c, _d, _e, _f, _g;
398
+ const { filter, options, request } = params;
399
+ const user = (_a = params.user) !== null && _a !== void 0 ? _a : null;
400
+ const repository = (_b = params.repository) !== null && _b !== void 0 ? _b : this.repository;
401
+ if (user) {
402
+ options.where = await this.getAccessControlWhereCondition(options.where, user);
403
+ }
404
+ const order = this.getOrderOptions((_c = filter.order) !== null && _c !== void 0 ? _c : [], { request, user });
412
405
  const nonNestedOrderColumns = (Array.isArray(filter.order) ? filter.order : [filter.order])
413
406
  .filter((order) => !!order)
414
407
  .map(order => {
@@ -426,10 +419,10 @@ let FilterService = FilterService_1 = class FilterService {
426
419
  const values = await repository.model.findAll({
427
420
  ...options,
428
421
  attributes: ["id", ...nonNestedOrderColumns, ...customAttributes],
429
- limit: filter.page ? filter.page.size : undefined,
430
- offset: filter.page ? filter.page.number * filter.page.size + ((_b = filter.page.offset) !== null && _b !== void 0 ? _b : 0) : undefined,
422
+ limit: (_d = filter.page) === null || _d === void 0 ? void 0 : _d.size,
423
+ offset: filter.page ? filter.page.number * filter.page.size + ((_e = filter.page.offset) !== null && _e !== void 0 ? _e : 0) : undefined,
431
424
  subQuery: false,
432
- group: (_c = filter.groupBy) !== null && _c !== void 0 ? _c : options.group,
425
+ group: (_f = filter.groupBy) !== null && _f !== void 0 ? _f : options.group,
433
426
  order
434
427
  });
435
428
  const group = this.generateRepositoryGroupBy(filter);
@@ -440,7 +433,7 @@ let FilterService = FilterService_1 = class FilterService {
440
433
  order,
441
434
  paranoid: options.paranoid,
442
435
  group
443
- }, (_d = filter.data) !== null && _d !== void 0 ? _d : {});
436
+ }, (_g = filter.data) !== null && _g !== void 0 ? _g : {});
444
437
  }
445
438
  async getAccessControlWhereCondition(where, user) {
446
439
  var _a;
@@ -489,18 +482,17 @@ let FilterService = FilterService_1 = class FilterService {
489
482
  filter.condition ? this.getConditionInclude(model, filter.condition) : []
490
483
  ];
491
484
  }
492
- getOrderOptions(orders) {
493
- if (!Array.isArray(orders)) {
494
- orders = [orders];
495
- }
485
+ getOrderOptions(orders, context) {
486
+ let orderColumns = Array.isArray(orders) ? orders : [orders];
496
487
  if (this.model.defaultOrderRule) {
497
488
  const defaultOrders = Array.isArray(this.model.defaultOrderRule.order)
498
489
  ? this.model.defaultOrderRule.order
499
490
  : [this.model.defaultOrderRule.order];
500
- orders = [...defaultOrders, ...orders];
491
+ const applicableDefaultOrderRule = defaultOrders.filter((order) => !orderColumns.some((o) => o.column === order.column));
492
+ orderColumns = [...applicableDefaultOrderRule, ...orderColumns];
501
493
  }
502
494
  const generatedOrder = [];
503
- for (const order of orders) {
495
+ for (const order of orderColumns) {
504
496
  if (!(order === null || order === void 0 ? void 0 : order.column) || !order.direction) {
505
497
  continue;
506
498
  }
@@ -515,7 +507,7 @@ let FilterService = FilterService_1 = class FilterService {
515
507
  generatedOrder.push(this.sequelizeModelScanner.getOrder(this.repository.model, order));
516
508
  }
517
509
  else {
518
- generatedOrder.push([rule.getOrderOption(this.repository.model), order.direction.toUpperCase()]);
510
+ generatedOrder.push([rule.getOrderOption(this.repository.model, context), order.direction.toUpperCase()]);
519
511
  }
520
512
  }
521
513
  return generatedOrder;
@@ -8,6 +8,7 @@ import { Condition, QueryModel, QueryRuleModel } from "../models/query.model";
8
8
  import { IRule } from "../models/rule.model";
9
9
  import { CustomOperator, FilterOperators, FilterOperatorTypes } from "../operators";
10
10
  import { FilterType } from "../type";
11
+ import { OrderRuleContext } from "../order-rules/order-rule";
11
12
  export interface FilterConditionRule {
12
13
  key: string;
13
14
  path?: string;
@@ -19,9 +20,10 @@ export interface FilterCondition {
19
20
  condition: Condition;
20
21
  rules: (FilterConditionRule | FilterCondition)[];
21
22
  }
23
+ type JsonCallback<Request = unknown> = (context: OrderRuleContext) => string;
22
24
  export interface JsonConfig {
23
25
  type: "array" | "object";
24
- path?: string;
26
+ path?: JsonCallback | string;
25
27
  }
26
28
  export type PathCondition = boolean | {
27
29
  [filter: string]: any;
@@ -90,3 +92,4 @@ export declare abstract class Filter implements FilterDefinition {
90
92
  private transformForJsonArray;
91
93
  private transformForJsonObject;
92
94
  }
95
+ export {};
@@ -12,12 +12,13 @@ export interface OptionsFilterOption {
12
12
  operator?: FilterOperatorTypes;
13
13
  condition?: FilterCondition;
14
14
  }
15
- export type OptionsFilterSelectionMode = "radio" | "select";
15
+ export declare const optionsFilterSelectionModes: readonly ["radio", "select"];
16
+ export type OptionsFilterSelectionMode = (typeof optionsFilterSelectionModes)[number];
16
17
  export interface OptionsFilterDefinition {
17
18
  selectionMode: OptionsFilterSelectionMode;
18
19
  options: OptionsFilterOption[];
19
20
  }
20
- export interface OptionsFilterOptionConfiguration {
21
+ export declare class OptionsFilterOptionConfiguration {
21
22
  key: string;
22
23
  name?: string;
23
24
  }
@@ -1,11 +1,33 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RadioFilter = exports.OptionsFilter = void 0;
12
+ exports.RadioFilter = exports.OptionsFilter = exports.OptionsFilterOptionConfiguration = exports.optionsFilterSelectionModes = void 0;
4
13
  const sequelize_1 = require("sequelize");
5
14
  const filter_utils_1 = require("../filter.utils");
6
15
  const operators_1 = require("../operators");
7
16
  const type_1 = require("../type");
8
17
  const filter_1 = require("./filter");
18
+ const swagger_1 = require("@nestjs/swagger");
19
+ exports.optionsFilterSelectionModes = ["radio", "select"];
20
+ class OptionsFilterOptionConfiguration {
21
+ }
22
+ exports.OptionsFilterOptionConfiguration = OptionsFilterOptionConfiguration;
23
+ __decorate([
24
+ (0, swagger_1.ApiProperty)({ type: () => String }),
25
+ __metadata("design:type", String)
26
+ ], OptionsFilterOptionConfiguration.prototype, "key", void 0);
27
+ __decorate([
28
+ (0, swagger_1.ApiPropertyOptional)({ type: () => String }),
29
+ __metadata("design:type", String)
30
+ ], OptionsFilterOptionConfiguration.prototype, "name", void 0);
9
31
  class OptionsFilter extends filter_1.Filter {
10
32
  constructor(definition) {
11
33
  super(definition);
@@ -2,7 +2,7 @@ import { DataFilterUserModel } from "../..";
2
2
  import { FilterType } from "../type";
3
3
  import { BaseFilterDefinition, Filter } from "./filter";
4
4
  import { FilterBaseConfigurationModel } from "../models/filter-configuration.model";
5
- export interface SelectFilterValue {
5
+ export declare class SelectFilterValue {
6
6
  id: number | string;
7
7
  name: string;
8
8
  }
@@ -1,9 +1,30 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SelectFilter = void 0;
12
+ exports.SelectFilter = exports.SelectFilterValue = void 0;
4
13
  const type_1 = require("../type");
5
14
  const operators_1 = require("../operators");
6
15
  const filter_1 = require("./filter");
16
+ const swagger_1 = require("@nestjs/swagger");
17
+ class SelectFilterValue {
18
+ }
19
+ exports.SelectFilterValue = SelectFilterValue;
20
+ __decorate([
21
+ (0, swagger_1.ApiProperty)({ oneOf: [{ type: "string" }, { type: "number" }] }),
22
+ __metadata("design:type", Object)
23
+ ], SelectFilterValue.prototype, "id", void 0);
24
+ __decorate([
25
+ (0, swagger_1.ApiProperty)({ type: () => String }),
26
+ __metadata("design:type", String)
27
+ ], SelectFilterValue.prototype, "name", void 0);
7
28
  class SelectFilter extends filter_1.Filter {
8
29
  constructor(definition) {
9
30
  super(definition);
@@ -5,6 +5,7 @@ export * from "./filter.service";
5
5
  export * from "./base-filter";
6
6
  export * from "./controllers/dynamic-filter.controller";
7
7
  export * from "./controllers/filter.controller";
8
+ export * from "./controllers/open-api-filter.controller";
8
9
  export * from "./decorators/inject-filter.decorator";
9
10
  export * from "./filter.utils";
10
11
  export * from "./operators";
@@ -21,6 +21,7 @@ __exportStar(require("./filter.service"), exports);
21
21
  __exportStar(require("./base-filter"), exports);
22
22
  __exportStar(require("./controllers/dynamic-filter.controller"), exports);
23
23
  __exportStar(require("./controllers/filter.controller"), exports);
24
+ __exportStar(require("./controllers/open-api-filter.controller"), exports);
24
25
  __exportStar(require("./decorators/inject-filter.decorator"), exports);
25
26
  __exportStar(require("./filter.utils"), exports);
26
27
  __exportStar(require("./operators"), exports);
@@ -1,4 +1,4 @@
1
- export interface FilterConfigurationSearchModel {
1
+ export declare class FilterConfigurationSearchModel {
2
2
  id: string;
3
3
  value: unknown;
4
4
  pageSize?: number;
@@ -1,2 +1,32 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FilterConfigurationSearchModel = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ class FilterConfigurationSearchModel {
15
+ }
16
+ exports.FilterConfigurationSearchModel = FilterConfigurationSearchModel;
17
+ __decorate([
18
+ (0, swagger_1.ApiProperty)({ type: () => String }),
19
+ __metadata("design:type", String)
20
+ ], FilterConfigurationSearchModel.prototype, "id", void 0);
21
+ __decorate([
22
+ (0, swagger_1.ApiProperty)({ type: () => Object }),
23
+ __metadata("design:type", Object)
24
+ ], FilterConfigurationSearchModel.prototype, "value", void 0);
25
+ __decorate([
26
+ (0, swagger_1.ApiPropertyOptional)({ type: () => Number }),
27
+ __metadata("design:type", Number)
28
+ ], FilterConfigurationSearchModel.prototype, "pageSize", void 0);
29
+ __decorate([
30
+ (0, swagger_1.ApiPropertyOptional)({ type: () => Number }),
31
+ __metadata("design:type", Number)
32
+ ], FilterConfigurationSearchModel.prototype, "page", void 0);
@@ -1,14 +1,14 @@
1
1
  import { FilterType } from "../type";
2
2
  import { OptionsFilterOptionConfiguration, OptionsFilterSelectionMode } from "../filters";
3
- export interface FilterOperatorsConfiguration {
3
+ export declare class FilterOperatorsConfiguration {
4
4
  id: string;
5
5
  name: string;
6
6
  }
7
- export interface FilterGroupConfiguration {
7
+ export declare class FilterGroupConfiguration {
8
8
  key: string;
9
9
  name: string;
10
10
  }
11
- export interface FilterBaseConfigurationModel {
11
+ export declare class FilterBaseConfigurationModel {
12
12
  type: FilterType;
13
13
  operators: FilterOperatorsConfiguration[];
14
14
  values?: unknown[];
@@ -18,18 +18,18 @@ export interface FilterBaseConfigurationModel {
18
18
  group?: FilterGroupConfiguration;
19
19
  mask?: string;
20
20
  }
21
- export interface FilterConfigurationModel extends FilterBaseConfigurationModel {
21
+ export declare class FilterConfigurationModel extends FilterBaseConfigurationModel {
22
22
  id: string;
23
23
  name: string;
24
24
  }
25
- export interface GroupFilterBaseConfigurationModel {
25
+ export declare class GroupFilterBaseConfigurationModel {
26
26
  type: FilterType;
27
27
  rootFilter: FilterBaseConfigurationModel | null;
28
28
  valueFilter?: FilterBaseConfigurationModel | null;
29
29
  lazyLoading?: boolean;
30
30
  group?: FilterGroupConfiguration;
31
31
  }
32
- export interface GroupFilterConfigurationModel extends GroupFilterBaseConfigurationModel {
32
+ export declare class GroupFilterConfigurationModel extends GroupFilterBaseConfigurationModel {
33
33
  id: string;
34
34
  name: string;
35
35
  }
@@ -1,2 +1,117 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.GroupFilterConfigurationModel = exports.GroupFilterBaseConfigurationModel = exports.FilterConfigurationModel = exports.FilterBaseConfigurationModel = exports.FilterGroupConfiguration = exports.FilterOperatorsConfiguration = void 0;
13
+ const type_1 = require("../type");
14
+ const filters_1 = require("../filters");
15
+ const swagger_1 = require("@nestjs/swagger");
16
+ class FilterOperatorsConfiguration {
17
+ }
18
+ exports.FilterOperatorsConfiguration = FilterOperatorsConfiguration;
19
+ __decorate([
20
+ (0, swagger_1.ApiProperty)({ type: () => String }),
21
+ __metadata("design:type", String)
22
+ ], FilterOperatorsConfiguration.prototype, "id", void 0);
23
+ __decorate([
24
+ (0, swagger_1.ApiProperty)({ type: () => String }),
25
+ __metadata("design:type", String)
26
+ ], FilterOperatorsConfiguration.prototype, "name", void 0);
27
+ class FilterGroupConfiguration {
28
+ }
29
+ exports.FilterGroupConfiguration = FilterGroupConfiguration;
30
+ __decorate([
31
+ (0, swagger_1.ApiProperty)({ type: () => String }),
32
+ __metadata("design:type", String)
33
+ ], FilterGroupConfiguration.prototype, "key", void 0);
34
+ __decorate([
35
+ (0, swagger_1.ApiProperty)({ type: () => String }),
36
+ __metadata("design:type", String)
37
+ ], FilterGroupConfiguration.prototype, "name", void 0);
38
+ class FilterBaseConfigurationModel {
39
+ }
40
+ exports.FilterBaseConfigurationModel = FilterBaseConfigurationModel;
41
+ __decorate([
42
+ (0, swagger_1.ApiProperty)({ enum: type_1.FilterType, enumName: "FilterType" }),
43
+ __metadata("design:type", String)
44
+ ], FilterBaseConfigurationModel.prototype, "type", void 0);
45
+ __decorate([
46
+ (0, swagger_1.ApiProperty)({ isArray: true, type: () => FilterOperatorsConfiguration }),
47
+ __metadata("design:type", Array)
48
+ ], FilterBaseConfigurationModel.prototype, "operators", void 0);
49
+ __decorate([
50
+ (0, swagger_1.ApiPropertyOptional)({ isArray: true, type: () => Object }),
51
+ __metadata("design:type", Array)
52
+ ], FilterBaseConfigurationModel.prototype, "values", void 0);
53
+ __decorate([
54
+ (0, swagger_1.ApiPropertyOptional)({ type: () => Boolean }),
55
+ __metadata("design:type", Boolean)
56
+ ], FilterBaseConfigurationModel.prototype, "lazyLoading", void 0);
57
+ __decorate([
58
+ (0, swagger_1.ApiPropertyOptional)({ enum: filters_1.optionsFilterSelectionModes, enumName: "OptionsFilterSelectionMode" }),
59
+ __metadata("design:type", String)
60
+ ], FilterBaseConfigurationModel.prototype, "selectionMode", void 0);
61
+ __decorate([
62
+ (0, swagger_1.ApiPropertyOptional)({ isArray: true, type: () => filters_1.OptionsFilterOptionConfiguration }),
63
+ __metadata("design:type", Array)
64
+ ], FilterBaseConfigurationModel.prototype, "options", void 0);
65
+ __decorate([
66
+ (0, swagger_1.ApiPropertyOptional)({ type: () => FilterGroupConfiguration }),
67
+ __metadata("design:type", FilterGroupConfiguration)
68
+ ], FilterBaseConfigurationModel.prototype, "group", void 0);
69
+ __decorate([
70
+ (0, swagger_1.ApiPropertyOptional)({ type: () => String }),
71
+ __metadata("design:type", String)
72
+ ], FilterBaseConfigurationModel.prototype, "mask", void 0);
73
+ class FilterConfigurationModel extends FilterBaseConfigurationModel {
74
+ }
75
+ exports.FilterConfigurationModel = FilterConfigurationModel;
76
+ __decorate([
77
+ (0, swagger_1.ApiProperty)({ type: () => String }),
78
+ __metadata("design:type", String)
79
+ ], FilterConfigurationModel.prototype, "id", void 0);
80
+ __decorate([
81
+ (0, swagger_1.ApiProperty)({ type: () => String }),
82
+ __metadata("design:type", String)
83
+ ], FilterConfigurationModel.prototype, "name", void 0);
84
+ class GroupFilterBaseConfigurationModel {
85
+ }
86
+ exports.GroupFilterBaseConfigurationModel = GroupFilterBaseConfigurationModel;
87
+ __decorate([
88
+ (0, swagger_1.ApiProperty)({ enum: type_1.FilterType, enumName: "FilterType" }),
89
+ __metadata("design:type", String)
90
+ ], GroupFilterBaseConfigurationModel.prototype, "type", void 0);
91
+ __decorate([
92
+ (0, swagger_1.ApiProperty)({ type: () => FilterBaseConfigurationModel }),
93
+ __metadata("design:type", Object)
94
+ ], GroupFilterBaseConfigurationModel.prototype, "rootFilter", void 0);
95
+ __decorate([
96
+ (0, swagger_1.ApiPropertyOptional)({ type: () => FilterBaseConfigurationModel }),
97
+ __metadata("design:type", Object)
98
+ ], GroupFilterBaseConfigurationModel.prototype, "valueFilter", void 0);
99
+ __decorate([
100
+ (0, swagger_1.ApiPropertyOptional)({ type: () => Boolean }),
101
+ __metadata("design:type", Boolean)
102
+ ], GroupFilterBaseConfigurationModel.prototype, "lazyLoading", void 0);
103
+ __decorate([
104
+ (0, swagger_1.ApiPropertyOptional)({ type: () => FilterGroupConfiguration }),
105
+ __metadata("design:type", FilterGroupConfiguration)
106
+ ], GroupFilterBaseConfigurationModel.prototype, "group", void 0);
107
+ class GroupFilterConfigurationModel extends GroupFilterBaseConfigurationModel {
108
+ }
109
+ exports.GroupFilterConfigurationModel = GroupFilterConfigurationModel;
110
+ __decorate([
111
+ (0, swagger_1.ApiProperty)({ type: () => String }),
112
+ __metadata("design:type", String)
113
+ ], GroupFilterConfigurationModel.prototype, "id", void 0);
114
+ __decorate([
115
+ (0, swagger_1.ApiProperty)({ type: () => String }),
116
+ __metadata("design:type", String)
117
+ ], GroupFilterConfigurationModel.prototype, "name", void 0);
@@ -1,4 +1,4 @@
1
- export interface FilterResourceValueModel {
1
+ export declare class FilterResourceValueModel {
2
2
  id: string;
3
3
  resourceId: number | string;
4
4
  }
@@ -1,2 +1,24 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FilterResourceValueModel = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ class FilterResourceValueModel {
15
+ }
16
+ exports.FilterResourceValueModel = FilterResourceValueModel;
17
+ __decorate([
18
+ (0, swagger_1.ApiProperty)({ type: () => String }),
19
+ __metadata("design:type", String)
20
+ ], FilterResourceValueModel.prototype, "id", void 0);
21
+ __decorate([
22
+ (0, swagger_1.ApiProperty)({ oneOf: [{ type: "string" }, { type: "number" }] }),
23
+ __metadata("design:type", Object)
24
+ ], FilterResourceValueModel.prototype, "resourceId", void 0);
@@ -1,9 +1,11 @@
1
1
  import { RuleModel } from "./rule.model";
2
- export type Condition = "and" | "or";
3
- export interface QueryRuleModel extends RuleModel {
2
+ declare const conditions: readonly ["and", "or"];
3
+ export type Condition = (typeof conditions)[number];
4
+ export declare class QueryRuleModel extends RuleModel {
4
5
  id: string;
5
6
  }
6
- export interface QueryModel {
7
+ export declare class QueryModel {
7
8
  condition: Condition;
8
9
  rules: (QueryRuleModel | QueryModel)[];
9
10
  }
11
+ export {};
@@ -1,2 +1,41 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.QueryModel = exports.QueryRuleModel = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const rule_model_1 = require("./rule.model");
15
+ const conditions = ["and", "or"];
16
+ class QueryRuleModel extends rule_model_1.RuleModel {
17
+ }
18
+ exports.QueryRuleModel = QueryRuleModel;
19
+ __decorate([
20
+ (0, swagger_1.ApiProperty)({ type: () => String }),
21
+ __metadata("design:type", String)
22
+ ], QueryRuleModel.prototype, "id", void 0);
23
+ let QueryModel = class QueryModel {
24
+ };
25
+ exports.QueryModel = QueryModel;
26
+ __decorate([
27
+ (0, swagger_1.ApiProperty)({ enum: conditions, enumName: "Condition" }),
28
+ __metadata("design:type", String)
29
+ ], QueryModel.prototype, "condition", void 0);
30
+ __decorate([
31
+ (0, swagger_1.ApiProperty)({
32
+ oneOf: [
33
+ { type: "array", items: { $ref: (0, swagger_1.getSchemaPath)(QueryRuleModel) } },
34
+ { type: "array", items: { $ref: (0, swagger_1.getSchemaPath)(QueryModel) } },
35
+ ],
36
+ }),
37
+ __metadata("design:type", Array)
38
+ ], QueryModel.prototype, "rules", void 0);
39
+ exports.QueryModel = QueryModel = __decorate([
40
+ (0, swagger_1.ApiExtraModels)(QueryRuleModel)
41
+ ], QueryModel);