Skip to content

feat(vtex/plp): rich typing + JSDoc on PLPProps for CMS admin - #80

Merged
JonasJesus42 merged 1 commit into
mainfrom
fix/plp-loader-typed-props
Jun 18, 2026
Merged

feat(vtex/plp): rich typing + JSDoc on PLPProps for CMS admin#80
JonasJesus42 merged 1 commit into
mainfrom
fix/plp-loader-typed-props

Conversation

@JonasJesus42

@JonasJesus42 JonasJesus42 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

The decoCMS admin generates section/loader edit forms from the loader's Props TypeScript types. PLPProps (VTEX inline PLP loader) had weak typing and no JSDoc, so the admin rendered plain text inputs and raw field names ("Count") instead of dropdowns and labelled fields.

Changes (vtex/inline-loaders/productListingPage.ts)

  • sort?: stringsort?: Sort — the 8-value union already in vtex/utils/types.ts → admin renders a dropdown.
  • fuzzy?: stringfuzzy?: LabelledFuzzy ("automatic" | "disabled" | "enabled") → dropdown with friendly labels.
  • Added @title / @description JSDoc to every field (e.g. count"Items per page", "Number of products per page to display").

Latent runtime fix

props.fuzzy (a friendly LabelledFuzzy like "automatic") was passed raw to the Intelligent Search API, which expects "0" | "1" | "auto". It's now mapped via the existing mapLabelledFuzzyToFuzzy(); the raw ?fuzzy= URL param still passes through.

const fuzzy =
  mapLabelledFuzzyToFuzzy(props.fuzzy) ??
  pageUrl?.searchParams.get("fuzzy") ??
  undefined;

Compatibility

  • tsc --noEmit clean; vitest run vtex/inline-loaders passes (4/4).
  • Loader body uses sort/fuzzy as strings downstream — no behavior change beyond the fuzzy mapping fix.
  • Sites must bump and (if their loader defines a local Props) adopt the typed Props to see the richer form.

Related

DECO-5296 — CMS Studio loader form parity for @decocms/start sites.

Generated with Claude Code


Summary by cubic

Improve the VTEX PLP loader’s PLPProps typing and JSDoc so the CMS admin shows labeled dropdowns and clearer fields instead of plain text. Also fix fuzzy search value mapping to the Intelligent Search API. Addresses DECO-5296 (CMS Studio loader form parity for @decocms/start).

  • New Features

    • sort?: stringsort?: Sort (8-value union) to render a dropdown.
    • fuzzy?: stringfuzzy?: LabelledFuzzy ("automatic" | "disabled" | "enabled") with friendly labels.
    • Added @title/@description JSDoc to all fields (e.g., count → "Items per page").
  • Bug Fixes

    • Map LabelledFuzzy to "0" | "1" | "auto" before calling Intelligent Search; the raw ?fuzzy= URL param still passes through.

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

Review in cubic

The CMS admin generates edit forms from the loader's Props TypeScript types.
PLPProps had weak typing (sort?: string, fuzzy?: string) and no JSDoc, so
the admin rendered plain text inputs and raw field names ('Count') instead
of dropdowns and labelled fields.

- sort?: string  → sort?: Sort         (8-value union → dropdown)
- fuzzy?: string → fuzzy?: LabelledFuzzy ('automatic'|'disabled'|'enabled' → dropdown)
- add @title/@description to every field (e.g. count → 'Items per page')

Also fixes a latent runtime bug: props.fuzzy (a friendly LabelledFuzzy like
'automatic') was passed raw to the IS API, which expects '0'|'1'|'auto'. Now
mapped via mapLabelledFuzzyToFuzzy(); the raw URL ?fuzzy= param still passes
through.

Related: DECO-5296 (CMS Studio loader form parity)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@JonasJesus42
JonasJesus42 requested a review from a team June 18, 2026 19:46
@JonasJesus42
JonasJesus42 merged commit 6e693b6 into main Jun 18, 2026
2 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 5.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant