@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
@@ -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
 
@@ -0,0 +1,35 @@
1
+ # Class: Uint8ArrayHelper
2
+
3
+ Class to help with uint8 arrays.
4
+
5
+ ## Constructors
6
+
7
+ ### Constructor
8
+
9
+ > **new Uint8ArrayHelper**(): `Uint8ArrayHelper`
10
+
11
+ #### Returns
12
+
13
+ `Uint8ArrayHelper`
14
+
15
+ ## Methods
16
+
17
+ ### concat()
18
+
19
+ > `static` **concat**(`arrays`): `Uint8Array`
20
+
21
+ Concatenate multiple arrays.
22
+
23
+ #### Parameters
24
+
25
+ ##### arrays
26
+
27
+ `Uint8Array`\<`ArrayBufferLike`\>[]
28
+
29
+ The array to concatenate.
30
+
31
+ #### Returns
32
+
33
+ `Uint8Array`
34
+
35
+ The combined array.
@@ -8,33 +8,39 @@ Class to handle errors which are triggered by access not being unauthorized.
8
8
 
9
9
  ## Constructors
10
10
 
11
- ### new UnauthorizedError()
11
+ ### Constructor
12
12
 
13
- > **new UnauthorizedError**(`source`, `message`, `inner`?): [`UnauthorizedError`](UnauthorizedError.md)
13
+ > **new UnauthorizedError**(`source`, `message`, `inner?`): `UnauthorizedError`
14
14
 
15
15
  Create a new instance of UnauthorizedError.
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
- **inner?**: `unknown`
31
+ ##### inner?
32
+
33
+ `unknown`
28
34
 
29
35
  The inner error if we have wrapped another error.
30
36
 
31
37
  #### Returns
32
38
 
33
- [`UnauthorizedError`](UnauthorizedError.md)
39
+ `UnauthorizedError`
34
40
 
35
41
  #### Overrides
36
42
 
