@stonyx/orm 0.3.2-alpha.82 → 0.3.2-alpha.83
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 +73 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1468,10 +1468,31 @@ they are recorded here.
|
|
|
1468
1468
|
return 404. Only affects function-style `access` users, for whom the old
|
|
1469
1469
|
behaviour was the bypass.
|
|
1470
1470
|
|
|
1471
|
-
"Seven surfaces" means the seven endpoints of **the filtered model
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
is
|
|
1471
|
+
"Seven surfaces" means the seven endpoints of **the filtered model** —
|
|
1472
|
+
`GET /:models`, `GET /:models/:id`, `GET /:models/:id/{relationship}`,
|
|
1473
|
+
`GET /:models/:id/relationships/{relationship}`, `POST /:models`,
|
|
1474
|
+
`PATCH /:models/:id` and `DELETE /:models/:id`. That count is still seven and
|
|
1475
|
+
is still the model's own endpoints, but **it is no longer the whole
|
|
1476
|
+
population**: the boundary moved outward rather than the number changing, and
|
|
1477
|
+
this sentence used to be read as saying a filtered model's predicate is
|
|
1478
|
+
consulted nowhere else. It now is, in two further places, both from
|
|
1479
|
+
*another* model's routes —
|
|
1480
|
+
|
|
1481
|
+
- on **both relationship route families**, where the related record is the
|
|
1482
|
+
primary data and the filtered model's own class decides whether it is
|
|
1483
|
+
served at all (breaking change 9 below,
|
|
1484
|
+
[#232](https://github.com/abofs/stonyx-orm/issues/232)); and
|
|
1485
|
+
- on the `relationships.*.data` **linkage** of every request-bound surface
|
|
1486
|
+
that serializes a record through `toJSON()`
|
|
1487
|
+
([#234](https://github.com/abofs/stonyx-orm/issues/234),
|
|
1488
|
+
[#235](https://github.com/abofs/stonyx-orm/issues/235)), which decides
|
|
1489
|
+
which ids another model's document may name.
|
|
1490
|
+
|
|
1491
|
+
A **write** to another collection can still reach one of its records through
|
|
1492
|
+
a relationship — [#207](https://github.com/abofs/stonyx-orm/issues/207),
|
|
1493
|
+
which is **not** closed here. That is the half of the old sentence that
|
|
1494
|
+
survives, and it is a read/write asymmetry now rather than a blanket
|
|
1495
|
+
statement about cross-model reach.
|
|
1475
1496
|
5. **A predicate that throws is treated as a denial** rather than propagating to
|
|
1476
1497
|
Express's default 500 handler. So is an `access()` that throws.
|
|
1477
1498
|
6. **`access()` returning a bare string is one permission, not full access.**
|
|
@@ -1546,6 +1567,54 @@ they are recorded here.
|
|
|
1546
1567
|
`stonyx/log`. Previously this case threw out of the handler and express
|
|
1547
1568
|
answered `500` with a stack trace.
|
|
1548
1569
|
|
|
1570
|
+
9. **Both relationship route families now resolve the *related* model's own
|
|
1571
|
+
access class, so a related record that is hidden on its own routes is no
|
|
1572
|
+
longer served through another model's.**
|
|
1573
|
+
[#232](https://github.com/abofs/stonyx-orm/issues/232). Affects
|
|
1574
|
+
function-style `access` users with relationships between filtered models. The
|
|
1575
|
+
old behaviour was a bypass at **zero query parameters** and with no
|
|
1576
|
+
`include=`: measured on `dev @ 8dda5d6`, `GET /animals/1/owner` returned
|
|
1577
|
+
angela's full document and `GET /animals/1/relationships/owner` returned
|
|
1578
|
+
`{"type":"owner","id":"angela"}`, while `GET /owners/angela` answered `404`.
|
|
1579
|
+
The severe case is a model claimed by **no** access class — `getAccess()`
|
|
1580
|
+
returns `undefined`, no route is mounted for it at all, and it was still
|
|
1581
|
+
readable as a related resource.
|
|
1582
|
+
|
|
1583
|
+
**The shapes, on both families.** A denied `hasMany` member is **dropped from
|
|
1584
|
+
the array**: `200`, `links` intact, no `errors` member. A denied `belongsTo`
|
|
1585
|
+
target answers **`200` with `data: null`**, byte-identical to a target that
|
|
1586
|
+
genuinely does not exist — same status, same bytes modulo the parent id the
|
|
1587
|
+
caller put in the URL. `404` on these routes is now reserved for the
|
|
1588
|
+
**parent**.
|
|
1589
|
+
|
|
1590
|
+
**`data: null` and not `404`, deliberately.** The 404 spelling was an
|
|
1591
|
+
existence oracle and was measured as one on this branch: unauthenticated, no
|
|
1592
|
+
query string, one request each, against `tag` — the model with no route
|
|
1593
|
+
mounted at all — `GET /traits/1/tag` (absent) answered `200`
|
|
1594
|
+
`application/json` at 68 bytes while `GET /traits/2/tag` (denied) answered
|
|
1595
|
+
`404` `text/plain` at 9 bytes, and the document surface reported both as
|
|
1596
|
+
`{"data":null}`. It also brings these two routes into line with this module's
|
|
1597
|
+
rule that every status on a record route is identical for filtered-out and
|
|
1598
|
+
does-not-exist (see [Filter functions](#filter-functions)), which the `404`
|
|
1599
|
+
spelling was the one exception to.
|
|
1600
|
+
|
|
1601
|
+
**What to check before you upgrade.** If a consumer reaches a related record
|
|
1602
|
+
through `GET /:models/:id/{relationship}` that it cannot reach on that
|
|
1603
|
+
record's own collection route, it was relying on the bypass and will now get
|
|
1604
|
+
`data: null` or a shorter array. And the related model's class is resolved
|
|
1605
|
+
through the same `Orm.instance.getAccess` path as the linkage filter, so it
|
|
1606
|
+
inherits the same arity limit: a **single-argument** predicate answers about
|
|
1607
|
+
the collection the request was *addressed to*, not the one it was asked
|
|
1608
|
+
about, and that is the direction that **grants**. See
|
|
1609
|
+
[Known limitations](#known-limitations) and
|
|
1610
|
+
[#221](https://github.com/abofs/stonyx-orm/issues/221).
|
|
1611
|
+
|
|
1612
|
+
**Not closed here:** whether a related resource appears in `included` at all
|
|
1613
|
+
([#233](https://github.com/abofs/stonyx-orm/issues/233)), and the
|
|
1614
|
+
re-parenting write ([#207](https://github.com/abofs/stonyx-orm/issues/207)).
|
|
1615
|
+
A **per-record** deny for a related resource is not expressible on these
|
|
1616
|
+
routes at all — see [Consumer Contracts](#consumer-contracts).
|
|
1617
|
+
|
|
1549
1618
|
### Include Parameter (Sideloading Relationships)
|
|
1550
1619
|
|
|
1551
1620
|
The ORM supports JSON API-compliant relationship sideloading via the `include` query parameter. This reduces the need for multiple API requests by embedding related records in a single response.
|