Temporary fork: integrate upstream PRs 63, 59 and 62 #1
Loading…
Reference in a new issue
No description provided.
Delete branch "hakalya/temporary-upstream-pr-integration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The recipe.getRecipesPage() endpoint in picnic-api targets `meals-page-root`, which is just the navigation shell. The actual recipe content lives one level deeper in `cookbook-page-content` (highlights) and the `recipe_cattree_*` category pages. Rework picnic_get_recipes to: - Hit `cookbook-page-content` by default, returning ~30 highlighted recipes plus the list of available category IDs. - Accept a `category` parameter (bare id or full page id) to fetch a specific `recipe_cattree_<id>` page; a single category can hold hundreds of recipes, so add limit/offset pagination. - Project each recipe to {recipe_id, title, cooking_time, tagline?, image_id?} by walking the FusionPage and using the Snowplow recipe analytics context as the stable id, with a longest-string heuristic for the title that works across both the cookbook and category layouts. - Expose `full: true` to fall back to the raw FusionPage. Add unit tests covering both layouts, deduplication, pagination, category discovery, and the full=true escape hatch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>picnic-api's `recipe.getRecipeDetailsPage()` targets the retired `recipe-details-page-root` page id and now 404s. The live recipe page is served as `selling-group-details-page?selling_group_id=<recipe_id>`, so reach for it directly via `client.app.getPage()`. The page is a 1.7MB FusionPage; project it into a clean shape using Picnic's own stable block ids: - `sellable-components-CORE-list` → ingredients - `sellable-components-CORE_STOCKABLE-list` → likely_in_stock - `sellable-components-CUPBOARD-list` → pantry ("uit eigen keuken") - `sellable-components-COMPLEMENTARY-list` → complementary - `instructions-section` PML → steps + tip - `sellable-header-container` → tagline / name / description - `selling-group-details-image-wrapper` → image_id - the `selling_units` arrays embedded throughout the tree provide the selling_unit_id / quantity / checked fields, joined by ingredient_id. Each ingredient comes back as `{selling_unit_id, ingredient_id, name, brand?, price (cents), unit_quantity?, needed?, quantity, checked}`, ready to be passed to the cart tools. `full: true` falls back to the raw FusionPage. Verified live against recipe 69a6d2ab92f7b13019c86579 (kip-kormaballetjes): 10 core ingredients, 1 likely-in-stock, 3 pantry, 1 complementary, 6 steps, and the variation tip — all extracted with correct fields. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>- picnic_get_recipes: reject path/query characters in `category` via the input schema (P1). The id ends up unencoded in the /pages/ request path, so '../cart' could otherwise turn the tool into an arbitrary authenticated same-origin GET. - Identify title/tagline by Picnic's color-marker structure instead of text length. This also fixes a live bug: newer cookbook tiles carry compound times ("15 min bereiden | 30 min totaal") that are longer than many titles and won the title slot under the length heuristic. - Extract compound cooking times via a loose `<digits> min` token fallback restricted to color-wrapped texts. - Recognize DE/FR step, tip and cooking-time markers and extend the UI label / promo / needed-amount filters to DE/FR (NL verified live, DE/FR best-effort), instead of NL-only parsing. - Ground header tagline/description relative to the canonical recipe name instead of fixed [0]/[1]/[2] slots, so extra badges/chips cannot shift the fields. - Describe `full: true` as a debugging-only escape hatch (raw pages exceed LLM context windows). - Commit the live-API probe scripts under scripts/ (with README) instead of gitignoring them; probe-recipes now exercises the real tool handler. - Prettier pass over the touched files. Verified against the live API (NL account): cookbook, category and detail pages extract correctly, including compound-time tiles. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>Multi-angle review of the recipe tools surfaced several real defects, confirmed against the live API: - Category round-trip was broken: extractRecipeCategoryIds stripped the prefix to a bare slug, but the handler always re-prefixed with the underscore form. Picnic emits both 'recipe_cattree_' and 'recipe-cattree-' and is strict (recipe_cattree_jamie-oliver 404s; recipe-cattree-jamie-oliver resolves), so ~half the advertised categories were unfetchable. Now the full page id is surfaced and forwarded verbatim. Verified live: jamie-oliver returns 32 recipes. - Theme categories (e.g. recipe_cattree_thema-kids) hold only sub-category links and no recipes; surface those sub-categories so drilling into a theme isn't a dead end. Verified live (4 sub-categories surfaced). - Ingredient names starting with a digit ("100% pindakaas", "30+ kaas") were dropped by the `/^\d/` filter; tightened to number-then-space/end so real names survive. - Price/promo labels ("nu €2.29") leaked into the ingredient name slot, pushing the real name into `brand`; any €-bearing text is now chrome. Verified live on the enchilada recipe. - unit_quantity now accepts comma decimals (like the price parser) and spelled-out / DE-FR units (liter, Stück, pièces). - Listing titles now strip `**bold**` (the detail path already did); the color-marker "wrapped" cue is computed independently so a bold-only title stays a title. Deduped stripColorMarkers into stripMd. - stripMd NFC-normalizes so NFD-encoded accented locale tokens (Étape, Hinzufügen) still match. - extractStepsAndTip no longer consumes a following header as a step body when a step's body text is missing. - limit/offset are now .int() so fractional values can't desync pagination. - full:true returns compact JSON (the registry pretty-prints objects, inflating the already-oversized raw page by ~a third). - scripts/README: corrected the false claim that a saved session alone suffices — config requires PICNIC_USERNAME/PICNIC_PASSWORD at startup. 229 unit tests pass (8 new); prettier clean; verified live against an NL account (cookbook, category round-trip, theme sub-categories, detail parsing). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>