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

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 (85) hide show
  1. package/dist/cjs/index.cjs +2266 -1470
  2. package/dist/esm/index.mjs +2263 -1471
  3. package/dist/types/errors/alreadyExistsError.d.ts +2 -2
  4. package/dist/types/errors/baseError.d.ts +25 -5
  5. package/dist/types/errors/conflictError.d.ts +2 -2
  6. package/dist/types/errors/generalError.d.ts +2 -2
  7. package/dist/types/errors/notFoundError.d.ts +2 -2
  8. package/dist/types/errors/notSupportedError.d.ts +2 -2
  9. package/dist/types/errors/unauthorizedError.d.ts +2 -2
  10. package/dist/types/errors/unprocessableError.d.ts +2 -2
  11. package/dist/types/factories/factory.d.ts +21 -2
  12. package/dist/types/helpers/arrayHelper.d.ts +13 -0
  13. package/dist/types/helpers/envHelper.d.ts +16 -0
  14. package/dist/types/helpers/errorHelper.d.ts +5 -4
  15. package/dist/types/helpers/jsonHelper.d.ts +30 -0
  16. package/dist/types/helpers/objectHelper.d.ts +25 -0
  17. package/dist/types/helpers/uint8ArrayHelper.d.ts +11 -0
  18. package/dist/types/index.d.ts +6 -0
  19. package/dist/types/models/IComponent.d.ts +6 -6
  20. package/dist/types/models/IError.d.ts +2 -2
  21. package/dist/types/models/II18nShared.d.ts +29 -0
  22. package/dist/types/models/coerceType.d.ts +49 -0
  23. package/dist/types/models/compressionType.d.ts +1 -1
  24. package/dist/types/models/objectOrArray.d.ts +4 -0
  25. package/dist/types/utils/asyncCache.d.ts +10 -1
  26. package/dist/types/utils/coerce.d.ts +22 -0
  27. package/dist/types/utils/guards.d.ts +35 -0
  28. package/dist/types/utils/is.d.ts +18 -0
  29. package/dist/types/utils/sharedStore.d.ts +23 -0
  30. package/dist/types/utils/validation.d.ts +2 -0
  31. package/docs/changelog.md +442 -1
  32. package/docs/reference/classes/AlreadyExistsError.md +166 -32
  33. package/docs/reference/classes/ArrayHelper.md +71 -5
  34. package/docs/reference/classes/AsyncCache.md +75 -13
  35. package/docs/reference/classes/Base32.md +9 -5
  36. package/docs/reference/classes/Base58.md +9 -5
  37. package/docs/reference/classes/Base64.md +12 -6
  38. package/docs/reference/classes/Base64Url.md +9 -5
  39. package/docs/reference/classes/BaseError.md +160 -34
  40. package/docs/reference/classes/BitString.md +23 -11
  41. package/docs/reference/classes/Coerce.md +110 -12
  42. package/docs/reference/classes/Compression.md +19 -11
  43. package/docs/reference/classes/ConflictError.md +169 -33
  44. package/docs/reference/classes/Converter.md +72 -28
  45. package/docs/reference/classes/EnvHelper.md +45 -0
  46. package/docs/reference/classes/ErrorHelper.md +22 -10
  47. package/docs/reference/classes/Factory.md +96 -18
  48. package/docs/reference/classes/FilenameHelper.md +6 -4
  49. package/docs/reference/classes/GeneralError.md +164 -32
  50. package/docs/reference/classes/GuardError.md +168 -32
  51. package/docs/reference/classes/Guards.md +398 -80
  52. package/docs/reference/classes/HexHelper.md +18 -8
  53. package/docs/reference/classes/I18n.md +46 -20
  54. package/docs/reference/classes/Is.md +207 -51
  55. package/docs/reference/classes/JsonHelper.md +146 -10
  56. package/docs/reference/classes/NotFoundError.md +166 -32
  57. package/docs/reference/classes/NotImplementedError.md +159 -29
  58. package/docs/reference/classes/NotSupportedError.md +163 -31
  59. package/docs/reference/classes/ObjectHelper.md +197 -39
  60. package/docs/reference/classes/RandomHelper.md +6 -4
  61. package/docs/reference/classes/SharedStore.md +94 -0
  62. package/docs/reference/classes/StringHelper.md +54 -20
  63. package/docs/reference/classes/Uint8ArrayHelper.md +35 -0
  64. package/docs/reference/classes/UnauthorizedError.md +163 -31
  65. package/docs/reference/classes/UnprocessableError.md +164 -32
  66. package/docs/reference/classes/Url.md +37 -17
  67. package/docs/reference/classes/Urn.md +63 -27
  68. package/docs/reference/classes/Validation.md +349 -135
  69. package/docs/reference/classes/ValidationError.md +162 -30
  70. package/docs/reference/index.md +7 -0
  71. package/docs/reference/interfaces/IComponent.md +21 -11
  72. package/docs/reference/interfaces/IError.md +4 -4
  73. package/docs/reference/interfaces/II18nShared.md +47 -0
  74. package/docs/reference/interfaces/IKeyValue.md +3 -1
  75. package/docs/reference/interfaces/ILabelledValue.md +3 -1
  76. package/docs/reference/interfaces/ILocaleDictionary.md +1 -1
  77. package/docs/reference/interfaces/IPatchOperation.md +1 -1
  78. package/docs/reference/interfaces/IValidationFailure.md +1 -1
  79. package/docs/reference/type-aliases/CoerceType.md +5 -0
  80. package/docs/reference/type-aliases/CompressionType.md +1 -1
  81. package/docs/reference/type-aliases/ObjectOrArray.md +11 -0
  82. package/docs/reference/variables/CoerceType.md +67 -0
  83. package/docs/reference/variables/CompressionType.md +2 -2
  84. package/locales/en.json +14 -1
  85. package/package.json +7 -7
