@opra/common 0.10.3 → 0.13.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 (132) 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/data-type/data-type.js +4 -0
  29. package/cjs/schema/implementation/opra-document.js +12 -11
  30. package/cjs/schema/implementation/resource/collection-resource-info.js +15 -0
  31. package/cjs/schema/implementation/resource/singleton-resource-info.js +8 -0
  32. package/cjs/url/opra-url-path.js +96 -72
  33. package/cjs/url/opra-url-search-params.js +16 -234
  34. package/cjs/url/opra-url.js +201 -160
  35. package/esm/filter/antlr/OpraFilterLexer.d.ts +1 -1
  36. package/esm/filter/antlr/OpraFilterLexer.js +1 -1
  37. package/esm/filter/antlr/OpraFilterListener.d.ts +1 -1
  38. package/esm/filter/antlr/OpraFilterListener.js +1 -1
  39. package/esm/filter/antlr/OpraFilterParser.d.ts +1 -1
  40. package/esm/filter/antlr/OpraFilterParser.js +5 -5
  41. package/esm/filter/antlr/OpraFilterVisitor.d.ts +1 -1
  42. package/esm/filter/antlr/OpraFilterVisitor.js +1 -1
  43. package/esm/filter/ast/expressions/arithmetic-expression.d.ts +1 -1
  44. package/esm/filter/ast/expressions/comparison-expression.d.ts +1 -1
  45. package/esm/filter/ast/expressions/logical-expression.d.ts +1 -1
  46. package/esm/filter/build.d.ts +3 -3
  47. package/esm/filter/errors.d.ts +4 -2
  48. package/esm/filter/filter-tree-visitor.d.ts +2 -1
  49. package/esm/filter/filter-tree-visitor.js +8 -2
  50. package/esm/filter/opra-error-listener.d.ts +2 -2
  51. package/esm/filter/opra-error-listener.js +2 -2
  52. package/esm/filter/parse.d.ts +1 -1
  53. package/esm/filter/parse.js +1 -1
  54. package/esm/helpers/responsive-map.d.ts +19 -5
  55. package/esm/helpers/responsive-map.js +45 -28
  56. package/esm/http/enums/{http-headers.enum.d.ts → http-headers-codes.enum.d.ts} +1 -1
  57. package/{cjs/http/enums/http-headers.enum.js → esm/http/enums/http-headers-codes.enum.js} +92 -95
  58. package/esm/http/enums/{http-status.enum.d.ts → http-status-codes.enum.d.ts} +1 -1
  59. package/{cjs/http/enums/http-status.enum.js → esm/http/enums/http-status-codes.enum.js} +59 -62
  60. package/esm/http/http-headers.d.ts +70 -0
  61. package/esm/http/http-headers.js +209 -0
  62. package/esm/http/http-param-codec.d.ts +4 -0
  63. package/esm/http/http-param-codec.js +2 -0
  64. package/esm/http/http-params.d.ts +99 -0
  65. package/esm/http/http-params.js +317 -0
  66. package/esm/http/http-request-node.d.ts +34 -0
  67. package/esm/http/http-request-node.js +101 -0
  68. package/esm/http/http-request.d.ts +73 -31
  69. package/esm/http/http-request.js +72 -87
  70. package/esm/http/http-response.d.ts +41 -0
  71. package/esm/http/http-response.js +19 -0
  72. package/esm/http/index.d.ts +13 -2
  73. package/esm/http/index.js +13 -2
  74. package/esm/http/interfaces/client-http-headers.interface.d.ts +1 -1
  75. package/esm/http/interfaces/server-http-headers.interface.d.ts +1 -1
  76. package/esm/http/multipart/batch-multipart.d.ts +1 -1
  77. package/esm/http/multipart/batch-multipart.js +12 -12
  78. package/esm/http/multipart/http-request-content.d.ts +1 -1
  79. package/esm/http/multipart/http-response-content.d.ts +1 -1
  80. package/esm/http/param-codec/boolean-codec.d.ts +5 -0
  81. package/esm/http/param-codec/boolean-codec.js +21 -0
  82. package/esm/http/param-codec/date-codec.d.ts +16 -0
  83. package/esm/http/param-codec/date-codec.js +40 -0
  84. package/esm/http/param-codec/filter-codec.d.ts +6 -0
  85. package/esm/http/param-codec/filter-codec.js +14 -0
  86. package/esm/http/param-codec/integer-codec.d.ts +9 -0
  87. package/esm/http/param-codec/integer-codec.js +15 -0
  88. package/esm/http/param-codec/number-codec.d.ts +12 -0
  89. package/esm/http/param-codec/number-codec.js +22 -0
  90. package/esm/http/param-codec/string-codec.d.ts +14 -0
  91. package/esm/http/param-codec/string-codec.js +21 -0
  92. package/esm/http/utils/encodeURIParam.d.ts +1 -0
  93. package/esm/http/utils/encodeURIParam.js +17 -0
  94. package/esm/http/utils/normalize-headers.js +2 -2
  95. package/esm/i18n/i18n.d.ts +6 -6
  96. package/esm/i18n/i18n.js +1 -4
  97. package/esm/schema/decorators/opr-collection-resource.decorator.d.ts +1 -1
  98. package/esm/schema/decorators/opr-complex-type.decorator.d.ts +1 -1
  99. package/esm/schema/decorators/opr-simple-type.decorator.d.ts +1 -1
  100. package/esm/schema/decorators/opr-singleton-resource.decorator.d.ts +1 -1
  101. package/esm/schema/implementation/data-type/complex-type.d.ts +1 -1
  102. package/esm/schema/implementation/data-type/data-type.d.ts +1 -0
  103. package/esm/schema/implementation/data-type/data-type.js +4 -0
  104. package/esm/schema/implementation/data-type/union-type.d.ts +1 -1
  105. package/esm/schema/implementation/document-builder.d.ts +1 -1
  106. package/esm/schema/implementation/opra-document.d.ts +2 -2
  107. package/esm/schema/implementation/opra-document.js +12 -11
  108. package/esm/schema/implementation/query/collection-count-query.d.ts +1 -1
  109. package/esm/schema/implementation/query/collection-create-query.d.ts +1 -1
  110. package/esm/schema/implementation/query/collection-delete-many-query.d.ts +1 -1
  111. package/esm/schema/implementation/query/collection-get-query.d.ts +1 -1
  112. package/esm/schema/implementation/query/collection-search-query.d.ts +1 -1
  113. package/esm/schema/implementation/query/collection-update-many-query.d.ts +1 -1
  114. package/esm/schema/implementation/query/collection-update-query.d.ts +1 -1
  115. package/esm/schema/implementation/query/field-get-query.d.ts +1 -1
  116. package/esm/schema/implementation/query/index.d.ts +4 -4
  117. package/esm/schema/implementation/query/singleton-get-query.d.ts +1 -1
  118. package/esm/schema/implementation/resource/collection-resource-info.d.ts +3 -0
  119. package/esm/schema/implementation/resource/collection-resource-info.js +15 -0
  120. package/esm/schema/implementation/resource/singleton-resource-info.d.ts +1 -0
  121. package/esm/schema/implementation/resource/singleton-resource-info.js +8 -0
  122. package/esm/schema/interfaces/data-type.metadata.d.ts +4 -4
  123. package/esm/schema/interfaces/resource.metadata.d.ts +9 -9
  124. package/esm/schema/types.d.ts +8 -8
  125. package/esm/url/opra-url-path-component.d.ts +1 -1
  126. package/esm/url/opra-url-path.d.ts +24 -18
  127. package/esm/url/opra-url-path.js +96 -72
  128. package/esm/url/opra-url-search-params.d.ts +3 -42
  129. package/esm/url/opra-url-search-params.js +16 -234
  130. package/esm/url/opra-url.d.ts +38 -28
  131. package/esm/url/opra-url.js +201 -160
  132. package/package.json +11 -11
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.OpraURL = void 0;
4
5
  const fast_tokenizer_1 = require("fast-tokenizer");
