feat(product): formalize product data contract and decouple from assessments#23359
Conversation
579fc01 to
db542ef
Compare
|
A merge conflict has been detected for the proposed code changes in this PR. Please resolve the conflict by either rebasing the PR or merging in changes from the base branch. |
…input-contract-for-non-wordpress-consumers' of github.com:Yoast/wordpress-seo into 657-api-migration-formalize-the-product-customdata-contract-and-decouple-producttype-from-the-e-commerce-assessments
Adds a typed, validated productData field to the PaperDTO input contract (productData.js / productDataSchema), wired through toPaper onto Paper.productData. The narrower that applies it at the consumption boundary, normalizeProductData, lives in a separate zod-free module that the assessments import directly, keeping zod out of the core analysis bundle. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
d3001bc to
7c3c7f6
Compare
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.
Context
Part of the API-migration work to make the content-analysis engine consumable off-WordPress. The two e-commerce SEO assessments (Product identifiers, SKU) were coupled to WooCommerce's
productTypeenum and read their input from an implicit, undocumentedcustomDataobject. This formalizes that input as a typed, validatedproductDatacontract and replaces the platform-specific enum with a neutralisVariableProductboolean, so non-WordPress/headless consumers can reproduce in-editor scores.Stacked on #23336 (the PaperDTO input contract, #634); this should merge after it lands.
Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
productDatais a new first-classPaperfield with a zod schema; the existingcustomDatastays as a back-compat fallback so unmigrated producers (and npm consumers) keep working without a coordinated release.productType → isVariableProductderivation lives in a consumption-boundary narrower (normalizeProductData), not a zod.transform(), because the in-editor path builds thePaperdirectly and never crosses the contract boundary — so the defaulting has to happen where the assessment reads the data.zodstays out of the core analysis bundle — measured ~60 KB smaller versus importing through the barrel.productTypestring-lists to a single boolean also removed a latent applicability asymmetry in the SKU assessment (it omittedgrouped); verified inert for real WooCommerce data and pinned with a test.Test instructions
Test instructions for the acceptance test before the PR gets merged
This is engine plumbing with no intended change for the standard product types. It is covered by unit tests (
yarn workspace yoastseo test, contract + assessment specs). For behavioural parity:Note
Test together with this https://github.com/Yoast/wpseo-woocommerce/pull/1164
trunk(the back-compatcustomDatafallback keeps unmigrated producers working even without the matching wpseo-woocommerce PR #1164).Test instructions for the Shopify app
Shopify is not modified by this PR — it still sends its product data through the legacy
customDatabag — so this is a regression check that the back-compat fallback keeps it working:Relevant test scenarios
Test instructions for QA when the code is in the RC
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
Papervalue object (newproductDataattribute), and the PaperDTO input contract. WooCommerce and Shopify are the only producers of this data; both keep working through thecustomDataback-compat fallback.Other environments
[shopify-seo], added test instructions for Shopify and attached theShopifylabel to this PR.[yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached theGoogle Docs Add-onlabel to this PR.Documentation
Quality assurance
grunt build:imagesand committed the results, if my PR introduces or edits images or SVGs.Innovation
innovationlabel.Part of Yoast/lingo-other-tasks#657