@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,128 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// noinspection JSUnusedGlobalSymbols
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.HttpStatusCodes = void 0;
|
|
2
5
|
/**
|
|
3
6
|
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#successful_responses
|
|
4
7
|
*/
|
|
5
|
-
|
|
6
|
-
(function (
|
|
8
|
+
var HttpStatusCodes;
|
|
9
|
+
(function (HttpStatusCodes) {
|
|
7
10
|
/* *** Information responses *** */
|
|
8
11
|
/**
|
|
9
12
|
* This interim response indicates that the client should continue the request or
|
|
10
13
|
* ignore the response if the request is already finished.
|
|
11
14
|
*/
|
|
12
|
-
|
|
15
|
+
HttpStatusCodes[HttpStatusCodes["CONTINUE"] = 100] = "CONTINUE";
|
|
13
16
|
/**
|
|
14
17
|
* This code is sent in response to an Upgrade request header from the client and
|
|
15
18
|
* indicates the protocol the server is switching to.
|
|
16
19
|
*/
|
|
17
|
-
|
|
20
|
+
HttpStatusCodes[HttpStatusCodes["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
18
21
|
/**
|
|
19
22
|
* This code indicates that the server has received and is processing the request, but no response is available yet.
|
|
20
23
|
*/
|
|
21
|
-
|
|
24
|
+
HttpStatusCodes[HttpStatusCodes["PROCESSING"] = 102] = "PROCESSING";
|
|
22
25
|
/**
|
|
23
26
|
* This status code is primarily intended to be used with the Link header, letting the user agent
|
|
24
27
|
* start preloading resources while the server prepares a response.
|
|
25
28
|
*/
|
|
26
|
-
|
|
29
|
+
HttpStatusCodes[HttpStatusCodes["EARLYHINTS"] = 103] = "EARLYHINTS";
|
|
27
30
|
/* *** Successful responses *** */
|
|
28
31
|
/**
|
|
29
32
|
* The request succeeded.
|
|
30
33
|
*/
|
|
31
|
-
|
|
34
|
+
HttpStatusCodes[HttpStatusCodes["OK"] = 200] = "OK";
|
|
32
35
|
/**
|
|
33
36
|
* The request succeeded, and a new resource was created as a result.
|
|
34
37
|
* This is typically the response sent after POST requests, or some PUT requests.
|
|
35
38
|
*/
|
|
36
|
-
|
|
39
|
+
HttpStatusCodes[HttpStatusCodes["CREATED"] = 201] = "CREATED";
|
|
37
40
|
/**
|
|
38
41
|
* The request has been received but not yet acted upon. It is noncommittal,
|
|
39
42
|
* since there is no way in HTTP to later send an asynchronous response indicating
|
|
40
43
|
* the outcome of the request. It is intended for cases where another process or
|
|
41
44
|
* server handles the request, or for batch processing.
|
|
42
45
|
*/
|
|
43
|
-
|
|
46
|
+
HttpStatusCodes[HttpStatusCodes["ACCEPTED"] = 202] = "ACCEPTED";
|
|
44
47
|
/**
|
|
45
48
|
* This response code means the returned metadata is not exactly the same as is available from
|
|
46
49
|
* the origin server, but is collected from a local or a third-party copy. This is mostly used
|
|
47
50
|
* for mirrors or backups of another resource. Except for that specific case, the 200 OK
|
|
48
51
|
* response is preferred to this status.
|
|
49
52
|
*/
|
|
50
|
-
|
|
53
|
+
HttpStatusCodes[HttpStatusCodes["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
51
54
|
/**
|
|
52
55
|
* There is no content to send for this request, but the headers may be useful.
|
|
53
56
|
* The user agent may update its cached headers for this resource with the new ones.
|
|
54
57
|
*/
|
|
55
|
-
|
|
58
|
+
HttpStatusCodes[HttpStatusCodes["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
56
59
|
/**
|
|
57
60
|
* Tells the user agent to reset the document which sent this request.
|
|
58
61
|
*/
|
|
59
|
-
|
|
62
|
+
HttpStatusCodes[HttpStatusCodes["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
60
63
|
/**
|
|
61
64
|
* This response code is used when the Range header is sent from the client to request only part of a resource.
|
|
62
65
|
*/
|
|
63
|
-
|
|
66
|
+
HttpStatusCodes[HttpStatusCodes["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
64
67
|
/* *** Redirection messages *** */
|
|
65
68
|
/**
|
|
66
69
|
* The request has more than one possible response. The user agent or user should choose one of them.
|
|
67
70
|
* (There is no standardized way of choosing one of the responses, but HTML links to the possibilities
|
|
68
71
|
* are recommended so the user can pick.)
|
|
69
72
|
*/
|
|
70
|
-
|
|
73
|
+
HttpStatusCodes[HttpStatusCodes["AMBIGUOUS"] = 300] = "AMBIGUOUS";
|
|
71
74
|
/**
|
|
72
75
|
* The URL of the requested resource has been changed permanently. The new URL is given in the response.
|
|
73
76
|
*/
|
|
74
|
-
|
|
77
|
+
HttpStatusCodes[HttpStatusCodes["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
75
78
|
/**
|
|
76
79
|
* This response code means that the URI of requested resource has been changed temporarily.
|
|
77
80
|
* Further changes in the URI might be made in the future. Therefore, this same URI should
|
|
78
81
|
* be used by the client in future requests.
|
|
79
82
|
*/
|
|
80
|
-
|
|
83
|
+
HttpStatusCodes[HttpStatusCodes["FOUND"] = 302] = "FOUND";
|
|
81
84
|
/**
|
|
82
85
|
* This is used for caching purposes. It tells the client that the response has not been modified,
|
|
83
86
|
* so the client can continue to use the same cached version of the response.
|
|
84
87
|
*/
|
|
85
|
-
|
|
88
|
+
HttpStatusCodes[HttpStatusCodes["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
86
89
|
/**
|
|
87
90
|
*
|
|
88
91
|
*/
|
|
89
|
-
|
|
92
|
+
HttpStatusCodes[HttpStatusCodes["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
90
93
|
/**
|
|
91
94
|
* The server sends this response to direct the client to get the requested resource at another
|
|
92
95
|
* URI with same method that was used in the prior request. This has the same semantics as
|
|
93
96
|
* the 302 Found HTTP response code, with the exception that the user agent must not change
|
|
94
97
|
* the HTTP method used: if a POST was used in the first request, a POST must be used in the second request.
|
|
95
98
|
*/
|
|
96
|
-
|
|
99
|
+
HttpStatusCodes[HttpStatusCodes["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
97
100
|
/**
|
|
98
101
|
* This means that the resource is now permanently located at another URI, specified by the Location:
|
|
99
102
|
* HTTP Response header. This has the same semantics as the 301 Moved Permanently HTTP response code,
|
|
100
103
|
* with the exception that the user agent must not change the HTTP method used: if a POST was used
|
|
101
104
|
* in the first request, a POST must be used in the second request.
|
|
102
105
|
*/
|
|
103
|
-
|
|
106
|
+
HttpStatusCodes[HttpStatusCodes["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
104
107
|
/* *** Client error responses *** */
|
|
105
108
|
/**
|
|
106
109
|
* The server cannot or will not process the request due to something that is perceived to be a client error
|
|
107
110
|
* (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
|
|
108
111
|
*/
|
|
109
|
-
|
|
112
|
+
HttpStatusCodes[HttpStatusCodes["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
110
113
|
/**
|
|
111
114
|
* Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated".
|
|
112
115
|
* That is, the client must authenticate itself to get the requested response.
|
|
113
116
|
*/
|
|
114
|
-
|
|
117
|
+
HttpStatusCodes[HttpStatusCodes["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
115
118
|
/**
|
|
116
119
|
* This response code is reserved for future use. The initial aim for creating this code was using
|
|
117
120
|
* it for digital payment systems, however this status code is used very rarely and no standard convention exists.
|
|
118
121
|
*/
|
|
119
|
-
|
|
122
|
+
HttpStatusCodes[HttpStatusCodes["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
120
123
|
/**
|
|
121
124
|
* The client does not have access rights to the content; that is, it is unauthorized,
|
|
122
125
|
* so the server is refusing to give the requested resource. Unlike 401 Unauthorized,
|
|
123
126
|
* the client's identity is known to the server.
|
|
124
127
|
*/
|
|
125
|
-
|
|
128
|
+
HttpStatusCodes[HttpStatusCodes["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
126
129
|
/**
|
|
127
130
|
* The server can not find the requested resource. In the browser, this means the URL is not recognized.
|
|
128
131
|
* In an API, this can also mean that the endpoint is valid but the resource itself does not exist.
|
|
@@ -130,21 +133,21 @@ export var HttpStatus;
|
|
|
130
133
|
* from an unauthorized client. This response code is probably the most well known due to its
|
|
131
134
|
* frequent occurrence on the web.
|
|
132
135
|
*/
|
|
133
|
-
|
|
136
|
+
HttpStatusCodes[HttpStatusCodes["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
134
137
|
/**
|
|
135
138
|
* The request method is known by the server but is not supported by the target resource.
|
|
136
139
|
* For example, an API may not allow calling DELETE to remove a resource.
|
|
137
140
|
*/
|
|
138
|
-
|
|
141
|
+
HttpStatusCodes[HttpStatusCodes["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
139
142
|
/**
|
|
140
143
|
* This response is sent when the web server, after performing server-driven content negotiation,
|
|
141
144
|
* doesn't find any content that conforms to the criteria given by the user agent.
|
|
142
145
|
*/
|
|
143
|
-
|
|
146
|
+
HttpStatusCodes[HttpStatusCodes["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
144
147
|
/**
|
|
145
148
|
* This is similar to 401 Unauthorized but authentication is needed to be done by a proxy.
|
|
146
149
|
*/
|
|
147
|
-
|
|
150
|
+
HttpStatusCodes[HttpStatusCodes["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
148
151
|
/**
|
|
149
152
|
* This response is sent on an idle connection by some servers, even without any previous request by the client.
|
|
150
153
|
* It means that the server would like to shut down this unused connection.
|
|
@@ -152,107 +155,107 @@ export var HttpStatus;
|
|
|
152
155
|
* like Chrome, Firefox 27+, or IE9, use HTTP pre-connection mechanisms to speed up surfing.
|
|
153
156
|
* Also note that some servers merely shut down the connection without sending this message.
|
|
154
157
|
*/
|
|
155
|
-
|
|
158
|
+
HttpStatusCodes[HttpStatusCodes["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
156
159
|
/**
|
|
157
160
|
* This response is sent when a request conflicts with the current state of the server.
|
|
158
161
|
*/
|
|
159
|
-
|
|
162
|
+
HttpStatusCodes[HttpStatusCodes["CONFLICT"] = 409] = "CONFLICT";
|
|
160
163
|
/**
|
|
161
164
|
* This response is sent when the requested content has been permanently deleted from server,
|
|
162
165
|
* with no forwarding address. Clients are expected to remove their caches and links to the resource.
|
|
163
166
|
* The HTTP specification intends this status code to be used for "limited-time, promotional services".
|
|
164
167
|
* APIs should not feel compelled to indicate resources that have been deleted with this status code.
|
|
165
168
|
*/
|
|
166
|
-
|
|
169
|
+
HttpStatusCodes[HttpStatusCodes["GONE"] = 410] = "GONE";
|
|
167
170
|
/**
|
|
168
171
|
* Server rejected the request because the Content-Length header field is not defined and the server requires it.
|
|
169
172
|
*/
|
|
170
|
-
|
|
173
|
+
HttpStatusCodes[HttpStatusCodes["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
171
174
|
/**
|
|
172
175
|
* The client has indicated preconditions in its headers which the server does not meet.
|
|
173
176
|
*/
|
|
174
|
-
|
|
177
|
+
HttpStatusCodes[HttpStatusCodes["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
175
178
|
/**
|
|
176
179
|
* Request entity is larger than limits defined by server. The server might close the connection or
|
|
177
180
|
* return an Retry-After header field.
|
|
178
181
|
*/
|
|
179
|
-
|
|
182
|
+
HttpStatusCodes[HttpStatusCodes["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
180
183
|
/**
|
|
181
184
|
* The URI requested by the client is longer than the server is willing to interpret.
|
|
182
185
|
*/
|
|
183
|
-
|
|
186
|
+
HttpStatusCodes[HttpStatusCodes["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
184
187
|
/**
|
|
185
188
|
* The media format of the requested data is not supported by the server, so the server is rejecting the request.
|
|
186
189
|
*/
|
|
187
|
-
|
|
190
|
+
HttpStatusCodes[HttpStatusCodes["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
188
191
|
/**
|
|
189
192
|
* The range specified by the Range header field in the request cannot be fulfilled.
|
|
190
193
|
* It's possible that the range is outside the size of the target URI's data.
|
|
191
194
|
*/
|
|
192
|
-
|
|
195
|
+
HttpStatusCodes[HttpStatusCodes["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
|
|
193
196
|
/**
|
|
194
197
|
* This response code means the expectation indicated by the Expect request header field cannot be met by the server.
|
|
195
198
|
*/
|
|
196
|
-
|
|
199
|
+
HttpStatusCodes[HttpStatusCodes["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
197
200
|
/**
|
|
198
201
|
* The server refuses the attempt to brew coffee with a teapot.
|
|
199
202
|
*/
|
|
200
|
-
|
|
203
|
+
HttpStatusCodes[HttpStatusCodes["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
201
204
|
/**
|
|
202
205
|
* The request was directed at a server that is not able to produce a response.
|
|
203
206
|
* This can be sent by a server that is not configured to produce responses for
|
|
204
207
|
* the combination of scheme and authority that are included in the request URI.
|
|
205
208
|
*/
|
|
206
|
-
|
|
209
|
+
HttpStatusCodes[HttpStatusCodes["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
207
210
|
/**
|
|
208
211
|
* The request was well-formed but was unable to be followed due to semantic errors.
|
|
209
212
|
*/
|
|
210
|
-
|
|
213
|
+
HttpStatusCodes[HttpStatusCodes["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
211
214
|
/**
|
|
212
215
|
* The resource that is being accessed is locked.
|
|
213
216
|
*/
|
|
214
|
-
|
|
217
|
+
HttpStatusCodes[HttpStatusCodes["LOCKED"] = 423] = "LOCKED";
|
|
215
218
|
/**
|
|
216
219
|
* The request failed due to failure of a previous request.
|
|
217
220
|
*/
|
|
218
|
-
|
|
221
|
+
HttpStatusCodes[HttpStatusCodes["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
219
222
|
/**
|
|
220
223
|
* Indicates that the server is unwilling to risk processing a request that might be replayed.
|
|
221
224
|
*/
|
|
222
|
-
|
|
225
|
+
HttpStatusCodes[HttpStatusCodes["TOO_EARLY"] = 425] = "TOO_EARLY";
|
|
223
226
|
/**
|
|
224
227
|
* The server refuses to perform the request using the current protocol but might be willing
|
|
225
228
|
* to do so after the client upgrades to a different protocol. The server sends an Upgrade
|
|
226
229
|
* header in a 426 response to indicate the required protocol(s).
|
|
227
230
|
*/
|
|
228
|
-
|
|
231
|
+
HttpStatusCodes[HttpStatusCodes["UPGRADE_REQUIRED"] = 428] = "UPGRADE_REQUIRED";
|
|
229
232
|
/**
|
|
230
233
|
* The origin server requires the request to be conditional. This response is intended to prevent
|
|
231
234
|
* the 'lost update' problem, where a client GETs a resource's state, modifies it and PUTs
|
|
232
235
|
* it back to the server, when meanwhile a third party has modified the state on the server,
|
|
233
236
|
* leading to a conflict.
|
|
234
237
|
*/
|
|
235
|
-
|
|
238
|
+
HttpStatusCodes[HttpStatusCodes["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
236
239
|
/**
|
|
237
240
|
* The user has sent too many requests in a given amount of time ("rate limiting").
|
|
238
241
|
*/
|
|
239
|
-
|
|
242
|
+
HttpStatusCodes[HttpStatusCodes["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
240
243
|
/* *** Server error responses *** */
|
|
241
244
|
/**
|
|
242
245
|
* The server has encountered a situation it does not know how to handle.
|
|
243
246
|
*/
|
|
244
|
-
|
|
247
|
+
HttpStatusCodes[HttpStatusCodes["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
245
248
|
/**
|
|
246
249
|
* The request method is not supported by the server and cannot be handled.
|
|
247
250
|
* The only methods that servers are required to support (and therefore that must not return this code)
|
|
248
251
|
* are GET and HEAD.
|
|
249
252
|
*/
|
|
250
|
-
|
|
253
|
+
HttpStatusCodes[HttpStatusCodes["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
251
254
|
/**
|
|
252
255
|
* This error response means that the server, while working as a gateway to get
|
|
253
256
|
* a response needed to handle the request, got an invalid response.
|
|
254
257
|
*/
|
|
255
|
-
|
|
258
|
+
HttpStatusCodes[HttpStatusCodes["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
256
259
|
/**
|
|
257
260
|
* The server is not ready to handle the request. Common causes are a server that is down for maintenance
|
|
258
261
|
* or that is overloaded. Note that together with this response, a user-friendly page explaining
|
|
@@ -262,36 +265,36 @@ export var HttpStatus;
|
|
|
262
265
|
* headers that are sent along with this response, as these temporary condition responses
|
|
263
266
|
* should usually not be cached.
|
|
264
267
|
*/
|
|
265
|
-
|
|
268
|
+
HttpStatusCodes[HttpStatusCodes["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
266
269
|
/**
|
|
267
270
|
* This error response is given when the server is acting as a gateway and cannot get a response in time.
|
|
268
271
|
*/
|
|
269
|
-
|
|
272
|
+
HttpStatusCodes[HttpStatusCodes["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
270
273
|
/**
|
|
271
274
|
* The HTTP version used in the request is not supported by the server.
|
|
272
275
|
*/
|
|
273
|
-
|
|
276
|
+
HttpStatusCodes[HttpStatusCodes["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
274
277
|
/**
|
|
275
278
|
* The server has an internal configuration error: the chosen variant resource is configured
|
|
276
279
|
* to engage in transparent content negotiation itself, and is therefore not a proper end
|
|
277
280
|
* point in the negotiation process.
|
|
278
281
|
*/
|
|
279
|
-
|
|
282
|
+
HttpStatusCodes[HttpStatusCodes["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
|
|
280
283
|
/**
|
|
281
284
|
* The method could not be performed on the resource because the server is unable to store
|
|
282
285
|
* the representation needed to successfully complete the request.
|
|
283
286
|
*/
|
|
284
|
-
|
|
287
|
+
HttpStatusCodes[HttpStatusCodes["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
285
288
|
/**
|
|
286
289
|
* The server detected an infinite loop while processing the request.
|
|
287
290
|
*/
|
|
288
|
-
|
|
291
|
+
HttpStatusCodes[HttpStatusCodes["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
|
|
289
292
|
/**
|
|
290
293
|
* Further extensions to the request are required for the server to fulfill it.
|
|
291
294
|
*/
|
|
292
|
-
|
|
295
|
+
HttpStatusCodes[HttpStatusCodes["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
|
|
293
296
|
/**
|
|
294
297
|
* Indicates that the client needs to authenticate to gain network access.
|
|
295
298
|
*/
|
|
296
|
-
|
|
297
|
-
})(
|
|
299
|
+
HttpStatusCodes[HttpStatusCodes["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
300
|
+
})(HttpStatusCodes = exports.HttpStatusCodes || (exports.HttpStatusCodes = {}));
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a, _b;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.HttpHeaders = void 0;
|
|
5
|
+
const responsive_map_js_1 = require("../helpers/responsive-map.js");
|
|
6
|
+
const http_headers_codes_enum_js_1 = require("./enums/http-headers-codes.enum.js");
|
|
7
|
+
const knownKeys = Object.keys(http_headers_codes_enum_js_1.HttpHeaderCodes);
|
|
8
|
+
const knownKeysLower = knownKeys.map(x => x.toLowerCase());
|
|
9
|
+
const nodeInspectCustom = Symbol.for('nodejs.util.inspect.custom');
|
|
10
|
+
const kEntries = Symbol('kEntries');
|
|
11
|
+
const kSize = Symbol('kSize');
|
|
12
|
+
const kOptions = Symbol('kOptions');
|
|
13
|
+
class HttpHeaders {
|
|
14
|
+
constructor(init, options) {
|
|
15
|
+
this[_a] = new responsive_map_js_1.ResponsiveMap();
|
|
16
|
+
this[_b] = 0;
|
|
17
|
+
this[kOptions] = { ...options, onChange: undefined };
|
|
18
|
+
if (init)
|
|
19
|
+
this.appendAll(init);
|
|
20
|
+
this[kOptions].onChange = options?.onChange;
|
|
21
|
+
}
|
|
22
|
+
get size() {
|
|
23
|
+
return this[kSize];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Appends a new value to the existing set of values for a header
|
|
27
|
+
* and returns this instance
|
|
28
|
+
*/
|
|
29
|
+
append(name, value) {
|
|
30
|
+
this._append(name, value);
|
|
31
|
+
this.changed();
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Appends multiple values to the existing set of values for a header
|
|
36
|
+
* and returns this instance
|
|
37
|
+
*/
|
|
38
|
+
appendAll(headers) {
|
|
39
|
+
if (typeof headers === 'string') {
|
|
40
|
+
headers.split('\n').forEach(line => {
|
|
41
|
+
const index = line.indexOf(':');
|
|
42
|
+
if (index > 0) {
|
|
43
|
+
const name = line.slice(0, index);
|
|
44
|
+
const value = line.slice(index + 1).trim();
|
|
45
|
+
this._append(name, value);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
else if (headers.forEach && typeof headers.forEach === 'function')
|
|
50
|
+
headers.forEach((value, name) => this._append(name, value));
|
|
51
|
+
else
|
|
52
|
+
Object.keys(headers).forEach(name => this._append(name, headers[name]));
|
|
53
|
+
this.changed();
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
changed() {
|
|
57
|
+
if (this[kOptions].onChange)
|
|
58
|
+
this[kOptions].onChange();
|
|
59
|
+
}
|
|
60
|
+
clear() {
|
|
61
|
+
if (this[kEntries].size) {
|
|
62
|
+
this[kEntries].clear();
|
|
63
|
+
this[kSize] = 0;
|
|
64
|
+
this.changed();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Deletes values for a given header
|
|
69
|
+
*/
|
|
70
|
+
delete(name, value) {
|
|
71
|
+
if (this._delete(name, value))
|
|
72
|
+
this.changed();
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns an iterable of key, value pairs for every entry in the map.
|
|
77
|
+
*/
|
|
78
|
+
entries() {
|
|
79
|
+
const iter = this[kEntries].entries();
|
|
80
|
+
let i = 0;
|
|
81
|
+
let key;
|
|
82
|
+
let values;
|
|
83
|
+
return {
|
|
84
|
+
[Symbol.iterator]() {
|
|
85
|
+
return this;
|
|
86
|
+
},
|
|
87
|
+
next() {
|
|
88
|
+
if (values) {
|
|
89
|
+
if (i >= values.length) {
|
|
90
|
+
values = undefined;
|
|
91
|
+
i = 0;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (!values) {
|
|
95
|
+
const n = iter.next();
|
|
96
|
+
if (n.done)
|
|
97
|
+
return { done: true, value: undefined };
|
|
98
|
+
key = n.value[0];
|
|
99
|
+
values = n.value[1];
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
done: false,
|
|
103
|
+
value: [key, values[i++]]
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
forEach(callbackFn, thisArg) {
|
|
109
|
+
const iterator = this.entries();
|
|
110
|
+
let entry = iterator.next();
|
|
111
|
+
while (!entry.done) {
|
|
112
|
+
callbackFn.call(thisArg || this, entry.value[1], entry.value[0], this);
|
|
113
|
+
entry = iterator.next();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Retrieves value of a given header at given index
|
|
118
|
+
*/
|
|
119
|
+
get(name, index = 0) {
|
|
120
|
+
const values = this[kEntries].get(name.toLowerCase());
|
|
121
|
+
return values && values.length > index ? values[index] : null;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Retrieves an array of values for a given header.
|
|
125
|
+
*/
|
|
126
|
+
getAll(name) {
|
|
127
|
+
const entry = this[kEntries].get(name);
|
|
128
|
+
return entry ? entry.slice(0) : null;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Retrieves the names of the headers.
|
|
132
|
+
*/
|
|
133
|
+
keys() {
|
|
134
|
+
return this[kEntries].keys();
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Checks for existence of a given header.
|
|
138
|
+
*/
|
|
139
|
+
has(name) {
|
|
140
|
+
return this[kEntries].has(name);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Sets or modifies a value for a given header.
|
|
144
|
+
* If the header already exists, its value is replaced with the given value
|
|
145
|
+
*/
|
|
146
|
+
set(name, value) {
|
|
147
|
+
this._set(name, String(value));
|
|
148
|
+
this.changed();
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
sort(compareFn) {
|
|
152
|
+
this[kEntries].sort(compareFn);
|
|
153
|
+
this.changed();
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
_append(name, value) {
|
|
157
|
+
const i = knownKeysLower.indexOf(name);
|
|
158
|
+
const normalizedName = knownKeys[i] || name;
|
|
159
|
+
let values = this[kEntries].get(normalizedName);
|
|
160
|
+
if (!values) {
|
|
161
|
+
values = [];
|
|
162
|
+
this[kEntries].set(normalizedName, values);
|
|
163
|
+
}
|
|
164
|
+
const oldSize = values.length;
|
|
165
|
+
if (Array.isArray(value))
|
|
166
|
+
values.push(...value.map(x => String(x)));
|
|
167
|
+
else
|
|
168
|
+
values.push(String(value));
|
|
169
|
+
this[kSize] = -oldSize + values.length;
|
|
170
|
+
}
|
|
171
|
+
_delete(name, value) {
|
|
172
|
+
const oldValues = this[kEntries].get(name);
|
|
173
|
+
if (!oldValues)
|
|
174
|
+
return false;
|
|
175
|
+
const oldSize = this[kSize];
|
|
176
|
+
if (value) {
|
|
177
|
+
const valueToDelete = Array.isArray(value) ? value.map(x => String(x)) : [String(value)];
|
|
178
|
+
const newValues = oldValues.filter(x => !valueToDelete.includes(x));
|
|
179
|
+
this[kEntries].set(name, newValues);
|
|
180
|
+
this[kSize] += -oldValues.length + newValues.length;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
this[kEntries].delete(name);
|
|
184
|
+
this[kSize] -= oldValues.length;
|
|
185
|
+
}
|
|
186
|
+
return oldSize !== this[kSize];
|
|
187
|
+
}
|
|
188
|
+
_set(name, value) {
|
|
189
|
+
if (value == null) {
|
|
190
|
+
this._delete(name);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const oldValues = this[kEntries].get(name);
|
|
194
|
+
const i = knownKeysLower.indexOf(name);
|
|
195
|
+
const normalizedName = knownKeys[i] || name;
|
|
196
|
+
const newValues = Array.isArray(value) ? value : [value];
|
|
197
|
+
this[kEntries].set(normalizedName, newValues);
|
|
198
|
+
this[kSize] += -(oldValues?.length || 0) + newValues.length;
|
|
199
|
+
}
|
|
200
|
+
[(_a = kEntries, _b = kSize, nodeInspectCustom)]() {
|
|
201
|
+
return this[kEntries];
|
|
202
|
+
}
|
|
203
|
+
[Symbol.iterator]() {
|
|
204
|
+
return this.entries();
|
|
205
|
+
}
|
|
206
|
+
get [Symbol.toStringTag]() {
|
|
207
|
+
return 'HttpHeaders';
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
exports.HttpHeaders = HttpHeaders;
|
|
211
|
+
HttpHeaders.kEntries = kEntries;
|
|
212
|
+
HttpHeaders.kSize = kSize;
|
|
213
|
+
HttpHeaders.kOptions = kOptions;
|