@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.
Files changed (126) hide show
  1. package/cjs/filter/antlr/OpraFilterLexer.js +1 -1
  2. package/cjs/filter/antlr/OpraFilterListener.js +1 -1
  3. package/cjs/filter/antlr/OpraFilterParser.js +5 -5
  4. package/cjs/filter/antlr/OpraFilterVisitor.js +1 -1
  5. package/cjs/filter/filter-tree-visitor.js +8 -2
  6. package/cjs/filter/opra-error-listener.js +2 -2
  7. package/cjs/filter/parse.js +1 -1
  8. package/cjs/helpers/responsive-map.js +45 -28
  9. package/{esm/http/enums/http-headers.enum.js → cjs/http/enums/http-headers-codes.enum.js} +95 -92
  10. package/{esm/http/enums/http-status.enum.js → cjs/http/enums/http-status-codes.enum.js} +62 -59
  11. package/cjs/http/http-headers.js +213 -0
  12. package/cjs/http/http-param-codec.js +6 -0
  13. package/cjs/http/http-params.js +321 -0
  14. package/cjs/http/http-request-node.js +105 -0
  15. package/cjs/http/http-request.js +73 -88
  16. package/cjs/http/http-response.js +23 -0
  17. package/cjs/http/index.js +13 -2
  18. package/cjs/http/multipart/batch-multipart.js +12 -12
  19. package/cjs/http/param-codec/boolean-codec.js +25 -0
  20. package/cjs/http/param-codec/date-codec.js +44 -0
  21. package/cjs/http/param-codec/filter-codec.js +18 -0
  22. package/cjs/http/param-codec/integer-codec.js +19 -0
  23. package/cjs/http/param-codec/number-codec.js +26 -0
  24. package/cjs/http/param-codec/string-codec.js +25 -0
  25. package/cjs/http/utils/encodeURIParam.js +21 -0
  26. package/cjs/http/utils/normalize-headers.js +2 -2
  27. package/cjs/i18n/i18n.js +1 -4
  28. package/cjs/schema/implementation/opra-document.js +12 -11
  29. package/cjs/schema/implementation/resource/collection-resource-info.js +7 -0
  30. package/cjs/url/opra-url-path.js +96 -72
  31. package/cjs/url/opra-url-search-params.js +16 -234
  32. package/cjs/url/opra-url.js +201 -160
  33. package/esm/filter/antlr/OpraFilterLexer.d.ts +1 -1
  34. package/esm/filter/antlr/OpraFilterLexer.js +1 -1
  35. package/esm/filter/antlr/OpraFilterListener.d.ts +1 -1
  36. package/esm/filter/antlr/OpraFilterListener.js +1 -1
  37. package/esm/filter/antlr/OpraFilterParser.d.ts +1 -1
  38. package/esm/filter/antlr/OpraFilterParser.js +5 -5
  39. package/esm/filter/antlr/OpraFilterVisitor.d.ts +1 -1
  40. package/esm/filter/antlr/OpraFilterVisitor.js +1 -1
  41. package/esm/filter/ast/expressions/arithmetic-expression.d.ts +1 -1
  42. package/esm/filter/ast/expressions/comparison-expression.d.ts +1 -1
  43. package/esm/filter/ast/expressions/logical-expression.d.ts +1 -1
  44. package/esm/filter/build.d.ts +3 -3
  45. package/esm/filter/errors.d.ts +4 -2
  46. package/esm/filter/filter-tree-visitor.d.ts +2 -1
  47. package/esm/filter/filter-tree-visitor.js +8 -2
  48. package/esm/filter/opra-error-listener.d.ts +2 -2
  49. package/esm/filter/opra-error-listener.js +2 -2
  50. package/esm/filter/parse.d.ts +1 -1
  51. package/esm/filter/parse.js +1 -1
  52. package/esm/helpers/responsive-map.d.ts +19 -5
  53. package/esm/helpers/responsive-map.js +45 -28
  54. package/esm/http/enums/{http-headers.enum.d.ts → http-headers-codes.enum.d.ts} +1 -1
  55. package/{cjs/http/enums/http-headers.enum.js → esm/http/enums/http-headers-codes.enum.js} +92 -95
  56. package/esm/http/enums/{http-status.enum.d.ts → http-status-codes.enum.d.ts} +1 -1
  57. package/{cjs/http/enums/http-status.enum.js → esm/http/enums/http-status-codes.enum.js} +59 -62
  58. package/esm/http/http-headers.d.ts +70 -0
  59. package/esm/http/http-headers.js +209 -0
  60. package/esm/http/http-param-codec.d.ts +4 -0
  61. package/esm/http/http-param-codec.js +2 -0
  62. package/esm/http/http-params.d.ts +99 -0
  63. package/esm/http/http-params.js +317 -0
  64. package/esm/http/http-request-node.d.ts +34 -0
  65. package/esm/http/http-request-node.js +101 -0
  66. package/esm/http/http-request.d.ts +73 -31
  67. package/esm/http/http-request.js +72 -87
  68. package/esm/http/http-response.d.ts +41 -0
  69. package/esm/http/http-response.js +19 -0
  70. package/esm/http/index.d.ts +13 -2
  71. package/esm/http/index.js +13 -2
  72. package/esm/http/interfaces/client-http-headers.interface.d.ts +1 -1
  73. package/esm/http/interfaces/server-http-headers.interface.d.ts +1 -1
  74. package/esm/http/multipart/batch-multipart.d.ts +1 -1
  75. package/esm/http/multipart/batch-multipart.js +12 -12
  76. package/esm/http/multipart/http-request-content.d.ts +1 -1
  77. package/esm/http/multipart/http-response-content.d.ts +1 -1
  78. package/esm/http/param-codec/boolean-codec.d.ts +5 -0
  79. package/esm/http/param-codec/boolean-codec.js +21 -0
  80. package/esm/http/param-codec/date-codec.d.ts +16 -0
  81. package/esm/http/param-codec/date-codec.js +40 -0
  82. package/esm/http/param-codec/filter-codec.d.ts +6 -0
  83. package/esm/http/param-codec/filter-codec.js +14 -0
  84. package/esm/http/param-codec/integer-codec.d.ts +9 -0
  85. package/esm/http/param-codec/integer-codec.js +15 -0
  86. package/esm/http/param-codec/number-codec.d.ts +12 -0
  87. package/esm/http/param-codec/number-codec.js +22 -0
  88. package/esm/http/param-codec/string-codec.d.ts +14 -0
  89. package/esm/http/param-codec/string-codec.js +21 -0
  90. package/esm/http/utils/encodeURIParam.d.ts +1 -0
  91. package/esm/http/utils/encodeURIParam.js +17 -0
  92. package/esm/http/utils/normalize-headers.js +2 -2
  93. package/esm/i18n/i18n.d.ts +6 -6
  94. package/esm/i18n/i18n.js +1 -4
  95. package/esm/schema/decorators/opr-collection-resource.decorator.d.ts +1 -1
  96. package/esm/schema/decorators/opr-complex-type.decorator.d.ts +1 -1
  97. package/esm/schema/decorators/opr-simple-type.decorator.d.ts +1 -1
  98. package/esm/schema/decorators/opr-singleton-resource.decorator.d.ts +1 -1
  99. package/esm/schema/implementation/data-type/complex-type.d.ts +1 -1
  100. package/esm/schema/implementation/data-type/union-type.d.ts +1 -1
  101. package/esm/schema/implementation/document-builder.d.ts +1 -1
  102. package/esm/schema/implementation/opra-document.d.ts +2 -2
  103. package/esm/schema/implementation/opra-document.js +12 -11
  104. package/esm/schema/implementation/query/collection-count-query.d.ts +1 -1
  105. package/esm/schema/implementation/query/collection-create-query.d.ts +1 -1
  106. package/esm/schema/implementation/query/collection-delete-many-query.d.ts +1 -1
  107. package/esm/schema/implementation/query/collection-get-query.d.ts +1 -1
  108. package/esm/schema/implementation/query/collection-search-query.d.ts +1 -1
  109. package/esm/schema/implementation/query/collection-update-many-query.d.ts +1 -1
  110. package/esm/schema/implementation/query/collection-update-query.d.ts +1 -1
  111. package/esm/schema/implementation/query/field-get-query.d.ts +1 -1
  112. package/esm/schema/implementation/query/index.d.ts +4 -4
  113. package/esm/schema/implementation/query/singleton-get-query.d.ts +1 -1
  114. package/esm/schema/implementation/resource/collection-resource-info.d.ts +2 -0
  115. package/esm/schema/implementation/resource/collection-resource-info.js +7 -0
  116. package/esm/schema/interfaces/data-type.metadata.d.ts +4 -4
  117. package/esm/schema/interfaces/resource.metadata.d.ts +9 -9
  118. package/esm/schema/types.d.ts +8 -8
  119. package/esm/url/opra-url-path-component.d.ts +1 -1
  120. package/esm/url/opra-url-path.d.ts +24 -18
  121. package/esm/url/opra-url-path.js +96 -72
  122. package/esm/url/opra-url-search-params.d.ts +3 -42
  123. package/esm/url/opra-url-search-params.js +16 -234
  124. package/esm/url/opra-url.d.ts +38 -28
  125. package/esm/url/opra-url.js +201 -160
  126. package/package.json +12 -12
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // Generated from ./src/filter/antlr/OpraFilter.g4 by ANTLR 4.11.2-SNAPSHOT
4
4
  // noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols
