@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,711 @@
1
+ # Class: Guards
2
+
3
+ Class to handle guard operations for parameters.
4
+
5
+ ## Constructors
6
+
7
+ ### new Guards()
8
+
9
+ > **new Guards**(): [`Guards`](Guards.md)
10
+
11
+ #### Returns
12
+
13
+ [`Guards`](Guards.md)
14
+
15
+ ## Methods
16
+
17
+ ### defined()
18
+
19
+ > `static` **defined**(`source`, `property`, `value`): `asserts value`
20
+
21
+ Is the property defined.
22
+
23
+ #### Parameters
24
+
25
+ • **source**: `string`
26
+
27
+ The source of the error.
28
+
29
+ • **property**: `string`
30
+
31
+ The name of the property.
32
+
33
+ • **value**: `unknown`
34
+
35
+ The value to test.
36
+
37
+ #### Returns
38
+
39
+ `asserts value`
40
+
41
+ #### Throws
42
+
43
+ GuardError If the value does not match the assertion.
44
+
45
+ ***
46
+
47
+ ### string()
48
+
49
+ > `static` **string**(`source`, `property`, `value`): `asserts value is string`
50
+
51
+ Is the property a string.
52
+
53
+ #### Parameters
54
+
55
+ • **source**: `string`
56
+
57
+ The source of the error.
58
+
59
+ • **property**: `string`
60
+
61
+ The name of the property.
62
+
63
+ • **value**: `unknown`
64
+
65
+ The value to test.
66
+
67
+ #### Returns
68
+
69
+ `asserts value is string`
70
+
71
+ #### Throws
72
+
73
+ GuardError If the value does not match the assertion.
74
+
75
+ ***
76
+
77
+ ### stringValue()
78
+
79
+ > `static` **stringValue**(`source`, `property`, `value`): `asserts value is string`
80
+
81
+ Is the property a string with a value.
82
+
83
+ #### Parameters
84
+
85
+ • **source**: `string`
86
+
87
+ The source of the error.
88
+
89
+ • **property**: `string`
90
+
91
+ The name of the property.
92
+
93
+ • **value**: `unknown`
94
+
95
+ The value to test.
96
+
97
+ #### Returns
98
+
99
+ `asserts value is string`
100
+
101
+ #### Throws
102
+
103
+ GuardError If the value does not match the assertion.
104
+
105
+ ***
106
+
107
+ ### stringBase64()
108
+
109
+ > `static` **stringBase64**(`source`, `property`, `value`): `asserts value is string`
110
+
111
+ Is the property a base64 string.
112
+
113
+ #### Parameters
114
+
115
+ • **source**: `string`
116
+
117
+ The source of the error.
118
+
119
+ • **property**: `string`
120
+
121
+ The name of the property.
122
+
123
+ • **value**: `unknown`
124
+
125
+ The value to test.
126
+
127
+ #### Returns
128
+
129
+ `asserts value is string`
130
+
131
+ #### Throws
132
+
133
+ GuardError If the value does not match the assertion.
134
+
135
+ ***
136
+
137
+ ### stringBase64Url()
138
+
139
+ > `static` **stringBase64Url**(`source`, `property`, `value`): `asserts value is string`
140
+
141
+ Is the property a base64 url string.
142
+
143
+ #### Parameters
144
+
145
+ • **source**: `string`
146
+
147
+ The source of the error.
148
+
149
+ • **property**: `string`
150
+
151
+ The name of the property.
152
+
153
+ • **value**: `unknown`
154
+
155
+ The value to test.
156
+
157
+ #### Returns
158
+
159
+ `asserts value is string`
160
+
161
+ #### Throws
162
+
163
+ GuardError If the value does not match the assertion.
164
+
165
+ ***
166
+
167
+ ### stringHex()
168
+
169
+ > `static` **stringHex**(`source`, `property`, `value`, `allowPrefix`): `asserts value is string`
170
+
171
+ Is the property a string with a hex value.
172
+
173
+ #### Parameters
174
+
175
+ • **source**: `string`
176
+
177
+ The source of the error.
178
+
179
+ • **property**: `string`
180
+
181
+ The name of the property.
182
+
183
+ • **value**: `unknown`
184
+
185
+ The value to test.
186
+
187
+ • **allowPrefix**: `boolean` = `false`
188
+
189
+ Allow the hex to have the 0x prefix.
190
+
191
+ #### Returns
192
+
193
+ `asserts value is string`
194
+
195
+ #### Throws
196
+
197
+ GuardError If the value does not match the assertion.
198
+
199
+ ***
200
+
201
+ ### stringHexLength()
202
+
203
+ > `static` **stringHexLength**(`source`, `property`, `value`, `length`, `allowPrefix`): `asserts value is string`
204
+
205
+ Is the property a string with a hex value with fixed length.
206
+
207
+ #### Parameters
208
+
209
+ • **source**: `string`
210
+
211
+ The source of the error.
212
+
213
+ • **property**: `string`
214
+
215
+ The name of the property.
216
+
217
+ • **value**: `unknown`
218
+
219
+ The value to test.
220
+
221
+ • **length**: `number`
222
+
223
+ The length of the string to match.
224
+
225
+ • **allowPrefix**: `boolean` = `false`
226
+
227
+ Allow the hex to have the 0x prefix.
228
+
229
+ #### Returns
230
+
231
+ `asserts value is string`
232
+
233
+ #### Throws
234
+
235
+ GuardError If the value does not match the assertion.
236
+
237
+ ***
238
+
239
+ ### number()
240
+
241
+ > `static` **number**(`source`, `property`, `value`): `asserts value is number`
242
+
243
+ Is the property a number.
244
+
245
+ #### Parameters
246
+
247
+ • **source**: `string`
248
+
249
+ The source of the error.
250
+
251
+ • **property**: `string`
252
+
253
+ The name of the property.
254
+
255
+ • **value**: `unknown`
256
+
257
+ The value to test.
258
+
259
+ #### Returns
260
+
261
+ `asserts value is number`
262
+
263
+ #### Throws
264
+
265
+ GuardError If the value does not match the assertion.
266
+
267
+ ***
268
+
269
+ ### integer()
270
+
271
+ > `static` **integer**(`source`, `property`, `value`): `asserts value is number`
272
+
273
+ Is the property an integer.
274
+
275
+ #### Parameters
276
+
277
+ • **source**: `string`
278
+
279
+ The source of the error.
280
+
281
+ • **property**: `string`
282
+
283
+ The name of the property.
284
+
285
+ • **value**: `unknown`
286
+
287
+ The value to test.
288
+
289
+ #### Returns
290
+
291
+ `asserts value is number`
292
+
293
+ #### Throws
294
+
295
+ GuardError If the value does not match the assertion.
296
+
297
+ ***
298
+
299
+ ### bigint()
300
+
301
+ > `static` **bigint**(`source`, `property`, `value`): `asserts value is bigint`
302
+
303
+ Is the property a bigint.
304
+
305
+ #### Parameters
306
+
307
+ • **source**: `string`
308
+
309
+ The source of the error.
310
+
311
+ • **property**: `string`
312
+
313
+ The name of the property.
314
+
315
+ • **value**: `unknown`
316
+
317
+ The value to test.
318
+
319
+ #### Returns
320
+
321
+ `asserts value is bigint`
322
+
323
+ #### Throws
324
+
325
+ GuardError If the value does not match the assertion.
326
+
327
+ ***
328
+
329
+ ### boolean()
330
+
331
+ > `static` **boolean**(`source`, `property`, `value`): `asserts value is boolean`
332
+
333
+ Is the property a boolean.
334
+
335
+ #### Parameters
336
+
337
+ • **source**: `string`
338
+
339
+ The source of the error.
340
+
341
+ • **property**: `string`
342
+
343
+ The name of the property.
344
+
345
+ • **value**: `unknown`
346
+
347
+ The value to test.
348
+
349
+ #### Returns
350
+
351
+ `asserts value is boolean`
352
+
353
+ #### Throws
354
+
355
+ GuardError If the value does not match the assertion.
356
+
357
+ ***
358
+
359
+ ### date()
360
+
361
+ > `static` **date**(`source`, `property`, `value`): `asserts value is Date`
362
+
363
+ Is the property a date.
364
+
365
+ #### Parameters
366
+
367
+ • **source**: `string`
368
+
369
+ The source of the error.
370
+
371
+ • **property**: `string`
372
+
373
+ The name of the property.
374
+
375
+ • **value**: `unknown`
376
+
377
+ The value to test.
378
+
379
+ #### Returns
380
+
381
+ `asserts value is Date`
382
+
383
+ #### Throws
384
+
385
+ GuardError If the value does not match the assertion.
386
+
387
+ ***
388
+
389
+ ### timestampMilliseconds()
390
+
391
+ > `static` **timestampMilliseconds**(`source`, `property`, `value`): `asserts value is number`
392
+
393
+ Is the property a timestamp in milliseconds.
394
+
395
+ #### Parameters
396
+
397
+ • **source**: `string`
398
+
399
+ The source of the error.
400
+
401
+ • **property**: `string`
402
+
403
+ The name of the property.
404
+
405
+ • **value**: `unknown`
406
+
407
+ The value to test.
408
+
409
+ #### Returns
410
+
411
+ `asserts value is number`
412
+
413
+ #### Throws
414
+
415
+ GuardError If the value does not match the assertion.
416
+
417
+ ***
418
+
419
+ ### timestampSeconds()
420
+
421
+ > `static` **timestampSeconds**(`source`, `property`, `value`): `asserts value is number`
422
+
423
+ Is the property a timestamp in seconds.
424
+
425
+ #### Parameters
426
+
427
+ • **source**: `string`
428
+
429
+ The source of the error.
430
+
431
+ • **property**: `string`
432
+
433
+ The name of the property.
434
+
435
+ • **value**: `unknown`
436
+
437
+ The value to test.
438
+
439
+ #### Returns
440
+
441
+ `asserts value is number`
442
+
443
+ #### Throws
444
+
445
+ GuardError If the value does not match the assertion.
446
+
447
+ ***
448
+
449
+ ### object()
450
+
451
+ > `static` **object**\<`T`\>(`source`, `property`, `value`): `asserts value is T`
452
+
453
+ Is the property an object.
454
+
455
+ #### Type Parameters
456
+
457
+ • **T** = `object`
458
+
459
+ #### Parameters
460
+
461
+ • **source**: `string`
462
+
463
+ The source of the error.
464
+
465
+ • **property**: `string`
466
+
467
+ The name of the property.
468
+
469
+ • **value**: `unknown`
470
+
471
+ The value to test.
472
+
473
+ #### Returns
474
+
475
+ `asserts value is T`
476
+
477
+ #### Throws
478
+
479
+ GuardError If the value does not match the assertion.
480
+
481
+ ***
482
+
483
+ ### objectValue()
484
+
485
+ > `static` **objectValue**\<`T`\>(`source`, `property`, `value`): `asserts value is T`
486
+
487
+ Is the property is an object with at least one property.
488
+
489
+ #### Type Parameters
490
+
491
+ • **T** = `object`
492
+
493
+ #### Parameters
494
+
495
+ • **source**: `string`
496
+
497
+ The source of the error.
498
+
499
+ • **property**: `string`
500
+
501
+ The name of the property.
502
+
503
+ • **value**: `unknown`
504
+
505
+ The value to test.
506
+
507
+ #### Returns
508
+
509
+ `asserts value is T`
510
+
511
+ #### Throws
512
+
513
+ GuardError If the value does not match the assertion.
514
+
515
+ ***
516
+
517
+ ### array()
518
+
519
+ > `static` **array**\<`T`\>(`source`, `property`, `value`): `asserts value is T[]`
520
+
521
+ Is the property is an array.
522
+
523
+ #### Type Parameters
524
+
525
+ • **T**
526
+
527
+ #### Parameters
528
+
529
+ • **source**: `string`
530
+
531
+ The source of the error.
532
+
533
+ • **property**: `string`
534
+
535
+ The name of the property.
536
+
537
+ • **value**: `unknown`
538
+
539
+ The value to test.
540
+
541
+ #### Returns
542
+
543
+ `asserts value is T[]`
544
+
545
+ #### Throws
546
+
547
+ GuardError If the value does not match the assertion.
548
+
549
+ ***
550
+
551
+ ### arrayValue()
552
+
553
+ > `static` **arrayValue**\<`T`\>(`source`, `property`, `value`): `asserts value is T[]`
554
+
555
+ Is the property is an array with at least one item.
556
+
557
+ #### Type Parameters
558
+
559
+ • **T**
560
+
561
+ #### Parameters
562
+
563
+ • **source**: `string`
564
+
565
+ The source of the error.
566
+
567
+ • **property**: `string`
568
+
569
+ The name of the property.
570
+
571
+ • **value**: `unknown`
572
+
573
+ The value to test.
574
+
575
+ #### Returns
576
+
577
+ `asserts value is T[]`
578
+
579
+ #### Throws
580
+
581
+ GuardError If the value does not match the assertion.
582
+
583
+ ***
584
+
585
+ ### arrayOneOf()
586
+
587
+ > `static` **arrayOneOf**\<`T`\>(`source`, `property`, `value`, `options`): `asserts value is T`
588
+
589
+ Is the property one of a list of items.
590
+
591
+ #### Type Parameters
592
+
593
+ • **T**
594
+
595
+ #### Parameters
596
+
597
+ • **source**: `string`
598
+
599
+ The source of the error.
600
+
601
+ • **property**: `string`
602
+
603
+ The name of the property.
604
+
605
+ • **value**: `T`
606
+
607
+ The value to test.
608
+
609
+ • **options**: `T`[]
610
+
611
+ The options the value must be one of.
612
+
613
+ #### Returns
614
+
615
+ `asserts value is T`
616
+
617
+ #### Throws
618
+
619
+ GuardError If the value does not match the assertion.
620
+
621
+ ***
622
+
623
+ ### uint8Array()
624
+
625
+ > `static` **uint8Array**(`source`, `property`, `value`): `asserts value is Uint8Array`
626
+
627
+ Is the property a Uint8Array.
628
+
629
+ #### Parameters
630
+
631
+ • **source**: `string`
632
+
633
+ The source of the error.
634
+
635
+ • **property**: `string`
636
+
637
+ The name of the property.
638
+
639
+ • **value**: `unknown`
640
+
641
+ The value to test.
642
+
643
+ #### Returns
644
+
645
+ `asserts value is Uint8Array`
646
+
647
+ #### Throws
648
+
649
+ GuardError If the value does not match the assertion.
650
+
651
+ ***
652
+
653
+ ### function()
654
+
655
+ > `static` **function**(`source`, `property`, `value`): `boolean`
656
+
657
+ Is the property a function.
658
+
659
+ #### Parameters
660
+
661
+ • **source**: `string`
662
+
663
+ The source of the error.
664
+
665
+ • **property**: `string`
666
+
667
+ The name of the property.
668
+
669
+ • **value**: `unknown`
670
+
671
+ The value to test.
672
+
673
+ #### Returns
674
+
675
+ `boolean`
676
+
677
+ True if the value is a function.
678
+
679
+ #### Throws
680
+
681
+ GuardError If the value does not match the assertion.
682
+
683
+ ***
684
+
685
+ ### email()
686
+
687
+ > `static` **email**(`source`, `property`, `value`): `asserts value is string`
688
+
689
+ Is the property a string formatted as an email address.
690
+
691
+ #### Parameters
692
+
693
+ • **source**: `string`
694
+
695
+ The source of the error.
696
+
697
+ • **property**: `string`
698
+
699
+ The name of the property.
700
+
701
+ • **value**: `unknown`
702
+
703
+ The value to test.
704
+
705
+ #### Returns
706
+
707
+ `asserts value is string`
708
+
709
+ #### Throws
710
+
711
+ GuardError If the value does not match the assertion.