@twin.org/core 0.0.1-next.9 → 0.0.2-next.3

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 (77) hide show
  1. package/dist/cjs/index.cjs +1574 -833
  2. package/dist/esm/index.mjs +1571 -834
  3. package/dist/types/errors/baseError.d.ts +8 -1
  4. package/dist/types/factories/factory.d.ts +20 -1
  5. package/dist/types/helpers/arrayHelper.d.ts +13 -0
  6. package/dist/types/helpers/envHelper.d.ts +16 -0
  7. package/dist/types/helpers/errorHelper.d.ts +2 -1
  8. package/dist/types/helpers/jsonHelper.d.ts +30 -0
  9. package/dist/types/helpers/objectHelper.d.ts +25 -0
  10. package/dist/types/helpers/uint8ArrayHelper.d.ts +11 -0
  11. package/dist/types/index.d.ts +6 -0
  12. package/dist/types/models/IComponent.d.ts +12 -3
  13. package/dist/types/models/II18nShared.d.ts +29 -0
  14. package/dist/types/models/coerceType.d.ts +49 -0
  15. package/dist/types/models/compressionType.d.ts +1 -1
  16. package/dist/types/models/objectOrArray.d.ts +4 -0
  17. package/dist/types/utils/asyncCache.d.ts +10 -1
  18. package/dist/types/utils/coerce.d.ts +22 -0
  19. package/dist/types/utils/guards.d.ts +35 -0
  20. package/dist/types/utils/is.d.ts +12 -0
  21. package/dist/types/utils/sharedStore.d.ts +23 -0
  22. package/dist/types/utils/validation.d.ts +2 -0
  23. package/docs/changelog.md +323 -1
  24. package/docs/reference/classes/AlreadyExistsError.md +103 -27
  25. package/docs/reference/classes/ArrayHelper.md +71 -5
  26. package/docs/reference/classes/AsyncCache.md +75 -13
  27. package/docs/reference/classes/Base32.md +9 -5
  28. package/docs/reference/classes/Base58.md +9 -5
  29. package/docs/reference/classes/Base64.md +12 -6
  30. package/docs/reference/classes/Base64Url.md +9 -5
  31. package/docs/reference/classes/BaseError.md +101 -29
  32. package/docs/reference/classes/BitString.md +23 -11
  33. package/docs/reference/classes/Coerce.md +110 -12
  34. package/docs/reference/classes/Compression.md +19 -11
  35. package/docs/reference/classes/ConflictError.md +106 -28
  36. package/docs/reference/classes/Converter.md +72 -28
  37. package/docs/reference/classes/EnvHelper.md +45 -0
  38. package/docs/reference/classes/ErrorHelper.md +19 -7
  39. package/docs/reference/classes/Factory.md +95 -17
  40. package/docs/reference/classes/FilenameHelper.md +6 -4
  41. package/docs/reference/classes/GeneralError.md +101 -27
  42. package/docs/reference/classes/GuardError.md +106 -28
  43. package/docs/reference/classes/Guards.md +398 -80
  44. package/docs/reference/classes/HexHelper.md +18 -8
  45. package/docs/reference/classes/I18n.md +46 -20
  46. package/docs/reference/classes/Is.md +179 -51
  47. package/docs/reference/classes/JsonHelper.md +146 -10
  48. package/docs/reference/classes/NotFoundError.md +103 -27
  49. package/docs/reference/classes/NotImplementedError.md +97 -25
  50. package/docs/reference/classes/NotSupportedError.md +100 -26
  51. package/docs/reference/classes/ObjectHelper.md +197 -39
  52. package/docs/reference/classes/RandomHelper.md +6 -4
  53. package/docs/reference/classes/SharedStore.md +94 -0
  54. package/docs/reference/classes/StringHelper.md +54 -20
  55. package/docs/reference/classes/Uint8ArrayHelper.md +35 -0
  56. package/docs/reference/classes/UnauthorizedError.md +100 -26
  57. package/docs/reference/classes/UnprocessableError.md +101 -27
  58. package/docs/reference/classes/Url.md +37 -17
  59. package/docs/reference/classes/Urn.md +63 -27
  60. package/docs/reference/classes/Validation.md +349 -135
  61. package/docs/reference/classes/ValidationError.md +100 -26
  62. package/docs/reference/index.md +7 -0
  63. package/docs/reference/interfaces/IComponent.md +30 -8
  64. package/docs/reference/interfaces/IError.md +2 -2
  65. package/docs/reference/interfaces/II18nShared.md +47 -0
  66. package/docs/reference/interfaces/IKeyValue.md +3 -1
  67. package/docs/reference/interfaces/ILabelledValue.md +3 -1
  68. package/docs/reference/interfaces/ILocaleDictionary.md +1 -1
  69. package/docs/reference/interfaces/IPatchOperation.md +1 -1
  70. package/docs/reference/interfaces/IValidationFailure.md +1 -1
  71. package/docs/reference/type-aliases/CoerceType.md +5 -0
  72. package/docs/reference/type-aliases/CompressionType.md +1 -1
  73. package/docs/reference/type-aliases/ObjectOrArray.md +11 -0
  74. package/docs/reference/variables/CoerceType.md +67 -0
  75. package/docs/reference/variables/CompressionType.md +1 -1
  76. package/locales/en.json +14 -1
  77. package/package.json +7 -7
