Skip to content

Make CompressionInputConfig properties optional #1133

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

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nice-pumas-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smithy/middleware-compression": patch
---

Make CompressionInputConfig properties optional
4 changes: 2 additions & 2 deletions packages/middleware-compression/src/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ export interface CompressionInputConfig {
/**
* Whether to disable request compression.
*/
disableRequestCompression: boolean | Provider<boolean>;
disableRequestCompression?: boolean | Provider<boolean>;

/**
* The minimum size in bytes that a request body should be to trigger compression.
* The value must be a non-negative integer value between 0 and 10485760 bytes inclusive.
*/
requestMinCompressionSizeBytes: number | Provider<number>;
requestMinCompressionSizeBytes?: number | Provider<number>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { CompressionInputConfig, CompressionResolvedConfig } from "./configurati
/**
* @internal
*/
export const resolveCompressionConfig = <T>(input: T & CompressionInputConfig): T & CompressionResolvedConfig => ({
export const resolveCompressionConfig = <T>(
input: T & Required<CompressionInputConfig>
): T & CompressionResolvedConfig => ({
...input,
disableRequestCompression: normalizeProvider(input.disableRequestCompression),
requestMinCompressionSizeBytes: async () => {
Comment on lines -8 to 13
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: is it safer to guard against undefined values for disableRequestCompression and requestMinCompressionSizeBytes, and not make CompressionInputConfig required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There won't be undefined values when calling resolveCompressionConfig as runtimeConfig resolution ensure that it's defined. If it doesn't, the client compilation should fail like it's happening in protocol tests.

Also, the Required doesn't allow undefined.
Playground Link

Expand Down