@@ -4,13 +4,13 @@ Class to help with objects.
4
4
 
5
5
  ## Constructors
6
6
 
7
- ### new ObjectHelper()
7
+ ### Constructor
8
8
 
9
- > **new ObjectHelper**(): [`ObjectHelper`](ObjectHelper.md)
9
+ > **new ObjectHelper**(): `ObjectHelper`
10
10
 
11
11
  #### Returns
12
12
 
13
- [`ObjectHelper`](ObjectHelper.md)
13
+ `ObjectHelper`
14
14
 
15
15
  ## Methods
16
16
 
@@ -22,15 +22,21 @@ Convert an object to bytes.
22
22
 
23
23
  #### Type Parameters
24
24
 
25
- **T**
25
+ ##### T
26
+
27
+ `T`
26
28
 
27
29
  #### Parameters
28
30
 
29
- **obj**: `undefined` \| `T`
31
+ ##### obj
30
32
 
31
33
  The object to convert.
32
34
 
33
- • **format**: `boolean` = `false`
35
+ `undefined` | `T`
36
+
37
+ ##### format
38
+
39
+ `boolean` = `false`
34
40
 
35
41
  Format the JSON content.
36
42
 
@@ -50,14 +56,18 @@ Convert a bytes to an object.
50
56
 
51
57
  #### Type Parameters
52
58
 
53
- **T**
59
+ ##### T
60
+
61
+ `T`
54
62
 
55
63
  #### Parameters
56
64
 
57
- **bytes**: `undefined` \| `null` \| `Uint8Array`
65
+ ##### bytes
58
66
 
59
67
  The bytes to convert to an object.
60
68
 
69
+ `undefined` | `null` | `Uint8Array`\<`ArrayBufferLike`\>
70
+
61
71
  #### Returns
62
72
 
63
73
  `T`
@@ -78,11 +88,15 @@ Make a deep clone of an object.
78
88
 
79
89
  #### Type Parameters
80
90
 
81
- **T**
91
+ ##### T
92
+
93
+ `T`
82
94
 
83
95
  #### Parameters
84
96
 
85
- **obj**: `T`
97
+ ##### obj
98
+
99
+ `T`
86
100
 
87
101
  The object to clone.
88
102
 
@@ -102,17 +116,25 @@ Deep merge objects.
102
116
 
103
117
  #### Type Parameters
104
118
 
105
- **T** = `unknown`
119
+ ##### T
106
120
 
107
- **U** = `unknown`
121
+ `T` = `unknown`
122
+
123
+ ##### U
124
+
125
+ `U` = `unknown`
108
126
 
109
127
  #### Parameters
110
128
 
111
- **obj1**: `T`
129
+ ##### obj1
130
+
131
+ `T`
112
132
 
113
133
  The first object to merge.
114
134
 
115
- **obj2**: `U`
135
+ ##### obj2
136
+
137
+ `U`
116
138
 
117
139
  The second object to merge.
118
140
 
@@ -126,25 +148,33 @@ The combined deep merge of the objects.
126
148
 
127
149
  ### equal()
128
150
 
129
- > `static` **equal**\<`T`\>(`obj1`, `obj2`, `strictPropertyOrder`?): `boolean`
151
+ > `static` **equal**\<`T`\>(`obj1`, `obj2`, `strictPropertyOrder?`): `boolean`
130
152
 
131
153
  Does one object equal another.
132
154
 
133
155
  #### Type Parameters
134
156
 
135
- **T**
157
+ ##### T
158
+
159
+ `T`
136
160
 
137
161
  #### Parameters
138
162
 
139
- **obj1**: `T`
163
+ ##### obj1
164
+
165
+ `T`
140
166
 
141
167
  The first object to compare.
142
168
 
143
- **obj2**: `T`
169
+ ##### obj2
170
+
171
+ `T`
144
172
 
145
173
  The second object to compare.
146
174
 
147
- **strictPropertyOrder?**: `boolean`
175
+ ##### strictPropertyOrder?
176
+
177
+ `boolean`
148
178
 
149
179
  Should the properties be in the same order, defaults to true.
150
180
 
@@ -164,15 +194,21 @@ Get the property of an unknown object.
164
194
 
165
195
  #### Type Parameters
166
196
 
167
- **T** = `unknown`
197
+ ##### T
198
+
199
+ `T` = `unknown`
168
200
 
169
201
  #### Parameters
170
202
 
171
- **obj**: `unknown`
203
+ ##### obj
204
+
205
+ `unknown`
172
206
 
173
207
  The object to get the property from.
174
208
 
175
- **property**: `string`
209
+ ##### property
210
+
211
+ `string`
176
212
 
177
213
  The property to get, can be separated by dots for nested path.
178
214
 
@@ -192,15 +228,21 @@ Set the property of an unknown object.
192
228
 
193
229
  #### Parameters
194
230
 
195
- **obj**: `unknown`
231
+ ##### obj
232
+
233
+ `unknown`
196
234
 
197
235
  The object to set the property from.
198
236
 
199
- **property**: `string`
237
+ ##### property
238
+
239
+ `string`
200
240
 
201
241
  The property to set.
202
242
 
203
- **value**: `unknown`
243
+ ##### value
244
+
245
+ `unknown`
204
246
 
205
247
  The value to set.
206
248
 
@@ -208,6 +250,10 @@ The value to set.
208
250
 
209
251
  `void`
210
252
 
253
+ #### Throws
254
+
255
+ GeneralError if the property target is not an object.
256
+
211
257
  ***
212
258
 
213
259
  ### propertyDelete()
@@ -218,11 +264,15 @@ Delete the property of an unknown object.
218
264
 
219
265
  #### Parameters
220
266
 
221
- **obj**: `unknown`
267
+ ##### obj
268
+
269
+ `unknown`
222
270
 
223
271
  The object to set the property from.
224
272
 
225
- **property**: `string`
273
+ ##### property
274
+
275
+ `string`
226
276
 
227
277
  The property to set
228
278
 
@@ -240,19 +290,27 @@ Extract a property from the object, providing alternative names.
240
290
 
241
291
  #### Type Parameters
242
292
 
243
- **T**
293
+ ##### T
294
+
295
+ `T`
244
296
 
245
297
  #### Parameters
246
298
 
247
- **obj**: `unknown`
299
+ ##### obj
300
+
301
+ `unknown`
248
302
 
249
303
  The object to extract from.
250
304
 
