@leyyo/common 1.0.0 → 1.0.2
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/dist/assertion/common-assertion-impl.d.ts +38 -7
- package/dist/assertion/common-assertion-impl.js +64 -26
- package/dist/assertion/index-types.d.ts +466 -75
- package/dist/assertion/index.d.ts +0 -1
- package/dist/assertion/index.js +0 -1
- package/dist/error/common-error-impl.d.ts +6 -4
- package/dist/error/common-error-impl.js +8 -4
- package/dist/error/index-types.d.ts +5 -54
- package/dist/error/index.d.ts +0 -5
- package/dist/error/index.js +0 -5
- package/dist/{error → exception}/assertion-exception.d.ts +1 -1
- package/dist/{error → exception}/caused-exception.d.ts +1 -1
- package/dist/{error → exception}/developer-exception.d.ts +1 -1
- package/dist/{error → exception}/exception.d.ts +4 -3
- package/dist/{error → exception}/exception.js +4 -4
- package/dist/exception/index-types.d.ts +30 -0
- package/dist/exception/index.d.ts +6 -0
- package/dist/exception/index.js +22 -0
- package/dist/fqn/common-fqn-impl.d.ts +11 -0
- package/dist/fqn/common-fqn-impl.js +47 -0
- package/dist/fqn/index-types.d.ts +6 -0
- package/dist/fqn/index-types.js +2 -0
- package/dist/fqn/index.d.ts +2 -0
- package/dist/{callback → fqn}/index.js +1 -1
- package/dist/hook/common-hook-impl.d.ts +30 -0
- package/dist/hook/common-hook-impl.js +111 -0
- package/dist/hook/index-types.d.ts +56 -0
- package/dist/hook/index-types.js +2 -0
- package/dist/hook/index.d.ts +2 -0
- package/dist/hook/index.js +18 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.js +19 -6
- package/dist/is/common-is-impl.d.ts +36 -15
- package/dist/is/common-is-impl.js +35 -10
- package/dist/is/index-types.d.ts +142 -20
- package/dist/leyyo/index-types.d.ts +4 -2
- package/dist/leyyo/leyyo-impl.d.ts +4 -2
- package/dist/leyyo/leyyo-impl.js +37 -29
- package/dist/literal/country-code.d.ts +8 -0
- package/dist/literal/country-code.js +17 -0
- package/dist/literal/environment.d.ts +8 -0
- package/dist/literal/environment.js +7 -0
- package/dist/literal/http-method.d.ts +8 -0
- package/dist/literal/http-method.js +7 -0
- package/dist/literal/http-place.d.ts +8 -0
- package/dist/literal/http-place.js +7 -0
- package/dist/literal/index-types.d.ts +6 -0
- package/dist/literal/index-types.js +2 -0
- package/dist/literal/index.d.ts +14 -0
- package/dist/literal/index.js +30 -0
- package/dist/literal/key-value.d.ts +4 -0
- package/dist/literal/key-value.js +7 -0
- package/dist/literal/language-code.d.ts +8 -0
- package/dist/literal/language-code.js +12 -0
- package/dist/literal/locale-code.d.ts +10 -0
- package/dist/literal/locale-code.js +17 -0
- package/dist/literal/primitive.d.ts +8 -0
- package/dist/literal/primitive.js +7 -0
- package/dist/literal/real-value.d.ts +8 -0
- package/dist/literal/real-value.js +7 -0
- package/dist/literal/severity.d.ts +8 -0
- package/dist/literal/severity.js +7 -0
- package/dist/literal/storage-type.d.ts +8 -0
- package/dist/literal/storage-type.js +7 -0
- package/dist/literal/weak-false.d.ts +8 -0
- package/dist/literal/weak-false.js +7 -0
- package/dist/literal/weak-true.d.ts +8 -0
- package/dist/literal/weak-true.js +7 -0
- package/dist/log/common-log-impl.d.ts +3 -2
- package/dist/log/common-log-impl.js +6 -6
- package/dist/log/index-types.d.ts +2 -55
- package/dist/log/index-types.js +0 -1
- package/dist/log/index.d.ts +1 -1
- package/dist/log/index.js +1 -1
- package/dist/log/logger-impl.d.ts +4 -3
- package/dist/log/logger-impl.js +7 -6
- package/dist/{assertion → shared}/assert.js +1 -0
- package/dist/{aliases.d.ts → shared/index-aliases.d.ts} +32 -4
- package/dist/shared/index-types.d.ts +141 -0
- package/dist/shared/index-types.js +3 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.js +21 -0
- package/dist/storage/common-storage-impl.d.ts +3 -2
- package/dist/storage/common-storage-impl.js +3 -3
- package/dist/storage/index-types.d.ts +3 -18
- package/dist/storage/index.d.ts +0 -1
- package/dist/storage/index.js +0 -1
- package/dist/to/common-to-impl.d.ts +19 -19
- package/dist/to/common-to-impl.js +11 -11
- package/dist/to/index-types.d.ts +18 -48
- package/package.json +1 -1
- package/dist/callback/common-callback-impl.d.ts +0 -31
- package/dist/callback/common-callback-impl.js +0 -134
- package/dist/callback/index-types.d.ts +0 -75
- package/dist/callback/index.d.ts +0 -2
- package/dist/literals.d.ts +0 -98
- package/dist/literals.js +0 -77
- package/dist/{error → exception}/assertion-exception.js +0 -0
- package/dist/{error → exception}/caused-exception.js +0 -0
- package/dist/{error → exception}/developer-exception.js +0 -0
- package/dist/{callback → exception}/index-types.js +0 -0
- package/dist/{error → exception}/multiple-exception.d.ts +1 -1
- package/dist/{error → exception}/multiple-exception.js +0 -0
- package/dist/{assertion → shared}/assert.d.ts +1 -1
- /package/dist/{aliases.js → shared/index-aliases.js} +0 -0
- /package/dist/{constants.d.ts → shared/index-constants.d.ts} +0 -0
- /package/dist/{constants.js → shared/index-constants.js} +0 -0
- /package/dist/{storage → shared}/list.d.ts +0 -0
- /package/dist/{storage → shared}/list.js +0 -0
|
@@ -1,79 +1,470 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Arr, AssertionCallback, AssertionOpt, InitLike, ShiftMain, ShiftSecure, ToTypeOpt } from "../shared";
|
|
2
|
+
/**
|
|
3
|
+
* Basic assertions to easy use
|
|
4
|
+
* */
|
|
4
5
|
export interface CommonAssertion extends ShiftSecure<CommonAssertionSecure> {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Raises an error with given parameters
|
|
8
|
+
*
|
|
9
|
+
* @param {string} message - error message
|
|
10
|
+
* @param {any?} value
|
|
11
|
+
* @param {string?} indicator - developer indicator
|
|
12
|
+
* @param {string?} def - default error message
|
|
13
|
+
* */
|
|
14
|
+
raise(message: string, value?: any, indicator?: string, def?: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Raises an error with given parameters
|
|
17
|
+
*
|
|
18
|
+
* @param {AssertionCallback} fn - callback which should return {@link AssertionOpt}
|
|
19
|
+
* @param {any?} value
|
|
20
|
+
* @param {string?} indicator - developer indicator
|
|
21
|
+
* @param {string?} def - default error message
|
|
22
|
+
* */
|
|
23
|
+
raise(fn: AssertionCallback, value?: any, indicator?: string, def?: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Raises an error with given parameters
|
|
26
|
+
*
|
|
27
|
+
* @param {AssertionOpt} opt - options
|
|
28
|
+
* @param {any?} value
|
|
29
|
+
* @param {string?} indicator - developer indicator
|
|
30
|
+
* @param {string?} def - default error message
|
|
31
|
+
* */
|
|
7
32
|
raise(opt: AssertionOpt, value?: any, indicator?: string, def?: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Empty function, it can be more useful sometimes
|
|
35
|
+
*
|
|
36
|
+
* @param {Arr} params - insignificant parameters
|
|
37
|
+
* */
|
|
8
38
|
emptyFn(...params: Arr): void;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Converts ant value secure json value
|
|
41
|
+
*
|
|
42
|
+
* Controls:
|
|
43
|
+
* - circular dependency
|
|
44
|
+
* - depth control
|
|
45
|
+
* - handling function and symbol values
|
|
46
|
+
*
|
|
47
|
+
* @param {any} value
|
|
48
|
+
* @returns {any} - it based on generic
|
|
49
|
+
* */
|
|
50
|
+
secureJson<E = unknown>(value: any): E;
|
|
51
|
+
/**
|
|
52
|
+
* Validates value is real number
|
|
53
|
+
*
|
|
54
|
+
* Real number means: !NaN and isFinite
|
|
55
|
+
*
|
|
56
|
+
* @param {any} value
|
|
57
|
+
* @param {ToTypeOpt} opt
|
|
58
|
+
* @returns {number}
|
|
59
|
+
* */
|
|
60
|
+
realNumber(value: number, opt?: ToTypeOpt): number;
|
|
61
|
+
/**
|
|
62
|
+
* Asserts value is not empty
|
|
63
|
+
* @see CommonIs#empty
|
|
64
|
+
*
|
|
65
|
+
* @param {any} value
|
|
66
|
+
* @param {string?} message
|
|
67
|
+
* */
|
|
68
|
+
notEmpty(value: any, message?: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* Asserts value is not empty
|
|
71
|
+
* @see CommonIs#empty
|
|
72
|
+
*
|
|
73
|
+
* @param {any} value
|
|
74
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
75
|
+
* */
|
|
76
|
+
notEmpty(value: any, fn?: AssertionCallback): void;
|
|
77
|
+
/**
|
|
78
|
+
* Asserts value is not empty
|
|
79
|
+
* @see CommonIs#empty
|
|
80
|
+
*
|
|
81
|
+
* @param {any} value
|
|
82
|
+
* @param {AssertionOpt?} opt
|
|
83
|
+
* */
|
|
84
|
+
notEmpty(value: any, opt?: AssertionOpt): void;
|
|
85
|
+
/**
|
|
86
|
+
* Asserts value is a primitive
|
|
87
|
+
* @see CommonIs#primitive
|
|
88
|
+
*
|
|
89
|
+
* @param {any} value
|
|
90
|
+
* @param {string?} message
|
|
91
|
+
* */
|
|
92
|
+
primitive(value: any, message?: string): void;
|
|
93
|
+
/**
|
|
94
|
+
* Asserts value is a primitive
|
|
95
|
+
* @see CommonIs#primitive
|
|
96
|
+
*
|
|
97
|
+
* @param {any} value
|
|
98
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
99
|
+
* */
|
|
100
|
+
primitive(value: any, fn?: AssertionCallback): void;
|
|
101
|
+
/**
|
|
102
|
+
* Asserts value is a primitive
|
|
103
|
+
* @see CommonIs#primitive
|
|
104
|
+
*
|
|
105
|
+
* @param {any} value
|
|
106
|
+
* @param {AssertionOpt?} opt
|
|
107
|
+
* */
|
|
108
|
+
primitive(value: any, opt?: AssertionOpt): void;
|
|
109
|
+
/**
|
|
110
|
+
* Asserts value is a real value
|
|
111
|
+
* @see CommonIs#realValue
|
|
112
|
+
*
|
|
113
|
+
* @param {any} value
|
|
114
|
+
* @param {string?} message
|
|
115
|
+
* */
|
|
116
|
+
realValue(value: any, message?: string): void;
|
|
117
|
+
/**
|
|
118
|
+
* Asserts value is a real value
|
|
119
|
+
* @see CommonIs#realValue
|
|
120
|
+
*
|
|
121
|
+
* @param {any} value
|
|
122
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
123
|
+
* */
|
|
124
|
+
realValue(value: any, fn?: AssertionCallback): void;
|
|
125
|
+
/**
|
|
126
|
+
* Asserts value is a real value
|
|
127
|
+
* @see CommonIs#realValue
|
|
128
|
+
*
|
|
129
|
+
* @param {any} value
|
|
130
|
+
* @param {AssertionOpt?} opt
|
|
131
|
+
* */
|
|
132
|
+
realValue(value: any, opt?: AssertionOpt): void;
|
|
133
|
+
/**
|
|
134
|
+
* Asserts value is a key
|
|
135
|
+
* @see CommonIs#key
|
|
136
|
+
*
|
|
137
|
+
* @param {any} value
|
|
138
|
+
* @param {string?} message
|
|
139
|
+
* */
|
|
140
|
+
key(value: any, message?: string): void;
|
|
141
|
+
/**
|
|
142
|
+
* Asserts value is a key
|
|
143
|
+
* @see CommonIs#key
|
|
144
|
+
*
|
|
145
|
+
* @param {any} value
|
|
146
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
147
|
+
* */
|
|
148
|
+
key(value: any, fn?: AssertionCallback): void;
|
|
149
|
+
/**
|
|
150
|
+
* Asserts value is a key
|
|
151
|
+
* @see CommonIs#key
|
|
152
|
+
*
|
|
153
|
+
* @param {any} value
|
|
154
|
+
* @param {AssertionOpt?} opt
|
|
155
|
+
* */
|
|
156
|
+
key(value: any, opt?: AssertionOpt): void;
|
|
157
|
+
/**
|
|
158
|
+
* Asserts value is an object
|
|
159
|
+
* @see CommonIs#object
|
|
160
|
+
*
|
|
161
|
+
* @param {any} value
|
|
162
|
+
* @param {string?} message
|
|
163
|
+
* */
|
|
164
|
+
object(value: any, message?: string): void;
|
|
165
|
+
/**
|
|
166
|
+
* Asserts value is an object
|
|
167
|
+
* @see CommonIs#object
|
|
168
|
+
*
|
|
169
|
+
* @param {any} value
|
|
170
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
171
|
+
* */
|
|
172
|
+
object(value: any, fn?: AssertionCallback): void;
|
|
173
|
+
/**
|
|
174
|
+
* Asserts value is an object
|
|
175
|
+
* @see CommonIs#object
|
|
176
|
+
*
|
|
177
|
+
* @param {any} value
|
|
178
|
+
* @param {AssertionOpt?} opt
|
|
179
|
+
* */
|
|
180
|
+
object(value: any, opt?: AssertionOpt): void;
|
|
181
|
+
/**
|
|
182
|
+
* Asserts value is an array
|
|
183
|
+
* @see CommonIs#empty
|
|
184
|
+
*
|
|
185
|
+
* @param {any} value
|
|
186
|
+
* @param {string?} message
|
|
187
|
+
* */
|
|
188
|
+
array(value: any, message?: string): void;
|
|
189
|
+
/**
|
|
190
|
+
* Asserts value is an array
|
|
191
|
+
* @see CommonIs#array
|
|
192
|
+
*
|
|
193
|
+
* @param {any} value
|
|
194
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
195
|
+
* */
|
|
196
|
+
array(value: any, fn?: AssertionCallback): void;
|
|
197
|
+
/**
|
|
198
|
+
* Asserts value is an array
|
|
199
|
+
* @see CommonIs#array
|
|
200
|
+
*
|
|
201
|
+
* @param {any} value
|
|
202
|
+
* @param {AssertionOpt?} opt
|
|
203
|
+
* */
|
|
204
|
+
array(value: any, opt?: AssertionOpt): void;
|
|
205
|
+
/**
|
|
206
|
+
* Asserts value is a function
|
|
207
|
+
* @see CommonIs#func
|
|
208
|
+
*
|
|
209
|
+
* @param {any} value
|
|
210
|
+
* @param {string?} message
|
|
211
|
+
* */
|
|
212
|
+
func(value: any, message?: string): void;
|
|
213
|
+
/**
|
|
214
|
+
* Asserts value is a function
|
|
215
|
+
* @see CommonIs#func
|
|
216
|
+
*
|
|
217
|
+
* @param {any} value
|
|
218
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
219
|
+
* */
|
|
220
|
+
func(value: any, fn?: AssertionCallback): void;
|
|
221
|
+
/**
|
|
222
|
+
* Asserts value is a function
|
|
223
|
+
* @see CommonIs#func
|
|
224
|
+
*
|
|
225
|
+
* @param {any} value
|
|
226
|
+
* @param {AssertionOpt?} opt
|
|
227
|
+
* */
|
|
228
|
+
func(value: any, opt?: AssertionOpt): void;
|
|
229
|
+
/**
|
|
230
|
+
* Asserts value is a number
|
|
231
|
+
* @see CommonIs#number
|
|
232
|
+
*
|
|
233
|
+
* @param {any} value
|
|
234
|
+
* @param {string?} message
|
|
235
|
+
* */
|
|
236
|
+
number(value: any, message?: string): void;
|
|
237
|
+
/**
|
|
238
|
+
* Asserts value is a number
|
|
239
|
+
* @see CommonIs#number
|
|
240
|
+
*
|
|
241
|
+
* @param {any} value
|
|
242
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
243
|
+
* */
|
|
244
|
+
number(value: any, fn?: AssertionCallback): void;
|
|
245
|
+
/**
|
|
246
|
+
* Asserts value is a number
|
|
247
|
+
* @see CommonIs#number
|
|
248
|
+
*
|
|
249
|
+
* @param {any} value
|
|
250
|
+
* @param {AssertionOpt?} opt
|
|
251
|
+
* */
|
|
252
|
+
number(value: any, opt?: AssertionOpt): void;
|
|
253
|
+
/**
|
|
254
|
+
* Asserts value is a positive number
|
|
255
|
+
* @see CommonIs#number
|
|
256
|
+
*
|
|
257
|
+
* @param {any} value
|
|
258
|
+
* @param {string?} message
|
|
259
|
+
* */
|
|
260
|
+
positiveNumber(value: any, message?: string): void;
|
|
261
|
+
/**
|
|
262
|
+
* Asserts value is a positive number
|
|
263
|
+
* @see CommonIs#number
|
|
264
|
+
*
|
|
265
|
+
* @param {any} value
|
|
266
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
267
|
+
* */
|
|
268
|
+
positiveNumber(value: any, fn?: AssertionCallback): void;
|
|
269
|
+
/**
|
|
270
|
+
* Asserts value is a positive number
|
|
271
|
+
* @see CommonIs#number
|
|
272
|
+
*
|
|
273
|
+
* @param {any} value
|
|
274
|
+
* @param {AssertionOpt?} opt
|
|
275
|
+
* */
|
|
276
|
+
positiveNumber(value: any, opt?: AssertionOpt): void;
|
|
277
|
+
/**
|
|
278
|
+
* Asserts value is an integer
|
|
279
|
+
* @see CommonIs#integer
|
|
280
|
+
*
|
|
281
|
+
* @param {any} value
|
|
282
|
+
* @param {string?} message
|
|
283
|
+
* */
|
|
284
|
+
integer(value: any, message?: string): void;
|
|
285
|
+
/**
|
|
286
|
+
* Asserts value is an integer
|
|
287
|
+
* @see CommonIs#integer
|
|
288
|
+
*
|
|
289
|
+
* @param {any} value
|
|
290
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
291
|
+
* */
|
|
292
|
+
integer(value: any, fn?: AssertionCallback): void;
|
|
293
|
+
/**
|
|
294
|
+
* Asserts value is an integer
|
|
295
|
+
* @see CommonIs#integer
|
|
296
|
+
*
|
|
297
|
+
* @param {any} value
|
|
298
|
+
* @param {AssertionOpt?} opt
|
|
299
|
+
* */
|
|
300
|
+
integer(value: any, opt?: AssertionOpt): void;
|
|
301
|
+
/**
|
|
302
|
+
* Asserts value is a safe integer
|
|
303
|
+
* @see CommonIs#safeInteger
|
|
304
|
+
*
|
|
305
|
+
* @param {any} value
|
|
306
|
+
* @param {string?} message
|
|
307
|
+
* */
|
|
308
|
+
safeInteger(value: any, message?: string): void;
|
|
309
|
+
/**
|
|
310
|
+
* Asserts value is a safe integer
|
|
311
|
+
* @see CommonIs#safeInteger
|
|
312
|
+
*
|
|
313
|
+
* @param {any} value
|
|
314
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
315
|
+
* */
|
|
316
|
+
safeInteger(value: any, fn?: AssertionCallback): void;
|
|
317
|
+
/**
|
|
318
|
+
* Asserts value is a safe integer
|
|
319
|
+
* @see CommonIs#safeInteger
|
|
320
|
+
*
|
|
321
|
+
* @param {any} value
|
|
322
|
+
* @param {AssertionOpt?} opt
|
|
323
|
+
* */
|
|
324
|
+
safeInteger(value: any, opt?: AssertionOpt): void;
|
|
325
|
+
/**
|
|
326
|
+
* Asserts value is a positive integer
|
|
327
|
+
* @see CommonIs#integer
|
|
328
|
+
*
|
|
329
|
+
* @param {any} value
|
|
330
|
+
* @param {string?} message
|
|
331
|
+
* */
|
|
332
|
+
positiveInteger(value: any, message?: string): void;
|
|
333
|
+
/**
|
|
334
|
+
* Asserts value is a positive integer
|
|
335
|
+
* @see CommonIs#integer
|
|
336
|
+
*
|
|
337
|
+
* @param {any} value
|
|
338
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
339
|
+
* */
|
|
340
|
+
positiveInteger(value: any, fn?: AssertionCallback): void;
|
|
341
|
+
/**
|
|
342
|
+
* Asserts value is a positive integer
|
|
343
|
+
* @see CommonIs#integer
|
|
344
|
+
*
|
|
345
|
+
* @param {any} value
|
|
346
|
+
* @param {AssertionOpt?} opt
|
|
347
|
+
* */
|
|
348
|
+
positiveInteger(value: any, opt?: AssertionOpt): void;
|
|
349
|
+
/**
|
|
350
|
+
* Asserts value is a string
|
|
351
|
+
* @see CommonIs#string
|
|
352
|
+
*
|
|
353
|
+
* @param {any} value
|
|
354
|
+
* @param {string?} message
|
|
355
|
+
* */
|
|
356
|
+
string(value: any, message?: string): void;
|
|
357
|
+
/**
|
|
358
|
+
* Asserts value is a string
|
|
359
|
+
* @see CommonIs#string
|
|
360
|
+
*
|
|
361
|
+
* @param {any} value
|
|
362
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
363
|
+
* */
|
|
364
|
+
string(value: any, fn?: AssertionCallback): void;
|
|
365
|
+
/**
|
|
366
|
+
* Asserts value is a string
|
|
367
|
+
* @see CommonIs#string
|
|
368
|
+
*
|
|
369
|
+
* @param {any} value
|
|
370
|
+
* @param {AssertionOpt?} opt
|
|
371
|
+
* */
|
|
372
|
+
string(value: any, opt?: AssertionOpt): void;
|
|
373
|
+
/**
|
|
374
|
+
* Asserts value is a text
|
|
375
|
+
* @see CommonIs#text
|
|
376
|
+
*
|
|
377
|
+
* @param {any} value
|
|
378
|
+
* @param {string?} message
|
|
379
|
+
* */
|
|
380
|
+
text(value: any, message?: string): string;
|
|
381
|
+
/**
|
|
382
|
+
* Asserts value is a text
|
|
383
|
+
* @see CommonIs#text
|
|
384
|
+
*
|
|
385
|
+
* @param {any} value
|
|
386
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
387
|
+
* */
|
|
388
|
+
text(value: any, fn?: AssertionCallback): string;
|
|
389
|
+
/**
|
|
390
|
+
* Asserts value is a text
|
|
391
|
+
* @see CommonIs#text
|
|
392
|
+
*
|
|
393
|
+
* @param {any} value
|
|
394
|
+
* @param {AssertionOpt?} opt
|
|
395
|
+
* */
|
|
396
|
+
text(value: any, opt?: AssertionOpt): string;
|
|
397
|
+
/**
|
|
398
|
+
* Asserts value is a possible class
|
|
399
|
+
* @see CommonIs#clazz
|
|
400
|
+
*
|
|
401
|
+
* @param {any} value
|
|
402
|
+
* @param {string?} message
|
|
403
|
+
* */
|
|
404
|
+
clazz(value: any, message?: string): void;
|
|
405
|
+
/**
|
|
406
|
+
* Asserts value is a possible class
|
|
407
|
+
* @see CommonIs#clazz
|
|
408
|
+
*
|
|
409
|
+
* @param {any} value
|
|
410
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
411
|
+
* */
|
|
412
|
+
clazz(value: any, fn?: AssertionCallback): void;
|
|
413
|
+
/**
|
|
414
|
+
* Asserts value is a possible class
|
|
415
|
+
* @see CommonIs#clazz
|
|
416
|
+
*
|
|
417
|
+
* @param {any} value
|
|
418
|
+
* @param {AssertionOpt?} opt
|
|
419
|
+
* */
|
|
420
|
+
clazz(value: any, opt?: AssertionOpt): void;
|
|
421
|
+
/**
|
|
422
|
+
* Asserts value is a date
|
|
423
|
+
*
|
|
424
|
+
* @param {any} value
|
|
425
|
+
* @param {string?} message
|
|
426
|
+
* */
|
|
427
|
+
date(value: any, message?: string): void;
|
|
428
|
+
/**
|
|
429
|
+
* Asserts value is a date
|
|
430
|
+
*
|
|
431
|
+
* @param {any} value
|
|
432
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
433
|
+
* */
|
|
434
|
+
date(value: any, fn?: AssertionCallback): void;
|
|
435
|
+
/**
|
|
436
|
+
* Asserts value is a date
|
|
437
|
+
*
|
|
438
|
+
* @param {any} value
|
|
439
|
+
* @param {AssertionOpt?} opt
|
|
440
|
+
* */
|
|
441
|
+
date(value: any, opt?: AssertionOpt): void;
|
|
442
|
+
/**
|
|
443
|
+
* Asserts value is a boolean
|
|
444
|
+
* @see CommonIs#boolean
|
|
445
|
+
*
|
|
446
|
+
* @param {any} value
|
|
447
|
+
* @param {string?} message
|
|
448
|
+
* */
|
|
449
|
+
boolean(value: any, message?: string): void;
|
|
450
|
+
/**
|
|
451
|
+
* Asserts value is a boolean
|
|
452
|
+
* @see CommonIs#boolean
|
|
453
|
+
*
|
|
454
|
+
* @param {any} value
|
|
455
|
+
* @param {AssertionCallback?} fn - it should return {@link AssertionOpt}
|
|
456
|
+
* */
|
|
457
|
+
boolean(value: any, fn?: AssertionCallback): void;
|
|
458
|
+
/**
|
|
459
|
+
* Asserts value is a boolean
|
|
460
|
+
* @see CommonIs#boolean
|
|
461
|
+
*
|
|
462
|
+
* @param {any} value
|
|
463
|
+
* @param {AssertionOpt?} opt
|
|
464
|
+
* */
|
|
465
|
+
boolean(value: any, opt?: AssertionOpt): void;
|
|
59
466
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
export
|
|
64
|
-
indicator?: AssertionReason | string;
|
|
65
|
-
param?: string;
|
|
66
|
-
where?: string;
|
|
67
|
-
value?: any;
|
|
68
|
-
expected?: OneOrMore<string>;
|
|
69
|
-
current?: string;
|
|
70
|
-
type?: string;
|
|
71
|
-
[k: string]: any;
|
|
72
|
-
}
|
|
73
|
-
type AssertionReason = 'invalid.type' | 'not.found' | 'duplicated' | 'empty';
|
|
74
|
-
export type AssertionCallback = () => string | AssertionOpt;
|
|
75
|
-
export interface AssertionBuiltResult {
|
|
76
|
-
message?: string;
|
|
77
|
-
params: AssertionOpt;
|
|
78
|
-
}
|
|
79
|
-
export {};
|
|
467
|
+
/**
|
|
468
|
+
* Secure assertion methods
|
|
469
|
+
* */
|
|
470
|
+
export type CommonAssertionSecure = ShiftMain<CommonAssertion> & InitLike;
|
package/dist/assertion/index.js
CHANGED
|
@@ -16,4 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./index-types"), exports);
|
|
18
18
|
__exportStar(require("./common-assertion-impl"), exports);
|
|
19
|
-
__exportStar(require("./assert"), exports);
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { CommonError, CommonErrorSecure
|
|
1
|
+
import { CommonError, CommonErrorSecure } from "./index-types";
|
|
2
2
|
import { Leyyo } from "../leyyo";
|
|
3
|
-
import { Dict } from "../
|
|
4
|
-
import {
|
|
3
|
+
import { Dict } from "../shared";
|
|
4
|
+
import { ExceptionLike } from "../exception";
|
|
5
5
|
export declare class CommonErrorImpl implements CommonError, CommonErrorSecure {
|
|
6
|
+
private hook;
|
|
6
7
|
get $back(): CommonError;
|
|
7
8
|
$init(leyyo: Leyyo): void;
|
|
8
9
|
get $secure(): CommonErrorSecure;
|
|
9
10
|
addOmit(clz: Function, ...properties: Array<string>): boolean;
|
|
10
11
|
addSign(err: Error, ...keys: Array<string>): boolean;
|
|
11
12
|
afterCreate(e: ExceptionLike): void;
|
|
13
|
+
register(cls: Function): void;
|
|
12
14
|
build(e: Error | string): ExceptionLike;
|
|
13
15
|
buildStack(e: Error): void;
|
|
14
|
-
copyStack(exception:
|
|
16
|
+
copyStack(exception: ExceptionLike, error: Error): void;
|
|
15
17
|
causedBy(e: Error | string): ExceptionLike;
|
|
16
18
|
getOmit(clz: Function): Array<string>;
|
|
17
19
|
getSign(err: Error): Array<string>;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommonErrorImpl = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const shared_1 = require("../shared");
|
|
5
|
+
const exception_1 = require("../exception");
|
|
6
6
|
// noinspection JSUnusedLocalSymbols
|
|
7
7
|
class CommonErrorImpl {
|
|
8
8
|
get $back() {
|
|
9
9
|
return this;
|
|
10
10
|
}
|
|
11
11
|
$init(leyyo) {
|
|
12
|
+
this.hook = leyyo.hook;
|
|
12
13
|
const fields = ['build', 'afterCreate', 'causedBy', 'toObject', 'buildStack', 'copyStack',
|
|
13
14
|
'initSign', 'addSign', 'getSign', 'removeSign', 'hasSign',
|
|
14
15
|
'initOmit', 'addOmit', 'getOmit', 'inheritOmit'];
|
|
@@ -17,9 +18,9 @@ class CommonErrorImpl {
|
|
|
17
18
|
rec[field] = this[field];
|
|
18
19
|
});
|
|
19
20
|
// define itself temporarily for error operations
|
|
20
|
-
|
|
21
|
+
this.hook.defineProvider(shared_1.LY_ATTACHED_ERROR, CommonErrorImpl, rec);
|
|
21
22
|
// when new error provider is defined, replace all common methods
|
|
22
|
-
|
|
23
|
+
this.hook.whenProviderDefined(shared_1.LY_ATTACHED_ERROR, CommonErrorImpl, (ins) => {
|
|
23
24
|
fields.forEach(field => {
|
|
24
25
|
if (typeof ins[field] === 'function') {
|
|
25
26
|
this[field] = ins[field];
|
|
@@ -39,6 +40,9 @@ class CommonErrorImpl {
|
|
|
39
40
|
afterCreate(e) {
|
|
40
41
|
e.$secure.$setName(e.constructor.name);
|
|
41
42
|
}
|
|
43
|
+
register(cls) {
|
|
44
|
+
this.hook.queueForCallback(shared_1.LY_PENDING_ERROR_REGISTER, cls);
|
|
45
|
+
}
|
|
42
46
|
build(e) {
|
|
43
47
|
if (e instanceof exception_1.Exception) {
|
|
44
48
|
return e;
|