@twin.org/core 0.0.3-next.3 → 0.0.3-next.30

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 (92) hide show
  1. package/README.md +1 -9
  2. package/dist/es/encoding/base32.js +1 -1
  3. package/dist/es/encoding/base32.js.map +1 -1
  4. package/dist/es/factories/factory.js +41 -0
  5. package/dist/es/factories/factory.js.map +1 -1
  6. package/dist/es/helpers/arrayHelper.js.map +1 -1
  7. package/dist/es/helpers/randomHelper.js +50 -2
  8. package/dist/es/helpers/randomHelper.js.map +1 -1
  9. package/dist/es/index.js +2 -1
  10. package/dist/es/index.js.map +1 -1
  11. package/dist/es/types/objectOrArray.js.map +1 -0
  12. package/dist/es/types/singleOccurrenceArray.js +2 -0
  13. package/dist/es/types/singleOccurrenceArray.js.map +1 -0
  14. package/dist/es/types/urn.js +1 -2
  15. package/dist/es/types/urn.js.map +1 -1
  16. package/dist/es/utils/asyncCache.js +92 -74
  17. package/dist/es/utils/asyncCache.js.map +1 -1
  18. package/dist/es/utils/guards.js +16 -0
  19. package/dist/es/utils/guards.js.map +1 -1
  20. package/dist/es/utils/is.js +16 -0
  21. package/dist/es/utils/is.js.map +1 -1
  22. package/dist/types/encoding/base32.d.ts +1 -1
  23. package/dist/types/factories/factory.d.ts +23 -1
  24. package/dist/types/helpers/arrayHelper.d.ts +1 -1
  25. package/dist/types/helpers/randomHelper.d.ts +16 -0
  26. package/dist/types/index.d.ts +2 -1
  27. package/dist/types/types/singleOccurrenceArray.d.ts +9 -0
  28. package/dist/types/utils/asyncCache.d.ts +7 -0
  29. package/dist/types/utils/guards.d.ts +10 -1
  30. package/dist/types/utils/is.d.ts +7 -0
  31. package/docs/changelog.md +524 -1
  32. package/docs/examples.md +308 -1
  33. package/docs/reference/classes/AlreadyExistsError.md +35 -35
  34. package/docs/reference/classes/ArrayHelper.md +2 -2
  35. package/docs/reference/classes/AsyncCache.md +8 -8
  36. package/docs/reference/classes/Base32.md +4 -4
  37. package/docs/reference/classes/Base58.md +3 -3
  38. package/docs/reference/classes/Base64.md +4 -4
  39. package/docs/reference/classes/Base64Url.md +3 -3
  40. package/docs/reference/classes/BaseError.md +34 -34
  41. package/docs/reference/classes/BitString.md +6 -6
  42. package/docs/reference/classes/Coerce.md +11 -11
  43. package/docs/reference/classes/Compression.md +3 -3
  44. package/docs/reference/classes/ConflictError.md +35 -35
  45. package/docs/reference/classes/Converter.md +18 -18
  46. package/docs/reference/classes/EnvHelper.md +1 -1
  47. package/docs/reference/classes/ErrorHelper.md +3 -3
  48. package/docs/reference/classes/Factory.md +112 -18
  49. package/docs/reference/classes/FilenameHelper.md +1 -1
  50. package/docs/reference/classes/GeneralError.md +35 -35
  51. package/docs/reference/classes/GuardError.md +35 -35
  52. package/docs/reference/classes/Guards.md +72 -30
  53. package/docs/reference/classes/HexHelper.md +6 -6
  54. package/docs/reference/classes/I18n.md +14 -14
  55. package/docs/reference/classes/Is.md +67 -39
  56. package/docs/reference/classes/JsonHelper.md +10 -10
  57. package/docs/reference/classes/NotFoundError.md +35 -35
  58. package/docs/reference/classes/NotImplementedError.md +35 -35
  59. package/docs/reference/classes/NotSupportedError.md +35 -35
  60. package/docs/reference/classes/NumberHelper.md +2 -2
  61. package/docs/reference/classes/ObjectHelper.md +32 -32
  62. package/docs/reference/classes/RandomHelper.md +53 -1
  63. package/docs/reference/classes/SharedStore.md +3 -3
  64. package/docs/reference/classes/StringHelper.md +23 -23
  65. package/docs/reference/classes/Uint8ArrayHelper.md +1 -1
  66. package/docs/reference/classes/UnauthorizedError.md +35 -35
  67. package/docs/reference/classes/UnprocessableError.md +35 -35
  68. package/docs/reference/classes/Url.md +8 -8
  69. package/docs/reference/classes/Urn.md +24 -24
  70. package/docs/reference/classes/Validation.md +25 -25
  71. package/docs/reference/classes/ValidationError.md +35 -35
  72. package/docs/reference/index.md +2 -0
  73. package/docs/reference/interfaces/IComponent.md +4 -4
  74. package/docs/reference/interfaces/IError.md +10 -10
  75. package/docs/reference/interfaces/II18nShared.md +4 -4
  76. package/docs/reference/interfaces/IKeyValue.md +2 -2
  77. package/docs/reference/interfaces/ILabelledValue.md +2 -2
  78. package/docs/reference/interfaces/ILocale.md +2 -2
  79. package/docs/reference/interfaces/ILocaleDictionary.md +1 -1
  80. package/docs/reference/interfaces/ILocalesIndex.md +1 -1
  81. package/docs/reference/interfaces/IPatchOperation.md +6 -6
  82. package/docs/reference/interfaces/IUrlParts.md +9 -9
  83. package/docs/reference/interfaces/IValidationFailure.md +4 -4
  84. package/docs/reference/type-aliases/SingleOccurrenceArray.md +15 -0
  85. package/docs/reference/type-aliases/SingleOccurrenceArrayDepthHelper.md +19 -0
  86. package/docs/reference/variables/CoerceType.md +10 -10
  87. package/docs/reference/variables/CompressionType.md +2 -2
  88. package/locales/en.json +5 -2
  89. package/package.json +4 -4
  90. package/dist/es/models/objectOrArray.js.map +0 -1
  91. /package/dist/es/{models → types}/objectOrArray.js +0 -0
  92. /package/dist/types/{models → types}/objectOrArray.d.ts +0 -0
@@ -4,7 +4,7 @@ Model to describe serialized error.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### name
7
+ ### name {#name}
8
8
 
9
9
  > **name**: `string`
10
10
 
@@ -12,7 +12,7 @@ The name for the error.
12
12
 
13
13
  ***
14
14
 
15
- ### message
15
+ ### message {#message}
16
16
 
17
17
  > **message**: `string`
18
18
 
@@ -20,17 +20,17 @@ The message for the error.
20
20
 
21
21
  ***
22
22
 
23
- ### source?
23
+ ### source? {#source}
24
24
 
25
- > `optional` **source**: `string`
25
+ > `optional` **source?**: `string`
26
26
 
27
27
  The source of the error.
28
28
 
29
29
  ***
30
30
 
31
- ### properties?
31
+ ### properties? {#properties}
32
32
 
33
- > `optional` **properties**: `object`
33
+ > `optional` **properties?**: `object`
34
34
 
35
35
  Any additional information for the error.
36
36
 
@@ -40,16 +40,16 @@ Any additional information for the error.
40
40
 
41
41
  ***
42
42
 
43
- ### stack?
43
+ ### stack? {#stack}
44
44
 
45
- > `optional` **stack**: `string`
45
+ > `optional` **stack?**: `string`
46
46
 
47
47
  The stack trace for the error.
48
48
 
49
49
  ***
50
50
 
51
- ### cause?
51
+ ### cause? {#cause}
52
52
 
53
- > `optional` **cause**: `IError`
53
+ > `optional` **cause?**: `IError`
54
54
 
55
55
  The cause of the error if there was one.
@@ -4,7 +4,7 @@ The shared state for the I18n global.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### localeDictionaries
7
+ ### localeDictionaries {#localedictionaries}
8
8
 
9
9
  > **localeDictionaries**: `object`
10
10
 
@@ -16,7 +16,7 @@ Dictionaries for lookups.
16
16
 
17
17
  ***
18
18
 
19
- ### currentLocale
19
+ ### currentLocale {#currentlocale}
20
20
 
21
21
  > **currentLocale**: `string`
