feat(schema): scan app loaders from @decocms/apps#272
Open
guitavano wants to merge 2 commits into
Open
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@decocms/apps(productListShelf, productListingPage, productDetailsPage)ProductShelf.products,SearchResult.page) and commerce extension wrappers now automatically include app loaders in their anyOfTest plan
generate-schema.ts --site casaevideo— all 8 app loaders scanned with correct output typesProductShelf.productsanyOf includesvtex/loaders/intelligentSearch/productList.ts+ aliasesSearchResult.pageanyOf includesvtex/loaders/intelligentSearch/productListingPage.ts+ aliaseslistingPagedata field includes 3 PLP loaders🤖 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
@decocms/appsand add them to definitions, loaderBlocks, and root anyOf.ProductShelf.productsandSearchResult.pagenow include the app loaders; the commercelistingPagewrapper lists the 3 PLP loaders.Bug Fixes
Product[](notArray) to avoid collisions in loader→section matching.Written for commit 5c64018. Summary will update on new commits.