@twin.org/core 0.9.1-next.1 → 0.9.1-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.
@@ -26,7 +26,7 @@ export declare class Is {
26
26
  * @param value The value to test.
27
27
  * @returns True if the value is not null or undefined.
28
28
  */
29
- static notEmpty(value: unknown): boolean;
29
+ static notEmpty<T>(value: T): value is NonNullable<T>;
30
30
  /**
31
31
  * Is the value a string.
32
32
  * @param value The value to test.
@@ -113,25 +113,25 @@ export declare class Is {
113
113
  * @param value The value to test.
114
114
  * @returns True if the value is an empty date.
115
115
  */
116
- static dateEmpty(value: unknown): boolean;
116
+ static dateEmpty(value: unknown): value is Date;
117
117
  /**
118
118
  * Is the value a date string.
119
119
  * @param value The value to test.
120
120
  * @returns True if the value is a string in ISO 8601 date format.
121
121
  */
122
- static dateString(value: unknown): boolean;
122
+ static dateString(value: unknown): value is string;
123
123
  /**
124
124
  * Is the value a date string.
125
125
  * @param value The value to test.
126
126
  * @returns True if the value is a string in ISO 8601 date/time format.
127
127
  */
128
- static dateTimeString(value: unknown): boolean;
128
+ static dateTimeString(value: unknown): value is string;
129
129
  /**
130
130
  * Is the value a time string.
131
131
  * @param value The value to test.
132
132
  * @returns True if the value is a string in ISO 8601 time format.
133
133
  */
134
- static timeString(value: unknown): boolean;
134
+ static timeString(value: unknown): value is string;
135
135
  /**
136
136
  * Is the value a timestamp in seconds.
137
137
  * @param value The value to test.
@@ -9,6 +9,16 @@ export declare class SharedStore {
9
9
  * @returns The property if it exists.
10
10
  */
11
11
  static get<T = unknown>(prop: string): T | undefined;
12
+ /**
13
+ * Get a property from the shared store, creating and storing it with the
14
+ * factory if absent. The factory is invoked synchronously so its return
15
+ * value - including a Promise - is stored before any async yield, making
16
+ * this safe against concurrent callers.
17
+ * @param prop The name of the property to get or create.
18
+ * @param factory A synchronous factory that produces the initial value.
19
+ * @returns The existing or newly created value.
20
+ */
21
+ static get<T = unknown>(prop: string, factory: () => T): T;
12
22
  /**
13
23
  * Set the property in the shared store.
14
24
  * @param prop The name of the property to set.
package/docs/changelog.md CHANGED
@@ -1,5 +1,228 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.1-next.10](https://github.com/iotaledger/twin-framework/compare/core-v0.9.1-next.9...core-v0.9.1-next.10) (2026-07-20)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * time coercion ([8ac43f8](https://github.com/iotaledger/twin-framework/commit/8ac43f85fbd521ff54786d92df3e432d7f738b0c))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/nameof bumped from 0.9.1-next.9 to 0.9.1-next.10
16
+ * devDependencies
17
+ * @twin.org/nameof-transformer bumped from 0.9.1-next.9 to 0.9.1-next.10
18
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.1-next.9 to 0.9.1-next.10
19
+
20
+ ## [0.9.1-next.9](https://github.com/iotaledger/twin-framework/compare/core-v0.9.1-next.8...core-v0.9.1-next.9) (2026-07-20)
21
+
22
+
23
+ ### Features
24
+
25
+ * improved coercion ([fcc7d98](https://github.com/iotaledger/twin-framework/commit/fcc7d9826f5405be5e3b5414ea53be42f974f9d5))
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * iso 8601 checks ([#409](https://github.com/iotaledger/twin-framework/issues/409)) ([4427101](https://github.com/iotaledger/twin-framework/commit/442710109b63ec67ca5ee7cb948df742500d0151))
31
+
32
+
33
+ ### Dependencies
34
+
35
+ * The following workspace dependencies were updated
36
+ * dependencies
37
+ * @twin.org/nameof bumped from 0.9.1-next.8 to 0.9.1-next.9
38
+ * devDependencies
39
+ * @twin.org/nameof-transformer bumped from 0.9.1-next.8 to 0.9.1-next.9
40
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.1-next.8 to 0.9.1-next.9
41
+
42
+ ## [0.9.1-next.8](https://github.com/iotaledger/twin-framework/compare/core-v0.9.1-next.7...core-v0.9.1-next.8) (2026-07-20)
43
+
44
+
45
+ ### Miscellaneous Chores
46
+
47
+ * **core:** Synchronize repo versions
48
+
49
+
50
+ ### Dependencies
51
+
52
+ * The following workspace dependencies were updated
53
+ * dependencies
54
+ * @twin.org/nameof bumped from 0.9.1-next.7 to 0.9.1-next.8
55
+ * devDependencies
56
+ * @twin.org/nameof-transformer bumped from 0.9.1-next.7 to 0.9.1-next.8
57
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.1-next.7 to 0.9.1-next.8
58
+
59
+ ## [0.9.1-next.7](https://github.com/iotaledger/twin-framework/compare/core-v0.9.1-next.6...core-v0.9.1-next.7) (2026-07-09)
60
+
61
+
62
+ ### Bug Fixes
63
+
64
+ * settle AsyncCache waiters correctly when a request resolves undefined or null ([#401](https://github.com/iotaledger/twin-framework/issues/401)) ([6ae3f8a](https://github.com/iotaledger/twin-framework/commit/6ae3f8aca688ca76d93ec3964178a3b1a8895453))
65
+
66
+
67
+ ### Dependencies
68
+
69
+ * The following workspace dependencies were updated
70
+ * dependencies
71
+ * @twin.org/nameof bumped from 0.9.1-next.6 to 0.9.1-next.7
72
+ * devDependencies
73
+ * @twin.org/nameof-transformer bumped from 0.9.1-next.6 to 0.9.1-next.7
74
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.1-next.6 to 0.9.1-next.7
75
+
76
+ ## [0.9.1-next.6](https://github.com/iotaledger/twin-framework/compare/core-v0.9.1-next.5...core-v0.9.1-next.6) (2026-07-03)
77
+
78
+
79
+ ### Features
80
+
81
+ * add wildcard support to the envhelper ([c064d46](https://github.com/iotaledger/twin-framework/commit/c064d46d36bbee8022a741b985d2b64c8f9572e4))
82
+
83
+
84
+ ### Dependencies
85
+
86
+ * The following workspace dependencies were updated
87
+ * dependencies
88
+ * @twin.org/nameof bumped from 0.9.1-next.5 to 0.9.1-next.6
89
+ * devDependencies
90
+ * @twin.org/nameof-transformer bumped from 0.9.1-next.5 to 0.9.1-next.6
91
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.1-next.5 to 0.9.1-next.6
92
+
93
+ ## [0.9.1-next.5](https://github.com/iotaledger/twin-framework/compare/core-v0.9.1-next.4...core-v0.9.1-next.5) (2026-06-29)
94
+
95
+
96
+ ### Features
97
+
98
+ * urn and header helper extensions ([#395](https://github.com/iotaledger/twin-framework/issues/395)) ([5976756](https://github.com/iotaledger/twin-framework/commit/5976756886d22e5063671052abc4dfa04ce23a53))
99
+
100
+
101
+ ### Dependencies
102
+
103
+ * The following workspace dependencies were updated
104
+ * dependencies
105
+ * @twin.org/nameof bumped from 0.9.1-next.4 to 0.9.1-next.5
106
+ * devDependencies
107
+ * @twin.org/nameof-transformer bumped from 0.9.1-next.4 to 0.9.1-next.5
108
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.1-next.4 to 0.9.1-next.5
109
+
110
+ ## [0.9.1-next.4](https://github.com/iotaledger/twin-framework/compare/core-v0.9.1-next.3...core-v0.9.1-next.4) (2026-06-26)
111
+
112
+
113
+ ### Miscellaneous Chores
114
+
115
+ * **core:** Synchronize repo versions
116
+
117
+
118
+ ### Dependencies
119
+
120
+ * The following workspace dependencies were updated
121
+ * dependencies
122
+ * @twin.org/nameof bumped from 0.9.1-next.3 to 0.9.1-next.4
123
+ * devDependencies
124
+ * @twin.org/nameof-transformer bumped from 0.9.1-next.3 to 0.9.1-next.4
125
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.1-next.3 to 0.9.1-next.4
126
+
127
+ ## [0.9.1-next.3](https://github.com/iotaledger/twin-framework/compare/core-v0.9.1-next.2...core-v0.9.1-next.3) (2026-06-26)
128
+
129
+
130
+ ### Features
131
+
132
+ * add context id features ([#206](https://github.com/iotaledger/twin-framework/issues/206)) ([ef0d4ee](https://github.com/iotaledger/twin-framework/commit/ef0d4ee11a4f5fc6cc6f52a4958ce905c04ee13b))
133
+ * add duration support ([#362](https://github.com/iotaledger/twin-framework/issues/362)) ([24dbe8b](https://github.com/iotaledger/twin-framework/commit/24dbe8b208eb127a52024cb219d31d27731e9ae3))
134
+ * add factory.createIfExists ([aad5a53](https://github.com/iotaledger/twin-framework/commit/aad5a53cef1b1c2e04344ea46244d41e371dff9b))
135
+ * add Factory.getFactory ([ad6cd2d](https://github.com/iotaledger/twin-framework/commit/ad6cd2d30351c145c70212f8cce1b66d5e8a5235))
136
+ * add guard.dateString ([#335](https://github.com/iotaledger/twin-framework/issues/335)) ([a26a166](https://github.com/iotaledger/twin-framework/commit/a26a166eb1f62ece05b2432730cb7354feacecfc))
137
+ * add health method to components ([a88016d](https://github.com/iotaledger/twin-framework/commit/a88016d90d172413e5bc5238dc1b3e35f82fcc2c))
138
+ * add Is.class method ([4988205](https://github.com/iotaledger/twin-framework/commit/498820543e256a130b4888c958fe1d87ca865d7f))
139
+ * add isDefault option to factory registration ([a8a700b](https://github.com/iotaledger/twin-framework/commit/a8a700bb8ddaf7dd5097869a358b8fc5f7c40ce7))
140
+ * add mutex ([#316](https://github.com/iotaledger/twin-framework/issues/316)) ([1027e5a](https://github.com/iotaledger/twin-framework/commit/1027e5ac77aa9804178b4253abdeefd6f1c3d521))
141
+ * add objectHelper.split ([386830a](https://github.com/iotaledger/twin-framework/commit/386830a77f8e842a5b119be0983708e042c3b14b))
142
+ * add partial second support ([39bf087](https://github.com/iotaledger/twin-framework/commit/39bf087ddc113a9bf73e0d0e99f738f6f60c2f2d))
143
+ * add rsa cipher support ([7af6cc6](https://github.com/iotaledger/twin-framework/commit/7af6cc67512d3363bd4a2f2e87bd7733c2800147))
144
+ * add single occurrence array type ([e890e43](https://github.com/iotaledger/twin-framework/commit/e890e4399e75ae5097f3ad8b1007321cbb1ed4ac))
145
+ * add single occurrence array type ([#245](https://github.com/iotaledger/twin-framework/issues/245)) ([771dc78](https://github.com/iotaledger/twin-framework/commit/771dc78025b5546c9c9681be9494a76ab71171c6))
146
+ * add support for health i18n validation ([7a286dd](https://github.com/iotaledger/twin-framework/commit/7a286ddb0c1bfa498bf3a77126cd589042bad6de))
147
+ * add teardown to IComponent interface ([32c173c](https://github.com/iotaledger/twin-framework/commit/32c173cda115c20d3b4cee14b8a29cdc08e91555))
148
+ * add teardown to IComponent interface ([98ce864](https://github.com/iotaledger/twin-framework/commit/98ce8648e709310c4435de334825b381fb4e32cb))
149
+ * add typeName method to factory ([699fcbd](https://github.com/iotaledger/twin-framework/commit/699fcbd1168228401ddb81fdacb959b8cdc4206a))
150
+ * add uuidv7 support ([#219](https://github.com/iotaledger/twin-framework/issues/219)) ([916c657](https://github.com/iotaledger/twin-framework/commit/916c657d270ce99fafe554233739fdd9ca28635b))
151
+ * adding link header helper ([#225](https://github.com/iotaledger/twin-framework/issues/225)) ([703c072](https://github.com/iotaledger/twin-framework/commit/703c0725aceac6b6ec0c4fa729ef832d12fb3fd7))
152
+ * additional nameof operators ([a5aab60](https://github.com/iotaledger/twin-framework/commit/a5aab60bf66a86f1b7ff8af7c4f044cb03706d50))
153
+ * additional RSA methods and async ([1fceee2](https://github.com/iotaledger/twin-framework/commit/1fceee2d1248a24a7620846025fcf906495c07f4))
154
+ * bump version ([c5354fa](https://github.com/iotaledger/twin-framework/commit/c5354fa906f4493c70f2642a9175a66780a10636))
155
+ * concurrency in SharedStore ([#388](https://github.com/iotaledger/twin-framework/issues/388)) ([0610198](https://github.com/iotaledger/twin-framework/commit/0610198ba482273c3f6ba918e34f5875a3659571))
156
+ * configurable timeout for mutex ([2087e04](https://github.com/iotaledger/twin-framework/commit/2087e04464a110a3f009fbc8b066696ed6784fc2))
157
+ * env helper conversion methods ([e8c607e](https://github.com/iotaledger/twin-framework/commit/e8c607e59f6f79d4b1d562e9313babe348778835))
158
+ * eslint migration to flat config ([74427d7](https://github.com/iotaledger/twin-framework/commit/74427d78d342167f7850e49ab87269326355befe))
159
+ * expand error params to accept properties ([032e9fd](https://github.com/iotaledger/twin-framework/commit/032e9fd1388e457cde32ca1005dfe014a5a9c077))
160
+ * factory create and integrity ([#235](https://github.com/iotaledger/twin-framework/issues/235)) ([9f98b99](https://github.com/iotaledger/twin-framework/commit/9f98b99daf46eb365346fae49cc4ffba63e74cb3))
161
+ * health status grouping ([5007c29](https://github.com/iotaledger/twin-framework/commit/5007c29fe4123fe56f754450b993dbe5dc32a057))
162
+ * improve async cache edge cases ([4e57a6e](https://github.com/iotaledger/twin-framework/commit/4e57a6ec4113533b0ea903eae7d469200fa1348c))
163
+ * improve error formatting ([#313](https://github.com/iotaledger/twin-framework/issues/313)) ([5a19623](https://github.com/iotaledger/twin-framework/commit/5a196231bcbf088bf9ba92a93b7478d3b8c5593f))
164
+ * improve Is.function and ModuleHelper.getModuleMethod signatures ([ecf968b](https://github.com/iotaledger/twin-framework/commit/ecf968b02934b3676be4bf7cd2d1e7f8e7af6ce2))
165
+ * improve Is.function definition to retain types ([f20b6b0](https://github.com/iotaledger/twin-framework/commit/f20b6b0dd16e74b75dc359be72b05989305c6410))
166
+ * improve signatures ([45a7d58](https://github.com/iotaledger/twin-framework/commit/45a7d58baa5b6abc8c0735656f393d402fabb4ad))
167
+ * improve signatures ([cdd24be](https://github.com/iotaledger/twin-framework/commit/cdd24be6fb898d33955b6f2f93c3ddbd73582269))
168
+ * improve signatures ([2041ae2](https://github.com/iotaledger/twin-framework/commit/2041ae214cbd8d472d5e8be8d3403cd06a114040))
169
+ * improve signatures ([d8a0ee1](https://github.com/iotaledger/twin-framework/commit/d8a0ee16542134a3f8b0653065239f42045125b4))
170
+ * improve signatures ([1d084c5](https://github.com/iotaledger/twin-framework/commit/1d084c58c7eb41ae50b0ce80ce57e48a22dd3102))
171
+ * improve signatures ([#287](https://github.com/iotaledger/twin-framework/issues/287)) ([c9f38f0](https://github.com/iotaledger/twin-framework/commit/c9f38f00e1cea8759e1105b41872a650c66c00f4))
172
+ * is and coerce accept duration object ([51dffa1](https://github.com/iotaledger/twin-framework/commit/51dffa18066eb86a14c700d90d3c1bd8b322c0fc))
173
+ * locales validation ([#197](https://github.com/iotaledger/twin-framework/issues/197)) ([55fdadb](https://github.com/iotaledger/twin-framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
174
+ * mutex safe usage in browser ([#339](https://github.com/iotaledger/twin-framework/issues/339)) ([02d409f](https://github.com/iotaledger/twin-framework/commit/02d409f211e91267964208d58a27f29791715086))
175
+ * nodeIdentity optional in IComponent methods ([c78dc17](https://github.com/iotaledger/twin-framework/commit/c78dc17f4357d3e1ae40e415f468d3eae13e81f4))
176
+ * shared object buffer ([#355](https://github.com/iotaledger/twin-framework/issues/355)) ([70d82ea](https://github.com/iotaledger/twin-framework/commit/70d82ea8f43f01aa840ae90ee0b1f23b064a07c6))
177
+ * simplify factory options ([7f85a85](https://github.com/iotaledger/twin-framework/commit/7f85a8553dd3008364e8e1104f2e6f6b6595d77e))
178
+ * simplify StringHelper signature ([0390403](https://github.com/iotaledger/twin-framework/commit/039040344952f91ee3c671249bc0e1c8f3b38e17))
179
+ * typescript 6 update ([1d10f31](https://github.com/iotaledger/twin-framework/commit/1d10f31e6516ec622773f45e88af82fe749b384a))
180
+ * update dependencies ([4da77ab](https://github.com/iotaledger/twin-framework/commit/4da77ab30f499e52825ac5a76f51436ceb59c26e))
181
+ * update dependencies ([f3bd015](https://github.com/iotaledger/twin-framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
182
+ * urn random switched to using uuidv7 ([606c9a2](https://github.com/iotaledger/twin-framework/commit/606c9a2ed68a10fc7fc2bc5f93388c1b71033154))
183
+ * urn random switched to using uuidv7 ([6a29f8b](https://github.com/iotaledger/twin-framework/commit/6a29f8bd573d06992b7eaa027b1daf4c2a2e1e85))
184
+ * use cause instead of inner for errors ([1f4acc4](https://github.com/iotaledger/twin-framework/commit/1f4acc4d7a6b71a134d9547da9bf40de1e1e49da))
185
+
186
+
187
+ ### Bug Fixes
188
+
189
+ * async thread lock ([97a96a5](https://github.com/iotaledger/twin-framework/commit/97a96a57f60c7b45a0ccbbfa1c43199b6e7512f9))
190
+ * ensure __decorate is defined for decorators ([103a563](https://github.com/iotaledger/twin-framework/commit/103a563ce01ebdef6240d2e590e7b026e8692684))
191
+ * improve exception handling in asyncCache ([c81b29b](https://github.com/iotaledger/twin-framework/commit/c81b29b660b152d2f0757d323430287e6491bf59))
192
+ * improve jsdoc comments ([f7c8e43](https://github.com/iotaledger/twin-framework/commit/f7c8e43fab9803dffa6461950d5b9979e25bcd24))
193
+ * linting ([b77511d](https://github.com/iotaledger/twin-framework/commit/b77511de8781707088b1beb4c92f12d7d6e0fd5f))
194
+ * mutex locking ([d5af3c1](https://github.com/iotaledger/twin-framework/commit/d5af3c1e66070f86408ba1410809689c6d22958b))
195
+ * pick non iterable keys ([399399a](https://github.com/iotaledger/twin-framework/commit/399399abfb8947c4eb235df527532ffe186986b3))
196
+ * prevent TOCTOU race in Mutex.getOrFetchLock for concurrent async callers ([#343](https://github.com/iotaledger/twin-framework/issues/343)) ([5238ad1](https://github.com/iotaledger/twin-framework/commit/5238ad1a68e24c69162204b02030c6686c15e9f4))
197
+ * remove misleading undefined from AsyncCache return type ([05b3291](https://github.com/iotaledger/twin-framework/commit/05b32914e03a63c7daf7b77952a2ebedb7ca7f6b))
198
+
199
+
200
+ ### Dependencies
201
+
202
+ * The following workspace dependencies were updated
203
+ * dependencies
204
+ * @twin.org/nameof bumped from 0.9.1-next.2 to 0.9.1-next.3
205
+ * devDependencies
206
+ * @twin.org/nameof-transformer bumped from 0.9.1-next.2 to 0.9.1-next.3
207
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.1-next.2 to 0.9.1-next.3
208
+
209
+ ## [0.9.1-next.2](https://github.com/iotaledger/twin-framework/compare/core-v0.9.1-next.1...core-v0.9.1-next.2) (2026-06-26)
210
+
211
+
212
+ ### Features
213
+
214
+ * concurrency in SharedStore ([#388](https://github.com/iotaledger/twin-framework/issues/388)) ([0610198](https://github.com/iotaledger/twin-framework/commit/0610198ba482273c3f6ba918e34f5875a3659571))
215
+
216
+
217
+ ### Dependencies
218
+
219
+ * The following workspace dependencies were updated
220
+ * dependencies
221
+ * @twin.org/nameof bumped from 0.9.1-next.1 to 0.9.1-next.2
222
+ * devDependencies
223
+ * @twin.org/nameof-transformer bumped from 0.9.1-next.1 to 0.9.1-next.2
224
+ * @twin.org/nameof-vitest-plugin bumped from 0.9.1-next.1 to 0.9.1-next.2
225
+
3
226
  ## [0.9.1-next.1](https://github.com/iotaledger/twin-framework/compare/core-v0.9.1-next.0...core-v0.9.1-next.1) (2026-06-25)
4
227
 
5
228
 
@@ -18,7 +18,9 @@ Cache the results from asynchronous requests.
18
18
 
19
19
  > `static` **exec**\<`T`\>(`key`, `ttlMs`, `requestMethod`, `cacheFailures?`): `Promise`\<`T`\>
20
20
 
21
- Execute an async request and cache the result.
21
+ Execute an async request and cache the result. A result that resolves to
22
+ undefined or null is treated as a cache miss for later callers, who re-run
23
+ requestMethod themselves instead of waiting on the empty value.
22
24
 
23
25
  #### Type Parameters
24
26
 
@@ -51,6 +51,7 @@ The object with camel cased names.
51
51
  > `static` **envVarKeyToJsonKey**(`envVarKey`, `prefix?`): `string`
52
52
 
53
53
  Convert an environment variable key to a JSON key.
54
+ A trailing _* or * is preserved as a wildcard suffix (e.g. TWIN_REST_PATH_* → "restPath*").
54
55
 
55
56
  #### Parameters
56
57
 
@@ -82,21 +82,27 @@ True if the value is null or undefined.
82
82
 
83
83
  ### notEmpty() {#notempty}
84
84
 
85
- > `static` **notEmpty**(`value`): `boolean`
85
+ > `static` **notEmpty**\<`T`\>(`value`): `value is NonNullable<T>`
86
86
 
87
87
  Is the property not null or undefined.
88
88
 
89
+ #### Type Parameters
90
+
91
+ ##### T
92
+
93
+ `T`
94
+
89
95
  #### Parameters
90
96
 
91
97
  ##### value
92
98
 
93
- `unknown`
99
+ `T`
94
100
 
95
101
  The value to test.
96
102
 
97
103
  #### Returns
98
104
 
99
- `boolean`
105
+ `value is NonNullable<T>`
100
106
 
101
107
  True if the value is not null or undefined.
102
108
 
@@ -408,7 +414,7 @@ True if the value is a date.
408
414
 
409
415
  ### dateEmpty() {#dateempty}
410
416
 
411
- > `static` **dateEmpty**(`value`): `boolean`
417
+ > `static` **dateEmpty**(`value`): `value is Date`
412
418
 
413
419
  Is the value an empty date.
414
420
 
@@ -422,7 +428,7 @@ The value to test.
422
428
 
423
429
  #### Returns
424
430
 
425
- `boolean`
431
+ `value is Date`
426
432
 
427
433
  True if the value is an empty date.
428
434
 
@@ -430,7 +436,7 @@ True if the value is an empty date.
430
436
 
431
437
  ### dateString() {#datestring}
432
438
 
433
- > `static` **dateString**(`value`): `boolean`
439
+ > `static` **dateString**(`value`): `value is string`
434
440
 
435
441
  Is the value a date string.
436
442
 
@@ -444,7 +450,7 @@ The value to test.
444
450
 
445
451
  #### Returns
446
452
 
447
- `boolean`
453
+ `value is string`
448
454
 
449
455
  True if the value is a string in ISO 8601 date format.
450
456
 
@@ -452,7 +458,7 @@ True if the value is a string in ISO 8601 date format.
452
458
 
453
459
  ### dateTimeString() {#datetimestring}
454
460
 
455
- > `static` **dateTimeString**(`value`): `boolean`
461
+ > `static` **dateTimeString**(`value`): `value is string`
456
462
 
457
463
  Is the value a date string.
458
464
 
@@ -466,7 +472,7 @@ The value to test.
466
472
 
467
473
  #### Returns
468
474
 
469
- `boolean`
475
+ `value is string`
470
476
 
471
477
  True if the value is a string in ISO 8601 date/time format.
472
478
 
@@ -474,7 +480,7 @@ True if the value is a string in ISO 8601 date/time format.
474
480
 
475
481
  ### timeString() {#timestring}
476
482
 
477
- > `static` **timeString**(`value`): `boolean`
483
+ > `static` **timeString**(`value`): `value is string`
478
484
 
479
485
  Is the value a time string.
480
486
 
@@ -488,7 +494,7 @@ The value to test.
488
494
 
489
495
  #### Returns
490
496
 
491
- `boolean`
497
+ `value is string`
492
498
 
493
499
  True if the value is a string in ISO 8601 time format.
494
500
 
@@ -17,30 +17,84 @@ instance loads of a package.
17
17
 
18
18
  ### get() {#get}
19
19
 
20
+ Get a property from the shared store, creating and storing it with the
21
+ factory if absent. The factory is invoked synchronously so its return
22
+ value - including a Promise - is stored before any async yield, making
23
+ this safe against concurrent callers.
24
+
25
+ #### Param
26
+
27
+ **prop**
28
+
29
+ The name of the property to get or create.
30
+
31
+ #### Param
32
+
33
+ **factory**
34
+
35
+ A synchronous factory that produces the initial value.
36
+
37
+ #### Call Signature
38
+
20
39
  > `static` **get**\<`T`\>(`prop`): `T` \| `undefined`
21
40
 
22
41
  Get a property from the shared store.
23
42
 
24
- #### Type Parameters
43
+ ##### Type Parameters
25
44
 
26
- ##### T
45
+ ###### T
27
46
 
28
47
  `T` = `unknown`
29
48
 
30
- #### Parameters
49
+ ##### Parameters
31
50
 
32
- ##### prop
51
+ ###### prop
33
52
 
34
53
  `string`
35
54
 
36
55
  The name of the property to get.
37
56
 
38
- #### Returns
57
+ ##### Returns
39
58
 
40
59
  `T` \| `undefined`
41
60
 
42
61
  The property if it exists.
43
62
 
63
+ #### Call Signature
64
+
65
+ > `static` **get**\<`T`\>(`prop`, `factory`): `T`
66
+
67
+ Get a property from the shared store, creating and storing it with the
68
+ factory if absent. The factory is invoked synchronously so its return
69
+ value - including a Promise - is stored before any async yield, making
70
+ this safe against concurrent callers.
71
+
72
+ ##### Type Parameters
73
+
74
+ ###### T
75
+
76
+ `T` = `unknown`
77
+
78
+ ##### Parameters
79
+
80
+ ###### prop
81
+
82
+ `string`
83
+
84
+ The name of the property to get or create.
85
+
86
+ ###### factory
87
+
88
+ () => `T`
89
+
90
+ A synchronous factory that produces the initial value.
91
+
92
+ ##### Returns
93
+
94
+ `T`
95
+
96
+ The existing or newly created value.
97
+
44
98
  ***
45
99
 
46
100
  ### set() {#set}
@@ -156,7 +156,7 @@ The urn with a prefix.
156
156
 
157
157
  ### guard() {#guard}
158
158
 
159
- > `static` **guard**(`source`, `property`, `value`): `asserts value is string`
159
+ > `static` **guard**(`source`, `property`, `value`, `options?`): `asserts value is string`
160
160
 
161
161
  Parse a string into the urn parts.
162
162
 
@@ -180,6 +180,22 @@ The name of the property.
180
180
 
181
181
  The urn to parse.
182
182
 
183
+ ##### options?
184
+
185
+ Optional constraints to validate the urn namespace identifier and specific parts.
186
+
187
+ ###### namespaceIdentifier?
188
+
189
+ `string`
190
+
191
+ The namespace identifier the urn must match.
192
+
193
+ ###### namespaceSpecific?
194
+
195
+ `string` \| `string`[]
196
+
197
+ The namespace specific part(s) the urn must match.
198
+
183
199
  #### Returns
184
200
 
185
201
  `asserts value is string`
@@ -282,7 +298,7 @@ The namespace method.
282
298
 
283
299
  ### namespaceSpecificParts() {#namespacespecificparts}
284
300
 
285
- > **namespaceSpecificParts**(`startIndex?`): `string`[]
301
+ > **namespaceSpecificParts**(`startIndex?`, `count?`): `string`[]
286
302
 
287
303
  Get the namespace specific parts.
288
304
 
@@ -294,6 +310,12 @@ Get the namespace specific parts.
294
310
 
295
311
  The index to start from, defaults to 0.
296
312
 
313
+ ##### count?
314
+
315
+ `number`
316
+
317
+ The number of parts to return, defaults to all remaining parts.
318
+
297
319
  #### Returns
298
320
 
299
321
  `string`[]
package/locales/en.json CHANGED
@@ -71,6 +71,8 @@
71
71
  "uint8Array": "Property \"{property}\" must be a Uint8Array, it is \"{value}\"",
72
72
  "function": "Property \"{property}\" must be a function, it is \"{value}\"",
73
73
  "urn": "Property \"{property}\" must be a URN formatted string, it is \"{value}\"",
74
+ "urnNamespaceIdentifier": "Property \"{property}\" must be a URN with namespace identifier \"{options}\", it is \"{value}\"",
75
+ "urnNamespaceSpecific": "Property \"{property}\" must be a URN with namespace specific \"{options}\", it is \"{value}\"",
74
76
  "url": "Property \"{property}\" must be a URL formatted string, it is \"{value}\"",
75
77
  "email": "Property \"{property}\" must be string in e-mail format, it is \"{value}\"",
76
78
  "uuidV7": "Property \"{property}\" must be a UUIDv7 formatted string, it is \"{value}\"",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/core",
3
- "version": "0.9.1-next.1",
3
+ "version": "0.9.1-next.10",
4
4
  "description": "Helper methods/classes for data type checking/validation/guarding/error handling",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/nameof": "0.9.1-next.1",
17
+ "@twin.org/nameof": "0.9.1-next.10",
18
18
  "intl-messageformat": "11.2.8",
19
19
  "rfc6902": "5.2.0"
20
20
  },