@stonyx/orm 0.3.2-alpha.81 → 0.3.2-alpha.82

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/README.md +26 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1325,6 +1325,32 @@ or an `errors` member for the withheld case makes the route an **existence
1325
1325
  oracle** — see [Filter functions](#filter-functions) for the rule and for the
1326
1326
  measurement that closed it on this route.
1327
1327
 
1328
+ **A per-record deny for a *related* resource cannot be expressed, and nothing
1329
+ tells you so at the point you would write it.** `createLinkageFilter` resolves
1330
+ the related model's access class by **type**: `context.recordId` is `null`, and
1331
+ `request.params` names a record of a **different model** — the one the route is
1332
+ addressed to. So `access()` is handed the model, the operation and the request,
1333
+ and **a rule that has to know *which* related record it is being asked about
1334
+ cannot be written**. Model-level denies (`return false` for a model) work.
1335
+ Request-level denies (a header, a tenant, the method) work. The per-record
1336
+ **filter** shape works too — `access()` may return a function, and that function
1337
+ receives the whole record, id included. What does not work is branching on the
1338
+ record's identity *before* returning, because `access()` is not told it.
1339
+
1340
+ This is a fixed property of the mechanism rather than a defect awaiting a fix.
1341
+ The verdict is resolved **once per type** and cached before any record has been
1342
+ examined, so seeding `recordId` from a record would let the first member of a
1343
+ `hasMany` decide the context for all of them. The rule the framework holds to is
1344
+ **`recordId` may name a record only where the route addresses exactly one record
1345
+ of the model being asked about** — true for `GET /owners/{id}`, false for
1346
+ linkage, and false for a `hasMany` related-resource route. The consumer-facing
1347
+ consequence is the part to check: a predicate that branches on `recordId` sees
1348
+ `null` here and takes whichever branch `null` takes, with no warning, and if
1349
+ that branch grants then it **grants**. Express the rule as a returned filter
1350
+ function instead. Stated again, with the same label, under
1351
+ [Known limitations](#known-limitations)
1352
+ ([#232](https://github.com/abofs/stonyx-orm/issues/232)).
1353
+
1328
1354
  Do this:
1329
1355
 
1330
1356
  ```js
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "stonyx-async",
5
5
  "stonyx-module"
6
6
  ],
7
- "version": "0.3.2-alpha.81",
7
+ "version": "0.3.2-alpha.82",
8
8
  "description": "",
9
9
  "main": "dist/index.js",
10
10
  "type": "module",