Skip to content

fix: support current UCP schema generation#16

Open
sakinaroufid wants to merge 1 commit intoUniversal-Commerce-Protocol:mainfrom
sakinaroufid:fix/ucp-schema-generation-clean
Open

fix: support current UCP schema generation#16
sakinaroufid wants to merge 1 commit intoUniversal-Commerce-Protocol:mainfrom
sakinaroufid:fix/ucp-schema-generation-clean

Conversation

@sakinaroufid
Copy link
Copy Markdown

@sakinaroufid sakinaroufid commented Mar 24, 2026

Summary

Fix js-sdk model generation so it works with the current upstream UCP schema layout while keeping the existing generated SDK API intact.

Context

The SDK generator was built around the older split schema layout (*.create_req, *.update_req, *_resp). Upstream UCP has moved to unified schemas under source/, so generation in this repo had drifted away from the actual source of truth.

This change brings the generator back in line with upstream without forcing a consumer-facing API rewrite in js-sdk.

What changed

  • updated generate_models.sh to handle both the legacy split layout and the current upstream source/ layout
  • added a projection step that derives the legacy request/update/response inputs from the unified upstream schemas
  • kept the existing quicktype-based generation flow in place after that projection step
  • normalized duplicated quicktype output so the generated export surface stays stable
  • regenerated src/spec_generated.ts

Why this approach

There were two obvious ways to deal with the upstream schema changes:

  1. switch the SDK over to the unified upstream model directly
  2. preserve the SDK’s current generated surface and adapt the generator

This takes the second approach. The problem here is generator drift, not that the SDK suddenly needs a new public API.

Validation

Ran locally:

  • npm run generate -- /tmp/ucp-spec-test
  • npm run build:noEmit
  • npm run build

Notes

The largest part of the change is the projection layer. That is where the compatibility logic now lives, and it is what allows js-sdk to keep generating the same kind of output from the current upstream schema model.

Project the current upstream UCP source schemas into the legacy split request and response shapes this SDK exports, then normalize quicktype output to keep the generated API stable.
@sakinaroufid
Copy link
Copy Markdown
Author

sakinaroufid commented Mar 24, 2026

@wry-ry tagging you here as I have submitted PR to fix schema generation

@sakinaroufid
Copy link
Copy Markdown
Author

Clarification: this PR fixes the repo-side schema generation issues that were causing drift against the current upstream UCP schema model while preserving the legacy generated API shape.

Thanks!

@artemii-karkusha
Copy link
Copy Markdown

We hit this in production while integrating with real merchants from https://merchants.awesomeucp.com/ (Everlane, Monos, etc.). The current spec_generated.ts breaks capability detection — capabilities parsed as an array returns empty when merchants send the spec-compliant object format, so checkout/fulfillment/discount are never detected.

Filed #19 with details and reproduction steps.

Would be great to get this merged — it's currently the main blocker for any JS client connecting to live UCP merchants.

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.

2 participants