@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.
- package/README.md +1 -9
- package/dist/es/encoding/base32.js +1 -1
- package/dist/es/encoding/base32.js.map +1 -1
- package/dist/es/factories/factory.js +41 -0
- package/dist/es/factories/factory.js.map +1 -1
- package/dist/es/helpers/arrayHelper.js.map +1 -1
- package/dist/es/helpers/randomHelper.js +50 -2
- package/dist/es/helpers/randomHelper.js.map +1 -1
- package/dist/es/index.js +2 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/types/objectOrArray.js.map +1 -0
- package/dist/es/types/singleOccurrenceArray.js +2 -0
- package/dist/es/types/singleOccurrenceArray.js.map +1 -0
- package/dist/es/types/urn.js +1 -2
- package/dist/es/types/urn.js.map +1 -1
- package/dist/es/utils/asyncCache.js +92 -74
- package/dist/es/utils/asyncCache.js.map +1 -1
- package/dist/es/utils/guards.js +16 -0
- package/dist/es/utils/guards.js.map +1 -1
- package/dist/es/utils/is.js +16 -0
- package/dist/es/utils/is.js.map +1 -1
- package/dist/types/encoding/base32.d.ts +1 -1
- package/dist/types/factories/factory.d.ts +23 -1
- package/dist/types/helpers/arrayHelper.d.ts +1 -1
- package/dist/types/helpers/randomHelper.d.ts +16 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/types/singleOccurrenceArray.d.ts +9 -0
- package/dist/types/utils/asyncCache.d.ts +7 -0
- package/dist/types/utils/guards.d.ts +10 -1
- package/dist/types/utils/is.d.ts +7 -0
- package/docs/changelog.md +524 -1
- package/docs/examples.md +308 -1
- package/docs/reference/classes/AlreadyExistsError.md +35 -35
- package/docs/reference/classes/ArrayHelper.md +2 -2
- package/docs/reference/classes/AsyncCache.md +8 -8
- package/docs/reference/classes/Base32.md +4 -4
- package/docs/reference/classes/Base58.md +3 -3
- package/docs/reference/classes/Base64.md +4 -4
- package/docs/reference/classes/Base64Url.md +3 -3
- package/docs/reference/classes/BaseError.md +34 -34
- package/docs/reference/classes/BitString.md +6 -6
- package/docs/reference/classes/Coerce.md +11 -11
- package/docs/reference/classes/Compression.md +3 -3
- package/docs/reference/classes/ConflictError.md +35 -35
- package/docs/reference/classes/Converter.md +18 -18
- package/docs/reference/classes/EnvHelper.md +1 -1
- package/docs/reference/classes/ErrorHelper.md +3 -3
- package/docs/reference/classes/Factory.md +112 -18
- package/docs/reference/classes/FilenameHelper.md +1 -1
- package/docs/reference/classes/GeneralError.md +35 -35
- package/docs/reference/classes/GuardError.md +35 -35
- package/docs/reference/classes/Guards.md +72 -30
- package/docs/reference/classes/HexHelper.md +6 -6
- package/docs/reference/classes/I18n.md +14 -14
- package/docs/reference/classes/Is.md +67 -39
- package/docs/reference/classes/JsonHelper.md +10 -10
- package/docs/reference/classes/NotFoundError.md +35 -35
- package/docs/reference/classes/NotImplementedError.md +35 -35
- package/docs/reference/classes/NotSupportedError.md +35 -35
- package/docs/reference/classes/NumberHelper.md +2 -2
- package/docs/reference/classes/ObjectHelper.md +32 -32
- package/docs/reference/classes/RandomHelper.md +53 -1
- package/docs/reference/classes/SharedStore.md +3 -3
- package/docs/reference/classes/StringHelper.md +23 -23
- package/docs/reference/classes/Uint8ArrayHelper.md +1 -1
- package/docs/reference/classes/UnauthorizedError.md +35 -35
- package/docs/reference/classes/UnprocessableError.md +35 -35
- package/docs/reference/classes/Url.md +8 -8
- package/docs/reference/classes/Urn.md +24 -24
- package/docs/reference/classes/Validation.md +25 -25
- package/docs/reference/classes/ValidationError.md +35 -35
- package/docs/reference/index.md +2 -0
- package/docs/reference/interfaces/IComponent.md +4 -4
- package/docs/reference/interfaces/IError.md +10 -10
- package/docs/reference/interfaces/II18nShared.md +4 -4
- package/docs/reference/interfaces/IKeyValue.md +2 -2
- package/docs/reference/interfaces/ILabelledValue.md +2 -2
- package/docs/reference/interfaces/ILocale.md +2 -2
- package/docs/reference/interfaces/ILocaleDictionary.md +1 -1
- package/docs/reference/interfaces/ILocalesIndex.md +1 -1
- package/docs/reference/interfaces/IPatchOperation.md +6 -6
- package/docs/reference/interfaces/IUrlParts.md +9 -9
- package/docs/reference/interfaces/IValidationFailure.md +4 -4
- package/docs/reference/type-aliases/SingleOccurrenceArray.md +15 -0
- package/docs/reference/type-aliases/SingleOccurrenceArrayDepthHelper.md +19 -0
- package/docs/reference/variables/CoerceType.md +10 -10
- package/docs/reference/variables/CompressionType.md +2 -2
- package/locales/en.json +5 -2
- package/package.json +4 -4
- package/dist/es/models/objectOrArray.js.map +0 -1
- /package/dist/es/{models → types}/objectOrArray.js +0 -0
- /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
|
|
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
|
|
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
|
|
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
|
|
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 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 @@ 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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
+
"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.
|
|
18
|
-
"intl-messageformat": "
|
|
19
|
-
"rfc6902": "5.
|
|
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
|