5
- const antlr4_1 = require("antlr4");
5
+ const antlr4_1 = require("@browsery/antlr4");
6
6
  class OpraFilterLexer extends antlr4_1.Lexer {
7
7
  constructor(input) {
8
8
  super(input);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // Generated from ./src/filter/antlr/OpraFilter.g4 by ANTLR 4.11.2-SNAPSHOT
4
- const antlr4_1 = require("antlr4");
4
+ const antlr4_1 = require("@browsery/antlr4");
5
5
  /**
6
6
  * This interface defines a complete listener for a parse tree produced by
7
7
  * `OpraFilterParser`.
@@ -5,12 +5,8 @@
5
5
  // @ts-nocheck
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.InfinityContext = exports.NullContext = exports.BooleanContext = exports.LogOpContext = exports.PolarOpContext = exports.ArthOpContext = exports.CompOpContext = exports.NumberLiteralContext = exports.BooleanLiteralContext = exports.InfinityLiteralContext = exports.DateLiteralContext = exports.StringLiteralContext = exports.DateTimeLiteralContext = exports.NullLiteralContext = exports.TimeLiteralContext = exports.LiteralContext = exports.IdentifierContext = exports.ExternalConstantContext = exports.QualifiedIdentifierContext = exports.PluralDateTimePrecisionContext = exports.DateTimePrecisionContext = exports.UnitContext = exports.ParamListContext = exports.FunctionContext = exports.MemberIndexContext = exports.NumberIndexContext = exports.IndexerContext = exports.MemberInvocationContext = exports.InvocationContext = exports.InvocableContext = exports.QualifiedIdentifierTermContext = exports.LiteralTermContext = exports.ExternalConstantTermContext = exports.TermContext = exports.TermExpressionContext = exports.LogicalExpressionContext = exports.ArithmeticExpressionContext = exports.ComparisonExpressionContext = exports.PolarityExpressionContext = exports.ArrayExpressionContext = exports.ParenthesizedExpressionContext = exports.ExpressionContext = exports.RootContext = void 0;
8
- const antlr4_1 = require("antlr4");
8
+ const antlr4_1 = require("@browsery/antlr4");
9
9
  class OpraFilterParser extends antlr4_1.Parser {
10
- constructor(input) {
11
- super(input);
12
- this._interp = new antlr4_1.ParserATNSimulator(this, OpraFilterParser._ATN, OpraFilterParser.DecisionsToDFA, new antlr4_1.PredictionContextCache());
13
- }
14
10
  get grammarFileName() {
15
11
  return "OpraFilter.g4";
16
12
  }
@@ -29,6 +25,10 @@ class OpraFilterParser extends antlr4_1.Parser {
29
25
  createFailedPredicateException(predicate, message) {
30
26
  return new antlr4_1.FailedPredicateException(this, predicate, message);
31
27
  }
28
+ constructor(input) {
29
+ super(input);
30
+ this._interp = new antlr4_1.ParserATNSimulator(this, OpraFilterParser._ATN, OpraFilterParser.DecisionsToDFA, new antlr4_1.PredictionContextCache());
31
+ }
32
32
  // @RuleVersion(0)
33
33
  root() {
34
34
  let localctx = new RootContext(this, this._ctx, this.state);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // Generated from ./src/filter/antlr/OpraFilter.g4 by ANTLR 4.11.2-SNAPSHOT
4
- const antlr4_1 = require("antlr4");
4
+ const antlr4_1 = require("@browsery/antlr4");
5
5
  /**
6
6
  * This interface defines a complete generic visitor for a parse tree produced
7
7
  * by `OpraFilterParser`.
@@ -2,19 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FilterTreeVisitor = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const antlr4_1 = tslib_1.__importDefault(require("antlr4"));
5
+ const antlr4_1 = tslib_1.__importDefault(require("@browsery/antlr4"));
6
6
  const OpraFilterParser_js_1 = require("./antlr/OpraFilterParser.js");
7
7
  const index_js_1 = require("./ast/index.js");
8
8
  const external_constant_js_1 = require("./ast/terms/external-constant.js");
9
9
  const errors_js_1 = require("./errors.js");
10
10
  const utils_js_1 = require("./utils.js");
11
- // Fix: antlr4 d.ts files is invalid
11
+ // Fix: antlr4 d.ts files are invalid
12
12
  const ParseTreeVisitor = antlr4_1.default.tree.ParseTreeVisitor;
13
13
  class FilterTreeVisitor extends ParseTreeVisitor {
14
14
  constructor(options) {
15
15
  super();
16
16
  this._timeZone = options?.timeZone;
17
17
  }
18
+ visitChildren(node) {
19
+ const result = super.visitChildren(node);
20
+ if (Array.isArray(result) && result.length < 2)
21
+ return result[0];
22
+ return result;
23
+ }
18
24
  defaultResult() {
19
25
  return undefined;
20
26
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OpraErrorListener = void 0;
4
- const antlr4_1 = require("antlr4");
4
+ const antlr4_1 = require("@browsery/antlr4");
5
5
  const errors_js_1 = require("./errors.js");
6
6
  class OpraErrorListener extends antlr4_1.ErrorListener {
7
7
  constructor(errors) {
@@ -9,7 +9,7 @@ class OpraErrorListener extends antlr4_1.ErrorListener {
9
9
  this.errors = errors;
10
10
  }
11
11
  syntaxError(recognizer, offendingSymbol, line, column, msg, e) {
12
- this.errors.push(new errors_js_1.FilterParseError(msg, { recognizer, offendingSymbol, line, e }));
12
+ this.errors.push(new errors_js_1.FilterParseError(msg, { recognizer, offendingSymbol, line, column, e }));
13
13
  }
14
14
  }
15
15
  exports.OpraErrorListener = OpraErrorListener;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseFilter = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const antlr4_1 = require("antlr4");
5
+ const antlr4_1 = require("@browsery/antlr4");
6
6
  const OpraFilterLexer_js_1 = tslib_1.__importDefault(require("./antlr/OpraFilterLexer.js"));
7
7
  const OpraFilterParser_js_1 = tslib_1.__importDefault(require("./antlr/OpraFilterParser.js"));
8
8
  const errors_js_1 = require("./errors.js");
@@ -1,45 +1,58 @@
1
1
  "use strict";
2
+ var _a, _b, _c, _d;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.ResponsiveMap = void 0;
5
+ function isMap(v) {
6
+ return v && typeof v.forEach === 'function';
7
+ }
8
+ const kKeyMap = Symbol('kKeyMap');
9
+ const kKeyOrder = Symbol('kKeyOrder');
10
+ const kWellKnownKeys = Symbol('kWellKnownKeys');
11
+ const kOptions = Symbol('kOptions');
12
+ /**
13
+ * A Map implementation that supports case-insensitivity and ordered keys
14
+ */
4
15
  class ResponsiveMap extends Map {
5
- constructor(data, wellKnownKeys) {
16
+ constructor(init, options) {
6
17
  super();
7
- this._keyMap = new Map();
8
- this._keyOrder = [];
9
- this._wellKnownKeyMap = new Map();
10
- if (wellKnownKeys)
11
- wellKnownKeys.forEach(k => this._wellKnownKeyMap.set(k.toLowerCase(), k));
12
- if (typeof data?.forEach === 'function') {
13
- data.forEach((v, k) => this.set(k, v));
18
+ this[_a] = new Map();
19
+ this[_b] = [];
20
+ this[_c] = new Map();
21
+ this[_d] = { caseSensitive: false };
22
+ this[kOptions].caseSensitive = !!options?.caseSensitive;
23
+ if (options?.wellKnownKeys)
24
+ options.wellKnownKeys.forEach(k => this[kWellKnownKeys].set(k.toLowerCase(), k));
25
+ if (isMap(init)) {
26
+ init.forEach((v, k) => this.set(k, v));
14
27
  }
15
- else if (data && typeof data === 'object')
16
- Object.keys(data).forEach(k => this.set(k, data[k]));
28
+ else if (init && typeof init === 'object')
29
+ Object.keys(init).forEach(k => this.set(k, init[k]));
17
30
  }
18
31
  clear() {
19
32
  super.clear();
20
- this._keyMap.clear();
21
- this._keyOrder = [];
33
+ this[kKeyMap].clear();
34
+ this[kKeyOrder] = [];
22
35
  }
23
36
  get(key) {
24
37
  const orgKey = this._getOriginalKey(key);
25
38
  return super.get(orgKey);
26
39
  }
27
40
  has(key) {
28
- return this._keyMap.has(this._getLowerKey(key));
41
+ return this[kKeyMap].has(this._getStoringKey(key));
29
42
  }
30
43
  set(key, value) {
31
44
  key = this._getOriginalKey(key);
32
- this._keyMap.set(this._getLowerKey(key), key);
33
- if (!this._keyOrder.includes(key))
34
- this._keyOrder.push(key);
45
+ this[kKeyMap].set(this._getStoringKey(key), key);
46
+ if (!this[kKeyOrder].includes(key))
47
+ this[kKeyOrder].push(key);
35
48
  return super.set(key, value);
36
49
  }
37
50
  keys() {
38
- return this._keyOrder.values();
51
+ return this[kKeyOrder].values();
39
52
  }
40
53
  values() {
41
54
  let i = -1;
42
- const arr = this._keyOrder;
55
+ const arr = this[kKeyOrder];
43
56
  const map = this;
44
57
  return {
45
58
  [Symbol.iterator]() {
@@ -56,7 +69,7 @@ class ResponsiveMap extends Map {
56
69
  }
57
70
  entries() {
58
71
  let i = -1;
59
- const arr = this._keyOrder;
72
+ const arr = this[kKeyOrder];
60
73
  const map = this;
61
74
  return {
62
75
  [Symbol.iterator]() {
@@ -73,27 +86,31 @@ class ResponsiveMap extends Map {
73
86
  }
74
87
  delete(key) {
75
88
  const orgKey = this._getOriginalKey(key);
76
- const k = this._getLowerKey(key);
77
- this._keyMap.delete(k);
78
- const i = this._keyOrder.indexOf(orgKey);
89
+ const k = this._getStoringKey(key);
90
+ this[kKeyMap].delete(k);
91
+ const i = this[kKeyOrder].indexOf(orgKey);
79
92
  if (i >= 0)
80
- this._keyOrder.splice(i, 1);
93
+ this[kKeyOrder].splice(i, 1);
81
94
  return super.delete(orgKey);
82
95
  }
83
96
  sort(compareFn) {
84
- this._keyOrder.sort(compareFn);
97
+ this[kKeyOrder].sort(compareFn);
85
98
  return this;
86
99
  }
87
- [Symbol.iterator]() {
100
+ [(_a = kKeyMap, _b = kKeyOrder, _c = kWellKnownKeys, _d = kOptions, Symbol.iterator)]() {
88
101
  return this.entries();
89
102
  }
90
103
  _getOriginalKey(key) {
104
+ if (this[kOptions].caseSensitive)
105
+ return key;
91
106
  if (typeof key === 'string')
92
- return this._keyMap.get(key.toLowerCase()) ??
93
- (this._wellKnownKeyMap.get(key.toLowerCase()) ?? key);
107
+ return this[kKeyMap].get(key.toLowerCase()) ??
108
+ (this[kWellKnownKeys].get(key.toLowerCase()) ?? key);
94
109
  return key;
95
110
  }
96
- _getLowerKey(key) {
111
+ _getStoringKey(key) {
112
+ if (this[kOptions].caseSensitive)
113
+ return key;
97
114
  if (typeof key === 'string')
98
115
  return key.toLowerCase();
99
116
  return key;