@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,167 @@
1
+ # Class: Url
2
+
3
+ Class to help with urls.
4
+
5
+ ## Constructors
6
+
7
+ ### new Url()
8
+
9
+ > **new Url**(`url`): [`Url`](Url.md)
10
+
11
+ Create a new instance of Url.
12
+
13
+ #### Parameters
14
+
15
+ • **url**: `string`
16
+
17
+ The url string.
18
+
19
+ #### Returns
20
+
21
+ [`Url`](Url.md)
22
+
23
+ ## Methods
24
+
25
+ ### tryParseExact()
26
+
27
+ > `static` **tryParseExact**(`url`): `undefined` \| [`Url`](Url.md)
28
+
29
+ Try and parse a string into the url parts.
30
+
31
+ #### Parameters
32
+
33
+ • **url**: `unknown`
34
+
35
+ The url to parse.
36
+
37
+ #### Returns
38
+
39
+ `undefined` \| [`Url`](Url.md)
40
+
41
+ The formatted url or undefined if the value is not a url.
42
+
43
+ ***
44
+
45
+ ### guard()
46
+
47
+ > `static` **guard**(`source`, `property`, `value`): `asserts value is string`
48
+
49
+ Parse a string into the url parts.
50
+
51
+ #### Parameters
52
+
53
+ • **source**: `string`
54
+
55
+ The source of the error.
56
+
57
+ • **property**: `string`
58
+
59
+ The name of the property.
60
+
61
+ • **value**: `unknown`
62
+
63
+ The url to parse.
64
+
65
+ #### Returns
66
+
67
+ `asserts value is string`
68
+
69
+ #### Throws
70
+
71
+ GuardError If the value does not match the assertion.
72
+
73
+ ***
74
+
75
+ ### validate()
76
+
77
+ > `static` **validate**(`property`, `value`, `failures`): `value is Url`
78
+
79
+ Validate a string as a Url.
80
+
81
+ #### Parameters
82
+
83
+ • **property**: `string`
84
+
85
+ Throw an exception if the url property is invalid.
86
+
87
+ • **value**: `unknown`
88
+
89
+ The url to parse.
90
+
91
+ • **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
92
+
93
+ The list of failures to add to.
94
+
95
+ #### Returns
96
+
97
+ `value is Url`
98
+
99
+ The formatted url.
100
+
101
+ ***
102
+
103
+ ### fromURLToParts()
104
+
105
+ > `static` **fromURLToParts**(`url`): [`IUrlParts`](../interfaces/IUrlParts.md)
106
+
107
+ Construct a url from a URL.
108
+
109
+ #### Parameters
110
+
111
+ • **url**: `URL`
112
+
113
+ The url to construct from.
114
+
115
+ #### Returns
116
+
117
+ [`IUrlParts`](../interfaces/IUrlParts.md)
118
+
119
+ The formatted url.
120
+
121
+ ***
122
+
123
+ ### fromParts()
124
+
125
+ > `static` **fromParts**(`urlParts`): [`Url`](Url.md)
126
+
127
+ Construct a url from valid parts.
128
+
129
+ #### Parameters
130
+
131
+ • **urlParts**: [`IUrlParts`](../interfaces/IUrlParts.md)
132
+
133
+ The url to create the parts from.
134
+
135
+ #### Returns
136
+
137
+ [`Url`](Url.md)
138
+
139
+ The formatted url.
140
+
141
+ ***
142
+
143
+ ### parts()
144
+
145
+ > **parts**(): [`IUrlParts`](../interfaces/IUrlParts.md)
146
+
147
+ Get the parts of the url.
148
+
149
+ #### Returns
150
+
151
+ [`IUrlParts`](../interfaces/IUrlParts.md)
152
+
153
+ The parts of the url.
154
+
155
+ ***
156
+
157
+ ### toString()
158
+
159
+ > **toString**(): `string`
160
+
161
+ Convert the parts in to a full string.
162
+
163
+ #### Returns
164
+
165
+ `string`
166
+
167
+ The formatted url.
@@ -0,0 +1,295 @@
1
+ # Class: Urn
2
+
3
+ Class to help with urns.
4
+
5
+ ## Constructors
6
+
7
+ ### new Urn()
8
+
9
+ > **new Urn**(`namespaceIdentifier`, `namespaceSpecific`): [`Urn`](Urn.md)
10
+
11
+ Create a new instance of Urn.
12
+
13
+ #### Parameters
14
+
15
+ • **namespaceIdentifier**: `string`
16
+
17
+ The identifier for the namespace.
18
+
19
+ • **namespaceSpecific**: `string` \| `string`[]
20
+
21
+ The specific part of the namespace.
22
+
23
+ #### Returns
24
+
25
+ [`Urn`](Urn.md)
26
+
27
+ ## Methods
28
+
29
+ ### generateRandom()
30
+
31
+ > `static` **generateRandom**(`namespace`): [`Urn`](Urn.md)
32
+
33
+ Generate a random identifier with 32 byte id.
34
+
35
+ #### Parameters
36
+
37
+ • **namespace**: `string`
38
+
39
+ The prefix for the urn.
40
+
41
+ #### Returns
42
+
43
+ [`Urn`](Urn.md)
44
+
45
+ A new Id in URN format.
46
+
47
+ ***
48
+
49
+ ### hasNamespace()
50
+
51
+ > `static` **hasNamespace**(`urn`, `namespace`): `boolean`
52
+
53
+ Does the provided urn match the namespace.
54
+
55
+ #### Parameters
56
+
57
+ • **urn**: `string`
58
+
59
+ The urn to check.
60
+
61
+ • **namespace**: `string`
62
+
63
+ The namespace to match.
64
+
65
+ #### Returns
66
+
67
+ `boolean`
68
+
69
+ True if the namespace matches.
70
+
71
+ ***
72
+
73
+ ### tryParseExact()
74
+
75
+ > `static` **tryParseExact**(`urn`): `undefined` \| [`Urn`](Urn.md)
76
+
77
+ Try and parse a string into the urn parts.
78
+
79
+ #### Parameters
80
+
81
+ • **urn**: `unknown`
82
+
83
+ The urn to parse.
84
+
85
+ #### Returns
86
+
87
+ `undefined` \| [`Urn`](Urn.md)
88
+
89
+ The formatted urn or undefined if the value is not a urn.
90
+
91
+ ***
92
+
93
+ ### fromValidString()
94
+
95
+ > `static` **fromValidString**(`urn`): [`Urn`](Urn.md)
96
+
97
+ Construct a urn from a string that has already been validated.
98
+
99
+ #### Parameters
100
+
101
+ • **urn**: `string`
102
+
103
+ The urn to parse.
104
+
105
+ #### Returns
106
+
107
+ [`Urn`](Urn.md)
108
+
109
+ The formatted urn.
110
+
111
+ ***
112
+
113
+ ### addPrefix()
114
+
115
+ > `static` **addPrefix**(`urn`): `undefined` \| `string`
116
+
117
+ Add a urn: prefix if there isn't one already.
118
+
119
+ #### Parameters
120
+
121
+ • **urn**: `unknown`
122
+
123
+ The urn string to add a prefix to.
124
+
125
+ #### Returns
126
+
127
+ `undefined` \| `string`
128
+
129
+ The urn with a prefix.
130
+
131
+ ***
132
+
133
+ ### guard()
134
+
135
+ > `static` **guard**(`source`, `property`, `value`): `asserts value is string`
136
+
137
+ Parse a string into the urn parts.
138
+
139
+ #### Parameters
140
+
141
+ • **source**: `string`
142
+
143
+ The source of the error.
144
+
145
+ • **property**: `string`
146
+
147
+ The name of the property.
148
+
149
+ • **value**: `unknown`
150
+
151
+ The urn to parse.
152
+
153
+ #### Returns
154
+
155
+ `asserts value is string`
156
+
157
+ #### Throws
158
+
159
+ GuardError If the value does not match the assertion.
160
+
161
+ ***
162
+
163
+ ### validate()
164
+
165
+ > `static` **validate**(`property`, `value`, `failures`): `value is string`
166
+
167
+ Validate a string as a Urn.
168
+
169
+ #### Parameters
170
+
171
+ • **property**: `string`
172
+
173
+ Throw an exception if the urn property is invalid.
174
+
175
+ • **value**: `unknown`
176
+
177
+ The urn to parse.
178
+
179
+ • **failures**: [`IValidationFailure`](../interfaces/IValidationFailure.md)[]
180
+
181
+ The list of failures to add to.
182
+
183
+ #### Returns
184
+
185
+ `value is string`
186
+
187
+ The formatted urn.
188
+
189
+ ***
190
+
191
+ ### parts()
192
+
193
+ > **parts**(`startIndex`): `string`[]
194
+
195
+ Get the parts.
196
+
197
+ #### Parameters
198
+
199
+ • **startIndex**: `number` = `0`
200
+
201
+ The index to start from, defaults to 0.
202
+
203
+ #### Returns
204
+
205
+ `string`[]
206
+
207
+ The parts.
208
+
209
+ ***
210
+
211
+ ### namespaceIdentifier()
212
+
213
+ > **namespaceIdentifier**(): `string`
214
+
215
+ Get the namespace identifier.
216
+
217
+ #### Returns
218
+
219
+ `string`
220
+
221
+ The namespace identifier.
222
+
223
+ ***
224
+
225
+ ### namespaceMethod()
226
+
227
+ > **namespaceMethod**(): `string`
228
+
229
+ Get the namespace method, the first component after the identifier.
230
+
231
+ #### Returns
232
+
233
+ `string`
234
+
235
+ The namespace method.
236
+
237
+ ***
238
+
239
+ ### namespaceSpecificParts()
240
+
241
+ > **namespaceSpecificParts**(`startIndex`): `string`[]
242
+
243
+ Get the namespace specific parts.
244
+
245
+ #### Parameters
246
+
247
+ • **startIndex**: `number` = `0`
248
+
249
+ The index to start from, defaults to 0.
250
+
251
+ #### Returns
252
+
253
+ `string`[]
254
+
255
+ The namespace specific parts.
256
+
257
+ ***
258
+
259
+ ### namespaceSpecific()
260
+
261
+ > **namespaceSpecific**(`startIndex`): `string`
262
+
263
+ Get the namespace specific.
264
+
265
+ #### Parameters
266
+
267
+ • **startIndex**: `number` = `0`
268
+
269
+ The index to start from, defaults to 0.
270
+
271
+ #### Returns
272
+
273
+ `string`
274
+
275
+ The namespace specific.
276
+
277
+ ***
278
+
279
+ ### toString()
280
+
281
+ > **toString**(`omitPrefix`): `string`
282
+
283
+ Convert the parts in to a full string.
284
+
285
+ #### Parameters
286
+
287
+ • **omitPrefix**: `boolean` = `true`
288
+
289
+ Omit the urn: prefix from the string.
290
+
291
+ #### Returns
292
+
293
+ `string`
294
+
295
+ The formatted urn.