Skip to content

feat(apps-nuvemshop): Nuvemshop Storefront API app - #628

Merged
JonasJesus42 merged 6 commits into
mainfrom
JonasJesus42/nuuvem-shop-api-integration
Oct 6, 2026
Merged

JonasJesus42 merged 6 commits into
mainfrom
JonasJesus42/nuuvem-shop-api-integration

Conversation

@JonasJesus42

@JonasJesus42 JonasJesus42 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What

New commerce app @decocms/apps-nuvemshop over the headless Nuvemshop / Tiendanube Storefront API (v2026-11, OpenAPI 0.5.0). It has the same shape as the other commerce apps: a deco-nuvemshop block, configure, a registry entry and a manifest.

Surface Covers
loaders/productListingPage Category pages (taken from the URL path; supports /<cat>/<sub>/), search (?q=), facets, sort and pagination
loaders/productDetailsPage Product by handle or id; ?variant= selects the variant; breadcrumb and SEO
loaders/productList Shelf by ids, handles, category or search term
loaders/suggestions, loaders/categories Autocomplete and the category tree for menus
loaders/shippingOptions Shipping quote for one variant and a CEP
actions/createCheckout Line items plus an optional coupon → hosted checkout_url
hooks/useCart Cart kept in localStorage (the API has no server-side cart) that hands off to createCheckout

Design notes

  • Field sets. The API returns only id,name,handle unless fields= is sent, so the client always requests the full product and category field sets. Leaving parent out silently flattens the category tree; the live smoke test caught this. The variant cost field is never requested or mapped.
  • Instrumentation and caching. Egress goes through createNuvemshopFetch by default, like Salesforce, so sites need no setXFetch wiring. GETs go through createFetchCache. The app is added to the instrumentation guardrail and to the biome bare-fetch ban.
  • Auth and rate limits. The token is optional: requests without one are limited to 120/min per store and IP; with a token the limit is 1,200/min. When a token is set, POSTs forward X-LinkedStore-Buyer-IP (from cf-connecting-ip) so each buyer gets their own bucket.
  • Facets, sort and pagination are computed in memory. The API has no facets and only 3 sorts, but the Nuvemshop core already filters by variant values and price. Until the API exposes this, the PLP fetches a window of up to 200 products and computes:
    • attribute facets with counts, price range, 8 sorts (relevance, best-selling, release, price ↑↓, discount, name A–Z / Z–A) and pagination.
    • It is marked ponytail: with its limit: it is only correct while a category or search fits in 200 products.
  • URLs match the Nuvemshop theme (/produtos/<handle>/, ?Cor=Vermelho, min_price), so links and SEO survive a migration.

Tests

The tests were written first, against API responses captured from the demo store. The fixtures are assigned to the API types, so if the response shape drifts, tsc fails (verified by temporarily breaking a type). Expected outputs are hand-written commerce objects, not snapshots. The suite has 59 tests and the package passes tsc; this PR adds no new biome errors.

Live checks against the real API, not committed:

  • loaders on two stores: categories, PLP with filters whose counts match the filtered record count, sorts, PDP, 404, search, suggestions, shelves, shipping;
  • configure → setupApps → /deco/invoke for productList and createCheckout, ending on the hosted checkout page (HTTP 200).

Already failing on main and not touched here: the blocks-cli typecheck, biome format drift in apps-commerce/apps-algolia/tanstack, and per-package knip.

Before release

  • Configure npm Trusted Publishing for @decocms/apps-nuvemshop.

🤖 Generated with Claude Code


Summary by cubic

Adds @decocms/apps-nuvemshop, a new commerce app over the Nuvemshop/Tiendanube Storefront API covering catalog, search, categories, shipping quotes, and hosted checkout. It follows the shape of the other commerce apps and is wired into the instrumentation guardrail, the biome fetch ban, the README, and the repo lockfile.

What's included

  • PLP for category and search with facets, sorts, and pagination; sorts mirror the theme's ?sort_by= values (plus discount), with newest-first as the configurable category default and only "Relevância" on search. PDP with ?variant= selection, breadcrumb, and SEO; plus shelves, suggestions (6 like the theme), related products via the theme's fallback rule, and single-variant shipping quotes that expose free_shipping.
  • createCheckout takes line items plus an optional coupon and returns the hosted checkout_url.
  • useCart keeps the cart in localStorage (the API has no server cart) and hands it to createCheckout.
  • GETs go through createFetchCache; egress uses the instrumented createNuvemshopFetch by default, so sites need no setXFetch wiring.
  • Tokenless requests are limited to 120/min; with a token, 1,200/min and POSTs forward the buyer IP so each buyer gets their own bucket.

Notes

  • Facets, sort, and pagination are computed in memory over a 200-product window because the API exposes none; correct only while a category or search fits in that window.
  • URLs match the Nuvemshop theme (/produtos/<handle>/, ?Cor=Vermelho|Preto): filter values are pipe-joined rather than repeated, matching the theme's OR semantics so migrated links keep filtering.
  • Tests run against captured API fixtures typed with the API types, so response shape drift fails tsc (59 tests).
  • Configure npm Trusted Publishing for the package before release.

Written for commit b0db795. Summary will update on new commits.

Review in cubic Turn on auto-fix

New commerce app over the headless Nuvemshop/Tiendanube Storefront API
(v2026-11): catalog, search, categories, single-variant shipping quote and
hosted checkout.

- client: tokenless or bearer token; GETs through createFetchCache, egress
  through createNuvemshopFetch by default (no site wiring); always requests
  the full product/category field sets (the API defaults to id,name,handle);
  buyer IP forwarded on POSTs only with a token.
- loaders: productListingPage, productDetailsPage, productList, suggestions,
  categories, shippingOptions; action createCheckout -> checkout_url.
- PLP facets (variant attributes + price), 8 sorts and pagination are
  computed in memory over a 200-product window until the API exposes the
  core's filters. URLs mirror the Nuvemshop theme (/produtos/<handle>/,
  /<cat>/<sub>/, ?Cor=..., ?variant=).
- hooks/useCart: localStorage cart (the API has no server cart) that hands
  off to createCheckout.
- Tests are written against captured API fixtures typed with the API
  types, so a response shape drift fails tsc.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@JonasJesus42
JonasJesus42 requested a review from a team October 6, 2026 20:37
JonasJesus42 and others added 5 commits October 6, 2026 17:41
/search/products takes no sort_by, so the option silently kept relevance order.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The Nuvemshop theme ORs multiple values of one filter as ?Cor=Vermelho|Preto
(repeated params keep only the last). Match it so migrated links keep
filtering; counts now equal the theme on 12/12 live search/category cases.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…shipping)

Reviewed against TiendaNube/base-theme and the live demo theme:

- Sort uses the theme's ?sort_by= and values (alpha-*, created-*,
  best-selling, price-*) plus discount-descending. Category default is
  newest-first (configurable `defaultSort`; the API doesn't expose the
  category's sort and returns oldest-first) and ties break newest-first.
  Top-8 order now equals the theme on 14/14 category x sort cases.
  "user" (manual order) isn't in the API, so it falls back to the default.
  Search keeps API relevance and offers "Relevância".
- relatedProducts loader: the theme's fallback rule (same category,
  without itself, in-stock first, refilled with out-of-stock, max 8).
- free_shipping is now exposed (the theme's shipping label).
- suggestions default to 6 products, like the theme.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@JonasJesus42
JonasJesus42 merged commit 43b5bdb into main Oct 6, 2026
2 checks passed
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