@twin.org/core 0.0.1 → 0.0.2-next.11

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 (40) hide show
  1. package/dist/cjs/index.cjs +915 -849
  2. package/dist/esm/index.mjs +915 -849
  3. package/dist/types/errors/alreadyExistsError.d.ts +2 -2
  4. package/dist/types/errors/baseError.d.ts +23 -4
  5. package/dist/types/errors/conflictError.d.ts +2 -2
  6. package/dist/types/errors/generalError.d.ts +2 -2
  7. package/dist/types/errors/notFoundError.d.ts +2 -2
  8. package/dist/types/errors/notSupportedError.d.ts +2 -2
  9. package/dist/types/errors/unauthorizedError.d.ts +2 -2
  10. package/dist/types/errors/unprocessableError.d.ts +2 -2
  11. package/dist/types/factories/factory.d.ts +1 -1
  12. package/dist/types/helpers/errorHelper.d.ts +3 -3
  13. package/dist/types/models/IComponent.d.ts +6 -15
  14. package/dist/types/models/IError.d.ts +2 -2
  15. package/dist/types/utils/is.d.ts +6 -0
  16. package/docs/changelog.md +229 -0
  17. package/docs/reference/classes/AlreadyExistsError.md +91 -7
  18. package/docs/reference/classes/ArrayHelper.md +0 -8
  19. package/docs/reference/classes/BaseError.md +83 -7
  20. package/docs/reference/classes/ConflictError.md +91 -7
  21. package/docs/reference/classes/EnvHelper.md +1 -1
  22. package/docs/reference/classes/ErrorHelper.md +3 -3
  23. package/docs/reference/classes/Factory.md +2 -2
  24. package/docs/reference/classes/GeneralError.md +91 -7
  25. package/docs/reference/classes/GuardError.md +88 -4
  26. package/docs/reference/classes/Guards.md +2 -2
  27. package/docs/reference/classes/I18n.md +2 -2
  28. package/docs/reference/classes/Is.md +30 -2
  29. package/docs/reference/classes/NotFoundError.md +91 -7
  30. package/docs/reference/classes/NotImplementedError.md +88 -4
  31. package/docs/reference/classes/NotSupportedError.md +91 -7
  32. package/docs/reference/classes/UnauthorizedError.md +91 -7
  33. package/docs/reference/classes/UnprocessableError.md +91 -7
  34. package/docs/reference/classes/Validation.md +1 -1
  35. package/docs/reference/classes/ValidationError.md +88 -4
  36. package/docs/reference/interfaces/IComponent.md +9 -21
  37. package/docs/reference/interfaces/IError.md +3 -3
  38. package/docs/reference/variables/CoerceType.md +1 -1
  39. package/docs/reference/variables/CompressionType.md +1 -1
  40. package/package.json +2 -2
@@ -27,7 +27,7 @@ Class to handle errors.
27
27
 
28
28
  ### Constructor
29
29
 
30
- > **new BaseError**(`name`, `source`, `message`, `properties?`, `inner?`): `BaseError`
30
+ > **new BaseError**(`name`, `source`, `message`, `properties?`, `cause?`): `BaseError`
31
31
 
32
32
  Create a new instance of BaseError.
33
33
 
@@ -55,11 +55,11 @@ The message as a code.
55
55
 
56
56
  Any additional information for the error.
57
57
 
58
- ##### inner?
58
+ ##### cause?
59
59
 
60
60
  `unknown`
61
61
 
62
- The inner error if we have wrapped another error.
62
+ The cause of error if we have wrapped another error.
63
63
 
64
64
  #### Returns
65
65
 
@@ -99,15 +99,19 @@ Any additional information for the error.
99
99
 
100
100
  ***
101
101
 
102
- ### inner?
102
+ ### cause?
103
103
 
104
- > `optional` **inner**: [`IError`](../interfaces/IError.md)
104
+ > `optional` **cause**: [`IError`](../interfaces/IError.md)
105
105
 
106
- The inner error if there was one.
106
+ The cause of the error.
107
107
 
108
108
  #### Implementation of
109
109
 
