Skip to content

feat(item): expose recipeId, rawIngredient, and ingredients#57

Open
arunderwood wants to merge 1 commit intokevdliu:masterfrom
arunderwood:feat/expose-item-recipe-origin
Open

feat(item): expose recipeId, rawIngredient, and ingredients#57
arunderwood wants to merge 1 commit intokevdliu:masterfrom
arunderwood:feat/expose-item-recipe-origin

Conversation

@arunderwood
Copy link
Copy Markdown

Summary

  • Expose recipeId, rawIngredient, and ingredients on the Item class
  • These fields are already present in the protobuf ListItem definition but were not surfaced by the JS class
  • recipeId and rawIngredient identify the recipe an item was added from
  • ingredients is an array tracking multiple recipe sources when items are merged (each entry has recipeId, recipeName, eventId, eventDate)
  • All three properties are read-only, following the same pattern as identifier and userId

Motivation

The AnyList UI shows which recipe an item was added from, but this data was inaccessible through the package. The protobuf layer already deserializes these fields — they just needed to be wired up in the Item constructor, getters, toJSON(), and _encode().

Changes

  • lib/item.js: Added constructor initialization, read-only getters with throwing setters, JSDoc @property tags, and serialization support in both toJSON() and _encode()
  • lib/index.js: Fixed pre-existing lint error (missing blank line)

Test plan

  • Verified xo linter passes
  • Verified documentation build succeeds (via pre-commit hook)
  • Live-tested against real AnyList account — 724 of 4,077 items returned valid recipeId and rawIngredient values

Items added from recipes carry recipe-origin data in the protobuf
response but the Item class did not surface it. This adds read-only
access to recipeId, rawIngredient, and the ingredients array which
tracks multiple recipe sources for merged grocery items.
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.

1 participant