feat(client): typed render builders for preview_creative discriminator#772
Merged
Conversation
Adds urlRender / htmlRender / bothRender factory helpers + a grouped
Render namespace. Each helper takes the render payload without
output_format and returns the tagged object — urlRender({ render_id,
preview_url, role }) can't be called without preview_url because the
input type omits output_format and requires the sibling field the url
variant needs.
Mirrors the asset-builder pattern (#771). PreviewRender is a oneOf on
output_format with three variants; matrix runs kept catching renders
that dropped the discriminator or its required sibling. These helpers
make the wrong shape syntactically harder to express.
Return type is Omit<Variant, 'output_format'> & { output_format: <literal> }
for regen-stability. Discriminator spread last so a runtime cast can't
overwrite the canonical tag.
Skill pitfall callouts in build-creative-agent and
build-generative-seller-agent now recommend the render helpers alongside
the asset helpers.
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
Adds
urlRender/htmlRender/bothRenderfactory helpers + a groupedRendernamespace — directly targets thepreview_creativedrift class matrix v13 surfaced (2 hits on/previews/0/renders/0/preview_url: must have required property 'preview_url').Mirrors the asset-builder pattern shipped in #771.
PreviewRenderis a oneOf onoutput_formatwith three variants (url/html/both); the discriminator decides which sibling becomes required. Matrix runs kept catching renders that dropped either the discriminator or the sibling it makes required.Design
urlRender({...})withoutpreview_urlbecause its input type requires it.Omit<Variant, 'output_format'> & { output_format: <literal> }— regen-stable whether or not the generated interface declares the discriminator in the future.output_format: 'wrong'into the input still produces the correct tag.Rendernamespace (Render.url(...)) as convenience for renders[] arrays that mix variants.Skill updates
build-creative-agentandbuild-generative-seller-agentcross-cutting pitfall callouts now recommend the render helpers alongside the asset helpers, completing the set:imageAsset/videoAsset/htmlAsset/urlAssetfor each asseturlRender/htmlRender/bothRenderfor each renderBoth classes of drift the matrix has been catching now have typed construction paths Claude can lean on.
Test plan
npm run typecheckcleanrender builders— discriminator injection per variant, field forwarding, spread-order invariant, namespace equivalencenpm test— no regressionsMinor version bump — new public API, no breaking change.