@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
@@ -30,7 +30,9 @@ Set the locale.
30
30
 
31
31
  #### Parameters
32
32
 
33
- **locale**: `string`
33
+ ##### locale
34
+
35
+ `string`
34
36
 
35
37
  The new locale.
36
38
 
@@ -62,11 +64,15 @@ Add a locale dictionary.
62
64
 
63
65
  #### Parameters
64
66
 
65
- **locale**: `string`
67
+ ##### locale
68
+
69
+ `string`
66
70
 
67
71
  The locale.
68
72
 
69
- **dictionary**: [`ILocaleDictionary`](../interfaces/ILocaleDictionary.md)
73
+ ##### dictionary
74
+
75
+ [`ILocaleDictionary`](../interfaces/ILocaleDictionary.md)
70
76
 
71
77
  The dictionary to add.
72
78
 
@@ -78,19 +84,21 @@ The dictionary to add.
78
84
 
79
85
  ### getDictionary()
80
86
 
81
- > `static` **getDictionary**(`locale`): `undefined` \| `object`
87
+ > `static` **getDictionary**(`locale`): `undefined` \| \{\}
82
88
 
83
89
  Get a locale dictionary.
84
90
 
85
91
  #### Parameters
86
92
 
87
- **locale**: `string`
93
+ ##### locale
94
+
95
+ `string`
88
96
 
89
97
  The locale.
90
98
 
91
99
  #### Returns
92
100
 
93
- `undefined` \| `object`
101
+ `undefined` \| \{\}
94
102
 
95
103
  The dictionary of undefined if it does not exist.
96
104
 
@@ -118,11 +126,15 @@ Add a locale changed handler.
118
126
 
119
127
  #### Parameters
120
128
 
121
- **id**: `string`
129
+ ##### id
130
+
131
+ `string`
122
132
 
123
133
  The id of the handler.
124
134
 
125
- **handler**
135
+ ##### handler
136
+
137
+ (`locale`) => `void`
126
138
 
127
139
  The handler to add.
128
140
 
@@ -140,7 +152,9 @@ Remove a locale changed handler.
140
152
 
141
153
  #### Parameters
142
154
 
143
- **id**: `string`
155
+ ##### id
156
+
157
+ `string`
144
158
 
145
159
  The id of the handler.
146
160
 
@@ -158,11 +172,15 @@ Add a dictionary changed handler.
158
172
 
159
173
  #### Parameters
160
174
 
161
- **id**: `string`
175
+ ##### id
176
+
177
+ `string`
162
178
 
163
179
  The id of the handler.
164
180
 
165
- **handler**
181
+ ##### handler
182
+
183
+ (`locale`) => `void`
166
184
 
167
185
  The handler to add.
168
186
 
@@ -180,7 +198,9 @@ Remove a dictionary changed handler.
180
198
 
181
199
  #### Parameters
182
200
 
183
- **id**: `string`
201
+ ##### id
202
+
203
+ `string`
184
204
 
185
205
  The id of the handler.
186
206
 
@@ -198,15 +218,19 @@ Format a message.
198
218
 
199
219
  #### Parameters
200
220
 
201
- **key**: `string`
221
+ ##### key
222
+
223
+ `string`
202
224
 
203
225
  The key of the message to format.
204
226
 
205
- **values?**
227
+ ##### values?
206
228
 
207
229
  The values to substitute into the message.
208
230
 
209
- **overrideLocale?**: `string`
231
+ ##### overrideLocale?
232
+
233
+ `string`
210
234
 
211
235
  Override the locale.
212
236
 
@@ -226,7 +250,9 @@ Check if the dictionaries have a message for the given key.
226
250
 
227
251
  #### Parameters
228
252
 
229
- **key**: `string`
253
+ ##### key
254
+
255
+ `string`
230
256
 
231
257
  The key to check for existence.
232
258
 
@@ -22,7 +22,9 @@ Is the property undefined.
22
22
 
23
23
  #### Parameters
24
24
 
25
- **value**: `unknown`
25
+ ##### value
26
+
27
+ `unknown`
26
28
 
27
29
  The value to test.
28
30
 
@@ -42,7 +44,9 @@ Is the property null.
42
44
 
43
45
  #### Parameters
44
46
 
45
- **value**: `unknown`
47
+ ##### value
48
+
49
+ `unknown`
46
50
 
47
51
  The value to test.
