Skip to content

feat(schema): scan app loaders from @decocms/apps#272

Open
guitavano wants to merge 2 commits into
mainfrom
fix/schema-array-output-block-ref
Open

feat(schema): scan app loaders from @decocms/apps#272
guitavano wants to merge 2 commits into
mainfrom
fix/schema-array-output-block-ref

Conversation

@guitavano

@guitavano guitavano commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a static mapping of 8 CMS keys → 3 unique inline-loader source files from @decocms/apps (productListShelf, productListingPage, productDetailsPage)
  • Parse each source file once via ts-morph and register them in definitions, loaderBlocks, loaderRootAnyOf, and outputTypeToLoaderKeys
  • Section block-ref props (ProductShelf.products, SearchResult.page) and commerce extension wrappers now automatically include app loaders in their anyOf

Test plan

  • Ran generate-schema.ts --site casaevideo — all 8 app loaders scanned with correct output types
  • ProductShelf.products anyOf includes vtex/loaders/intelligentSearch/productList.ts + aliases
  • SearchResult.page anyOf includes vtex/loaders/intelligentSearch/productListingPage.ts + aliases
  • Commerce extension wrapper listingPage data field includes 3 PLP loaders
  • CI passes

🤖 Generated with Claude Code


Summary by cubic

Scan and register inline app loaders from @decocms/apps, and fix array output type detection so block-ref fields surface the correct loader pickers.

  • New Features

    • Map 8 CMS keys to 3 inline loaders from @decocms/apps and add them to definitions, loaderBlocks, and root anyOf.
    • Block-refs like ProductShelf.products and SearchResult.page now include the app loaders; the commerce listingPage wrapper lists the 3 PLP loaders.
  • Bug Fixes

    • Resolve array return types as Product[] (not Array) to avoid collisions in loader→section matching.
    • For array or nullable-array props, match on the element type to find the right loaders.

Written for commit 5c64018. Summary will update on new commits.

Review in cubic

guitavano and others added 2 commits June 22, 2026 23:14
…etection

Loaders returning array types (e.g. Product[]) had their output type
resolved as "Array" by getSymbol().getName(), causing all array-returning
loaders to collide under the same key. Section properties like
`products: Product[] | null` also resolved to "Array", matching the wrong
loaders or none at all — rendering as inline array forms instead of
loader pickers in the CMS.

Now extractLoaderOutputTypeName unwraps array element types and keys them
as "Product[]", and typeToJsonSchema falls back to element-type lookup
for array/nullable-array properties.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a static mapping of CMS keys → inline-loader source files so the
schema generator registers app loaders (productList, productListingPage,
productDetailsPage) alongside site loaders. Each source file is parsed
once and reused across alias keys. The output types feed into
outputTypeToLoaderKeys so section block-ref props (e.g.
ProductShelf.products, SearchResult.page) and commerce extension
wrappers automatically include app loaders in their anyOf.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@guitavano guitavano requested a review from a team June 23, 2026 03:06
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