@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.
- package/cjs/document/data-type/complex-type.js +69 -56
- package/cjs/document/data-type/simple-type.js +0 -1
- package/cjs/document/resource/collection.js +15 -16
- package/cjs/document/resource/singleton.js +2 -2
- package/cjs/http/http-params.js +10 -11
- package/esm/document/api-document.js +33 -37
- package/esm/document/constants.js +3 -6
- package/esm/document/data-type/api-field.js +12 -15
- package/esm/document/data-type/builtin/any.type.js +5 -8
- package/esm/document/data-type/builtin/base64.type.js +5 -8
- package/esm/document/data-type/builtin/bigint.type.js +5 -8
- package/esm/document/data-type/builtin/boolean.type.js +8 -11
- package/esm/document/data-type/builtin/date.type.js +7 -10
- package/esm/document/data-type/builtin/guid.type.js +9 -12
- package/esm/document/data-type/builtin/index.js +10 -13
- package/esm/document/data-type/builtin/integer.type.js +10 -13
- package/esm/document/data-type/builtin/number.type.js +7 -10
- package/esm/document/data-type/builtin/object.type.js +5 -8
- package/esm/document/data-type/builtin/string.type.js +8 -11
- package/esm/document/data-type/builtin/time.type.js +7 -10
- package/esm/document/data-type/builtin/timestamp.type.js +9 -12
- package/esm/document/data-type/complex-type.js +94 -85
- package/esm/document/data-type/data-type.js +9 -12
- package/esm/document/data-type/enum-type.js +15 -19
- package/esm/document/data-type/mapped-type.js +24 -29
- package/esm/document/data-type/simple-type.js +17 -22
- package/esm/document/data-type/union-type.js +26 -29
- package/esm/document/factory/add-references.js +3 -7
- package/esm/document/factory/create-document.js +10 -16
- package/esm/document/factory/factory.js +33 -37
- package/esm/document/factory/import-resource-class.js +16 -22
- package/esm/document/factory/import-type-class.js +24 -34
- package/esm/document/factory/index.js +1 -4
- package/esm/document/factory/process-resources.js +10 -16
- package/esm/document/factory/process-types.js +31 -37
- package/esm/document/index.js +14 -17
- package/esm/document/resource/collection.js +58 -63
- package/esm/document/resource/resource.js +9 -12
- package/esm/document/resource/singleton.js +27 -31
- package/esm/document/utils/inspect.util.js +4 -7
- package/esm/document/utils/string-compare.util.js +1 -5
- package/esm/exception/enums/issue-severity.enum.js +2 -5
- package/esm/exception/error-issue.js +1 -2
- package/esm/exception/http-errors/bad-request.error.js +4 -8
- package/esm/exception/http-errors/failed-dependency.error.js +4 -8
- package/esm/exception/http-errors/forbidden.error.js +4 -8
- package/esm/exception/http-errors/internal-server.error.js +4 -8
- package/esm/exception/http-errors/method-not-allowed.error.js +4 -8
- package/esm/exception/http-errors/not-acceptable.error.js +4 -8
- package/esm/exception/http-errors/not-found.error.js +4 -8
- package/esm/exception/http-errors/unauthorized.error.js +4 -8
- package/esm/exception/http-errors/unprocessable-entity.error.js +4 -8
- package/esm/exception/index.js +15 -18
- package/esm/exception/opra-exception.js +3 -7
- package/esm/exception/resource-errors/resource-conflict.error.js +4 -8
- package/esm/exception/resource-errors/resource-not-found.error.js +4 -8
- package/esm/exception/wrap-exception.js +20 -24
- package/esm/filter/antlr/OpraFilterLexer.js +6 -9
- package/esm/filter/antlr/OpraFilterListener.js +2 -5
- package/esm/filter/antlr/OpraFilterParser.js +79 -126
- package/esm/filter/antlr/OpraFilterVisitor.js +2 -5
- package/esm/filter/ast/abstract/ast.js +1 -5
- package/esm/filter/ast/abstract/expression.js +2 -6
- package/esm/filter/ast/abstract/literal.js +2 -6
- package/esm/filter/ast/abstract/term.js +2 -6
- package/esm/filter/ast/expressions/arithmetic-expression.js +3 -8
- package/esm/filter/ast/expressions/array-expression.js +2 -6
- package/esm/filter/ast/expressions/comparison-expression.js +2 -6
- package/esm/filter/ast/expressions/logical-expression.js +2 -6
- package/esm/filter/ast/expressions/parentheses-expression.js +2 -6
- package/esm/filter/ast/index.js +16 -19
- package/esm/filter/ast/terms/boolean-literal.js +2 -6
- package/esm/filter/ast/terms/date-literal.js +8 -12
- package/esm/filter/ast/terms/external-constant.js +2 -6
- package/esm/filter/ast/terms/null-literal.js +2 -6
- package/esm/filter/ast/terms/number-literal.js +4 -8
- package/esm/filter/ast/terms/qualified-identifier.js +2 -6
- package/esm/filter/ast/terms/string-literal.js +4 -8
- package/esm/filter/ast/terms/time-literal.js +6 -10
- package/esm/filter/build.js +45 -69
- package/esm/filter/errors.js +3 -9
- package/esm/filter/filter-tree-visitor.js +26 -31
- package/esm/filter/index.js +5 -8
- package/esm/filter/opra-error-listener.js +4 -8
- package/esm/filter/parse.js +14 -19
- package/esm/filter/utils.js +2 -7
- package/esm/helpers/function-utils.js +8 -14
- package/esm/helpers/get-stack-filename.js +1 -5
- package/esm/helpers/index.js +8 -11
- package/esm/helpers/is-url.js +1 -5
- package/esm/helpers/mixin-utils.js +2 -7
- package/esm/helpers/object-utils.js +6 -12
- package/esm/helpers/path-to-object-tree.js +1 -5
- package/esm/helpers/responsive-map.js +1 -5
- package/esm/helpers/type-guards.js +7 -17
- package/esm/http/codecs/boolean-codec.js +1 -5
- package/esm/http/codecs/date-codec.js +1 -5
- package/esm/http/codecs/filter-codec.js +5 -9
- package/esm/http/codecs/integer-codec.js +2 -6
- package/esm/http/codecs/number-codec.js +1 -5
- package/esm/http/codecs/string-codec.js +1 -5
- package/esm/http/enums/http-headers-codes.enum.js +2 -5
- package/esm/http/enums/http-status-codes.enum.js +2 -5
- package/esm/http/enums/http-status-messages.js +1 -4
- package/esm/http/http-headers.js +5 -9
- package/esm/http/http-message.host.js +13 -18
- package/esm/http/http-params.js +30 -36
- package/esm/http/http-request-message.js +18 -22
- package/esm/http/http-response-message.js +23 -28
- package/esm/http/index.js +14 -17
- package/esm/http/interfaces/client-http-headers.interface.js +1 -2
- package/esm/http/interfaces/cookie-options.interface.js +1 -2
- package/esm/http/interfaces/server-http-headers.interface.js +1 -2
- package/esm/i18n/i18n.js +23 -28
- package/esm/i18n/index.js +5 -9
- package/esm/i18n/string-utils.js +2 -7
- package/esm/i18n/translate.js +3 -7
- package/esm/index.js +11 -16
- package/esm/schema/constants.js +1 -4
- package/esm/schema/data-type/complex-type.interface.js +2 -5
- package/esm/schema/data-type/data-type.interface.js +1 -2
- package/esm/schema/data-type/enum-type.interface.js +2 -5
- package/esm/schema/data-type/field.interface.js +1 -2
- package/esm/schema/data-type/mapped-type.interface.js +2 -5
- package/esm/schema/data-type/simple-type.interface.js +2 -5
- package/esm/schema/data-type/union-type.interface.js +2 -5
- package/esm/schema/document.interface.js +1 -2
- package/esm/schema/index.js +31 -34
- package/esm/schema/resource/collection.interface.js +2 -5
- package/esm/schema/resource/container.interface.js +2 -5
- package/esm/schema/resource/endpoint.interface.js +1 -2
- package/esm/schema/resource/resource.interface.js +1 -2
- package/esm/schema/resource/singleton.interface.js +2 -5
- package/esm/schema/type-guards.js +40 -53
- package/esm/types.js +1 -2
- package/esm/url/index.js +5 -8
- package/esm/url/opra-url-path-component.js +3 -7
- package/esm/url/opra-url-path.js +14 -18
- package/esm/url/opra-url.js +15 -19
- package/esm/url/utils/decode-path-component.js +4 -8
- package/esm/url/utils/encode-path-component.js +3 -8
- package/esm/utils/path-utils.js +2 -7
- package/package.json +1 -1
- package/types/document/data-type/complex-type.d.ts +8 -2
- package/types/document/resource/collection.d.ts +5 -3
- package/types/document/resource/singleton.d.ts +3 -1
- package/types/filter/ast/terms/qualified-identifier.d.ts +4 -0
- 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
|
-
|
|
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
|
|
10
|
+
export default class OpraFilterVisitor extends ParseTreeVisitor {
|
|
13
11
|
}
|
|
14
|
-
exports.default = OpraFilterVisitor;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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;
|
package/esm/filter/ast/index.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
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' &&
|
|
15
|
+
if (typeof value === 'string' && toDateDef(value, NullDate) !== NullDate) {
|
|
19
16
|
this.value = value;
|
|
20
17
|
return;
|
|
21
18
|
}
|
|
22
|
-
throw new
|
|
19
|
+
throw new ValidationError(`Invalid date value "${value}"`);
|
|
23
20
|
}
|
|
24
21
|
toString() {
|
|
25
|
-
return
|
|
22
|
+
return quoteFilterString(this.value);
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
|
-
exports.DateLiteral = DateLiteral;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
8
|
+
return quoteFilterString(this.value);
|
|
12
9
|
}
|
|
13
10
|
}
|
|
14
|
-
exports.StringLiteral = StringLiteral;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
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
|
|
20
|
+
throw new ValidationError(`Invalid time value "${value}"`);
|
|
24
21
|
}
|
|
25
22
|
toString() {
|
|
26
|
-
return
|
|
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
|
}
|
package/esm/filter/build.js
CHANGED
|
@@ -1,89 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function $
|
|
6
|
-
return new
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function $
|
|
18
|
-
return new
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
37
|
-
function $ne(left, right) {
|
|
26
|
+
export function $ne(left, right) {
|
|
38
27
|
return comparisonExpression('!=', left, right);
|
|
39
28
|
}
|
|
40
|
-
|
|
41
|
-
function $gt(left, right) {
|
|
29
|
+
export function $gt(left, right) {
|
|
42
30
|
return comparisonExpression('>', left, right);
|
|
43
31
|
}
|
|
44
|
-
|
|
45
|
-
function $gte(left, right) {
|
|
32
|
+
export function $gte(left, right) {
|
|
46
33
|
return comparisonExpression('>=', left, right);
|
|
47
34
|
}
|
|
48
|
-
|
|
49
|
-
function $lt(left, right) {
|
|
35
|
+
export function $lt(left, right) {
|
|
50
36
|
return comparisonExpression('<', left, right);
|
|
51
37
|
}
|
|
52
|
-
|
|
53
|
-
function $lte(left, right) {
|
|
38
|
+
export function $lte(left, right) {
|
|
54
39
|
return comparisonExpression('<=', left, right);
|
|
55
40
|
}
|
|
56
|
-
|
|
57
|
-
function $in(left, right) {
|
|
41
|
+
export function $in(left, right) {
|
|
58
42
|
return comparisonExpression('in', left, right);
|
|
59
43
|
}
|
|
60
|
-
|
|
61
|
-
function $notIn(left, right) {
|
|
44
|
+
export function $notIn(left, right) {
|
|
62
45
|
return comparisonExpression('!in', left, right);
|
|
63
46
|
}
|
|
64
|
-
|
|
65
|
-
function $like(left, right) {
|
|
47
|
+
export function $like(left, right) {
|
|
66
48
|
return comparisonExpression('like', left, right);
|
|
67
49
|
}
|
|
68
|
-
|
|
69
|
-
function $notLike(left, right) {
|
|
50
|
+
export function $notLike(left, right) {
|
|
70
51
|
return comparisonExpression('!like', left, right);
|
|
71
52
|
}
|
|
72
|
-
|
|
73
|
-
function $ilike(left, right) {
|
|
53
|
+
export function $ilike(left, right) {
|
|
74
54
|
return comparisonExpression('ilike', left, right);
|
|
75
55
|
}
|
|
76
|
-
|
|
77
|
-
function $notILike(left, right) {
|
|
56
|
+
export function $notILike(left, right) {
|
|
78
57
|
return comparisonExpression('!ilike', left, right);
|
|
79
58
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return new index_js_1.ParenthesesExpression(expression);
|
|
59
|
+
export function $paren(expression) {
|
|
60
|
+
return new ParenthesesExpression(expression);
|
|
83
61
|
}
|
|
84
|
-
|
|
85
|
-
|
|
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
|
|
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
|
|
94
|
+
if (v instanceof Expression)
|
|
119
95
|
return v;
|
|
120
96
|
if (typeof v === 'boolean')
|
|
121
|
-
return new
|
|
97
|
+
return new BooleanLiteral(v);
|
|
122
98
|
if (typeof v === 'number' || typeof v === 'bigint')
|
|
123
|
-
return new
|
|
99
|
+
return new NumberLiteral(v);
|
|
124
100
|
if (v == null)
|
|
125
|
-
return new
|
|
101
|
+
return new NullLiteral();
|
|
126
102
|
if (v instanceof Date)
|
|
127
|
-
return new
|
|
128
|
-
return new
|
|
103
|
+
return new DateLiteral(v);
|
|
104
|
+
return new StringLiteral('' + v);
|
|
129
105
|
};
|
package/esm/filter/errors.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
7
|
-
class ValidationError extends TypeError {
|
|
3
|
+
export class ValidationError extends TypeError {
|
|
8
4
|
}
|
|
9
|
-
|
|
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;
|