@twin.org/core 0.0.1 → 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.
@@ -803,6 +803,17 @@ class BaseError extends Error {
803
803
  static someErrorCode(error, code) {
804
804
  return BaseError.flatten(error).some(e => BaseError.isErrorCode(e, code));
805
805
  }
806
+ /**
807
+ * Is the error empty.
808
+ * @param err The error to check for being empty.
809
+ * @returns True if the error is empty.
810
+ */
811
+ static isEmpty(err) {
812
+ return (!Is.stringValue(err.message) &&
813
+ !Is.stringValue(err.source) &&
814
+ !Is.objectValue(err.properties) &&
815
+ Is.empty(err.inner));
816
+ }
806
817
  /**
807
818
  * Serialize the error to the error model.
808
819
  * @param includeStackTrace Whether to include the error stack in the model, defaults to false.
@@ -801,6 +801,17 @@ class BaseError extends Error {
801
801
  static someErrorCode(error, code) {
802
802
  return BaseError.flatten(error).some(e => BaseError.isErrorCode(e, code));
803
803
  }
804
+ /**
805
+ * Is the error empty.
806
+ * @param err The error to check for being empty.
807
+ * @returns True if the error is empty.
808
+ */
809
+ static isEmpty(err) {
810
+ return (!Is.stringValue(err.message) &&
811
+ !Is.stringValue(err.source) &&
812
+ !Is.objectValue(err.properties) &&
813
+ Is.empty(err.inner));
814
+ }
804
815
  /**
805
816
  * Serialize the error to the error model.
806
817
  * @param includeStackTrace Whether to include the error stack in the model, defaults to false.
@@ -95,6 +95,12 @@ export declare class BaseError extends Error implements IError {
95
95
  * @returns True if the error has the name.
96
96
  */
97
97
  static someErrorCode(error: unknown, code: string | RegExp): error is BaseError;
98
+ /**
99
+ * Is the error empty.
100
+ * @param err The error to check for being empty.
101
+ * @returns True if the error is empty.
102
+ */
103
+ static isEmpty(err: IError): boolean;
98
104
  /**
99
105
  * Serialize the error to the error model.
100
106
  * @param includeStackTrace Whether to include the error stack in the model, defaults to false.
package/docs/changelog.md CHANGED
@@ -1,5 +1,98 @@
1
1
  # @twin.org/core - Changelog
2
2
 
3
+ ## [0.0.2-next.3](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.2...core-v0.0.2-next.3) (2025-08-06)
4
+
5
+
6
+ ### Features
7
+
8
+ * add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
9
+ * add ObjectOrArray and ArrayHelper methods ([0ac9077](https://github.com/twinfoundation/framework/commit/0ac907764d64b38ad1b04b0e9c3027055b527559))
10
+ * add rsa cipher support ([7af6cc6](https://github.com/twinfoundation/framework/commit/7af6cc67512d3363bd4a2f2e87bd7733c2800147))
11
+ * add set method for async caches ([ba34b55](https://github.com/twinfoundation/framework/commit/ba34b55e651ad56ab8fc59e139e4af631c19cda0))
12
+ * add zlib/deflate mime types detection ([72c472b](https://github.com/twinfoundation/framework/commit/72c472b5a35a973e7109336f5b6cdd84dbb8bbcb))
13
+ * async cache don't cache failures unless requested ([658ec4b](https://github.com/twinfoundation/framework/commit/658ec4b67a58a075de4702a3886d151e25ad3ddc))
14
+ * improve base error data extraction ([dccc933](https://github.com/twinfoundation/framework/commit/dccc93361a1544b41db0e7c126ff90e858d87960))
15
+ * improve error display in CLI ([94b6ca8](https://github.com/twinfoundation/framework/commit/94b6ca8bdcfe3ca7671c4095b436ea7bddaae98e))
16
+ * propagate includeStackTrace on error conversion ([8471cbb](https://github.com/twinfoundation/framework/commit/8471cbb71f8fc98247a0e92126c438c1a8b04d9b))
17
+ * propagate includeStackTrace on error conversion ([818337d](https://github.com/twinfoundation/framework/commit/818337d50d14bf5a7e8b3204649aa7527115cca9))
18
+ * relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
19
+ * simplify async set ([#121](https://github.com/twinfoundation/framework/issues/121)) ([2693c32](https://github.com/twinfoundation/framework/commit/2693c325266fd1a0aede6f1336c8b254c981a9ca))
20
+ * support indexed properties set in objects ([b9c001d](https://github.com/twinfoundation/framework/commit/b9c001dc4614f6ff7486f4370735a553613d823a))
21
+ * update dependencies ([f3bd015](https://github.com/twinfoundation/framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
22
+ * use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/nameof bumped from 0.0.2-next.2 to 0.0.2-next.3
30
+ * devDependencies
31
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.2 to 0.0.2-next.3
32
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.2 to 0.0.2-next.3
33
+
34
+ ## [0.0.2-next.2](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.1...core-v0.0.2-next.2) (2025-08-06)
35
+
36
+
37
+ ### Features
38
+
39
+ * add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
40
+ * add ObjectOrArray and ArrayHelper methods ([0ac9077](https://github.com/twinfoundation/framework/commit/0ac907764d64b38ad1b04b0e9c3027055b527559))
41
+ * add rsa cipher support ([7af6cc6](https://github.com/twinfoundation/framework/commit/7af6cc67512d3363bd4a2f2e87bd7733c2800147))
42
+ * add set method for async caches ([ba34b55](https://github.com/twinfoundation/framework/commit/ba34b55e651ad56ab8fc59e139e4af631c19cda0))
43
+ * add zlib/deflate mime types detection ([72c472b](https://github.com/twinfoundation/framework/commit/72c472b5a35a973e7109336f5b6cdd84dbb8bbcb))
44
+ * async cache don't cache failures unless requested ([658ec4b](https://github.com/twinfoundation/framework/commit/658ec4b67a58a075de4702a3886d151e25ad3ddc))
45
+ * improve base error data extraction ([dccc933](https://github.com/twinfoundation/framework/commit/dccc93361a1544b41db0e7c126ff90e858d87960))
46
+ * improve error display in CLI ([94b6ca8](https://github.com/twinfoundation/framework/commit/94b6ca8bdcfe3ca7671c4095b436ea7bddaae98e))
47
+ * propagate includeStackTrace on error conversion ([8471cbb](https://github.com/twinfoundation/framework/commit/8471cbb71f8fc98247a0e92126c438c1a8b04d9b))
48
+ * propagate includeStackTrace on error conversion ([818337d](https://github.com/twinfoundation/framework/commit/818337d50d14bf5a7e8b3204649aa7527115cca9))
49
+ * relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
50
+ * simplify async set ([#121](https://github.com/twinfoundation/framework/issues/121)) ([2693c32](https://github.com/twinfoundation/framework/commit/2693c325266fd1a0aede6f1336c8b254c981a9ca))
51
+ * support indexed properties set in objects ([b9c001d](https://github.com/twinfoundation/framework/commit/b9c001dc4614f6ff7486f4370735a553613d823a))
52
+ * update dependencies ([f3bd015](https://github.com/twinfoundation/framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
53
+ * use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
54
+
55
+
56
+ ### Dependencies
57
+
58
+ * The following workspace dependencies were updated
59
+ * dependencies
60
+ * @twin.org/nameof bumped from 0.0.2-next.1 to 0.0.2-next.2
61
+ * devDependencies
62
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.1 to 0.0.2-next.2
63
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.1 to 0.0.2-next.2
64
+
65
+ ## [0.0.2-next.1](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.0...core-v0.0.2-next.1) (2025-08-06)
66
+
67
+
68
+ ### Features
69
+
70
+ * add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
71
+ * add ObjectOrArray and ArrayHelper methods ([0ac9077](https://github.com/twinfoundation/framework/commit/0ac907764d64b38ad1b04b0e9c3027055b527559))
72
+ * add rsa cipher support ([7af6cc6](https://github.com/twinfoundation/framework/commit/7af6cc67512d3363bd4a2f2e87bd7733c2800147))
73
+ * add set method for async caches ([ba34b55](https://github.com/twinfoundation/framework/commit/ba34b55e651ad56ab8fc59e139e4af631c19cda0))
74
+ * add zlib/deflate mime types detection ([72c472b](https://github.com/twinfoundation/framework/commit/72c472b5a35a973e7109336f5b6cdd84dbb8bbcb))
75
+ * async cache don't cache failures unless requested ([658ec4b](https://github.com/twinfoundation/framework/commit/658ec4b67a58a075de4702a3886d151e25ad3ddc))
76
+ * improve base error data extraction ([dccc933](https://github.com/twinfoundation/framework/commit/dccc93361a1544b41db0e7c126ff90e858d87960))
77
+ * improve error display in CLI ([94b6ca8](https://github.com/twinfoundation/framework/commit/94b6ca8bdcfe3ca7671c4095b436ea7bddaae98e))
78
+ * propagate includeStackTrace on error conversion ([8471cbb](https://github.com/twinfoundation/framework/commit/8471cbb71f8fc98247a0e92126c438c1a8b04d9b))
79
+ * propagate includeStackTrace on error conversion ([818337d](https://github.com/twinfoundation/framework/commit/818337d50d14bf5a7e8b3204649aa7527115cca9))
80
+ * relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
81
+ * simplify async set ([#121](https://github.com/twinfoundation/framework/issues/121)) ([2693c32](https://github.com/twinfoundation/framework/commit/2693c325266fd1a0aede6f1336c8b254c981a9ca))
82
+ * support indexed properties set in objects ([b9c001d](https://github.com/twinfoundation/framework/commit/b9c001dc4614f6ff7486f4370735a553613d823a))
83
+ * update dependencies ([f3bd015](https://github.com/twinfoundation/framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
84
+ * use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
85
+
86
+
87
+ ### Dependencies
88
+
89
+ * The following workspace dependencies were updated
90
+ * dependencies
91
+ * @twin.org/nameof bumped from 0.0.2-next.0 to 0.0.2-next.1
92
+ * devDependencies
93
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.0 to 0.0.2-next.1
94
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.0 to 0.0.2-next.1
95
+
3
96
  ## 0.0.1 (2025-07-03)
4
97
 
5
98
 
@@ -400,6 +400,32 @@ True if the error has the name.
400
400
 
401
401
  ***
402
402
 
403
+ ### isEmpty()
404
+
405
+ > `static` **isEmpty**(`err`): `boolean`
406
+
407
+ Is the error empty.
408
+
409
+ #### Parameters
410
+
411
+ ##### err
412
+
413
+ [`IError`](../interfaces/IError.md)
414
+
415
+ The error to check for being empty.
416
+
417
+ #### Returns
418
+
419
+ `boolean`
420
+
421
+ True if the error is empty.
422
+
423
+ #### Inherited from
424
+
425
+ [`BaseError`](BaseError.md).[`isEmpty`](BaseError.md#isempty)
426
+
427
+ ***
428
+
403
429
  ### toJsonObject()
404
430
 
405
431
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -76,10 +76,6 @@ The object or array to convert.
76
76
 
77
77
  The array.
78
78
 
79
- ##### Param
80
-
81
- The object or array to convert.
82
-
83
79
  #### Call Signature
84
80
 
85
81
  > `static` **fromObjectOrArray**\<`T`\>(`value`): `T`[]
@@ -105,7 +101,3 @@ The object or array to convert.
105
101
  `T`[]
106
102
 
107
103
  The array.
108
-
109
- ##### Param
110
-
111
- The object or array to convert.
@@ -373,6 +373,28 @@ True if the error has the name.
373
373
 
374
374
  ***
375
375
 
376
+ ### isEmpty()
377
+
378
+ > `static` **isEmpty**(`err`): `boolean`
379
+
380
+ Is the error empty.
381
+
382
+ #### Parameters
383
+
384
+ ##### err
385
+
386
+ [`IError`](../interfaces/IError.md)
387
+
388
+ The error to check for being empty.
389
+
390
+ #### Returns
391
+
392
+ `boolean`
393
+
394
+ True if the error is empty.
395
+
396
+ ***
397
+
376
398
  ### toJsonObject()
377
399
 
378
400
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -406,6 +406,32 @@ 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.
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
+
409
435
  ### toJsonObject()
410
436
 
411
437
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -398,6 +398,32 @@ 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.
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
+
401
427
  ### toJsonObject()
402
428
 
403
429
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -406,6 +406,32 @@ 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.
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
+
409
435
  ### toJsonObject()
410
436
 
411
437
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -400,6 +400,32 @@ True if the error has the name.
400
400
 
401
401
  ***
402
402
 
403
+ ### isEmpty()
404
+
405
+ > `static` **isEmpty**(`err`): `boolean`
406
+
407
+ Is the error empty.
408
+
409
+ #### Parameters
410
+
411
+ ##### err
412
+
413
+ [`IError`](../interfaces/IError.md)
414
+
415
+ The error to check for being empty.
416
+
417
+ #### Returns
418
+
419
+ `boolean`
420
+
421
+ True if the error is empty.
422
+
423
+ #### Inherited from
424
+
425
+ [`BaseError`](BaseError.md).[`isEmpty`](BaseError.md#isempty)
426
+
427
+ ***
428
+
403
429
  ### toJsonObject()
404
430
 
405
431
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -388,6 +388,32 @@ True if the error has the name.
388
388
 
389
389
  ***
390
390
 
391
+ ### isEmpty()
392
+
393
+ > `static` **isEmpty**(`err`): `boolean`
394
+
395
+ Is the error empty.
396
+
397
+ #### Parameters
398
+
399
+ ##### err
400
+
401
+ [`IError`](../interfaces/IError.md)
402
+
403
+ The error to check for being empty.
404
+
405
+ #### Returns
406
+
407
+ `boolean`
408
+
409
+ True if the error is empty.
410
+
411
+ #### Inherited from
412
+
413
+ [`BaseError`](BaseError.md).[`isEmpty`](BaseError.md#isempty)
414
+
415
+ ***
416
+
391
417
  ### toJsonObject()
392
418
 
393
419
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -394,6 +394,32 @@ True if the error has the name.
394
394
 
395
395
  ***
396
396
 
397
+ ### isEmpty()
398
+
399
+ > `static` **isEmpty**(`err`): `boolean`
400
+
401
+ Is the error empty.
402
+
403
+ #### Parameters
404
+
405
+ ##### err
406
+
407
+ [`IError`](../interfaces/IError.md)
408
+
409
+ The error to check for being empty.
410
+
411
+ #### Returns
412
+
413
+ `boolean`
414
+
415
+ True if the error is empty.
416
+
417
+ #### Inherited from
418
+
419
+ [`BaseError`](BaseError.md).[`isEmpty`](BaseError.md#isempty)
420
+
421
+ ***
422
+
397
423
  ### toJsonObject()
398
424
 
399
425
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -394,6 +394,32 @@ True if the error has the name.
394
394
 
395
395
  ***
396
396
 
397
+ ### isEmpty()
398
+
399
+ > `static` **isEmpty**(`err`): `boolean`
400
+
401
+ Is the error empty.
402
+
403
+ #### Parameters
404
+
405
+ ##### err
406
+
407
+ [`IError`](../interfaces/IError.md)
408
+
409
+ The error to check for being empty.
410
+
411
+ #### Returns
412
+
413
+ `boolean`
414
+
415
+ True if the error is empty.
416
+
417
+ #### Inherited from
418
+
419
+ [`BaseError`](BaseError.md).[`isEmpty`](BaseError.md#isempty)
420
+
421
+ ***
422
+
397
423
  ### toJsonObject()
398
424
 
399
425
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -398,6 +398,32 @@ 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.
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
+
401
427
  ### toJsonObject()
402
428
 
403
429
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
@@ -394,6 +394,32 @@ True if the error has the name.
394
394
 
395
395
  ***
396
396
 
397
+ ### isEmpty()
398
+
399
+ > `static` **isEmpty**(`err`): `boolean`
400
+
401
+ Is the error empty.
402
+
403
+ #### Parameters
404
+
405
+ ##### err
406
+
407
+ [`IError`](../interfaces/IError.md)
408
+
409
+ The error to check for being empty.
410
+
411
+ #### Returns
412
+
413
+ `boolean`
414
+
415
+ True if the error is empty.
416
+
417
+ #### Inherited from
418
+
419
+ [`BaseError`](BaseError.md).[`isEmpty`](BaseError.md#isempty)
420
+
421
+ ***
422
+
397
423
  ### toJsonObject()
398
424
 
399
425
  > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.2-next.3",
4
4
  "description": "Helper methods/classes for data type checking/validation/guarding/error handling",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/nameof": "^0.0.1",
17
+ "@twin.org/nameof": "0.0.2-next.3",
18
18
  "intl-messageformat": "10.7.16",
19
19
  "rfc6902": "5.1.2"
20
20
  },