@twin.org/core 0.0.1-next.9 → 0.0.2-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/cjs/index.cjs +1574 -833
  2. package/dist/esm/index.mjs +1571 -834
  3. package/dist/types/errors/baseError.d.ts +8 -1
  4. package/dist/types/factories/factory.d.ts +20 -1
  5. package/dist/types/helpers/arrayHelper.d.ts +13 -0
  6. package/dist/types/helpers/envHelper.d.ts +16 -0
  7. package/dist/types/helpers/errorHelper.d.ts +2 -1
  8. package/dist/types/helpers/jsonHelper.d.ts +30 -0
  9. package/dist/types/helpers/objectHelper.d.ts +25 -0
  10. package/dist/types/helpers/uint8ArrayHelper.d.ts +11 -0
  11. package/dist/types/index.d.ts +6 -0
  12. package/dist/types/models/IComponent.d.ts +12 -3
  13. package/dist/types/models/II18nShared.d.ts +29 -0
  14. package/dist/types/models/coerceType.d.ts +49 -0
  15. package/dist/types/models/compressionType.d.ts +1 -1
  16. package/dist/types/models/objectOrArray.d.ts +4 -0
  17. package/dist/types/utils/asyncCache.d.ts +10 -1
  18. package/dist/types/utils/coerce.d.ts +22 -0
  19. package/dist/types/utils/guards.d.ts +35 -0
  20. package/dist/types/utils/is.d.ts +12 -0
  21. package/dist/types/utils/sharedStore.d.ts +23 -0
  22. package/dist/types/utils/validation.d.ts +2 -0
  23. package/docs/changelog.md +323 -1
  24. package/docs/reference/classes/AlreadyExistsError.md +103 -27
  25. package/docs/reference/classes/ArrayHelper.md +71 -5
  26. package/docs/reference/classes/AsyncCache.md +75 -13
  27. package/docs/reference/classes/Base32.md +9 -5
  28. package/docs/reference/classes/Base58.md +9 -5
  29. package/docs/reference/classes/Base64.md +12 -6
  30. package/docs/reference/classes/Base64Url.md +9 -5
  31. package/docs/reference/classes/BaseError.md +101 -29
  32. package/docs/reference/classes/BitString.md +23 -11
  33. package/docs/reference/classes/Coerce.md +110 -12
  34. package/docs/reference/classes/Compression.md +19 -11
  35. package/docs/reference/classes/ConflictError.md +106 -28
  36. package/docs/reference/classes/Converter.md +72 -28
  37. package/docs/reference/classes/EnvHelper.md +45 -0
  38. package/docs/reference/classes/ErrorHelper.md +19 -7
  39. package/docs/reference/classes/Factory.md +95 -17
  40. package/docs/reference/classes/FilenameHelper.md +6 -4
  41. package/docs/reference/classes/GeneralError.md +101 -27
  42. package/docs/reference/classes/GuardError.md +106 -28
  43. package/docs/reference/classes/Guards.md +398 -80
  44. package/docs/reference/classes/HexHelper.md +18 -8
  45. package/docs/reference/classes/I18n.md +46 -20
  46. package/docs/reference/classes/Is.md +179 -51
  47. package/docs/reference/classes/JsonHelper.md +146 -10
  48. package/docs/reference/classes/NotFoundError.md +103 -27
  49. package/docs/reference/classes/NotImplementedError.md +97 -25
  50. package/docs/reference/classes/NotSupportedError.md +100 -26
  51. package/docs/reference/classes/ObjectHelper.md +197 -39
  52. package/docs/reference/classes/RandomHelper.md +6 -4
  53. package/docs/reference/classes/SharedStore.md +94 -0
  54. package/docs/reference/classes/StringHelper.md +54 -20
  55. package/docs/reference/classes/Uint8ArrayHelper.md +35 -0
  56. package/docs/reference/classes/UnauthorizedError.md +100 -26
  57. package/docs/reference/classes/UnprocessableError.md +101 -27
  58. package/docs/reference/classes/Url.md +37 -17
  59. package/docs/reference/classes/Urn.md +63 -27
  60. package/docs/reference/classes/Validation.md +349 -135
  61. package/docs/reference/classes/ValidationError.md +100 -26
  62. package/docs/reference/index.md +7 -0
  63. package/docs/reference/interfaces/IComponent.md +30 -8
  64. package/docs/reference/interfaces/IError.md +2 -2
  65. package/docs/reference/interfaces/II18nShared.md +47 -0
  66. package/docs/reference/interfaces/IKeyValue.md +3 -1
  67. package/docs/reference/interfaces/ILabelledValue.md +3 -1
  68. package/docs/reference/interfaces/ILocaleDictionary.md +1 -1
  69. package/docs/reference/interfaces/IPatchOperation.md +1 -1
  70. package/docs/reference/interfaces/IValidationFailure.md +1 -1
  71. package/docs/reference/type-aliases/CoerceType.md +5 -0
  72. package/docs/reference/type-aliases/CompressionType.md +1 -1
  73. package/docs/reference/type-aliases/ObjectOrArray.md +11 -0
  74. package/docs/reference/variables/CoerceType.md +67 -0
  75. package/docs/reference/variables/CompressionType.md +1 -1
  76. package/locales/en.json +14 -1
  77. package/package.json +7 -7
