Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(headless): update product interface to reflect how the commerce api behaves #4104

Merged
merged 3 commits into from
Jun 25, 2024

Conversation

olamothe
Copy link
Member

@olamothe olamothe commented Jun 19, 2024

This is less changes that what I had originally thought.

The BaseProduct interface should now properly reflect what's returned by the commerce API, following the source of truth (the code of the service itself).

  • Most of the change are about changing from foo | undefined to foo | null.
  • Array values are never null, but might be an empty array (due to how the service is coded)
  • ec_category is always an array, not a string
  • Added couple missing properties (non breaking)

There is only "one lie" in this change: excerpts, nameHighlights, excerptsHighlights are "always defined when in a search use case", and "always undefined when in a listing or recommendation use case".

I thought about splitting and creating multiple interface SearchProduct, ListingProduct, RecommendationProduct, and remove Product as it exists right now.

However this would be a very noisy change, for existing deployments. Product is an important interface, which is nearly always referenced by any implementer using TypeScript.

So I made the judgment call to "lie a little bit, for the greater good" 😂 They are marked as possibly undefined for all use cases.

https://coveord.atlassian.net/browse/KIT-3164

@developer-experience-bot
Copy link
Contributor

developer-experience-bot bot commented Jun 19, 2024

Pull Request Report

PR Title

✅ Title follows the conventional commit spec.

Live demo links

Bundle Size

File Old (kb) New (kb) Change (%)
case-assist 204.9 204.9 0
commerce 293.1 293.1 0
search 372.4 372.4 0
insight 352.4 352.4 0
product-listing 267 267 0
product-recommendation 170.8 170.8 0
recommendation 217.8 217.8 0
ssr 365.2 365.2 0

SSR Progress

Use case SSR (#) CSR (#) Progress (%)
search 39 44 89
recommendation 0 4 0
product-recommendation 0 10 0
product-listing 0 13 0
case-assist 0 6 0
insight 0 27 0
commerce 0 15 0
Detailed logs search : buildInteractiveResult
search : buildInteractiveInstantResult
search : buildInteractiveRecentResult
search : buildInteractiveCitation
search : buildGeneratedAnswer
recommendation : missing SSR support
product-recommendation : missing SSR support
product-listing : missing SSR support
case-assist : missing SSR support
insight : missing SSR support
commerce : missing SSR support

Copy link

@buggyvelarde buggyvelarde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice types!

@olamothe olamothe enabled auto-merge June 25, 2024 14:46
@olamothe olamothe added this pull request to the merge queue Jun 25, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 25, 2024
@olamothe olamothe enabled auto-merge June 25, 2024 18:11
@olamothe olamothe added this pull request to the merge queue Jun 25, 2024
Merged via the queue into master with commit 5e514c5 Jun 25, 2024
90 of 92 checks passed
@olamothe olamothe deleted the KIT-3164 branch June 25, 2024 19:00
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.

None yet

5 participants