Skip to content

Commit

Permalink
fix(middleware-flexible-checksums): use union for new config types
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Sep 17, 2024
1 parent a993838 commit a66eda9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { normalizeProvider } from "@smithy/util-middleware";

import { DEFAULT_REQUEST_CHECKSUM_CALCULATION, DEFAULT_RESPONSE_CHECKSUM_VALIDATION } from "./constants";
import {
DEFAULT_REQUEST_CHECKSUM_CALCULATION,
DEFAULT_RESPONSE_CHECKSUM_VALIDATION,
RequestChecksumCalculation,
ResponseChecksumValidation,
} from "./constants";
import { resolveFlexibleChecksumsConfig } from "./resolveFlexibleChecksumsConfig";

jest.mock("@smithy/util-middleware");
Expand All @@ -25,8 +30,8 @@ describe(resolveFlexibleChecksumsConfig.name, () => {

it("normalizes client checksums configuration", () => {
const mockInput = {
requestChecksumCalculation: "WHEN_REQUIRED",
responseChecksumValidation: "WHEN_REQUIRED",
requestChecksumCalculation: RequestChecksumCalculation.WHEN_REQUIRED,
responseChecksumValidation: ResponseChecksumValidation.WHEN_REQUIRED,
};
const resolvedConfig = resolveFlexibleChecksumsConfig(mockInput);
expect(resolvedConfig).toEqual(mockInput);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import { Provider } from "@smithy/types";
import { normalizeProvider } from "@smithy/util-middleware";

import { DEFAULT_REQUEST_CHECKSUM_CALCULATION, DEFAULT_RESPONSE_CHECKSUM_VALIDATION } from "./constants";
import {
DEFAULT_REQUEST_CHECKSUM_CALCULATION,
DEFAULT_RESPONSE_CHECKSUM_VALIDATION,
RequestChecksumCalculation,
ResponseChecksumValidation,
} from "./constants";

export interface FlexibleChecksumsInputConfig {
/**
* Determines when a checksum will be calculated for request payloads.
*/
requestChecksumCalculation?: string | Provider<string>;
requestChecksumCalculation?: RequestChecksumCalculation | Provider<RequestChecksumCalculation>;

/**
* Determines when checksum validation will be performed on response payloads.
*/
responseChecksumValidation?: string | Provider<string>;
responseChecksumValidation?: ResponseChecksumValidation | Provider<ResponseChecksumValidation>;
}

export interface FlexibleChecksumsResolvedConfig {
requestChecksumCalculation: Provider<string>;
responseChecksumValidation: Provider<string>;
requestChecksumCalculation: Provider<RequestChecksumCalculation>;
responseChecksumValidation: Provider<ResponseChecksumValidation>;
}

export const resolveFlexibleChecksumsConfig = <T>(
Expand Down

0 comments on commit a66eda9

Please sign in to comment.