@@ -8,37 +8,43 @@ Class to handle errors.
8
8
 
9
9
  ## Constructors
10
10
 
11
- ### new GeneralError()
11
+ ### Constructor
12
12
 
13
- > **new GeneralError**(`source`, `message`, `properties`?, `inner`?): [`GeneralError`](GeneralError.md)
13
+ > **new GeneralError**(`source`, `message`, `properties?`, `inner?`): `GeneralError`
14
14
 
15
15
  Create a new instance of GeneralError.
16
16
 
17
17
  #### Parameters
18
18
 
19
- **source**: `string`
19
+ ##### source
20
+
21
+ `string`
20
22
 
21
23
  The source of the error.
22
24
 
23
- **message**: `string`
25
+ ##### message
26
+
27
+ `string`
24
28
 
25
29
  The message as a code.
26
30
 
27
- **properties?**
31
+ ##### properties?
28
32
 
29
33
  Any additional information for the error.
30
34
 
31
- **inner?**: `unknown`
35
+ ##### inner?
36
+
37
+ `unknown`
32
38
 
33
39
  The inner error if we have wrapped another error.
34
40
 
35
41
  #### Returns
36
42
 
37
- [`GeneralError`](GeneralError.md)
43
+ `GeneralError`
38
44
 
39
45
  #### Overrides
40
46
 