22
22
 
@@ -24,7 +24,7 @@ The current locale.
24
24
 
25
25
  ***
26
26
 
27
- ### localeChangedHandlers
27
+ ### localeChangedHandlers {#localechangedhandlers}
28
28
 
29
29
  > **localeChangedHandlers**: `object`
30
30
 
@@ -36,7 +36,7 @@ Change handler for the locale being updated.
36
36
 
37
37
  ***
38
38
 
39
- ### dictionaryChangedHandlers
39
+ ### dictionaryChangedHandlers {#dictionarychangedhandlers}
40
40
 
41
41
  > **dictionaryChangedHandlers**: `object`
42
42
 
@@ -10,7 +10,7 @@ Interface describing a key/value pair.
10
10
 
11
11
  ## Properties
12
12
 
13
- ### key
13
+ ### key {#key}
14
14
 
15
15
  > **key**: `string`
16
16
 
@@ -18,7 +18,7 @@ The key for the item.
18
18
 
19
19
  ***
20
20
 
21
- ### value
21
+ ### value {#value}
22
22
 
23
23
  > **value**: `T`
24
24
 
@@ -10,7 +10,7 @@ Interface describing a label/value pair.
10
10
 
11
11
  ## Properties
12
12
 
13
- ### label
13
+ ### label {#label}
14
14
 
15
15
  > **label**: `string`
16
16
 
@@ -18,7 +18,7 @@ The label for the item.
18
18
 
19
19
  ***
20
20
 
21
- ### value
21
+ ### value {#value}
22
22
 
23
23
  > **value**: `T`
24
24
 
@@ -4,7 +4,7 @@ Model for a local.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### label
7
+ ### label {#label}
8
8
 
9
9
  > **label**: `string`
10
10
 
@@ -12,7 +12,7 @@ The label.
12
12
 
13
13
  ***
14
14
 
15
- ### code
15
+ ### code {#code}
16
16
 
17
17
  > **code**: `string`
18
18
 
@@ -4,4 +4,4 @@ Type for the JSON locale dictionary files.
4
4
 
5
5
  ## Indexable
6
6
 
7
- \[`key`: `string`\]: `string` \| `ILocaleDictionary`
7
+ > \[`key`: `string`\]: `string` \| `ILocaleDictionary`
@@ -4,7 +4,7 @@ Model for a locales index.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### locales
7
+ ### locales {#locales}
8
8
 
9
9
  > **locales**: [`ILocale`](ILocale.md)[]
10
10
 
@@ -4,7 +4,7 @@ Interface describing a patch operation to add a property.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### op
7
+ ### op {#op}
8
8
 
9
9
  > **op**: `"add"` \| `"remove"` \| `"replace"` \| `"move"` \| `"copy"` \| `"test"`
10
10
 
@@ -12,7 +12,7 @@ The operation that was performed on the item.
12
12
 
13
13
  ***
14
14
 
15
- ### path
15
+ ### path {#path}
16
16
 
17
17
  > **path**: `string`
18
18
 
@@ -20,16 +20,16 @@ The path to the object that was changed.
20
20
 
21
21
  ***
22
22
 
23
- ### from?
23
+ ### from? {#from}
24
24
 
25
- > `optional` **from**: `string`
25
+ > `optional` **from?**: `string`
26
26
 
27
27
  The path the value was copied or moved from.
28
28
 
29
29
  ***
30
30
 
31
- ### value?
31
+ ### value? {#value}
32
32
 
33
- > `optional` **value**: `unknown`
33
+ > `optional` **value?**: `unknown`
34
34
 
35
35
  The value to add.
@@ -4,7 +4,7 @@ Model to describe the parts of a url.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### schema
7
+ ### schema {#schema}
8
8
 
9
9
  > **schema**: `string`
10
10
 
@@ -12,7 +12,7 @@ The schema for the url.
12
12
 
13
13
  ***
14
14
 
15
- ### host
15
+ ### host {#host}
16
16
 
17
17
  > **host**: `string`
18
18
 
@@ -20,15 +20,15 @@ The host for the url.
20
20
 
21
21
  ***
22
22
 
23
- ### port?
23
+ ### port? {#port}
24
24
 