48
52
 
@@ -62,7 +66,9 @@ Is the property null or undefined.
62
66
 
63
67
  #### Parameters
64
68
 
65
- **value**: `unknown`
69
+ ##### value
70
+
71
+ `unknown`
66
72
 
67
73
  The value to test.
68
74
 
@@ -82,7 +88,9 @@ Is the property is not null or undefined.
82
88
 
83
89
  #### Parameters
84
90
 
85
- **value**: `unknown`
91
+ ##### value
92
+
93
+ `unknown`
86
94
 
87
95
  The value to test.
88
96
 
@@ -102,7 +110,9 @@ Is the value a string.
102
110
 
103
111
  #### Parameters
104
112
 
105
- **value**: `unknown`
113
+ ##### value
114
+
115
+ `unknown`
106
116
 
107
117
  The value to test.
108
118
 
@@ -122,7 +132,9 @@ Is the value a string.
122
132
 
123
133
  #### Parameters
124
134
 
125
- **value**: `unknown`
135
+ ##### value
136
+
137
+ `unknown`
126
138
 
127
139
  The value to test.
128
140
 
@@ -142,7 +154,9 @@ Is the value a JSON string.
142
154
 
143
155
  #### Parameters
144
156
 
145
- **value**: `unknown`
157
+ ##### value
158
+
159
+ `unknown`
146
160
 
147
161
  The value to test.
148
162
 
@@ -162,7 +176,9 @@ Is the value a base64 string.
162
176
 
163
177
  #### Parameters
164
178
 
165
- **value**: `unknown`
179
+ ##### value
180
+
181
+ `unknown`
166
182
 
167
183
  The value to test.
168
184
 
@@ -182,7 +198,9 @@ Is the value a base64 url string.
182
198
 
183
199
  #### Parameters
184
200
 
185
- **value**: `unknown`
201
+ ##### value
202
+
203
+ `unknown`
186
204
 
187
205
  The value to test.
188
206
 
@@ -194,6 +212,28 @@ True if the value is a base64 string.
194
212
 
195
213
  ***
196
214
 
215
+ ### stringBase58()
216
+
217
+ > `static` **stringBase58**(`value`): `value is string`
218
+
219
+ Is the value a base58 string.
220
+
221
+ #### Parameters
222
+
223
+ ##### value
224
+
225
+ `unknown`
226
+
227
+ The value to test.
228
+
229
+ #### Returns
230
+
231
+ `value is string`
232
+
233
+ True if the value is a base58 string.
234
+
235
+ ***
236
+
197
237
  ### stringHex()
198
238
 
199
239
  > `static` **stringHex**(`value`, `allowPrefix`): `value is string`
@@ -202,11 +242,15 @@ Is the value a hex string.
202
242
 
203
243
  #### Parameters
204
244
 
205
- **value**: `unknown`
245
+ ##### value
246
+
247
+ `unknown`
206
248
 
207
249
  The value to test.
208
250
 
209
- **allowPrefix**: `boolean` = `false`
251
+ ##### allowPrefix
252
+
253
+ `boolean` = `false`
210
254
 
211
255
  Allow the hex to have the 0x prefix.
212
256
 
@@ -226,15 +270,21 @@ Is the value a hex string of fixed length.
226
270
 
227
271
  #### Parameters
228
272
 
229
- **value**: `unknown`
273
+ ##### value
274
+
275
+ `unknown`
230
276
 
231
277
  The value to test.
232
278
 
233
- **length**: `number`
279
+ ##### length
280
+
281
+ `number`
234
282
 
235
283
  The length to test.
236
284
 
237
- **allowPrefix**: `boolean` = `false`
285
+ ##### allowPrefix
286
+
287
+ `boolean` = `false`
238
288
 
239
289
  Allow the hex to have the 0x prefix.
240
290
 
@@ -254,7 +304,9 @@ Is the value a number.
254
304
 
255
305
  #### Parameters
256
306
 
257
- **value**: `unknown`
307
+ ##### value
308
+
309
+ `unknown`
258
310
 
259
311
  The value to test.
260
312
 
@@ -274,7 +326,9 @@ Is the value an integer.
274
326
 
275
327
  #### Parameters
276
328
 
277
- **value**: `unknown`
329
+ ##### value
330
+
331
+ `unknown`
278
332
 
279
333
  The value to test.
280
334
 