@@ -10,166 +11,227 @@ const urlRegEx = /^(?:((?:[A-Z][A-Z+-.]+:)+)\/\/([^/?]+))?(.*)?$/i;
10
11
  const schemeRegEx = /^([A-Z][A-Z+-.]+:?)+$/i;
11
12
  const hostRegEx = /^([^/:]+)(?::(\d+))?$/;
12
13
  const hostnameRegEx = /^([^/:]+)$/;
13
- const CONTEXT_KEY = Symbol.for('opra.url.context');
14
- const PATH_KEY = Symbol.for('opra.url.path');
15
- const SEARCHPARAMS_KEY = Symbol.for('opra.url.searchparams');
14
+ const kContext = Symbol('kContext');
15
+ const kPath = Symbol('kPath');
16
+ const kSearchParams = Symbol('kSearchParams');
16
17
  class OpraURL {
17
- constructor(input, pathPrefix) {
18
- Object.defineProperty(this, CONTEXT_KEY, {
19
- writable: true,
20
- configurable: true,
21
- enumerable: false,
22
- value: {}
23
- });
24
- Object.defineProperty(this, PATH_KEY, {
25
- writable: true,
26
- configurable: true,
27
- enumerable: false,
28
- value: new opra_url_path_js_1.OpraURLPath()
18
+ constructor(input, arg1) {
19
+ this[_a] = {
20
+ protocol: '',
21
+ username: '',
22
+ pathname: '',
23
+ prefix: '',
24
+ hostname: '',
25
+ port: '',
26
+ hash: '',
27
+ password: '',
28
+ search: '',
29
+ address: '',
30
+ needUpdate: true
31
+ };
32
+ this[kPath] = new opra_url_path_js_1.OpraURLPath('', {
33
+ onChange: () => this._changed()
29
34
  });
30
- Object.defineProperty(this, SEARCHPARAMS_KEY, {
31
- writable: true,
32
- configurable: true,
33
- enumerable: false,
34
- value: new opra_url_search_params_js_1.OpraURLSearchParams()
35
+ this[kSearchParams] = new opra_url_search_params_js_1.OpraURLSearchParams('', {
36
+ onChange: () => this._changed()
35
37
  });
36
- this.searchParams.on('change', () => this._invalidate());
37
- this.path.on('change', () => this._invalidate());
38
- if (pathPrefix)
39
- this.setPrefix(pathPrefix);
38
+ const base = typeof arg1 === 'object' ? arg1.base : arg1;
39
+ if (typeof arg1 === 'object') {
40
+ const defineParams = arg1?.params;
41
+ if (defineParams)
42
+ Object.keys(defineParams).forEach(key => this.searchParams.define(key, defineParams[key]));
43
+ }
40
44
  if (input)
41
- this.parse(input);
45
+ this.parse(typeof input === 'object' ? input.toString() : input);
46
+ if (base) {
47
+ const baseUrl = base instanceof OpraURL ? base : new OpraURL(base);
48
+ this[kContext].protocol = baseUrl.protocol;
49
+ this[kContext].hostname = baseUrl.hostname;
50
+ this[kContext].port = baseUrl.port;
51
+ this[kContext].prefix = baseUrl.pathname;
52
+ }
42
53
  }
43
54
  get address() {
44
55
  this._update();
45
- let out = '';
46
- if (this.hostname) {
47
- out += this.protocol + '//' +
48
- (this.username || this.password
49
- ? ((this.username ? encodeURIComponent(this.username) : '') +
50
- (this.password ? ':' + encodeURIComponent(this.password) : '') + '@')
51
- : '') + this.host;
52
- }
53
- return out + this.pathPrefix + this.pathname;
56
+ return this[kContext].address;
54
57
  }
55
- get href() {
56
- return this.address + this.search + this.hash;
58
+ get host() {
59
+ return this.hostname ? (this.hostname + (this.port ? ':' + this.port : '')) : '';
57
60
  }
58
- get protocol() {
59
- return this[CONTEXT_KEY].protocol || 'http:';
61
+ set host(v) {
62
+ if (v) {
63
+ const m = hostRegEx.exec(v);
64
+ if (!m)
65
+ throw Object.assign(new TypeError('Invalid host'), {
66
+ host: v,
67
+ code: 'ERR_INVALID_URL'
68
+ });
69
+ this[kContext].hostname = m[1];
70
+ this[kContext].port = m[2] || '';
71
+ }
72
+ else {
73
+ this[kContext].hostname = '';
74
+ this[kContext].port = '';
75
+ }
76
+ this._changed();
60
77
  }
61
- set protocol(v) {
62
- if (!schemeRegEx.test(v))
63
- throw Object.assign(new TypeError('Invalid protocol'), {
64
- protocol: v,
65
- code: 'ERR_INVALID_URL'
66
- });
67
- this[CONTEXT_KEY].protocol = v + (v.endsWith(':') ? '' : ':');
78
+ get hostname() {
79
+ return this[kContext].hostname || '';
68
80
  }
69
- get username() {
70
- return this[CONTEXT_KEY].username || '';
81
+ set hostname(v) {
82
+ if (v) {
83
+ if (!hostnameRegEx.test(v))
84
+ throw Object.assign(new TypeError('Invalid hostname'), {
85
+ hostname: v,
86
+ code: 'ERR_INVALID_URL'
87
+ });
88
+ this[kContext].hostname = v;
89
+ }
90
+ else
91
+ this[kContext].hostname = '';
92
+ this._changed();
71
93
  }
72
- set username(v) {
73
- this[CONTEXT_KEY].username = v;
94
+ get href() {
95
+ return this.address + this.search + this.hash;
74
96
  }
75
97
  get password() {
76
- return this[CONTEXT_KEY].password || '';
98
+ return this[kContext].password;
77
99
  }
78
100
  set password(v) {
79
- this[CONTEXT_KEY].password = v;
101
+ this[kContext].password = v || '';
102
+ this._changed();
80
103
  }
81
- get host() {
82
- return this.hostname ? (this.hostname + (this.port ? ':' + this.port : '')) : '';
83
- }
84
- set host(v) {
85
- const m = hostRegEx.exec(v);
86
- if (!m)
87
- throw Object.assign(new TypeError('Invalid host'), {
88
- host: v,
89
- code: 'ERR_INVALID_URL'
90
- });
91
- this[CONTEXT_KEY].hostname = m[1];
92
- this[CONTEXT_KEY].port = m[2] ? parseInt(m[2], 10) : null;
104
+ get port() {
105
+ return this[kContext].port;
106
+ }
107
+ set port(value) {
108
+ if (value) {
109
+ // noinspection SuspiciousTypeOfGuard
110
+ const v = parseInt(value, 10);
111
+ if (isNaN(v) || v < 1 || v > 35535 || v % 1 > 0)
112
+ throw Object.assign(new TypeError('Invalid port'), {
113
+ hostname: v,
114
+ code: 'ERR_INVALID_URL'
115
+ });
116
+ this[kContext].port = value;
117
+ }
118
+ else
119
+ this[kContext].port = '';
120
+ this._changed();
93
121
  }
94
- get hostname() {
95
- return this[CONTEXT_KEY].hostname || '';
122
+ get prefix() {
123
+ return this[kContext].prefix;
96
124
  }
97
- set hostname(v) {
98
- if (!hostnameRegEx.test(v))
99
- throw Object.assign(new TypeError('Invalid hostname'), {
100
- hostname: v,
101
- code: 'ERR_INVALID_URL'
102
- });
103
- this[CONTEXT_KEY].hostname = v;
125
+ set prefix(value) {
126
+ if (value) {
127
+ const url = new OpraURL(value);
128
+ this[kContext].prefix = url.pathname;
129
+ }
130
+ else
131
+ this[kContext].prefix = '';
132
+ this._changed();
104
133
  }
105
- get port() {
106
- const v = this[CONTEXT_KEY].port;
107
- return v == null ? null : v;
134
+ get protocol() {
135
+ return this[kContext].protocol || 'http:';
108
136
  }
109
- set port(v) {
110
- if (v == null) {
111
- this[CONTEXT_KEY].port = null;
112
- return;
137
+ set protocol(v) {
138
+ if (v) {
139
+ if (!schemeRegEx.test(v))
140
+ throw Object.assign(new TypeError('Invalid protocol'), {
141
+ protocol: v,
142
+ code: 'ERR_INVALID_URL'
143
+ });
144
+ this[kContext].protocol = v + (v.endsWith(':') ? '' : ':');
113
145
  }
114
- // noinspection SuspiciousTypeOfGuard
115
- if (typeof v !== 'number' || isNaN(v) || v < 1 || v > 35535 || v % 1 > 0)
116
- throw Object.assign(new TypeError('Invalid port'), {
117
- hostname: v,
118
- code: 'ERR_INVALID_URL'
119
- });
120
- this[CONTEXT_KEY].port = v;
146
+ else
147
+ this[kContext].protocol = '';
148
+ this._changed();
121
149
  }
122
- get origin() {
123
- return this.hostname ? (this.protocol + '//' + this.hostname) : '';
150
+ get username() {
151
+ return this[kContext].username;
124
152
  }
125
- get pathPrefix() {
126
- return this[CONTEXT_KEY].pathPrefix || '';
153
+ set username(v) {
154
+ this[kContext].username = v || '';
155
+ this._changed();
127
156
  }
128
- set pathPrefix(v) {
129
- if (!v) {
130
- this[CONTEXT_KEY].pathPrefix = '';
131
- return;
132
- }
133
- v = (0, path_utils_js_1.normalizePath)((0, fast_tokenizer_1.tokenize)(v, { delimiters: '#?', quotes: true, brackets: true }).next() || '', true);
134
- if (v.includes('://'))
135
- this[CONTEXT_KEY].pathPrefix = v;
136
- else
137
- this[CONTEXT_KEY].pathPrefix = v ? '/' + v : '';
157
+ get origin() {
158
+ return this.hostname ? (this.protocol + '//' + this.hostname) : '';
138
159
  }
139
160
  get path() {
140
- return this[PATH_KEY];
161
+ return this[kPath];
141
162
  }
142
163
  get pathname() {
143
164
  this._update();
144
- return this[CONTEXT_KEY].pathname || '';
165
+ return this[kContext].pathname || '';
145
166
  }
146
167
  set pathname(v) {
147
168
  this._setPathname(v, false);
148
169
  }
149
170
  get searchParams() {
150
- return this[SEARCHPARAMS_KEY];
171
+ return this[kSearchParams];
151
172
  }
152
173
  get hash() {
153
- return this[CONTEXT_KEY].hash || '';
174
+ return this[kContext].hash || '';
154
175
  }
155
176
  set hash(v) {
156
- this[CONTEXT_KEY].hash = v ? (v.startsWith('#') ? v : '#' + v) : '';
177
+ this[kContext].hash = v ? (v.startsWith('#') ? v : '#' + v) : '';
178
+ this._changed();
157
179
  }
158
180
  get search() {
159
181
  this._update();
160
- return this[CONTEXT_KEY].search || '';
182
+ return this[kContext].search || '';
161
183
  }
162
184
  set search(v) {
163
- this.searchParams.parse(v);
185
+ this.searchParams.clear();
186
+ this.searchParams.appendAll(v);
187
+ }
188
+ parse(input) {
189
+ const m = urlRegEx.exec(input);
190
+ if (!m)
191
+ throw Object.assign(new TypeError('Invalid URL'), {
192
+ input,
193
+ code: 'ERR_INVALID_URL'
194
+ });
195
+ this.protocol = m[1];
196
+ const isAbsolute = !!m[2];
197
+ if (isAbsolute) {
198
+ let tokens = (0, fast_tokenizer_1.splitString)(m[2], { delimiters: '@' });
199
+ if (tokens.length > 1) {
200
+ this.host = tokens[1];
201
+ tokens = (0, fast_tokenizer_1.splitString)(tokens[0], { delimiters: ':' });
202
+ this.username = tokens[0] ? decodeURIComponent(tokens[0]) : '';
203
+ this.password = tokens[1] ? decodeURIComponent(tokens[1]) : '';
204
+ }
205
+ else
206
+ this.host = tokens[0];
207
+ }
208
+ else {
209
+ this.host = '';
210
+ this.username = '';
211
+ this.password = '';
212
+ }
213
+ input = m[3] || '';
214
+ let tokenizer = (0, fast_tokenizer_1.tokenize)(input, { delimiters: '#', quotes: true, brackets: true });
215
+ input = tokenizer.next() || '';
216
+ this.hash = tokenizer.join('#');
217
+ tokenizer = (0, fast_tokenizer_1.tokenize)(input, { delimiters: '?', quotes: true, brackets: true });
218
+ this._setPathname(tokenizer.next() || '', isAbsolute);
219
+ this.searchParams.clear();
220
+ this.searchParams.appendAll(tokenizer.join('&'));
221
+ this._changed();
164
222
  }
165
- addPath(name, key) {
166
- this.path.add(name, key);
223
+ join(...source) {
224
+ this.path.join(...source);
167
225
  return this;
168
226
  }
169
- addSearchParam(name, value) {
227
+ addParam(name, value) {
170
228
  this.searchParams.append(name, value);
171
229
  return this;
172
230
  }
231
+ setParam(name, value) {
232
+ this.searchParams.set(name, value);
233
+ return this;
234
+ }
173
235
  setHost(v) {
174
236
  this.host = v;
175
237
  return this;
@@ -183,11 +245,11 @@ class OpraURL {
183
245
  return this;
184
246
  }
185
247
  setPort(v) {
186
- this.port = v;
248
+ this.port = v ? String(v) : '';
187
249
  return this;
188
250
  }
189
251
  setPrefix(v) {
190
- this.pathPrefix = v;
252
+ this.prefix = v;
191
253
  return this;
192
254
  }
193
255
  setPathname(v) {
@@ -202,46 +264,11 @@ class OpraURL {
202
264
  this.search = v;
203
265
  return this;
204
266
  }
205
- setSearchParam(name, value) {
206
- this.searchParams.set(name, value);
207
- return this;
208
- }
209
- parse(input) {
210
- const m = urlRegEx.exec(input);
211
- if (!m)
212
- throw Object.assign(new TypeError('Invalid URL'), {
213
- input,
214
- code: 'ERR_INVALID_URL'
215
- });
216
- if (m[1])
217
- this.protocol = m[1];
218
- if (m[2]) {
219
- let tokens = (0, fast_tokenizer_1.splitString)(m[2], { delimiters: '@' });
220
- if (tokens.length > 1) {
221
- this.host = tokens[1];
222
- tokens = (0, fast_tokenizer_1.splitString)(tokens[0], { delimiters: ':' });
223
- this.username = tokens[0] ? decodeURIComponent(tokens[0]) : '';
224
- this.password = tokens[1] ? decodeURIComponent(tokens[1]) : '';
225
- }
226
- else
227
- this.host = tokens[0];
228
- }
229
- input = m[3] || '';
230
- let tokenizer = (0, fast_tokenizer_1.tokenize)(input, { delimiters: '#', quotes: true, brackets: true });
231
- input = tokenizer.next() || '';
232
- this.hash = tokenizer.join('#');
233
- tokenizer = (0, fast_tokenizer_1.tokenize)(input, { delimiters: '?', quotes: true, brackets: true });
234
- this._setPathname(tokenizer.next() || '', true);
235
- // this.path.join()
236
- this.searchParams.clear();
237
- this.searchParams.parse(tokenizer.join('&'));
238
- return this;
239
- }
240
267
  toString() {
241
268
  return this.href;
242
269
  }
243
270
  /* istanbul ignore next */
244
- [nodeInspectCustom]() {
271
+ [(_a = kContext, nodeInspectCustom)]() {
245
272
  this._update();
246
273
  return {
247
274
  protocol: this.protocol,
@@ -250,7 +277,7 @@ class OpraURL {
250
277
  host: this.host,
251
278
  hostname: this.hostname,
252
279
  origin: this.origin,
253
- pathPrefix: this.pathPrefix,
280
+ pathPrefix: this.prefix,
254
281
  path: this.path,
255
282
  pathname: this.pathname,
256
283
  search: this.search,
@@ -258,27 +285,34 @@ class OpraURL {
258
285
  hash: this.hash,
259
286
  };
260
287
  }
261
- _invalidate() {
262
- this[CONTEXT_KEY].needUpdate = true;
263
- }
264
288
  _update() {
265
- if (!this[CONTEXT_KEY].needUpdate)
289
+ if (!this[kContext].needUpdate)
266
290
  return;
267
- this[CONTEXT_KEY].needUpdate = false;
291
+ const ctx = this[kContext];
292
+ ctx.needUpdate = false;
268
293
  let s = this.path.toString();
269
- this[CONTEXT_KEY].pathname = s ? '/' + s : '';
294
+ ctx.pathname = s ? '/' + s : '';
270
295
  s = this.searchParams.toString();
271
- this[CONTEXT_KEY].search = s ? '?' + s : '';
296
+ ctx.search = s ? '?' + s : '';
297
+ let address = '';
298
+ if (ctx.hostname) {
299
+ address += (ctx.protocol || 'http:') + '//' +
300
+ (ctx.username || ctx.password
301
+ ? ((ctx.username ? encodeURIComponent(ctx.username) : '') +
302
+ (ctx.password ? ':' + encodeURIComponent(ctx.password) : '') + '@')
303
+ : '') + this.host;
304
+ }
305
+ ctx.address = address + ctx.prefix + ctx.pathname;
272
306
  }
273
- _setPathname(v, inclSvcRoot) {
307
+ _setPathname(v, trimPrefix) {
274
308
  this.path.clear();
275
309
  if (!v)
276
310
  return;
277
311
  const pathTokenizer = (0, fast_tokenizer_1.tokenize)((0, path_utils_js_1.normalizePath)(v, true), {
278
312
  delimiters: '/', quotes: true, brackets: true,
279
313
  });
280
- if (inclSvcRoot && this.pathPrefix) {
281
- const prefixTokenizer = (0, fast_tokenizer_1.tokenize)((0, path_utils_js_1.normalizePath)(this.pathPrefix, true), {
314
+ if (trimPrefix && this.prefix) {
315
+ const prefixTokenizer = (0, fast_tokenizer_1.tokenize)((0, path_utils_js_1.normalizePath)(this.prefix, true), {
282
316
  delimiters: '/', quotes: true, brackets: true,
283
317
  });
284
318
  for (const a of prefixTokenizer) {
@@ -289,8 +323,15 @@ class OpraURL {
289
323
  }
290
324
  for (const x of pathTokenizer) {
291
325
  const p = (0, path_utils_js_1.decodePathComponent)(x);
292
- this.path.add(p);
326
+ this.path.join(p);
293
327
  }
328
+ this._changed();
329
+ }
330
+ _changed() {
331
+ this[kContext].needUpdate = true;
294
332
  }
295
333
  }
296
334
  exports.OpraURL = OpraURL;
335
+ OpraURL.kContext = kContext;
336
+ OpraURL.kPath = kPath;
337
+ OpraURL.kSearchParams = kSearchParams;
@@ -1,4 +1,4 @@
1
- import { ATN, CharStream, DFA, Lexer } from "antlr4";
1
+ import { ATN, CharStream, DFA, Lexer } from "@browsery/antlr4";
2
2
  export default class OpraFilterLexer extends Lexer {
3
3
  static readonly T__0 = 1;
4
4
  static readonly T__1 = 2;
@@ -1,6 +1,6 @@
1
1
  // Generated from ./src/filter/antlr/OpraFilter.g4 by ANTLR 4.11.2-SNAPSHOT
2
2
  // noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols
3
- import { ATNDeserializer, DFA, Lexer, LexerATNSimulator, PredictionContextCache, Token } from "antlr4";
3
+ import { ATNDeserializer, DFA, Lexer, LexerATNSimulator, PredictionContextCache, Token } from "@browsery/antlr4";
4
4
  export default class OpraFilterLexer extends Lexer {
5
5
  constructor(input) {
6
6
  super(input);
@@ -1,4 +1,4 @@
1
- import { ParseTreeListener } from "antlr4";
1
+ import { ParseTreeListener } from "@browsery/antlr4";
2
2
  import { ArithmeticExpressionContext, ArrayExpressionContext, ArthOpContext, BooleanContext, BooleanLiteralContext, ComparisonExpressionContext, CompOpContext, DateLiteralContext, DateTimeLiteralContext, DateTimePrecisionContext, ExternalConstantContext, ExternalConstantTermContext, FunctionContext, IdentifierContext, InfinityContext, InfinityLiteralContext, InvocableContext, LiteralTermContext, LogicalExpressionContext, LogOpContext, MemberIndexContext, MemberInvocationContext, NullContext, NullLiteralContext, NumberIndexContext, NumberLiteralContext, ParamListContext, ParenthesizedExpressionContext, PluralDateTimePrecisionContext, PolarityExpressionContext, PolarOpContext, QualifiedIdentifierContext, QualifiedIdentifierTermContext, RootContext, StringLiteralContext, TermExpressionContext, TimeLiteralContext, UnitContext } from "./OpraFilterParser.js";
3
3
  /**
4
4
  * This interface defines a complete listener for a parse tree produced by
@@ -1,5 +1,5 @@
1
1
  // Generated from ./src/filter/antlr/OpraFilter.g4 by ANTLR 4.11.2-SNAPSHOT
2
- import { ParseTreeListener } from "antlr4";
2
+ import { ParseTreeListener } from "@browsery/antlr4";
3
3
  /**
4
4
  * This interface defines a complete listener for a parse tree produced by
5
5
  * `OpraFilterParser`.
@@ -1,4 +1,4 @@
1
- import { ATN, DFA, FailedPredicateException, Parser, ParserRuleContext, RuleContext, TerminalNode, TokenStream } from 'antlr4';
1
+ import { ATN, DFA, FailedPredicateException, Parser, ParserRuleContext, RuleContext, TerminalNode, TokenStream } from '@browsery/antlr4';
2
2
  import type OpraFilterListener from "./OpraFilterListener.js";
3
3
  import type OpraFilterVisitor from "./OpraFilterVisitor.js";
4
4
  export default class OpraFilterParser extends Parser {
@@ -2,12 +2,8 @@
2
2
  // Generated from ./src/filter/antlr/OpraFilter.g4 by ANTLR 4.11.2-SNAPSHOT
3
3
  // noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols,SpellCheckingInspection
4
4
  // @ts-nocheck
5
- import { ATN, ATNDeserializer, DFA, FailedPredicateException, NoViableAltException, Parser, ParserATNSimulator, ParserRuleContext, PredictionContextCache, RecognitionException, Token } from 'antlr4';
5
+ import { ATN, ATNDeserializer, DFA, FailedPredicateException, NoViableAltException, Parser, ParserATNSimulator, ParserRuleContext, PredictionContextCache, RecognitionException, Token } from '@browsery/antlr4';
6
6
  export default class OpraFilterParser extends Parser {
7
- constructor(input) {
8
- super(input);
9
- this._interp = new ParserATNSimulator(this, OpraFilterParser._ATN, OpraFilterParser.DecisionsToDFA, new PredictionContextCache());
10
- }
11
7
  get grammarFileName() {
12
8
  return "OpraFilter.g4";
13
9
  }
@@ -26,6 +22,10 @@ export default class OpraFilterParser extends Parser {
26
22
  createFailedPredicateException(predicate, message) {
27
23
  return new FailedPredicateException(this, predicate, message);
28
24
  }
25
+ constructor(input) {
26
+ super(input);
27
+ this._interp = new ParserATNSimulator(this, OpraFilterParser._ATN, OpraFilterParser.DecisionsToDFA, new PredictionContextCache());
28
+ }
29
29
  // @RuleVersion(0)
30
30
  root() {
31
31
  let localctx = new RootContext(this, this._ctx, this.state);
@@ -1,4 +1,4 @@
1
- import { ParseTreeVisitor } from 'antlr4';
1
+ import { ParseTreeVisitor } from '@browsery/antlr4';
2
2
  import { ArithmeticExpressionContext, ArrayExpressionContext, ArthOpContext, BooleanContext, BooleanLiteralContext, ComparisonExpressionContext, CompOpContext, DateLiteralContext, DateTimeLiteralContext, DateTimePrecisionContext, ExternalConstantContext, ExternalConstantTermContext, FunctionContext, IdentifierContext, InfinityContext, InfinityLiteralContext, InvocableContext, LiteralTermContext, LogicalExpressionContext, LogOpContext, MemberIndexContext, MemberInvocationContext, NullContext, NullLiteralContext, NumberIndexContext, NumberLiteralContext, ParamListContext, ParenthesizedExpressionContext, PluralDateTimePrecisionContext, PolarityExpressionContext, PolarOpContext, QualifiedIdentifierContext, QualifiedIdentifierTermContext, RootContext, StringLiteralContext, TermExpressionContext, TimeLiteralContext, UnitContext } from "./OpraFilterParser.js";
3
3
  /**
4
4
  * This interface defines a complete generic visitor for a parse tree produced
@@ -1,5 +1,5 @@
1
1
  // Generated from ./src/filter/antlr/OpraFilter.g4 by ANTLR 4.11.2-SNAPSHOT
2
- import { ParseTreeVisitor } from 'antlr4';
2
+ import { ParseTreeVisitor } from '@browsery/antlr4';
3
3
  /**
4
4
  * This interface defines a complete generic visitor for a parse tree produced
5
5
  * by `OpraFilterParser`.
@@ -1,5 +1,5 @@
1
1
  import { Expression } from '../abstract/expression.js';
2
- export declare type ArithmeticOperator = '+' | '-' | '*' | '/';
2
+ export type ArithmeticOperator = '+' | '-' | '*' | '/';
3
3
  export declare class ArithmeticExpression extends Expression {
4
4
  items: ArithmeticExpressionItem[];
5
5
  constructor();
@@ -1,6 +1,6 @@
1
1
  import { StrictOmit } from 'ts-gems';
2
2
  import { Expression } from '../abstract/expression.js';
3
- export declare type ComparisonOperator = '<=' | '<' | '>' | '>=' | '=' | '!=' | 'in' | '!in' | 'like' | '!like' | 'ilike' | '!ilike';
3
+ export type ComparisonOperator = '<=' | '<' | '>' | '>=' | '=' | '!=' | 'in' | '!in' | 'like' | '!like' | 'ilike' | '!ilike';
4
4
  export declare class ComparisonExpression extends Expression {
5
5
  op: ComparisonOperator;
6
6
  left: Expression;
@@ -1,5 +1,5 @@
1
1
  import { Expression } from '../abstract/expression.js';
2
- export declare type LogicalOperator = 'and' | 'or';
2
+ export type LogicalOperator = 'and' | 'or';
3
3
  export declare class LogicalExpression extends Expression {
4
4
  op: LogicalOperator;
5
5
  items: Expression[];
@@ -1,6 +1,6 @@
1
1
  import { ArithmeticExpression, ArrayExpression, ComparisonExpression, DateLiteral, Expression, LogicalExpression, NumberLiteral, ParenthesesExpression, QualifiedIdentifier, TimeLiteral } from './ast/index.js';
2
- declare type _EntryValue = Expression | string | number | bigint | boolean | null | Date;
3
- export declare type EntryValue = _EntryValue | _EntryValue[];
2
+ type _EntryValue = Expression | string | number | bigint | boolean | null | Date;
3
+ export type EntryValue = _EntryValue | _EntryValue[];
4
4
  export declare function $or(...items: Expression[]): LogicalExpression;
5
5
  export declare function $and(...items: Expression[]): LogicalExpression;
6
6
  export declare function $date(v: string): DateLiteral;
@@ -21,7 +21,7 @@ export declare function $notLike(left: _EntryValue, right: _EntryValue): Compari
21
21
  export declare function $ilike(left: _EntryValue, right: _EntryValue): ComparisonExpression;
22
22
  export declare function $notILike(left: _EntryValue, right: _EntryValue): ComparisonExpression;
23
23
  export declare function $paren(expression: Expression): ParenthesesExpression;
24
- declare type MathExpression = ArithmeticExpression & {
24
+ type MathExpression = ArithmeticExpression & {
25
25
  add(expression: EntryValue): MathExpression;
26
26
  sub(expression: EntryValue): MathExpression;
27
27
  mul(expression: EntryValue): MathExpression;
@@ -1,5 +1,5 @@
1
- import { RecognitionException } from 'antlr4';
2
- import { Recognizer } from 'antlr4/src/antlr4/Recognizer';
1
+ import { RecognitionException } from '@browsery/antlr4';
2
+ import { Recognizer } from '@browsery/antlr4/typings/Recognizer';
3
3
  export declare class SyntaxError extends TypeError {
4
4
  }
5
5
  export declare class ValidationError extends TypeError {
@@ -8,11 +8,13 @@ export declare class FilterParseError extends Error {
8
8
  recognizer: Recognizer<any>;
9
9
  offendingSymbol: any | undefined;
10
10
  line: number;
11
+ column: number;
11
12
  e: RecognitionException | undefined;
12
13
  constructor(message: string, args: {
13
14
  recognizer: Recognizer<any>;
14
15
  offendingSymbol: any | undefined;
15
16
  line: number;
17
+ column: number;
16
18
  e: RecognitionException | undefined;
17
19
  });
18
20
  }
@@ -1,4 +1,4 @@
1
- import type { ParseTreeVisitor as TParseTreeVisitor } from 'antlr4';
1
+ import type { ParseTreeVisitor as TParseTreeVisitor, RuleNode } from '@browsery/antlr4';
2
2
  import { ArithmeticExpressionContext, ArrayExpressionContext, BooleanLiteralContext, ComparisonExpressionContext, DateLiteralContext, DateTimeLiteralContext, ExternalConstantTermContext, IdentifierContext, LogicalExpressionContext, NumberLiteralContext, ParenthesizedExpressionContext, PolarityExpressionContext, QualifiedIdentifierTermContext, RootContext, StringLiteralContext, TimeLiteralContext } from './antlr/OpraFilterParser.js';
3
3
  import OpraFilterVisitor from './antlr/OpraFilterVisitor.js';
4
4
  import { ArithmeticExpression, ArrayExpression, BooleanLiteral, DateLiteral, LogicalExpression, NullLiteral, NumberLiteral, ParenthesesExpression, QualifiedIdentifier, StringLiteral, TimeLiteral } from './ast/index.js';
@@ -9,6 +9,7 @@ export declare class FilterTreeVisitor extends ParseTreeVisitor<any> implements
9
9
  constructor(options?: {
10
10
  timeZone?: string;
11
11
  });
12
+ visitChildren(node: RuleNode): any;
12
13
  protected defaultResult(): any;
13
14
  visitRoot(ctx: RootContext): any;
14
15
  visitIdentifier(ctx: IdentifierContext): string;