-
Notifications
You must be signed in to change notification settings - Fork 605
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
feat(codegen): general data mapping function #3830
Conversation
smithy counterpart: smithy-lang/smithy-typescript#576 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just some nits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ship it! 🐑 🇮🇹
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
No clients diff: https://github.com/aws/aws-sdk-js-v3/compare/main...kuhe:aws-sdk-js-v3:s3/codegen-no-clients-diff?expand=1
Problem:
Object field names are often repeated multiple times per line in code that is only transferring fields from one object to another (mapping), with repetitive checks.
Examples
Request headers
Response headers
Body deserialization
... and more.
Proposed solution:
A general purpose data mapping function. It accepts transfer instructions in a brevity form:
Where the key's value in the target object is created with a combination of the filter and the value, both of which can be value expressions or lazy functional providers.
source: https://github.com/aws/aws-sdk-js-v3/blob/800e8e97ea1f184111e2a85208b07d68fb7297b2/packages/smithy-client/src/object-mapping.ts
Also targeted were the following repeated patterns:
Resolved path construction, XML node creation, and default error deserialization. These were turned into helper functions.
Effects
The change for S3 in for example dist-cjs and dist-es:
dist-cjs/protocols -> 568kb to 440kb
dist-es/protocols -> 692kb to 556kb
overall reduction is approximately 0.1mb out of 1.2 to 1.3mb.