37
- [`BaseError`](BaseError.md).[`constructor`](BaseError.md#constructors)
43
+ [`BaseError`](BaseError.md).[`constructor`](BaseError.md#constructor)
38
44
 
39
45
  ## Properties
40
46
 
@@ -58,7 +64,7 @@ Any additional information for the error.
58
64
 
59
65
  #### Index Signature
60
66
 
61
- \[`id`: `string`\]: `unknown`
67
+ \[`id`: `string`\]: `unknown`
62
68
 
63
69
  #### Inherited from
64
70
 
@@ -94,7 +100,9 @@ Construct an error from an existing one.
94
100
 
95
101
  #### Parameters
96
102
 
97
- **err**: `unknown`
103
+ ##### err
104
+
105
+ `unknown`
98
106
 
99
107
  The existing error.
100
108
 
@@ -118,7 +126,9 @@ Flatten an error tree.
118
126
 
119
127
  #### Parameters
120
128
 
121
- **err**: `unknown`
129
+ ##### err
130
+
131
+ `unknown`
122
132
 
123
133
  The starting error.
124
134
 
@@ -142,10 +152,12 @@ Expand an error tree.
142
152
 
143
153
  #### Parameters
144
154
 
145
- **errors**: `undefined` \| [`IError`](../interfaces/IError.md)[]
155
+ ##### errors
146
156
 
147
157
  The list of errors to expand.
148
158
 
159
+ `undefined` | [`IError`](../interfaces/IError.md)[]
160
+
149
161
  #### Returns
150
162
 
151
163
  `undefined` \| [`IError`](../interfaces/IError.md)
@@ -166,14 +178,18 @@ Test to see if the error has the specified error name.
166
178
 
167
179
  #### Parameters
168
180
 
169
- **error**: `unknown`
181
+ ##### error
182
+
183
+ `unknown`
170
184
 
171
185
  The error to test.
172
186
 
173
- **name**: `string` \| `RegExp`
187
+ ##### name
174
188
 
175
189
  The name to check for.
176
190
 
191
+ `string` | `RegExp`
192
+
177
193
  #### Returns
178
194
 
179
195
  `error is BaseError`
@@ -194,14 +210,18 @@ Test to see if the error has the specified error message.
194
210
 
195
211
  #### Parameters
196
212
 
197
- **error**: `unknown`
213
+ ##### error
214
+
215
+ `unknown`
198
216
 
199
217
  The error to test.
200
218
 
201
- **message**: `string` \| `RegExp`
219
+ ##### message
202
220
 
203
221
  The message to check for.
204
222
 
223
+ `string` | `RegExp`
224
+
205
225
  #### Returns
206
226
 
207
227
  `error is BaseError`
@@ -222,14 +242,18 @@ Test to see if the error has the specified error code.
222
242
 
223
243
  #### Parameters
224
244
 
225
- **error**: `unknown`
245
+ ##### error
246
+
247
+ `unknown`
226
248
 
227
249
  The error to test.
228
250
 
229
- **code**: `string` \| `RegExp`
251
+ ##### code
230
252
 
231
253
  The code to check for.
232
254
 
255
+ `string` | `RegExp`
256
+
233
257
  #### Returns
234
258
 
235
259
  `boolean`
@@ -250,14 +274,18 @@ Test to see if any of the errors or children have the given error name.
250
274
 
251
275
  #### Parameters
252
276
 
253
- **error**: `unknown`
277
+ ##### error
278
+
279
+ `unknown`
254
280
 
255
281
  The error to test.
256
282
 
257
- **name**: `string` \| `RegExp`
283
+ ##### name
258
284
 
259
285
  The name to check for.
260
286
 
287
+ `string` | `RegExp`
288
+
261
289
  #### Returns
262
290
 
263
291
  `error is BaseError`
@@ -278,14 +306,18 @@ Test to see if any of the errors or children have the given error message.
278
306
 
279
307
  #### Parameters
280
308
 
281
- **error**: `unknown`
309
+ ##### error
310
+
311
+ `unknown`
282
312
 
283
313
  The error to test.
284
314
 
285
- **message**: `string` \| `RegExp`
315
+ ##### message
286
316
 
287
317
  The message to check for.
288
318
 
319
+ `string` | `RegExp`
320
+
289
321
  #### Returns
290
322
 
291
323
  `error is BaseError`
@@ -306,11 +338,15 @@ Test to see if any of the errors or children are from a specific class.
306
338
 
307
339
  #### Parameters
308
340
 
309
- **error**: `unknown`
341
+ ##### error
342
+
343
+ `unknown`
310
344
 
311
345
  The error to test.
312
346
 
313
- **cls**: `string`
347
+ ##### cls
348
+
349
+ `string`
314
350
 
315
351
  The class to check for.
316
352
 
@@ -334,14 +370,18 @@ Test to see if any of the errors or children have the given error code.
334
370
 
335
371
  #### Parameters
336
372
 
337
- **error**: `unknown`
373
+ ##### error
374
+
375
+ `unknown`
338
376
 
339
377
  The error to test.
340
378
 
341
- **code**: `string` \| `RegExp`
379
+ ##### code
342
380
 
343
381
  The code to check for.
344
382
 
383
+ `string` | `RegExp`
384
+
345
385
  #### Returns
346
386
 
347
387
  `error is BaseError`
@@ -354,12 +394,46 @@ True if the error has the name.
354
394
 
355
395
  ***
356
396
 
397
+ ### isEmpty()
398
+
399
+ > `static` **isEmpty**(`err`): `boolean`
400
+
401
+ Is the error empty.
402
+
403
+ #### Parameters
404
+
405
+ ##### err
406
+
407
+ [`IError`](../interfaces/IError.md)
408
+
409
+ The error to check for being empty.
410
+
411
+ #### Returns
412
+
413
+ `boolean`
414
+
415
+ True if the error is empty.
416
+
417
+ #### Inherited from
418
+
419
+ [`BaseError`](BaseError.md).[`isEmpty`](BaseError.md#isempty)
420
+
421
+ ***
422
+
357
423
  ### toJsonObject()
358
424
 
359
- > **toJsonObject**(): [`IError`](../interfaces/IError.md)
425
+ > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
360
426
 
361
427
  Serialize the error to the error model.
362
428
 
429
+ #### Parameters
430
+
431
+ ##### includeStackTrace?
432
+
433
+ `boolean`
434
+
435
+ Whether to include the error stack in the model, defaults to false.
436
+
363
437
  #### Returns
364
438
 
365
439
  [`IError`](../interfaces/IError.md)