@opra/common 0.16.2 → 0.17.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 (148) hide show
  1. package/cjs/document/data-type/complex-type.js +69 -56
  2. package/cjs/document/data-type/simple-type.js +0 -1
  3. package/cjs/document/resource/collection.js +15 -16
  4. package/cjs/document/resource/singleton.js +2 -2
  5. package/cjs/http/http-params.js +10 -11
  6. package/esm/document/api-document.js +33 -37
  7. package/esm/document/constants.js +3 -6
  8. package/esm/document/data-type/api-field.js +12 -15
  9. package/esm/document/data-type/builtin/any.type.js +5 -8
  10. package/esm/document/data-type/builtin/base64.type.js +5 -8
  11. package/esm/document/data-type/builtin/bigint.type.js +5 -8
  12. package/esm/document/data-type/builtin/boolean.type.js +8 -11
  13. package/esm/document/data-type/builtin/date.type.js +7 -10
  14. package/esm/document/data-type/builtin/guid.type.js +9 -12
  15. package/esm/document/data-type/builtin/index.js +10 -13
  16. package/esm/document/data-type/builtin/integer.type.js +10 -13
  17. package/esm/document/data-type/builtin/number.type.js +7 -10
  18. package/esm/document/data-type/builtin/object.type.js +5 -8
  19. package/esm/document/data-type/builtin/string.type.js +8 -11
  20. package/esm/document/data-type/builtin/time.type.js +7 -10
  21. package/esm/document/data-type/builtin/timestamp.type.js +9 -12
  22. package/esm/document/data-type/complex-type.js +94 -85
  23. package/esm/document/data-type/data-type.js +9 -12
  24. package/esm/document/data-type/enum-type.js +15 -19
  25. package/esm/document/data-type/mapped-type.js +24 -29
  26. package/esm/document/data-type/simple-type.js +17 -22
  27. package/esm/document/data-type/union-type.js +26 -29
  28. package/esm/document/factory/add-references.js +3 -7
  29. package/esm/document/factory/create-document.js +10 -16
  30. package/esm/document/factory/factory.js +33 -37
  31. package/esm/document/factory/import-resource-class.js +16 -22
  32. package/esm/document/factory/import-type-class.js +24 -34
  33. package/esm/document/factory/index.js +1 -4
  34. package/esm/document/factory/process-resources.js +10 -16
  35. package/esm/document/factory/process-types.js +31 -37
  36. package/esm/document/index.js +14 -17
  37. package/esm/document/resource/collection.js +58 -63
  38. package/esm/document/resource/resource.js +9 -12
  39. package/esm/document/resource/singleton.js +27 -31
  40. package/esm/document/utils/inspect.util.js +4 -7
  41. package/esm/document/utils/string-compare.util.js +1 -5
  42. package/esm/exception/enums/issue-severity.enum.js +2 -5
  43. package/esm/exception/error-issue.js +1 -2
  44. package/esm/exception/http-errors/bad-request.error.js +4 -8
  45. package/esm/exception/http-errors/failed-dependency.error.js +4 -8
  46. package/esm/exception/http-errors/forbidden.error.js +4 -8
  47. package/esm/exception/http-errors/internal-server.error.js +4 -8
  48. package/esm/exception/http-errors/method-not-allowed.error.js +4 -8
  49. package/esm/exception/http-errors/not-acceptable.error.js +4 -8
  50. package/esm/exception/http-errors/not-found.error.js +4 -8
  51. package/esm/exception/http-errors/unauthorized.error.js +4 -8
  52. package/esm/exception/http-errors/unprocessable-entity.error.js +4 -8
  53. package/esm/exception/index.js +15 -18
  54. package/esm/exception/opra-exception.js +3 -7
  55. package/esm/exception/resource-errors/resource-conflict.error.js +4 -8
  56. package/esm/exception/resource-errors/resource-not-found.error.js +4 -8
  57. package/esm/exception/wrap-exception.js +20 -24
  58. package/esm/filter/antlr/OpraFilterLexer.js +6 -9
  59. package/esm/filter/antlr/OpraFilterListener.js +2 -5
  60. package/esm/filter/antlr/OpraFilterParser.js +79 -126
  61. package/esm/filter/antlr/OpraFilterVisitor.js +2 -5
  62. package/esm/filter/ast/abstract/ast.js +1 -5
  63. package/esm/filter/ast/abstract/expression.js +2 -6
  64. package/esm/filter/ast/abstract/literal.js +2 -6
  65. package/esm/filter/ast/abstract/term.js +2 -6
  66. package/esm/filter/ast/expressions/arithmetic-expression.js +3 -8
  67. package/esm/filter/ast/expressions/array-expression.js +2 -6
  68. package/esm/filter/ast/expressions/comparison-expression.js +2 -6
  69. package/esm/filter/ast/expressions/logical-expression.js +2 -6
  70. package/esm/filter/ast/expressions/parentheses-expression.js +2 -6
  71. package/esm/filter/ast/index.js +16 -19
  72. package/esm/filter/ast/terms/boolean-literal.js +2 -6
  73. package/esm/filter/ast/terms/date-literal.js +8 -12
  74. package/esm/filter/ast/terms/external-constant.js +2 -6
  75. package/esm/filter/ast/terms/null-literal.js +2 -6
  76. package/esm/filter/ast/terms/number-literal.js +4 -8
  77. package/esm/filter/ast/terms/qualified-identifier.js +2 -6
  78. package/esm/filter/ast/terms/string-literal.js +4 -8
  79. package/esm/filter/ast/terms/time-literal.js +6 -10
  80. package/esm/filter/build.js +45 -69
  81. package/esm/filter/errors.js +3 -9
  82. package/esm/filter/filter-tree-visitor.js +26 -31
  83. package/esm/filter/index.js +5 -8
  84. package/esm/filter/opra-error-listener.js +4 -8
  85. package/esm/filter/parse.js +14 -19
  86. package/esm/filter/utils.js +2 -7
  87. package/esm/helpers/function-utils.js +8 -14
  88. package/esm/helpers/get-stack-filename.js +1 -5
  89. package/esm/helpers/index.js +8 -11
  90. package/esm/helpers/is-url.js +1 -5
  91. package/esm/helpers/mixin-utils.js +2 -7
  92. package/esm/helpers/object-utils.js +6 -12
  93. package/esm/helpers/path-to-object-tree.js +1 -5
  94. package/esm/helpers/responsive-map.js +1 -5
  95. package/esm/helpers/type-guards.js +7 -17
  96. package/esm/http/codecs/boolean-codec.js +1 -5
  97. package/esm/http/codecs/date-codec.js +1 -5
  98. package/esm/http/codecs/filter-codec.js +5 -9
  99. package/esm/http/codecs/integer-codec.js +2 -6
  100. package/esm/http/codecs/number-codec.js +1 -5
  101. package/esm/http/codecs/string-codec.js +1 -5
  102. package/esm/http/enums/http-headers-codes.enum.js +2 -5
  103. package/esm/http/enums/http-status-codes.enum.js +2 -5
  104. package/esm/http/enums/http-status-messages.js +1 -4
  105. package/esm/http/http-headers.js +5 -9
  106. package/esm/http/http-message.host.js +13 -18
  107. package/esm/http/http-params.js +30 -36
  108. package/esm/http/http-request-message.js +18 -22
  109. package/esm/http/http-response-message.js +23 -28
  110. package/esm/http/index.js +14 -17
  111. package/esm/http/interfaces/client-http-headers.interface.js +1 -2
  112. package/esm/http/interfaces/cookie-options.interface.js +1 -2
  113. package/esm/http/interfaces/server-http-headers.interface.js +1 -2
  114. package/esm/i18n/i18n.js +23 -28
  115. package/esm/i18n/index.js +5 -9
  116. package/esm/i18n/string-utils.js +2 -7
  117. package/esm/i18n/translate.js +3 -7
  118. package/esm/index.js +11 -16
  119. package/esm/schema/constants.js +1 -4
  120. package/esm/schema/data-type/complex-type.interface.js +2 -5
  121. package/esm/schema/data-type/data-type.interface.js +1 -2
  122. package/esm/schema/data-type/enum-type.interface.js +2 -5
  123. package/esm/schema/data-type/field.interface.js +1 -2
  124. package/esm/schema/data-type/mapped-type.interface.js +2 -5
  125. package/esm/schema/data-type/simple-type.interface.js +2 -5
  126. package/esm/schema/data-type/union-type.interface.js +2 -5
  127. package/esm/schema/document.interface.js +1 -2
  128. package/esm/schema/index.js +31 -34
  129. package/esm/schema/resource/collection.interface.js +2 -5
  130. package/esm/schema/resource/container.interface.js +2 -5
  131. package/esm/schema/resource/endpoint.interface.js +1 -2
  132. package/esm/schema/resource/resource.interface.js +1 -2
  133. package/esm/schema/resource/singleton.interface.js +2 -5
  134. package/esm/schema/type-guards.js +40 -53
  135. package/esm/types.js +1 -2
  136. package/esm/url/index.js +5 -8
  137. package/esm/url/opra-url-path-component.js +3 -7
  138. package/esm/url/opra-url-path.js +14 -18
  139. package/esm/url/opra-url.js +15 -19
  140. package/esm/url/utils/decode-path-component.js +4 -8
  141. package/esm/url/utils/encode-path-component.js +3 -8
  142. package/esm/utils/path-utils.js +2 -7
  143. package/package.json +1 -1
  144. package/types/document/data-type/complex-type.d.ts +8 -2
  145. package/types/document/resource/collection.d.ts +5 -3
  146. package/types/document/resource/singleton.d.ts +3 -1
  147. package/types/filter/ast/terms/qualified-identifier.d.ts +4 -0
  148. package/types/http/http-params.d.ts +20 -19
