@opra/common 0.17.1 → 0.17.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.
Files changed (62) hide show
  1. package/browser.js +12220 -0
  2. package/cjs/document/data-type/complex-type.js +1 -1
  3. package/cjs/document/resource/collection.js +13 -7
  4. package/cjs/filter/antlr/OpraFilterLexer.js +209 -238
  5. package/cjs/filter/antlr/OpraFilterListener.js +1 -1
  6. package/cjs/filter/antlr/OpraFilterParser.js +795 -1482
  7. package/cjs/filter/antlr/OpraFilterVisitor.js +1 -1
  8. package/cjs/filter/ast/expressions/logical-expression.js +4 -0
  9. package/cjs/filter/ast/expressions/{parentheses-expression.js → negative-expression.js} +3 -3
  10. package/cjs/filter/ast/expressions/parenthesized-expression.js +14 -0
  11. package/cjs/filter/ast/index.js +2 -1
  12. package/cjs/filter/build.js +1 -1
  13. package/cjs/filter/filter-tree-visitor.js +44 -66
  14. package/cjs/filter/index.js +2 -5
  15. package/cjs/filter/opra-filter.ns.js +8 -0
  16. package/cjs/filter/parse.js +5 -6
  17. package/cjs/http/codecs/filter-codec.js +2 -2
  18. package/cjs/http/http-message.host.js +6 -6
  19. package/cjs/http/http-request-message.js +3 -3
  20. package/cjs/http/http-response-message.js +2 -2
  21. package/cjs/http/multipart/batch-multipart.js +1 -1
  22. package/cjs/i18n/i18n.js +1 -1
  23. package/esm/document/data-type/complex-type.js +1 -1
  24. package/esm/document/resource/collection.js +14 -8
  25. package/esm/filter/antlr/OpraFilterLexer.js +209 -238
  26. package/esm/filter/antlr/OpraFilterListener.js +1 -1
  27. package/esm/filter/antlr/OpraFilterParser.js +775 -1448
  28. package/esm/filter/antlr/OpraFilterVisitor.js +1 -1
  29. package/esm/filter/ast/expressions/logical-expression.js +4 -0
  30. package/esm/filter/ast/expressions/{parentheses-expression.js → negative-expression.js} +1 -1
  31. package/esm/filter/ast/expressions/parenthesized-expression.js +10 -0
  32. package/esm/filter/ast/index.js +2 -1
  33. package/esm/filter/build.js +2 -2
  34. package/esm/filter/filter-tree-visitor.js +46 -68
  35. package/esm/filter/index.js +1 -5
  36. package/esm/filter/opra-filter.ns.js +5 -0
  37. package/esm/filter/parse.js +3 -4
  38. package/esm/http/codecs/filter-codec.js +2 -2
  39. package/esm/http/http-message.host.js +1 -1
  40. package/esm/http/http-request-message.js +1 -1
  41. package/esm/http/http-response-message.js +1 -1
  42. package/esm/http/multipart/batch-multipart.js +1 -1
  43. package/esm/i18n/i18n.js +1 -1
  44. package/package.json +30 -18
  45. package/types/document/resource/collection.d.ts +2 -2
  46. package/types/filter/antlr/OpraFilterLexer.d.ts +9 -22
  47. package/types/filter/antlr/OpraFilterListener.d.ts +89 -217
  48. package/types/filter/antlr/OpraFilterParser.d.ts +91 -206
  49. package/types/filter/antlr/OpraFilterVisitor.d.ts +49 -124
  50. package/types/filter/ast/expressions/{parentheses-expression.d.ts → negative-expression.d.ts} +1 -1
  51. package/types/filter/ast/expressions/parenthesized-expression.d.ts +6 -0
  52. package/types/filter/ast/index.d.ts +2 -1
  53. package/types/filter/build.d.ts +2 -2
  54. package/types/filter/filter-tree-visitor.d.ts +10 -11
  55. package/types/filter/index.d.ts +1 -5
  56. package/types/filter/opra-filter.ns.d.ts +5 -0
  57. package/types/filter/parse.d.ts +1 -1
  58. package/types/http/http-message.host.d.ts +1 -1
  59. package/types/i18n/i18n.d.ts +2 -2
  60. package/types/i18n/translate.d.ts +1 -1
  61. package/types/schema/data-type/complex-type.interface.d.ts +1 -1
  62. package/types/schema/resource/endpoint.interface.d.ts +2 -2
@@ -142,7 +142,7 @@ const proto = {
142
142
  if (dataType && !dataType.additionalFields) {
143
143
  if (silent)
144
144
  return { done: true, value: [] };
145
- throw new Error(`Invalid field definition "${curPath}"`);
145
+ throw new Error(`Unknown or Invalid field (${curPath})`);
146
146
  }
147
147
  }
148
148
  }
@@ -137,23 +137,29 @@ const proto = {
137
137
  });
138
138
  return normalized;
139
139
  },
140
- normalizeFilter(ast) {
141
- if (ast instanceof index_js_2.ComparisonExpression) {
140
+ normalizeFilter(filter) {
141
+ if (!filter)
142
+ return;
143
+ const ast = typeof filter === 'string' ? index_js_2.OpraFilter.parse(filter) : filter;
144
+ if (ast instanceof index_js_2.OpraFilter.ComparisonExpression) {
142
145
  this.normalizeFilter(ast.left);
146
+ if (!(ast.left instanceof index_js_2.OpraFilter.QualifiedIdentifier && ast.left.field))
147
+ throw new TypeError(`Invalid filter query. Left side should be a data field.`);
148
+ this.normalizeFilter(ast.right);
143
149
  }
144
- else if (ast instanceof index_js_2.LogicalExpression) {
150
+ else if (ast instanceof index_js_2.OpraFilter.LogicalExpression) {
145
151
  ast.items.forEach(item => this.normalizeFilter(item));
146
152
  }
147
- else if (ast instanceof index_js_2.ArithmeticExpression) {
153
+ else if (ast instanceof index_js_2.OpraFilter.ArithmeticExpression) {
148
154
  ast.items.forEach(item => this.normalizeFilter(item.expression));
149
155
  }
150
- else if (ast instanceof index_js_2.ArrayExpression) {
156
+ else if (ast instanceof index_js_2.OpraFilter.ArrayExpression) {
151
157
  ast.items.forEach(item => this.normalizeFilter(item));
152
158
  }
153
- else if (ast instanceof index_js_2.ParenthesesExpression) {
159
+ else if (ast instanceof index_js_2.OpraFilter.ParenthesizedExpression) {
154
160
  this.normalizeFilter(ast.expression);
155
161
  }
156
- else if (ast instanceof index_js_2.QualifiedIdentifier) {
162
+ else if (ast instanceof index_js_2.OpraFilter.QualifiedIdentifier) {
157
163
  ast.field = this.type.findField(ast.value);
158
164
  ast.dataType = ast.field?.type || this.document.getDataType('any');
159
165
  ast.value = this.type.normalizeFieldPath(ast.value);