@@ -4,13 +4,13 @@ Class to handle guard operations for parameters.
4
4
 
5
5
  ## Constructors
6
6
 
7
- ### new Guards()
7
+ ### Constructor
8
8
 
9
- > **new Guards**(): [`Guards`](Guards.md)
9
+ > **new Guards**(): `Guards`
10
10
 
11
11
  #### Returns
12
12
 
13
- [`Guards`](Guards.md)
13
+ `Guards`
14
14
 
15
15
  ## Methods
16
16
 
@@ -22,15 +22,21 @@ Is the property defined.
22
22
 
23
23
  #### Parameters
24
24
 
25
- **source**: `string`
25
+ ##### source
26
+
27
+ `string`
26
28
 
27
29
  The source of the error.
28
30
 
29
- **property**: `string`
31
+ ##### property
32
+
33
+ `string`
30
34
 
31
35
  The name of the property.
32
36
 
33
- **value**: `unknown`
37
+ ##### value
38
+
39
+ `unknown`
34
40
 
35
41
  The value to test.
36
42
 
@@ -52,15 +58,21 @@ Is the property a string.
52
58
 
53
59
  #### Parameters
54
60
 
55
- **source**: `string`
61
+ ##### source
62
+
63
+ `string`
56
64
 
57
65
  The source of the error.
58
66
 
59
- **property**: `string`
67
+ ##### property
68
+
69
+ `string`
60
70
 
61
71
  The name of the property.
62
72
 
63
- **value**: `unknown`
73
+ ##### value
74
+
75
+ `unknown`
64
76
 
65
77
  The value to test.
66
78
 
@@ -82,15 +94,57 @@ Is the property a string with a value.
82
94
 
83
95
  #### Parameters
84
96
 
85
- **source**: `string`
97
+ ##### source
98
+
99
+ `string`
100
+
101
+ The source of the error.
102
+
103
+ ##### property
104
+
105
+ `string`
106
+
107
+ The name of the property.
108
+
109
+ ##### value
110
+
111
+ `unknown`
112
+
113
+ The value to test.
114
+
115
+ #### Returns
116
+
117
+ `asserts value is string`
118
+
119
+ #### Throws
120
+
121
+ GuardError If the value does not match the assertion.
122
+
123
+ ***
124
+
125
+ ### json()
126
+
127
+ > `static` **json**(`source`, `property`, `value`): `asserts value is string`
128
+
129
+ Is the property a JSON value.
130
+
131
+ #### Parameters
132
+
133
+ ##### source
134
+
135
+ `string`
86
136
 
87
137
  The source of the error.
88
138
 
89
- **property**: `string`
139
+ ##### property
140
+
141
+ `string`
90
142
 