251
- **propertyNames**: `string` \| `string`[]
305
+ ##### propertyNames
252
306
 
253
307
  The possible names for the property.
254
308
 
255
- • **removeProperties**: `boolean` = `true`
309
+ `string` | `string`[]
310
+
311
+ ##### removeProperties
312
+
313
+ `boolean` = `true`
256
314
 
257
315
  Remove the properties from the object, defaults to true.
258
316
 
@@ -266,21 +324,27 @@ The property if available.
266
324
 
267
325
  ### pick()
268
326
 
269
- > `static` **pick**\<`T`\>(`obj`, `keys`?): `Partial`\<`T`\>
327
+ > `static` **pick**\<`T`\>(`obj`, `keys?`): `Partial`\<`T`\>
270
328
 
271
329
  Pick a subset of properties from an object.
272
330
 
273
331
  #### Type Parameters
274
332
 
275
- **T**
333
+ ##### T
334
+
335
+ `T`
276
336
 
277
337
  #### Parameters
278
338
 
279
- **obj**: `undefined` \| `T`
339
+ ##### obj
280
340
 
281
341
  The object to pick the properties from.
282
342
 
283
- **keys?**: keyof `T`[]
343
+ `undefined` | `T`
344
+
345
+ ##### keys?
346
+
347
+ keyof `T`[]
284
348
 
285
349
  The property keys to pick.
286
350
 
@@ -294,21 +358,27 @@ The partial object.
294
358
 
295
359
  ### omit()
296
360
 
297
- > `static` **omit**\<`T`\>(`obj`, `keys`?): `Partial`\<`T`\>
361
+ > `static` **omit**\<`T`\>(`obj`, `keys?`): `Partial`\<`T`\>
298
362
 
299
363
  Omit a subset of properties from an object.
300
364
 
301
365
  #### Type Parameters
302
366
 
303
- **T**
367
+ ##### T
368
+
369
+ `T`
304
370
 
305
371
  #### Parameters
306
372
 
307
- **obj**: `undefined` \| `T`
373
+ ##### obj
308
374
 
309
375
  The object to omit the properties from.
310
376
 
311
- **keys?**: keyof `T`[]
377
+ `undefined` | `T`
378
+
379
+ ##### keys?
380
+
381
+ keyof `T`[]
312
382
 
313
383
  The property keys to omit.
314
384
 
@@ -317,3 +387,91 @@ The property keys to omit.
317
387
  `Partial`\<`T`\>
318
388
 
319
389
  The partial object.
390
+
391
+ ***
392
+
393
+ ### toExtended()
394
+
395
+ > `static` **toExtended**(`obj`): `any`
396
+
397
+ Converter the non JSON primitives to extended types.
398
+
399
+ #### Parameters
400
+
401
+ ##### obj
402
+
403
+ `any`
404
+
405
+ The object to convert.
406
+
407
+ #### Returns
408
+
409
+ `any`
410
+
411
+ The object with extended properties.
412
+
413
+ ***
414
+
415
+ ### fromExtended()
416
+
417
+ > `static` **fromExtended**(`obj`): `any`
418
+
419
+ Converter the extended types to non JSON primitives.
420
+
421
+ #### Parameters
422
+
423
+ ##### obj
424
+
425
+ `any`
426
+
427
+ The object to convert.
428
+
429
+ #### Returns
430
+
431
+ `any`
432
+
433
+ The object with regular properties.
434
+
435
+ ***
436
+
437
+ ### removeEmptyProperties()
438
+
439
+ > `static` **removeEmptyProperties**\<`T`\>(`obj`, `options?`): `T`
440
+
441
+ Remove empty properties from an object.
442
+
443
+ #### Type Parameters
444
+
445
+ ##### T
446
+
447
+ `T` = `unknown`
448
+
449
+ #### Parameters
450
+
451
+ ##### obj
452
+
453
+ `T`
454
+
455
+ The object to remove the empty properties from.
456
+
457
+ ##### options?
458
+
459
+ The options for the removal.
460
+
461
+ ###### removeUndefined?
462
+
463
+ `boolean`
464
+
465
+ Remove undefined properties, defaults to true.
466
+
467
+ ###### removeNull?
468
+
469
+ `boolean`
470
+
471
+ Remove null properties, defaults to false.
472
+
473
+ #### Returns
474
+
475
+ `T`
476
+
477
+ The object with empty properties removed.
@@ -4,13 +4,13 @@ Class to help with random generation.
4
4
 