41
- [`BaseError`](BaseError.md).[`constructor`](BaseError.md#constructors)
47
+ [`BaseError`](BaseError.md).[`constructor`](BaseError.md#constructor)
42
48
 
43
49
  ## Properties
44
50
 
@@ -62,7 +68,7 @@ Any additional information for the error.
62
68
 
63
69
  #### Index Signature
64
70
 
65
- \[`id`: `string`\]: `unknown`
71
+ \[`id`: `string`\]: `unknown`
66
72
 
67
73
  #### Inherited from
68
74
 
@@ -98,7 +104,9 @@ Construct an error from an existing one.
98
104
 
99
105
  #### Parameters
100
106
 
101
- **err**: `unknown`
107
+ ##### err
108
+
109
+ `unknown`
102
110
 
103
111
  The existing error.
104
112
 
@@ -122,7 +130,9 @@ Flatten an error tree.
122
130
 
123
131
  #### Parameters
124
132
 
125
- **err**: `unknown`
133
+ ##### err
134
+
135
+ `unknown`
126
136
 
127
137
  The starting error.
128
138
 
@@ -146,10 +156,12 @@ Expand an error tree.
146
156
 
147
157
  #### Parameters
148
158
 
149
- **errors**: `undefined` \| [`IError`](../interfaces/IError.md)[]
159
+ ##### errors
150
160
 
151
161
  The list of errors to expand.
152
162
 
163
+ `undefined` | [`IError`](../interfaces/IError.md)[]
164
+
153
165
  #### Returns
154
166
 
155
167
  `undefined` \| [`IError`](../interfaces/IError.md)
@@ -170,14 +182,18 @@ Test to see if the error has the specified error name.
170
182
 
171
183
  #### Parameters
172
184
 
173
- **error**: `unknown`
185
+ ##### error
186
+
187
+ `unknown`
174
188
 
175
189
  The error to test.
176
190
 
177
- **name**: `string` \| `RegExp`
191
+ ##### name
178
192
 
179
193
  The name to check for.
180
194
 
195
+ `string` | `RegExp`
196
+
181
197
  #### Returns
182
198
 
183
199
  `error is BaseError`
@@ -198,14 +214,18 @@ Test to see if the error has the specified error message.
198
214
 
199
215
  #### Parameters
200
216
 
201
- **error**: `unknown`
217
+ ##### error
218
+
219
+ `unknown`
202
220
 
203
221
  The error to test.
204
222
 
205
- **message**: `string` \| `RegExp`
223
+ ##### message
206
224
 
207
225
  The message to check for.
208
226
 
227
+ `string` | `RegExp`
228
+
209
229
  #### Returns
210
230
 
211
231
  `error is BaseError`
@@ -226,14 +246,18 @@ Test to see if the error has the specified error code.
226
246
 
227
247
  #### Parameters
228
248
 
229
- **error**: `unknown`
249
+ ##### error
250
+
251
+ `unknown`
230
252
 
231
253
  The error to test.
232
254
 
233
- **code**: `string` \| `RegExp`
255
+ ##### code
234
256
 
235
257
  The code to check for.
236
258
 
259
+ `string` | `RegExp`
260
+
237
261
  #### Returns
238
262
 
239
263
  `boolean`
@@ -254,14 +278,18 @@ Test to see if any of the errors or children have the given error name.
254
278
 
255
279
  #### Parameters
256
280
 
257
- **error**: `unknown`
281
+ ##### error
282
+
283
+ `unknown`
258
284
 
259
285
  The error to test.
260
286
 
261
- **name**: `string` \| `RegExp`
287
+ ##### name
262
288
 
263
289
  The name to check for.
264
290
 
291
+ `string` | `RegExp`
292
+
265
293
  #### Returns
266
294
 
267
295
  `error is BaseError`
@@ -282,14 +310,18 @@ Test to see if any of the errors or children have the given error message.
282
310
 
283
311
  #### Parameters
284
312
 
285
- **error**: `unknown`
313
+ ##### error
314
+
315
+ `unknown`
286
316
 
287
317
  The error to test.
288
318
 
289
- **message**: `string` \| `RegExp`
319
+ ##### message
290
320
 
291
321
  The message to check for.
292
322
 
323
+ `string` | `RegExp`
324
+
293
325
  #### Returns
294
326
 
295
327
  `error is BaseError`
@@ -310,11 +342,15 @@ Test to see if any of the errors or children are from a specific class.
310
342
 
311
343
  #### Parameters
312
344
 
313
- **error**: `unknown`
345
+ ##### error
346
+
347
+ `unknown`
314
348
 
315
349
  The error to test.
316
350
 
317
- **cls**: `string`
351
+ ##### cls
352
+
353
+ `string`
318
354
 
319
355
  The class to check for.
320
356
 
@@ -338,14 +374,18 @@ Test to see if any of the errors or children have the given error code.
338
374
 
339
375
  #### Parameters
340
376
 
341
- **error**: `unknown`
377
+ ##### error
378
+
379
+ `unknown`
342
380
 
343
381
  The error to test.
344
382
 
345
- **code**: `string` \| `RegExp`
383
+ ##### code
346
384
 
347
385
  The code to check for.
348
386
 
387
+ `string` | `RegExp`
388
+
349
389
  #### Returns
350
390
 
351
391
  `error is BaseError`
@@ -358,12 +398,46 @@ True if the error has the name.
358
398
 
359
399
  ***
360
400
 
401
+ ### isEmpty()
402
+
403
+ > `static` **isEmpty**(`err`): `boolean`
404
+
405
+ Is the error empty.
406
+
407
+ #### Parameters
408
+
409
+ ##### err
410
+
411
+ [`IError`](../interfaces/IError.md)
412
+
413
+ The error to check for being empty.
414
+
415
+ #### Returns
416
+
417
+ `boolean`
418
+
419
+ True if the error is empty.
420
+
421
+ #### Inherited from
422
+
423
+ [`BaseError`](BaseError.md).[`isEmpty`](BaseError.md#isempty)
424
+
425
+ ***
426
+
361
427
  ### toJsonObject()
362
428
 
363
- > **toJsonObject**(): [`IError`](../interfaces/IError.md)
429
+ > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
364
430
 
365
431
  Serialize the error to the error model.
366
432
 
433
+ #### Parameters
434
+
435
+ ##### includeStackTrace?
436
+
437
+ `boolean`
438
+
439
+ Whether to include the error stack in the model, defaults to false.
440
+
367
441
  #### Returns
368
442
 
369
443
  [`IError`](../interfaces/IError.md)
@@ -8,41 +8,51 @@ Class to handle errors which are triggered by data guards.
8
8
 
9
9
  ## Constructors
10
10
 
11
- ### new GuardError()
11
+ ### Constructor
12
12
 
13
- > **new GuardError**(`source`, `message`, `propertyName`, `propertyValue`, `propertyOptions`?): [`GuardError`](GuardError.md)
13
+ > **new GuardError**(`source`, `message`, `propertyName`, `propertyValue`, `propertyOptions?`): `GuardError`
14
14
 
15
15
  Create a new instance of GuardError.
16
16
 
17
17
  #### Parameters
18
18
 
19
- **source**: `string`
19
+ ##### source
20
+
21
+ `string`
20
22
 
21
23
  The source of the error.
22
24
 
23
- **message**: `string`
25
+ ##### message
26
+
27
+ `string`
24
28
 
25
29
  The message as a code.
26
30
 
27
- **propertyName**: `string`
31
+ ##### propertyName
32
+
33
+ `string`
28
34
 
29
35
  The property which triggered the guard error for the item.
30
36
 
31
- **propertyValue**: `unknown`
37
+ ##### propertyValue
38
+
39
+ `unknown`
32
40
 
33
41
  The property value which triggered the guard error for the item.
34
42
 
35
- **propertyOptions?**: `string`
43
+ ##### propertyOptions?
44
+
45
+ `string`
36
46
 
37
47
  The property options which might be allowed.
38
48
 
39
49
  #### Returns
40
50
 
41
- [`GuardError`](GuardError.md)
51
+ `GuardError`
42
52
 
43
53
  #### Overrides
44
54
 
45
- [`BaseError`](BaseError.md).[`constructor`](BaseError.md#constructors)
55
+ [`BaseError`](BaseError.md).[`constructor`](BaseError.md#constructor)
46
56
 
47
57
  ## Properties
48
58
 
@@ -66,7 +76,7 @@ Any additional information for the error.
66
76
 
67
77
  #### Index Signature
68
78
 
69
- \[`id`: `string`\]: `unknown`
79
+ \[`id`: `string`\]: `unknown`
70
80
 
71
81
  #### Inherited from
72
82
 
@@ -102,7 +112,9 @@ Construct an error from an existing one.
102
112
 
103
113
  #### Parameters
104
114
 
105
- **err**: `unknown`
115
+ ##### err
116
+
117
+ `unknown`
106
118
 
107
119
  The existing error.
108
120
 
@@ -126,7 +138,9 @@ Flatten an error tree.
126
138
 
127
139
  #### Parameters
128
140
 
129
- **err**: `unknown`
141
+ ##### err
142
+
143
+ `unknown`
130
144
 
131
145
  The starting error.
132
146
 
@@ -150,10 +164,12 @@ Expand an error tree.
150
164
 
151
165
  #### Parameters
152
166
 
153
- **errors**: `undefined` \| [`IError`](../interfaces/IError.md)[]
167
+ ##### errors
154
168
 
155
169
  The list of errors to expand.
156
170
 
171
+ `undefined` | [`IError`](../interfaces/IError.md)[]
172
+
157
173
  #### Returns
158
174
 
159
175
  `undefined` \| [`IError`](../interfaces/IError.md)
@@ -174,14 +190,18 @@ Test to see if the error has the specified error name.
174
190
 
175
191
  #### Parameters
176
192
 
177
- **error**: `unknown`
193
+ ##### error
194
+
195
+ `unknown`
178
196
 
179
197
  The error to test.
180
198
 
181
- **name**: `string` \| `RegExp`
199
+ ##### name
182
200
 
183
201
  The name to check for.
184
202
 
203
+ `string` | `RegExp`
204
+
185
205
  #### Returns
186
206
 
187
207
  `error is BaseError`
@@ -202,14 +222,18 @@ Test to see if the error has the specified error message.
202
222
 
203
223
  #### Parameters
204
224
 
205
- **error**: `unknown`
225
+ ##### error
226
+
227
+ `unknown`
206
228
 
207
229
  The error to test.
208
230
 
209
- **message**: `string` \| `RegExp`
231
+ ##### message
210
232
 
211
233
  The message to check for.
212
234
 
235
+ `string` | `RegExp`
236
+
213
237
  #### Returns
214
238
 
215
239
  `error is BaseError`
@@ -230,14 +254,18 @@ Test to see if the error has the specified error code.
230
254
 
231
255
  #### Parameters
232
256
 
233
- **error**: `unknown`
257
+ ##### error
258
+
259
+ `unknown`
234
260
 
235
261
  The error to test.
236
262
 
237
- **code**: `string` \| `RegExp`
263
+ ##### code
238
264
 
239
265
  The code to check for.
240
266
 
267
+ `string` | `RegExp`
268
+
241
269
  #### Returns
242
270
 
243
271
  `boolean`
@@ -258,14 +286,18 @@ Test to see if any of the errors or children have the given error name.
258
286
 
259
287
  #### Parameters
260
288
 
261
- **error**: `unknown`
289
+ ##### error
290
+
291
+ `unknown`
262
292
 
263
293
  The error to test.
264
294
 
265
- **name**: `string` \| `RegExp`
295
+ ##### name
266
296
 
267
297
  The name to check for.
268
298
 
299
+ `string` | `RegExp`
300
+
269
301
  #### Returns
270
302
 
271
303
  `error is BaseError`
@@ -286,14 +318,18 @@ Test to see if any of the errors or children have the given error message.
286
318
 
287
319
  #### Parameters
288
320
 
289
- **error**: `unknown`
321
+ ##### error
322
+
323
+ `unknown`
290
324
 
291
325
  The error to test.
292
326
 
293
- **message**: `string` \| `RegExp`
327
+ ##### message
294
328
 
295
329
  The message to check for.
296
330
 
331
+ `string` | `RegExp`
332
+
297
333
  #### Returns
298
334
 
299
335
  `error is BaseError`
@@ -314,11 +350,15 @@ Test to see if any of the errors or children are from a specific class.
314
350
 
315
351
  #### Parameters
316
352
 
317
- **error**: `unknown`
353
+ ##### error
354
+
355
+ `unknown`
318
356
 
319
357
  The error to test.
320
358
 
321
- **cls**: `string`
359
+ ##### cls
360
+
361
+ `string`
322
362
 
323
363
  The class to check for.
324
364
 
@@ -342,14 +382,18 @@ Test to see if any of the errors or children have the given error code.
342
382
 
343
383
  #### Parameters
344
384
 
345
- **error**: `unknown`
385
+ ##### error
386
+
387
+ `unknown`
346
388
 
347
389
  The error to test.
348
390
 
349
- **code**: `string` \| `RegExp`
391
+ ##### code
350
392
 
351
393
  The code to check for.
352
394
 
395
+ `string` | `RegExp`
396
+
353
397
  #### Returns
354
398
 
355
399
  `error is BaseError`
@@ -362,12 +406,46 @@ True if the error has the name.
362
406
 
363
407
  ***
364
408
 
409
+ ### isEmpty()
410
+
411
+ > `static` **isEmpty**(`err`): `boolean`
412
+
413
+ Is the error empty.
414
+
415
+ #### Parameters
416
+
417
+ ##### err
418
+
419
+ [`IError`](../interfaces/IError.md)
420
+
421
+ The error to check for being empty.
422
+
423
+ #### Returns
424
+
425
+ `boolean`
426
+
427
+ True if the error is empty.
428
+
429
+ #### Inherited from
430
+
431
+ [`BaseError`](BaseError.md).[`isEmpty`](BaseError.md#isempty)
432
+
433
+ ***
434
+
365
435
  ### toJsonObject()
366
436
 
367
- > **toJsonObject**(): [`IError`](../interfaces/IError.md)
437
+ > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
368
438
 
369
439
  Serialize the error to the error model.
370
440
 
441
+ #### Parameters
442
+
443
+ ##### includeStackTrace?
444
+
445
+ `boolean`
446
+
447
+ Whether to include the error stack in the model, defaults to false.
448
+
371
449
  #### Returns
372
450
 
373
451
  [`IError`](../interfaces/IError.md)