@nu-art/ts-common 0.202.45 → 0.202.47
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.
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ApiException } from "./exceptions";
|
|
2
|
+
import { ApiError_GeneralErrorMessage } from './types';
|
|
3
|
+
export declare const HttpCodes: {
|
|
4
|
+
readonly _1XX: {
|
|
5
|
+
readonly CONTINUE: 100;
|
|
6
|
+
readonly SWITCHING_PROTOCOLS: 101;
|
|
7
|
+
readonly PROCESSING: 102;
|
|
8
|
+
readonly EARLY_HINTS: 103;
|
|
9
|
+
};
|
|
10
|
+
readonly _2XX: {
|
|
11
|
+
readonly OK: 200;
|
|
12
|
+
readonly CREATED: 201;
|
|
13
|
+
readonly ACCEPTED: 202;
|
|
14
|
+
readonly NON_AUTHORITATIVE_INFORMATION: 203;
|
|
15
|
+
readonly NO_CONTENT: 204;
|
|
16
|
+
readonly RESET_CONTENT: 205;
|
|
17
|
+
readonly PARTIAL_CONTENT: 206;
|
|
18
|
+
readonly MULTI_STATUS: 207;
|
|
19
|
+
readonly ALREADY_REPORTED: 208;
|
|
20
|
+
readonly IM_USED: 226;
|
|
21
|
+
};
|
|
22
|
+
readonly _3XX: {
|
|
23
|
+
readonly MULTIPLE_CHOICES: 300;
|
|
24
|
+
readonly MOVED_PERMANENTLY: 301;
|
|
25
|
+
readonly FOUND: 302;
|
|
26
|
+
readonly SEE_OTHER: 303;
|
|
27
|
+
readonly NOT_MODIFIED: 304;
|
|
28
|
+
readonly USE_PROXY: 305;
|
|
29
|
+
readonly TEMPORARY_REDIRECT: 307;
|
|
30
|
+
readonly PERMANENT_REDIRECT: 308;
|
|
31
|
+
};
|
|
32
|
+
readonly _4XX: {
|
|
33
|
+
readonly BAD_REQUEST: ((userMessage: string, debugMessage?: string, cause?: Error) => ApiException<ApiError_GeneralErrorMessage>) & {
|
|
34
|
+
code: number;
|
|
35
|
+
};
|
|
36
|
+
readonly UNAUTHORIZED: 401;
|
|
37
|
+
readonly PAYMENT_REQUIRED: 402;
|
|
38
|
+
readonly FORBIDDEN: ((userMessage: string, debugMessage?: string, cause?: Error) => ApiException<ApiError_GeneralErrorMessage>) & {
|
|
39
|
+
code: number;
|
|
40
|
+
};
|
|
41
|
+
readonly NOT_FOUND: 404;
|
|
42
|
+
readonly METHOD_NOT_ALLOWED: 405;
|
|
43
|
+
readonly NOT_ACCEPTABLE: 406;
|
|
44
|
+
readonly PROXY_AUTHENTICATION_REQUIRED: 407;
|
|
45
|
+
readonly REQUEST_TIMEOUT: 408;
|
|
46
|
+
readonly CONFLICT: 409;
|
|
47
|
+
readonly GONE: 410;
|
|
48
|
+
readonly LENGTH_REQUIRED: 411;
|
|
49
|
+
readonly PRECONDITION_FAILED: 412;
|
|
50
|
+
readonly PAYLOAD_TOO_LARGE: 413;
|
|
51
|
+
readonly URI_TOO_LONG: 414;
|
|
52
|
+
readonly UNSUPPORTED_MEDIA_TYPE: 415;
|
|
53
|
+
readonly RANGE_NOT_SATISFIABLE: 416;
|
|
54
|
+
readonly EXPECTATION_FAILED: 417;
|
|
55
|
+
readonly IM_A_TEAPOT: 418;
|
|
56
|
+
readonly MISDIRECTED_REQUEST: 421;
|
|
57
|
+
readonly UNPROCESSABLE_ENTITY: 422;
|
|
58
|
+
readonly LOCKED: 423;
|
|
59
|
+
readonly FAILED_DEPENDENCY: 424;
|
|
60
|
+
readonly TOO_EARLY: 425;
|
|
61
|
+
readonly UPGRADE_REQUIRED: 426;
|
|
62
|
+
readonly PRECONDITION_REQUIRED: 428;
|
|
63
|
+
readonly TOO_MANY_REQUESTS: 429;
|
|
64
|
+
readonly REQUEST_HEADER_FIELDS_TOO_LARGE: 431;
|
|
65
|
+
readonly UNAVAILABLE_FOR_LEGAL_REASONS: 451;
|
|
66
|
+
readonly ENTITY_ALREADY_EXISTS: 460;
|
|
67
|
+
readonly ENTITY_IS_OUTDATED: ((userMessage: string, debugMessage?: string, cause?: Error) => ApiException<ApiError_GeneralErrorMessage>) & {
|
|
68
|
+
code: number;
|
|
69
|
+
};
|
|
70
|
+
readonly OPERATION_FAILED: 490;
|
|
71
|
+
};
|
|
72
|
+
readonly _5XX: {
|
|
73
|
+
readonly INTERNAL_SERVER_ERROR: 500;
|
|
74
|
+
readonly NOT_IMPLEMENTED: ((userMessage: string, debugMessage?: string, cause?: Error) => ApiException<ApiError_GeneralErrorMessage>) & {
|
|
75
|
+
code: number;
|
|
76
|
+
};
|
|
77
|
+
readonly BAD_GATEWAY: 502;
|
|
78
|
+
readonly SERVICE_UNAVAILABLE: 503;
|
|
79
|
+
readonly GATEWAY_TIMEOUT: 504;
|
|
80
|
+
readonly HTTP_VERSION_NOT_SUPPORTED: 505;
|
|
81
|
+
readonly VARIANT_ALSO_NEGOTIATES: 506;
|
|
82
|
+
readonly INSUFFICIENT_STORAGE: 507;
|
|
83
|
+
readonly LOOP_DETECTED: 508;
|
|
84
|
+
readonly NOT_EXTENDED: 510;
|
|
85
|
+
readonly NETWORK_AUTHENTICATION_REQUIRED: 511;
|
|
86
|
+
readonly DEBUG_WHO_CALLED_THIS: 555;
|
|
87
|
+
readonly BAD_IMPLEMENTATION: 560;
|
|
88
|
+
readonly IMPLEMENTATION_MISSION: 561;
|
|
89
|
+
readonly SHOULD_NOT_HAPPENED: 598;
|
|
90
|
+
readonly MUST_NEVER_HAPPENED: 599;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpCodes = void 0;
|
|
4
|
+
const exceptions_1 = require("./exceptions");
|
|
5
|
+
function createGeneralError(code) {
|
|
6
|
+
const errorFunction = (userMessage, debugMessage = userMessage, cause) => new exceptions_1.ApiException(code, debugMessage, cause).setErrorBody({
|
|
7
|
+
type: 'error-message',
|
|
8
|
+
data: { message: userMessage }
|
|
9
|
+
});
|
|
10
|
+
return Object.assign(errorFunction, { code });
|
|
11
|
+
}
|
|
12
|
+
exports.HttpCodes = {
|
|
13
|
+
_1XX: {
|
|
14
|
+
CONTINUE: 100,
|
|
15
|
+
SWITCHING_PROTOCOLS: 101,
|
|
16
|
+
PROCESSING: 102,
|
|
17
|
+
EARLY_HINTS: 103,
|
|
18
|
+
},
|
|
19
|
+
_2XX: {
|
|
20
|
+
OK: 200,
|
|
21
|
+
CREATED: 201,
|
|
22
|
+
ACCEPTED: 202,
|
|
23
|
+
NON_AUTHORITATIVE_INFORMATION: 203,
|
|
24
|
+
NO_CONTENT: 204,
|
|
25
|
+
RESET_CONTENT: 205,
|
|
26
|
+
PARTIAL_CONTENT: 206,
|
|
27
|
+
MULTI_STATUS: 207,
|
|
28
|
+
ALREADY_REPORTED: 208,
|
|
29
|
+
IM_USED: 226,
|
|
30
|
+
},
|
|
31
|
+
_3XX: {
|
|
32
|
+
MULTIPLE_CHOICES: 300,
|
|
33
|
+
MOVED_PERMANENTLY: 301,
|
|
34
|
+
FOUND: 302,
|
|
35
|
+
SEE_OTHER: 303,
|
|
36
|
+
NOT_MODIFIED: 304,
|
|
37
|
+
USE_PROXY: 305,
|
|
38
|
+
TEMPORARY_REDIRECT: 307,
|
|
39
|
+
PERMANENT_REDIRECT: 308,
|
|
40
|
+
},
|
|
41
|
+
_4XX: {
|
|
42
|
+
BAD_REQUEST: createGeneralError(400),
|
|
43
|
+
UNAUTHORIZED: 401,
|
|
44
|
+
PAYMENT_REQUIRED: 402,
|
|
45
|
+
FORBIDDEN: createGeneralError(403),
|
|
46
|
+
NOT_FOUND: 404,
|
|
47
|
+
METHOD_NOT_ALLOWED: 405,
|
|
48
|
+
NOT_ACCEPTABLE: 406,
|
|
49
|
+
PROXY_AUTHENTICATION_REQUIRED: 407,
|
|
50
|
+
REQUEST_TIMEOUT: 408,
|
|
51
|
+
CONFLICT: 409,
|
|
52
|
+
GONE: 410,
|
|
53
|
+
LENGTH_REQUIRED: 411,
|
|
54
|
+
PRECONDITION_FAILED: 412,
|
|
55
|
+
PAYLOAD_TOO_LARGE: 413,
|
|
56
|
+
URI_TOO_LONG: 414,
|
|
57
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
58
|
+
RANGE_NOT_SATISFIABLE: 416,
|
|
59
|
+
EXPECTATION_FAILED: 417,
|
|
60
|
+
IM_A_TEAPOT: 418,
|
|
61
|
+
MISDIRECTED_REQUEST: 421,
|
|
62
|
+
UNPROCESSABLE_ENTITY: 422,
|
|
63
|
+
LOCKED: 423,
|
|
64
|
+
FAILED_DEPENDENCY: 424,
|
|
65
|
+
TOO_EARLY: 425,
|
|
66
|
+
UPGRADE_REQUIRED: 426,
|
|
67
|
+
PRECONDITION_REQUIRED: 428,
|
|
68
|
+
TOO_MANY_REQUESTS: 429,
|
|
69
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
|
|
70
|
+
UNAVAILABLE_FOR_LEGAL_REASONS: 451,
|
|
71
|
+
//custom
|
|
72
|
+
ENTITY_ALREADY_EXISTS: 460,
|
|
73
|
+
ENTITY_IS_OUTDATED: createGeneralError(461),
|
|
74
|
+
OPERATION_FAILED: 490,
|
|
75
|
+
},
|
|
76
|
+
_5XX: {
|
|
77
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
78
|
+
NOT_IMPLEMENTED: createGeneralError(501),
|
|
79
|
+
BAD_GATEWAY: 502,
|
|
80
|
+
SERVICE_UNAVAILABLE: 503,
|
|
81
|
+
GATEWAY_TIMEOUT: 504,
|
|
82
|
+
HTTP_VERSION_NOT_SUPPORTED: 505,
|
|
83
|
+
VARIANT_ALSO_NEGOTIATES: 506,
|
|
84
|
+
INSUFFICIENT_STORAGE: 507,
|
|
85
|
+
LOOP_DETECTED: 508,
|
|
86
|
+
NOT_EXTENDED: 510,
|
|
87
|
+
NETWORK_AUTHENTICATION_REQUIRED: 511,
|
|
88
|
+
//custom
|
|
89
|
+
DEBUG_WHO_CALLED_THIS: 555,
|
|
90
|
+
BAD_IMPLEMENTATION: 560,
|
|
91
|
+
IMPLEMENTATION_MISSION: 561,
|
|
92
|
+
SHOULD_NOT_HAPPENED: 598,
|
|
93
|
+
MUST_NEVER_HAPPENED: 599,
|
|
94
|
+
},
|
|
95
|
+
};
|