@twin.org/core 0.0.1-next.5 → 0.0.1-next.50

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 (66) hide show
  1. package/dist/cjs/index.cjs +1401 -736
  2. package/dist/esm/index.mjs +1398 -737
  3. package/dist/types/encoding/base58.d.ts +18 -0
  4. package/dist/types/factories/factory.d.ts +20 -1
  5. package/dist/types/helpers/envHelper.d.ts +16 -0
  6. package/dist/types/helpers/jsonHelper.d.ts +30 -0
  7. package/dist/types/helpers/objectHelper.d.ts +33 -0
  8. package/dist/types/helpers/uint8ArrayHelper.d.ts +11 -0
  9. package/dist/types/index.d.ts +4 -0
  10. package/dist/types/models/IComponent.d.ts +12 -3
  11. package/dist/types/models/coerceType.d.ts +49 -0
  12. package/dist/types/models/compressionType.d.ts +1 -1
  13. package/dist/types/utils/asyncCache.d.ts +8 -0
  14. package/dist/types/utils/coerce.d.ts +22 -0
  15. package/dist/types/utils/converter.d.ts +12 -0
  16. package/dist/types/utils/guards.d.ts +16 -0
  17. package/dist/types/utils/is.d.ts +12 -0
  18. package/dist/types/utils/validation.d.ts +2 -0
  19. package/docs/changelog.md +8 -1
  20. package/docs/reference/classes/AlreadyExistsError.md +67 -25
  21. package/docs/reference/classes/ArrayHelper.md +6 -2
  22. package/docs/reference/classes/AsyncCache.md +56 -6
  23. package/docs/reference/classes/Base32.md +6 -2
  24. package/docs/reference/classes/Base58.md +61 -0
  25. package/docs/reference/classes/Base64.md +9 -3
  26. package/docs/reference/classes/Base64Url.md +6 -2
  27. package/docs/reference/classes/BaseError.md +65 -23
  28. package/docs/reference/classes/BitString.md +18 -6
  29. package/docs/reference/classes/Coerce.md +104 -8
  30. package/docs/reference/classes/Compression.md +16 -8
  31. package/docs/reference/classes/ConflictError.md +70 -26
  32. package/docs/reference/classes/Converter.md +104 -20
  33. package/docs/reference/classes/EnvHelper.md +43 -0
  34. package/docs/reference/classes/ErrorHelper.md +9 -3
  35. package/docs/reference/classes/Factory.md +78 -10
  36. package/docs/reference/classes/FilenameHelper.md +3 -1
  37. package/docs/reference/classes/GeneralError.md +65 -25
  38. package/docs/reference/classes/GuardError.md +70 -26
  39. package/docs/reference/classes/Guards.md +286 -74
  40. package/docs/reference/classes/HexHelper.md +15 -5
  41. package/docs/reference/classes/I18n.md +42 -16
  42. package/docs/reference/classes/Is.md +160 -44
  43. package/docs/reference/classes/JsonHelper.md +137 -5
  44. package/docs/reference/classes/NotFoundError.md +67 -25
  45. package/docs/reference/classes/NotImplementedError.md +61 -23
  46. package/docs/reference/classes/NotSupportedError.md +64 -24
  47. package/docs/reference/classes/ObjectHelper.md +188 -20
  48. package/docs/reference/classes/RandomHelper.md +3 -1
  49. package/docs/reference/classes/StringHelper.md +51 -17
  50. package/docs/reference/classes/Uint8ArrayHelper.md +35 -0
  51. package/docs/reference/classes/UnauthorizedError.md +64 -24
  52. package/docs/reference/classes/UnprocessableError.md +65 -25
  53. package/docs/reference/classes/Url.md +30 -10
  54. package/docs/reference/classes/Urn.md +54 -18
  55. package/docs/reference/classes/Validation.md +315 -109
  56. package/docs/reference/classes/ValidationError.md +64 -24
  57. package/docs/reference/index.md +5 -0
  58. package/docs/reference/interfaces/IComponent.md +30 -8
  59. package/docs/reference/interfaces/IError.md +1 -1
  60. package/docs/reference/interfaces/ILocaleDictionary.md +1 -1
  61. package/docs/reference/interfaces/IValidationFailure.md +1 -1
  62. package/docs/reference/type-aliases/CoerceType.md +5 -0
  63. package/docs/reference/variables/CoerceType.md +67 -0
  64. package/docs/reference/variables/CompressionType.md +1 -1
  65. package/locales/en.json +21 -1
  66. package/package.json +6 -6
