@oxyhq/core 5.4.2 → 5.4.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.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/mixins/OxyServices.user.js +30 -8
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/mixins/OxyServices.user.js +30 -8
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/mixins/OxyServices.user.d.ts +32 -6
- package/package.json +1 -1
- package/src/mixins/OxyServices.user.ts +30 -8
- package/src/mixins/__tests__/userReadCacheBypass.test.ts +121 -0
|
@@ -16,12 +16,23 @@ export function OxyServicesUserMixin(Base) {
|
|
|
16
16
|
super(...args);
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Get profile by username
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
* Get profile by username.
|
|
20
|
+
*
|
|
21
|
+
* @param username - The profile's username.
|
|
22
|
+
* @param options.cache - Defaults to `true` (5-minute TTL), matching prior
|
|
23
|
+
* behavior. Pass `{ cache: false }` to force a registry-fresh read: the
|
|
24
|
+
* request bypasses BOTH the cache lookup and the post-fetch cache write
|
|
25
|
+
* (see {@link HttpService.request}'s `cache` handling), so it neither
|
|
26
|
+
* serves nor overwrites any entry already cached for this key — a
|
|
27
|
+
* previously cached response (if one exists) is left in place until its
|
|
28
|
+
* own TTL expires or is explicitly invalidated elsewhere. Use this when a
|
|
29
|
+
* caller must observe a just-written change (e.g. a privacy/consent flag)
|
|
30
|
+
* that would otherwise be masked by the TTL window.
|
|
31
|
+
*/
|
|
32
|
+
async getProfileByUsername(username, options) {
|
|
22
33
|
try {
|
|
23
34
|
const user = await this.makeRequest('GET', `/profiles/username/${username}`, undefined, {
|
|
24
|
-
cache: true,
|
|
35
|
+
cache: options?.cache ?? true,
|
|
25
36
|
cacheTTL: 5 * 60 * 1000, // 5 minutes cache for profiles
|
|
26
37
|
});
|
|
27
38
|
return normalizeUserIdentity(user);
|
|
@@ -204,12 +215,23 @@ export function OxyServicesUserMixin(Base) {
|
|
|
204
215
|
return users.map((user) => normalizeUserIdentity(user));
|
|
205
216
|
}
|
|
206
217
|
/**
|
|
207
|
-
* Get user by ID
|
|
208
|
-
|
|
209
|
-
|
|
218
|
+
* Get user by ID.
|
|
219
|
+
*
|
|
220
|
+
* @param userId - The target user's id.
|
|
221
|
+
* @param options.cache - Defaults to `true` (5-minute TTL), matching prior
|
|
222
|
+
* behavior. Pass `{ cache: false }` to force a registry-fresh read: the
|
|
223
|
+
* request bypasses BOTH the cache lookup and the post-fetch cache write
|
|
224
|
+
* (see {@link HttpService.request}'s `cache` handling), so it neither
|
|
225
|
+
* serves nor overwrites any entry already cached for this key — a
|
|
226
|
+
* previously cached response (if one exists) is left in place until its
|
|
227
|
+
* own TTL expires or is explicitly invalidated elsewhere. Use this when a
|
|
228
|
+
* caller must observe a just-written change (e.g. a privacy/consent flag)
|
|
229
|
+
* that would otherwise be masked by the TTL window.
|
|
230
|
+
*/
|
|
231
|
+
async getUserById(userId, options) {
|
|
210
232
|
try {
|
|
211
233
|
const user = await this.makeRequest('GET', `/users/${userId}`, undefined, {
|
|
212
|
-
cache: true,
|
|
234
|
+
cache: options?.cache ?? true,
|
|
213
235
|
cacheTTL: 5 * 60 * 1000, // 5 minutes cache
|
|
214
236
|
});
|
|
215
237
|
return normalizeUserIdentity(user);
|