@twin.org/core 0.0.1-next.1

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 (103) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +29 -0
  3. package/dist/cjs/index.cjs +4221 -0
  4. package/dist/esm/index.mjs +4184 -0
  5. package/dist/types/encoding/base32.d.ts +18 -0
  6. package/dist/types/encoding/base64.d.ts +24 -0
  7. package/dist/types/encoding/base64Url.d.ts +18 -0
  8. package/dist/types/errors/alreadyExistsError.d.ts +18 -0
  9. package/dist/types/errors/baseError.d.ts +103 -0
  10. package/dist/types/errors/conflictError.d.ts +19 -0
  11. package/dist/types/errors/generalError.d.ts +20 -0
  12. package/dist/types/errors/guardError.d.ts +19 -0
  13. package/dist/types/errors/notFoundError.d.ts +18 -0
  14. package/dist/types/errors/notImplementedError.d.ts +16 -0
  15. package/dist/types/errors/notSupportedError.d.ts +17 -0
  16. package/dist/types/errors/unauthorizedError.d.ts +17 -0
  17. package/dist/types/errors/unprocessableError.d.ts +20 -0
  18. package/dist/types/errors/validationError.d.ts +18 -0
  19. package/dist/types/factories/componentFactory.d.ts +6 -0
  20. package/dist/types/factories/factory.d.ts +67 -0
  21. package/dist/types/helpers/arrayHelper.d.ts +12 -0
  22. package/dist/types/helpers/errorHelper.d.ts +24 -0
  23. package/dist/types/helpers/filenameHelper.d.ts +11 -0
  24. package/dist/types/helpers/hexHelper.d.ts +30 -0
  25. package/dist/types/helpers/jsonHelper.d.ts +29 -0
  26. package/dist/types/helpers/objectHelper.d.ts +74 -0
  27. package/dist/types/helpers/randomHelper.d.ts +11 -0
  28. package/dist/types/helpers/stringHelper.d.ts +90 -0
  29. package/dist/types/index.d.ts +46 -0
  30. package/dist/types/models/IComponent.d.ts +29 -0
  31. package/dist/types/models/IError.d.ts +31 -0
  32. package/dist/types/models/IKeyValue.d.ts +13 -0
  33. package/dist/types/models/ILabelledValue.d.ts +13 -0
  34. package/dist/types/models/ILocale.d.ts +13 -0
  35. package/dist/types/models/ILocaleDictionary.d.ts +6 -0
  36. package/dist/types/models/ILocalesIndex.d.ts +10 -0
  37. package/dist/types/models/IPatchOperation.d.ts +21 -0
  38. package/dist/types/models/IUrlParts.d.ts +29 -0
  39. package/dist/types/models/IValidationFailure.d.ts +23 -0
  40. package/dist/types/models/compressionType.d.ts +17 -0
  41. package/dist/types/types/bitString.d.ts +41 -0
  42. package/dist/types/types/url.d.ts +56 -0
  43. package/dist/types/types/urn.d.ts +93 -0
  44. package/dist/types/utils/asyncCache.d.ts +33 -0
  45. package/dist/types/utils/coerce.d.ts +61 -0
  46. package/dist/types/utils/compression.d.ts +20 -0
  47. package/dist/types/utils/converter.d.ts +85 -0
  48. package/dist/types/utils/guards.d.ts +190 -0
  49. package/dist/types/utils/i18n.d.ts +81 -0
  50. package/dist/types/utils/is.d.ts +205 -0
  51. package/dist/types/utils/validation.d.ts +245 -0
  52. package/docs/changelog.md +5 -0
  53. package/docs/examples.md +1 -0
  54. package/docs/reference/classes/AlreadyExistsError.md +375 -0
  55. package/docs/reference/classes/ArrayHelper.md +37 -0
  56. package/docs/reference/classes/AsyncCache.md +117 -0
  57. package/docs/reference/classes/Base32.md +57 -0
  58. package/docs/reference/classes/Base64.md +74 -0
  59. package/docs/reference/classes/Base64Url.md +54 -0
  60. package/docs/reference/classes/BaseError.md +344 -0
  61. package/docs/reference/classes/BitString.md +123 -0
  62. package/docs/reference/classes/Coerce.md +209 -0
  63. package/docs/reference/classes/Compression.md +61 -0
  64. package/docs/reference/classes/ConflictError.md +379 -0
  65. package/docs/reference/classes/Converter.md +285 -0
  66. package/docs/reference/classes/ErrorHelper.md +73 -0
  67. package/docs/reference/classes/Factory.md +221 -0
  68. package/docs/reference/classes/FilenameHelper.md +33 -0
  69. package/docs/reference/classes/GeneralError.md +375 -0
  70. package/docs/reference/classes/GuardError.md +379 -0
  71. package/docs/reference/classes/Guards.md +711 -0
  72. package/docs/reference/classes/HexHelper.md +97 -0
  73. package/docs/reference/classes/I18n.md +237 -0
  74. package/docs/reference/classes/Is.md +693 -0
  75. package/docs/reference/classes/JsonHelper.md +92 -0
  76. package/docs/reference/classes/NotFoundError.md +375 -0
  77. package/docs/reference/classes/NotImplementedError.md +367 -0
  78. package/docs/reference/classes/NotSupportedError.md +371 -0
  79. package/docs/reference/classes/ObjectHelper.md +287 -0
  80. package/docs/reference/classes/RandomHelper.md +33 -0
  81. package/docs/reference/classes/StringHelper.md +270 -0
  82. package/docs/reference/classes/UnauthorizedError.md +371 -0
  83. package/docs/reference/classes/UnprocessableError.md +375 -0
  84. package/docs/reference/classes/Url.md +167 -0
  85. package/docs/reference/classes/Urn.md +295 -0
  86. package/docs/reference/classes/Validation.md +821 -0
  87. package/docs/reference/classes/ValidationError.md +371 -0
  88. package/docs/reference/index.md +60 -0
  89. package/docs/reference/interfaces/IComponent.md +79 -0
  90. package/docs/reference/interfaces/IError.md +55 -0
  91. package/docs/reference/interfaces/IKeyValue.md +23 -0
  92. package/docs/reference/interfaces/ILabelledValue.md +23 -0
  93. package/docs/reference/interfaces/ILocale.md +19 -0
  94. package/docs/reference/interfaces/ILocaleDictionary.md +7 -0
  95. package/docs/reference/interfaces/ILocalesIndex.md +11 -0
  96. package/docs/reference/interfaces/IPatchOperation.md +35 -0
  97. package/docs/reference/interfaces/IUrlParts.md +51 -0
  98. package/docs/reference/interfaces/IValidationFailure.md +39 -0
  99. package/docs/reference/type-aliases/CompressionType.md +5 -0
  100. package/docs/reference/variables/ComponentFactory.md +5 -0
  101. package/docs/reference/variables/CompressionType.md +19 -0
  102. package/locales/en.json +98 -0
  103. package/package.json +65 -0