91
143
  The name of the property.
92
144
 
93
- **value**: `unknown`
145
+ ##### value
146
+
147
+ `unknown`
94
148
 
95
149
  The value to test.
96
150
 
@@ -112,15 +166,21 @@ Is the property a base64 string.
112
166
 
113
167
  #### Parameters
114
168
 
115
- **source**: `string`
169
+ ##### source
170
+
171
+ `string`
116
172
 
117
173
  The source of the error.
118
174
 
119
- **property**: `string`
175
+ ##### property
176
+
177
+ `string`
120
178
 
121
179
  The name of the property.
122
180
 
123
- **value**: `unknown`
181
+ ##### value
182
+
183
+ `unknown`
124
184
 
125
185
  The value to test.
126
186
 
@@ -142,15 +202,57 @@ Is the property a base64 url string.
142
202
 
143
203
  #### Parameters
144
204
 
145
- **source**: `string`
205
+ ##### source
206
+
207
+ `string`
146
208
 
147
209
  The source of the error.
148
210
 
149
- **property**: `string`
211
+ ##### property
212
+
213
+ `string`
150
214
 
151
215
  The name of the property.
152
216
 
153
- **value**: `unknown`
217
+ ##### value
218
+
219
+ `unknown`
220
+
221
+ The value to test.
222
+
223
+ #### Returns
224
+
225
+ `asserts value is string`
226
+
227
+ #### Throws
228
+
229
+ GuardError If the value does not match the assertion.
230
+
231
+ ***
232
+
233
+ ### stringBase58()
234
+
235
+ > `static` **stringBase58**(`source`, `property`, `value`): `asserts value is string`
236
+
237
+ Is the property a base58 string.
238
+
239
+ #### Parameters
240
+
241
+ ##### source
242
+
243
+ `string`
244
+
245
+ The source of the error.
246
+
247
+ ##### property
248
+
249
+ `string`
250
+
251
+ The name of the property.
252
+
253
+ ##### value
254
+
255
+ `unknown`
154
256
 
155
257
  The value to test.
156
258
 
@@ -172,19 +274,27 @@ Is the property a string with a hex value.
172
274
 
173
275
  #### Parameters
174
276
 
175
- **source**: `string`
277
+ ##### source
278
+
279
+ `string`
176
280
 
177
281
  The source of the error.
178
282
 
179
- **property**: `string`
283
+ ##### property
284
+
285
+ `string`
180
286
 
181
287
  The name of the property.
182
288
 
183
- **value**: `unknown`
289
+ ##### value
290
+
291
+ `unknown`
184
292
 
185
293
  The value to test.
186
294
 
187
- **allowPrefix**: `boolean` = `false`
295
+ ##### allowPrefix
296
+
297
+ `boolean` = `false`
188
298
 
189
299
  Allow the hex to have the 0x prefix.
190
300
 
@@ -206,23 +316,33 @@ Is the property a string with a hex value with fixed length.
206
316
 
207
317
  #### Parameters
208
318
 
209
- **source**: `string`
319
+ ##### source
320
+
321
+ `string`
210
322
 
211
323
  The source of the error.
212
324
 
213
- **property**: `string`
325
+ ##### property
326
+
327
+ `string`
214
328
 
215
329
  The name of the property.
216
330
 
217
- **value**: `unknown`
331
+ ##### value
332
+
333
+ `unknown`
218
334
 
219
335
  The value to test.
220
336
 
221
- **length**: `number`
337
+ ##### length
338
+
339
+ `number`
222
340
 
223
341
  The length of the string to match.
224
342
 
225
- **allowPrefix**: `boolean` = `false`
343
+ ##### allowPrefix
344
+
345
+ `boolean` = `false`
226
346
 
227
347
  Allow the hex to have the 0x prefix.
228
348
 
@@ -244,15 +364,21 @@ Is the property a number.
244
364
 
245
365
  #### Parameters
246
366
 
247
- **source**: `string`
367
+ ##### source
368
+
369
+ `string`
248
370
 