25
- > `optional` **port**: `number`
25
+ > `optional` **port?**: `number`
26
26
 
27
27
  The port for the url.
28
28
 
29
29
  ***
30
30
 
31
- ### path
31
+ ### path {#path}
32
32
 
33
33
  > **path**: `string`
34
34
 
@@ -36,16 +36,16 @@ The path for the url.
36
36
 
37
37
  ***
38
38
 
39
- ### params?
39
+ ### params? {#params}
40
40
 
41
- > `optional` **params**: `string`
41
+ > `optional` **params?**: `string`
42
42
 
43
43
  The params for the url.
44
44
 
45
45
  ***
46
46
 
47
- ### hash?
47
+ ### hash? {#hash}
48
48
 
49
- > `optional` **hash**: `string`
49
+ > `optional` **hash?**: `string`
50
50
 
51
51
  The hash for the url.
@@ -4,7 +4,7 @@ Interface describing the reason a validation failed.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### property
7
+ ### property {#property}
8
8
 
9
9
  > **property**: `string`
10
10
 
@@ -12,7 +12,7 @@ The property that failed validation.
12
12
 
13
13
  ***
14
14
 
15
- ### reason
15
+ ### reason {#reason}
16
16
 
17
17
  > **reason**: `string`
18
18
 
@@ -20,9 +20,9 @@ The reason the validation failed as an i18 resource error.
20
20
 
21
21
  ***
22
22
 
23
- ### properties?
23
+ ### properties? {#properties}
24
24
 
25
- > `optional` **properties**: `object`
25
+ > `optional` **properties?**: `object`
26
26
 
27
27
  Additional properties for the validation failure.
28
28
 
@@ -0,0 +1,15 @@
1
+ # Type Alias: SingleOccurrenceArray\<T, U\>
2
+
3
+ > **SingleOccurrenceArray**\<`T`, `U`\> = [`SingleOccurrenceArrayDepthHelper`](SingleOccurrenceArrayDepthHelper.md)\<`T`, `U`, \[\]\>
4
+
5
+ Utility type to create a non-empty array with values of type T and exactly one value of type U.
6
+
7
+ ## Type Parameters
8
+
9
+ ### T
10
+
11
+ `T` = `unknown`
12
+
13
+ ### U
14
+
15
+ `U` = `never`
@@ -0,0 +1,19 @@
1
+ # Type Alias: SingleOccurrenceArrayDepthHelper\<T, U, Depth\>
2
+
3
+ > **SingleOccurrenceArrayDepthHelper**\<`T`, `U`, `Depth`\> = `Depth`\[`"length"`\] *extends* `16` ? \[`U`, `...T[]`\] : \[`U`, `...T[]`\] \| \[`T`, `...SingleOccurrenceArrayDepthHelper<T, U, [0, ...Depth]>`\]
4
+
5
+ Helper with bounded recursion depth to keep type instantiation tractable.
6
+
7
+ ## Type Parameters
8
+
9
+ ### T
10
+
11
+ `T`
12
+
13
+ ### U
14
+
15
+ `U`
16
+
17
+ ### Depth
18
+
19
+ `Depth` *extends* `0`[]
@@ -6,61 +6,61 @@ The types the extracted data can be coerced to.
6
6
 
7
7
  ## Type Declaration
8
8
 
9
- ### String
9
+ ### String {#string}
10
10
 
11
11
  > `readonly` **String**: `"string"` = `"string"`
12
12
 
13
13
  String.
14
14
 
15
- ### Number
15
+ ### Number {#number}
16
16
 
17
17
  > `readonly` **Number**: `"number"` = `"number"`
18
18
 
19
19
  Number.
20
20
 
21
- ### Integer
21
+ ### Integer {#integer}
22
22
 
23
23
  > `readonly` **Integer**: `"integer"` = `"integer"`
24
24
 
25
25
  Integer.
26
26
 
27
- ### Boolean
27
+ ### Boolean {#boolean}
28
28
 
29
29
  > `readonly` **Boolean**: `"boolean"` = `"boolean"`
30
30
 
31
31
  Boolean.
32
32
 
33
- ### BigInt
33
+ ### BigInt {#bigint}
34
34
 
