@opra/common 0.16.2 → 0.17.1
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/constants.js +1 -1
- 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,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const index_js_1 = require("./ast/index.js");
|
|
8
|
-
const external_constant_js_1 = require("./ast/terms/external-constant.js");
|
|
9
|
-
const errors_js_1 = require("./errors.js");
|
|
10
|
-
const utils_js_1 = require("./utils.js");
|
|
1
|
+
import antlr4 from '@browsery/antlr4';
|
|
2
|
+
import { ArithmeticExpressionContext, LogicalExpressionContext, } from './antlr/OpraFilterParser.js';
|
|
3
|
+
import { ArithmeticExpression, ArrayExpression, BooleanLiteral, ComparisonExpression, DateLiteral, LogicalExpression, NullLiteral, NumberLiteral, ParenthesesExpression, QualifiedIdentifier, StringLiteral, TimeLiteral } from './ast/index.js';
|
|
4
|
+
import { ExternalConstant } from './ast/terms/external-constant.js';
|
|
5
|
+
import { SyntaxError } from './errors.js';
|
|
6
|
+
import { unquoteFilterString } from './utils.js';
|
|
11
7
|
// Fix: antlr4 d.ts files are invalid
|
|
12
|
-
const ParseTreeVisitor =
|
|
13
|
-
class FilterTreeVisitor extends ParseTreeVisitor {
|
|
8
|
+
const ParseTreeVisitor = antlr4.tree.ParseTreeVisitor;
|
|
9
|
+
export class FilterTreeVisitor extends ParseTreeVisitor {
|
|
14
10
|
constructor(options) {
|
|
15
11
|
super();
|
|
16
12
|
this._timeZone = options?.timeZone;
|
|
@@ -31,31 +27,31 @@ class FilterTreeVisitor extends ParseTreeVisitor {
|
|
|
31
27
|
return ctx.getText();
|
|
32
28
|
}
|
|
33
29
|
visitNullLiteral() {
|
|
34
|
-
return new
|
|
30
|
+
return new NullLiteral();
|
|
35
31
|
}
|
|
36
32
|
visitBooleanLiteral(ctx) {
|
|
37
|
-
return new
|
|
33
|
+
return new BooleanLiteral(ctx.getText() === 'true');
|
|
38
34
|
}
|
|
39
35
|
visitNumberLiteral(ctx) {
|
|
40
|
-
return new
|
|
36
|
+
return new NumberLiteral(ctx.getText());
|
|
41
37
|
}
|
|
42
38
|
visitStringLiteral(ctx) {
|
|
43
|
-
return new
|
|
39
|
+
return new StringLiteral(unquoteFilterString(ctx.getText()));
|
|
44
40
|
}
|
|
45
41
|
visitInfinityLiteral() {
|
|
46
|
-
return new
|
|
42
|
+
return new NumberLiteral(Infinity);
|
|
47
43
|
}
|
|
48
44
|
visitDateLiteral(ctx) {
|
|
49
|
-
return new
|
|
45
|
+
return new DateLiteral(unquoteFilterString(ctx.getText()));
|
|
50
46
|
}
|
|
51
47
|
visitDateTimeLiteral(ctx) {
|
|
52
|
-
return new
|
|
48
|
+
return new DateLiteral(unquoteFilterString(ctx.getText()));
|
|
53
49
|
}
|
|
54
50
|
visitTimeLiteral(ctx) {
|
|
55
|
-
return new
|
|
51
|
+
return new TimeLiteral(unquoteFilterString(ctx.getText()));
|
|
56
52
|
}
|
|
57
53
|
visitQualifiedIdentifierTerm(ctx) {
|
|
58
|
-
return new
|
|
54
|
+
return new QualifiedIdentifier(ctx.getText());
|
|
59
55
|
}
|
|
60
56
|
visitPolarityExpression(ctx) {
|
|
61
57
|
const x = this.visit(ctx.expression());
|
|
@@ -64,20 +60,20 @@ class FilterTreeVisitor extends ParseTreeVisitor {
|
|
|
64
60
|
x.value *= -1;
|
|
65
61
|
return x;
|
|
66
62
|
}
|
|
67
|
-
throw new
|
|
63
|
+
throw new SyntaxError('Unexpected token "' + ctx.getText() + '"');
|
|
68
64
|
}
|
|
69
65
|
visitExternalConstantTerm(ctx) {
|
|
70
|
-
return new
|
|
66
|
+
return new ExternalConstant(ctx.externalConstant().getText().substring(1));
|
|
71
67
|
}
|
|
72
68
|
visitParenthesizedExpression(ctx) {
|
|
73
69
|
const expression = this.visit(ctx.expression());
|
|
74
|
-
return new
|
|
70
|
+
return new ParenthesesExpression(expression);
|
|
75
71
|
}
|
|
76
72
|
visitArrayExpression(ctx) {
|
|
77
|
-
return new
|
|
73
|
+
return new ArrayExpression(ctx.expression_list().map(child => this.visit(child)));
|
|
78
74
|
}
|
|
79
75
|
visitComparisonExpression(ctx) {
|
|
80
|
-
return new
|
|
76
|
+
return new ComparisonExpression({
|
|
81
77
|
op: ctx.compOp().getText(),
|
|
82
78
|
left: this.visit(ctx.expression(0)),
|
|
83
79
|
right: this.visit(ctx.expression(1))
|
|
@@ -87,7 +83,7 @@ class FilterTreeVisitor extends ParseTreeVisitor {
|
|
|
87
83
|
const items = [];
|
|
88
84
|
const wrapChildren = (arr, op) => {
|
|
89
85
|
for (const c of arr) {
|
|
90
|
-
if (c instanceof
|
|
86
|
+
if (c instanceof LogicalExpressionContext && c.logOp().getText() === op) {
|
|
91
87
|
wrapChildren(c.expression_list(), c.logOp().getText());
|
|
92
88
|
continue;
|
|
93
89
|
}
|
|
@@ -96,17 +92,17 @@ class FilterTreeVisitor extends ParseTreeVisitor {
|
|
|
96
92
|
}
|
|
97
93
|
};
|
|
98
94
|
wrapChildren(ctx.expression_list(), ctx.logOp().getText());
|
|
99
|
-
return new
|
|
95
|
+
return new LogicalExpression({
|
|
100
96
|
op: ctx.logOp().getText(),
|
|
101
97
|
items
|
|
102
98
|
});
|
|
103
99
|
}
|
|
104
100
|
visitArithmeticExpression(ctx) {
|
|
105
|
-
const exp = new
|
|
101
|
+
const exp = new ArithmeticExpression();
|
|
106
102
|
const wrapChildren = (children, op) => {
|
|
107
103
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
108
104
|
const child = children[i];
|
|
109
|
-
if (child instanceof
|
|
105
|
+
if (child instanceof ArithmeticExpressionContext) {
|
|
110
106
|
wrapChildren(child.expression_list(), child.arthOp().getText());
|
|
111
107
|
continue;
|
|
112
108
|
}
|
|
@@ -118,4 +114,3 @@ class FilterTreeVisitor extends ParseTreeVisitor {
|
|
|
118
114
|
return exp;
|
|
119
115
|
}
|
|
120
116
|
}
|
|
121
|
-
exports.FilterTreeVisitor = FilterTreeVisitor;
|
package/esm/filter/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
tslib_1.__exportStar(require("./build.js"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./opra-error-listener.js"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./filter-tree-visitor.js"), exports);
|
|
1
|
+
export * from './ast/index.js';
|
|
2
|
+
export * from './parse.js';
|
|
3
|
+
export * from './build.js';
|
|
4
|
+
export * from './opra-error-listener.js';
|
|
5
|
+
export * from './filter-tree-visitor.js';
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const antlr4_1 = require("@browsery/antlr4");
|
|
5
|
-
const errors_js_1 = require("./errors.js");
|
|
6
|
-
class OpraErrorListener extends antlr4_1.ErrorListener {
|
|
1
|
+
import { ErrorListener } from '@browsery/antlr4';
|
|
2
|
+
import { FilterParseError } from './errors.js';
|
|
3
|
+
export class OpraErrorListener extends ErrorListener {
|
|
7
4
|
constructor(errors) {
|
|
8
5
|
super();
|
|
9
6
|
this.errors = errors;
|
|
10
7
|
}
|
|
11
8
|
syntaxError(recognizer, offendingSymbol, line, column, msg, e) {
|
|
12
|
-
this.errors.push(new
|
|
9
|
+
this.errors.push(new FilterParseError(msg, { recognizer, offendingSymbol, line, column, e }));
|
|
13
10
|
}
|
|
14
11
|
}
|
|
15
|
-
exports.OpraErrorListener = OpraErrorListener;
|
package/esm/filter/parse.js
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const chars = new antlr4_1.CharStream(text);
|
|
13
|
-
const lexer = new OpraFilterLexer_js_1.default(chars);
|
|
14
|
-
const tokenStream = new antlr4_1.CommonTokenStream(lexer);
|
|
15
|
-
const parser = new OpraFilterParser_js_1.default(tokenStream);
|
|
1
|
+
import { CharStream, CommonTokenStream } from '@browsery/antlr4';
|
|
2
|
+
import OpraFilterLexer from './antlr/OpraFilterLexer.js';
|
|
3
|
+
import OpraFilterParser from './antlr/OpraFilterParser.js';
|
|
4
|
+
import { SyntaxError } from './errors.js';
|
|
5
|
+
import { FilterTreeVisitor } from './filter-tree-visitor.js';
|
|
6
|
+
import { OpraErrorListener } from './opra-error-listener.js';
|
|
7
|
+
export function parseFilter(text, visitor) {
|
|
8
|
+
const chars = new CharStream(text);
|
|
9
|
+
const lexer = new OpraFilterLexer(chars);
|
|
10
|
+
const tokenStream = new CommonTokenStream(lexer);
|
|
11
|
+
const parser = new OpraFilterParser(tokenStream);
|
|
16
12
|
parser.buildParseTrees = true;
|
|
17
13
|
const errors = [];
|
|
18
|
-
const errorListener = new
|
|
14
|
+
const errorListener = new OpraErrorListener(errors);
|
|
19
15
|
lexer.removeErrorListeners();
|
|
20
16
|
lexer.addErrorListener(errorListener);
|
|
21
17
|
parser.removeErrorListeners();
|
|
22
18
|
parser.addErrorListener(errorListener);
|
|
23
19
|
const tree = parser.root();
|
|
24
|
-
visitor = visitor || new
|
|
20
|
+
visitor = visitor || new FilterTreeVisitor();
|
|
25
21
|
const result = visitor.visit(tree);
|
|
26
22
|
if (errors.length) {
|
|
27
23
|
const errMsgs = [];
|
|
@@ -31,10 +27,9 @@ function parseFilter(text, visitor) {
|
|
|
31
27
|
? (' at ' + 'line: ' + err.line + ' column: ' + err.column)
|
|
32
28
|
: (' at ' + ' column: ' + err.column)));
|
|
33
29
|
}
|
|
34
|
-
const e = new
|
|
30
|
+
const e = new SyntaxError(errMsgs.join('\n'));
|
|
35
31
|
e.errors = errors;
|
|
36
32
|
throw e;
|
|
37
33
|
}
|
|
38
34
|
return result;
|
|
39
35
|
}
|
|
40
|
-
exports.parseFilter = parseFilter;
|
package/esm/filter/utils.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unquoteFilterString = exports.quoteFilterString = void 0;
|
|
4
1
|
const quotesRegEx = /'/g;
|
|
5
2
|
const escapeRegEx = /(\\)/g;
|
|
6
3
|
const unescapeRegEx = /\\(.)/g;
|
|
@@ -10,17 +7,15 @@ function escapeString(s) {
|
|
|
10
7
|
function unescapeString(s) {
|
|
11
8
|
return s.replace(unescapeRegEx, '$1');
|
|
12
9
|
}
|
|
13
|
-
function quoteFilterString(s) {
|
|
10
|
+
export function quoteFilterString(s) {
|
|
14
11
|
return "'" +
|
|
15
12
|
escapeString(s).replace(quotesRegEx, '\\\'') +
|
|
16
13
|
"'";
|
|
17
14
|
}
|
|
18
|
-
|
|
19
|
-
function unquoteFilterString(s) {
|
|
15
|
+
export function unquoteFilterString(s) {
|
|
20
16
|
if (s && (s.startsWith("'") || s.startsWith('"')) && s.endsWith(s.charAt(0))) {
|
|
21
17
|
return unescapeString(s.substring(1, s.length - 1));
|
|
22
18
|
}
|
|
23
19
|
/* istanbul ignore next */
|
|
24
20
|
return s;
|
|
25
21
|
}
|
|
26
|
-
exports.unquoteFilterString = unquoteFilterString;
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const putil_promisify_1 = tslib_1.__importDefault(require("putil-promisify"));
|
|
6
|
-
const type_guards_js_1 = require("./type-guards.js");
|
|
7
|
-
async function resolveThunk(thunk) {
|
|
8
|
-
thunk = putil_promisify_1.default.isPromise(thunk) ? await thunk : thunk;
|
|
1
|
+
import promisify from 'putil-promisify';
|
|
2
|
+
import { isConstructor } from './type-guards.js';
|
|
3
|
+
export async function resolveThunk(thunk) {
|
|
4
|
+
thunk = promisify.isPromise(thunk) ? await thunk : thunk;
|
|
9
5
|
if (typeof thunk === 'function') {
|
|
10
|
-
if (
|
|
6
|
+
if (isConstructor(thunk))
|
|
11
7
|
return thunk;
|
|
12
8
|
return resolveClass(thunk());
|
|
13
9
|
}
|
|
14
10
|
return thunk;
|
|
15
11
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
thunk = putil_promisify_1.default.isPromise(thunk) ? await thunk : thunk;
|
|
12
|
+
export async function resolveClass(thunk) {
|
|
13
|
+
thunk = promisify.isPromise(thunk) ? await thunk : thunk;
|
|
19
14
|
if (typeof thunk !== 'function')
|
|
20
15
|
throw new Error(`No Class type resolved`);
|
|
21
|
-
if (
|
|
16
|
+
if (isConstructor(thunk))
|
|
22
17
|
return thunk;
|
|
23
18
|
return resolveClass(thunk());
|
|
24
19
|
}
|
|
25
|
-
exports.resolveClass = resolveClass;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStackFileName = void 0;
|
|
4
1
|
const PATH_PATTERN = /^(?:file:\/\/)?(.+)$/;
|
|
5
|
-
function getStackFileName(position = 1) {
|
|
2
|
+
export function getStackFileName(position = 1) {
|
|
6
3
|
if (position >= Error.stackTraceLimit) {
|
|
7
4
|
throw new TypeError('getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `' +
|
|
8
5
|
position + '` and Error.stackTraceLimit was: `' + Error.stackTraceLimit + '`');
|
|
@@ -21,4 +18,3 @@ function getStackFileName(position = 1) {
|
|
|
21
18
|
}
|
|
22
19
|
return '';
|
|
23
20
|
}
|
|
24
|
-
exports.getStackFileName = getStackFileName;
|
package/esm/helpers/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
tslib_1.__exportStar(require("./path-to-object-tree.js"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./responsive-map.js"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./type-guards.js"), exports);
|
|
1
|
+
export * from './function-utils.js';
|
|
2
|
+
export * from './get-stack-filename.js';
|
|
3
|
+
export * from './is-url.js';
|
|
4
|
+
export * from './mixin-utils.js';
|
|
5
|
+
export * from './object-utils.js';
|
|
6
|
+
export * from './path-to-object-tree.js';
|
|
7
|
+
export * from './responsive-map.js';
|
|
8
|
+
export * from './type-guards.js';
|
package/esm/helpers/is-url.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isUrl = void 0;
|
|
4
1
|
const URL_PATTERN = /^(https?:\/\/.)[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/i;
|
|
5
|
-
function isUrl(url) {
|
|
2
|
+
export function isUrl(url) {
|
|
6
3
|
return URL_PATTERN.test(url);
|
|
7
4
|
}
|
|
8
|
-
exports.isUrl = isUrl;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inheritPropertyInitializers = exports.applyMixins = void 0;
|
|
4
|
-
function applyMixins(derivedCtor, baseCtor, filter) {
|
|
1
|
+
export function applyMixins(derivedCtor, baseCtor, filter) {
|
|
5
2
|
for (const k of Object.getOwnPropertyNames(baseCtor.prototype)) {
|
|
6
3
|
if ((k === 'constructor' || k === '__proto__' || k === 'toJSON' || k === 'toString') ||
|
|
7
4
|
filter && !filter(k))
|
|
@@ -10,8 +7,7 @@ function applyMixins(derivedCtor, baseCtor, filter) {
|
|
|
10
7
|
Object.create(null));
|
|
11
8
|
}
|
|
12
9
|
}
|
|
13
|
-
|
|
14
|
-
function inheritPropertyInitializers(target, sourceClass,
|
|
10
|
+
export function inheritPropertyInitializers(target, sourceClass,
|
|
15
11
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
12
|
isPropertyInherited = (key) => true) {
|
|
17
13
|
try {
|
|
@@ -29,4 +25,3 @@ isPropertyInherited = (key) => true) {
|
|
|
29
25
|
//
|
|
30
26
|
}
|
|
31
27
|
}
|
|
32
|
-
exports.inheritPropertyInitializers = inheritPropertyInitializers;
|
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const putil_isplainobject_1 = tslib_1.__importDefault(require("putil-isplainobject"));
|
|
6
|
-
const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
|
|
7
|
-
function cloneObject(obj, jsonOnly) {
|
|
8
|
-
return (0, putil_merge_1.default)({}, obj, {
|
|
1
|
+
import isPlainObject from 'putil-isplainobject';
|
|
2
|
+
import merge from 'putil-merge';
|
|
3
|
+
export function cloneObject(obj, jsonOnly) {
|
|
4
|
+
return merge({}, obj, {
|
|
9
5
|
deep: true,
|
|
10
6
|
clone: true,
|
|
11
7
|
filter: (source, key) => {
|
|
12
8
|
const v = source[key];
|
|
13
9
|
return v != null &&
|
|
14
10
|
!jsonOnly || (typeof v !== 'function' &&
|
|
15
|
-
(typeof v !== 'object' || (
|
|
11
|
+
(typeof v !== 'object' || isPlainObject(v) || Array.isArray(v)));
|
|
16
12
|
}
|
|
17
13
|
});
|
|
18
14
|
}
|
|
19
|
-
|
|
20
|
-
function omitUndefined(obj) {
|
|
15
|
+
export function omitUndefined(obj) {
|
|
21
16
|
if (!(obj && typeof obj === 'object'))
|
|
22
17
|
return obj;
|
|
23
18
|
for (const k of Object.keys(obj)) {
|
|
@@ -28,4 +23,3 @@ function omitUndefined(obj) {
|
|
|
28
23
|
}
|
|
29
24
|
return obj;
|
|
30
25
|
}
|
|
31
|
-
exports.omitUndefined = omitUndefined;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pathToObjectTree = void 0;
|
|
4
1
|
const DOT_PATTERN = /^([^.]+)\.(.*)$/;
|
|
5
|
-
function pathToObjectTree(arr, lowerCaseKeys) {
|
|
2
|
+
export function pathToObjectTree(arr, lowerCaseKeys) {
|
|
6
3
|
if (!(arr && arr.length))
|
|
7
4
|
return;
|
|
8
5
|
return _pathToObjectTree(arr, {}, lowerCaseKeys);
|
|
9
6
|
}
|
|
10
|
-
exports.pathToObjectTree = pathToObjectTree;
|
|
11
7
|
function _pathToObjectTree(arr, target, lowerCaseKeys) {
|
|
12
8
|
for (let k of arr) {
|
|
13
9
|
if (lowerCaseKeys)
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var _a, _b, _c, _d;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ResponsiveMap = void 0;
|
|
5
2
|
function isMap(v) {
|
|
6
3
|
return v && typeof v.forEach === 'function';
|
|
7
4
|
}
|
|
@@ -12,7 +9,7 @@ const kOptions = Symbol('kOptions');
|
|
|
12
9
|
/**
|
|
13
10
|
* A Map implementation that supports case-insensitivity and ordered keys
|
|
14
11
|
*/
|
|
15
|
-
class ResponsiveMap extends Map {
|
|
12
|
+
export class ResponsiveMap extends Map {
|
|
16
13
|
constructor(init, options) {
|
|
17
14
|
super();
|
|
18
15
|
this[_a] = new Map();
|
|
@@ -164,4 +161,3 @@ class ResponsiveMap extends Map {
|
|
|
164
161
|
return key.toLowerCase();
|
|
165
162
|
}
|
|
166
163
|
}
|
|
167
|
-
exports.ResponsiveMap = ResponsiveMap;
|
|
@@ -1,53 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isURL = exports.isFormData = exports.isBlob = exports.isReadableStream = exports.isReadable = exports.isStream = exports.isConstructor = void 0;
|
|
4
|
-
function isConstructor(fn) {
|
|
1
|
+
export function isConstructor(fn) {
|
|
5
2
|
return typeof fn === 'function' && fn.prototype &&
|
|
6
3
|
fn.prototype.constructor === fn &&
|
|
7
4
|
fn.prototype.constructor.name !== 'Function' &&
|
|
8
5
|
fn.prototype.constructor.name !== 'anonymous';
|
|
9
6
|
}
|
|
10
|
-
|
|
11
|
-
function isStream(stream) {
|
|
7
|
+
export function isStream(stream) {
|
|
12
8
|
return stream !== null
|
|
13
9
|
&& typeof stream === 'object'
|
|
14
10
|
&& typeof stream.pipe === 'function';
|
|
15
11
|
}
|
|
16
|
-
|
|
17
|
-
function isReadable(x) {
|
|
12
|
+
export function isReadable(x) {
|
|
18
13
|
return isStream(x)
|
|
19
14
|
&& x.readable !== false
|
|
20
15
|
&& typeof x._read === 'function'
|
|
21
16
|
&& typeof x._readableState === 'object';
|
|
22
17
|
}
|
|
23
|
-
|
|
24
|
-
function isReadableStream(x) {
|
|
18
|
+
export function isReadableStream(x) {
|
|
25
19
|
return isStream(x)
|
|
26
20
|
&& x.readable !== false
|
|
27
21
|
&& typeof x.getReader === 'function'
|
|
28
22
|
&& typeof x.pipeThrough === 'function'
|
|
29
23
|
&& typeof x.pipeTo === 'function';
|
|
30
24
|
}
|
|
31
|
-
|
|
32
|
-
function isBlob(x) {
|
|
25
|
+
export function isBlob(x) {
|
|
33
26
|
return x !== null
|
|
34
27
|
&& typeof x === 'object'
|
|
35
28
|
&& typeof x.size === 'number'
|
|
36
29
|
&& typeof x.arrayBuffer === 'function'
|
|
37
30
|
&& typeof x.stream === 'function';
|
|
38
31
|
}
|
|
39
|
-
|
|
40
|
-
function isFormData(x) {
|
|
32
|
+
export function isFormData(x) {
|
|
41
33
|
return x !== null
|
|
42
34
|
&& typeof x.constructor === 'function'
|
|
43
35
|
&& x.constructor.name === 'FormData'
|
|
44
36
|
&& typeof x.append === 'function'
|
|
45
37
|
&& typeof x.getAll === 'function';
|
|
46
38
|
}
|
|
47
|
-
|
|
48
|
-
function isURL(x) {
|
|
39
|
+
export function isURL(x) {
|
|
49
40
|
return x !== null
|
|
50
41
|
&& typeof x.host === 'string'
|
|
51
42
|
&& typeof x.href === 'string';
|
|
52
43
|
}
|
|
53
|
-
exports.isURL = isURL;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BooleanCodec = void 0;
|
|
4
1
|
const trueValues = ['true', 't', 'yes', 'y', '1'];
|
|
5
2
|
const falseValues = ['false', 'f', 'no', 'n', '0'];
|
|
6
|
-
class BooleanCodec {
|
|
3
|
+
export class BooleanCodec {
|
|
7
4
|
decode(value) {
|
|
8
5
|
if (value === '')
|
|
9
6
|
return true;
|
|
@@ -21,4 +18,3 @@ class BooleanCodec {
|
|
|
21
18
|
(value ? 'true' : 'false') : '';
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
|
-
exports.BooleanCodec = BooleanCodec;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DateCodec = void 0;
|
|
4
1
|
// noinspection RegExpUnnecessaryNonCapturingGroup
|
|
5
2
|
const DATE_FORMAT_PATTERN = /^(\d{4})(?:-?(0[1-9]|1[012])(?:-?([123]0|[012][1-9]|31))?)?(?:[T ]?([01][0-9]|2[0-3]):?([0-5][0-9]):?([0-5][0-9])?(?:\.(\d+))?(?:(Z)|(?:([+-])([01]?[0-9]|2[0-3]):?([0-5][0-9])?))?)?$/;
|
|
6
|
-
class DateCodec {
|
|
3
|
+
export class DateCodec {
|
|
7
4
|
constructor(options) {
|
|
8
5
|
this.max = options?.max ? coerceToDateString(options.max) : undefined;
|
|
9
6
|
this.min = options?.min ? coerceToDateString(options.min) : undefined;
|
|
@@ -22,7 +19,6 @@ class DateCodec {
|
|
|
22
19
|
return coerceToDateString(value, this.time, this.timeZone);
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
|
-
exports.DateCodec = DateCodec;
|
|
26
22
|
function coerceToDateString(value, time, timeZone) {
|
|
27
23
|
if (value === '' || value == null)
|
|
28
24
|
return '';
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const index_js_1 = require("../../filter/ast/index.js");
|
|
5
|
-
const parse_js_1 = require("../../filter/parse.js");
|
|
6
|
-
class FilterCodec {
|
|
1
|
+
import { Expression } from '../../filter/ast/index.js';
|
|
2
|
+
import { parseFilter } from '../../filter/parse.js';
|
|
3
|
+
export class FilterCodec {
|
|
7
4
|
decode(value) {
|
|
8
|
-
if (value instanceof
|
|
5
|
+
if (value instanceof Expression)
|
|
9
6
|
return value;
|
|
10
|
-
return
|
|
7
|
+
return parseFilter(value);
|
|
11
8
|
}
|
|
12
9
|
encode(value) {
|
|
13
10
|
// @ts-ignore
|
|
14
11
|
return value ? '' + value : '';
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
|
-
exports.FilterCodec = FilterCodec;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.IntegerCodec = void 0;
|
|
4
|
-
const number_codec_js_1 = require("./number-codec.js");
|
|
5
|
-
class IntegerCodec extends number_codec_js_1.NumberCodec {
|
|
1
|
+
import { NumberCodec } from './number-codec.js';
|
|
2
|
+
export class IntegerCodec extends NumberCodec {
|
|
6
3
|
constructor(options) {
|
|
7
4
|
super(options);
|
|
8
5
|
this.enum = options?.enum;
|
|
@@ -16,4 +13,3 @@ class IntegerCodec extends number_codec_js_1.NumberCodec {
|
|
|
16
13
|
return v;
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
|
-
exports.IntegerCodec = IntegerCodec;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NumberCodec = void 0;
|
|
4
|
-
class NumberCodec {
|
|
1
|
+
export class NumberCodec {
|
|
5
2
|
constructor(options) {
|
|
6
3
|
this.max = options?.max;
|
|
7
4
|
this.min = options?.min;
|
|
@@ -21,4 +18,3 @@ class NumberCodec {
|
|
|
21
18
|
return typeof value === 'number' ? '' + value : '';
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
|
-
exports.NumberCodec = NumberCodec;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StringCodec = void 0;
|
|
4
|
-
class StringCodec {
|
|
1
|
+
export class StringCodec {
|
|
5
2
|
constructor(options) {
|
|
6
3
|
this.maxLength = options?.maxLength;
|
|
7
4
|
this.minLength = options?.minLength;
|
|
@@ -20,4 +17,3 @@ class StringCodec {
|
|
|
20
17
|
return value == null ? '' : '' + value;
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
|
-
exports.StringCodec = StringCodec;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// noinspection JSUnusedGlobalSymbols
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.HttpHeaderCodes = void 0;
|
|
5
2
|
/**
|
|
6
3
|
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers#controls
|
|
7
4
|
*/
|
|
8
|
-
var HttpHeaderCodes;
|
|
5
|
+
export var HttpHeaderCodes;
|
|
9
6
|
(function (HttpHeaderCodes) {
|
|
10
7
|
/* *** Opra Headers *** */
|
|
11
8
|
HttpHeaderCodes["X_Opra_Version"] = "X-OPRA-Version";
|
|
@@ -410,4 +407,4 @@ var HttpHeaderCodes;
|
|
|
410
407
|
*
|
|
411
408
|
*/
|
|
412
409
|
HttpHeaderCodes["Max_Forwards"] = "Max-Forwards";
|
|
413
|
-
})(HttpHeaderCodes
|
|
410
|
+
})(HttpHeaderCodes || (HttpHeaderCodes = {}));
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// noinspection JSUnusedGlobalSymbols
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.HttpStatusCodes = void 0;
|
|
5
2
|
/**
|
|
6
3
|
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#successful_responses
|
|
7
4
|
*/
|
|
8
|
-
var HttpStatusCodes;
|
|
5
|
+
export var HttpStatusCodes;
|
|
9
6
|
(function (HttpStatusCodes) {
|
|
10
7
|
/* *** Information responses *** */
|
|
11
8
|
/**
|
|
@@ -297,4 +294,4 @@ var HttpStatusCodes;
|
|
|
297
294
|
* Indicates that the client needs to authenticate to gain network access.
|
|
298
295
|
*/
|
|
299
296
|
HttpStatusCodes[HttpStatusCodes["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
300
|
-
})(HttpStatusCodes
|
|
297
|
+
})(HttpStatusCodes || (HttpStatusCodes = {}));
|