@oxyhq/core 3.8.2 → 3.9.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.
- package/README.md +10 -0
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/OxyServices.base.js +15 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/OxyServices.base.js +15 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/OxyServices.base.d.ts +12 -0
- package/package.json +3 -2
- package/src/OxyServices.base.ts +15 -1
- package/src/__tests__/linkedClient.test.ts +61 -0
- package/dist/cjs/mixins/OxyServices.popup.js +0 -263
- package/dist/esm/mixins/OxyServices.popup.js +0 -261
- package/dist/types/mixins/OxyServices.popup.d.ts +0 -170
|
@@ -96,9 +96,23 @@ class OxyServicesBase {
|
|
|
96
96
|
* OxyServices instance mounted in OxyProvider. The returned client has its own
|
|
97
97
|
* base URL, cache and request queue, but its bearer token is kept in lockstep
|
|
98
98
|
* with this session and its 401 refresh path delegates back to this session.
|
|
99
|
+
*
|
|
100
|
+
* **GET response caching is OFF by default for linked clients.** The SDK's
|
|
101
|
+
* per-instance GET cache is only safe where the SDK OWNS invalidation: on the
|
|
102
|
+
* canonical OxyServices client, every mutation (`updateProfile`, `followUser`,
|
|
103
|
+
* `blockUser`, …) busts the matching cached GET. A linked client targets the
|
|
104
|
+
* consuming app's OWN backend (`api.mention.earth`, `api.syra.fm`, …), whose
|
|
105
|
+
* resources and write endpoints the SDK has no knowledge of — so it cannot
|
|
106
|
+
* invalidate them, and a cached GET there would silently serve stale data
|
|
107
|
+
* after the app mutates its own data. Caching is therefore unsafe-by-construction
|
|
108
|
+
* here and is left to the consumer's own layer (React Query / stores), which
|
|
109
|
+
* owns its invalidation. Pass `createLinkedClient({ baseURL, enableCache: true })`
|
|
110
|
+
* to explicitly opt back in when the consumer accepts that responsibility.
|
|
99
111
|
*/
|
|
100
112
|
createLinkedClient(config) {
|
|
101
|
-
|
|
113
|
+
// Default the GET cache OFF unless the caller explicitly opts in (see the
|
|
114
|
+
// method doc): the SDK cannot invalidate the consumer backend's resources.
|
|
115
|
+
const client = new HttpService_1.HttpService({ ...config, enableCache: config.enableCache ?? false });
|
|
102
116
|
const syncToken = (accessToken) => {
|
|
103
117
|
const currentAccessToken = client.getAccessToken();
|
|
104
118
|
if (accessToken) {
|