5
5
  ## Constructors
6
6
 
7
- ### new RandomHelper()
7
+ ### Constructor
8
8
 
9
- > **new RandomHelper**(): [`RandomHelper`](RandomHelper.md)
9
+ > **new RandomHelper**(): `RandomHelper`
10
10
 
11
11
  #### Returns
12
12
 
13
- [`RandomHelper`](RandomHelper.md)
13
+ `RandomHelper`
14
14
 
15
15
  ## Methods
16
16
 
@@ -22,7 +22,9 @@ Generate a new random array.
22
22
 
23
23
  #### Parameters
24
24
 
25
- **length**: `number`
25
+ ##### length
26
+
27
+ `number`
26
28
 
27
29
  The length of buffer to create.
28
30
 
@@ -0,0 +1,94 @@
1
+ # Class: SharedStore
2
+
3
+ Provide a store for shared objects which can be accesses through multiple
4
+ instance loads of a packages.
5
+
6
+ ## Constructors
7
+
8
+ ### Constructor
9
+
10
+ > **new SharedStore**(): `SharedStore`
11
+
12
+ #### Returns
13
+
14
+ `SharedStore`
15
+
16
+ ## Methods
17
+
18
+ ### get()
19
+
20
+ > `static` **get**\<`T`\>(`prop`): `undefined` \| `T`
21
+
22
+ Get a property from the shared store.
23
+
24
+ #### Type Parameters
25
+
26
+ ##### T
27
+
28
+ `T` = `unknown`
29
+
30
+ #### Parameters
31
+
32
+ ##### prop
33
+
34
+ `string`
35
+
36
+ The name of the property to get.
37
+
38
+ #### Returns
39
+
40
+ `undefined` \| `T`
41
+
42
+ The property if it exists.
43
+
44
+ ***
45
+
46
+ ### set()
47
+
48
+ > `static` **set**\<`T`\>(`prop`, `value`): `void`
49
+
50
+ Set the property in the shared store.
51
+
52
+ #### Type Parameters
53
+
54
+ ##### T
55
+
56
+ `T` = `unknown`
57
+
58
+ #### Parameters
59
+
60
+ ##### prop
61
+
62
+ `string`
63
+
64
+ The name of the property to set.
65
+
66
+ ##### value
67
+
68
+ `T`
69
+
70
+ The value to set.
71
+
72
+ #### Returns
73
+
74
+ `void`
75
+
76
+ ***
77
+
78
+ ### remove()
79
+
80
+ > `static` **remove**(`prop`): `void`
81
+
82
+ Remove a property from the shared store.
83
+
84
+ #### Parameters
85
+
86
+ ##### prop
87
+
88
+ `string`
89
+
90
+ The name of the property to remove.
91
+
92
+ #### Returns
93
+
94
+ `void`
@@ -4,13 +4,13 @@ Class to help with string.
4
4
 
5
5
  ## Constructors
6
6
 
7
- ### new StringHelper()
7
+ ### Constructor
8
8
 
9
- > **new StringHelper**(): [`StringHelper`](StringHelper.md)
9
+ > **new StringHelper**(): `StringHelper`
10
10
 
11
11
  #### Returns
12
12
 
13
- [`StringHelper`](StringHelper.md)
13
+ `StringHelper`
14
14
 
15
15
  ## Methods
16
16
 
@@ -22,10 +22,12 @@ Trim trailing slashes from a string.
22
22
 
23
23
  #### Parameters
24
24
 
25
- **value**: `undefined` \| `string`
25
+ ##### value
26
26
 
27
27
  The value to trim.
28
28
 
29
+ `undefined` | `string`
30
+
29
31
  #### Returns
30
32
 
31
33
  `string`
@@ -42,10 +44,12 @@ Trim leading slashes from a string.
42
44
 
