mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 01:28:55 +00:00
feat(plugins): extend the output allowlist to child rows and whole-row read models
The output contract cut only the top level of an entity result. A derived key's value went out untouched, so the children that are whole rows still carried every column: a day's notes_items are full day_notes entities and a reservation's endpoints are SELECT e.* on reservation_endpoints. About fifty methods were also left as readModel and passed through whole, many of them backed by SELECT * reads (day_accommodations, day_notes, todos, tags, packing bags, journal entries, collab, collections, vacay plans). A new column on any of those tables reached every plugin by default, which is what the contract was meant to stop and what the SDK README and the wiki already claimed it did. PLUGIN_ENTITY_NESTED now names, per entity, the derived keys that hold rows of another entity, and the shaper cuts those rows down to their own field list, recursively. dayNote and reservationEndpoint are the child tables that were whole rows; day.assignments and place.tags are held to the assignment and tag lists too, although their reads already name their columns. The remaining derived children (travelers, participants, ratings, budget members, payers and receipts, packing recipients, attachments, voters, bag members) are built field by field, which the contract comment now states as the rule for a derived key without a nested entity. The whole-row read models get entity contracts: accommodation, dayNote, todo, tag, category, packingBag, fileLink, collabNote, collabPoll, collabMessage, journey, journalEntry, bucketItem and collection, and vacayPlan with its holiday calendars. collections.listMine, collections.get and vacay.mine return envelopes around rows; an entity with a null table describes those, so their rows are reached through the same nesting. Every list holds exactly the keys each read returned before, so no plugin loses a field. What stays readModel is built field by field from named columns, and each such entry says what it returns: setBagMembers, atlas.visited, collections.savePlace and copyToTrip, the two vacay toggles and journal.addEntryPhoto. The schema test now covers every child and new table, and calls each newly shaped method on the real services, comparing nested rows key for key so the only field allowed to disappear is a withheld one. A further case proves the nested rows it compares are not empty. gen:plugin-facts publishes PLUGIN_ENTITY_NESTED to the SDK, and the SDK README, the plugin wiki pages and server/CLAUDE.md describe the nested rows and list the new entities.
This commit is contained in:
+24
-13
@@ -247,23 +247,34 @@ parser would ignore one if you added it.
|
||||
**What the reads return.** Every method's result is one of three kinds, and the SDK
|
||||
exports the list per method as `PLUGIN_METHOD_RESULT`:
|
||||
|
||||
- **Entity rows** (`trip`, `place`, `day`, `reservation`, `packingItem`, `tripFile`,
|
||||
`budgetItem`, `assignment`, `user`). A row carries exactly the fields TREK publishes
|
||||
for that entity (`PLUGIN_ENTITY_FIELDS` in the SDK): the table's columns in
|
||||
snake_case, then what TREK adds on top, such as a trip's `day_count`,
|
||||
`place_count`, `is_owner`, `owner_username` and `shared_count`, a place's
|
||||
`category`, `tags` and `ratings`, a reservation's `endpoints`, `travelers` and
|
||||
`day_positions`, or a day's `assignments` and `notes_items`. A field appears only
|
||||
where the method's read produces it (`trips.getById` has no `day_count`,
|
||||
- **Entity rows**: the trip data (`trip`, `place`, `day`, `reservation`,
|
||||
`accommodation`, `packingItem`, `packingBag`, `tripFile`, `fileLink`, `budgetItem`,
|
||||
`assignment`, `dayNote`, `todo`, `user`), the collab board (`collabNote`,
|
||||
`collabPoll`, `collabMessage`) and the acting user's own data (`tag`, `category`,
|
||||
`journey`, `journalEntry`, `bucketItem`, `collection`). A row carries exactly the
|
||||
fields TREK publishes for that entity (`PLUGIN_ENTITY_FIELDS` in the SDK): the
|
||||
table's columns in snake_case, then what TREK adds on top, such as a trip's
|
||||
`day_count`, `place_count`, `is_owner`, `owner_username` and `shared_count`, a
|
||||
place's `category`, `tags` and `ratings`, a reservation's `endpoints`, `travelers`
|
||||
and `day_positions`, or a day's `assignments` and `notes_items`. A field appears
|
||||
only where the method's read produces it (`trips.getById` has no `day_count`,
|
||||
`trips.listMine` has). Credentials are never part of a row: a trip's calendar
|
||||
`feed_token` is withheld, and a user is only `id`, `username`, `display_name` and
|
||||
`avatar`. A column TREK adds in a later release is **not** delivered until TREK
|
||||
publishes it in that list, so the rows your plugin reads do not change shape on an
|
||||
update. `Place.day_id` in the SDK types is deprecated and never set: a place's days
|
||||
are the `assignments` of `getDays`.
|
||||
- **Read models** (tags, to-dos, collab notes, polls and messages, journals and
|
||||
entries, bags, collections, accommodations, Atlas and Vacay data): the same shape
|
||||
TREK's own REST route returns, passed on unchanged. The SDK types them `unknown`.
|
||||
update. That holds for the rows inside a row too: the fields listed in
|
||||
`PLUGIN_ENTITY_NESTED` hold rows of another entity (a day's `notes_items` are
|
||||
`dayNote` rows, a reservation's `endpoints` are `reservationEndpoint` rows) and
|
||||
carry that entity's published fields only, however deep they sit; every other
|
||||
added field is a value TREK builds field by field. `collections.listMine`,
|
||||
`collections.get` and `vacay.mine` return envelopes around such rows
|
||||
(`collectionListing`, `collectionDetail`, `vacayPlanData`). `Place.day_id` in the
|
||||
SDK types is deprecated and never set: a place's days are the `assignments` of
|
||||
`getDays`.
|
||||
- **Read models**: small results TREK builds field by field from named columns, so
|
||||
no stored row passes through them whole (a bag's members, the Atlas `visited`
|
||||
codes, what a Vacay toggle did, a saved collection place or a copy summary, a
|
||||
journal photo). The SDK types them `unknown`.
|
||||
- **Host values**: `{ deleted }`, `{ sent }`, a model's answer, an access token, and
|
||||
your own data (`ctx.db`, `ctx.meta`, another plugin's answer), returned as they are.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user