249
371
  The source of the error.
250
372
 
251
- **property**: `string`
373
+ ##### property
374
+
375
+ `string`
252
376
 
253
377
  The name of the property.
254
378
 
255
- **value**: `unknown`
379
+ ##### value
380
+
381
+ `unknown`
256
382
 
257
383
  The value to test.
258
384
 
@@ -274,15 +400,21 @@ Is the property an integer.
274
400
 
275
401
  #### Parameters
276
402
 
277
- **source**: `string`
403
+ ##### source
404
+
405
+ `string`
278
406
 
279
407
  The source of the error.
280
408
 
281
- **property**: `string`
409
+ ##### property
410
+
411
+ `string`
282
412
 
283
413
  The name of the property.
284
414
 
285
- **value**: `unknown`
415
+ ##### value
416
+
417
+ `unknown`
286
418
 
287
419
  The value to test.
288
420
 
@@ -304,15 +436,21 @@ Is the property a bigint.
304
436
 
305
437
  #### Parameters
306
438
 
307
- **source**: `string`
439
+ ##### source
440
+
441
+ `string`
308
442
 
309
443
  The source of the error.
310
444
 
311
- **property**: `string`
445
+ ##### property
446
+
447
+ `string`
312
448
 
313
449
  The name of the property.
314
450
 
315
- **value**: `unknown`
451
+ ##### value
452
+
453
+ `unknown`
316
454
 
317
455
  The value to test.
318
456
 
@@ -334,15 +472,21 @@ Is the property a boolean.
334
472
 
335
473
  #### Parameters
336
474
 
337
- **source**: `string`
475
+ ##### source
476
+
477
+ `string`
338
478
 
339
479
  The source of the error.
340
480
 
341
- **property**: `string`
481
+ ##### property
482
+
483
+ `string`
342
484
 
343
485
  The name of the property.
344
486
 
345
- **value**: `unknown`
487
+ ##### value
488
+
489
+ `unknown`
346
490
 
347
491
  The value to test.
348
492
 
@@ -364,15 +508,21 @@ Is the property a date.
364
508
 
365
509
  #### Parameters
366
510
 
367
- **source**: `string`
511
+ ##### source
512
+
513
+ `string`
368
514
 
369
515
  The source of the error.
370
516
 
371
- **property**: `string`
517
+ ##### property
518
+
519
+ `string`
372
520
 
373
521
  The name of the property.
374
522
 
375
- **value**: `unknown`
523
+ ##### value
524
+
525
+ `unknown`
376
526
 
377
527
  The value to test.
378
528
 
@@ -394,15 +544,21 @@ Is the property a timestamp in milliseconds.
394
544
 
395
545
  #### Parameters
396
546
 
397
- **source**: `string`
547
+ ##### source
548
+
549
+ `string`
398
550
 
399
551
  The source of the error.
400
552
 
401
- **property**: `string`
553
+ ##### property
554
+
555
+ `string`
402
556
 
403
557
  The name of the property.
404
558
 
405
- **value**: `unknown`
559
+ ##### value
560
+
561
+ `unknown`
406
562
 
407
563
  The value to test.
408
564
 
@@ -424,15 +580,21 @@ Is the property a timestamp in seconds.
424
580
 
425
581
  #### Parameters
426
582
 
427
- **source**: `string`
583
+ ##### source
584
+
585
+ `string`
428
586
 
429
587
  The source of the error.
430
588
 
431
- **property**: `string`
589
+ ##### property
590
+
591
+ `string`
432
592
 
433
593
  The name of the property.
434
594
 
435
- **value**: `unknown`
595
+ ##### value
596
+
597
+ `unknown`
436
598
 
437
599
  The value to test.
438
600
 
@@ -454,19 +616,27 @@ Is the property an object.
454
616
 
455
617
  #### Type Parameters
456
618
 
457
- **T** = `object`
619
+ ##### T
620
+
621
+ `T` = \{[`id`: `string`]: `unknown`; \}
458
622
 
