@twin.org/core 0.9.2-next.1 → 0.9.2-next.11

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 (39) hide show
  1. package/dist/es/helpers/objectHelper.js +17 -10
  2. package/dist/es/helpers/objectHelper.js.map +1 -1
  3. package/dist/es/index.js +2 -2
  4. package/dist/es/index.js.map +1 -1
  5. package/dist/es/models/IComponent.js +2 -0
  6. package/dist/es/models/IComponent.js.map +1 -1
  7. package/dist/es/models/coerceType.js +5 -1
  8. package/dist/es/models/coerceType.js.map +1 -1
  9. package/dist/es/utils/coerce.js +35 -6
  10. package/dist/es/utils/coerce.js.map +1 -1
  11. package/dist/es/utils/lfuCache.js +380 -0
  12. package/dist/es/utils/lfuCache.js.map +1 -0
  13. package/dist/es/utils/lruCache.js +271 -0
  14. package/dist/es/utils/lruCache.js.map +1 -0
  15. package/dist/types/helpers/objectHelper.d.ts +6 -6
  16. package/dist/types/index.d.ts +2 -2
  17. package/dist/types/models/IComponent.d.ts +0 -6
  18. package/dist/types/models/coerceType.d.ts +4 -0
  19. package/dist/types/utils/coerce.d.ts +6 -0
  20. package/dist/types/utils/lfuCache.d.ts +100 -0
  21. package/dist/types/utils/lruCache.d.ts +97 -0
  22. package/docs/changelog.md +172 -0
  23. package/docs/reference/classes/Coerce.md +28 -0
  24. package/docs/reference/classes/LfuCache.md +265 -0
  25. package/docs/reference/classes/LruCache.md +262 -0
  26. package/docs/reference/classes/ObjectHelper.md +6 -6
  27. package/docs/reference/index.md +2 -3
  28. package/docs/reference/interfaces/IComponent.md +0 -14
  29. package/docs/reference/variables/CoerceType.md +6 -0
  30. package/package.json +4 -4
  31. package/dist/es/models/IHealth.js +0 -2
  32. package/dist/es/models/IHealth.js.map +0 -1
  33. package/dist/es/models/healthStatus.js +0 -21
  34. package/dist/es/models/healthStatus.js.map +0 -1
  35. package/dist/types/models/IHealth.d.ts +0 -32
  36. package/dist/types/models/healthStatus.d.ts +0 -21
  37. package/docs/reference/interfaces/IHealth.md +0 -55
  38. package/docs/reference/type-aliases/HealthStatus.md +0 -5
  39. package/docs/reference/variables/HealthStatus.md +0 -25
