@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
@@ -8,37 +8,45 @@ Class to handle errors which are triggered by data not being found.
8
8
 
9
9
  ## Constructors
10
10
 
11
- ### new NotFoundError()
11
+ ### Constructor
12
12
 
13
- > **new NotFoundError**(`source`, `message`, `notFoundId`?, `inner`?): [`NotFoundError`](NotFoundError.md)
13
+ > **new NotFoundError**(`source`, `message`, `notFoundId?`, `inner?`): `NotFoundError`
14
14
 
15
15
  Create a new instance of NotFoundError.
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
- **notFoundId?**: `string`
31
+ ##### notFoundId?
32
+
33
+ `string`
28
34
 
29
35
  The id for the item.
30
36
 
31
- **inner?**: `unknown`
37
+ ##### inner?
38
+
39
+ `unknown`
32
40
 
33
41
  The inner error if we have wrapped another error.
34
42
 
35
43
  #### Returns
36
44
 
37
- [`NotFoundError`](NotFoundError.md)
45
+ `NotFoundError`
38
46
 
39
47
  #### Overrides
40
48
 
41
- [`BaseError`](BaseError.md).[`constructor`](BaseError.md#constructors)
49
+ [`BaseError`](BaseError.md).[`constructor`](BaseError.md#constructor)
42
50
 
43
51
  ## Properties
44
52
 
@@ -62,7 +70,7 @@ Any additional information for the error.
62
70
 
63
71
  #### Index Signature
64
72
 
65
- \[`id`: `string`\]: `unknown`
73
+ \[`id`: `string`\]: `unknown`
66
74
 
67
75
  #### Inherited from
68
76
 
@@ -98,7 +106,9 @@ Construct an error from an existing one.
98
106
 
99
107
  #### Parameters
100
108
 
101
- **err**: `unknown`
109
+ ##### err
110
+
111
+ `unknown`
102
112
 
103
113
  The existing error.
104
114
 
@@ -122,7 +132,9 @@ Flatten an error tree.
122
132
 
123
133
  #### Parameters
124
134
 
125
- **err**: `unknown`
135
+ ##### err
136
+
137
+ `unknown`
126
138
 
127
139
  The starting error.
128
140
 
@@ -146,10 +158,12 @@ Expand an error tree.
146
158
 
147
159
  #### Parameters
148
160
 
149
- **errors**: `undefined` \| [`IError`](../interfaces/IError.md)[]
161
+ ##### errors
150
162
 
151
163
  The list of errors to expand.
152
164
 
165
+ `undefined` | [`IError`](../interfaces/IError.md)[]
166
+
153
167
  #### Returns
154
168
 
155
169
  `undefined` \| [`IError`](../interfaces/IError.md)
@@ -170,14 +184,18 @@ Test to see if the error has the specified error name.
170
184
 
171
185
  #### Parameters
172
186
 
173
- **error**: `unknown`
187
+ ##### error
188
+
189
+ `unknown`
174
190
 
175
191
  The error to test.
176
192
 
177
- **name**: `string` \| `RegExp`
193
+ ##### name
178
194
 
179
195
  The name to check for.
180
196
 
197
+ `string` | `RegExp`
198
+
181
199
  #### Returns
182
200
 
183
201
  `error is BaseError`
@@ -198,14 +216,18 @@ Test to see if the error has the specified error message.
198
216
 
199
217
  #### Parameters
200
218
 
201
- **error**: `unknown`
219
+ ##### error
220
+
221
+ `unknown`
202
222
 
203
223
  The error to test.
204
224
 
205
- **message**: `string` \| `RegExp`
225
+ ##### message
206
226
 
207
227
  The message to check for.
208
228
 
229
+ `string` | `RegExp`
230
+
209
231
  #### Returns
210
232
 
211
233
  `error is BaseError`
@@ -226,14 +248,18 @@ Test to see if the error has the specified error code.
226
248
 
227
249
  #### Parameters
228
250
 
229
- **error**: `unknown`
251
+ ##### error
252
+
253
+ `unknown`
230
254
 
231
255
  The error to test.
232
256
 
233
- **code**: `string` \| `RegExp`
257
+ ##### code
234
258
 
235
259
  The code to check for.
236
260
 
261
+ `string` | `RegExp`
262
+
237
263
  #### Returns
238
264
 
239
265
  `boolean`
@@ -254,14 +280,18 @@ Test to see if any of the errors or children have the given error name.
254
280
 
255
281
  #### Parameters
256
282
 
257
- **error**: `unknown`
283
+ ##### error
284
+
285
+ `unknown`
258
286
 
259
287
  The error to test.
260
288
 
261
- **name**: `string` \| `RegExp`
289
+ ##### name
262
290
 
263
291
  The name to check for.
264
292
 
293
+ `string` | `RegExp`
294
+
265
295
  #### Returns
266
296
 
267
297
  `error is BaseError`
@@ -282,14 +312,18 @@ Test to see if any of the errors or children have the given error message.
282
312
 
283
313
  #### Parameters
284
314
 
285
- **error**: `unknown`
315
+ ##### error
316
+
317
+ `unknown`
286
318
 
287
319
  The error to test.
288
320
 
289
- **message**: `string` \| `RegExp`
321
+ ##### message
290
322
 
291
323
  The message to check for.
292
324
 
325
+ `string` | `RegExp`
326
+
293
327
  #### Returns
294
328
 
295
329
  `error is BaseError`
@@ -310,11 +344,15 @@ Test to see if any of the errors or children are from a specific class.
310
344
 
311
345
  #### Parameters
312
346
 
313
- **error**: `unknown`
347
+ ##### error
348
+
349
+ `unknown`
314
350
 
315
351
  The error to test.
316
352
 
317
- **cls**: `string`
353
+ ##### cls
354
+
355
+ `string`
318
356
 
319
357
  The class to check for.
320
358
 
@@ -338,14 +376,18 @@ Test to see if any of the errors or children have the given error code.
338
376
 
339
377
  #### Parameters
340
378
 
341
- **error**: `unknown`
379
+ ##### error
380
+
381
+ `unknown`
342
382
 
343
383
  The error to test.
344
384
 
345
- **code**: `string` \| `RegExp`
385
+ ##### code
346
386
 
347
387
  The code to check for.
348
388
 
389
+ `string` | `RegExp`
390
+
349
391
  #### Returns
350
392
 
351
393
  `error is BaseError`
@@ -358,12 +400,46 @@ True if the error has the name.
358
400
 
359
401
  ***
360
402
 
403
+ ### isEmpty()
404
+
405
+ > `static` **isEmpty**(`err`): `boolean`
406
+
407
+ Is the error empty.
408
+
409
+ #### Parameters
410
+
411
+ ##### err
412
+
413
+ [`IError`](../interfaces/IError.md)
414
+
415
+ The error to check for being empty.
416
+
417
+ #### Returns
418
+
419
+ `boolean`
420
+
421
+ True if the error is empty.
422
+
423
+ #### Inherited from
424
+
425
+ [`BaseError`](BaseError.md).[`isEmpty`](BaseError.md#isempty)
426
+
427
+ ***
428
+
361
429
  ### toJsonObject()
362
430
 
363
- > **toJsonObject**(): [`IError`](../interfaces/IError.md)
431
+ > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
364
432
 
365
433
  Serialize the error to the error model.
366
434
 
435
+ #### Parameters
436
+
437
+ ##### includeStackTrace?
438
+
439
+ `boolean`
440
+
441
+ Whether to include the error stack in the model, defaults to false.
442
+
367
443
  #### Returns
368
444
 
369
445
  [`IError`](../interfaces/IError.md)
@@ -8,29 +8,33 @@ Class to handle errors.
8
8
 
9
9
  ## Constructors
10
10
 
11
- ### new NotImplementedError()
11
+ ### Constructor
12
12
 
13
- > **new NotImplementedError**(`source`, `method`): [`NotImplementedError`](NotImplementedError.md)
13
+ > **new NotImplementedError**(`source`, `method`): `NotImplementedError`
14
14
 
15
15
  Create a new instance of NotImplementedError.
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
- **method**: `string`
25
+ ##### method
26
+
27
+ `string`
24
28
 
25
29
  The method for the error.
26
30
 
27
31
  #### Returns
28
32
 
29
- [`NotImplementedError`](NotImplementedError.md)
33
+ `NotImplementedError`
30
34
 
31
35
  #### Overrides
32
36
 
33
- [`BaseError`](BaseError.md).[`constructor`](BaseError.md#constructors)
37
+ [`BaseError`](BaseError.md).[`constructor`](BaseError.md#constructor)
34
38
 
35
39
  ## Properties
36
40
 
@@ -54,7 +58,7 @@ Any additional information for the error.
54
58
 
55
59
  #### Index Signature
56
60
 
57
- \[`id`: `string`\]: `unknown`
61
+ \[`id`: `string`\]: `unknown`
58
62
 
59
63
  #### Inherited from
60
64
 
@@ -90,7 +94,9 @@ Construct an error from an existing one.
90
94
 
91
95
  #### Parameters
92
96
 
93
- **err**: `unknown`
97
+ ##### err
98
+
99
+ `unknown`
94
100
 
95
101
  The existing error.
96
102
 
@@ -114,7 +120,9 @@ Flatten an error tree.
114
120
 
115
121
  #### Parameters
116
122
 
117
- **err**: `unknown`
123
+ ##### err
124
+
125
+ `unknown`
118
126
 
119
127
  The starting error.
120
128
 
@@ -138,10 +146,12 @@ Expand an error tree.
138
146
 
139
147
  #### Parameters
140
148
 
141
- **errors**: `undefined` \| [`IError`](../interfaces/IError.md)[]
149
+ ##### errors
142
150
 
143
151
  The list of errors to expand.
144
152
 
153
+ `undefined` | [`IError`](../interfaces/IError.md)[]
154
+
145
155
  #### Returns
146
156
 
147
157
  `undefined` \| [`IError`](../interfaces/IError.md)
@@ -162,14 +172,18 @@ Test to see if the error has the specified error name.
162
172
 
163
173
  #### Parameters
164
174
 
165
- **error**: `unknown`
175
+ ##### error
176
+
177
+ `unknown`
166
178
 
167
179
  The error to test.
168
180
 
169
- **name**: `string` \| `RegExp`
181
+ ##### name
170
182
 
171
183
  The name to check for.
172
184
 
185
+ `string` | `RegExp`
186
+
173
187
  #### Returns
174
188
 
175
189
  `error is BaseError`
@@ -190,14 +204,18 @@ Test to see if the error has the specified error message.
190
204
 
191
205
  #### Parameters
192
206
 
193
- **error**: `unknown`
207
+ ##### error
208
+
209
+ `unknown`
194
210
 
195
211
  The error to test.
196
212
 
197
- **message**: `string` \| `RegExp`
213
+ ##### message
198
214
 
199
215
  The message to check for.
200
216
 
217
+ `string` | `RegExp`
218
+
201
219
  #### Returns
202
220
 
203
221
  `error is BaseError`
@@ -218,14 +236,18 @@ Test to see if the error has the specified error code.
218
236
 
219
237
  #### Parameters
220
238
 
221
- **error**: `unknown`
239
+ ##### error
240
+
241
+ `unknown`
222
242
 
223
243
  The error to test.
224
244
 
225
- **code**: `string` \| `RegExp`
245
+ ##### code
226
246
 
227
247
  The code to check for.
228
248
 
249
+ `string` | `RegExp`
250
+
229
251
  #### Returns
230
252
 
231
253
  `boolean`
@@ -246,14 +268,18 @@ Test to see if any of the errors or children have the given error name.
246
268
 
247
269
  #### Parameters
248
270
 
249
- **error**: `unknown`
271
+ ##### error
272
+
273
+ `unknown`
250
274
 
251
275
  The error to test.
252
276
 
253
- **name**: `string` \| `RegExp`
277
+ ##### name
254
278
 
255
279
  The name to check for.
256
280
 
281
+ `string` | `RegExp`
282
+
257
283
  #### Returns
258
284
 
259
285
  `error is BaseError`
@@ -274,14 +300,18 @@ Test to see if any of the errors or children have the given error message.
274
300
 
275
301
  #### Parameters
276
302
 
277
- **error**: `unknown`
303
+ ##### error
304
+
305
+ `unknown`
278
306
 
279
307
  The error to test.
280
308
 
281
- **message**: `string` \| `RegExp`
309
+ ##### message
282
310
 
283
311
  The message to check for.
284
312
 
313
+ `string` | `RegExp`
314
+
285
315
  #### Returns
286
316
 
287
317
  `error is BaseError`
@@ -302,11 +332,15 @@ Test to see if any of the errors or children are from a specific class.
302
332
 
303
333
  #### Parameters
304
334
 
305
- **error**: `unknown`
335
+ ##### error
336
+
337
+ `unknown`
306
338
 
307
339
  The error to test.
308
340
 
309
- **cls**: `string`
341
+ ##### cls
342
+
343
+ `string`
310
344
 
311
345
  The class to check for.
312
346
 
@@ -330,14 +364,18 @@ Test to see if any of the errors or children have the given error code.
330
364
 
331
365
  #### Parameters
332
366
 
333
- **error**: `unknown`
367
+ ##### error
368
+
369
+ `unknown`
334
370
 
335
371
  The error to test.
336
372
 
337
- **code**: `string` \| `RegExp`
373
+ ##### code
338
374
 
339
375
  The code to check for.
340
376
 
377
+ `string` | `RegExp`
378
+
341
379
  #### Returns
342
380
 
343
381
  `error is BaseError`
@@ -350,12 +388,46 @@ True if the error has the name.
350
388
 
351
389
  ***
352
390
 
391
+ ### isEmpty()
392
+
393
+ > `static` **isEmpty**(`err`): `boolean`
394
+
395
+ Is the error empty.
396
+
397
+ #### Parameters
398
+
399
+ ##### err
400
+
401
+ [`IError`](../interfaces/IError.md)
402
+
403
+ The error to check for being empty.
404
+
405
+ #### Returns
406
+
407
+ `boolean`
408
+
409
+ True if the error is empty.
410
+
411
+ #### Inherited from
412
+
413
+ [`BaseError`](BaseError.md).[`isEmpty`](BaseError.md#isempty)
414
+
415
+ ***
416
+
353
417
  ### toJsonObject()
354
418
 
355
- > **toJsonObject**(): [`IError`](../interfaces/IError.md)
419
+ > **toJsonObject**(`includeStackTrace?`): [`IError`](../interfaces/IError.md)
356
420
 
357
421
  Serialize the error to the error model.
358
422
 
423
+ #### Parameters
424
+
425
+ ##### includeStackTrace?
426
+
427
+ `boolean`
428
+
429
+ Whether to include the error stack in the model, defaults to false.
430
+
359
431
  #### Returns
360
432
 
361
433
  [`IError`](../interfaces/IError.md)