459
623
  #### Parameters
460
624
 
461
- **source**: `string`
625
+ ##### source
626
+
627
+ `string`
462
628
 
463
629
  The source of the error.
464
630
 
465
- **property**: `string`
631
+ ##### property
632
+
633
+ `string`
466
634
 
467
635
  The name of the property.
468
636
 
469
- **value**: `unknown`
637
+ ##### value
638
+
639
+ `unknown`
470
640
 
471
641
  The value to test.
472
642
 
@@ -488,19 +658,27 @@ Is the property is an object with at least one property.
488
658
 
489
659
  #### Type Parameters
490
660
 
491
- **T** = `object`
661
+ ##### T
662
+
663
+ `T` = \{[`id`: `string`]: `unknown`; \}
492
664
 
493
665
  #### Parameters
494
666
 
495
- **source**: `string`
667
+ ##### source
668
+
669
+ `string`
496
670
 
497
671
  The source of the error.
498
672
 
499
- **property**: `string`
673
+ ##### property
674
+
675
+ `string`
500
676
 
501
677
  The name of the property.
502
678
 
503
- **value**: `unknown`
679
+ ##### value
680
+
681
+ `unknown`
504
682
 
505
683
  The value to test.
506
684
 
@@ -522,19 +700,27 @@ Is the property is an array.
522
700
 
523
701
  #### Type Parameters
524
702
 
525
- **T**
703
+ ##### T
704
+
705
+ `T`
526
706
 
527
707
  #### Parameters
528
708
 
529
- **source**: `string`
709
+ ##### source
710
+
711
+ `string`
530
712
 
531
713
  The source of the error.
532
714
 
533
- **property**: `string`
715
+ ##### property
716
+
717
+ `string`
534
718
 
535
719
  The name of the property.
536
720
 
537
- **value**: `unknown`
721
+ ##### value
722
+
723
+ `unknown`
538
724
 
539
725
  The value to test.
540
726
 
@@ -556,19 +742,27 @@ Is the property is an array with at least one item.
556
742
 
557
743
  #### Type Parameters
558
744
 
559
- **T**
745
+ ##### T
746
+
747
+ `T`
560
748
 
561
749
  #### Parameters
562
750
 
563
- **source**: `string`
751
+ ##### source
752
+
753
+ `string`
564
754
 
565
755
  The source of the error.
566
756
 
567
- **property**: `string`
757
+ ##### property
758
+
759
+ `string`
568
760
 
569
761
  The name of the property.
570
762
 
571
- **value**: `unknown`
763
+ ##### value
764
+
765
+ `unknown`
572
766
 
573
767
  The value to test.
574
768
 
@@ -590,23 +784,33 @@ Is the property one of a list of items.
590
784
 
591
785
  #### Type Parameters
592
786
 
593
- **T**
787
+ ##### T
788
+
789
+ `T`
594
790
 
595
791
  #### Parameters
596
792
 
597
- **source**: `string`
793
+ ##### source
794
+
795
+ `string`
598
796
 
599
797
  The source of the error.
600
798
 
601
- **property**: `string`
799
+ ##### property
800
+
801
+ `string`
602
802
 
603
803
  The name of the property.
604
804
 
605
- **value**: `T`
805
+ ##### value
806
+
807
+ `T`
606
808
 
607
809
  The value to test.
608
810
 
609
- **options**: `T`[]
811
+ ##### options
812
+
813
+ `T`[]
610
814
 
611
815
  The options the value must be one of.
612
816
 
@@ -620,29 +824,131 @@ GuardError If the value does not match the assertion.
620
824
 
621
825
  ***
622
826
 