package/docs/changelog.md CHANGED
@@ -1,5 +1,177 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.2-next.11](https://github.com/iotaledger/twin-framework/compare/core-v0.9.2-next.10...core-v0.9.2-next.11) (2026-08-20)
4
+
5
+
6
+ ### Features
7
+
8
+ * coerce array ([#452](https://github.com/iotaledger/twin-framework/issues/452)) ([2019567](https://github.com/iotaledger/twin-framework/commit/20195673a65fe7179272ac84f37dc927218c128a))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/nameof bumped from 0.9.2-next.10 to 0.9.2-next.11
16
+ * devDependencies
17
+ * @twin.org/nameof-transformer bumped from 0.9.2-next.10 to 0.9.2-next.11
18
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.10 to 0.9.2-next.11
19
+
20
+ ## [0.9.2-next.10](https://github.com/iotaledger/twin-framework/compare/core-v0.9.2-next.9...core-v0.9.2-next.10) (2026-08-11)
21
+
22
+
23
+ ### Features
24
+
25
+ * add lru and lft cache ([#449](https://github.com/iotaledger/twin-framework/issues/449)) ([67d741e](https://github.com/iotaledger/twin-framework/commit/67d741eab3b89556e3c55053b5a473a4c1592fed))
26
+
27
+
28
+ ### Dependencies
29
+
30
+ * The following workspace dependencies were updated
31
+ * dependencies
32
+ * @twin.org/nameof bumped from 0.9.2-next.9 to 0.9.2-next.10
33
+ * devDependencies
34
+ * @twin.org/nameof-transformer bumped from 0.9.2-next.9 to 0.9.2-next.10
35
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.9 to 0.9.2-next.10
36
+
37
+ ## [0.9.2-next.9](https://github.com/iotaledger/twin-framework/compare/core-v0.9.2-next.8...core-v0.9.2-next.9) (2026-08-10)
38
+
39
+
40
+ ### Bug Fixes
41
+
42
+ * number coercion wrongly accepts alpha ([c04c1af](https://github.com/iotaledger/twin-framework/commit/c04c1af24697b6c92a180a71c0722c5673313360))
43
+ * number coercion wrongly accepts alpha ([dd5b193](https://github.com/iotaledger/twin-framework/commit/dd5b193c2501f6d30ca94aa0fc30a6edfe405e6f))
44
+
45
+
46
+ ### Dependencies
47
+
48
+ * The following workspace dependencies were updated
49
+ * dependencies
50
+ * @twin.org/nameof bumped from 0.9.2-next.8 to 0.9.2-next.9
51
+ * devDependencies
52
+ * @twin.org/nameof-transformer bumped from 0.9.2-next.8 to 0.9.2-next.9
53
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.8 to 0.9.2-next.9
54
+
55
+ ## [0.9.2-next.8](https://github.com/iotaledger/twin-framework/compare/core-v0.9.2-next.7...core-v0.9.2-next.8) (2026-08-10)
56
+
57
+
58
+ ### Features
59
+
60
+ * optimistic locking version property for schemas ([#443](https://github.com/iotaledger/twin-framework/issues/443)) ([1b90987](https://github.com/iotaledger/twin-framework/commit/1b909875dc915a0ec133d8424d013ae7e4ddfb48))
61
+
62
+
63
+ ### Dependencies
64
+
65
+ * The following workspace dependencies were updated
66
+ * dependencies
67
+ * @twin.org/nameof bumped from 0.9.2-next.7 to 0.9.2-next.8
68
+ * devDependencies
69
+ * @twin.org/nameof-transformer bumped from 0.9.2-next.7 to 0.9.2-next.8
70
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.7 to 0.9.2-next.8
71
+
72
+ ## [0.9.2-next.7](https://github.com/iotaledger/twin-framework/compare/core-v0.9.2-next.6...core-v0.9.2-next.7) (2026-08-07)
73
+
74
+
75
+ ### Features
76
+
77
+ * linting and dependency update ([1c428ef](https://github.com/iotaledger/twin-framework/commit/1c428efe0391c52632962847d8dad68bd8e5dd00))
78
+ * linting and dependency update ([676b4e9](https://github.com/iotaledger/twin-framework/commit/676b4e9d9bce158065200bbf875bb31da81d166d))
79
+
80
+
81
+ ### Dependencies
82
+
83
+ * The following workspace dependencies were updated
84
+ * dependencies
85
+ * @twin.org/nameof bumped from 0.9.2-next.6 to 0.9.2-next.7
86
+ * devDependencies
87
+ * @twin.org/nameof-transformer bumped from 0.9.2-next.6 to 0.9.2-next.7
88
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.6 to 0.9.2-next.7
89
+
90
+ ## [0.9.2-next.6](https://github.com/iotaledger/twin-framework/compare/core-v0.9.2-next.5...core-v0.9.2-next.6) (2026-08-04)
91
+
92
+
93
+ ### Miscellaneous Chores
94
+
95
+ * **core:** Synchronize repo versions
96
+
97
+
98
+ ### Dependencies
99
+
100
+ * The following workspace dependencies were updated
101
+ * dependencies
102
+ * @twin.org/nameof bumped from 0.9.2-next.5 to 0.9.2-next.6
103
+ * devDependencies
104
+ * @twin.org/nameof-transformer bumped from 0.9.2-next.5 to 0.9.2-next.6
105
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.5 to 0.9.2-next.6
106
+
107
+ ## [0.9.2-next.5](https://github.com/iotaledger/twin-framework/compare/core-v0.9.2-next.4...core-v0.9.2-next.5) (2026-08-03)
108
+
109
+
110
+ ### Features
111
+
112
+ * move health support to api repo ([#435](https://github.com/iotaledger/twin-framework/issues/435)) ([867f766](https://github.com/iotaledger/twin-framework/commit/867f766afc86607bec6b5cf9c3ab5bd5c41d0b3c))
113
+
114
+
115
+ ### Dependencies
116
+
117
+ * The following workspace dependencies were updated
118
+ * dependencies
119
+ * @twin.org/nameof bumped from 0.9.2-next.4 to 0.9.2-next.5
120
+ * devDependencies
121
+ * @twin.org/nameof-transformer bumped from 0.9.2-next.4 to 0.9.2-next.5
122
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.4 to 0.9.2-next.5
123
+
124
+ ## [0.9.2-next.4](https://github.com/iotaledger/twin-framework/compare/core-v0.9.2-next.3...core-v0.9.2-next.4) (2026-07-31)
125
+
126
+
127
+ ### Miscellaneous Chores
128
+
129
+ * **core:** Synchronize repo versions
130
+
131
+
132
+ ### Dependencies
133
+
134
+ * The following workspace dependencies were updated
135
+ * dependencies
136
+ * @twin.org/nameof bumped from 0.9.2-next.3 to 0.9.2-next.4
137
+ * devDependencies
138
+ * @twin.org/nameof-transformer bumped from 0.9.2-next.3 to 0.9.2-next.4
139
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.3 to 0.9.2-next.4
140
+
141
+ ## [0.9.2-next.3](https://github.com/iotaledger/twin-framework/compare/core-v0.9.2-next.2...core-v0.9.2-next.3) (2026-07-30)
142
+
143
+
144
+ ### Bug Fixes
145
+
146
+ * coerce and includes ([#429](https://github.com/iotaledger/twin-framework/issues/429)) ([98c9132](https://github.com/iotaledger/twin-framework/commit/98c9132316c0393ede9d6e634bbae9e5ece2d6b9))
147
+
148
+
149
+ ### Dependencies
150
+
151
+ * The following workspace dependencies were updated
152
+ * dependencies
153
+ * @twin.org/nameof bumped from 0.9.2-next.2 to 0.9.2-next.3
154
+ * devDependencies
155
+ * @twin.org/nameof-transformer bumped from 0.9.2-next.2 to 0.9.2-next.3
156
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.2 to 0.9.2-next.3
157
+
158
+ ## [0.9.2-next.2](https://github.com/iotaledger/twin-framework/compare/core-v0.9.2-next.1...core-v0.9.2-next.2) (2026-07-29)
159
+
160
+
161
+ ### Miscellaneous Chores
162
+
163
+ * **core:** Synchronize repo versions
164
+
165
+
166
+ ### Dependencies
167
+
168
+ * The following workspace dependencies were updated
169
+ * dependencies
170
+ * @twin.org/nameof bumped from 0.9.2-next.1 to 0.9.2-next.2
171
+ * devDependencies
172
+ * @twin.org/nameof-transformer bumped from 0.9.2-next.1 to 0.9.2-next.2
173
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.1 to 0.9.2-next.2
174
+
3
175
  ## [0.9.2-next.1](https://github.com/iotaledger/twin-framework/compare/core-v0.9.2-next.0...core-v0.9.2-next.1) (2026-07-28)
4
176
 
5
177
 
@@ -214,6 +214,34 @@ The duration object, or undefined if the value cannot be coerced.
214
214
 
215
215
  ***
216
216
 
217
+ ### array() {#array}
218
+
219
+ > `static` **array**\<`T`\>(`value`): `T`[] \| `undefined`
220
+
221
+ Coerce the value to an array.
222
+
223
+ #### Type Parameters
224
+
225
+ ##### T
226
+
227
+ `T` = `unknown`
228
+
229
+ #### Parameters
230
+
231
+ ##### value
232
+
233
+ `unknown`
234
+
235
+ The value to coerce.
236
+
237
+ #### Returns
238
+
239
+ `T`[] \| `undefined`
240
+
241
+ The coerced array, or undefined if the value cannot be coerced.
242
+
243
+ ***
244
+
217
245
  ### object() {#object}
218
246
 
219
247
  > `static` **object**\<`T`\>(`value`): `T` \| `undefined`
@@ -0,0 +1,265 @@
1
+ # Class: LfuCache\<T\>
2
+
3
+ A fixed-capacity LFU cache with time-to-idle eviction.
4
+
5
+ Entries are removed in two ways:
6
+ - Capacity eviction: when the cache is full the least-frequently-used entry is removed first.
7
+ Ties in frequency are broken by recency the least-recently-used entry among those with the
8
+ minimum frequency is evicted.
9
+ - TTI eviction: a background timer sweeps idle entries every ttiMs milliseconds.
10
+ The timer only runs while there are entries; it stops automatically when the cache empties.
11
+
12
+ `get` and `set` increment an entry's access frequency and reset its idle timer.
13
+ `has` and `keys` are pure peeks they evict idle entries but do not affect frequency or TTI.
14
+ Call `destroy` when the cache is no longer needed to stop the background timer.
15
+
16
+ ## Type Parameters
17
+
18
+ ### T
19
+
20
+ `T`
21
+
22
+ ## Constructors
23
+
24
+ ### Constructor
25
+
26
+ > **new LfuCache**\<`T`\>(`options?`): `LfuCache`\<`T`\>
27
+
28
+ Create a new instance of LfuCache.
29
+
30
+ #### Parameters
31
+
32
+ ##### options?
33
+
34
+ The cache options.
35
+
36
+ ###### capacity?
37
+
38
+ `number`
39
+
40
+ Maximum number of entries. Defaults to 1000. Must be a positive integer.
41
+
42
+ ###### ttiMs?
43
+
44
+ `number`
45
+
46
+ Time-to-idle in milliseconds. Defaults to 10000. Must be a positive integer.
47
+
48
+ ###### mutexTimeoutMs?
49
+
50
+ `number`
51
+
52
+ Maximum time in milliseconds to wait for getOrSet mutex acquisition.
53
+
54
+ #### Returns
55
+
56
+ `LfuCache`\<`T`\>
57
+
58
+ #### Throws
59
+
60
+ ValidationError if capacity or ttiMs is not a positive integer.
61
+
62
+ ## Properties
63
+
64
+ ### CLASS\_NAME {#class_name}
65
+
66
+ > `readonly` `static` **CLASS\_NAME**: `string`
67
+
68
+ Runtime name for the class.
69
+
70
+ ***
71
+
72
+ ### DEFAULT\_CAPACITY {#default_capacity}
73
+
74
+ > `readonly` `static` **DEFAULT\_CAPACITY**: `1000` = `1000`
75
+
76
+ Default capacity.
77
+
78
+ ***
79
+
80
+ ### DEFAULT\_TTI\_MS {#default_tti_ms}
81
+
82
+ > `readonly` `static` **DEFAULT\_TTI\_MS**: `10000` = `10000`
83
+
84
+ Default time-to-idle in milliseconds.
85
+
86
+ ## Methods
87
+
88
+ ### count() {#count}
89
+
90
+ > **count**(): `number`
91
+
92
+ The number of entries currently held in the cache.
93
+
94
+ #### Returns
95
+
96
+ `number`
97
+
98
+ The number of entries in the cache.
99
+
100
+ ***
101
+
102
+ ### get() {#get}
103
+
104
+ > **get**(`key`): `T` \| `undefined`
105
+
106
+ Get a value from the cache.
107
+ Returns undefined if the key is absent or the entry has idled out.
108
+ A successful hit increments the entry's frequency and resets its idle timer.
109
+
110
+ #### Parameters
111
+
112
+ ##### key
113
+
114
+ `string`
115
+
116
+ The key to retrieve.
117
+
118
+ #### Returns
119
+
120
+ `T` \| `undefined`
121
+
122
+ The cached value, or undefined on a miss or idle eviction.
123
+
124
+ ***
125
+
126
+ ### set() {#set}
127
+
128
+ > **set**(`key`, `value`): `void`
129
+
130
+ Store a value in the cache.
131
+ If the key already exists its value and frequency are updated.
132
+ When the cache is at capacity, idle entries are swept first; if it is still full the
133
+ least-frequently-used entry is evicted (LRU among ties).
134
+
135
+ #### Parameters
136
+
137
+ ##### key
138
+
139
+ `string`
140
+
141
+ The key to store.
142
+
143
+ ##### value
144
+
145
+ `T`
146
+
147
+ The value to cache.
148
+
149
+ #### Returns
150
+
151
+ `void`
152
+
153
+ ***
154
+
155
+ ### getOrSet() {#getorset}
156
+
157
+ > **getOrSet**(`key`, `valueFactory`): `Promise`\<`T`\>
158
+
159
+ Atomically get an existing value or create and store it once using an async factory.
160
+ Concurrent calls for the same key are serialized via a mutex.
161
+
162
+ #### Parameters
163
+
164
+ ##### key
165
+
166
+ `string`
167
+
168
+ The key to get or create.
169
+
170
+ ##### valueFactory
171
+
172
+ () => `Promise`\<`T`\>
173
+
174
+ Async callback used to build a value when the key is absent.
175
+
176
+ #### Returns
177
+
178
+ `Promise`\<`T`\>
179
+
180
+ The existing or newly created value.
181
+
182
+ ***
183
+
184
+ ### has() {#has}
185
+
186
+ > **has**(`key`): `boolean`
187
+
188
+ Check whether a key exists in the cache and has not idled out.
189
+ Idle entries are evicted on peek, but a live entry's frequency and TTI are not updated.
190
+
191
+ #### Parameters
192
+
193
+ ##### key
194
+
195
+ `string`
196
+
197
+ The key to test.
198
+
199
+ #### Returns
200
+
201
+ `boolean`
202
+
203
+ True if the key is present and not idle.
204
+
205
+ ***
206
+
207
+ ### keys() {#keys}
208
+
209
+ > **keys**(): `string`[]
210
+
211
+ Return all keys for entries that have not idled out.
212
+ Idle entries encountered during iteration are evicted.
213
+ Keys are returned in ascending frequency order; within the same frequency, LRU first.
214
+
215
+ #### Returns
216
+
217
+ `string`[]
218
+
219
+ An array of live keys ordered from least-frequently-used to most-frequently-used.
220
+
221
+ ***
222
+
223
+ ### delete() {#delete}
224
+
225
+ > **delete**(`key`): `void`
226
+
227
+ Remove an entry from the cache.
228
+ Cancels the background timer if the cache becomes empty.
229
+
230
+ #### Parameters
231
+
232
+ ##### key
233
+
234
+ `string`
235
+
236
+ The key to remove.
237
+
238
+ #### Returns
239
+
240
+ `void`
241
+
242
+ ***
243
+
244
+ ### clear() {#clear}
245
+
246
+ > **clear**(): `void`
247
+
248
+ Remove all entries from the cache and cancel the background timer.
249
+
250
+ #### Returns
251
+
252
+ `void`
253
+
254
+ ***
255
+
256
+ ### destroy() {#destroy}
257
+
258
+ > **destroy**(): `void`
259
+
260
+ Stop the background idle-sweep timer and release all entries.
261
+ The cache must not be used after this call.
262
+
263
+ #### Returns
264
+
265
+ `void`