@smithy/types
Advanced tools
Comparing version 1.1.1 to 2.0.0
@@ -6,2 +6,3 @@ "use strict"; | ||
tslib_1.__exportStar(require("./auth"), exports); | ||
tslib_1.__exportStar(require("./blob/blob-payload-input-types"), exports); | ||
tslib_1.__exportStar(require("./checksum"), exports); | ||
@@ -28,5 +29,10 @@ tslib_1.__exportStar(require("./client"), exports); | ||
tslib_1.__exportStar(require("./stream"), exports); | ||
tslib_1.__exportStar(require("./streaming-payload/streaming-blob-common-types"), exports); | ||
tslib_1.__exportStar(require("./streaming-payload/streaming-blob-payload-input-types"), exports); | ||
tslib_1.__exportStar(require("./streaming-payload/streaming-blob-payload-output-types"), exports); | ||
tslib_1.__exportStar(require("./transfer"), exports); | ||
tslib_1.__exportStar(require("./transform/client-payload-blob-type-narrow"), exports); | ||
tslib_1.__exportStar(require("./transform/type-transform"), exports); | ||
tslib_1.__exportStar(require("./uri"), exports); | ||
tslib_1.__exportStar(require("./util"), exports); | ||
tslib_1.__exportStar(require("./waiter"), exports); |
export * from "./abort"; | ||
export * from "./auth"; | ||
export * from "./blob/blob-payload-input-types"; | ||
export * from "./checksum"; | ||
@@ -24,5 +25,10 @@ export * from "./client"; | ||
export * from "./stream"; | ||
export * from "./streaming-payload/streaming-blob-common-types"; | ||
export * from "./streaming-payload/streaming-blob-payload-input-types"; | ||
export * from "./streaming-payload/streaming-blob-payload-output-types"; | ||
export * from "./transfer"; | ||
export * from "./transform/client-payload-blob-type-narrow"; | ||
export * from "./transform/type-transform"; | ||
export * from "./uri"; | ||
export * from "./util"; | ||
export * from "./waiter"; |
@@ -9,4 +9,5 @@ import { Command } from "./command"; | ||
*/ | ||
interface InvokeFunction<InputTypes extends object, OutputTypes extends MetadataBearer, ResolvedClientConfiguration> { | ||
export interface InvokeFunction<InputTypes extends object, OutputTypes extends MetadataBearer, ResolvedClientConfiguration> { | ||
<InputType extends InputTypes, OutputType extends OutputTypes>(command: Command<InputTypes, InputType, OutputTypes, OutputType, ResolvedClientConfiguration>, options?: any): Promise<OutputType>; | ||
<InputType extends InputTypes, OutputType extends OutputTypes>(command: Command<InputTypes, InputType, OutputTypes, OutputType, ResolvedClientConfiguration>, cb: (err: any, data?: OutputType) => void): void; | ||
<InputType extends InputTypes, OutputType extends OutputTypes>(command: Command<InputTypes, InputType, OutputTypes, OutputType, ResolvedClientConfiguration>, options: any, cb: (err: any, data?: OutputType) => void): void; | ||
@@ -16,2 +17,13 @@ <InputType extends InputTypes, OutputType extends OutputTypes>(command: Command<InputTypes, InputType, OutputTypes, OutputType, ResolvedClientConfiguration>, options?: any, cb?: (err: any, data?: OutputType) => void): Promise<OutputType> | void; | ||
/** | ||
* @internal | ||
* | ||
* Signature that appears on aggregated clients' methods. | ||
*/ | ||
export interface InvokeMethod<InputType extends object, OutputType extends MetadataBearer> { | ||
(input: InputType, options?: any): Promise<OutputType>; | ||
(input: InputType, cb: (err: any, data?: OutputType) => void): void; | ||
(input: InputType, options: any, cb: (err: any, data?: OutputType) => void): void; | ||
(input: InputType, options?: any, cb?: (err: any, data?: OutputType) => void): Promise<OutputType> | void; | ||
} | ||
/** | ||
* A general interface for service clients, idempotent to browser or node clients | ||
@@ -27,2 +39,1 @@ * This type corresponds to SmithyClient(https://github.com/aws/aws-sdk-js-v3/blob/main/packages/smithy-client/src/client.ts). | ||
} | ||
export {}; |
export * from "./abort"; | ||
export * from "./auth"; | ||
export * from "./blob/blob-payload-input-types"; | ||
export * from "./checksum"; | ||
@@ -24,5 +25,10 @@ export * from "./client"; | ||
export * from "./stream"; | ||
export * from "./streaming-payload/streaming-blob-common-types"; | ||
export * from "./streaming-payload/streaming-blob-payload-input-types"; | ||
export * from "./streaming-payload/streaming-blob-payload-output-types"; | ||
export * from "./transfer"; | ||
export * from "./transform/client-payload-blob-type-narrow"; | ||
export * from "./transform/type-transform"; | ||
export * from "./uri"; | ||
export * from "./util"; | ||
export * from "./waiter"; |
@@ -9,4 +9,5 @@ import { Command } from "./command"; | ||
*/ | ||
interface InvokeFunction<InputTypes extends object, OutputTypes extends MetadataBearer, ResolvedClientConfiguration> { | ||
export interface InvokeFunction<InputTypes extends object, OutputTypes extends MetadataBearer, ResolvedClientConfiguration> { | ||
<InputType extends InputTypes, OutputType extends OutputTypes>(command: Command<InputTypes, InputType, OutputTypes, OutputType, ResolvedClientConfiguration>, options?: any): Promise<OutputType>; | ||
<InputType extends InputTypes, OutputType extends OutputTypes>(command: Command<InputTypes, InputType, OutputTypes, OutputType, ResolvedClientConfiguration>, cb: (err: any, data?: OutputType) => void): void; | ||
<InputType extends InputTypes, OutputType extends OutputTypes>(command: Command<InputTypes, InputType, OutputTypes, OutputType, ResolvedClientConfiguration>, options: any, cb: (err: any, data?: OutputType) => void): void; | ||
@@ -16,2 +17,13 @@ <InputType extends InputTypes, OutputType extends OutputTypes>(command: Command<InputTypes, InputType, OutputTypes, OutputType, ResolvedClientConfiguration>, options?: any, cb?: (err: any, data?: OutputType) => void): Promise<OutputType> | void; | ||
/** | ||
* @internal | ||
* | ||
* Signature that appears on aggregated clients' methods. | ||
*/ | ||
export interface InvokeMethod<InputType extends object, OutputType extends MetadataBearer> { | ||
(input: InputType, options?: any): Promise<OutputType>; | ||
(input: InputType, cb: (err: any, data?: OutputType) => void): void; | ||
(input: InputType, options: any, cb: (err: any, data?: OutputType) => void): void; | ||
(input: InputType, options?: any, cb?: (err: any, data?: OutputType) => void): Promise<OutputType> | void; | ||
} | ||
/** | ||
* A general interface for service clients, idempotent to browser or node clients | ||
@@ -27,2 +39,1 @@ * This type corresponds to SmithyClient(https://github.com/aws/aws-sdk-js-v3/blob/main/packages/smithy-client/src/client.ts). | ||
} | ||
export {}; |
export * from "./abort"; | ||
export * from "./auth"; | ||
export * from "./blob/blob-payload-input-types"; | ||
export * from "./checksum"; | ||
@@ -24,5 +25,10 @@ export * from "./client"; | ||
export * from "./stream"; | ||
export * from "./streaming-payload/streaming-blob-common-types"; | ||
export * from "./streaming-payload/streaming-blob-payload-input-types"; | ||
export * from "./streaming-payload/streaming-blob-payload-output-types"; | ||
export * from "./transfer"; | ||
export * from "./transform/client-payload-blob-type-narrow"; | ||
export * from "./transform/type-transform"; | ||
export * from "./uri"; | ||
export * from "./util"; | ||
export * from "./waiter"; |
{ | ||
"name": "@smithy/types", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"scripts": { | ||
@@ -14,3 +14,4 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'", | ||
"format": "prettier --config ../../prettier.config.js --ignore-path ../.prettierignore --write \"**/*.{ts,md,json}\"", | ||
"test": "tsc -p tsconfig.test.json" | ||
"test": "tsc -p tsconfig.test.json", | ||
"extract:docs": "api-extractor run --local" | ||
}, | ||
@@ -17,0 +18,0 @@ "main": "./dist-cjs/index.js", |
@@ -5,1 +5,38 @@ # @smithy/types | ||
[![NPM downloads](https://img.shields.io/npm/dm/@smithy/types.svg)](https://www.npmjs.com/package/@smithy/types) | ||
## Usage | ||
This package is mostly used internally by generated clients. | ||
Some public components have independent applications. | ||
### Scenario: Narrowing a smithy-typescript generated client's output payload blob types | ||
--- | ||
This is mostly relevant to operations with streaming bodies such as within | ||
the S3Client in the AWS SDK for JavaScript v3. | ||
Because blob payload types are platform dependent, you may wish to indicate in your application that a client is running in a specific | ||
environment. This narrows the blob payload types. | ||
```typescript | ||
import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3"; | ||
import type { NodeJsClient, SdkStream, StreamingBlobPayloadOutputTypes } from "@smithy/types"; | ||
import type { IncomingMessage } from "node:http"; | ||
// default client init. | ||
const s3Default = new S3Client({}); | ||
// client init with type narrowing. | ||
const s3NarrowType = new S3Client({}) as NodeJsClient<S3Client>; | ||
// The default type of blob payloads is a wide union type including multiple possible | ||
// request handlers. | ||
const body1: StreamingBlobPayloadOutputTypes = (await s3Default.send(new GetObjectCommand({ Key: "", Bucket: "" }))) | ||
.Body!; | ||
// This is of the narrower type SdkStream<IncomingMessage> representing | ||
// blob payload responses using specifically the node:http request handler. | ||
const body2: SdkStream<IncomingMessage> = (await s3NarrowType.send(new GetObjectCommand({ Key: "", Bucket: "" }))) | ||
.Body!; | ||
``` |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
185786
183
5087
42
1