@azure-net/kit 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +58 -0
  2. package/dist/core/datasource/BaseDatasource.d.ts +19 -0
  3. package/dist/core/datasource/BaseDatasource.js +14 -0
  4. package/dist/core/datasource/index.d.ts +1 -0
  5. package/dist/core/datasource/index.js +1 -0
  6. package/dist/core/eventModifiers/EventModifiers.d.ts +6 -0
  7. package/dist/core/eventModifiers/EventModifiers.js +22 -0
  8. package/dist/core/eventModifiers/index.d.ts +1 -0
  9. package/dist/core/eventModifiers/index.js +1 -0
  10. package/dist/core/httpService/HttpService.d.ts +53 -0
  11. package/dist/core/httpService/HttpService.js +134 -0
  12. package/dist/core/httpService/Statuses.d.ts +315 -0
  13. package/dist/core/httpService/Statuses.js +316 -0
  14. package/dist/core/httpService/index.d.ts +2 -0
  15. package/dist/core/httpService/index.js +2 -0
  16. package/dist/core/provider/dependencies/AsyncHelpers.d.ts +37 -0
  17. package/dist/core/provider/dependencies/AsyncHelpers.js +57 -0
  18. package/dist/core/provider/dependencies/ErrorHandler.d.ts +20 -0
  19. package/dist/core/provider/dependencies/ErrorHandler.js +47 -0
  20. package/dist/core/request/BaseRequest.d.ts +41 -0
  21. package/dist/core/request/BaseRequest.js +72 -0
  22. package/dist/core/request/index.d.ts +1 -0
  23. package/dist/core/request/index.js +1 -0
  24. package/dist/core/request/rules/Rules.d.ts +62 -0
  25. package/dist/core/request/rules/Rules.js +288 -0
  26. package/dist/core/request/rules/index.d.ts +1 -0
  27. package/dist/core/request/rules/index.js +1 -0
  28. package/dist/core/request/rules/messages/En.d.ts +2 -0
  29. package/dist/core/request/rules/messages/En.js +40 -0
  30. package/dist/core/request/rules/messages/Ru.d.ts +2 -0
  31. package/dist/core/request/rules/messages/Ru.js +40 -0
  32. package/dist/core/request/rules/messages/WithI18n.d.ts +2 -0
  33. package/dist/core/request/rules/messages/WithI18n.js +40 -0
  34. package/dist/core/request/rules/messages/index.d.ts +3 -0
  35. package/dist/core/request/rules/messages/index.js +3 -0
  36. package/dist/core/request/rules/messages/types.d.ts +41 -0
  37. package/dist/core/request/rules/messages/types.js +1 -0
  38. package/dist/core/response/BaseResponse.d.ts +11 -0
  39. package/dist/core/response/BaseResponse.js +13 -0
  40. package/dist/core/response/index.d.ts +1 -0
  41. package/dist/core/response/index.js +1 -0
  42. package/dist/core/service/BaseService.d.ts +11 -0
  43. package/dist/core/service/BaseService.js +13 -0
  44. package/dist/core/service/index.d.ts +1 -0
  45. package/dist/core/service/index.js +1 -0
  46. package/dist/edges/index.d.ts +1 -0
  47. package/dist/edges/index.js +1 -0
  48. package/dist/edges/server/index.d.ts +1 -0
  49. package/dist/edges/server/index.js +1 -0
  50. package/dist/edges/state/index.d.ts +1 -0
  51. package/dist/edges/state/index.js +1 -0
  52. package/dist/i18n/index.d.ts +1 -0
  53. package/dist/i18n/index.js +1 -0
  54. package/dist/index.d.ts +1 -0
  55. package/dist/index.js +2 -0
  56. package/dist/tools/index.d.ts +1 -0
  57. package/dist/tools/index.js +1 -0
  58. package/package.json +88 -0
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Svelte library
2
+
3
+ Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
4
+
5
+ Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
6
+
7
+ ## Creating a project
8
+
9
+ If you're seeing this, you've probably already done this step. Congrats!
10
+
11
+ ```bash
12
+ # create a new project in the current directory
13
+ npx sv create
14
+
15
+ # create a new project in my-app
16
+ npx sv create my-app
17
+ ```
18
+
19
+ ## Developing
20
+
21
+ Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
22
+
23
+ ```bash
24
+ npm run dev
25
+
26
+ # or start the server and open the app in a new browser tab
27
+ npm run dev -- --open
28
+ ```
29
+
30
+ Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
31
+
32
+ ## Building
33
+
34
+ To build your library:
35
+
36
+ ```bash
37
+ npm run package
38
+ ```
39
+
40
+ To create a production version of your showcase app:
41
+
42
+ ```bash
43
+ npm run build
44
+ ```
45
+
46
+ You can preview the production build with `npm run preview`.
47
+
48
+ > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
49
+
50
+ ## Publishing
51
+
52
+ Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
53
+
54
+ To publish your library to [npm](https://www.npmjs.com):
55
+
56
+ ```bash
57
+ npm publish
58
+ ```
@@ -0,0 +1,19 @@
1
+ import { HttpService, HttpServiceResponse } from '../httpService/HttpService.js';
2
+ export interface IDatasource {
3
+ /**
4
+ * Executes a wrapped HTTP request and handles the response.
5
+ *
6
+ * @param callback - A function that receives the HttpService and returns a Promise of a response.
7
+ * @returns A typed HTTP response wrapped in a Promise.
8
+ */
9
+ createRequest<T>(callback: <J = T>(params: {
10
+ http: HttpService;
11
+ }) => Promise<HttpServiceResponse<J>>): Promise<HttpServiceResponse<T>>;
12
+ }
13
+ export declare class BaseDatasource implements IDatasource {
14
+ protected readonly httpClient: HttpService;
15
+ constructor(httpClient: HttpService);
16
+ createRequest<T>(callback: <J = T>(params: {
17
+ http: HttpService;
18
+ }) => Promise<HttpServiceResponse<J>>): Promise<HttpServiceResponse<T>>;
19
+ }
@@ -0,0 +1,14 @@
1
+ import { HttpService, HttpServiceError, HttpServiceResponse } from '../httpService/HttpService.js';
2
+ export class BaseDatasource {
3
+ httpClient;
4
+ constructor(httpClient) {
5
+ this.httpClient = httpClient;
6
+ }
7
+ async createRequest(callback) {
8
+ return await callback({ http: this.httpClient })
9
+ .then((response) => response)
10
+ .catch((err) => {
11
+ throw err;
12
+ });
13
+ }
14
+ }
@@ -0,0 +1 @@
1
+ export * from './BaseDatasource.js';
@@ -0,0 +1 @@
1
+ export * from './BaseDatasource.js';
@@ -0,0 +1,6 @@
1
+ export type EventHandler<E = Event> = (event: E) => void;
2
+ export declare const preventDefault: <E extends Event = Event>(fn: EventHandler<E>) => EventHandler<E>;
3
+ export declare const stopPropagation: <E extends Event = Event>(fn: EventHandler<E>) => EventHandler<E>;
4
+ export declare const stopImmediatePropagation: <E extends Event = Event>(fn: EventHandler<E>) => EventHandler<E>;
5
+ export declare const once: <E extends Event = Event>(fn: EventHandler<E>) => EventHandler<E>;
6
+ export declare const compose: <E extends Event = Event>(...wrappers: Array<(fn: EventHandler<E>) => EventHandler<E>>) => (fn: EventHandler<E>) => EventHandler<E>;
@@ -0,0 +1,22 @@
1
+ export const preventDefault = (fn) => (event) => {
2
+ event.preventDefault();
3
+ fn(event);
4
+ };
5
+ export const stopPropagation = (fn) => (event) => {
6
+ event.stopPropagation();
7
+ fn(event);
8
+ };
9
+ export const stopImmediatePropagation = (fn) => (event) => {
10
+ event.stopImmediatePropagation();
11
+ fn(event);
12
+ };
13
+ export const once = (fn) => {
14
+ let called = false;
15
+ return (event) => {
16
+ if (!called) {
17
+ called = true;
18
+ fn(event);
19
+ }
20
+ };
21
+ };
22
+ export const compose = (...wrappers) => (fn) => wrappers.reduce((acc, wrap) => wrap(acc), fn);
@@ -0,0 +1 @@
1
+ export * from './EventModifiers.js';
@@ -0,0 +1 @@
1
+ export * from './EventModifiers.js';
@@ -0,0 +1,53 @@
1
+ import { type Options } from 'ky';
2
+ import { EventBus } from 'azure-net-tools';
3
+ export interface IHttpServiceResponse<T = unknown> {
4
+ headers: Record<string, string>;
5
+ status: number;
6
+ success: boolean;
7
+ data: T;
8
+ message?: string;
9
+ }
10
+ export interface IHttpServiceError<T = unknown> extends IHttpServiceResponse<T> {
11
+ original?: Error;
12
+ }
13
+ export declare class HttpServiceResponse<T> implements IHttpServiceResponse<T> {
14
+ headers: Record<string, string>;
15
+ status: number;
16
+ success: boolean;
17
+ data: T;
18
+ message?: string;
19
+ constructor({ headers, status, success, data, message }: IHttpServiceResponse<T>);
20
+ }
21
+ export declare class HttpServiceError<T> implements IHttpServiceError<T> {
22
+ headers: Record<string, string>;
23
+ status: number;
24
+ success: boolean;
25
+ data: T;
26
+ message?: string;
27
+ original?: Error;
28
+ constructor({ headers, status, success, data, message, original }: IHttpServiceError<T>);
29
+ }
30
+ export interface IHttpServiceOptions extends Options {
31
+ responseFormat?: 'json' | 'blob' | 'text';
32
+ }
33
+ export declare const httpServiceEventBus: EventBus<"HttpServiceError">;
34
+ export declare class HttpService {
35
+ private readonly baseUrl;
36
+ private readonly instance;
37
+ private readonly requestHandler?;
38
+ private readonly errorHandler?;
39
+ constructor(opts: {
40
+ baseUrl: string;
41
+ baseOptions?: Options;
42
+ requestHandler?: (options: Options) => void | Promise<void>;
43
+ errorHandler?: (err: IHttpServiceError) => unknown;
44
+ });
45
+ private prepareOptions;
46
+ private prepareResponse;
47
+ post<T>(url: string, options?: IHttpServiceOptions): Promise<IHttpServiceResponse<T>>;
48
+ get<T>(url: string, options?: IHttpServiceOptions): Promise<IHttpServiceResponse<T>>;
49
+ patch<T>(url: string, options?: IHttpServiceOptions): Promise<IHttpServiceResponse<T>>;
50
+ delete<T>(url: string, options?: IHttpServiceOptions): Promise<IHttpServiceResponse<T>>;
51
+ put<T>(url: string, options?: IHttpServiceOptions): Promise<IHttpServiceResponse<T>>;
52
+ private handleError;
53
+ }
@@ -0,0 +1,134 @@
1
+ import ky, {} from 'ky';
2
+ import { EventBus } from 'azure-net-tools';
3
+ export class HttpServiceResponse {
4
+ headers;
5
+ status;
6
+ success;
7
+ data;
8
+ message;
9
+ constructor({ headers, status, success, data, message }) {
10
+ this.headers = headers;
11
+ this.status = status;
12
+ this.success = success;
13
+ this.data = data;
14
+ this.message = message;
15
+ }
16
+ }
17
+ export class HttpServiceError {
18
+ headers;
19
+ status;
20
+ success;
21
+ data;
22
+ message;
23
+ original;
24
+ constructor({ headers, status, success, data, message, original }) {
25
+ this.headers = headers;
26
+ this.status = status;
27
+ this.success = success;
28
+ this.data = data;
29
+ this.message = message;
30
+ this.original = original;
31
+ }
32
+ }
33
+ export const httpServiceEventBus = new EventBus({
34
+ HttpServiceError: []
35
+ });
36
+ export class HttpService {
37
+ baseUrl;
38
+ instance;
39
+ requestHandler;
40
+ errorHandler;
41
+ constructor(opts) {
42
+ this.baseUrl = opts.baseUrl;
43
+ this.instance = ky.create(opts?.baseOptions);
44
+ this.errorHandler = opts?.errorHandler ?? undefined;
45
+ this.requestHandler = opts?.requestHandler ?? undefined;
46
+ }
47
+ async prepareOptions(requestOptions) {
48
+ const options = typeof requestOptions === 'object' ? { ...requestOptions } : {};
49
+ if (this.requestHandler) {
50
+ await this.requestHandler(options);
51
+ }
52
+ return options;
53
+ }
54
+ async prepareResponse(request, format = 'json') {
55
+ return new HttpServiceResponse({
56
+ headers: request.headers instanceof Headers ? Object.fromEntries(request.headers.entries()) : {},
57
+ status: request.status,
58
+ success: request.status <= 400,
59
+ data: await request?.[format](),
60
+ message: 'Request completed'
61
+ });
62
+ }
63
+ async post(url, options) {
64
+ return await this.instance
65
+ .post(this.baseUrl + url, await this.prepareOptions(options))
66
+ .then((response) => {
67
+ return this.prepareResponse(response, options?.responseFormat);
68
+ })
69
+ .catch(async (error) => {
70
+ throw await this.handleError(error);
71
+ });
72
+ }
73
+ async get(url, options) {
74
+ return await this.instance
75
+ .get(this.baseUrl + url, await this.prepareOptions(options))
76
+ .then((response) => {
77
+ return this.prepareResponse(response, options?.responseFormat);
78
+ })
79
+ .catch(async (error) => {
80
+ throw await this.handleError(error);
81
+ });
82
+ }
83
+ async patch(url, options) {
84
+ return await this.instance
85
+ .patch(this.baseUrl + url, await this.prepareOptions(options))
86
+ .then((response) => {
87
+ return this.prepareResponse(response, options?.responseFormat);
88
+ })
89
+ .catch(async (error) => {
90
+ throw await this.handleError(error);
91
+ });
92
+ }
93
+ async delete(url, options) {
94
+ return await this.instance
95
+ .delete(this.baseUrl + url, await this.prepareOptions(options))
96
+ .then((response) => {
97
+ return this.prepareResponse(response, options?.responseFormat);
98
+ })
99
+ .catch(async (error) => {
100
+ throw await this.handleError(error);
101
+ });
102
+ }
103
+ async put(url, options) {
104
+ return await this.instance
105
+ .put(this.baseUrl + url, await this.prepareOptions(options))
106
+ .then((response) => {
107
+ return this.prepareResponse(response, options?.responseFormat);
108
+ })
109
+ .catch(async (error) => {
110
+ throw await this.handleError(error);
111
+ });
112
+ }
113
+ async handleError(err) {
114
+ let headers = {};
115
+ let response = {};
116
+ try {
117
+ headers = err?.response?.headers && err?.response?.headers instanceof Headers ? Object.fromEntries(err?.response?.headers.entries()) : {};
118
+ response = await err?.response?.json();
119
+ }
120
+ catch {
121
+ headers = {};
122
+ response = {};
123
+ }
124
+ const error = new HttpServiceError({
125
+ data: response,
126
+ status: err?.response?.status ?? 500,
127
+ headers,
128
+ success: false,
129
+ original: err
130
+ });
131
+ httpServiceEventBus.publish('HttpServiceError', error);
132
+ return this.errorHandler ? this.errorHandler(error) : error;
133
+ }
134
+ }
@@ -0,0 +1,315 @@
1
+ declare enum HttpStatusCode {
2
+ /**
3
+ * The server has received the request headers and the client should proceed to send the request body
4
+ * (in the case of a request for which a body needs to be sent; for example, a POST request).
5
+ * Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient.
6
+ * To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request
7
+ * and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates the request should not be continued.
8
+ */
9
+ CONTINUE = 100,
10
+ /**
11
+ * The requester has asked the server to switch protocols and the server has agreed to do so.
12
+ */
13
+ SWITCHING_PROTOCOLS = 101,
14
+ /**
15
+ * A WebDAV request may contain many sub-requests involving file operations, requiring a long time to complete the request.
16
+ * This code indicates that the server has received and is processing the request, but no response is available yet.
17
+ * This prevents the client from timing out and assuming the request was lost.
18
+ */
19
+ PROCESSING = 102,
20
+ /**
21
+ * Standard response for successful HTTP requests.
22
+ * The actual response will depend on the request method used.
23
+ * In a GET request, the response will contain an entity corresponding to the requested resource.
24
+ * In a POST request, the response will contain an entity describing or containing the result of the action.
25
+ */
26
+ OK = 200,
27
+ /**
28
+ * The request has been fulfilled, resulting in the creation of a new resource.
29
+ */
30
+ CREATED = 201,
31
+ /**
32
+ * The request has been accepted for processing, but the processing has not been completed.
33
+ * The request might or might not be eventually acted upon, and may be disallowed when processing occurs.
34
+ */
35
+ ACCEPTED = 202,
36
+ /**
37
+ * SINCE HTTP/1.1
38
+ * The server is a transforming proxy that received a 200 OK from its origin,
39
+ * but is returning a modified version of the origin's response.
40
+ */
41
+ NON_AUTHORITATIVE_INFORMATION = 203,
42
+ /**
43
+ * The server successfully processed the request and is not returning any content.
44
+ */
45
+ NO_CONTENT = 204,
46
+ /**
47
+ * The server successfully processed the request, but is not returning any content.
48
+ * Unlike a 204 response, this response requires that the requester reset the document view.
49
+ */
50
+ RESET_CONTENT = 205,
51
+ /**
52
+ * The server is delivering only part of the resource (byte serving) due to a range header sent by the client.
53
+ * The range header is used by HTTP clients to enable resuming of interrupted downloads,
54
+ * or split a download into multiple simultaneous streams.
55
+ */
56
+ PARTIAL_CONTENT = 206,
57
+ /**
58
+ * The message body that follows is an XML message and can contain a number of separate response codes,
59
+ * depending on how many sub-requests were made.
60
+ */
61
+ MULTI_STATUS = 207,
62
+ /**
63
+ * The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response,
64
+ * and are not being included again.
65
+ */
66
+ ALREADY_REPORTED = 208,
67
+ /**
68
+ * The server has fulfilled a request for the resource,
69
+ * and the response is a representation of the result of one or more instance-manipulations applied to the current instance.
70
+ */
71
+ IM_USED = 226,
72
+ /**
73
+ * Indicates multiple options for the resource from which the client may choose (via agent-driven content negotiation).
74
+ * For example, this code could be used to present multiple video format options,
75
+ * to list files with different filename extensions, or to suggest word-sense disambiguation.
76
+ */
77
+ MULTIPLE_CHOICES = 300,
78
+ /**
79
+ * This and all future requests should be directed to the given URI.
80
+ */
81
+ MOVED_PERMANENTLY = 301,
82
+ /**
83
+ * This is an example of industry practice contradicting the standard.
84
+ * The HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect
85
+ * (the original describing phrase was "Moved Temporarily"), but popular browsers implemented 302
86
+ * with the functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307
87
+ * to distinguish between the two behaviours. However, some Web applications and frameworks
88
+ * use the 302 status code as if it were the 303.
89
+ */
90
+ FOUND = 302,
91
+ /**
92
+ * SINCE HTTP/1.1
93
+ * The response to the request can be found under another URI using a GET method.
94
+ * When received in response to a POST (or PUT/DELETE), the client should presume that
95
+ * the server has received the data and should issue a redirect with a separate GET message.
96
+ */
97
+ SEE_OTHER = 303,
98
+ /**
99
+ * Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match.
100
+ * In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy.
101
+ */
102
+ NOT_MODIFIED = 304,
103
+ /**
104
+ * SINCE HTTP/1.1
105
+ * The requested resource is available only through a proxy, the address for which is provided in the response.
106
+ * Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code, primarily for security reasons.
107
+ */
108
+ USE_PROXY = 305,
109
+ /**
110
+ * No longer used. Originally meant "Subsequent requests should use the specified proxy."
111
+ */
112
+ SWITCH_PROXY = 306,
113
+ /**
114
+ * SINCE HTTP/1.1
115
+ * In this case, the request should be repeated with another URI; however, future requests should still use the original URI.
116
+ * In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request.
117
+ * For example, a POST request should be repeated using another POST request.
118
+ */
119
+ TEMPORARY_REDIRECT = 307,
120
+ /**
121
+ * The request and all future requests should be repeated using another URI.
122
+ * 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change.
123
+ * So, for example, submitting a form to a permanently redirected resource may continue smoothly.
124
+ */
125
+ PERMANENT_REDIRECT = 308,
126
+ /**
127
+ * The server cannot or will not process the request due to an apparent client error
128
+ * (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing).
129
+ */
130
+ BAD_REQUEST = 400,
131
+ /**
132
+ * Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet
133
+ * been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the
134
+ * requested resource. See Basic access authentication and Digest access authentication. 401 semantically means
135
+ * "unauthenticated",i.e. the user does not have the necessary credentials.
136
+ */
137
+ UNAUTHORIZED = 401,
138
+ /**
139
+ * Reserved for future use. The original intention was that this code might be used as part of some form of digital
140
+ * cash or micro payment scheme, but that has not happened, and this code is not usually used.
141
+ * Google Developers API uses this status if a particular developer has exceeded the daily limit on requests.
142
+ */
143
+ PAYMENT_REQUIRED = 402,
144
+ /**
145
+ * The request was valid, but the server is refusing action.
146
+ * The user might not have the necessary permissions for a resource.
147
+ */
148
+ FORBIDDEN = 403,
149
+ /**
150
+ * The requested resource could not be found but may be available in the future.
151
+ * Subsequent requests by the client are permissible.
152
+ */
153
+ NOT_FOUND = 404,
154
+ /**
155
+ * A request method is not supported for the requested resource;
156
+ * for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource.
157
+ */
158
+ METHOD_NOT_ALLOWED = 405,
159
+ /**
160
+ * The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.
161
+ */
162
+ NOT_ACCEPTABLE = 406,
163
+ /**
164
+ * The client must first authenticate itself with the proxy.
165
+ */
166
+ PROXY_AUTHENTICATION_REQUIRED = 407,
167
+ /**
168
+ * The server timed out waiting for the request.
169
+ * According to HTTP specifications:
170
+ * "The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time."
171
+ */
172
+ REQUEST_TIMEOUT = 408,
173
+ /**
174
+ * Indicates that the request could not be processed because of conflict in the request,
175
+ * such as an edit conflict between multiple simultaneous updates.
176
+ */
177
+ CONFLICT = 409,
178
+ /**
179
+ * Indicates that the resource requested is no longer available and will not be available again.
180
+ * This should be used when a resource has been intentionally removed and the resource should be purged.
181
+ * Upon receiving a 410 status code, the client should not request the resource in the future.
182
+ * Clients such as search engines should remove the resource from their indices.
183
+ * Most use cases do not require clients and search engines to purge the resource, and a "404 Not Found" may be used instead.
184
+ */
185
+ GONE = 410,
186
+ /**
187
+ * The request did not specify the length of its content, which is required by the requested resource.
188
+ */
189
+ LENGTH_REQUIRED = 411,
190
+ /**
191
+ * The server does not meet one of the preconditions that the requester put on the request.
192
+ */
193
+ PRECONDITION_FAILED = 412,
194
+ /**
195
+ * The request is larger than the server is willing or able to process. Previously called "Request Entity Too Large".
196
+ */
197
+ PAYLOAD_TOO_LARGE = 413,
198
+ /**
199
+ * The URI provided was too long for the server to process. Often the result of too much data being encoded as a query-string of a GET request,
200
+ * in which case it should be converted to a POST request.
201
+ * Called "Request-URI Too Long" previously.
202
+ */
203
+ URI_TOO_LONG = 414,
204
+ /**
205
+ * The request entity has a media type which the server or resource does not support.
206
+ * For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format.
207
+ */
208
+ UNSUPPORTED_MEDIA_TYPE = 415,
209
+ /**
210
+ * The client has asked for a portion of the file (byte serving), but the server cannot supply that portion.
211
+ * For example, if the client asked for a part of the file that lies beyond the end of the file.
212
+ * Called "Requested Range Not Satisfiable" previously.
213
+ */
214
+ RANGE_NOT_SATISFIABLE = 416,
215
+ /**
216
+ * The server cannot meet the requirements of the Expect request-header field.
217
+ */
218
+ EXPECTATION_FAILED = 417,
219
+ /**
220
+ * This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol,
221
+ * and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by
222
+ * teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including Google.com.
223
+ */
224
+ I_AM_A_TEAPOT = 418,
225
+ /**
226
+ * The request was directed at a server that is not able to produce a response (for example because a connection reuse).
227
+ */
228
+ MISDIRECTED_REQUEST = 421,
229
+ /**
230
+ * The request was well-formed but was unable to be followed due to semantic errors.
231
+ */
232
+ UNPROCESSABLE_ENTITY = 422,
233
+ /**
234
+ * The resource that is being accessed is locked.
235
+ */
236
+ LOCKED = 423,
237
+ /**
238
+ * The request failed due to failure of a previous request (e.g., a PROPPATCH).
239
+ */
240
+ FAILED_DEPENDENCY = 424,
241
+ /**
242
+ * The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.
243
+ */
244
+ UPGRADE_REQUIRED = 426,
245
+ /**
246
+ * The origin server requires the request to be conditional.
247
+ * Intended to prevent "the 'lost update' problem, where a client
248
+ * GETs a resource's state, modifies it, and PUTs it back to the server,
249
+ * when meanwhile a third party has modified the state on the server, leading to a conflict."
250
+ */
251
+ PRECONDITION_REQUIRED = 428,
252
+ /**
253
+ * The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.
254
+ */
255
+ TOO_MANY_REQUESTS = 429,
256
+ /**
257
+ * The server is unwilling to process the request because either an individual header field,
258
+ * or all the header fields collectively, are too large.
259
+ */
260
+ REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
261
+ /**
262
+ * A server operator has received a legal demand to deny access to a resource or to a set of resources
263
+ * that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451.
264
+ */
265
+ UNAVAILABLE_FOR_LEGAL_REASONS = 451,
266
+ /**
267
+ * A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.
268
+ */
269
+ INTERNAL_SERVER_ERROR = 500,
270
+ /**
271
+ * The server either does not recognize the request method, or it lacks the ability to fulfill the request.
272
+ * Usually this implies future availability (e.g., a new feature of a web-service API).
273
+ */
274
+ NOT_IMPLEMENTED = 501,
275
+ /**
276
+ * The server was acting as a gateway or proxy and received an invalid response from the upstream server.
277
+ */
278
+ BAD_GATEWAY = 502,
279
+ /**
280
+ * The server is currently unavailable (because it is overloaded or down for maintenance).
281
+ * Generally, this is a temporary state.
282
+ */
283
+ SERVICE_UNAVAILABLE = 503,
284
+ /**
285
+ * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
286
+ */
287
+ GATEWAY_TIMEOUT = 504,
288
+ /**
289
+ * The server does not support the HTTP protocol version used in the request
290
+ */
291
+ HTTP_VERSION_NOT_SUPPORTED = 505,
292
+ /**
293
+ * Transparent content negotiation for the request results in a circular reference.
294
+ */
295
+ VARIANT_ALSO_NEGOTIATES = 506,
296
+ /**
297
+ * The server is unable to store the representation needed to complete the request.
298
+ */
299
+ INSUFFICIENT_STORAGE = 507,
300
+ /**
301
+ * The server detected an infinite loop while processing the request.
302
+ */
303
+ LOOP_DETECTED = 508,
304
+ /**
305
+ * Further extensions to the request are required for the server to fulfill it.
306
+ */
307
+ NOT_EXTENDED = 510,
308
+ /**
309
+ * The client needs to authenticate to gain network access.
310
+ * Intended for use by intercepting proxies used to control access to the network (e.g., "captive portals" used
311
+ * to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).
312
+ */
313
+ NETWORK_AUTHENTICATION_REQUIRED = 511
314
+ }
315
+ export { HttpStatusCode };