@@ -20,15 +20,21 @@ Create a new factory, which is shared throughout all library instances.
20
20
 
21
21
  #### Parameters
22
22
 
23
- **typeName**: `string`
23
+ ##### typeName
24
+
25
+ `string`
24
26
 
25
27
  The type name for the instances.
26
28
 
27
- **autoInstance**: `boolean` = `false`
29
+ ##### autoInstance
30
+
31
+ `boolean` = `false`
28
32
 
29
33
  Automatically create an instance when registered.
30
34
 
31
- **matcher?**
35
+ ##### matcher?
36
+
37
+ (`names`, `name`) => `undefined` \| `string`
32
38
 
33
39
  Match the name of the instance.
34
40
 
@@ -40,6 +46,44 @@ The factory instance.
40
46
 
41
47
  ***
42
48
 
49
+ ### getFactories()
50
+
51
+ > `static` **getFactories**(): `object`
52
+
53
+ Get all the factories.
54
+
55
+ #### Returns
56
+
57
+ `object`
58
+
59
+ All the factories.
60
+
61
+ ***
62
+
63
+ ### resetFactories()
64
+
65
+ > `static` **resetFactories**(): `void`
66
+
67
+ Reset all the factories, which removes any created instances, but not the registrations.
68
+
69
+ #### Returns
70
+
71
+ `void`
72
+
73
+ ***
74
+
75
+ ### clearFactories()
76
+
77
+ > `static` **clearFactories**(): `void`
78
+
79
+ Clear all the factories, which removes anything registered with the factories.
80
+
81
+ #### Returns
82
+
83
+ `void`
84
+
85
+ ***
86
+
43
87
  ### register()
44
88
 
45
89
  > **register**\<`U`\>(`name`, `generator`): `void`
@@ -52,11 +96,15 @@ Register a new generator.
52
96
 
53
97
  #### Parameters
54
98
 
55
- **name**: `string`
99
+ ##### name
100
+
101
+ `string`
56
102
 
57
103
  The name of the generator.
58
104
 
59
- **generator**
105
+ ##### generator
106
+
107
+ () => `U`
60
108
 
61
109
  The function to create an instance.
62
110
 
@@ -74,7 +122,9 @@ Unregister a generator.
74
122
 
75
123
  #### Parameters
76
124
 
77
- **name**: `string`
125
+ ##### name
126
+
127
+ `string`
78
128
 
79
129
  The name of the generator to unregister.
80
130
 
@@ -104,7 +154,9 @@ Get a generator instance.
104
154
 
105
155
  #### Parameters
106
156
 
107
- **name**: `string`
157
+ ##### name
158
+
159
+ `string`
108
160
 
109
161
  The name of the instance to generate.
110
162
 
@@ -136,7 +188,9 @@ Get a generator instance with no exceptions.
136
188
 
137
189
  #### Parameters
138
190
 
139
- **name**: `string`
191
+ ##### name
192
+
193
+ `string`
140
194
 
141
195
  The name of the instance to generate.
142
196
 
@@ -152,7 +206,19 @@ An instance of the item or undefined if it does not exist.
152
206
 
153
207
  > **reset**(): `void`
154
208
 
155
- Reset all the instances.
209
+ Remove all the instances and leave the generators intact.
210
+
211
+ #### Returns
212
+
213
+ `void`
214
+
215
+ ***
216
+
217
+ ### clear()
218
+
219
+ > **clear**(): `void`
220
+
221
+ Remove all the instances and the generators.
156
222
 
157
223
  #### Returns
158
224
 
@@ -210,7 +276,9 @@ Does the factory contain the name.
210
276
 
211
277
  #### Parameters
212
278
 
213
- **name**: `string`
279
+ ##### name
280
+
281
+ `string`
214
282
 
215
283
  The name of the instance to find.
216
284
 
@@ -22,7 +22,9 @@ Replaces any unsafe characters in the filename.
22
22
 
23
23
  #### Parameters
24
24
 
25
- **filename**: `unknown`
25
+ ##### filename
26
+
27
+ `unknown`
26
28
 
27
29
  The filename to make safe.
28
30
 
@@ -16,19 +16,25 @@ Create a new instance of GeneralError.
16
16
 
17
17
  #### Parameters
18
18
 
19
- **source**: `string`
19
+ ##### source
20
+
21
+ `string`
20
22
 
21
23
  The source of the error.
22
24
 
