@smithy/types
Advanced tools
Comparing version 2.5.0 to 2.6.0
@@ -34,2 +34,3 @@ "use strict"; | ||
tslib_1.__exportStar(require("./transform/client-payload-blob-type-narrow"), exports); | ||
tslib_1.__exportStar(require("./transform/no-undefined"), exports); | ||
tslib_1.__exportStar(require("./transform/type-transform"), exports); | ||
@@ -36,0 +37,0 @@ tslib_1.__exportStar(require("./uri"), exports); |
@@ -31,2 +31,3 @@ export * from "./abort"; | ||
export * from "./transform/client-payload-blob-type-narrow"; | ||
export * from "./transform/no-undefined"; | ||
export * from "./transform/type-transform"; | ||
@@ -33,0 +34,0 @@ export * from "./uri"; |
@@ -1,4 +0,16 @@ | ||
import { HttpRequest } from "../http"; | ||
import { HttpRequest, HttpResponse } from "../http"; | ||
import { Identity } from "../identity/identity"; | ||
/** | ||
* @internal | ||
*/ | ||
export interface ErrorHandler { | ||
(signingProperties: Record<string, unknown>): <E extends Error>(error: E) => never; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
export interface SuccessHandler { | ||
(httpResponse: HttpResponse | unknown, signingProperties: Record<string, unknown>): void; | ||
} | ||
/** | ||
* Interface to sign identity and signing properties. | ||
@@ -16,2 +28,15 @@ * @internal | ||
sign(httpRequest: HttpRequest, identity: Identity, signingProperties: Record<string, unknown>): Promise<HttpRequest>; | ||
/** | ||
* Handler that executes after the {@link HttpSigner.sign} invocation and corresponding | ||
* middleware throws an error. | ||
* The error handler is expected to throw the error it receives, so the return type of the error handler is `never`. | ||
* @internal | ||
*/ | ||
errorHandler?: ErrorHandler; | ||
/** | ||
* Handler that executes after the {@link HttpSigner.sign} invocation and corresponding | ||
* middleware succeeds. | ||
* @internal | ||
*/ | ||
successHandler?: SuccessHandler; | ||
} |
@@ -31,2 +31,3 @@ export * from "./abort"; | ||
export * from "./transform/client-payload-blob-type-narrow"; | ||
export * from "./transform/no-undefined"; | ||
export * from "./transform/type-transform"; | ||
@@ -33,0 +34,0 @@ export * from "./uri"; |
@@ -1,4 +0,16 @@ | ||
import { HttpRequest } from "../http"; | ||
import { HttpRequest, HttpResponse } from "../http"; | ||
import { Identity } from "../identity/identity"; | ||
/** | ||
* @internal | ||
*/ | ||
export interface ErrorHandler { | ||
(signingProperties: Record<string, unknown>): <E extends Error>(error: E) => never; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
export interface SuccessHandler { | ||
(httpResponse: HttpResponse | unknown, signingProperties: Record<string, unknown>): void; | ||
} | ||
/** | ||
* Interface to sign identity and signing properties. | ||
@@ -16,2 +28,15 @@ * @internal | ||
sign(httpRequest: HttpRequest, identity: Identity, signingProperties: Record<string, unknown>): Promise<HttpRequest>; | ||
/** | ||
* Handler that executes after the {@link HttpSigner.sign} invocation and corresponding | ||
* middleware throws an error. | ||
* The error handler is expected to throw the error it receives, so the return type of the error handler is `never`. | ||
* @internal | ||
*/ | ||
errorHandler?: ErrorHandler; | ||
/** | ||
* Handler that executes after the {@link HttpSigner.sign} invocation and corresponding | ||
* middleware succeeds. | ||
* @internal | ||
*/ | ||
successHandler?: SuccessHandler; | ||
} |
@@ -31,2 +31,3 @@ export * from "./abort"; | ||
export * from "./transform/client-payload-blob-type-narrow"; | ||
export * from "./transform/no-undefined"; | ||
export * from "./transform/type-transform"; | ||
@@ -33,0 +34,0 @@ export * from "./uri"; |
{ | ||
"name": "@smithy/types", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'", |
@@ -11,6 +11,45 @@ # @smithy/types | ||
--- | ||
### Scenario: Removing `| undefined` from input and output structures | ||
Generated shapes' members are unioned with `undefined` for | ||
input shapes, and are `?` (optional) for output shapes. | ||
- for inputs, this defers the validation to the service. | ||
- for outputs, this strongly suggests that you should runtime-check the output data. | ||
If you would like to skip these steps, use the `AssertiveClient` or | ||
`UncheckedClient` type helpers. | ||
Using AWS S3 as an example: | ||
```ts | ||
import { S3 } from "@aws-sdk/client-s3"; | ||
import type { AssertiveClient, UncheckedClient } from "@smithy/types"; | ||
const s3a = new S3({}) as AssertiveClient<S3>; | ||
const s3b = new S3({}) as UncheckedClient<S3>; | ||
// AssertiveClient enforces required inputs are not undefined | ||
// and required outputs are not undefined. | ||
const get = await s3a.getObject({ | ||
Bucket: "", | ||
Key: "", | ||
}); | ||
// UncheckedClient makes output fields non-nullable. | ||
// You should still perform type checks as you deem | ||
// necessary, but the SDK will no longer prompt you | ||
// with nullability errors. | ||
const body = await ( | ||
await s3b.getObject({ | ||
Bucket: "", | ||
Key: "", | ||
}) | ||
).Body.transformToString(); | ||
``` | ||
### Scenario: Narrowing a smithy-typescript generated client's output payload blob types | ||
--- | ||
This is mostly relevant to operations with streaming bodies such as within | ||
@@ -17,0 +56,0 @@ the S3Client in the AWS SDK for JavaScript v3. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
229582
251
6331
81