@uniweb/api 0.2.10 → 0.2.12

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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/client.js +17 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/api",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "The client for a Uniweb site's own backend — session, records, entities — imported by a foundation the way it imports @uniweb/kit.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -34,7 +34,7 @@
34
34
  "node": ">=20.19"
35
35
  },
36
36
  "dependencies": {
37
- "@uniweb/core": "^0.24.0"
37
+ "@uniweb/core": "^0.24.2"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": "^19.0.0"
package/src/client.js CHANGED
@@ -12,7 +12,7 @@
12
12
  */
13
13
 
14
14
  import { getUniweb, deriveCacheKey } from '@uniweb/core'
15
- import { resolveService } from '@uniweb/core/services'
15
+ import { resolveService } from '@uniweb/core'
16
16
  import { ApiError } from './errors.js'
17
17
  import { composeUrl, isCrossOrigin, readBody, UNSAFE } from './http.js'
18
18
  import { AUTH, ROUTES, PARAM, FIELD, LIST, OP } from './wire.js'
@@ -363,7 +363,22 @@ export class ApiClient {
363
363
  * @returns {string}
364
364
  */
365
365
  cacheKey(spec) {
366
- return deriveCacheKey({ ...spec, endpoint: `api:${this.viewerId}:${spec.endpoint ?? ''}` })
366
+ // ⛔ core's `deriveCacheKey` hashes a FIXED field set, and that set has
367
+ // drifted twice under this call: `schema` was renamed to `as` (2026-09-02),
368
+ // and `endpoint` was dropped by core 0.24 — so spreading the spec meant the
369
+ // qualifiers (`schema`, `scope`, `limit`, `offset`, `all`, `via`) fell out
370
+ // of the hash and every list a viewer read collided on `/entities`; under a
371
+ // 0.24 core EVERY key of this package degenerated to '{}'.
372
+ // ⇒ Compose the WHOLE identity into `url` — hashed by every core version —
373
+ // so this package's keys cannot drift with core's field selection again.
374
+ // Keys change once; the store is in-memory and repopulates.
375
+ const { endpoint = '', ...qualifiers } = spec ?? {}
376
+ const suffix = Object.keys(qualifiers)
377
+ .filter((k) => qualifiers[k] !== undefined)
378
+ .sort()
379
+ .map((k) => `${k}=${qualifiers[k]}`)
380
+ .join('&')
381
+ return deriveCacheKey({ url: `api:${this.viewerId}:${endpoint}${suffix ? `?${suffix}` : ''}` })
367
382
  }
368
383
 
369
384
  /**