@twin.org/core 0.0.1-next.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.
- package/LICENSE +201 -0
- package/README.md +29 -0
- package/dist/cjs/index.cjs +4221 -0
- package/dist/esm/index.mjs +4184 -0
- package/dist/types/encoding/base32.d.ts +18 -0
- package/dist/types/encoding/base64.d.ts +24 -0
- package/dist/types/encoding/base64Url.d.ts +18 -0
- package/dist/types/errors/alreadyExistsError.d.ts +18 -0
- package/dist/types/errors/baseError.d.ts +103 -0
- package/dist/types/errors/conflictError.d.ts +19 -0
- package/dist/types/errors/generalError.d.ts +20 -0
- package/dist/types/errors/guardError.d.ts +19 -0
- package/dist/types/errors/notFoundError.d.ts +18 -0
- package/dist/types/errors/notImplementedError.d.ts +16 -0
- package/dist/types/errors/notSupportedError.d.ts +17 -0
- package/dist/types/errors/unauthorizedError.d.ts +17 -0
- package/dist/types/errors/unprocessableError.d.ts +20 -0
- package/dist/types/errors/validationError.d.ts +18 -0
- package/dist/types/factories/componentFactory.d.ts +6 -0
- package/dist/types/factories/factory.d.ts +67 -0
- package/dist/types/helpers/arrayHelper.d.ts +12 -0
- package/dist/types/helpers/errorHelper.d.ts +24 -0
- package/dist/types/helpers/filenameHelper.d.ts +11 -0
- package/dist/types/helpers/hexHelper.d.ts +30 -0
- package/dist/types/helpers/jsonHelper.d.ts +29 -0
- package/dist/types/helpers/objectHelper.d.ts +74 -0
- package/dist/types/helpers/randomHelper.d.ts +11 -0
- package/dist/types/helpers/stringHelper.d.ts +90 -0
- package/dist/types/index.d.ts +46 -0
- package/dist/types/models/IComponent.d.ts +29 -0
- package/dist/types/models/IError.d.ts +31 -0
- package/dist/types/models/IKeyValue.d.ts +13 -0
- package/dist/types/models/ILabelledValue.d.ts +13 -0
- package/dist/types/models/ILocale.d.ts +13 -0
- package/dist/types/models/ILocaleDictionary.d.ts +6 -0
- package/dist/types/models/ILocalesIndex.d.ts +10 -0
- package/dist/types/models/IPatchOperation.d.ts +21 -0
- package/dist/types/models/IUrlParts.d.ts +29 -0
- package/dist/types/models/IValidationFailure.d.ts +23 -0
- package/dist/types/models/compressionType.d.ts +17 -0
- package/dist/types/types/bitString.d.ts +41 -0
- package/dist/types/types/url.d.ts +56 -0
- package/dist/types/types/urn.d.ts +93 -0
- package/dist/types/utils/asyncCache.d.ts +33 -0
- package/dist/types/utils/coerce.d.ts +61 -0
- package/dist/types/utils/compression.d.ts +20 -0
- package/dist/types/utils/converter.d.ts +85 -0
- package/dist/types/utils/guards.d.ts +190 -0
- package/dist/types/utils/i18n.d.ts +81 -0
- package/dist/types/utils/is.d.ts +205 -0
- package/dist/types/utils/validation.d.ts +245 -0
- package/docs/changelog.md +5 -0
- package/docs/examples.md +1 -0
- package/docs/reference/classes/AlreadyExistsError.md +375 -0
- package/docs/reference/classes/ArrayHelper.md +37 -0
- package/docs/reference/classes/AsyncCache.md +117 -0
- package/docs/reference/classes/Base32.md +57 -0
- package/docs/reference/classes/Base64.md +74 -0
- package/docs/reference/classes/Base64Url.md +54 -0
- package/docs/reference/classes/BaseError.md +344 -0
- package/docs/reference/classes/BitString.md +123 -0
- package/docs/reference/classes/Coerce.md +209 -0
- package/docs/reference/classes/Compression.md +61 -0
- package/docs/reference/classes/ConflictError.md +379 -0
- package/docs/reference/classes/Converter.md +285 -0
- package/docs/reference/classes/ErrorHelper.md +73 -0
- package/docs/reference/classes/Factory.md +221 -0
- package/docs/reference/classes/FilenameHelper.md +33 -0
- package/docs/reference/classes/GeneralError.md +375 -0
- package/docs/reference/classes/GuardError.md +379 -0
- package/docs/reference/classes/Guards.md +711 -0
- package/docs/reference/classes/HexHelper.md +97 -0
- package/docs/reference/classes/I18n.md +237 -0
- package/docs/reference/classes/Is.md +693 -0
- package/docs/reference/classes/JsonHelper.md +92 -0
- package/docs/reference/classes/NotFoundError.md +375 -0
- package/docs/reference/classes/NotImplementedError.md +367 -0
- package/docs/reference/classes/NotSupportedError.md +371 -0
- package/docs/reference/classes/ObjectHelper.md +287 -0
- package/docs/reference/classes/RandomHelper.md +33 -0
- package/docs/reference/classes/StringHelper.md +270 -0
- package/docs/reference/classes/UnauthorizedError.md +371 -0
- package/docs/reference/classes/UnprocessableError.md +375 -0
- package/docs/reference/classes/Url.md +167 -0
- package/docs/reference/classes/Urn.md +295 -0
- package/docs/reference/classes/Validation.md +821 -0
- package/docs/reference/classes/ValidationError.md +371 -0
- package/docs/reference/index.md +60 -0
- package/docs/reference/interfaces/IComponent.md +79 -0
- package/docs/reference/interfaces/IError.md +55 -0
- package/docs/reference/interfaces/IKeyValue.md +23 -0
- package/docs/reference/interfaces/ILabelledValue.md +23 -0
- package/docs/reference/interfaces/ILocale.md +19 -0
- package/docs/reference/interfaces/ILocaleDictionary.md +7 -0
- package/docs/reference/interfaces/ILocalesIndex.md +11 -0
- package/docs/reference/interfaces/IPatchOperation.md +35 -0
- package/docs/reference/interfaces/IUrlParts.md +51 -0
- package/docs/reference/interfaces/IValidationFailure.md +39 -0
- package/docs/reference/type-aliases/CompressionType.md +5 -0
- package/docs/reference/variables/ComponentFactory.md +5 -0
- package/docs/reference/variables/CompressionType.md +19 -0
- package/locales/en.json +98 -0
- package/package.json +65 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert arrays to and from different formats.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Converter {
|
|
5
|
+
/**
|
|
6
|
+
* Encode a raw array to UTF8 string.
|
|
7
|
+
* @param array The bytes to encode.
|
|
8
|
+
* @param startIndex The index to start in the bytes.
|
|
9
|
+
* @param length The length of bytes to read.
|
|
10
|
+
* @returns The array formatted as UTF8.
|
|
11
|
+
*/
|
|
12
|
+
static bytesToUtf8(array: ArrayLike<number>, startIndex?: number, length?: number | undefined): string;
|
|
13
|
+
/**
|
|
14
|
+
* Convert a UTF8 string to raw array.
|
|
15
|
+
* @param utf8 The text to decode.
|
|
16
|
+
* @returns The array.
|
|
17
|
+
*/
|
|
18
|
+
static utf8ToBytes(utf8: string): Uint8Array;
|
|
19
|
+
/**
|
|
20
|
+
* Encode a raw array to hex string.
|
|
21
|
+
* @param array The bytes to encode.
|
|
22
|
+
* @param includePrefix Include the 0x prefix on the returned hex.
|
|
23
|
+
* @param startIndex The index to start in the bytes.
|
|
24
|
+
* @param length The length of bytes to read.
|
|
25
|
+
* @param reverse Reverse the combine direction.
|
|
26
|
+
* @returns The array formatted as hex.
|
|
27
|
+
*/
|
|
28
|
+
static bytesToHex(array: ArrayLike<number>, includePrefix?: boolean, startIndex?: number, length?: number | undefined, reverse?: boolean): string;
|
|
29
|
+
/**
|
|
30
|
+
* Decode a hex string to raw array.
|
|
31
|
+
* @param hex The hex to decode.
|
|
32
|
+
* @param reverse Store the characters in reverse.
|
|
33
|
+
* @returns The array.
|
|
34
|
+
*/
|
|
35
|
+
static hexToBytes(hex: string, reverse?: boolean): Uint8Array;
|
|
36
|
+
/**
|
|
37
|
+
* Convert the UTF8 to hex.
|
|
38
|
+
* @param utf8 The text to convert.
|
|
39
|
+
* @param includePrefix Include the 0x prefix on the returned hex.
|
|
40
|
+
* @returns The hex version of the bytes.
|
|
41
|
+
*/
|
|
42
|
+
static utf8ToHex(utf8: string, includePrefix?: boolean): string;
|
|
43
|
+
/**
|
|
44
|
+
* Convert the hex text to text.
|
|
45
|
+
* @param hex The hex to convert.
|
|
46
|
+
* @returns The UTF8 version of the bytes.
|
|
47
|
+
*/
|
|
48
|
+
static hexToUtf8(hex: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Convert bytes to binary string.
|
|
51
|
+
* @param bytes The bytes to convert.
|
|
52
|
+
* @returns A binary string of the bytes.
|
|
53
|
+
*/
|
|
54
|
+
static bytesToBinary(bytes: Uint8Array): string;
|
|
55
|
+
/**
|
|
56
|
+
* Convert a binary string to bytes.
|
|
57
|
+
* @param binary The binary string.
|
|
58
|
+
* @returns The bytes.
|
|
59
|
+
*/
|
|
60
|
+
static binaryToBytes(binary: string): Uint8Array;
|
|
61
|
+
/**
|
|
62
|
+
* Convert bytes to base64 string.
|
|
63
|
+
* @param bytes The bytes to convert.
|
|
64
|
+
* @returns A base64 string of the bytes.
|
|
65
|
+
*/
|
|
66
|
+
static bytesToBase64(bytes: Uint8Array): string;
|
|
67
|
+
/**
|
|
68
|
+
* Convert a base64 string to bytes.
|
|
69
|
+
* @param base64 The base64 string.
|
|
70
|
+
* @returns The bytes.
|
|
71
|
+
*/
|
|
72
|
+
static base64ToBytes(base64: string): Uint8Array;
|
|
73
|
+
/**
|
|
74
|
+
* Convert bytes to base64 url string.
|
|
75
|
+
* @param bytes The bytes to convert.
|
|
76
|
+
* @returns A base64 url string of the bytes.
|
|
77
|
+
*/
|
|
78
|
+
static bytesToBase64Url(bytes: Uint8Array): string;
|
|
79
|
+
/**
|
|
80
|
+
* Convert a base64 url string to bytes.
|
|
81
|
+
* @param base64Url The base64 url string.
|
|
82
|
+
* @returns The bytes.
|
|
83
|
+
*/
|
|
84
|
+
static base64UrlToBytes(base64Url: string): Uint8Array;
|
|
85
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class to handle guard operations for parameters.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Guards {
|
|
5
|
+
/**
|
|
6
|
+
* Is the property defined.
|
|
7
|
+
* @param source The source of the error.
|
|
8
|
+
* @param property The name of the property.
|
|
9
|
+
* @param value The value to test.
|
|
10
|
+
* @throws GuardError If the value does not match the assertion.
|
|
11
|
+
*/
|
|
12
|
+
static defined(source: string, property: string, value: unknown): asserts value;
|
|
13
|
+
/**
|
|
14
|
+
* Is the property a string.
|
|
15
|
+
* @param source The source of the error.
|
|
16
|
+
* @param property The name of the property.
|
|
17
|
+
* @param value The value to test.
|
|
18
|
+
* @throws GuardError If the value does not match the assertion.
|
|
19
|
+
*/
|
|
20
|
+
static string(source: string, property: string, value: unknown): asserts value is string;
|
|
21
|
+
/**
|
|
22
|
+
* Is the property a string with a value.
|
|
23
|
+
* @param source The source of the error.
|
|
24
|
+
* @param property The name of the property.
|
|
25
|
+
* @param value The value to test.
|
|
26
|
+
* @throws GuardError If the value does not match the assertion.
|
|
27
|
+
*/
|
|
28
|
+
static stringValue(source: string, property: string, value: unknown): asserts value is string;
|
|
29
|
+
/**
|
|
30
|
+
* Is the property a base64 string.
|
|
31
|
+
* @param source The source of the error.
|
|
32
|
+
* @param property The name of the property.
|
|
33
|
+
* @param value The value to test.
|
|
34
|
+
* @throws GuardError If the value does not match the assertion.
|
|
35
|
+
*/
|
|
36
|
+
static stringBase64(source: string, property: string, value: unknown): asserts value is string;
|
|
37
|
+
/**
|
|
38
|
+
* Is the property a base64 url string.
|
|
39
|
+
* @param source The source of the error.
|
|
40
|
+
* @param property The name of the property.
|
|
41
|
+
* @param value The value to test.
|
|
42
|
+
* @throws GuardError If the value does not match the assertion.
|
|
43
|
+
*/
|
|
44
|
+
static stringBase64Url(source: string, property: string, value: unknown): asserts value is string;
|
|
45
|
+
/**
|
|
46
|
+
* Is the property a string with a hex value.
|
|
47
|
+
* @param source The source of the error.
|
|
48
|
+
* @param property The name of the property.
|
|
49
|
+
* @param value The value to test.
|
|
50
|
+
* @param allowPrefix Allow the hex to have the 0x prefix.
|
|
51
|
+
* @throws GuardError If the value does not match the assertion.
|
|
52
|
+
*/
|
|
53
|
+
static stringHex(source: string, property: string, value: unknown, allowPrefix?: boolean): asserts value is string;
|
|
54
|
+
/**
|
|
55
|
+
* Is the property a string with a hex value with fixed length.
|
|
56
|
+
* @param source The source of the error.
|
|
57
|
+
* @param property The name of the property.
|
|
58
|
+
* @param value The value to test.
|
|
59
|
+
* @param length The length of the string to match.
|
|
60
|
+
* @param allowPrefix Allow the hex to have the 0x prefix.
|
|
61
|
+
* @throws GuardError If the value does not match the assertion.
|
|
62
|
+
*/
|
|
63
|
+
static stringHexLength(source: string, property: string, value: unknown, length: number, allowPrefix?: boolean): asserts value is string;
|
|
64
|
+
/**
|
|
65
|
+
* Is the property a number.
|
|
66
|
+
* @param source The source of the error.
|
|
67
|
+
* @param property The name of the property.
|
|
68
|
+
* @param value The value to test.
|
|
69
|
+
* @throws GuardError If the value does not match the assertion.
|
|
70
|
+
*/
|
|
71
|
+
static number(source: string, property: string, value: unknown): asserts value is number;
|
|
72
|
+
/**
|
|
73
|
+
* Is the property an integer.
|
|
74
|
+
* @param source The source of the error.
|
|
75
|
+
* @param property The name of the property.
|
|
76
|
+
* @param value The value to test.
|
|
77
|
+
* @throws GuardError If the value does not match the assertion.
|
|
78
|
+
*/
|
|
79
|
+
static integer(source: string, property: string, value: unknown): asserts value is number;
|
|
80
|
+
/**
|
|
81
|
+
* Is the property a bigint.
|
|
82
|
+
* @param source The source of the error.
|
|
83
|
+
* @param property The name of the property.
|
|
84
|
+
* @param value The value to test.
|
|
85
|
+
* @throws GuardError If the value does not match the assertion.
|
|
86
|
+
*/
|
|
87
|
+
static bigint(source: string, property: string, value: unknown): asserts value is bigint;
|
|
88
|
+
/**
|
|
89
|
+
* Is the property a boolean.
|
|
90
|
+
* @param source The source of the error.
|
|
91
|
+
* @param property The name of the property.
|
|
92
|
+
* @param value The value to test.
|
|
93
|
+
* @throws GuardError If the value does not match the assertion.
|
|
94
|
+
*/
|
|
95
|
+
static boolean(source: string, property: string, value: unknown): asserts value is boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Is the property a date.
|
|
98
|
+
* @param source The source of the error.
|
|
99
|
+
* @param property The name of the property.
|
|
100
|
+
* @param value The value to test.
|
|
101
|
+
* @throws GuardError If the value does not match the assertion.
|
|
102
|
+
*/
|
|
103
|
+
static date(source: string, property: string, value: unknown): asserts value is Date;
|
|
104
|
+
/**
|
|
105
|
+
* Is the property a timestamp in milliseconds.
|
|
106
|
+
* @param source The source of the error.
|
|
107
|
+
* @param property The name of the property.
|
|
108
|
+
* @param value The value to test.
|
|
109
|
+
* @throws GuardError If the value does not match the assertion.
|
|
110
|
+
*/
|
|
111
|
+
static timestampMilliseconds(source: string, property: string, value: unknown): asserts value is number;
|
|
112
|
+
/**
|
|
113
|
+
* Is the property a timestamp in seconds.
|
|
114
|
+
* @param source The source of the error.
|
|
115
|
+
* @param property The name of the property.
|
|
116
|
+
* @param value The value to test.
|
|
117
|
+
* @throws GuardError If the value does not match the assertion.
|
|
118
|
+
*/
|
|
119
|
+
static timestampSeconds(source: string, property: string, value: unknown): asserts value is number;
|
|
120
|
+
/**
|
|
121
|
+
* Is the property an object.
|
|
122
|
+
* @param source The source of the error.
|
|
123
|
+
* @param property The name of the property.
|
|
124
|
+
* @param value The value to test.
|
|
125
|
+
* @throws GuardError If the value does not match the assertion.
|
|
126
|
+
*/
|
|
127
|
+
static object<T = {
|
|
128
|
+
[id: string]: unknown;
|
|
129
|
+
}>(source: string, property: string, value: unknown): asserts value is T;
|
|
130
|
+
/**
|
|
131
|
+
* Is the property is an object with at least one property.
|
|
132
|
+
* @param source The source of the error.
|
|
133
|
+
* @param property The name of the property.
|
|
134
|
+
* @param value The value to test.
|
|
135
|
+
* @throws GuardError If the value does not match the assertion.
|
|
136
|
+
*/
|
|
137
|
+
static objectValue<T = {
|
|
138
|
+
[id: string]: unknown;
|
|
139
|
+
}>(source: string, property: string, value: unknown): asserts value is T;
|
|
140
|
+
/**
|
|
141
|
+
* Is the property is an array.
|
|
142
|
+
* @param source The source of the error.
|
|
143
|
+
* @param property The name of the property.
|
|
144
|
+
* @param value The value to test.
|
|
145
|
+
* @throws GuardError If the value does not match the assertion.
|
|
146
|
+
*/
|
|
147
|
+
static array<T>(source: string, property: string, value: unknown): asserts value is T[];
|
|
148
|
+
/**
|
|
149
|
+
* Is the property is an array with at least one item.
|
|
150
|
+
* @param source The source of the error.
|
|
151
|
+
* @param property The name of the property.
|
|
152
|
+
* @param value The value to test.
|
|
153
|
+
* @throws GuardError If the value does not match the assertion.
|
|
154
|
+
*/
|
|
155
|
+
static arrayValue<T>(source: string, property: string, value: unknown): asserts value is T[];
|
|
156
|
+
/**
|
|
157
|
+
* Is the property one of a list of items.
|
|
158
|
+
* @param source The source of the error.
|
|
159
|
+
* @param property The name of the property.
|
|
160
|
+
* @param value The value to test.
|
|
161
|
+
* @param options The options the value must be one of.
|
|
162
|
+
* @throws GuardError If the value does not match the assertion.
|
|
163
|
+
*/
|
|
164
|
+
static arrayOneOf<T>(source: string, property: string, value: T, options: T[]): asserts value is T;
|
|
165
|
+
/**
|
|
166
|
+
* Is the property a Uint8Array.
|
|
167
|
+
* @param source The source of the error.
|
|
168
|
+
* @param property The name of the property.
|
|
169
|
+
* @param value The value to test.
|
|
170
|
+
* @throws GuardError If the value does not match the assertion.
|
|
171
|
+
*/
|
|
172
|
+
static uint8Array(source: string, property: string, value: unknown): asserts value is Uint8Array;
|
|
173
|
+
/**
|
|
174
|
+
* Is the property a function.
|
|
175
|
+
* @param source The source of the error.
|
|
176
|
+
* @param property The name of the property.
|
|
177
|
+
* @param value The value to test.
|
|
178
|
+
* @returns True if the value is a function.
|
|
179
|
+
* @throws GuardError If the value does not match the assertion.
|
|
180
|
+
*/
|
|
181
|
+
static function(source: string, property: string, value: unknown): boolean;
|
|
182
|
+
/**
|
|
183
|
+
* Is the property a string formatted as an email address.
|
|
184
|
+
* @param source The source of the error.
|
|
185
|
+
* @param property The name of the property.
|
|
186
|
+
* @param value The value to test.
|
|
187
|
+
* @throws GuardError If the value does not match the assertion.
|
|
188
|
+
*/
|
|
189
|
+
static email(source: string, property: string, value: unknown): asserts value is string;
|
|
190
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ILocaleDictionary } from "../models/ILocaleDictionary";
|
|
2
|
+
/**
|
|
3
|
+
* Class to perform internationalization.
|
|
4
|
+
*/
|
|
5
|
+
export declare class I18n {
|
|
6
|
+
/**
|
|
7
|
+
* The default translation.
|
|
8
|
+
*/
|
|
9
|
+
static DEFAULT_LOCALE: string;
|
|
10
|
+
/**
|
|
11
|
+
* Set the locale.
|
|
12
|
+
* @param locale The new locale.
|
|
13
|
+
*/
|
|
14
|
+
static setLocale(locale: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Get the locale.
|
|
17
|
+
* @returns The current locale.
|
|
18
|
+
*/
|
|
19
|
+
static getLocale(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Add a locale dictionary.
|
|
22
|
+
* @param locale The locale.
|
|
23
|
+
* @param dictionary The dictionary to add.
|
|
24
|
+
*/
|
|
25
|
+
static addDictionary(locale: string, dictionary: ILocaleDictionary): void;
|
|
26
|
+
/**
|
|
27
|
+
* Get a locale dictionary.
|
|
28
|
+
* @param locale The locale.
|
|
29
|
+
* @returns The dictionary of undefined if it does not exist.
|
|
30
|
+
*/
|
|
31
|
+
static getDictionary(locale: string): {
|
|
32
|
+
[key: string]: string;
|
|
33
|
+
} | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Get all the locale dictionaries.
|
|
36
|
+
* @returns The dictionaries.
|
|
37
|
+
*/
|
|
38
|
+
static getAllDictionaries(): {
|
|
39
|
+
[locale: string]: {
|
|
40
|
+
[key: string]: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Add a locale changed handler.
|
|
45
|
+
* @param id The id of the handler.
|
|
46
|
+
* @param handler The handler to add.
|
|
47
|
+
*/
|
|
48
|
+
static addLocaleHandler(id: string, handler: (locale: string) => void): void;
|
|
49
|
+
/**
|
|
50
|
+
* Remove a locale changed handler.
|
|
51
|
+
* @param id The id of the handler.
|
|
52
|
+
*/
|
|
53
|
+
static removeLocaleHandler(id: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Add a dictionary changed handler.
|
|
56
|
+
* @param id The id of the handler.
|
|
57
|
+
* @param handler The handler to add.
|
|
58
|
+
*/
|
|
59
|
+
static addDictionaryHandler(id: string, handler: (locale: string) => void): void;
|
|
60
|
+
/**
|
|
61
|
+
* Remove a dictionary changed handler.
|
|
62
|
+
* @param id The id of the handler.
|
|
63
|
+
*/
|
|
64
|
+
static removeDictionaryHandler(id: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Format a message.
|
|
67
|
+
* @param key The key of the message to format.
|
|
68
|
+
* @param values The values to substitute into the message.
|
|
69
|
+
* @param overrideLocale Override the locale.
|
|
70
|
+
* @returns The formatted string.
|
|
71
|
+
*/
|
|
72
|
+
static formatMessage(key: string, values?: {
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}, overrideLocale?: string): string;
|
|
75
|
+
/**
|
|
76
|
+
* Check if the dictionaries have a message for the given key.
|
|
77
|
+
* @param key The key to check for existence.
|
|
78
|
+
* @returns True if the key exists.
|
|
79
|
+
*/
|
|
80
|
+
static hasMessage(key: string): boolean;
|
|
81
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class to check types of objects.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Is {
|
|
5
|
+
/**
|
|
6
|
+
* Is the property undefined.
|
|
7
|
+
* @param value The value to test.
|
|
8
|
+
* @returns True if the value is a empty.
|
|
9
|
+
*/
|
|
10
|
+
static undefined(value: unknown): value is undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Is the property null.
|
|
13
|
+
* @param value The value to test.
|
|
14
|
+
* @returns True if the value is a empty.
|
|
15
|
+
*/
|
|
16
|
+
static null(value: unknown): value is null;
|
|
17
|
+
/**
|
|
18
|
+
* Is the property null or undefined.
|
|
19
|
+
* @param value The value to test.
|
|
20
|
+
* @returns True if the value is a empty.
|
|
21
|
+
*/
|
|
22
|
+
static empty(value: unknown): value is undefined | null;
|
|
23
|
+
/**
|
|
24
|
+
* Is the property is not null or undefined.
|
|
25
|
+
* @param value The value to test.
|
|
26
|
+
* @returns True if the value is a not empty.
|
|
27
|
+
*/
|
|
28
|
+
static notEmpty(value: unknown): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Is the value a string.
|
|
31
|
+
* @param value The value to test.
|
|
32
|
+
* @returns True if the value is a string.
|
|
33
|
+
*/
|
|
34
|
+
static string(value: unknown): value is string;
|
|
35
|
+
/**
|
|
36
|
+
* Is the value a string.
|
|
37
|
+
* @param value The value to test.
|
|
38
|
+
* @returns True if the value is a string.
|
|
39
|
+
*/
|
|
40
|
+
static stringValue(value: unknown): value is string;
|
|
41
|
+
/**
|
|
42
|
+
* Is the value a JSON string.
|
|
43
|
+
* @param value The value to test.
|
|
44
|
+
* @returns True if the value is a JSON string.
|
|
45
|
+
*/
|
|
46
|
+
static json(value: unknown): value is string;
|
|
47
|
+
/**
|
|
48
|
+
* Is the value a base64 string.
|
|
49
|
+
* @param value The value to test.
|
|
50
|
+
* @returns True if the value is a base64 string.
|
|
51
|
+
*/
|
|
52
|
+
static stringBase64(value: unknown): value is string;
|
|
53
|
+
/**
|
|
54
|
+
* Is the value a base64 url string.
|
|
55
|
+
* @param value The value to test.
|
|
56
|
+
* @returns True if the value is a base64 string.
|
|
57
|
+
*/
|
|
58
|
+
static stringBase64Url(value: unknown): value is string;
|
|
59
|
+
/**
|
|
60
|
+
* Is the value a hex string.
|
|
61
|
+
* @param value The value to test.
|
|
62
|
+
* @param allowPrefix Allow the hex to have the 0x prefix.
|
|
63
|
+
* @returns True if the value is a hex string.
|
|
64
|
+
*/
|
|
65
|
+
static stringHex(value: unknown, allowPrefix?: boolean): value is string;
|
|
66
|
+
/**
|
|
67
|
+
* Is the value a hex string of fixed length.
|
|
68
|
+
* @param value The value to test.
|
|
69
|
+
* @param length The length to test.
|
|
70
|
+
* @param allowPrefix Allow the hex to have the 0x prefix.
|
|
71
|
+
* @returns True if the value is a hex string of required length.
|
|
72
|
+
*/
|
|
73
|
+
static stringHexLength(value: unknown, length: number, allowPrefix?: boolean): value is string;
|
|
74
|
+
/**
|
|
75
|
+
* Is the value a number.
|
|
76
|
+
* @param value The value to test.
|
|
77
|
+
* @returns True if the value is a number.
|
|
78
|
+
*/
|
|
79
|
+
static number(value: unknown): value is number;
|
|
80
|
+
/**
|
|
81
|
+
* Is the value an integer.
|
|
82
|
+
* @param value The value to test.
|
|
83
|
+
* @returns True if the value is an integer.
|
|
84
|
+
*/
|
|
85
|
+
static integer(value: unknown): value is number;
|
|
86
|
+
/**
|
|
87
|
+
* Is the value a big integer.
|
|
88
|
+
* @param value The value to test.
|
|
89
|
+
* @returns True if the value is a big integer.
|
|
90
|
+
*/
|
|
91
|
+
static bigint(value: unknown): value is bigint;
|
|
92
|
+
/**
|
|
93
|
+
* Is the value a boolean.
|
|
94
|
+
* @param value The value to test.
|
|
95
|
+
* @returns True if the value is a boolean.
|
|
96
|
+
*/
|
|
97
|
+
static boolean(value: unknown): value is boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Is the value a date.
|
|
100
|
+
* @param value The value to test.
|
|
101
|
+
* @returns True if the value is a date.
|
|
102
|
+
*/
|
|
103
|
+
static date(value: unknown): value is Date;
|
|
104
|
+
/**
|
|
105
|
+
* Is the value an empty date.
|
|
106
|
+
* @param value The value to test.
|
|
107
|
+
* @returns True if the value is an empty date.
|
|
108
|
+
*/
|
|
109
|
+
static dateEmpty(value: unknown): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Is the value a date string.
|
|
112
|
+
* @param value The value to test.
|
|
113
|
+
* @returns True if the value is a string in ISO 8601 date format.
|
|
114
|
+
*/
|
|
115
|
+
static dateString(value: unknown): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Is the value a date string.
|
|
118
|
+
* @param value The value to test.
|
|
119
|
+
* @returns True if the value is a string in ISO 8601 date/time format.
|
|
120
|
+
*/
|
|
121
|
+
static dateTimeString(value: unknown): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Is the value a time string.
|
|
124
|
+
* @param value The value to test.
|
|
125
|
+
* @returns True if the value is a string in ISO 8601 time format.
|
|
126
|
+
*/
|
|
127
|
+
static timeString(value: unknown): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Is the value a timestamp in seconds.
|
|
130
|
+
* @param value The value to test.
|
|
131
|
+
* @returns True if the value is a date.
|
|
132
|
+
*/
|
|
133
|
+
static timestampSeconds(value: unknown): value is number;
|
|
134
|
+
/**
|
|
135
|
+
* Is the value a timestamp in milliseconds.
|
|
136
|
+
* @param value The value to test.
|
|
137
|
+
* @returns True if the value is a date.
|
|
138
|
+
*/
|
|
139
|
+
static timestampMilliseconds(value: unknown): value is number;
|
|
140
|
+
/**
|
|
141
|
+
* Is the value an object.
|
|
142
|
+
* @param value The value to test.
|
|
143
|
+
* @returns True if the value is a object.
|
|
144
|
+
*/
|
|
145
|
+
static object<T = {
|
|
146
|
+
[id: string]: unknown;
|
|
147
|
+
}>(value: unknown): value is T;
|
|
148
|
+
/**
|
|
149
|
+
* Is the value an object with at least one property.
|
|
150
|
+
* @param value The value to test.
|
|
151
|
+
* @returns True if the value is a object.
|
|
152
|
+
*/
|
|
153
|
+
static objectValue<T = {
|
|
154
|
+
[id: string]: unknown;
|
|
155
|
+
}>(value: unknown): value is T;
|
|
156
|
+
/**
|
|
157
|
+
* Is the value an array.
|
|
158
|
+
* @param value The value to test.
|
|
159
|
+
* @returns True if the value is an array.
|
|
160
|
+
*/
|
|
161
|
+
static array<T>(value: unknown): value is T[];
|
|
162
|
+
/**
|
|
163
|
+
* Is the value an array with at least one element.
|
|
164
|
+
* @param value The value to test.
|
|
165
|
+
* @returns True if the value is an array with at least one element.
|
|
166
|
+
*/
|
|
167
|
+
static arrayValue<T>(value: unknown): value is T[];
|
|
168
|
+
/**
|
|
169
|
+
* Is the value an array with at least one element.
|
|
170
|
+
* @param value The value to test.
|
|
171
|
+
* @param options The options the value must be one of.
|
|
172
|
+
* @returns True if the value is an element from the options array.
|
|
173
|
+
*/
|
|
174
|
+
static arrayOneOf<T>(value: T, options: T[]): value is T;
|
|
175
|
+
/**
|
|
176
|
+
* Is the value a Uint8Array.
|
|
177
|
+
* @param value The value to test.
|
|
178
|
+
* @returns True if the value is a Uint8Array.
|
|
179
|
+
*/
|
|
180
|
+
static uint8Array(value: unknown): value is Uint8Array;
|
|
181
|
+
/**
|
|
182
|
+
* Is the value a TypedArray.
|
|
183
|
+
* @param value The value to test.
|
|
184
|
+
* @returns True if the value is a TypedArray.
|
|
185
|
+
*/
|
|
186
|
+
static typedArray(value: unknown): value is Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array;
|
|
187
|
+
/**
|
|
188
|
+
* Is the property a function.
|
|
189
|
+
* @param value The value to test.
|
|
190
|
+
* @returns True if the value is a function.
|
|
191
|
+
*/
|
|
192
|
+
static function(value: unknown): value is (...args: unknown[]) => unknown;
|
|
193
|
+
/**
|
|
194
|
+
* Is the value a string formatted as an email address.
|
|
195
|
+
* @param value The value to test.
|
|
196
|
+
* @returns True if the value is a string.
|
|
197
|
+
*/
|
|
198
|
+
static email(value: unknown): value is string;
|
|
199
|
+
/**
|
|
200
|
+
* Is the value a promise.
|
|
201
|
+
* @param value The value to test.
|
|
202
|
+
* @returns True if the value is a promise.
|
|
203
|
+
*/
|
|
204
|
+
static promise<T = unknown>(value: unknown): value is Promise<T>;
|
|
205
|
+
}
|