@@ -1,7 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  // Generated from ./src/filter/antlr/OpraFilter.g4 by ANTLR 4.11.2-SNAPSHOT
4
- const antlr4_1 = require("@browsery/antlr4");
2
+ import { ParseTreeVisitor } from '@browsery/antlr4';
5
3
  /**
6
4
  * This interface defines a complete generic visitor for a parse tree produced
7
5
  * by `OpraFilterParser`.
@@ -9,6 +7,5 @@ const antlr4_1 = require("@browsery/antlr4");
9
7
  * @param <Result> The return type of the visit operation. Use `void` for
10
8
  * operations with no return type.
11
9
  */
12
- class OpraFilterVisitor extends antlr4_1.ParseTreeVisitor {
10
+ export default class OpraFilterVisitor extends ParseTreeVisitor {
13
11
  }
14
- exports.default = OpraFilterVisitor;
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Ast = void 0;
4
- class Ast {
1
+ export class Ast {
5
2
  constructor() {
6
3
  this.kind = Object.getPrototypeOf(this).constructor.name;
7
4
  }
8
5
  }
9
- exports.Ast = Ast;
@@ -1,7 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Expression = void 0;
4
- const ast_js_1 = require("./ast.js");
5
- class Expression extends ast_js_1.Ast {
1
+ import { Ast } from './ast.js';
2
+ export class Expression extends Ast {
6
3
  }
7
- exports.Expression = Expression;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Literal = void 0;
4
- const term_js_1 = require("./term.js");
5
- class Literal extends term_js_1.Term {
1
+ import { Term } from './term.js';
2
+ export class Literal extends Term {
6
3
  constructor(value) {
7
4
  super();
8
5
  this.value = value;
@@ -11,4 +8,3 @@ class Literal extends term_js_1.Term {
11
8
  return '' + this.value;
12
9
  }
13
10
  }
14
- exports.Literal = Literal;
@@ -1,7 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Term = void 0;
4
- const expression_js_1 = require("./expression.js");
5
- class Term extends expression_js_1.Expression {
1
+ import { Expression } from './expression.js';
2
+ export class Term extends Expression {
6
3
  }
7
- exports.Term = Term;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArithmeticExpressionItem = exports.ArithmeticExpression = void 0;
4
- const expression_js_1 = require("../abstract/expression.js");
5
- class ArithmeticExpression extends expression_js_1.Expression {
1
+ import { Expression } from '../abstract/expression.js';
2
+ export class ArithmeticExpression extends Expression {
6
3
  constructor() {
7
4
  super();
8
5
  this.items = [];
@@ -18,10 +15,8 @@ class ArithmeticExpression extends expression_js_1.Expression {
18
15
  return this.items.map((child, i) => (i > 0 ? child.op : '') + child.expression).join('');
19
16
  }
20
17
  }
21
- exports.ArithmeticExpression = ArithmeticExpression;
22
- class ArithmeticExpressionItem {
18
+ export class ArithmeticExpressionItem {
23
19
  constructor(o) {
24
20
  Object.assign(this, o);
25
21
  }
26
22
  }
27
- exports.ArithmeticExpressionItem = ArithmeticExpressionItem;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayExpression = void 0;
4
- const term_js_1 = require("../abstract/term.js");
5
- class ArrayExpression extends term_js_1.Term {
1
+ import { Term } from '../abstract/term.js';
2
+ export class ArrayExpression extends Term {
6
3
  constructor(items) {
7
4
  super();
8
5
  this.items = items;
@@ -11,4 +8,3 @@ class ArrayExpression extends term_js_1.Term {
11
8
  return '[' + this.items.map(child => '' + child).join(',') + ']';
12
9
  }
13
10
  }
14
- exports.ArrayExpression = ArrayExpression;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ComparisonExpression = void 0;
4
- const expression_js_1 = require("../abstract/expression.js");
1
+ import { Expression } from '../abstract/expression.js';
5
2
  const WORD_PATTERN = /\w/;
6
- class ComparisonExpression extends expression_js_1.Expression {
3
+ export class ComparisonExpression extends Expression {
7
4
  constructor(o) {
8
5
  super();
9
6
  Object.assign(this, o);
@@ -12,4 +9,3 @@ class ComparisonExpression extends expression_js_1.Expression {
12
9
  return `${this.left}${WORD_PATTERN.test(this.op) ? ' ' + this.op + ' ' : this.op}${this.right}`;
13
10
  }
14
11
  }
15
- exports.ComparisonExpression = ComparisonExpression;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LogicalExpression = void 0;
4
- const expression_js_1 = require("../abstract/expression.js");
5
- class LogicalExpression extends expression_js_1.Expression {
1
+ import { Expression } from '../abstract/expression.js';
2
+ export class LogicalExpression extends Expression {
6
3
  constructor(o) {
7
4
  super();
8
5
  Object.assign(this, o);
@@ -13,4 +10,3 @@ class LogicalExpression extends expression_js_1.Expression {
13
10
  .join(' ' + this.op + ' ');
14
11
  }
15
12
  }
16
- exports.LogicalExpression = LogicalExpression;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParenthesesExpression = void 0;
4
- const expression_js_1 = require("../abstract/expression.js");
5
- class ParenthesesExpression extends expression_js_1.Expression {
1
+ import { Expression } from '../abstract/expression.js';
2
+ export class ParenthesesExpression extends Expression {
6
3
  constructor(expression) {
7
4
  super();
8
5
  this.expression = expression;
@@ -11,4 +8,3 @@ class ParenthesesExpression extends expression_js_1.Expression {
11
8
  return `(${this.expression})`;
12
9
  }
13
10
  }
14
- exports.ParenthesesExpression = ParenthesesExpression;
@@ -1,19 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./abstract/ast.js"), exports);
5
- tslib_1.__exportStar(require("./abstract/expression.js"), exports);
6
- tslib_1.__exportStar(require("./abstract/literal.js"), exports);
7
- tslib_1.__exportStar(require("./abstract/term.js"), exports);
8
- tslib_1.__exportStar(require("./expressions/arithmetic-expression.js"), exports);
9
- tslib_1.__exportStar(require("./expressions/array-expression.js"), exports);
10
- tslib_1.__exportStar(require("./expressions/comparison-expression.js"), exports);
11
- tslib_1.__exportStar(require("./expressions/logical-expression.js"), exports);
12
- tslib_1.__exportStar(require("./expressions/parentheses-expression.js"), exports);
13
- tslib_1.__exportStar(require("./terms/boolean-literal.js"), exports);
14
- tslib_1.__exportStar(require("./terms/date-literal.js"), exports);
15
- tslib_1.__exportStar(require("./terms/null-literal.js"), exports);
16
- tslib_1.__exportStar(require("./terms/number-literal.js"), exports);
17
- tslib_1.__exportStar(require("./terms/qualified-identifier.js"), exports);
18
- tslib_1.__exportStar(require("./terms/string-literal.js"), exports);
19
- tslib_1.__exportStar(require("./terms/time-literal.js"), exports);
1
+ export * from './abstract/ast.js';
2
+ export * from './abstract/expression.js';
3
+ export * from './abstract/literal.js';
4
+ export * from './abstract/term.js';
5
+ export * from './expressions/arithmetic-expression.js';
6
+ export * from './expressions/array-expression.js';
7
+ export * from './expressions/comparison-expression.js';
8
+ export * from './expressions/logical-expression.js';
9
+ export * from './expressions/parentheses-expression.js';
10
+ export * from './terms/boolean-literal.js';
11
+ export * from './terms/date-literal.js';
12
+ export * from './terms/null-literal.js';
13
+ export * from './terms/number-literal.js';
14
+ export * from './terms/qualified-identifier.js';
15
+ export * from './terms/string-literal.js';
16
+ export * from './terms/time-literal.js';
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BooleanLiteral = void 0;
4
- const literal_js_1 = require("../abstract/literal.js");
5
- class BooleanLiteral extends literal_js_1.Literal {
1
+ import { Literal } from '../abstract/literal.js';
2
+ export class BooleanLiteral extends Literal {
6
3
  constructor(value) {
7
4
  super(value);
8
5
  }
9
6
  }
10
- exports.BooleanLiteral = BooleanLiteral;
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DateLiteral = 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");
1
+ import { toDateDef } from 'putil-varhelpers';
2
+ import { ValidationError } from '../../errors.js';
3
+ import { quoteFilterString } from '../../utils.js';
4
+ import { Literal } from '../abstract/literal.js';
8
5
  // const DATE_PATTERN = /^(\d{4})-(0[1-9]|1[012])-([123]0|[012][1-9]|31)/;
9
6
  const NullDate = new Date(0);
10
- class DateLiteral extends literal_js_1.Literal {
7
+ export class DateLiteral extends Literal {
11
8
  constructor(value) {
12
9
  super('');
13
10
  if (value instanceof Date) {
@@ -15,14 +12,13 @@ class DateLiteral extends literal_js_1.Literal {
15
12
  return;
16
13
  }
17
14
  // noinspection SuspiciousTypeOfGuard
18
- if (typeof value === 'string' && (0, putil_varhelpers_1.toDateDef)(value, NullDate) !== NullDate) {
15
+ if (typeof value === 'string' && toDateDef(value, NullDate) !== NullDate) {
19
16
  this.value = value;
20
17
  return;
21
18
  }
22
- throw new errors_js_1.ValidationError(`Invalid date value "${value}"`);
19
+ throw new ValidationError(`Invalid date value "${value}"`);
23
20
  }
24
21
  toString() {
25
- return (0, utils_js_1.quoteFilterString)(this.value);
22
+ return quoteFilterString(this.value);
26
23
  }
27
24
  }
28
- exports.DateLiteral = DateLiteral;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExternalConstant = void 0;
4
- const literal_js_1 = require("../abstract/literal.js");
5
- class ExternalConstant extends literal_js_1.Literal {
1
+ import { Literal } from '../abstract/literal.js';
2
+ export class ExternalConstant extends Literal {
6
3
  constructor(value) {
7
4
  super('' + value);
8
5
  }
@@ -10,4 +7,3 @@ class ExternalConstant extends literal_js_1.Literal {
10
7
  return '@' + super.toString();
11
8
  }
12
9
  }
13
- exports.ExternalConstant = ExternalConstant;
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NullLiteral = void 0;
4
- const literal_js_1 = require("../abstract/literal.js");
5
- class NullLiteral extends literal_js_1.Literal {
1
+ import { Literal } from '../abstract/literal.js';
2
+ export class NullLiteral extends Literal {
6
3
  constructor() {
7
4
  super(null);
8
5
  this.value = null;
9
6
  }
10
7
  }
11
- exports.NullLiteral = NullLiteral;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NumberLiteral = void 0;
4
- const errors_js_1 = require("../../errors.js");
5
- const literal_js_1 = require("../abstract/literal.js");
6
- class NumberLiteral extends literal_js_1.Literal {
1
+ import { ValidationError } from '../../errors.js';
2
+ import { Literal } from '../abstract/literal.js';
3
+ export class NumberLiteral extends Literal {
7
4
  constructor(value) {
8
5
  super(0);
9
6
  if (typeof value === 'number' || typeof value === 'bigint') {
@@ -28,7 +25,7 @@ class NumberLiteral extends literal_js_1.Literal {
28
25
  catch {
29
26
  //
30
27
  }
31
- throw new errors_js_1.ValidationError(`Invalid number literal ${value}`);
28
+ throw new ValidationError(`Invalid number literal ${value}`);
32
29
  }
33
30
  toString() {
34
31
  return typeof this.value === 'bigint'
@@ -36,4 +33,3 @@ class NumberLiteral extends literal_js_1.Literal {
36
33
  : ('' + this.value);
37
34
  }
38
35
  }
39
- exports.NumberLiteral = NumberLiteral;
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QualifiedIdentifier = void 0;
4
- const literal_js_1 = require("../abstract/literal.js");
5
- class QualifiedIdentifier extends literal_js_1.Literal {
1
+ import { Literal } from '../abstract/literal.js';
2
+ export class QualifiedIdentifier extends Literal {
6
3
  constructor(value) {
7
4
  super('' + value);
8
5
  }
9
6
  }
10
- exports.QualifiedIdentifier = QualifiedIdentifier;
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StringLiteral = void 0;
4
- const utils_js_1 = require("../../utils.js");
5
- const literal_js_1 = require("../abstract/literal.js");
6
- class StringLiteral extends literal_js_1.Literal {
1
+ import { quoteFilterString } from '../../utils.js';
2
+ import { Literal } from '../abstract/literal.js';
3
+ export class StringLiteral extends Literal {
7
4
  constructor(value) {
8
5
  super('' + value);
9
6
  }
10
7
  toString() {
11
- return (0, utils_js_1.quoteFilterString)(this.value);
8
+ return quoteFilterString(this.value);
12
9
  }
13
10
  }
14
- exports.StringLiteral = StringLiteral;
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TimeLiteral = void 0;
4
- const errors_js_1 = require("../../errors.js");
5
- const utils_js_1 = require("../../utils.js");
6
- const literal_js_1 = require("../abstract/literal.js");
1
+ import { ValidationError } from '../../errors.js';
2
+ import { quoteFilterString } from '../../utils.js';
3
+ import { Literal } from '../abstract/literal.js';
7
4
  const TIME_PATTERN = /^([01]\d|2[0-3]):([0-5]\d)(:[0-5]\d)?(\.(\d+))?$/;
8
- class TimeLiteral extends literal_js_1.Literal {
5
+ export class TimeLiteral extends Literal {
9
6
  constructor(value) {
10
7
  super('');
11
8
  if (value instanceof Date) {
@@ -20,13 +17,12 @@ class TimeLiteral extends literal_js_1.Literal {
20
17
  this.value = value;
21
18
  return;
22
19
  }
23
- throw new errors_js_1.ValidationError(`Invalid time value "${value}"`);
20
+ throw new ValidationError(`Invalid time value "${value}"`);
24
21
  }
25
22
  toString() {
26
- return (0, utils_js_1.quoteFilterString)(this.value);
23
+ return quoteFilterString(this.value);
27
24
  }
28
25
  }
29
- exports.TimeLiteral = TimeLiteral;
30
26
  function pad(n) {
31
27
  return n <= 9 ? '0' + n : '' + n;
32
28
  }
@@ -1,89 +1,66 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.$arithmetic = exports.$paren = exports.$notILike = exports.$ilike = exports.$notLike = exports.$like = exports.$notIn = exports.$in = exports.$lte = exports.$lt = exports.$gte = exports.$gt = exports.$ne = exports.$eq = exports.$field = exports.$array = exports.$number = exports.$time = exports.$date = exports.$and = exports.$or = void 0;
4
- const index_js_1 = require("./ast/index.js");
5
- function $or(...items) {
6
- return new index_js_1.LogicalExpression({ op: 'or', items });
7
- }
8
- exports.$or = $or;
9
- function $and(...items) {
10
- return new index_js_1.LogicalExpression({ op: 'and', items });
11
- }
12
- exports.$and = $and;
13
- function $date(v) {
14
- return new index_js_1.DateLiteral(v);
15
- }
16
- exports.$date = $date;
17
- function $time(v) {
18
- return new index_js_1.TimeLiteral(v);
19
- }
20
- exports.$time = $time;
21
- function $number(v) {
22
- return new index_js_1.NumberLiteral(v);
23
- }
24
- exports.$number = $number;
25
- function $array(...items) {
26
- return new index_js_1.ArrayExpression(items.map(wrapEntryValue));
27
- }
28
- exports.$array = $array;
29
- function $field(v) {
30
- return new index_js_1.QualifiedIdentifier(v);
31
- }
32
- exports.$field = $field;
33
- function $eq(left, right) {
1
+ import { ArithmeticExpression, ArrayExpression, BooleanLiteral, ComparisonExpression, DateLiteral, Expression, LogicalExpression, NullLiteral, NumberLiteral, ParenthesesExpression, QualifiedIdentifier, StringLiteral, TimeLiteral } from './ast/index.js';
2
+ export function $or(...items) {
3
+ return new LogicalExpression({ op: 'or', items });
4
+ }
5
+ export function $and(...items) {
6
+ return new LogicalExpression({ op: 'and', items });
7
+ }
8
+ export function $date(v) {
9
+ return new DateLiteral(v);
10
+ }
11
+ export function $time(v) {
12
+ return new TimeLiteral(v);
13
+ }
14
+ export function $number(v) {
15
+ return new NumberLiteral(v);
16
+ }
17
+ export function $array(...items) {
18
+ return new ArrayExpression(items.map(wrapEntryValue));
19
+ }
20
+ export function $field(v) {
21
+ return new QualifiedIdentifier(v);
22
+ }
23
+ export function $eq(left, right) {
34
24
  return comparisonExpression('=', left, right);
35
25
  }
36
- exports.$eq = $eq;
37
- function $ne(left, right) {
26
+ export function $ne(left, right) {
38
27
  return comparisonExpression('!=', left, right);
39
28
  }
40
- exports.$ne = $ne;
41
- function $gt(left, right) {
29
+ export function $gt(left, right) {
42
30
  return comparisonExpression('>', left, right);
43
31
  }
44
- exports.$gt = $gt;
45
- function $gte(left, right) {
32
+ export function $gte(left, right) {
46
33
  return comparisonExpression('>=', left, right);
47
34
  }
48
- exports.$gte = $gte;
49
- function $lt(left, right) {
35
+ export function $lt(left, right) {
50
36
  return comparisonExpression('<', left, right);
51
37
  }
52
- exports.$lt = $lt;
53
- function $lte(left, right) {
38
+ export function $lte(left, right) {
54
39
  return comparisonExpression('<=', left, right);
55
40
  }
56
- exports.$lte = $lte;
57
- function $in(left, right) {
41
+ export function $in(left, right) {
58
42
  return comparisonExpression('in', left, right);
59
43
  }
60
- exports.$in = $in;
61
- function $notIn(left, right) {
44
+ export function $notIn(left, right) {
62
45
  return comparisonExpression('!in', left, right);
63
46
  }
64
- exports.$notIn = $notIn;
65
- function $like(left, right) {
47
+ export function $like(left, right) {
66
48
  return comparisonExpression('like', left, right);
67
49
  }
68
- exports.$like = $like;
69
- function $notLike(left, right) {
50
+ export function $notLike(left, right) {
70
51
  return comparisonExpression('!like', left, right);
71
52
  }
72
- exports.$notLike = $notLike;
73
- function $ilike(left, right) {
53
+ export function $ilike(left, right) {
74
54
  return comparisonExpression('ilike', left, right);
75
55
  }
76
- exports.$ilike = $ilike;
77
- function $notILike(left, right) {
56
+ export function $notILike(left, right) {
78
57
  return comparisonExpression('!ilike', left, right);
79
58
  }
80
- exports.$notILike = $notILike;
81
- function $paren(expression) {
82
- return new index_js_1.ParenthesesExpression(expression);
59
+ export function $paren(expression) {
60
+ return new ParenthesesExpression(expression);
83
61
  }
84
- exports.$paren = $paren;
85
- function $arithmetic(n) {
86
- const exp = new index_js_1.ArithmeticExpression();
62
+ export function $arithmetic(n) {
63
+ const exp = new ArithmeticExpression();
87
64
  exp.add = (expression) => {
88
65
  exp.append('+', _wrapEntryValue(expression));
89
66
  return exp;
@@ -103,11 +80,10 @@ function $arithmetic(n) {
103
80
  exp.append('+', wrapEntryValue(n));
104
81
  return exp;
105
82
  }
106
- exports.$arithmetic = $arithmetic;
107
83
  function comparisonExpression(op, left, right) {
108
84
  const lex = wrapEntryValue(left);
109
85
  const rex = wrapEntryValue(right);
110
- return new index_js_1.ComparisonExpression({ op, left: lex, right: rex });
86
+ return new ComparisonExpression({ op, left: lex, right: rex });
111
87
  }
112
88
  const wrapEntryValue = (v) => {
113
89
  return Array.isArray(v)
@@ -115,15 +91,15 @@ const wrapEntryValue = (v) => {
115
91
  : _wrapEntryValue(v);
116
92
  };
117
93
  const _wrapEntryValue = (v) => {
118
- if (v instanceof index_js_1.Expression)
94
+ if (v instanceof Expression)
119
95
  return v;
120
96
  if (typeof v === 'boolean')
121
- return new index_js_1.BooleanLiteral(v);
97
+ return new BooleanLiteral(v);
122
98
  if (typeof v === 'number' || typeof v === 'bigint')
123
- return new index_js_1.NumberLiteral(v);
99
+ return new NumberLiteral(v);
124
100
  if (v == null)
125
- return new index_js_1.NullLiteral();
101
+ return new NullLiteral();
126
102
  if (v instanceof Date)
127
- return new index_js_1.DateLiteral(v);
128
- return new index_js_1.StringLiteral('' + v);
103
+ return new DateLiteral(v);
104
+ return new StringLiteral('' + v);
129
105
  };
@@ -1,16 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FilterParseError = exports.ValidationError = exports.SyntaxError = void 0;
4
- class SyntaxError extends TypeError {
1
+ export class SyntaxError extends TypeError {
5
2
  }
6
- exports.SyntaxError = SyntaxError;
7
- class ValidationError extends TypeError {
3
+ export class ValidationError extends TypeError {
8
4
  }
9
- exports.ValidationError = ValidationError;
10
- class FilterParseError extends Error {
5
+ export class FilterParseError extends Error {
11
6
  constructor(message, args) {
12
7
  super(message);
13
8
  Object.assign(this, args);
14
9
  }
15
10
  }
16
- exports.FilterParseError = FilterParseError;