@twin.org/core 0.0.2-next.4 → 0.0.2-next.6

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 (36) hide show
  1. package/dist/cjs/index.cjs +76 -46
  2. package/dist/esm/index.mjs +76 -46
  3. package/dist/types/errors/alreadyExistsError.d.ts +2 -2
  4. package/dist/types/errors/baseError.d.ts +18 -5
  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/docs/changelog.md +34 -0
  16. package/docs/reference/classes/AlreadyExistsError.md +66 -8
  17. package/docs/reference/classes/BaseError.md +62 -8
  18. package/docs/reference/classes/ConflictError.md +66 -8
  19. package/docs/reference/classes/EnvHelper.md +1 -1
  20. package/docs/reference/classes/ErrorHelper.md +3 -3
  21. package/docs/reference/classes/Factory.md +2 -2
  22. package/docs/reference/classes/GeneralError.md +66 -8
  23. package/docs/reference/classes/GuardError.md +63 -5
  24. package/docs/reference/classes/Guards.md +2 -2
  25. package/docs/reference/classes/I18n.md +2 -2
  26. package/docs/reference/classes/Is.md +2 -2
  27. package/docs/reference/classes/NotFoundError.md +66 -8
  28. package/docs/reference/classes/NotImplementedError.md +63 -5
  29. package/docs/reference/classes/NotSupportedError.md +66 -8
  30. package/docs/reference/classes/UnauthorizedError.md +66 -8
  31. package/docs/reference/classes/UnprocessableError.md +66 -8
  32. package/docs/reference/classes/Validation.md +1 -1
  33. package/docs/reference/classes/ValidationError.md +63 -5
  34. package/docs/reference/interfaces/IComponent.md +9 -21
  35. package/docs/reference/interfaces/IError.md +3 -3
  36. package/package.json +2 -2
@@ -13,7 +13,7 @@ export declare class ConflictError extends BaseError {
13
13
  * @param message The message as a code.
14
14
  * @param conflictId The id that has conflicts.
15
15
  * @param conflicts The conflicts that occurred.
16
- * @param inner The inner error if we have wrapped another error.
16
+ * @param cause The cause or the error if we have wrapped another error.
17
17
  */
18
- constructor(source: string, message: string, conflictId?: string, conflicts?: string[], inner?: unknown);
18
+ constructor(source: string, message: string, conflictId?: string, conflicts?: string[], cause?: unknown);
19
19
  }
@@ -12,9 +12,9 @@ export declare class GeneralError extends BaseError {
12
12
  * @param source The source of the error.
13
13
  * @param message The message as a code.
14
14
  * @param properties Any additional information for the error.
15
- * @param inner The inner error if we have wrapped another error.
15
+ * @param cause The cause of the error if we have wrapped another error.
16
16
  */
17
17
  constructor(source: string, message: string, properties?: {
18
18
  [id: string]: unknown;
19
- }, inner?: unknown);
19
+ }, cause?: unknown);
20
20
  }
@@ -12,7 +12,7 @@ export declare class NotFoundError extends BaseError {
12
12
  * @param source The source of the error.
13
13
  * @param message The message as a code.
14
14
  * @param notFoundId The id for the item.
15
- * @param inner The inner error if we have wrapped another error.
15
+ * @param cause The cause of the error if we have wrapped another error.
16
16
  */
17
- constructor(source: string, message: string, notFoundId?: string, inner?: unknown);
17
+ constructor(source: string, message: string, notFoundId?: string, cause?: unknown);
18
18
  }
@@ -11,7 +11,7 @@ export declare class NotSupportedError extends BaseError {
11
11
  * Create a new instance of NotSupportedError.
12
12
  * @param source The source of the error.
13
13
  * @param message The message as a code.
14
- * @param inner The inner error if we have wrapped another error.
14
+ * @param cause The cause of the error if we have wrapped another error.
15
15
  */
16
- constructor(source: string, message: string, inner?: unknown);
16
+ constructor(source: string, message: string, cause?: unknown);
17
17
  }
@@ -11,7 +11,7 @@ export declare class UnauthorizedError extends BaseError {
11
11
  * Create a new instance of UnauthorizedError.
12
12
  * @param source The source of the error.
13
13
  * @param message The message as a code.
14
- * @param inner The inner error if we have wrapped another error.
14
+ * @param cause The cause of the error if we have wrapped another error.
15
15
  */
16
- constructor(source: string, message: string, inner?: unknown);
16
+ constructor(source: string, message: string, cause?: unknown);
17
17
  }
@@ -12,9 +12,9 @@ export declare class UnprocessableError extends BaseError {
12
12
  * @param source The source of the error.
13
13
  * @param message The message as a code.
14
14
  * @param properties Any additional information for the error.
15
- * @param inner The inner error if we have wrapped another error.
15
+ * @param cause The cause of the error if we have wrapped another error.
16
16
  */
17
17
  constructor(source: string, message: string, properties?: {
18
18
  [id: string]: unknown;
19
- }, inner?: unknown);
19
+ }, cause?: unknown);
20
20
  }
