@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,287 @@
1
+ # Class: ObjectHelper
2
+
3
+ Class to help with objects.
4
+
5
+ ## Constructors
6
+
7
+ ### new ObjectHelper()
8
+
9
+ > **new ObjectHelper**(): [`ObjectHelper`](ObjectHelper.md)
10
+
11
+ #### Returns
12
+
13
+ [`ObjectHelper`](ObjectHelper.md)
14
+
15
+ ## Methods
16
+
17
+ ### toBytes()
18
+
19
+ > `static` **toBytes**\<`T`\>(`obj`, `format`): `Uint8Array`
20
+
21
+ Convert an object to bytes.
22
+
23
+ #### Type Parameters
24
+
25
+ • **T**
26
+
27
+ #### Parameters
28
+
29
+ • **obj**: `undefined` \| `T`
30
+
31
+ The object to convert.
32
+
33
+ • **format**: `boolean` = `false`
34
+
35
+ Format the JSON content.
36
+
37
+ #### Returns
38
+
39
+ `Uint8Array`
40
+
41
+ The object as bytes.
42
+
43
+ ***
44
+
45
+ ### fromBytes()
46
+
47
+ > `static` **fromBytes**\<`T`\>(`bytes`): `T`
48
+
49
+ Convert a bytes to an object.
50
+
51
+ #### Type Parameters
52
+
53
+ • **T**
54
+
55
+ #### Parameters
56
+
57
+ • **bytes**: `undefined` \| `null` \| `Uint8Array`
58
+
59
+ The bytes to convert to an object.
60
+
61
+ #### Returns
62
+
63
+ `T`
64
+
65
+ The object.
66
+
67
+ #### Throws
68
+
69
+ GeneralError if there was an error parsing the JSON.
70
+
71
+ ***
72
+
73
+ ### clone()
74
+
75
+ > `static` **clone**\<`T`\>(`obj`): `T`
76
+
77
+ Make a deep clone of an object.
78
+
79
+ #### Type Parameters
80
+
81
+ • **T**
82
+
83
+ #### Parameters
84
+
85
+ • **obj**: `T`
86
+
87
+ The object to clone.
88
+
89
+ #### Returns
90
+
91
+ `T`
92
+
93
+ The objects clone.
94
+
95
+ ***
96
+
97
+ ### merge()
98
+
99
+ > `static` **merge**\<`T`, `U`\>(`obj1`, `obj2`): `T` & `U`
100
+
101
+ Deep merge objects.
102
+
103
+ #### Type Parameters
104
+
105
+ • **T** = `unknown`
106
+
107
+ • **U** = `unknown`
108
+
109
+ #### Parameters
110
+
111
+ • **obj1**: `T`
112
+
113
+ The first object to merge.
114
+
115
+ • **obj2**: `U`
116
+
117
+ The second object to merge.
118
+
119
+ #### Returns
120
+
121
+ `T` & `U`
122
+
123
+ The combined deep merge of the objects.
124
+
125
+ ***
126
+
127
+ ### equal()
128
+
129
+ > `static` **equal**\<`T`\>(`obj1`, `obj2`, `strictPropertyOrder`?): `boolean`
130
+
131
+ Does one object equal another.
132
+
133
+ #### Type Parameters
134
+
135
+ • **T**
136
+
137
+ #### Parameters
138
+
139
+ • **obj1**: `T`
140
+
141
+ The first object to compare.
142
+
143
+ • **obj2**: `T`
144
+
145
+ The second object to compare.
146
+
147
+ • **strictPropertyOrder?**: `boolean`
148
+
149
+ Should the properties be in the same order, defaults to true.
150
+
151
+ #### Returns
152
+
153
+ `boolean`
154
+
155
+ True is the objects are equal.
156
+
157
+ ***
158
+
159
+ ### propertyGet()
160
+
161
+ > `static` **propertyGet**\<`T`\>(`obj`, `property`): `undefined` \| `T`
162
+
163
+ Get the property of an unknown object.
164
+
165
+ #### Type Parameters
166
+
167
+ • **T** = `unknown`
168
+
169
+ #### Parameters
170
+
171
+ • **obj**: `unknown`
172
+
173
+ The object to get the property from.
174
+
175
+ • **property**: `string`
176
+
177
+ The property to get, can be separated by dots for nested path.
178
+
179
+ #### Returns
180
+
181
+ `undefined` \| `T`
182
+
183
+ The property.
184
+
185
+ ***
186
+
187
+ ### propertySet()
188
+
189
+ > `static` **propertySet**(`obj`, `property`, `value`): `void`
190
+
191
+ Set the property of an unknown object.
192
+
193
+ #### Parameters
194
+
195
+ • **obj**: `unknown`
196
+
197
+ The object to set the property from.
198
+
199
+ • **property**: `string`
200
+
201
+ The property to set.
202
+
203
+ • **value**: `unknown`
204
+
205
+ The value to set.
206
+
207
+ #### Returns
208
+
209
+ `void`
210
+
211
+ ***
212
+
213
+ ### propertyDelete()
214
+
215
+ > `static` **propertyDelete**(`obj`, `property`): `void`
216
+
217
+ Delete the property of an unknown object.
218
+
219
+ #### Parameters
220
+
221
+ • **obj**: `unknown`
222
+
223
+ The object to set the property from.
224
+
225
+ • **property**: `string`
226
+
227
+ The property to set
228
+
229
+ #### Returns
230
+
231
+ `void`
232
+
233
+ ***
234
+
235
+ ### pick()
236
+
237
+ > `static` **pick**\<`T`\>(`obj`, `keys`?): `Partial`\<`T`\>
238
+
239
+ Pick a subset of properties from an object.
240
+
241
+ #### Type Parameters
242
+
243
+ • **T**
244
+
245
+ #### Parameters
246
+
247
+ • **obj**: `undefined` \| `T`
248
+
249
+ The object to pick the properties from.
250
+
251
+ • **keys?**: keyof `T`[]
252
+
253
+ The property keys to pick.
254
+
255
+ #### Returns
256
+
257
+ `Partial`\<`T`\>
258
+
259
+ The partial object.
260
+
261
+ ***
262
+
263
+ ### omit()
264
+
265
+ > `static` **omit**\<`T`\>(`obj`, `keys`?): `Partial`\<`T`\>
266
+
267
+ Omit a subset of properties from an object.
268
+
269
+ #### Type Parameters
270
+
271
+ • **T**
272
+
273
+ #### Parameters
274
+
275
+ • **obj**: `undefined` \| `T`
276
+
277
+ The object to omit the properties from.
278
+
279
+ • **keys?**: keyof `T`[]
280
+
281
+ The property keys to omit.
282
+
283
+ #### Returns
284
+
285
+ `Partial`\<`T`\>
286
+
287
+ The partial object.
@@ -0,0 +1,33 @@
1
+ # Class: RandomHelper
2
+
3
+ Class to help with random generation.
4
+
5
+ ## Constructors
6
+
7
+ ### new RandomHelper()
8
+
9
+ > **new RandomHelper**(): [`RandomHelper`](RandomHelper.md)
10
+
11
+ #### Returns
12
+
13
+ [`RandomHelper`](RandomHelper.md)
14
+
15
+ ## Methods
16
+
17
+ ### generate()
18
+
19
+ > `static` **generate**(`length`): `Uint8Array`
20
+
21
+ Generate a new random array.
22
+
23
+ #### Parameters
24
+
25
+ • **length**: `number`
26
+
27
+ The length of buffer to create.
28
+
29
+ #### Returns
30
+
31
+ `Uint8Array`
32
+
33
+ The random array.
@@ -0,0 +1,270 @@
1
+ # Class: StringHelper
2
+
3
+ Class to help with string.
4
+
5
+ ## Constructors
6
+
7
+ ### new StringHelper()
8
+
9
+ > **new StringHelper**(): [`StringHelper`](StringHelper.md)
10
+
11
+ #### Returns
12
+
13
+ [`StringHelper`](StringHelper.md)
14
+
15
+ ## Methods
16
+
17
+ ### trimTrailingSlashes()
18
+
19
+ > `static` **trimTrailingSlashes**(`value`): `string`
20
+
21
+ Trim trailing slashes from a string.
22
+
23
+ #### Parameters
24
+
25
+ • **value**: `undefined` \| `string`
26
+
27
+ The value to trim.
28
+
29
+ #### Returns
30
+
31
+ `string`
32
+
33
+ The trimmed value.
34
+
35
+ ***
36
+
37
+ ### trimLeadingSlashes()
38
+
39
+ > `static` **trimLeadingSlashes**(`value`): `string`
40
+
41
+ Trim leading slashes from a string.
42
+
43
+ #### Parameters
44
+
45
+ • **value**: `undefined` \| `string`
46
+
47
+ The value to trim.
48
+
49
+ #### Returns
50
+
51
+ `string`
52
+
53
+ The trimmed value.
54
+
55
+ ***
56
+
57
+ ### kebabCase()
58
+
59
+ > `static` **kebabCase**(`input`, `stripInterfacePrefix`): `string`
60
+
61
+ Convert the input string to kebab case.
62
+
63
+ #### Parameters
64
+
65
+ • **input**: `string`
66
+
67
+ The input to convert.
68
+
69
+ • **stripInterfacePrefix**: `boolean` = `true`
70
+
71
+ Strip interface prefixes.
72
+
73
+ #### Returns
74
+
75
+ `string`
76
+
77
+ The kebab case version of the input.
78
+
79
+ ***
80
+
81
+ ### snakeCase()
82
+
83
+ > `static` **snakeCase**(`input`, `stripInterfacePrefix`): `string`
84
+
85
+ Convert the input string to snake case.
86
+
87
+ #### Parameters
88
+
89
+ • **input**: `string`
90
+
91
+ The input to convert.
92
+
93
+ • **stripInterfacePrefix**: `boolean` = `true`
94
+
95
+ Strip interface prefixes.
96
+
97
+ #### Returns
98
+
99
+ `string`
100
+
101
+ The snake case version of the input.
102
+
103
+ ***
104
+
105
+ ### titleCase()
106
+
107
+ > `static` **titleCase**(`input`, `stripInterfacePrefix`): `string`
108
+
109
+ Title case all the words.
110
+
111
+ #### Parameters
112
+
113
+ • **input**: `string`
114
+
115
+ The input to convert.
116
+
117
+ • **stripInterfacePrefix**: `boolean` = `true`
118
+
119
+ Strip interface prefixes.
120
+
121
+ #### Returns
122
+
123
+ `string`
124
+
125
+ The title case version of the input.
126
+
127
+ ***
128
+
129
+ ### pascalCase()
130
+
131
+ > `static` **pascalCase**(`input`, `stripInterfacePrefix`): `string`
132
+
133
+ Pascal case all the words.
134
+
135
+ #### Parameters
136
+
137
+ • **input**: `string`
138
+
139
+ The input to convert.
140
+
141
+ • **stripInterfacePrefix**: `boolean` = `true`
142
+
143
+ Strip interface prefixes.
144
+
145
+ #### Returns
146
+
147
+ `string`
148
+
149
+ The pascal case version of the input.
150
+
151
+ ***
152
+
153
+ ### camelCase()
154
+
155
+ > `static` **camelCase**(`input`, `stripInterfacePrefix`): `string`
156
+
157
+ Camel case all the words.
158
+
159
+ #### Parameters
160
+
161
+ • **input**: `string`
162
+
163
+ The input to convert.
164
+
165
+ • **stripInterfacePrefix**: `boolean` = `true`
166
+
167
+ Strip interface prefixes.
168
+
169
+ #### Returns
170
+
171
+ `string`
172
+
173
+ The camel case version of the input.
174
+
175
+ ***
176
+
177
+ ### wordPath()
178
+
179
+ > `static` **wordPath**(`input`, `stripInterfacePrefix`): `string`
180
+
181
+ Convert the words to a path.
182
+
183
+ #### Parameters
184
+
185
+ • **input**: `string`
186
+
187
+ The input to convert.
188
+
189
+ • **stripInterfacePrefix**: `boolean` = `true`
190
+
191
+ Strip interface prefixes.
192
+
193
+ #### Returns
194
+
195
+ `string`
196
+
197
+ The path version of the input.
198
+
199
+ ***
200
+
201
+ ### stripPrefix()
202
+
203
+ > `static` **stripPrefix**(`input`): `string`
204
+
205
+ Strip interface prefix if there is one.
206
+
207
+ #### Parameters
208
+
209
+ • **input**: `string`
210
+
211
+ The input to strip.
212
+
213
+ #### Returns
214
+
215
+ `string`
216
+
217
+ The input with any interface prefix stripped.
218
+
219
+ ***
220
+
221
+ ### words()
222
+
223
+ > `static` **words**(`input`): `string`[]
224
+
225
+ Split a string into words.
226
+
227
+ #### Parameters
228
+
229
+ • **input**: `string`
230
+
231
+ The input to split.
232
+
233
+ #### Returns
234
+
235
+ `string`[]
236
+
237
+ The string split into words.
238
+
239
+ ***
240
+
241
+ ### isUtf8()
242
+
243
+ > `static` **isUtf8**(`data`): `boolean`
244
+
245
+ Check if a Node.js Buffer or Uint8Array is UTF-8.
246
+ Url https://tools.ietf.org/html/rfc3629
247
+ Source https://github.com/hcodes/isutf8
248
+ UTF8-char = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4.
249
+ UTF8-1 = %x00-7F.
250
+ UTF8-2 = %xC2-DF UTF8-tail.
251
+ UTF8-3 = %xE0 %xA0-BF UTF8-tail.
252
+ - %xE1-EC 2( UTF8-tail ).
253
+ - %xED %x80-9F UTF8-tail.
254
+ - %xEE-EF 2( UTF8-tail ).
255
+ UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ).
256
+ - %xF1-F3 3( UTF8-tail ).
257
+ - %xF4 %x80-8F 2( UTF8-tail ).
258
+ UTF8-tail = %x80-BF.
259
+
260
+ #### Parameters
261
+
262
+ • **data**: `Uint8Array`
263
+
264
+ The data to check.
265
+
266
+ #### Returns
267
+
268
+ `boolean`
269
+
270
+ True if the data is utf8.