-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow feature identification on the smithy context
- Loading branch information
Showing
6 changed files
with
92 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@smithy/types": minor | ||
"@smithy/core": minor | ||
--- | ||
|
||
add feature identification map to smithy context |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { HandlerExecutionContext } from "@smithy/types"; | ||
|
||
import { setFeature } from "./setFeature"; | ||
|
||
describe(setFeature.name, () => { | ||
it("creates the context object path if needed", () => { | ||
const context: HandlerExecutionContext = {}; | ||
setFeature(context, "RETRY_MODE_STANDARD", "E"); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { HandlerExecutionContext, SmithyFeatures } from "@smithy/types"; | ||
|
||
/** | ||
* @internal | ||
* Indicates to the request context that a given feature is active. | ||
* | ||
* @param context - handler execution context. | ||
* @param feature - readable name of feature. | ||
* @param value - encoding value of feature. This is required because the | ||
* specification asks the library not to include a runtime lookup of all | ||
* the feature identifiers. | ||
*/ | ||
export function setFeature<F extends keyof SmithyFeatures>( | ||
context: HandlerExecutionContext, | ||
feature: F, | ||
value: SmithyFeatures[F] | ||
) { | ||
if (!context.__smithy_context) { | ||
context.__smithy_context = { | ||
features: {}, | ||
}; | ||
} else if (!context.__smithy_context.features) { | ||
context.__smithy_context.features = {}; | ||
} | ||
context.__smithy_context.features![feature] = value; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @internal | ||
*/ | ||
export type SmithyFeatures = Partial<{ | ||
RESOURCE_MODEL: "A"; | ||
WAITER: "B"; | ||
PAGINATOR: "C"; | ||
RETRY_MODE_LEGACY: "D"; | ||
RETRY_MODE_STANDARD: "E"; | ||
RETRY_MODE_ADAPTIVE: "F"; | ||
GZIP_REQUEST_COMPRESSION: "L"; | ||
PROTOCOL_RPC_V2_CBOR: "M"; | ||
ENDPOINT_OVERRIDE: "N"; | ||
SIGV4A_SIGNING: "S"; | ||
CREDENTIALS_CODE: "e"; | ||
CREDENTIALS_HTTP: "z"; | ||
CREDENTIALS_IMDS: "0"; | ||
}>; |
This file contains 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
This file contains 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