827
+ ### arrayStartsWith()
828
+
829
+ > `static` **arrayStartsWith**\<`T`\>(`source`, `property`, `value`, `startValues`): `asserts value is T[]`
830
+
831
+ Does the array start with the specified data.
832
+
833
+ #### Type Parameters
834
+
835
+ ##### T
836
+
837
+ `T`
838
+
839
+ #### Parameters
840
+
841
+ ##### source
842
+
843
+ `string`
844
+
845
+ The source of the error.
846
+
847
+ ##### property
848
+
849
+ `string`
850
+
851
+ The name of the property.
852
+
853
+ ##### value
854
+
855
+ `unknown`
856
+
857
+ The value to test.
858
+
859
+ ##### startValues
860
+
861
+ [`ObjectOrArray`](../type-aliases/ObjectOrArray.md)\<`T`\>
862
+
863
+ The values that must start the array.
864
+
865
+ #### Returns
866
+
867
+ `asserts value is T[]`
868
+
869
+ #### Throws
870
+
871
+ GuardError If the value does not match the assertion.
872
+
873
+ ***
874
+
875
+ ### arrayEndsWith()
876
+
877
+ > `static` **arrayEndsWith**\<`T`\>(`source`, `property`, `value`, `endValues`): `asserts value is T[]`
878
+
879
+ Does the array end with the specified data.
880
+
881
+ #### Type Parameters
882
+
883
+ ##### T
884
+
885
+ `T`
886
+
887
+ #### Parameters
888
+
889
+ ##### source
890
+
891
+ `string`
892
+
893
+ The source of the error.
894
+
895
+ ##### property
896
+
897
+ `string`
898
+
899
+ The name of the property.
900
+
901
+ ##### value
902
+
903
+ `unknown`
904
+
905
+ The value to test.
906
+
907
+ ##### endValues
908
+
909
+ [`ObjectOrArray`](../type-aliases/ObjectOrArray.md)\<`T`\>
910
+
911
+ The values that must end the array.
912
+
913
+ #### Returns
914
+
915
+ `asserts value is T[]`
916
+
917
+ #### Throws
918
+
919
+ GuardError If the value does not match the assertion.
920
+
921
+ ***
922
+
623
923
  ### uint8Array()
624
924
 
625
- > `static` **uint8Array**(`source`, `property`, `value`): `asserts value is Uint8Array`
925
+ > `static` **uint8Array**(`source`, `property`, `value`): `asserts value is Uint8Array<ArrayBufferLike>`
626
926
 
627
927
  Is the property a Uint8Array.
628
928
 
629
929
  #### Parameters
630
930
 
631
- **source**: `string`
931
+ ##### source
932
+
933
+ `string`
632
934
 
633
935
  The source of the error.
634
936
 
635
- **property**: `string`
937
+ ##### property
938
+
939
+ `string`
636
940
 
637
941
  The name of the property.
638
942
 
639
- **value**: `unknown`
943
+ ##### value
944
+
945
+ `unknown`
640
946
 
641
947
  The value to test.
642
948
 
643
949
  #### Returns
644
950
 
645
- `asserts value is Uint8Array`
951
+ `asserts value is Uint8Array<ArrayBufferLike>`
646
952
 
647
953
  #### Throws
648
954
 
@@ -658,15 +964,21 @@ Is the property a function.
658
964
 
659
965
  #### Parameters
660
966
 
661
- **source**: `string`
967
+ ##### source
968
+
969
+ `string`
662
970
 
663
971
  The source of the error.
664
972
 
665
- **property**: `string`
973
+ ##### property
974
+
975
+ `string`
666
976
 
667
977
  The name of the property.
668
978
 
669
- **value**: `unknown`
979
+ ##### value
980
+
981
+ `unknown`
670
982
 
671
983
  The value to test.
672
984
 
@@ -690,15 +1002,21 @@ Is the property a string formatted as an email address.
690
1002
 
691
1003
  #### Parameters
692
1004
 
693
- **source**: `string`
1005
+ ##### source
1006
+
1007
+ `string`
694
1008
 
695
1009
  The source of the error.
696
1010
 
697
- **property**: `string`
1011
+ ##### property
1012
+
1013
+ `string`
698
1014
 
699
1015
  The name of the property.
700
1016
 
701
- **value**: `unknown`
1017
+ ##### value
1018
+
1019
+ `unknown`
702
1020
 
703
1021
  The value to test.
704
1022