@opra/common 0.10.2 → 0.12.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/filter/antlr/OpraFilterLexer.js +1 -1
- package/cjs/filter/antlr/OpraFilterListener.js +1 -1
- package/cjs/filter/antlr/OpraFilterParser.js +5 -5
- package/cjs/filter/antlr/OpraFilterVisitor.js +1 -1
- package/cjs/filter/filter-tree-visitor.js +8 -2
- package/cjs/filter/opra-error-listener.js +2 -2
- package/cjs/filter/parse.js +1 -1
- package/cjs/helpers/responsive-map.js +45 -28
- package/{esm/http/enums/http-headers.enum.js → cjs/http/enums/http-headers-codes.enum.js} +95 -92
- package/{esm/http/enums/http-status.enum.js → cjs/http/enums/http-status-codes.enum.js} +62 -59
- package/cjs/http/http-headers.js +213 -0
- package/cjs/http/http-param-codec.js +6 -0
- package/cjs/http/http-params.js +321 -0
- package/cjs/http/http-request-node.js +105 -0
- package/cjs/http/http-request.js +73 -88
- package/cjs/http/http-response.js +23 -0
- package/cjs/http/index.js +13 -2
- package/cjs/http/multipart/batch-multipart.js +12 -12
- package/cjs/http/param-codec/boolean-codec.js +25 -0
- package/cjs/http/param-codec/date-codec.js +44 -0
- package/cjs/http/param-codec/filter-codec.js +18 -0
- package/cjs/http/param-codec/integer-codec.js +19 -0
- package/cjs/http/param-codec/number-codec.js +26 -0
- package/cjs/http/param-codec/string-codec.js +25 -0
- package/cjs/http/utils/encodeURIParam.js +21 -0
- package/cjs/http/utils/normalize-headers.js +2 -2
- package/cjs/i18n/i18n.js +1 -4
- package/cjs/schema/implementation/opra-document.js +12 -11
- package/cjs/schema/implementation/resource/collection-resource-info.js +7 -0
- package/cjs/url/opra-url-path.js +96 -72
- package/cjs/url/opra-url-search-params.js +16 -234
- package/cjs/url/opra-url.js +201 -160
- package/esm/filter/antlr/OpraFilterLexer.d.ts +1 -1
- package/esm/filter/antlr/OpraFilterLexer.js +1 -1
- package/esm/filter/antlr/OpraFilterListener.d.ts +1 -1
- package/esm/filter/antlr/OpraFilterListener.js +1 -1
- package/esm/filter/antlr/OpraFilterParser.d.ts +1 -1
- package/esm/filter/antlr/OpraFilterParser.js +5 -5
- package/esm/filter/antlr/OpraFilterVisitor.d.ts +1 -1
- package/esm/filter/antlr/OpraFilterVisitor.js +1 -1
- package/esm/filter/ast/expressions/arithmetic-expression.d.ts +1 -1
- package/esm/filter/ast/expressions/comparison-expression.d.ts +1 -1
- package/esm/filter/ast/expressions/logical-expression.d.ts +1 -1
- package/esm/filter/build.d.ts +3 -3
- package/esm/filter/errors.d.ts +4 -2
- package/esm/filter/filter-tree-visitor.d.ts +2 -1
- package/esm/filter/filter-tree-visitor.js +8 -2
- package/esm/filter/opra-error-listener.d.ts +2 -2
- package/esm/filter/opra-error-listener.js +2 -2
- package/esm/filter/parse.d.ts +1 -1
- package/esm/filter/parse.js +1 -1
- package/esm/helpers/responsive-map.d.ts +19 -5
- package/esm/helpers/responsive-map.js +45 -28
- package/esm/http/enums/{http-headers.enum.d.ts → http-headers-codes.enum.d.ts} +1 -1
- package/{cjs/http/enums/http-headers.enum.js → esm/http/enums/http-headers-codes.enum.js} +92 -95
- package/esm/http/enums/{http-status.enum.d.ts → http-status-codes.enum.d.ts} +1 -1
- package/{cjs/http/enums/http-status.enum.js → esm/http/enums/http-status-codes.enum.js} +59 -62
- package/esm/http/http-headers.d.ts +70 -0
- package/esm/http/http-headers.js +209 -0
- package/esm/http/http-param-codec.d.ts +4 -0
- package/esm/http/http-param-codec.js +2 -0
- package/esm/http/http-params.d.ts +99 -0
- package/esm/http/http-params.js +317 -0
- package/esm/http/http-request-node.d.ts +34 -0
- package/esm/http/http-request-node.js +101 -0
- package/esm/http/http-request.d.ts +73 -31
- package/esm/http/http-request.js +72 -87
- package/esm/http/http-response.d.ts +41 -0
- package/esm/http/http-response.js +19 -0
- package/esm/http/index.d.ts +13 -2
- package/esm/http/index.js +13 -2
- package/esm/http/interfaces/client-http-headers.interface.d.ts +1 -1
- package/esm/http/interfaces/server-http-headers.interface.d.ts +1 -1
- package/esm/http/multipart/batch-multipart.d.ts +1 -1
- package/esm/http/multipart/batch-multipart.js +12 -12
- package/esm/http/multipart/http-request-content.d.ts +1 -1
- package/esm/http/multipart/http-response-content.d.ts +1 -1
- package/esm/http/param-codec/boolean-codec.d.ts +5 -0
- package/esm/http/param-codec/boolean-codec.js +21 -0
- package/esm/http/param-codec/date-codec.d.ts +16 -0
- package/esm/http/param-codec/date-codec.js +40 -0
- package/esm/http/param-codec/filter-codec.d.ts +6 -0
- package/esm/http/param-codec/filter-codec.js +14 -0
- package/esm/http/param-codec/integer-codec.d.ts +9 -0
- package/esm/http/param-codec/integer-codec.js +15 -0
- package/esm/http/param-codec/number-codec.d.ts +12 -0
- package/esm/http/param-codec/number-codec.js +22 -0
- package/esm/http/param-codec/string-codec.d.ts +14 -0
- package/esm/http/param-codec/string-codec.js +21 -0
- package/esm/http/utils/encodeURIParam.d.ts +1 -0
- package/esm/http/utils/encodeURIParam.js +17 -0
- package/esm/http/utils/normalize-headers.js +2 -2
- package/esm/i18n/i18n.d.ts +6 -6
- package/esm/i18n/i18n.js +1 -4
- package/esm/schema/decorators/opr-collection-resource.decorator.d.ts +1 -1
- package/esm/schema/decorators/opr-complex-type.decorator.d.ts +1 -1
- package/esm/schema/decorators/opr-simple-type.decorator.d.ts +1 -1
- package/esm/schema/decorators/opr-singleton-resource.decorator.d.ts +1 -1
- package/esm/schema/implementation/data-type/complex-type.d.ts +1 -1
- package/esm/schema/implementation/data-type/union-type.d.ts +1 -1
- package/esm/schema/implementation/document-builder.d.ts +1 -1
- package/esm/schema/implementation/opra-document.d.ts +2 -2
- package/esm/schema/implementation/opra-document.js +12 -11
- package/esm/schema/implementation/query/collection-count-query.d.ts +1 -1
- package/esm/schema/implementation/query/collection-create-query.d.ts +1 -1
- package/esm/schema/implementation/query/collection-delete-many-query.d.ts +1 -1
- package/esm/schema/implementation/query/collection-get-query.d.ts +1 -1
- package/esm/schema/implementation/query/collection-search-query.d.ts +1 -1
- package/esm/schema/implementation/query/collection-update-many-query.d.ts +1 -1
- package/esm/schema/implementation/query/collection-update-query.d.ts +1 -1
- package/esm/schema/implementation/query/field-get-query.d.ts +1 -1
- package/esm/schema/implementation/query/index.d.ts +4 -4
- package/esm/schema/implementation/query/singleton-get-query.d.ts +1 -1
- package/esm/schema/implementation/resource/collection-resource-info.d.ts +2 -0
- package/esm/schema/implementation/resource/collection-resource-info.js +7 -0
- package/esm/schema/interfaces/data-type.metadata.d.ts +4 -4
- package/esm/schema/interfaces/resource.metadata.d.ts +9 -9
- package/esm/schema/types.d.ts +8 -8
- package/esm/url/opra-url-path-component.d.ts +1 -1
- package/esm/url/opra-url-path.d.ts +24 -18
- package/esm/url/opra-url-path.js +96 -72
- package/esm/url/opra-url-search-params.d.ts +3 -42
- package/esm/url/opra-url-search-params.js +16 -234
- package/esm/url/opra-url.d.ts +38 -28
- package/esm/url/opra-url.js +201 -160
- package/package.json +12 -12
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import antlr4 from 'antlr4';
|
|
1
|
+
import antlr4 from '@browsery/antlr4';
|
|
2
2
|
import { ArithmeticExpressionContext, LogicalExpressionContext, } from './antlr/OpraFilterParser.js';
|
|
3
3
|
import { ArithmeticExpression, ArrayExpression, BooleanLiteral, ComparisonExpression, DateLiteral, LogicalExpression, NullLiteral, NumberLiteral, ParenthesesExpression, QualifiedIdentifier, StringLiteral, TimeLiteral } from './ast/index.js';
|
|
4
4
|
import { ExternalConstant } from './ast/terms/external-constant.js';
|
|
5
5
|
import { SyntaxError } from './errors.js';
|
|
6
6
|
import { unquoteFilterString } from './utils.js';
|
|
7
|
-
// Fix: antlr4 d.ts files
|
|
7
|
+
// Fix: antlr4 d.ts files are invalid
|
|
8
8
|
const ParseTreeVisitor = antlr4.tree.ParseTreeVisitor;
|
|
9
9
|
export class FilterTreeVisitor extends ParseTreeVisitor {
|
|
10
10
|
constructor(options) {
|
|
11
11
|
super();
|
|
12
12
|
this._timeZone = options?.timeZone;
|
|
13
13
|
}
|
|
14
|
+
visitChildren(node) {
|
|
15
|
+
const result = super.visitChildren(node);
|
|
16
|
+
if (Array.isArray(result) && result.length < 2)
|
|
17
|
+
return result[0];
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
14
20
|
defaultResult() {
|
|
15
21
|
return undefined;
|
|
16
22
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ErrorListener, RecognitionException } from 'antlr4';
|
|
2
|
-
import { Recognizer } from 'antlr4/
|
|
1
|
+
import { ErrorListener, RecognitionException } from '@browsery/antlr4';
|
|
2
|
+
import { Recognizer } from '@browsery/antlr4/typings/Recognizer';
|
|
3
3
|
import { FilterParseError } from './errors.js';
|
|
4
4
|
export declare class OpraErrorListener extends ErrorListener<any> {
|
|
5
5
|
errors: FilterParseError[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorListener } from 'antlr4';
|
|
1
|
+
import { ErrorListener } from '@browsery/antlr4';
|
|
2
2
|
import { FilterParseError } from './errors.js';
|
|
3
3
|
export class OpraErrorListener extends ErrorListener {
|
|
4
4
|
constructor(errors) {
|
|
@@ -6,6 +6,6 @@ export class OpraErrorListener extends ErrorListener {
|
|
|
6
6
|
this.errors = errors;
|
|
7
7
|
}
|
|
8
8
|
syntaxError(recognizer, offendingSymbol, line, column, msg, e) {
|
|
9
|
-
this.errors.push(new FilterParseError(msg, { recognizer, offendingSymbol, line, e }));
|
|
9
|
+
this.errors.push(new FilterParseError(msg, { recognizer, offendingSymbol, line, column, e }));
|
|
10
10
|
}
|
|
11
11
|
}
|
package/esm/filter/parse.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ParseTreeVisitor } from 'antlr4';
|
|
1
|
+
import type { ParseTreeVisitor } from '@browsery/antlr4';
|
|
2
2
|
export declare function parseFilter(text: string, visitor?: ParseTreeVisitor<any>): any;
|
package/esm/filter/parse.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CharStream, CommonTokenStream } from 'antlr4';
|
|
1
|
+
import { CharStream, CommonTokenStream } from '@browsery/antlr4';
|
|
2
2
|
import OpraFilterLexer from './antlr/OpraFilterLexer.js';
|
|
3
3
|
import OpraFilterParser from './antlr/OpraFilterParser.js';
|
|
4
4
|
import { SyntaxError } from './errors.js';
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
export interface ResponsiveMapOptions {
|
|
2
|
+
wellKnownKeys?: string[];
|
|
3
|
+
caseSensitive?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export type ResponsiveMapInit<K, V> = ResponsiveMap<K, V> | Map<K, V> | Record<any, V>;
|
|
6
|
+
declare const kKeyMap: unique symbol;
|
|
7
|
+
declare const kKeyOrder: unique symbol;
|
|
8
|
+
declare const kWellKnownKeys: unique symbol;
|
|
9
|
+
declare const kOptions: unique symbol;
|
|
10
|
+
/**
|
|
11
|
+
* A Map implementation that supports case-insensitivity and ordered keys
|
|
12
|
+
*/
|
|
1
13
|
export declare class ResponsiveMap<K, V> extends Map<K, V> {
|
|
2
|
-
private
|
|
3
|
-
private
|
|
4
|
-
private
|
|
5
|
-
|
|
14
|
+
private [kKeyMap];
|
|
15
|
+
private [kKeyOrder];
|
|
16
|
+
private [kWellKnownKeys];
|
|
17
|
+
private [kOptions];
|
|
18
|
+
constructor(init?: ResponsiveMapInit<K, V>, options?: ResponsiveMapOptions);
|
|
6
19
|
clear(): void;
|
|
7
20
|
get(key: K): V | undefined;
|
|
8
21
|
has(key: K): boolean;
|
|
@@ -14,5 +27,6 @@ export declare class ResponsiveMap<K, V> extends Map<K, V> {
|
|
|
14
27
|
sort(compareFn?: (a: K, b: K) => number): this;
|
|
15
28
|
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
16
29
|
protected _getOriginalKey(key: K): K;
|
|
17
|
-
protected
|
|
30
|
+
protected _getStoringKey(key: K): K;
|
|
18
31
|
}
|
|
32
|
+
export {};
|
|
@@ -1,42 +1,55 @@
|
|
|
1
|
+
var _a, _b, _c, _d;
|
|
2
|
+
function isMap(v) {
|
|
3
|
+
return v && typeof v.forEach === 'function';
|
|
4
|
+
}
|
|
5
|
+
const kKeyMap = Symbol('kKeyMap');
|
|
6
|
+
const kKeyOrder = Symbol('kKeyOrder');
|
|
7
|
+
const kWellKnownKeys = Symbol('kWellKnownKeys');
|
|
8
|
+
const kOptions = Symbol('kOptions');
|
|
9
|
+
/**
|
|
10
|
+
* A Map implementation that supports case-insensitivity and ordered keys
|
|
11
|
+
*/
|
|
1
12
|
export class ResponsiveMap extends Map {
|
|
2
|
-
constructor(
|
|
13
|
+
constructor(init, options) {
|
|
3
14
|
super();
|
|
4
|
-
this
|
|
5
|
-
this
|
|
6
|
-
this
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (
|
|
10
|
-
|
|
15
|
+
this[_a] = new Map();
|
|
16
|
+
this[_b] = [];
|
|
17
|
+
this[_c] = new Map();
|
|
18
|
+
this[_d] = { caseSensitive: false };
|
|
19
|
+
this[kOptions].caseSensitive = !!options?.caseSensitive;
|
|
20
|
+
if (options?.wellKnownKeys)
|
|
21
|
+
options.wellKnownKeys.forEach(k => this[kWellKnownKeys].set(k.toLowerCase(), k));
|
|
22
|
+
if (isMap(init)) {
|
|
23
|
+
init.forEach((v, k) => this.set(k, v));
|
|
11
24
|
}
|
|
12
|
-
else if (
|
|
13
|
-
Object.keys(
|
|
25
|
+
else if (init && typeof init === 'object')
|
|
26
|
+
Object.keys(init).forEach(k => this.set(k, init[k]));
|
|
14
27
|
}
|
|
15
28
|
clear() {
|
|
16
29
|
super.clear();
|
|
17
|
-
this.
|
|
18
|
-
this
|
|
30
|
+
this[kKeyMap].clear();
|
|
31
|
+
this[kKeyOrder] = [];
|
|
19
32
|
}
|
|
20
33
|
get(key) {
|
|
21
34
|
const orgKey = this._getOriginalKey(key);
|
|
22
35
|
return super.get(orgKey);
|
|
23
36
|
}
|
|
24
37
|
has(key) {
|
|
25
|
-
return this.
|
|
38
|
+
return this[kKeyMap].has(this._getStoringKey(key));
|
|
26
39
|
}
|
|
27
40
|
set(key, value) {
|
|
28
41
|
key = this._getOriginalKey(key);
|
|
29
|
-
this.
|
|
30
|
-
if (!this.
|
|
31
|
-
this.
|
|
42
|
+
this[kKeyMap].set(this._getStoringKey(key), key);
|
|
43
|
+
if (!this[kKeyOrder].includes(key))
|
|
44
|
+
this[kKeyOrder].push(key);
|
|
32
45
|
return super.set(key, value);
|
|
33
46
|
}
|
|
34
47
|
keys() {
|
|
35
|
-
return this.
|
|
48
|
+
return this[kKeyOrder].values();
|
|
36
49
|
}
|
|
37
50
|
values() {
|
|
38
51
|
let i = -1;
|
|
39
|
-
const arr = this
|
|
52
|
+
const arr = this[kKeyOrder];
|
|
40
53
|
const map = this;
|
|
41
54
|
return {
|
|
42
55
|
[Symbol.iterator]() {
|
|
@@ -53,7 +66,7 @@ export class ResponsiveMap extends Map {
|
|
|
53
66
|
}
|
|
54
67
|
entries() {
|
|
55
68
|
let i = -1;
|
|
56
|
-
const arr = this
|
|
69
|
+
const arr = this[kKeyOrder];
|
|
57
70
|
const map = this;
|
|
58
71
|
return {
|
|
59
72
|
[Symbol.iterator]() {
|
|
@@ -70,27 +83,31 @@ export class ResponsiveMap extends Map {
|
|
|
70
83
|
}
|
|
71
84
|
delete(key) {
|
|
72
85
|
const orgKey = this._getOriginalKey(key);
|
|
73
|
-
const k = this.
|
|
74
|
-
this.
|
|
75
|
-
const i = this.
|
|
86
|
+
const k = this._getStoringKey(key);
|
|
87
|
+
this[kKeyMap].delete(k);
|
|
88
|
+
const i = this[kKeyOrder].indexOf(orgKey);
|
|
76
89
|
if (i >= 0)
|
|
77
|
-
this.
|
|
90
|
+
this[kKeyOrder].splice(i, 1);
|
|
78
91
|
return super.delete(orgKey);
|
|
79
92
|
}
|
|
80
93
|
sort(compareFn) {
|
|
81
|
-
this.
|
|
94
|
+
this[kKeyOrder].sort(compareFn);
|
|
82
95
|
return this;
|
|
83
96
|
}
|
|
84
|
-
[Symbol.iterator]() {
|
|
97
|
+
[(_a = kKeyMap, _b = kKeyOrder, _c = kWellKnownKeys, _d = kOptions, Symbol.iterator)]() {
|
|
85
98
|
return this.entries();
|
|
86
99
|
}
|
|
87
100
|
_getOriginalKey(key) {
|
|
101
|
+
if (this[kOptions].caseSensitive)
|
|
102
|
+
return key;
|
|
88
103
|
if (typeof key === 'string')
|
|
89
|
-
return this.
|
|
90
|
-
(this.
|
|
104
|
+
return this[kKeyMap].get(key.toLowerCase()) ??
|
|
105
|
+
(this[kWellKnownKeys].get(key.toLowerCase()) ?? key);
|
|
91
106
|
return key;
|
|
92
107
|
}
|
|
93
|
-
|
|
108
|
+
_getStoringKey(key) {
|
|
109
|
+
if (this[kOptions].caseSensitive)
|
|
110
|
+
return key;
|
|
94
111
|
if (typeof key === 'string')
|
|
95
112
|
return key.toLowerCase();
|
|
96
113
|
return key;
|