23
- **message**: `string`
25
+ ##### message
26
+
27
+ `string`
24
28
 
25
29
  The message as a code.
26
30
 
27
- **properties?**
31
+ ##### properties?
28
32
 
29
33
  Any additional information for the error.
30
34
 
31
- **inner?**: `unknown`
35
+ ##### inner?
36
+
37
+ `unknown`
32
38
 
33
39
  The inner error if we have wrapped another error.
34
40
 
@@ -50,7 +56,7 @@ The source of the error.
50
56
 
51
57
  #### Inherited from
52
58
 
53
- [`BaseError`](BaseError.md).[`source`](BaseError.md#source)
59
+ [`BaseError`](BaseError.md).[`source`](BaseError.md#source-1)
54
60
 
55
61
  ***
56
62
 
@@ -62,11 +68,11 @@ Any additional information for the error.
62
68
 
63
69
  #### Index Signature
64
70
 
65
- \[`id`: `string`\]: `unknown`
71
+ \[`id`: `string`\]: `unknown`
66
72
 
67
73
  #### Inherited from
68
74
 
69
- [`BaseError`](BaseError.md).[`properties`](BaseError.md#properties)
75
+ [`BaseError`](BaseError.md).[`properties`](BaseError.md#properties-1)
70
76
 
71
77
  ***
72
78
 
@@ -78,7 +84,7 @@ The inner error if there was one.
78
84
 
79
85
  #### Inherited from
80
86
 
81
- [`BaseError`](BaseError.md).[`inner`](BaseError.md#inner)
87
+ [`BaseError`](BaseError.md).[`inner`](BaseError.md#inner-1)
82
88
 
83
89
  ***
84
90
 
@@ -98,7 +104,9 @@ Construct an error from an existing one.
98
104
 
99
105
  #### Parameters
100
106
 
101
- **err**: `unknown`
107
+ ##### err
108
+
109
+ `unknown`
102
110
 
103
111
  The existing error.
104
112
 
@@ -122,7 +130,9 @@ Flatten an error tree.
122
130
 
123
131
  #### Parameters
124
132
 
125
- **err**: `unknown`
133
+ ##### err
134
+
135
+ `unknown`
126
136
 
127
137
  The starting error.
128
138
 
@@ -146,10 +156,12 @@ Expand an error tree.
146
156
 
147
157
  #### Parameters
148
158
 
149
- **errors**: `undefined` \| [`IError`](../interfaces/IError.md)[]
159
+ ##### errors
150
160
 
151
161
  The list of errors to expand.
152
162
 
163
+ `undefined` | [`IError`](../interfaces/IError.md)[]
164
+
153
165
  #### Returns
154
166
 
155
167
  `undefined` \| [`IError`](../interfaces/IError.md)
@@ -170,14 +182,18 @@ Test to see if the error has the specified error name.
170
182
 
171
183
  #### Parameters
172
184
 
173
- **error**: `unknown`
185
+ ##### error
186
+
187
+ `unknown`
174
188
 
175
189
  The error to test.
176
190
 
177
- **name**: `string` \| `RegExp`
191
+ ##### name
178
192
 
179
193
  The name to check for.
180
194
 
195
+ `string` | `RegExp`
196
+
181
197
  #### Returns
182
198
 
183
199
  `error is BaseError`
@@ -198,14 +214,18 @@ Test to see if the error has the specified error message.
198
214
 
199
215
  #### Parameters
200
216
 
201
- **error**: `unknown`
217
+ ##### error
218
+
219
+ `unknown`
202
220
 
203
221
  The error to test.
204
222
 
205
- **message**: `string` \| `RegExp`
223
+ ##### message
206
224
 
207
225
  The message to check for.
208
226
 
227
+ `string` | `RegExp`
228
+
209
229
  #### Returns
210
230
 
211
231
  `error is BaseError`
@@ -226,14 +246,18 @@ Test to see if the error has the specified error code.
226
246
 
227
247
  #### Parameters
228
248
 
229
- **error**: `unknown`
249
+ ##### error
250
+
251
+ `unknown`
230
252
 
231
253
  The error to test.
232
254
 
233
- **code**: `string` \| `RegExp`
255
+ ##### code
234
256
 
235
257
  The code to check for.
236
258
 
259
+ `string` | `RegExp`
260
+
237
261
  #### Returns
238
262
 
239
263
  `boolean`
@@ -254,14 +278,18 @@ Test to see if any of the errors or children have the given error name.
254
278
 
255
279
  #### Parameters
256
280
 
257
- **error**: `unknown`
281
+ ##### error
282
+
283
+ `unknown`
258
284
 
259
285
  The error to test.
260
286
 
261
- **name**: `string` \| `RegExp`
287
+ ##### name
262
288
 
263
289
  The name to check for.
264
290
 
291
+ `string` | `RegExp`
292
+
265
293
  #### Returns
266
294
 
267
295
  `error is BaseError`
@@ -282,14 +310,18 @@ Test to see if any of the errors or children have the given error message.
282
310
 
283
311
  #### Parameters
284
312
 
285
- **error**: `unknown`
313
+ ##### error
314
+
315
+ `unknown`
286
316
 
287
317
  The error to test.
288
318
 
289
- **message**: `string` \| `RegExp`
319
+ ##### message
290
320
 
291
321
  The message to check for.
292
322
 
323
+ `string` | `RegExp`
324
+
293
325
  #### Returns
294
326
 
295
327
  `error is BaseError`
@@ -310,11 +342,15 @@ Test to see if any of the errors or children are from a specific class.
310
342
 
311
343
  #### Parameters
312
344
 
313
- **error**: `unknown`
345
+ ##### error
346
+
347
+ `unknown`
314
348
 
315
349
  The error to test.
316
350
 
317
- **cls**: `string`
351
+ ##### cls
352
+
353
+ `string`
318
354
 
319
355
  The class to check for.
320
356
 
@@ -338,14 +374,18 @@ Test to see if any of the errors or children have the given error code.
338
374
 
339
375
  #### Parameters
340
376
 
341
- **error**: `unknown`
377
+ ##### error
378
+
379
+ `unknown`
342
380
 
343
381
  The error to test.
344
382
 
345
- **code**: `string` \| `RegExp`
383
+ ##### code
346
384
 
347
385
  The code to check for.
348
386
 
387
+ `string` | `RegExp`
388
+
349
389
  #### Returns
350
390
 
351
391
  `error is BaseError`
@@ -16,23 +16,33 @@ Create a new instance of GuardError.
16
16
 
17
17
  #### Parameters
18
18
 
19
- **source**: `string`
19
+ ##### source
20
+
21
+ `string`
20
22
 
21
23
  The source of the error.
22
24
 
23
- **message**: `string`
25
+ ##### message
26
+
27
+ `string`
24
28
 
25
29
  The message as a code.
26
30
 
27
- **propertyName**: `string`
31
+ ##### propertyName
32
+
33
+ `string`
28
34
 
29
35
  The property which triggered the guard error for the item.
30
36
 
31
- **propertyValue**: `unknown`
37
+ ##### propertyValue
38
+
39
+ `unknown`
32
40
 
33
41
  The property value which triggered the guard error for the item.
34
42
 
35
- **propertyOptions?**: `string`
43
+ ##### propertyOptions?
44
+
45
+ `string`
36
46
 
37
47
  The property options which might be allowed.
38
48
 
@@ -54,7 +64,7 @@ The source of the error.
54
64
 
55
65
  #### Inherited from
56
66
 
57
- [`BaseError`](BaseError.md).[`source`](BaseError.md#source)
67
+ [`BaseError`](BaseError.md).[`source`](BaseError.md#source-1)
58
68
 
59
69
  ***
60
70
 
@@ -66,11 +76,11 @@ Any additional information for the error.
66
76
 
67
77
  #### Index Signature
68
78
 
69
- \[`id`: `string`\]: `unknown`
79
+ \[`id`: `string`\]: `unknown`
70
80
 
71
81
  #### Inherited from
72
82
 
73
- [`BaseError`](BaseError.md).[`properties`](BaseError.md#properties)
83
+ [`BaseError`](BaseError.md).[`properties`](BaseError.md#properties-1)
74
84
 
75
85
  ***
76
86
 
@@ -82,7 +92,7 @@ The inner error if there was one.
82
92
 
83
93
  #### Inherited from
84
94
 
85
- [`BaseError`](BaseError.md).[`inner`](BaseError.md#inner)
95
+ [`BaseError`](BaseError.md).[`inner`](BaseError.md#inner-1)
86
96
 
87
97
  ***
88
98
 
@@ -102,7 +112,9 @@ Construct an error from an existing one.
102
112
 
103
113
  #### Parameters
104
114
 
105
- **err**: `unknown`
115
+ ##### err
116
+
117
+ `unknown`
106
118
 
107
119
  The existing error.
108
120
 
@@ -126,7 +138,9 @@ Flatten an error tree.
126
138
 
127
139
  #### Parameters
128
140
 
129
- **err**: `unknown`
141
+ ##### err
142
+
143
+ `unknown`
130
144
 
131
145
  The starting error.
132
146
 
@@ -150,10 +164,12 @@ Expand an error tree.
150
164
 
151
165
  #### Parameters
152
166
 
153
- **errors**: `undefined` \| [`IError`](../interfaces/IError.md)[]
167
+ ##### errors
154
168
 
155
169
  The list of errors to expand.
156
170
 
171
+ `undefined` | [`IError`](../interfaces/IError.md)[]
172
+
157
173
  #### Returns
158
174
 
159
175
  `undefined` \| [`IError`](../interfaces/IError.md)
@@ -174,14 +190,18 @@ Test to see if the error has the specified error name.
174
190
 
175
191
  #### Parameters
176
192
 
177
- **error**: `unknown`
193
+ ##### error
194
+
195
+ `unknown`
178
196
 
179
197
  The error to test.
180
198
 
181
- **name**: `string` \| `RegExp`
199
+ ##### name
182
200
 
183
201
  The name to check for.
184
202
 
203
+ `string` | `RegExp`
204
+
185
205
  #### Returns
186
206
 
187
207
  `error is BaseError`
@@ -202,14 +222,18 @@ Test to see if the error has the specified error message.
202
222
 
203
223
  #### Parameters
204
224
 
205
- **error**: `unknown`
225
+ ##### error
226
+
227
+ `unknown`
206
228
 
207
229
  The error to test.
208
230
 
209
- **message**: `string` \| `RegExp`
231
+ ##### message
210
232
 
211
233
  The message to check for.
212
234
 
235
+ `string` | `RegExp`
236
+
213
237
  #### Returns
214
238
 
215
239
  `error is BaseError`
@@ -230,14 +254,18 @@ Test to see if the error has the specified error code.
230
254
 
231
255
  #### Parameters
232
256
 
233
- **error**: `unknown`
257
+ ##### error
258
+
259
+ `unknown`
234
260
 
235
261
  The error to test.
236
262
 
237
- **code**: `string` \| `RegExp`
263
+ ##### code
238
264
 
239
265
  The code to check for.
240
266
 
267
+ `string` | `RegExp`
268
+
241
269
  #### Returns
242
270
 
243
271
  `boolean`
@@ -258,14 +286,18 @@ Test to see if any of the errors or children have the given error name.
258
286
 
259
287
  #### Parameters
260
288
 
261
- **error**: `unknown`
289
+ ##### error
290
+
291
+ `unknown`
262
292
 
263
293
  The error to test.
264
294
 
265
- **name**: `string` \| `RegExp`
295
+ ##### name
266
296
 
267
297
  The name to check for.
268
298
 
299
+ `string` | `RegExp`
300
+
269
301
  #### Returns
270
302
 
271
303
  `error is BaseError`
@@ -286,14 +318,18 @@ Test to see if any of the errors or children have the given error message.
286
318
 
287
319
  #### Parameters
288
320
 
289
- **error**: `unknown`
321
+ ##### error
322
+
323
+ `unknown`
290
324
 
291
325
  The error to test.
292
326
 
293
- **message**: `string` \| `RegExp`
327
+ ##### message
294
328
 
295
329
  The message to check for.
296
330
 
331
+ `string` | `RegExp`
332
+
297
333
  #### Returns
298
334
 
299
335
  `error is BaseError`
@@ -314,11 +350,15 @@ Test to see if any of the errors or children are from a specific class.
314
350
 
315
351
  #### Parameters
316
352
 
317
- **error**: `unknown`
353
+ ##### error
354
+
355
+ `unknown`
318
356
 
319
357
  The error to test.
320
358
 
321
- **cls**: `string`
359
+ ##### cls
360
+
361
+ `string`
322
362
 
323
363
  The class to check for.
324
364
 
@@ -342,14 +382,18 @@ Test to see if any of the errors or children have the given error code.
342
382
 
343
383
  #### Parameters
344
384
 
345
- **error**: `unknown`
385
+ ##### error
386
+
387
+ `unknown`
346
388
 
347
389
  The error to test.
348
390
 
349
- **code**: `string` \| `RegExp`
391
+ ##### code
350
392
 
351
393
  The code to check for.
352
394
 
395
+ `string` | `RegExp`
396
+
353
397
  #### Returns
354
398
 
355
399
  `error is BaseError`