@opra/common 1.7.4 → 1.8.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 (33) hide show
  1. package/browser/index.cjs +5 -5
  2. package/browser/index.mjs +5 -5
  3. package/cjs/document/data-type/api-field.js +2 -0
  4. package/cjs/document/decorators/api-field-decorator.js +1 -0
  5. package/cjs/filter/antlr/OpraFilterLexer.js +212 -347
  6. package/cjs/filter/antlr/OpraFilterListener.js +1 -1
  7. package/cjs/filter/antlr/OpraFilterParser.js +198 -227
  8. package/cjs/filter/antlr/OpraFilterVisitor.js +1 -1
  9. package/cjs/filter/ast/index.js +1 -0
  10. package/cjs/filter/ast/terms/date-time-literal.js +27 -0
  11. package/cjs/filter/build.js +3 -1
  12. package/cjs/filter/filter-tree-visitor.js +1 -1
  13. package/esm/document/data-type/api-field.js +2 -0
  14. package/esm/document/decorators/api-field-decorator.js +1 -0
  15. package/esm/filter/antlr/OpraFilterLexer.js +213 -348
  16. package/esm/filter/antlr/OpraFilterListener.js +2 -2
  17. package/esm/filter/antlr/OpraFilterParser.js +198 -227
  18. package/esm/filter/antlr/OpraFilterVisitor.js +1 -1
  19. package/esm/filter/ast/index.js +1 -0
  20. package/esm/filter/ast/terms/date-time-literal.js +23 -0
  21. package/esm/filter/build.js +3 -1
  22. package/esm/filter/filter-tree-visitor.js +2 -2
  23. package/package.json +2 -2
  24. package/types/document/data-type/api-field.d.ts +2 -1
  25. package/types/document/decorators/api-field-decorator.d.ts +2 -2
  26. package/types/filter/antlr/OpraFilterLexer.d.ts +1 -1
  27. package/types/filter/antlr/OpraFilterListener.d.ts +36 -10
  28. package/types/filter/antlr/OpraFilterParser.d.ts +1 -1
  29. package/types/filter/antlr/OpraFilterVisitor.d.ts +31 -5
  30. package/types/filter/ast/index.d.ts +1 -0
  31. package/types/filter/ast/terms/date-time-literal.d.ts +6 -0
  32. package/types/filter/filter-tree-visitor.d.ts +2 -2
  33. package/types/schema/data-type/field.interface.d.ts +16 -1
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Generated from ./src/filter/antlr/OpraFilter.g4 by ANTLR 4.12.0
2
+ // Generated from ./src/filter/antlr/OpraFilter.g4 by ANTLR 4.13.2
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const antlr4_1 = require("@browsery/antlr4");
5
5
  /**
@@ -13,6 +13,7 @@ tslib_1.__exportStar(require("./expressions/negative-expression.js"), exports);
13
13
  tslib_1.__exportStar(require("./expressions/parenthesized-expression.js"), exports);
14
14
  tslib_1.__exportStar(require("./terms/boolean-literal.js"), exports);
15
15
  tslib_1.__exportStar(require("./terms/date-literal.js"), exports);
16
+ tslib_1.__exportStar(require("./terms/date-time-literal.js"), exports);
16
17
  tslib_1.__exportStar(require("./terms/null-literal.js"), exports);
17
18
  tslib_1.__exportStar(require("./terms/number-literal.js"), exports);
18
19
  tslib_1.__exportStar(require("./terms/qualified-identifier.js"), exports);
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DateTimeLiteral = void 0;
4
+ const putil_varhelpers_1 = require("putil-varhelpers");
5
+ const errors_js_1 = require("../../errors.js");
6
+ const utils_js_1 = require("../../utils.js");
7
+ const literal_js_1 = require("../abstract/literal.js");
8
+ const NullDate = new Date(0);
9
+ class DateTimeLiteral extends literal_js_1.Literal {
10
+ constructor(value) {
11
+ super('');
12
+ if (value instanceof Date) {
13
+ this.value = value.toISOString();
14
+ return;
15
+ }
16
+ // noinspection SuspiciousTypeOfGuard
17
+ if (typeof value === 'string' && (0, putil_varhelpers_1.toDateDef)(value, NullDate) !== NullDate) {
18
+ this.value = value;
19
+ return;
20
+ }
21
+ throw new errors_js_1.FilterValidationError(`Invalid date-time value "${value}"`);
22
+ }
23
+ toString() {
24
+ return (0, utils_js_1.quoteFilterString)(this.value);
25
+ }
26
+ }
27
+ exports.DateTimeLiteral = DateTimeLiteral;
@@ -104,7 +104,9 @@ function $arithmetic(n) {
104
104
  return exp;
105
105
  }
106
106
  function comparisonExpression(op, left, right) {
107
- const lex = wrapEntryValue(left);
107
+ const lex = typeof left === 'string'
108
+ ? new index_js_1.QualifiedIdentifier(left)
109
+ : wrapEntryValue(left);
108
110
  const rex = wrapEntryValue(right);
109
111
  return new index_js_1.ComparisonExpression({ op, left: lex, right: rex });
110
112
  }
@@ -85,7 +85,7 @@ class FilterTreeVisitor extends antlr4_1.ParseTreeVisitor {
85
85
  return new index_js_1.DateLiteral((0, utils_js_1.unquoteFilterString)(ctx.getText()));
86
86
  }
87
87
  visitDateTimeLiteral(ctx) {
88
- return new index_js_1.DateLiteral((0, utils_js_1.unquoteFilterString)(ctx.getText()));
88
+ return new index_js_1.DateTimeLiteral((0, utils_js_1.unquoteFilterString)(ctx.getText()));
89
89
  }
90
90
  visitTimeLiteral(ctx) {
91
91
  return new index_js_1.TimeLiteral((0, utils_js_1.unquoteFilterString)(ctx.getText()));
@@ -33,6 +33,7 @@ export const ApiField = function (...args) {
33
33
  _this.type = initArgs.type || owner.node.getDataType('any');
34
34
  _this.description = initArgs.description;
35
35
  _this.isArray = initArgs.isArray;
36
+ _this.isNestedEntity = initArgs.isNestedEntity;
36
37
  _this.default = initArgs.default;
37
38
  _this.fixed = initArgs.fixed;
38
39
  _this.required = initArgs.required;
@@ -93,6 +94,7 @@ class ApiFieldClass extends DocumentElement {
93
94
  type: typeName ? typeName : this.type?.toJSON(options),
94
95
  description: this.description,
95
96
  isArray: this.isArray || undefined,
97
+ isNestedEntity: this.isNestedEntity || undefined,
96
98
  default: this.default,
97
99
  fixed: this.fixed,
98
100
  required: this.required || undefined,
@@ -37,6 +37,7 @@ export function ApiFieldDecoratorFactory(options) {
37
37
  scopePattern: Array.isArray(scopes) ? scopes : [scopes],
38
38
  type: undefined,
39
39
  isArray: undefined,
40
+ isNestedEntity: undefined,
40
41
  }));
41
42
  });
42
43
  return decorator;