feat(gen): derive mappings with caller-supplied parameters#1771
Merged
Conversation
Target fields that can't be derived from the source constructor are now exposed as parameters of the generated As-mapper instead of causing the mapping to be skipped. thumb_size on file-location inputs is required by the wire format but not present on the source, so the caller supplies it. Document/InputDocument now have AsInputDocumentFileLocation(thumbSize string) and Photo/InputPhoto gain a new AsInputPhotoFileLocation(thumbSize string) (previously dropped in #374 because thumb_size is required). telegram/query/messages uses these mappers instead of hand-building the location structs. Closes #376 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1771 +/- ##
==========================================
+ Coverage 71.07% 71.10% +0.03%
==========================================
Files 501 501
Lines 23500 23501 +1
==========================================
+ Hits 16703 16711 +8
+ Misses 5570 5569 -1
+ Partials 1227 1221 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Closes #376.
Problem
PR #374 dropped the
Photo/InputPhoto→InputPhotoFileLocationmappingsbecause
InputPhotoFileLocationrequires athumb_sizefield that can't bederived from the source constructor. As #376 notes, the generator could instead
emit
AsInputPhotoFileLocation(thumbSize string)and let the caller pass it in.Change
mappableFieldsnow splits the target's unmappable fields:thumb_sizeon file-location inputs becomes a method parameter (parameterField);The generated concrete
As-mappers render those fields as parameters and assignthem after the derived fields.
Generated API
telegram/query/messagesnow uses these mappers instead of building thelocation structs by hand.
Scope
The blast radius is exactly the four file-location mappers above — the
parameterized mappings carry a
Constructor, so the slice/field wrappertemplates (which only handle constructor-less interface mappings) are untouched.
Tests
gen: unit tests formappableFields(thumb_size → parameter; unmappablerequired field still skipped) and
parameterField.make check_generatedclean; full build +telegram/query/messagesracetests pass.
🤖 Generated with Claude Code