35
35
  > `readonly` **BigInt**: `"bigint"` = `"bigint"`
36
36
 
37
37
  Big Integer.
38
38
 
39
- ### Date
39
+ ### Date {#date}
40
40
 
41
41
  > `readonly` **Date**: `"date"` = `"date"`
42
42
 
43
43
  Date.
44
44
 
45
- ### DateTime
45
+ ### DateTime {#datetime}
46
46
 
47
47
  > `readonly` **DateTime**: `"datetime"` = `"datetime"`
48
48
 
49
49
  Date Time.
50
50
 
51
- ### Time
51
+ ### Time {#time}
52
52
 
53
53
  > `readonly` **Time**: `"time"` = `"time"`
54
54
 
55
55
  Time.
56
56
 
57
- ### Object
57
+ ### Object {#object}
58
58
 
59
59
  > `readonly` **Object**: `"object"` = `"object"`
60
60
 
61
61
  Object.
62
62
 
63
- ### Uint8Array
63
+ ### Uint8Array {#uint8array}
64
64
 
65
65
  > `readonly` **Uint8Array**: `"uint8array"` = `"uint8array"`
66
66
 
@@ -6,13 +6,13 @@ Compression types.
6
6
 
7
7
  ## Type Declaration
8
8
 
9
- ### Gzip
9
+ ### Gzip {#gzip}
10
10
 
11
11
  > `readonly` **Gzip**: `"gzip"` = `"gzip"`
12
12
 
13
13
  Gzip.
14
14
 
15
- ### Deflate
15
+ ### Deflate {#deflate}
16
16
 
17
17
  > `readonly` **Deflate**: `"deflate"` = `"deflate"`
18
18
 
package/locales/en.json CHANGED
@@ -69,7 +69,9 @@
69
69
  "function": "Property \"{property}\" must be a function, it is \"{value}\"",
70
70
  "urn": "Property \"{property}\" must be a Urn formatted string, it is \"{value}\"",
71
71
  "url": "Property \"{property}\" must be a Url formatted string, it is \"{value}\"",
72
- "email": "Property \"{property}\" must be string in e-mail format, it is \"{value}\""
72
+ "email": "Property \"{property}\" must be string in e-mail format, it is \"{value}\"",
73
+ "uuidV7": "Property \"{property}\" must be a UUIDv7 formatted string, it is \"{value}\"",
74
+ "uuidV7Compact": "Property \"{property}\" must be a UUIDv7 formatted string in compact mode, it is \"{value}\""
73
75
  },
74
76
  "objectHelper": {
75
77
  "failedBytesToJSON": "Failed converting bytes to JSON",
@@ -82,7 +84,8 @@
82
84
  },
83
85
  "factory": {
84
86
  "noUnregister": "There is no {typeName} registered with the name \"{name}\"",
85
- "noGet": "The requested {typeName} \"{name}\" does not exist in the factory"
87
+ "noGet": "The requested {typeName} \"{name}\" does not exist in the factory",
88
+ "noCreate": "The requested {typeName} \"{name}\" cannot be created by the factory, with params \"{params}\""
86
89
  },
87
90
  "bitString": {
88
91
  "outOfRange": "The index should be >= 0 and less than the length of the bit string, the index is \"{index}\" and the number of bit is \"{numberBits}\""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/core",
3
- "version": "0.0.3-next.3",
3
+ "version": "0.0.3-next.30",
4
4
  "description": "Helper methods/classes for data type checking/validation/guarding/error handling",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,9 +14,9 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/nameof": "0.0.3-next.3",
18
- "intl-messageformat": "10.7.18",
19
- "rfc6902": "5.1.2"
17
+ "@twin.org/nameof": "0.0.3-next.30",
18
+ "intl-messageformat": "11.2.0",
19
+ "rfc6902": "5.2.0"
20
20
  },
21
21
  "main": "./dist/es/index.js",
22
22
  "types": "./dist/types/index.d.ts",
@@ -1 +0,0 @@
1
- {"version":3,"file":"objectOrArray.js","sourceRoot":"","sources":["../../../src/models/objectOrArray.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n/**\n * Object or array data type\n */\nexport type ObjectOrArray<T = unknown> = T | T[];\n"]}
File without changes
File without changes