@@ -294,7 +348,9 @@ Is the value a big integer.
294
348
 
295
349
  #### Parameters
296
350
 
297
- **value**: `unknown`
351
+ ##### value
352
+
353
+ `unknown`
298
354
 
299
355
  The value to test.
300
356
 
@@ -314,7 +370,9 @@ Is the value a boolean.
314
370
 
315
371
  #### Parameters
316
372
 
317
- **value**: `unknown`
373
+ ##### value
374
+
375
+ `unknown`
318
376
 
319
377
  The value to test.
320
378
 
@@ -334,7 +392,9 @@ Is the value a date.
334
392
 
335
393
  #### Parameters
336
394
 
337
- **value**: `unknown`
395
+ ##### value
396
+
397
+ `unknown`
338
398
 
339
399
  The value to test.
340
400
 
@@ -354,7 +414,9 @@ Is the value an empty date.
354
414
 
355
415
  #### Parameters
356
416
 
357
- **value**: `unknown`
417
+ ##### value
418
+
419
+ `unknown`
358
420
 
359
421
  The value to test.
360
422
 
@@ -374,7 +436,9 @@ Is the value a date string.
374
436
 
375
437
  #### Parameters
376
438
 
377
- **value**: `unknown`
439
+ ##### value
440
+
441
+ `unknown`
378
442
 
379
443
  The value to test.
380
444
 
@@ -394,7 +458,9 @@ Is the value a date string.
394
458
 
395
459
  #### Parameters
396
460
 
397
- **value**: `unknown`
461
+ ##### value
462
+
463
+ `unknown`
398
464
 
399
465
  The value to test.
400
466
 
@@ -414,7 +480,9 @@ Is the value a time string.
414
480
 
415
481
  #### Parameters
416
482
 
417
- **value**: `unknown`
483
+ ##### value
484
+
485
+ `unknown`
418
486
 
419
487
  The value to test.
420
488
 
@@ -434,7 +502,9 @@ Is the value a timestamp in seconds.
434
502
 
435
503
  #### Parameters
436
504
 
437
- **value**: `unknown`
505
+ ##### value
506
+
507
+ `unknown`
438
508
 
439
509
  The value to test.
440
510
 
@@ -454,7 +524,9 @@ Is the value a timestamp in milliseconds.
454
524
 
455
525
  #### Parameters
456
526
 
457
- **value**: `unknown`
527
+ ##### value
528
+
529
+ `unknown`
458
530
 
459
531
  The value to test.
460
532
 
@@ -474,11 +546,13 @@ Is the value an object.
474
546
 
475
547
  #### Type Parameters
476
548
 
477
- • **T** = `object`
549
+ • **T** = \{\}
478
550
 
479
551
  #### Parameters
480
552
 
481
- **value**: `unknown`
553
+ ##### value
554
+
555
+ `unknown`
482
556
 
483
557
  The value to test.
484
558
 
@@ -498,11 +572,13 @@ Is the value an object with at least one property.
498
572
 
499
573
  #### Type Parameters
500
574
 
501
- • **T** = `object`
575
+ • **T** = \{\}
502
576
 
503
577
  #### Parameters
504
578
 
505
- **value**: `unknown`
579
+ ##### value
580
+
581
+ `unknown`
506
582
 
507
583
  The value to test.
508
584
 
@@ -526,7 +602,9 @@ Is the value an array.
526
602
 
527
603
  #### Parameters
528
604
 
529
- **value**: `unknown`
605
+ ##### value
606
+
607
+ `unknown`
530
608
 
531
609
  The value to test.
532
610
 
@@ -550,7 +628,9 @@ Is the value an array with at least one element.
550
628
 
551
629
  #### Parameters
552
630
 
553
- **value**: `unknown`
631
+ ##### value
632
+
633
+ `unknown`
554
634
 
555
635
  The value to test.
556
636
 
@@ -574,11 +654,15 @@ Is the value an array with at least one element.
574
654
 
575
655
  #### Parameters
576
656
 
577
- **value**: `T`
657
+ ##### value
658
+
659
+ `T`
578
660
 
579
661
  The value to test.
580
662
 
581
- **options**: `T`[]
663
+ ##### options
664
+
665
+ `T`[]
582
666
 
583
667
  The options the value must be one of.
584
668
 
@@ -592,19 +676,21 @@ True if the value is an element from the options array.
592
676
 