@@ -51,7 +51,7 @@ export declare class Factory<T> {
51
51
  * @param name The name of the instance to generate.
52
52
  * @returns An instance of the item or undefined if it does not exist.
53
53
  */
54
- getIfExists<U extends T>(name: string): U | undefined;
54
+ getIfExists<U extends T>(name?: string): U | undefined;
55
55
  /**
56
56
  * Remove all the instances and leave the generators intact.
57
57
  */
@@ -7,17 +7,17 @@ export declare class ErrorHelper {
7
7
  * Format Errors and returns just their messages.
8
8
  * @param error The error to format.
9
9
  * @param includeDetails Whether to include error details, defaults to false.
10
- * @returns The error formatted including any inner errors.
10
+ * @returns The error formatted including any causes errors.
11
11
  */
12
12
  static formatErrors(error: unknown, includeDetails?: boolean): string[];
13
13
  /**
14
- * Localize the content of an error and any inner errors.
14
+ * Localize the content of an error and any causes.
15
15
  * @param error The error to format.
16
16
  * @returns The localized version of the errors flattened.
17
17
  */
18
18
  static localizeErrors(error: unknown): IError[];
19
19
  /**
20
- * Localize the content of an error and any inner errors.
20
+ * Localize the content of an error and any causes.
21
21
  * @param error The error to format.
22
22
  * @returns The localized version of the errors flattened.
23
23
  */
@@ -8,31 +8,22 @@ export interface IComponent {
8
8
  readonly CLASS_NAME: string;
9
9
  /**
10
10
  * Bootstrap the component by creating and initializing any resources it needs.
11
- * @param nodeLoggingConnectorType The node logging connector type, defaults to "node-logging".
12
- * @param componentState A persistent state which can be modified by the method.
11
+ * @param nodeLoggingComponentType The node logging component type.
13
12
  * @returns True if the bootstrapping process was successful.
14
13
  */
15
- bootstrap?(nodeLoggingConnectorType: string | undefined, componentState?: {
16
- [id: string]: unknown;
17
- }): Promise<boolean>;
14
+ bootstrap?(nodeLoggingComponentType: string | undefined): Promise<boolean>;
18
15
  /**
19
16
  * The component needs to be started when the node is initialized.
20
17
  * @param nodeIdentity The identity of the node starting the component.
21
- * @param nodeLoggingConnectorType The node logging connector type, defaults to "node-logging".
22
- * @param componentState A persistent state which can be modified by the method.
18
+ * @param nodeLoggingComponentType The node logging component type.
23
19
  * @returns Nothing.
24
20
  */
25
- start?(nodeIdentity: string, nodeLoggingConnectorType: string | undefined, componentState?: {
26
- [id: string]: unknown;
27
- }): Promise<void>;
21
+ start?(nodeIdentity: string, nodeLoggingComponentType: string | undefined): Promise<void>;
28
22
  /**
29
23
  * The component needs to be stopped when the node is closed.
30
24
  * @param nodeIdentity The identity of the node stopping the component.
31
- * @param nodeLoggingConnectorType The node logging connector type, defaults to "node-logging".
32
- * @param componentState A persistent state which can be modified by the method.
25
+ * @param nodeLoggingComponentType The node logging component type.
33
26
  * @returns Nothing.
34
27
  */
35
- stop?(nodeIdentity: string, nodeLoggingConnectorType: string | undefined, componentState?: {
36
- [id: string]: unknown;
37
- }): Promise<void>;
28
+ stop?(nodeIdentity: string, nodeLoggingComponentType: string | undefined): Promise<void>;
38
29
  }
@@ -25,7 +25,7 @@ export interface IError {
25
25
  */
26
26
  stack?: string;
27
27
  /**
28
- * The inner error if there was one.
28
+ * The cause of the error if there was one.
29
29
  */
30
- inner?: IError;
30
+ cause?: IError;
31
31
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @twin.org/core - Changelog
2
2
 
3
+ ## [0.0.2-next.6](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.5...core-v0.0.2-next.6) (2025-08-27)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **core:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/nameof bumped from 0.0.2-next.5 to 0.0.2-next.6
16
+ * devDependencies
17
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.5 to 0.0.2-next.6
18
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.5 to 0.0.2-next.6
19
+
20
+ ## [0.0.2-next.5](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.4...core-v0.0.2-next.5) (2025-08-19)
21
+
22
+
23
+ ### Features
24
+
25
+ * use cause instead of inner for errors ([1f4acc4](https://github.com/twinfoundation/framework/commit/1f4acc4d7a6b71a134d9547da9bf40de1e1e49da))
26
+
27
+
28
+ ### Dependencies
29
+
30
+ * The following workspace dependencies were updated
31
+ * dependencies
32
+ * @twin.org/nameof bumped from 0.0.2-next.4 to 0.0.2-next.5
33
+ * devDependencies
34
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.4 to 0.0.2-next.5
35
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.4 to 0.0.2-next.5
36
+
3
37
  ## [0.0.2-next.4](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.3...core-v0.0.2-next.4) (2025-08-15)
4
38
 
5
39
 
@@ -10,7 +10,7 @@ Class to handle errors which are triggered by data already existing.
10
10
 
11
11
  ### Constructor
12
12
 
13
- > **new AlreadyExistsError**(`source`, `message`, `existingId?`, `inner?`): `AlreadyExistsError`
13
+ > **new AlreadyExistsError**(`source`, `message`, `existingId?`, `cause?`): `AlreadyExistsError`
14
14
 
15
15
  Create a new instance of AlreadyExistsError.
16
16
 
@@ -34,11 +34,11 @@ The message as a code.
34
34
 
35
35
  The id for the item.
36
36
 
37
- ##### inner?
37
+ ##### cause?
38
38
 
39
39
  `unknown`
40
40
 
41
- The inner error if we have wrapped another error.
41
+ The cause of the error if we have wrapped another error.
42
42
 
43
43
  #### Returns
44
44
 
@@ -86,15 +86,15 @@ Any additional information for the error.
86
86
 
87
87
  ***
88
88
 
89
- ### inner?
89
+ ### cause?
90
90
 
91
- > `optional` **inner**: [`IError`](../interfaces/IError.md)
91
+ > `optional` **cause**: [`IError`](../interfaces/IError.md)
92
92
 
93
- The inner error if there was one.
93
+ The cause of the error.
94
94
 
95
95
  #### Inherited from
96
96
 
97
- [`BaseError`](BaseError.md).[`inner`](BaseError.md#inner)
97
+ [`BaseError`](BaseError.md).[`cause`](BaseError.md#cause)
98
98
 
99
99
  ## Methods
100
100
 
@@ -404,7 +404,7 @@ True if the error has the name.
404
404
 
405
405
  > `static` **isEmpty**(`err`): `boolean`
406
406
 
407
- Is the error empty.
407
+ Is the error empty, i.e. does it have no message, source, properties, or cause?
408
408
 
409
409
  #### Parameters
410
410
 
@@ -426,6 +426,64 @@ True if the error is empty.
426
426
 
427
427
  ***
428
428
 
429
+ ### isAggregateError()
430
+
431
+ > `static` **isAggregateError**(`err`): `err is AggregateError`
432
+
433
+ Is the error an aggregate error.
434
+
435
+ #### Parameters
436
+
437
+ ##### err
438
+
439
+ `unknown`
440
+
441
+ The error to check for being an aggregate error.
442
+
443
+ #### Returns
444
+
445
+ `err is AggregateError`
446
+
447
+ True if the error is an aggregate error.
448
+
449
+ #### Inherited from
450
+
451
+ [`BaseError`](BaseError.md).[`isAggregateError`](BaseError.md#isaggregateerror)
452
+
453
+ ***
454
+
455
+ ### fromAggregate()
456
+
457
+ > `static` **fromAggregate**(`err`, `includeStackTrace?`): [`IError`](../interfaces/IError.md)[]
458
+
459
+ Convert the aggregate error to an array of errors.
460
+
461
+ #### Parameters
462
+
463
+ ##### err
464
+
465
+ `unknown`
466
+
467
+ The error to convert.
468
+
469
+ ##### includeStackTrace?
470
+
471
+ `boolean`
472
+
473
+ Whether to include the error stack in the model, defaults to false.
474
+
475
+ #### Returns
476
+
477
+ [`IError`](../interfaces/IError.md)[]
478
+
479
+ The array of errors.
480
+
481
+ #### Inherited from
482
+
483
+ [`BaseError`](BaseError.md).[`fromAggregate`](BaseError.md#fromaggregate)
484
+
485
+ ***
486
+
429
487
  ### toJsonObject()
430
488
 
431
489
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -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
 
@@ -377,7 +381,7 @@ True if the error has the name.
377
381
 
378
382
  > `static` **isEmpty**(`err`): `boolean`
379
383
 
380
- Is the error empty.
384
+ Is the error empty, i.e. does it have no message, source, properties, or cause?
381
385
 
382
386
  #### Parameters
383
387
 
@@ -395,6 +399,56 @@ True if the error is empty.
395
399
 
396
400
  ***
397
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
+
398
452
  ### toJsonObject()
399
453
 
400
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
 
@@ -410,7 +410,7 @@ True if the error has the name.
410
410
 
411
411
  > `static` **isEmpty**(`err`): `boolean`
412
412
 
413
- Is the error empty.
413
+ Is the error empty, i.e. does it have no message, source, properties, or cause?
414
414
 
415
415
  #### Parameters
416
416
 
@@ -432,6 +432,64 @@ True if the error is empty.
432
432
 
433
433
  ***
434
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
+
435
493
  ### toJsonObject()
436
494
 
437
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