110
- [`IError`](../interfaces/IError.md).[`inner`](../interfaces/IError.md#inner)
110
+ [`IError`](../interfaces/IError.md).[`cause`](../interfaces/IError.md#cause)
111
+
112
+ #### Overrides
113
+
114
+ `Error.cause`
111
115
 
112
116
  ## Methods
113
117
 
@@ -373,6 +377,78 @@ True if the error has the name.
373
377
 
374
378
  ***
375
379
 
380
+ ### isEmpty()
381
+
382
+ > `static` **isEmpty**(`err`): `boolean`
383
+
384
+ Is the error empty, i.e. does it have no message, source, properties, or cause?
385
+
386
+ #### Parameters
387
+
388
+ ##### err
389
+
390
+ [`IError`](../interfaces/IError.md)
391
+
392
+ The error to check for being empty.
393
+
394
+ #### Returns
395
+
396
+ `boolean`
397
+
398
+ True if the error is empty.
399
+
400
+ ***
401
+
402
+ ### isAggregateError()
403
+
404
+ > `static` **isAggregateError**(`err`): `err is AggregateError`
405
+
406
+ Is the error an aggregate error.
407
+
408
+ #### Parameters
409
+
410
+ ##### err
411
+
412
+ `unknown`
413
+
414
+ The error to check for being an aggregate error.
415
+
416
+ #### Returns
417
+
418
+ `err is AggregateError`
419
+
420
+ True if the error is an aggregate error.
421
+
422
+ ***
423
+
424
+ ### fromAggregate()
425
+
426
+ > `static` **fromAggregate**(`err`, `includeStackTrace?`): [`IError`](../interfaces/IError.md)[]
427
+
428
+ Convert the aggregate error to an array of errors.
429
+
430
+ #### Parameters
431
+
432
+ ##### err
433
+
434
+ `unknown`
435
+
436
+ The error to convert.
437
+
438
+ ##### includeStackTrace?
439
+
440
+ `boolean`
441
+
442
+ Whether to include the error stack in the model, defaults to false.
443
+
444
+ #### Returns
445
+
446
+ [`IError`](../interfaces/IError.md)[]
447
+
448
+ The array of errors.
449
+
450
+ ***
451
+
376
452
  ### toJsonObject()
377
453
 
378
454
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -10,7 +10,7 @@ Class to handle errors which are triggered by conflicting data.
10
10
 
11
11
  ### Constructor
12
12
 
13
- > **new ConflictError**(`source`, `message`, `conflictId?`, `conflicts?`, `inner?`): `ConflictError`
13
+ > **new ConflictError**(`source`, `message`, `conflictId?`, `conflicts?`, `cause?`): `ConflictError`
14
14
 
15
15
  Create a new instance of ConflictError.
16
16
 
@@ -40,11 +40,11 @@ The id that has conflicts.
40
40
 
41
41
  The conflicts that occurred.
42
42
 
43
- ##### inner?
43
+ ##### cause?
44
44
 
45
45
  `unknown`
46
46
 
47
- The inner error if we have wrapped another error.
47
+ The cause or the error if we have wrapped another error.
48
48
 
49
49
  #### Returns
50
50
 
@@ -84,15 +84,15 @@ Any additional information for the error.
84
84
 
85
85
  ***
86
86
 
87
- ### inner?
87
+ ### cause?
88
88
 
89
- > `optional` **inner**: [`IError`](../interfaces/IError.md)
89
+ > `optional` **cause**: [`IError`](../interfaces/IError.md)
90
90
 
91
- The inner error if there was one.
91
+ The cause of the error.
92
92
 
93
93
  #### Inherited from
94
94
 
95
- [`BaseError`](BaseError.md).[`inner`](BaseError.md#inner)
95
+ [`BaseError`](BaseError.md).[`cause`](BaseError.md#cause)
96
96
 
97
97
  ***
98
98
 
@@ -406,6 +406,90 @@ True if the error has the name.
406
406
 
407
407
  ***
408
408
 
409
+ ### isEmpty()
410
+
411
+ > `static` **isEmpty**(`err`): `boolean`
412
+
413
+ Is the error empty, i.e. does it have no message, source, properties, or cause?
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
+
435
+ ### isAggregateError()
436
+
437
+ > `static` **isAggregateError**(`err`): `err is AggregateError`
438
+
439
+ Is the error an aggregate error.
440
+
441
+ #### Parameters
442
+
443
+ ##### err
444
+
445
+ `unknown`
446
+
447
+ The error to check for being an aggregate error.
448
+
449
+ #### Returns
450
+
451
+ `err is AggregateError`
452
+
453
+ True if the error is an aggregate error.
454
+
455
+ #### Inherited from
456
+
457
+ [`BaseError`](BaseError.md).[`isAggregateError`](BaseError.md#isaggregateerror)
458
+
459
+ ***
460
+
461
+ ### fromAggregate()
462
+
463
+ > `static` **fromAggregate**(`err`, `includeStackTrace?`): [`IError`](../interfaces/IError.md)[]
464
+
465
+ Convert the aggregate error to an array of errors.
466
+
467
+ #### Parameters
468
+
469
+ ##### err
470
+
471
+ `unknown`
472
+
473
+ The error to convert.
474
+
475
+ ##### includeStackTrace?
476
+
477
+ `boolean`
478
+
479
+ Whether to include the error stack in the model, defaults to false.
480
+
481
+ #### Returns
482
+
483
+ [`IError`](../interfaces/IError.md)[]
484
+
485
+ The array of errors.
486
+
487
+ #### Inherited from
488
+
489
+ [`BaseError`](BaseError.md).[`fromAggregate`](BaseError.md#fromaggregate)
490
+
491
+ ***
492
+
409
493
  ### toJsonObject()
410
494
 
411
495
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -24,7 +24,7 @@ Get the environment variable as an object with camel cased names.
24
24
 
25
25
  ##### T
26
26
 
27
- `T` = \{[`id`: `string`]: `string`; \}
27
+ `T` = \{\[`id`: `string`\]: `string`; \}
28
28
 
29
29
  #### Parameters
30
30
 
@@ -38,7 +38,7 @@ Whether to include error details, defaults to false.
38
38
 
39
39
  `string`[]
40
40
 
41
- The error formatted including any inner errors.
41
+ The error formatted including any causes errors.
42
42
 
43
43
  ***
44
44
 
@@ -46,7 +46,7 @@ The error formatted including any inner errors.
46
46
 
47
47
  > `static` **localizeErrors**(`error`): [`IError`](../interfaces/IError.md)[]
48
48
 
49
- Localize the content of an error and any inner errors.
49
+ Localize the content of an error and any causes.
50
50
 
51
51
  #### Parameters
52
52
 
@@ -68,7 +68,7 @@ The localized version of the errors flattened.
68
68
 
69
69
  > `static` **formatValidationErrors**(`error`): `undefined` \| `string`
70
70
 
71
- Localize the content of an error and any inner errors.
71
+ Localize the content of an error and any causes.
72
72
 
73
73
  #### Parameters
74
74
 
@@ -186,7 +186,7 @@ GeneralError if no item exists to get.
186
186
 
187
187
  ### getIfExists()
188
188
 
189
- > **getIfExists**\<`U`\>(`name`): `undefined` \| `U`
189
+ > **getIfExists**\<`U`\>(`name?`): `undefined` \| `U`
190
190
 
191
191
  Get a generator instance with no exceptions.
192
192
 
@@ -198,7 +198,7 @@ Get a generator instance with no exceptions.
198
198
 
199
199
  #### Parameters
200
200
 
201
- ##### name
201
+ ##### name?
202
202
 
203
203
  `string`
204
204
 
@@ -10,7 +10,7 @@ Class to handle errors.
10
10
 
11
11
  ### Constructor
12
12
 
13
- > **new GeneralError**(`source`, `message`, `properties?`, `inner?`): `GeneralError`
13
+ > **new GeneralError**(`source`, `message`, `properties?`, `cause?`): `GeneralError`
14
14
 
15
15
  Create a new instance of GeneralError.
16
16
 
@@ -32,11 +32,11 @@ The message as a code.
32
32
 
33
33
  Any additional information for the error.
34
34
 
35
- ##### inner?
35
+ ##### cause?
36
36
 
37
37
  `unknown`
38
38
 
39
- The inner error if we have wrapped another error.
39
+ The cause of the error if we have wrapped another error.
40
40
 
41
41
  #### Returns
42
42
 
@@ -76,15 +76,15 @@ Any additional information for the error.
76
76
 
77
77
  ***
78
78
 
79
- ### inner?
79
+ ### cause?
80
80
 
81
- > `optional` **inner**: [`IError`](../interfaces/IError.md)
81
+ > `optional` **cause**: [`IError`](../interfaces/IError.md)
82
82
 
83
- The inner error if there was one.
83
+ The cause of the error.
84
84
 
85
85
  #### Inherited from
86
86
 
87
- [`BaseError`](BaseError.md).[`inner`](BaseError.md#inner)
87
+ [`BaseError`](BaseError.md).[`cause`](BaseError.md#cause)
88
88
 
89
89
  ***
90
90
 
@@ -398,6 +398,90 @@ True if the error has the name.
398
398
 
399
399
  ***
400
400
 
401
+ ### isEmpty()
402
+
403
+ > `static` **isEmpty**(`err`): `boolean`
404
+
405
+ Is the error empty, i.e. does it have no message, source, properties, or cause?
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
+
427
+ ### isAggregateError()
428
+
429
+ > `static` **isAggregateError**(`err`): `err is AggregateError`
430
+
431
+ Is the error an aggregate error.
432
+
433
+ #### Parameters
434
+
435
+ ##### err
436
+
437
+ `unknown`
438
+
439
+ The error to check for being an aggregate error.
440
+
441
+ #### Returns
442
+
443
+ `err is AggregateError`
444
+
445
+ True if the error is an aggregate error.
446
+
447
+ #### Inherited from
448
+
449
+ [`BaseError`](BaseError.md).[`isAggregateError`](BaseError.md#isaggregateerror)
450
+
451
+ ***
452
+
453
+ ### fromAggregate()
454
+
455
+ > `static` **fromAggregate**(`err`, `includeStackTrace?`): [`IError`](../interfaces/IError.md)[]
456
+
457
+ Convert the aggregate error to an array of errors.
458
+
459
+ #### Parameters
460
+
461
+ ##### err
462
+
463
+ `unknown`
464
+
465
+ The error to convert.
466
+
467
+ ##### includeStackTrace?
468
+
469
+ `boolean`
470
+
471
+ Whether to include the error stack in the model, defaults to false.
472
+
473
+ #### Returns
474
+
475
+ [`IError`](../interfaces/IError.md)[]
476
+
477
+ The array of errors.
478
+
479
+ #### Inherited from
480
+
481
+ [`BaseError`](BaseError.md).[`fromAggregate`](BaseError.md#fromaggregate)
482
+
483
+ ***
484
+
401
485
  ### toJsonObject()
402
486
 
403
487
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -84,15 +84,15 @@ Any additional information for the error.
84
84
 
85
85
  ***
86
86
 
87
- ### inner?
87
+ ### cause?
88
88
 
89
- > `optional` **inner**: [`IError`](../interfaces/IError.md)
89
+ > `optional` **cause**: [`IError`](../interfaces/IError.md)
90
90
 
91
- The inner error if there was one.
91
+ The cause of the error.
92
92
 
93
93
  #### Inherited from
94
94
 
95
- [`BaseError`](BaseError.md).[`inner`](BaseError.md#inner)
95
+ [`BaseError`](BaseError.md).[`cause`](BaseError.md#cause)
96
96
 
97
97
  ***
98
98
 
@@ -406,6 +406,90 @@ True if the error has the name.
406
406
 
407
407
  ***
408
408
 
409
+ ### isEmpty()
410
+
411
+ > `static` **isEmpty**(`err`): `boolean`
412
+
413
+ Is the error empty, i.e. does it have no message, source, properties, or cause?
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
+
435
+ ### isAggregateError()
436
+
437
+ > `static` **isAggregateError**(`err`): `err is AggregateError`
438
+
439
+ Is the error an aggregate error.
440
+
441
+ #### Parameters
442
+
443
+ ##### err
444
+
445
+ `unknown`
446
+
447
+ The error to check for being an aggregate error.
448
+
449
+ #### Returns
450
+
451
+ `err is AggregateError`
452
+
453
+ True if the error is an aggregate error.
454
+
455
+ #### Inherited from
456
+
457
+ [`BaseError`](BaseError.md).[`isAggregateError`](BaseError.md#isaggregateerror)
458
+
459
+ ***
460
+
461
+ ### fromAggregate()
462
+
463
+ > `static` **fromAggregate**(`err`, `includeStackTrace?`): [`IError`](../interfaces/IError.md)[]
464
+
465
+ Convert the aggregate error to an array of errors.
466
+
467
+ #### Parameters
468
+
469
+ ##### err
470
+
471
+ `unknown`
472
+
473
+ The error to convert.
474
+
475
+ ##### includeStackTrace?
476
+
477
+ `boolean`
478
+
479
+ Whether to include the error stack in the model, defaults to false.
480
+
481
+ #### Returns
482
+
483
+ [`IError`](../interfaces/IError.md)[]
484
+
485
+ The array of errors.
486
+
487
+ #### Inherited from
488
+
489
+ [`BaseError`](BaseError.md).[`fromAggregate`](BaseError.md#fromaggregate)
490
+
491
+ ***
492
+
409
493
  ### toJsonObject()
410
494
 
411
495
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -618,7 +618,7 @@ Is the property an object.
618
618
 
619
619
  ##### T
620
620
 
621
- `T` = \{[`id`: `string`]: `unknown`; \}
621
+ `T` = \{\[`id`: `string`\]: `unknown`; \}
622
622
 
623
623
  #### Parameters
624
624
 
@@ -660,7 +660,7 @@ Is the property is an object with at least one property.
660
660
 
661
661
  ##### T
662
662
 
663
- `T` = \{[`id`: `string`]: `unknown`; \}
663
+ `T` = \{\[`id`: `string`\]: `unknown`; \}
664
664
 
665
665
  #### Parameters
666
666
 
@@ -84,7 +84,7 @@ The dictionary to add.
84
84
 
85
85
  ### getDictionary()
86
86
 
87
- > `static` **getDictionary**(`locale`): `undefined` \| \{[`key`: `string`]: `string`; \}
87
+ > `static` **getDictionary**(`locale`): `undefined` \| \{\[`key`: `string`\]: `string`; \}
88
88
 
89
89
  Get a locale dictionary.
90
90
 
@@ -98,7 +98,7 @@ The locale.
98
98
 
99
99
  #### Returns
100
100
 
101
- `undefined` \| \{[`key`: `string`]: `string`; \}
101
+ `undefined` \| \{\[`key`: `string`\]: `string`; \}
102
102
 
103
103
  The dictionary of undefined if it does not exist.
104
104
 
@@ -548,7 +548,7 @@ Is the value an object.
548
548
 
549
549
  ##### T
550
550
 
551
- `T` = \{[`id`: `string`]: `unknown`; \}
551
+ `T` = \{\[`id`: `string`\]: `unknown`; \}
552
552
 
553
553
  #### Parameters
554
554
 
@@ -576,7 +576,7 @@ Is the value an object with at least one property.
576
576
 
577
577
  ##### T
578
578
 
579
- `T` = \{[`id`: `string`]: `unknown`; \}
579
+ `T` = \{\[`id`: `string`\]: `unknown`; \}
580
580
 
581
581
  #### Parameters
582
582
 
@@ -819,3 +819,31 @@ The value to test.
819
819
  `value is RegExp`
820
820
 
821
821
  True if the value is a regexp.
822
+
823
+ ***
824
+
825
+ ### class()
826
+
827
+ > `static` **class**\<`T`\>(`obj`): `obj is (args: any[]) => T`
828
+
829
+ Is the provided object a class constructor.
830
+
831
+ #### Type Parameters
832
+
833
+ ##### T
834
+
835
+ `T` = `unknown`
836
+
837
+ #### Parameters
838
+
839
+ ##### obj
840
+
841
+ `unknown`
842
+
843
+ The object to check.
844
+
845
+ #### Returns
846
+
847
+ `obj is (args: any[]) => T`
848
+
849
+ True if the object is a class, false otherwise.