593
677
  ### uint8Array()
594
678
 
595
- > `static` **uint8Array**(`value`): `value is Uint8Array`
679
+ > `static` **uint8Array**(`value`): `value is Uint8Array<ArrayBufferLike>`
596
680
 
597
681
  Is the value a Uint8Array.
598
682
 
599
683
  #### Parameters
600
684
 
601
- **value**: `unknown`
685
+ ##### value
686
+
687
+ `unknown`
602
688
 
603
689
  The value to test.
604
690
 
605
691
  #### Returns
606
692
 
607
- `value is Uint8Array`
693
+ `value is Uint8Array<ArrayBufferLike>`
608
694
 
609
695
  True if the value is a Uint8Array.
610
696
 
@@ -612,19 +698,21 @@ True if the value is a Uint8Array.
612
698
 
613
699
  ### typedArray()
614
700
 
615
- > `static` **typedArray**(`value`): value is Int8Array \| Uint8Array \| Int16Array \| Uint16Array \| Int32Array \| Uint32Array \| Float32Array \| Float64Array
701
+ > `static` **typedArray**(`value`): value is Int8Array\<ArrayBufferLike\> \| Uint8Array\<ArrayBufferLike\> \| Int16Array\<ArrayBufferLike\> \| Uint16Array\<ArrayBufferLike\> \| Int32Array\<ArrayBufferLike\> \| Uint32Array\<ArrayBufferLike\> \| Float32Array\<ArrayBufferLike\> \| Float64Array\<ArrayBufferLike\>
616
702
 
617
703
  Is the value a TypedArray.
618
704
 
619
705
  #### Parameters
620
706
 
621
- **value**: `unknown`
707
+ ##### value
708
+
709
+ `unknown`
622
710
 
623
711
  The value to test.
624
712
 
625
713
  #### Returns
626
714
 
627
- value is Int8Array \| Uint8Array \| Int16Array \| Uint16Array \| Int32Array \| Uint32Array \| Float32Array \| Float64Array
715
+ value is Int8Array\<ArrayBufferLike\> \| Uint8Array\<ArrayBufferLike\> \| Int16Array\<ArrayBufferLike\> \| Uint16Array\<ArrayBufferLike\> \| Int32Array\<ArrayBufferLike\> \| Uint32Array\<ArrayBufferLike\> \| Float32Array\<ArrayBufferLike\> \| Float64Array\<ArrayBufferLike\>
628
716
 
629
717
  True if the value is a TypedArray.
630
718
 
@@ -632,19 +720,21 @@ True if the value is a TypedArray.
632
720
 
633
721
  ### function()
634
722
 
635
- > `static` **function**(`value`): `value is Function`
723
+ > `static` **function**(`value`): `value is (args: unknown[]) => unknown`
636
724
 
637
725
  Is the property a function.
638
726
 
639
727
  #### Parameters
640
728
 
641
- **value**: `unknown`
729
+ ##### value
730
+
731
+ `unknown`
642
732
 
643
733
  The value to test.
644
734
 
645
735
  #### Returns
646
736
 
647
- `value is Function`
737
+ `value is (args: unknown[]) => unknown`
648
738
 
649
739
  True if the value is a function.
650
740
 
@@ -658,7 +748,9 @@ Is the value a string formatted as an email address.
658
748
 
659
749
  #### Parameters
660
750
 
661
- **value**: `unknown`
751
+ ##### value
752
+
753
+ `unknown`
662
754
 
663
755
  The value to test.
664
756
 
@@ -682,7 +774,9 @@ Is the value a promise.
682
774
 
683
775
  #### Parameters
684
776
 
685
- **value**: `unknown`
777
+ ##### value
778
+
779
+ `unknown`
686
780
 
687
781
  The value to test.
688
782
 
@@ -691,3 +785,25 @@ The value to test.
691
785
  `value is Promise<T>`
692
786
 
693
787
  True if the value is a promise.
788
+
789
+ ***
790
+
791
+ ### regexp()
792
+
793
+ > `static` **regexp**(`value`): `value is RegExp`
794
+
795
+ Is the value a regexp.
796
+
797
+ #### Parameters
798
+
799
+ ##### value
800
+
801
+ `unknown`
802
+
803
+ The value to test.
804
+
805
+ #### Returns
806
+
807
+ `value is RegExp`
808
+
809
+ True if the value is a regexp.