Skip to content

feat(api): add /api/v1/equipment REST resource - #727

Closed
allofmeng wants to merge 1 commit into
mainfrom
feat/equipment-api-endpoint
Closed

allofmeng wants to merge 1 commit into
mainfrom
feat/equipment-api-endpoint

Conversation

@allofmeng

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a general Equipment REST resource (type: basket|portafilter|dripper|other) for prep equipment that isn't a grinder. Baskets, portafilters, and drippers currently have no home in the bridge API — plugins that track them (e.g. the DYE2 plugin) have been parking that data in the generic plugin KV store instead of a proper resource.
  • Follows the same layered pattern as Grinders: domain model → Drift table (schema v4 → v5 migration) → DAO → mapper → storage service → REST handler, wired through webserver_service.dart / main.dart the same way grinderStorage is.
  • GET /api/v1/equipment supports ?type=<type> filtering and ?includeArchived=true, plus conditional GET (ETag), matching Grinders' conventions. PUT uses the same tri-state patch semantics (omit = keep, explicit null = clear nullable field / reject non-nullable field, value = replace) as the rest of the API.
  • Docs updated: assets/api/rest_v1.yml (new paths + Equipment schema), doc/Api.md, doc/AI_API_NOTES.md, doc/AI_STORAGE_NOTES.md.

Deliberately out of scope

To keep this PR reviewable, I did not add a data-export/backup section or DE1-app import support for Equipment, even though Grinders has both. Happy to follow up with either if wanted.

Test plan

  • dart analyze lib/ — no issues
  • New tests: test/models/equipment_test.dart, test/database/equipment_dao_test.dart, test/webserver/equipment_handler_test.dart (model round-trip, DAO CRUD/filter/watch, handler request/response incl. ETag + tri-state PATCH) — all passing
  • Existing grinder-related tests re-run after this change — all passing (one pre-existing flaky test in de1handler_machine_swap_ws_test.dart, unrelated to this change and reproducible on main without it)

🤖 Generated with Claude Code

https://claude.ai/code/session_01CZKqRkAaE9jCTBKr3S7f9G

Baskets, portafilters, drippers, and other prep equipment currently have
no home in the bridge API — plugins that need to track them (e.g. DYE2)
have been parking equipment data in the generic plugin KV store instead.

Adds a general Equipment resource (type: basket|portafilter|dripper|other)
following the same layered pattern as Grinders: domain model, Drift table
+ schema migration (v4 -> v5), DAO, mapper, storage service, and a REST
handler with the standard GET/POST/PUT/DELETE + conditional-GET (ETag) +
tri-state PATCH semantics used elsewhere in the API. GET supports
?type=<type> filtering and ?includeArchived=true, matching Grinders'
conventions.

Not included (kept out to bound this PR): a data-export/backup section
and DE1-app import support, mirroring what Grinders has for those. Happy
to follow up if wanted.

Docs: assets/api/rest_v1.yml (paths + Equipment schema), doc/Api.md,
doc/AI_API_NOTES.md, doc/AI_STORAGE_NOTES.md.

Tests: model round-trip, DAO CRUD/filter/watch, and handler request/response
tests mirroring grinders_handler_test.dart's coverage (incl. ETag and
tri-state PATCH semantics).
allofmeng added a commit to decentespresso/dye2 that referenced this pull request Aug 29, 2026
… read them

Answers a question about why beans/grinders are Decaid resources but
favourites/recipes/baskets aren't: they live in the bridge's generic
per-plugin KV store, which turns out to have no ownership/permission
check at all (verified against kv_store_handler.dart in the Decaid repo)
— any skin can already read (or write) dye2.reaplugin's KV keys today.
Also flags that baskets is transitional pending decentespresso/decaid#727.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CZKqRkAaE9jCTBKr3S7f9G
@tadelv

tadelv commented Aug 29, 2026

Copy link
Copy Markdown
Member

before we review, have you followed this discussion?
#63

@allofmeng

Copy link
Copy Markdown
Collaborator Author

oh thanks.
I noticed that in the original Basecamp thread other_equipment was mentioned to be added in as well and also Enrique's proposed schema for equipments.

I think what makes sense is that we update this PR to be other_equipment ?
Probably generic enough so even water filter system can be put under here.

Equipment and technique
grinder_model [Already on DE1]
grinder_setting [Already on DE1]
grinder_rpm
grinder_burrs
portafilter_model
portafilter_basket
filter_top
filter_bottom
distribution_tool
distribution_technique
tamper
tamping_technique

@tadelv

tadelv commented Sep 4, 2026

Copy link
Copy Markdown
Member

@allofmeng sorry to leave you hanging. Some of the fields you describe here do not seem to be "equipment" but rather describe how something was done, like e.g. distribution_technique
I haven't checked #63 yet, but maybe there are answers to be found or questions to be asked there?

@allofmeng

Copy link
Copy Markdown
Collaborator Author

closed this PR , will add the equipment endpoint options in DYE2 plugin.

@allofmeng allofmeng closed this Sep 10, 2026
@loganfuller

Copy link
Copy Markdown
Contributor

Is this definitely something we want to defer to the DYE2 plugin, or are you open to having this be in the Decaid data model at some point? I'm developing a synchronization plugin and am trying to avoid having to write to both Decaid and DYE2 if possible.

@tadelv

tadelv commented Oct 5, 2026

Copy link
Copy Markdown
Member

@loganfuller Decaid is the backing store for DYE2 anyway, but I think I understand what you mean. I am deferring the equipment endpoint to DYE2 for now until we start seeing the final shape of the api and how it attaches the data to shot records.
Feel free to check discussions we have on this and contribute to the chat and perhaps we come to a conclusion & spec we agree on, and implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants