@nr1e/commons 0.0.3-alpha.14 → 0.0.3-alpha.15
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/package.json +7 -7
- package/LICENSE +0 -26
- package/README.md +0 -14
- package/dist/bitsnbytes/b64.d.ts +0 -39
- package/dist/bitsnbytes/b64.js +0 -130
- package/dist/bitsnbytes/b64.js.map +0 -1
- package/dist/bitsnbytes/index.d.ts +0 -1
- package/dist/bitsnbytes/index.js +0 -2
- package/dist/bitsnbytes/index.js.map +0 -1
- package/dist/errors/errors.d.ts +0 -160
- package/dist/errors/errors.js +0 -230
- package/dist/errors/errors.js.map +0 -1
- package/dist/errors/index.d.ts +0 -1
- package/dist/errors/index.js +0 -2
- package/dist/errors/index.js.map +0 -1
- package/dist/http/http-method.d.ts +0 -9
- package/dist/http/http-method.js +0 -11
- package/dist/http/http-method.js.map +0 -1
- package/dist/http/http-status-code.d.ts +0 -42
- package/dist/http/http-status-code.js +0 -44
- package/dist/http/http-status-code.js.map +0 -1
- package/dist/http/index.d.ts +0 -2
- package/dist/http/index.js +0 -3
- package/dist/http/index.js.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -6
- package/dist/index.js.map +0 -1
- package/dist/lang/index.d.ts +0 -2
- package/dist/lang/index.js +0 -3
- package/dist/lang/index.js.map +0 -1
- package/dist/lang/sleep.d.ts +0 -6
- package/dist/lang/sleep.js +0 -9
- package/dist/lang/sleep.js.map +0 -1
- package/dist/lang/type-functions.d.ts +0 -3
- package/dist/lang/type-functions.js +0 -10
- package/dist/lang/type-functions.js.map +0 -1
- package/dist/validator/index.d.ts +0 -1
- package/dist/validator/index.js +0 -2
- package/dist/validator/index.js.map +0 -1
- package/dist/validator/validators.d.ts +0 -188
- package/dist/validator/validators.js +0 -302
- package/dist/validator/validators.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nr1e/commons",
|
|
3
3
|
"description": "Provides common patterns for validation",
|
|
4
|
-
"version": "0.0.3-alpha.
|
|
4
|
+
"version": "0.0.3-alpha.15",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -32,25 +32,25 @@
|
|
|
32
32
|
},
|
|
33
33
|
"exports": {
|
|
34
34
|
"./bitsnbytes": {
|
|
35
|
-
"import": "./
|
|
35
|
+
"import": "./bitsnbytes/index.js"
|
|
36
36
|
},
|
|
37
37
|
"./errors": {
|
|
38
|
-
"import": "./
|
|
38
|
+
"import": "./errors/index.js"
|
|
39
39
|
},
|
|
40
40
|
"./http": {
|
|
41
|
-
"import": "./
|
|
41
|
+
"import": "./http/index.js"
|
|
42
42
|
},
|
|
43
43
|
"./lang": {
|
|
44
|
-
"import": "./
|
|
44
|
+
"import": "./lang/index.js"
|
|
45
45
|
},
|
|
46
46
|
"./package.json": "./package.json",
|
|
47
47
|
"./validator": {
|
|
48
|
-
"import": "./
|
|
48
|
+
"import": "./validator/index.js"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsc",
|
|
53
|
-
"postbuild": "prettier --check . && gts lint",
|
|
53
|
+
"postbuild": "prettier --check . && gts lint && cp package.json dist",
|
|
54
54
|
"watch": "tsc -w",
|
|
55
55
|
"test": "vitest run",
|
|
56
56
|
"lint": "gts lint",
|
package/LICENSE
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
Copyright 2023-2024 NR1E, Inc.
|
|
2
|
-
|
|
3
|
-
Redistribution and use in source and binary forms, with or without
|
|
4
|
-
modification, are permitted provided that the following conditions are met:
|
|
5
|
-
|
|
6
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
|
7
|
-
list of conditions and the following disclaimer.
|
|
8
|
-
|
|
9
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
-
this list of conditions and the following disclaimer in the documentation
|
|
11
|
-
and/or other materials provided with the distribution.
|
|
12
|
-
|
|
13
|
-
3. Neither the name of the copyright holder nor the names of its contributors
|
|
14
|
-
may be used to endorse or promote products derived from this software without
|
|
15
|
-
specific prior written permission.
|
|
16
|
-
|
|
17
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
18
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
21
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
23
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
24
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
25
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# Commons JS
|
|
2
|
-
|
|
3
|
-
[![NPM Version][npm-image]][npm-url]
|
|
4
|
-
[![TypeScript Style Guide][gts-image]][gts-url]
|
|
5
|
-
[![GitHub Actions][github-image]][github-url]
|
|
6
|
-
|
|
7
|
-
This project provides reusable components commonly needed in typescript projects.
|
|
8
|
-
|
|
9
|
-
[github-url]: https://github.com/nr1etech/commons-js/actions
|
|
10
|
-
[github-image]: https://github.com/nr1etech/commons-js/workflows/ci/badge.svg
|
|
11
|
-
[npm-url]: https://npmjs.org/package/@nr1e/commons-js
|
|
12
|
-
[npm-image]: https://img.shields.io/npm/v/@nre1/commons-js.svg
|
|
13
|
-
[gts-image]: https://img.shields.io/badge/code%20style-google-blueviolet.svg
|
|
14
|
-
[gts-url]: https://github.com/google/gts
|
package/dist/bitsnbytes/b64.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export declare const BASE64_CHARS: Uint8Array;
|
|
2
|
-
export declare const URL_MODIFIED_BASE64_CHARS: Uint8Array;
|
|
3
|
-
export declare const YUI_BASE64_CHARS: Uint8Array;
|
|
4
|
-
export type Base64CharSet = 'b64' | 'url' | 'yui';
|
|
5
|
-
export interface Base64Options {
|
|
6
|
-
readonly fromIndex?: number;
|
|
7
|
-
readonly toIndex?: number;
|
|
8
|
-
readonly b64chars?: Uint8Array | Base64CharSet;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Returns a base64 character set and validates one if passed in.
|
|
12
|
-
*
|
|
13
|
-
* @param b64chars a base64 character set
|
|
14
|
-
*/
|
|
15
|
-
export declare function b64Charset(b64chars?: Uint8Array | Base64CharSet): Uint8Array;
|
|
16
|
-
/**
|
|
17
|
-
* Base64 encodes a series of bytes.
|
|
18
|
-
*
|
|
19
|
-
* @param buf Bytes to encode
|
|
20
|
-
* @param opts Encoding options
|
|
21
|
-
* @return a base64 string
|
|
22
|
-
*/
|
|
23
|
-
export declare function tob64(buf: Uint8Array, opts?: Base64Options): Uint8Array;
|
|
24
|
-
/**
|
|
25
|
-
* Base64 encodes a series of bytes to a string.
|
|
26
|
-
*
|
|
27
|
-
* @param buf Bytes to encode
|
|
28
|
-
* @param opts Encoding options
|
|
29
|
-
* @return a base64 string
|
|
30
|
-
*/
|
|
31
|
-
export declare function tob64s(buf: Uint8Array, opts?: Base64Options): string;
|
|
32
|
-
/**
|
|
33
|
-
* Base64 encodes a string to a string.
|
|
34
|
-
*
|
|
35
|
-
* @param str String to encode
|
|
36
|
-
* @param opts Encoding options
|
|
37
|
-
* @return a base64 string
|
|
38
|
-
*/
|
|
39
|
-
export declare function stob64s(str: string, opts?: Base64Options): string;
|
package/dist/bitsnbytes/b64.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { IllegalArgumentError } from '../errors';
|
|
2
|
-
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
3
|
-
const encoder = new TextEncoder();
|
|
4
|
-
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
5
|
-
const decoder = new TextDecoder();
|
|
6
|
-
export const BASE64_CHARS = new Uint8Array([
|
|
7
|
-
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,
|
|
8
|
-
0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
|
|
9
|
-
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
|
|
10
|
-
0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
|
|
11
|
-
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2b, 0x2f, 0x3d,
|
|
12
|
-
]);
|
|
13
|
-
// 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
|
14
|
-
// 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
|
15
|
-
// 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
|
16
|
-
// 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
|
17
|
-
// '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '='
|
|
18
|
-
export const URL_MODIFIED_BASE64_CHARS = new Uint8Array([
|
|
19
|
-
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,
|
|
20
|
-
0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
|
|
21
|
-
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
|
|
22
|
-
0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
|
|
23
|
-
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2d, 0x5f,
|
|
24
|
-
]);
|
|
25
|
-
// 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
|
26
|
-
// 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
|
27
|
-
// 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
|
28
|
-
// 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
|
29
|
-
// '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_',
|
|
30
|
-
export const YUI_BASE64_CHARS = new Uint8Array([
|
|
31
|
-
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,
|
|
32
|
-
0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
|
|
33
|
-
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
|
|
34
|
-
0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
|
|
35
|
-
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2e, 0x5f, 0x2d,
|
|
36
|
-
]);
|
|
37
|
-
/**
|
|
38
|
-
* Returns a base64 character set and validates one if passed in.
|
|
39
|
-
*
|
|
40
|
-
* @param b64chars a base64 character set
|
|
41
|
-
*/
|
|
42
|
-
export function b64Charset(b64chars) {
|
|
43
|
-
if (b64chars === undefined || b64chars === null) {
|
|
44
|
-
return BASE64_CHARS;
|
|
45
|
-
}
|
|
46
|
-
if (b64chars instanceof Uint8Array) {
|
|
47
|
-
if (b64chars.length !== 65 && b64chars.length !== 64) {
|
|
48
|
-
throw new IllegalArgumentError('b64chars', 'Base 64 character sets must be 64 or 65 characters.');
|
|
49
|
-
}
|
|
50
|
-
return b64chars;
|
|
51
|
-
}
|
|
52
|
-
switch (b64chars) {
|
|
53
|
-
case 'b64':
|
|
54
|
-
return BASE64_CHARS;
|
|
55
|
-
case 'url':
|
|
56
|
-
return URL_MODIFIED_BASE64_CHARS;
|
|
57
|
-
case 'yui':
|
|
58
|
-
return YUI_BASE64_CHARS;
|
|
59
|
-
default:
|
|
60
|
-
throw new IllegalArgumentError('b64chars', `Invalid base64 character set '${b64chars}'`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Base64 encodes a series of bytes.
|
|
65
|
-
*
|
|
66
|
-
* @param buf Bytes to encode
|
|
67
|
-
* @param opts Encoding options
|
|
68
|
-
* @return a base64 string
|
|
69
|
-
*/
|
|
70
|
-
export function tob64(buf, opts) {
|
|
71
|
-
var _a, _b;
|
|
72
|
-
const b64chars = b64Charset(opts === null || opts === void 0 ? void 0 : opts.b64chars);
|
|
73
|
-
const toIndex = (_a = opts === null || opts === void 0 ? void 0 : opts.toIndex) !== null && _a !== void 0 ? _a : buf.length;
|
|
74
|
-
const fromIndex = (_b = opts === null || opts === void 0 ? void 0 : opts.fromIndex) !== null && _b !== void 0 ? _b : 0;
|
|
75
|
-
// every 3 bytes is 4 characters in padded base64 (6 bits per char)
|
|
76
|
-
const num = toIndex - fromIndex;
|
|
77
|
-
const numc = b64chars.length === 65
|
|
78
|
-
? ((num + 2 - ((num + 2) % 3)) / 3) * 4 // padded
|
|
79
|
-
: (num * 8) / 6 + ((num * 8) % 6 !== 0 ? 1 : 0); // not padded
|
|
80
|
-
const b64 = new Uint8Array(numc);
|
|
81
|
-
let n = 0;
|
|
82
|
-
for (let i = 0; i < toIndex; i += 3) {
|
|
83
|
-
const v = ((buf[i] & 0xff) << 16) |
|
|
84
|
-
(i + 1 < toIndex ? (buf[i + 1] & 0xff) << 8 : 0) |
|
|
85
|
-
(i + 2 < toIndex ? buf[i + 2] & 0xff : 0);
|
|
86
|
-
b64[n++] = b64chars[(v >>> 18) & 0x3f];
|
|
87
|
-
b64[n++] = b64chars[(v >>> 12) & 0x3f];
|
|
88
|
-
switch (toIndex - i // calculate bytes remaining to be processed
|
|
89
|
-
) {
|
|
90
|
-
case 1: // 0 bytes left to process
|
|
91
|
-
if (b64chars.length === 65) {
|
|
92
|
-
b64[n++] = b64chars[64];
|
|
93
|
-
b64[n++] = b64chars[64];
|
|
94
|
-
}
|
|
95
|
-
break;
|
|
96
|
-
case 2: // 1 byte left to process
|
|
97
|
-
b64[n++] = b64chars[(v >>> 6) & 0x3f];
|
|
98
|
-
if (b64chars.length === 65) {
|
|
99
|
-
b64[n++] = b64chars[64];
|
|
100
|
-
}
|
|
101
|
-
break;
|
|
102
|
-
default:
|
|
103
|
-
b64[n++] = b64chars[(v >>> 6) & 0x3f];
|
|
104
|
-
b64[n++] = b64chars[v & 0x3f];
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return b64;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Base64 encodes a series of bytes to a string.
|
|
112
|
-
*
|
|
113
|
-
* @param buf Bytes to encode
|
|
114
|
-
* @param opts Encoding options
|
|
115
|
-
* @return a base64 string
|
|
116
|
-
*/
|
|
117
|
-
export function tob64s(buf, opts) {
|
|
118
|
-
return decoder.decode(tob64(buf, opts));
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Base64 encodes a string to a string.
|
|
122
|
-
*
|
|
123
|
-
* @param str String to encode
|
|
124
|
-
* @param opts Encoding options
|
|
125
|
-
* @return a base64 string
|
|
126
|
-
*/
|
|
127
|
-
export function stob64s(str, opts) {
|
|
128
|
-
return tob64s(encoder.encode(str), opts);
|
|
129
|
-
}
|
|
130
|
-
//# sourceMappingURL=b64.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"b64.js","sourceRoot":"","sources":["../../src/bitsnbytes/b64.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,WAAW,CAAC;AAE/C,sEAAsE;AACtE,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAClC,sEAAsE;AACtE,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,MAAM,CAAC,MAAM,YAAY,GAAe,IAAI,UAAU,CAAC;IACrD,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,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AAG,IAAI,CAAC,CAAC;gBACtC,IAAI,QAAQ,CAAC,MAAM,KAAK,EAAE,EAAE;oBAC1B,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;iBACzB;gBACD,MAAM;YACR;gBACE,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;gBACtC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;gBAC9B,MAAM;SACT;KACF;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAC,GAAe,EAAE,IAAoB;IAC1D,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,IAAoB;IACvD,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './b64';
|
package/dist/bitsnbytes/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bitsnbytes/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|
package/dist/errors/errors.d.ts
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { HttpStatusCode } from '../http';
|
|
2
|
-
export { isError } from '../lang';
|
|
3
|
-
/**
|
|
4
|
-
* An extended version of Error that includes an HttpStatusCode.
|
|
5
|
-
* This can be useful in middleware error handlers to determine http status codes to return to the client.
|
|
6
|
-
*/
|
|
7
|
-
export interface HttpError extends Error {
|
|
8
|
-
/**
|
|
9
|
-
* The HTTP status code.
|
|
10
|
-
*/
|
|
11
|
-
statusCode: HttpStatusCode | number;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Checks if the given parameter is an HttpError.
|
|
15
|
-
*
|
|
16
|
-
* @param e The parameter to check
|
|
17
|
-
*/
|
|
18
|
-
export declare function isHttpError(e?: unknown): e is HttpError;
|
|
19
|
-
/**
|
|
20
|
-
* Thrown when a resource cannot be found.
|
|
21
|
-
*/
|
|
22
|
-
export declare class NotFoundError extends Error implements HttpError {
|
|
23
|
-
readonly statusCode = HttpStatusCode.NOT_FOUND;
|
|
24
|
-
/**
|
|
25
|
-
* The max-age value to set in the Cache-Control header if used in a middleware.
|
|
26
|
-
*/
|
|
27
|
-
readonly maxAge?: number;
|
|
28
|
-
constructor(message?: string, maxAge?: number);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Checks if the given parameter is a NotFoundError.
|
|
32
|
-
*
|
|
33
|
-
* @param e The parameter to check
|
|
34
|
-
*/
|
|
35
|
-
export declare function isNotFoundError(e?: unknown): e is NotFoundError;
|
|
36
|
-
/**
|
|
37
|
-
* Thrown when a request is missing authentication credentials.
|
|
38
|
-
*/
|
|
39
|
-
export declare class UnauthorizedError extends Error implements HttpError {
|
|
40
|
-
readonly statusCode = HttpStatusCode.UNAUTHORIZED;
|
|
41
|
-
constructor(message?: string);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Checks if the given parameter is a UnauthorizedError.
|
|
45
|
-
*
|
|
46
|
-
* @param e The parameter to check
|
|
47
|
-
*/
|
|
48
|
-
export declare function isUnauthorizedError(e?: unknown): e is UnauthorizedError;
|
|
49
|
-
/**
|
|
50
|
-
* Thrown when credentials are present, but the requested operations is not allowed.
|
|
51
|
-
*/
|
|
52
|
-
export declare class ForbiddenError extends Error implements HttpError {
|
|
53
|
-
readonly statusCode = HttpStatusCode.FORBIDDEN;
|
|
54
|
-
constructor(message?: string);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Checks if the given parameter is a ForbiddenError.
|
|
58
|
-
*
|
|
59
|
-
* @param e The parameter to check
|
|
60
|
-
*/
|
|
61
|
-
export declare function isForbiddenError(e?: unknown): e is ForbiddenError;
|
|
62
|
-
/**
|
|
63
|
-
* Thrown when a validation error occurs.
|
|
64
|
-
*/
|
|
65
|
-
export declare class ValidationError extends Error implements HttpError {
|
|
66
|
-
readonly statusCode = HttpStatusCode.BAD_REQUEST;
|
|
67
|
-
constructor(message?: string);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Checks if the given variable is a ValidationError.
|
|
71
|
-
*
|
|
72
|
-
* @param e The variable to check
|
|
73
|
-
*/
|
|
74
|
-
export declare function isValidationError(e?: unknown): e is ValidationError;
|
|
75
|
-
/**
|
|
76
|
-
* Thrown when a bad request is made.
|
|
77
|
-
*/
|
|
78
|
-
export declare class BadRequestError extends Error implements HttpError {
|
|
79
|
-
readonly statusCode = HttpStatusCode.BAD_REQUEST;
|
|
80
|
-
constructor(message?: string);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Checks if the given parameter is a BadRequestError.
|
|
84
|
-
*
|
|
85
|
-
* @param e The parameter to check
|
|
86
|
-
*/
|
|
87
|
-
export declare function isBadRequestError(e?: unknown): e is BadRequestError;
|
|
88
|
-
/**
|
|
89
|
-
* Throws when an internal server error occurs.
|
|
90
|
-
*/
|
|
91
|
-
export declare class InternalServerError extends Error implements HttpError {
|
|
92
|
-
readonly statusCode = HttpStatusCode.INTERNAL_SERVER_ERROR;
|
|
93
|
-
constructor(message?: string);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Checks if the given parameter is a InternalServerError.
|
|
97
|
-
*
|
|
98
|
-
* @param e The parameter to check
|
|
99
|
-
*/
|
|
100
|
-
export declare function isInternalServerError(e?: unknown): e is InternalServerError;
|
|
101
|
-
/**
|
|
102
|
-
* Thrown when a conflict occurs.
|
|
103
|
-
*/
|
|
104
|
-
export declare class ConflictError extends Error implements HttpError {
|
|
105
|
-
readonly statusCode = HttpStatusCode.CONFLICT;
|
|
106
|
-
constructor(message?: string);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Checks if the given parameter is a ConflictError.
|
|
110
|
-
*
|
|
111
|
-
* @param e The parameter to check
|
|
112
|
-
*/
|
|
113
|
-
export declare function isConflictError(e?: unknown): e is ConflictError;
|
|
114
|
-
/**
|
|
115
|
-
* Thrown when a unsupported media type is used.
|
|
116
|
-
*/
|
|
117
|
-
export declare class UnsupportedMediaTypeError extends Error implements HttpError {
|
|
118
|
-
readonly statusCode = HttpStatusCode.UNSUPPORTED_MEDIA_TYPE;
|
|
119
|
-
constructor(message?: string);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Checks if the given parameter is a UnsupportedMediaTypeError.
|
|
123
|
-
*
|
|
124
|
-
* @param e The parameter to check
|
|
125
|
-
*/
|
|
126
|
-
export declare function isUnsupportedMediaTypeError(e?: unknown): e is UnsupportedMediaTypeError;
|
|
127
|
-
/**
|
|
128
|
-
* Thrown when a requested operation is not implemented.
|
|
129
|
-
*/
|
|
130
|
-
export declare class NotImplementedError extends Error implements HttpError {
|
|
131
|
-
readonly statusCode = HttpStatusCode.NOT_IMPLEMENTED;
|
|
132
|
-
readonly expose = true;
|
|
133
|
-
constructor(message?: string);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Checks if the given parameter is a NotImplementedError.
|
|
137
|
-
*
|
|
138
|
-
* @param e The parameter to check
|
|
139
|
-
*/
|
|
140
|
-
export declare function isNotImplementedError(e?: unknown): e is NotImplementedError;
|
|
141
|
-
/**
|
|
142
|
-
* Thrown when an illegal argument is passed to a function.
|
|
143
|
-
*/
|
|
144
|
-
export declare class IllegalArgumentError extends Error {
|
|
145
|
-
readonly argName: string;
|
|
146
|
-
constructor(argName: string, message?: string);
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Checks if the given parameter is a IllegalArgumentError.
|
|
150
|
-
*
|
|
151
|
-
* @param e The parameter to check
|
|
152
|
-
*/
|
|
153
|
-
export declare function isIllegalArgumentError(e?: unknown): e is IllegalArgumentError;
|
|
154
|
-
/**
|
|
155
|
-
* Converts the given parameter to an HttpError.
|
|
156
|
-
*
|
|
157
|
-
* @param code The HTTP status code
|
|
158
|
-
* @param message The error message
|
|
159
|
-
*/
|
|
160
|
-
export declare function toError(code: number | HttpStatusCode, message?: string): Error;
|
package/dist/errors/errors.js
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { HttpStatusCode } from '../http';
|
|
2
|
-
import { isError, isObject } from '../lang';
|
|
3
|
-
export { isError } from '../lang';
|
|
4
|
-
/**
|
|
5
|
-
* Checks if the given parameter is an HttpError.
|
|
6
|
-
*
|
|
7
|
-
* @param e The parameter to check
|
|
8
|
-
*/
|
|
9
|
-
export function isHttpError(e) {
|
|
10
|
-
return isObject(e) && !!(e && e.stack && e.statusCode && e.message && e.name);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Thrown when a resource cannot be found.
|
|
14
|
-
*/
|
|
15
|
-
export class NotFoundError extends Error {
|
|
16
|
-
constructor(message, maxAge) {
|
|
17
|
-
message = message !== null && message !== void 0 ? message : 'Not found';
|
|
18
|
-
super(message);
|
|
19
|
-
this.statusCode = HttpStatusCode.NOT_FOUND;
|
|
20
|
-
this.name = 'NotFoundError';
|
|
21
|
-
this.maxAge = maxAge;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Checks if the given parameter is a NotFoundError.
|
|
26
|
-
*
|
|
27
|
-
* @param e The parameter to check
|
|
28
|
-
*/
|
|
29
|
-
export function isNotFoundError(e) {
|
|
30
|
-
return isHttpError(e) && e.name === 'NotFoundError';
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Thrown when a request is missing authentication credentials.
|
|
34
|
-
*/
|
|
35
|
-
export class UnauthorizedError extends Error {
|
|
36
|
-
constructor(message) {
|
|
37
|
-
message = message !== null && message !== void 0 ? message : 'Unauthorized';
|
|
38
|
-
super(message);
|
|
39
|
-
this.statusCode = HttpStatusCode.UNAUTHORIZED;
|
|
40
|
-
this.name = 'UnauthorizedError';
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Checks if the given parameter is a UnauthorizedError.
|
|
45
|
-
*
|
|
46
|
-
* @param e The parameter to check
|
|
47
|
-
*/
|
|
48
|
-
export function isUnauthorizedError(e) {
|
|
49
|
-
return isHttpError(e) && e.name === 'UnauthorizedError';
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Thrown when credentials are present, but the requested operations is not allowed.
|
|
53
|
-
*/
|
|
54
|
-
export class ForbiddenError extends Error {
|
|
55
|
-
constructor(message) {
|
|
56
|
-
message = message !== null && message !== void 0 ? message : 'Forbidden';
|
|
57
|
-
super(message);
|
|
58
|
-
this.statusCode = HttpStatusCode.FORBIDDEN;
|
|
59
|
-
this.name = 'ForbiddenError';
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Checks if the given parameter is a ForbiddenError.
|
|
64
|
-
*
|
|
65
|
-
* @param e The parameter to check
|
|
66
|
-
*/
|
|
67
|
-
export function isForbiddenError(e) {
|
|
68
|
-
return isHttpError(e) && e.name === 'ForbiddenError';
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Thrown when a validation error occurs.
|
|
72
|
-
*/
|
|
73
|
-
export class ValidationError extends Error {
|
|
74
|
-
constructor(message) {
|
|
75
|
-
message = message !== null && message !== void 0 ? message : 'Validation error';
|
|
76
|
-
super(message);
|
|
77
|
-
this.statusCode = HttpStatusCode.BAD_REQUEST;
|
|
78
|
-
this.name = 'ValidationError';
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Checks if the given variable is a ValidationError.
|
|
83
|
-
*
|
|
84
|
-
* @param e The variable to check
|
|
85
|
-
*/
|
|
86
|
-
export function isValidationError(e) {
|
|
87
|
-
return isHttpError(e) && e.name === 'ValidationError';
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Thrown when a bad request is made.
|
|
91
|
-
*/
|
|
92
|
-
export class BadRequestError extends Error {
|
|
93
|
-
constructor(message) {
|
|
94
|
-
message = message !== null && message !== void 0 ? message : 'Bad request';
|
|
95
|
-
super(message !== null && message !== void 0 ? message : 'Bad request');
|
|
96
|
-
this.statusCode = HttpStatusCode.BAD_REQUEST;
|
|
97
|
-
this.name = 'BadRequestError';
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Checks if the given parameter is a BadRequestError.
|
|
102
|
-
*
|
|
103
|
-
* @param e The parameter to check
|
|
104
|
-
*/
|
|
105
|
-
export function isBadRequestError(e) {
|
|
106
|
-
return isHttpError(e) && e.name === 'BadRequestError';
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Throws when an internal server error occurs.
|
|
110
|
-
*/
|
|
111
|
-
export class InternalServerError extends Error {
|
|
112
|
-
constructor(message) {
|
|
113
|
-
message = message !== null && message !== void 0 ? message : 'Internal server error';
|
|
114
|
-
super(message);
|
|
115
|
-
this.statusCode = HttpStatusCode.INTERNAL_SERVER_ERROR;
|
|
116
|
-
this.name = 'InternalServerError';
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Checks if the given parameter is a InternalServerError.
|
|
121
|
-
*
|
|
122
|
-
* @param e The parameter to check
|
|
123
|
-
*/
|
|
124
|
-
export function isInternalServerError(e) {
|
|
125
|
-
return isHttpError(e) && e.name === 'InternalServerError';
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Thrown when a conflict occurs.
|
|
129
|
-
*/
|
|
130
|
-
export class ConflictError extends Error {
|
|
131
|
-
constructor(message) {
|
|
132
|
-
message = message !== null && message !== void 0 ? message : 'Conflict';
|
|
133
|
-
super(message);
|
|
134
|
-
this.statusCode = HttpStatusCode.CONFLICT;
|
|
135
|
-
this.name = 'ConflictError';
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Checks if the given parameter is a ConflictError.
|
|
140
|
-
*
|
|
141
|
-
* @param e The parameter to check
|
|
142
|
-
*/
|
|
143
|
-
export function isConflictError(e) {
|
|
144
|
-
return isHttpError(e) && e.name === 'ConflictError';
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Thrown when a unsupported media type is used.
|
|
148
|
-
*/
|
|
149
|
-
export class UnsupportedMediaTypeError extends Error {
|
|
150
|
-
constructor(message) {
|
|
151
|
-
message = message !== null && message !== void 0 ? message : 'Unsupported media type';
|
|
152
|
-
super(message);
|
|
153
|
-
this.statusCode = HttpStatusCode.UNSUPPORTED_MEDIA_TYPE;
|
|
154
|
-
this.name = 'UnsupportedMediaTypeError';
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Checks if the given parameter is a UnsupportedMediaTypeError.
|
|
159
|
-
*
|
|
160
|
-
* @param e The parameter to check
|
|
161
|
-
*/
|
|
162
|
-
export function isUnsupportedMediaTypeError(e) {
|
|
163
|
-
return isHttpError(e) && e.name === 'UnsupportedMediaTypeError';
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Thrown when a requested operation is not implemented.
|
|
167
|
-
*/
|
|
168
|
-
export class NotImplementedError extends Error {
|
|
169
|
-
constructor(message) {
|
|
170
|
-
message = message !== null && message !== void 0 ? message : 'Not implemented';
|
|
171
|
-
super(message);
|
|
172
|
-
this.statusCode = HttpStatusCode.NOT_IMPLEMENTED;
|
|
173
|
-
this.expose = true;
|
|
174
|
-
this.name = 'NotImplementedError';
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Checks if the given parameter is a NotImplementedError.
|
|
179
|
-
*
|
|
180
|
-
* @param e The parameter to check
|
|
181
|
-
*/
|
|
182
|
-
export function isNotImplementedError(e) {
|
|
183
|
-
return isHttpError(e) && e.name === 'NotImplementedError';
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Thrown when an illegal argument is passed to a function.
|
|
187
|
-
*/
|
|
188
|
-
export class IllegalArgumentError extends Error {
|
|
189
|
-
constructor(argName, message) {
|
|
190
|
-
message = message !== null && message !== void 0 ? message : `Illegal argument ${argName}`;
|
|
191
|
-
super(message);
|
|
192
|
-
this.argName = argName;
|
|
193
|
-
this.name = 'IllegalArgumentError';
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Checks if the given parameter is a IllegalArgumentError.
|
|
198
|
-
*
|
|
199
|
-
* @param e The parameter to check
|
|
200
|
-
*/
|
|
201
|
-
export function isIllegalArgumentError(e) {
|
|
202
|
-
return isError(e) && e.name === 'IllegalArgumentError';
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Converts the given parameter to an HttpError.
|
|
206
|
-
*
|
|
207
|
-
* @param code The HTTP status code
|
|
208
|
-
* @param message The error message
|
|
209
|
-
*/
|
|
210
|
-
export function toError(code, message) {
|
|
211
|
-
switch (code) {
|
|
212
|
-
case HttpStatusCode.NOT_FOUND:
|
|
213
|
-
return new NotFoundError(message);
|
|
214
|
-
case HttpStatusCode.FORBIDDEN:
|
|
215
|
-
return new ForbiddenError(message);
|
|
216
|
-
case HttpStatusCode.BAD_REQUEST:
|
|
217
|
-
return new BadRequestError(message);
|
|
218
|
-
case HttpStatusCode.INTERNAL_SERVER_ERROR:
|
|
219
|
-
return new InternalServerError(message);
|
|
220
|
-
case HttpStatusCode.CONFLICT:
|
|
221
|
-
return new ConflictError(message);
|
|
222
|
-
case HttpStatusCode.UNSUPPORTED_MEDIA_TYPE:
|
|
223
|
-
return new UnsupportedMediaTypeError(message);
|
|
224
|
-
case HttpStatusCode.NOT_IMPLEMENTED:
|
|
225
|
-
return new NotImplementedError(message);
|
|
226
|
-
default:
|
|
227
|
-
return new Error(message);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AACvC,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAahC;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,CAAW;IACrC,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AAChF,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAMtC,YAAY,OAAgB,EAAE,MAAe;QAC3C,OAAO,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,WAAW,CAAC;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAPR,eAAU,GAAG,cAAc,CAAC,SAAS,CAAC;QAQ7C,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,CAAW;IACzC,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,eAAe,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAE1C,YAAY,OAAgB;QAC1B,OAAO,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,cAAc,CAAC;QACpC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,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