@@ -0,0 +1,97 @@
1
+ # Class: HexHelper
2
+
3
+ Helper methods for hex conversions.
4
+
5
+ ## Constructors
6
+
7
+ ### new HexHelper()
8
+
9
+ > **new HexHelper**(): [`HexHelper`](HexHelper.md)
10
+
11
+ #### Returns
12
+
13
+ [`HexHelper`](HexHelper.md)
14
+
15
+ ## Methods
16
+
17
+ ### stripPrefix()
18
+
19
+ > `static` **stripPrefix**(`hex`): `string`
20
+
21
+ Strip the 0x prefix if it exists.
22
+
23
+ #### Parameters
24
+
25
+ • **hex**: `string`
26
+
27
+ The hex value to strip.
28
+
29
+ #### Returns
30
+
31
+ `string`
32
+
33
+ The stripped hex without the prefix.
34
+
35
+ ***
36
+
37
+ ### addPrefix()
38
+
39
+ > `static` **addPrefix**(`hex`): `string`
40
+
41
+ Add the 0x prefix if it does not exist.
42
+
43
+ #### Parameters
44
+
45
+ • **hex**: `string`
46
+
47
+ The hex value to add the prefix to.
48
+
49
+ #### Returns
50
+
51
+ `string`
52
+
53
+ The hex with the prefix.
54
+
55
+ ***
56
+
57
+ ### hasPrefix()
58
+
59
+ > `static` **hasPrefix**(`hex`): `boolean`
60
+
61
+ Does the hex string have the prefix.
62
+
63
+ #### Parameters
64
+
65
+ • **hex**: `string`
66
+
67
+ The hex value to check for the prefix.
68
+
69
+ #### Returns
70
+
71
+ `boolean`
72
+
73
+ True if the hex string has the prefix.
74
+
75
+ ***
76
+
77
+ ### isHex()
78
+
79
+ > `static` **isHex**(`value`, `allowPrefix`): `boolean`
80
+
81
+ Is the data hex format.
82
+
83
+ #### Parameters
84
+
85
+ • **value**: `string`
86
+
87
+ The value to test.
88
+
89
+ • **allowPrefix**: `boolean` = `false`
90
+
91
+ Allow the hex to have the 0x prefix.
92
+
93
+ #### Returns
94
+
95
+ `boolean`
96
+
97
+ True if the string is hex.
@@ -0,0 +1,237 @@
1
+ # Class: I18n
2
+
3
+ Class to perform internationalization.
4
+
5
+ ## Constructors
6
+
7
+ ### new I18n()
8
+
9
+ > **new I18n**(): [`I18n`](I18n.md)
10
+
11
+ #### Returns
12
+
13
+ [`I18n`](I18n.md)
14
+
15
+ ## Properties
16
+
17
+ ### DEFAULT\_LOCALE
18
+
19
+ > `static` **DEFAULT\_LOCALE**: `string` = `"en"`
20
+
21
+ The default translation.
22
+
23
+ ## Methods
24
+
25
+ ### setLocale()
26
+
27
+ > `static` **setLocale**(`locale`): `void`
28
+
29
+ Set the locale.
30
+
31
+ #### Parameters
32
+
33
+ • **locale**: `string`
34
+
35
+ The new locale.
36
+
37
+ #### Returns
38
+
39
+ `void`
40
+
41
+ ***
42
+
43
+ ### getLocale()
44
+
45
+ > `static` **getLocale**(): `string`
46
+
47
+ Get the locale.
48
+
49
+ #### Returns
50
+
51
+ `string`
52
+
53
+ The current locale.
54
+
55
+ ***
56
+
57
+ ### addDictionary()
58
+
59
+ > `static` **addDictionary**(`locale`, `dictionary`): `void`
60
+
61
+ Add a locale dictionary.
62
+
63
+ #### Parameters
64
+
65
+ • **locale**: `string`
66
+
67
+ The locale.
68
+
69
+ • **dictionary**: [`ILocaleDictionary`](../interfaces/ILocaleDictionary.md)
70
+
71
+ The dictionary to add.
72
+
73
+ #### Returns
74
+
75
+ `void`
76
+
77
+ ***
78
+
79
+ ### getDictionary()
80
+
81
+ > `static` **getDictionary**(`locale`): `undefined` \| `object`
82
+
83
+ Get a locale dictionary.
84
+
85
+ #### Parameters
86
+
87
+ • **locale**: `string`
88
+
89
+ The locale.
90
+
91
+ #### Returns
92
+
93
+ `undefined` \| `object`
94
+
95
+ The dictionary of undefined if it does not exist.
96
+
97
+ ***
98
+
99
+ ### getAllDictionaries()
100
+
101
+ > `static` **getAllDictionaries**(): `object`
102
+
103
+ Get all the locale dictionaries.
104
+
105
+ #### Returns
106
+
107
+ `object`
108
+
109
+ The dictionaries.
110
+
111
+ ***
112
+
113
+ ### addLocaleHandler()
114
+
115
+ > `static` **addLocaleHandler**(`id`, `handler`): `void`
116
+
117
+ Add a locale changed handler.
118
+
119
+ #### Parameters
120
+
121
+ • **id**: `string`
122
+
123
+ The id of the handler.
124
+
125
+ • **handler**
126
+
127
+ The handler to add.
128
+
129
+ #### Returns
130
+
131
+ `void`
132
+
133
+ ***
134
+
135
+ ### removeLocaleHandler()
136
+
137
+ > `static` **removeLocaleHandler**(`id`): `void`
138
+
139
+ Remove a locale changed handler.
140
+
141
+ #### Parameters
142
+
143
+ • **id**: `string`
144
+
145
+ The id of the handler.
146
+
147
+ #### Returns
148
+
149
+ `void`
150
+
151
+ ***
152
+
153
+ ### addDictionaryHandler()
154
+
155
+ > `static` **addDictionaryHandler**(`id`, `handler`): `void`
156
+
157
+ Add a dictionary changed handler.
158
+
159
+ #### Parameters
160
+
161
+ • **id**: `string`
162
+
163
+ The id of the handler.
164
+
165
+ • **handler**
166
+
167
+ The handler to add.
168
+
169
+ #### Returns
170
+
171
+ `void`
172
+
173
+ ***
174
+
175
+ ### removeDictionaryHandler()
176
+
177
+ > `static` **removeDictionaryHandler**(`id`): `void`
178
+
179
+ Remove a dictionary changed handler.
180
+
181
+ #### Parameters
182
+
183
+ • **id**: `string`
184
+
185
+ The id of the handler.
186
+
187
+ #### Returns
188
+
189
+ `void`
190
+
191
+ ***
192
+
193
+ ### formatMessage()
194
+
195
+ > `static` **formatMessage**(`key`, `values`?, `overrideLocale`?): `string`
196
+
197
+ Format a message.
198
+
199
+ #### Parameters
200
+
201
+ • **key**: `string`
202
+
203
+ The key of the message to format.
204
+
205
+ • **values?**
206
+
207
+ The values to substitute into the message.
208
+
209
+ • **overrideLocale?**: `string`
210
+
211
+ Override the locale.
212
+
213
+ #### Returns
214
+
215
+ `string`
216
+
217
+ The formatted string.
218
+
219
+ ***
220
+
221
+ ### hasMessage()
222
+
223
+ > `static` **hasMessage**(`key`): `boolean`
224
+
225
+ Check if the dictionaries have a message for the given key.
226
+
227
+ #### Parameters
228
+
229
+ • **key**: `string`
230
+
231
+ The key to check for existence.
232
+
233
+ #### Returns
234
+
235
+ `boolean`
236
+
237
+ True if the key exists.