@opra/common 1.9.1 → 1.9.3

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.
@@ -49,7 +49,7 @@ exports.MappedType = function (...args) {
49
49
  const required = Array.isArray(_this.required)
50
50
  ? _this.required.map(x => x.toLowerCase())
51
51
  : _this.required;
52
- for (const [k, v] of _this.base.fieldEntries()) {
52
+ for (const [k, v] of _this.base.fieldEntries('*')) {
53
53
  if (!isInheritedPredicate(k))
54
54
  continue;
55
55
  const meta = { ...v };
@@ -125,6 +125,11 @@ function createFilterDecorator(decorator, decoratorChain, dataType) {
125
125
  }
126
126
  : arg0) || {};
127
127
  filterOptions.operators = filterOptions.operators || ['=', '!='];
128
+ if (field.includes(':')) {
129
+ const a = field.split(':');
130
+ field = a[0];
131
+ filterOptions.mappedField = a[1];
132
+ }
128
133
  decoratorChain.push(() => {
129
134
  filterRules.set(field, filterOptions);
130
135
  filterType.rules = filterRules.toJSON();
@@ -69,6 +69,8 @@ class FilterRules {
69
69
  },
70
70
  });
71
71
  }
72
+ if (rule.mappedField)
73
+ ast.left.value = rule.mappedField;
72
74
  if (rule.prepare)
73
75
  ast.prepare = rule.prepare;
74
76
  this.normalizeFilterAst(ast.right, stack, currentType);
@@ -46,7 +46,7 @@ export const MappedType = function (...args) {
46
46
  const required = Array.isArray(_this.required)
47
47
  ? _this.required.map(x => x.toLowerCase())
48
48
  : _this.required;
49
- for (const [k, v] of _this.base.fieldEntries()) {
49
+ for (const [k, v] of _this.base.fieldEntries('*')) {
50
50
  if (!isInheritedPredicate(k))
51
51
  continue;
52
52
  const meta = { ...v };
@@ -119,6 +119,11 @@ export function createFilterDecorator(decorator, decoratorChain, dataType) {
119
119
  }
120
120
  : arg0) || {};
121
121
  filterOptions.operators = filterOptions.operators || ['=', '!='];
122
+ if (field.includes(':')) {
123
+ const a = field.split(':');
124
+ field = a[0];
125
+ filterOptions.mappedField = a[1];
126
+ }
122
127
  decoratorChain.push(() => {
123
128
  filterRules.set(field, filterOptions);
124
129
  filterType.rules = filterRules.toJSON();
@@ -66,6 +66,8 @@ export class FilterRules {
66
66
  },
67
67
  });
68
68
  }
69
+ if (rule.mappedField)
70
+ ast.left.value = rule.mappedField;
69
71
  if (rule.prepare)
70
72
  ast.prepare = rule.prepare;
71
73
  this.normalizeFilterAst(ast.right, stack, currentType);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "1.9.1",
3
+ "version": "1.9.3",
4
4
  "description": "Opra common package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  "super-fast-md5": "^1.0.3",
19
19
  "tslib": "^2.8.1",
20
20
  "uid": "^2.0.2",
21
- "valgen": "^5.12.0"
21
+ "valgen": "^5.13.0"
22
22
  },
23
23
  "type": "module",
24
24
  "exports": {
@@ -52,6 +52,7 @@ declare module '../http/http-operation.js' {
52
52
  }
53
53
  /** DeleteMany */
54
54
  interface FilterOptions {
55
+ mappedField?: string;
55
56
  operators?: OpraFilter.ComparisonOperator[];
56
57
  notes?: string;
57
58
  prepare?: (args: OpraFilter.ComparisonExpression.PrepareArgs) => any;
@@ -13,6 +13,7 @@ export declare namespace FilterRules {
13
13
  operators?: ComparisonOperator[];
14
14
  description?: string;
15
15
  prepare?: (args: ComparisonExpression.PrepareArgs) => any;
16
+ mappedField?: string;
16
17
  }
17
18
  }
18
19
  export declare class FilterRules {