43
45
  #### Parameters
44
46
 
45
- **value**: `undefined` \| `string`
47
+ ##### value
46
48
 
47
49
  The value to trim.
48
50
 
51
+ `undefined` | `string`
52
+
49
53
  #### Returns
50
54
 
51
55
  `string`
@@ -62,11 +66,15 @@ Convert the input string to kebab case.
62
66
 
63
67
  #### Parameters
64
68
 
65
- **input**: `string`
69
+ ##### input
70
+
71
+ `string`
66
72
 
67
73
  The input to convert.
68
74
 
69
- **stripInterfacePrefix**: `boolean` = `true`
75
+ ##### stripInterfacePrefix
76
+
77
+ `boolean` = `true`
70
78
 
71
79
  Strip interface prefixes.
72
80
 
@@ -86,11 +94,15 @@ Convert the input string to snake case.
86
94
 
87
95
  #### Parameters
88
96
 
89
- **input**: `string`
97
+ ##### input
98
+
99
+ `string`
90
100
 
91
101
  The input to convert.
92
102
 
93
- **stripInterfacePrefix**: `boolean` = `true`
103
+ ##### stripInterfacePrefix
104
+
105
+ `boolean` = `true`
94
106
 
95
107
  Strip interface prefixes.
96
108
 
@@ -110,11 +122,15 @@ Title case all the words.
110
122
 
111
123
  #### Parameters
112
124
 
113
- **input**: `string`
125
+ ##### input
126
+
127
+ `string`
114
128
 
115
129
  The input to convert.
116
130
 
117
- **stripInterfacePrefix**: `boolean` = `true`
131
+ ##### stripInterfacePrefix
132
+
133
+ `boolean` = `true`
118
134
 
119
135
  Strip interface prefixes.
120
136
 
@@ -134,11 +150,15 @@ Pascal case all the words.
134
150
 
135
151
  #### Parameters
136
152
 
137
- **input**: `string`
153
+ ##### input
154
+
155
+ `string`
138
156
 
139
157
  The input to convert.
140
158
 
141
- **stripInterfacePrefix**: `boolean` = `true`
159
+ ##### stripInterfacePrefix
160
+
161
+ `boolean` = `true`
142
162
 
143
163
  Strip interface prefixes.
144
164
 
@@ -158,11 +178,15 @@ Camel case all the words.
158
178
 
159
179
  #### Parameters
160
180
 
161
- **input**: `string`
181
+ ##### input
182
+
183
+ `string`
162
184
 
163
185
  The input to convert.
164
186
 
165
- **stripInterfacePrefix**: `boolean` = `true`
187
+ ##### stripInterfacePrefix
188
+
189
+ `boolean` = `true`
166
190
 
167
191
  Strip interface prefixes.
168
192
 
@@ -182,11 +206,15 @@ Convert the words to a path.
182
206
 
183
207
  #### Parameters
184
208
 
185
- **input**: `string`
209
+ ##### input
210
+
211
+ `string`
186
212
 
187
213
  The input to convert.
188
214
 
189
- **stripInterfacePrefix**: `boolean` = `true`
215
+ ##### stripInterfacePrefix
216
+
217
+ `boolean` = `true`
190
218
 
191
219
  Strip interface prefixes.
192
220
 
@@ -206,7 +234,9 @@ Strip interface prefix if there is one.
206
234
 
207
235
  #### Parameters
208
236
 
209
- **input**: `string`
237
+ ##### input
238
+
239
+ `string`
210
240
 
211
241
  The input to strip.
212
242
 
@@ -226,7 +256,9 @@ Split a string into words.
226
256
 
227
257
  #### Parameters
228
258
 
229
- **input**: `string`
259
+ ##### input
260
+
261
+ `string`
230
262
 
231
263
  The input to split.
232
264
 
@@ -259,7 +291,9 @@ UTF8-tail = %x80-BF.
259
291
 
260
292
  #### Parameters
261
293
 
262
- **data**: `Uint8Array`
294
+ ##### data
295
+
296
+ `Uint8Array`
263
297
 
264
298
  The data to check.
265
299