From 13401854523e996472f44b9943a5f56acb0f0b4d Mon Sep 17 00:00:00 2001 From: AllanZhengYP Date: Mon, 29 Aug 2022 21:50:59 +0000 Subject: [PATCH] feat(clients): support util functions to consume response streams --- clients/client-backupstorage/package.json | 2 ++ .../client-backupstorage/src/BackupStorageClient.ts | 7 +++++++ .../src/commands/GetChunkCommand.ts | 6 +++++- .../src/commands/GetObjectMetadataCommand.ts | 6 +++++- clients/client-backupstorage/src/models/models_0.ts | 11 ++++++----- .../src/protocols/Aws_restJson1.ts | 9 +++++---- .../client-backupstorage/src/runtimeConfig.browser.ts | 2 ++ clients/client-backupstorage/src/runtimeConfig.ts | 2 ++ .../client-cloudsearch-domain/src/models/models_0.ts | 3 ++- clients/client-codeartifact/package.json | 2 ++ clients/client-codeartifact/src/CodeartifactClient.ts | 7 +++++++ .../src/commands/GetPackageVersionAssetCommand.ts | 6 +++++- clients/client-codeartifact/src/models/models_0.ts | 3 ++- .../src/protocols/Aws_restJson1.ts | 5 +++-- .../client-codeartifact/src/runtimeConfig.browser.ts | 2 ++ clients/client-codeartifact/src/runtimeConfig.ts | 2 ++ clients/client-ebs/package.json | 2 ++ clients/client-ebs/src/EBSClient.ts | 7 +++++++ .../src/commands/GetSnapshotBlockCommand.ts | 6 +++++- clients/client-ebs/src/models/models_0.ts | 5 +++-- clients/client-ebs/src/protocols/Aws_restJson1.ts | 5 +++-- clients/client-ebs/src/runtimeConfig.browser.ts | 2 ++ clients/client-ebs/src/runtimeConfig.ts | 2 ++ clients/client-glacier/package.json | 2 ++ clients/client-glacier/src/GlacierClient.ts | 7 +++++++ .../src/commands/GetJobOutputCommand.ts | 6 +++++- clients/client-glacier/src/models/models_0.ts | 7 ++++--- clients/client-glacier/src/protocols/Aws_restJson1.ts | 5 +++-- clients/client-glacier/src/runtimeConfig.browser.ts | 2 ++ clients/client-glacier/src/runtimeConfig.ts | 2 ++ .../client-kinesis-video-archived-media/package.json | 2 ++ .../src/KinesisVideoArchivedMediaClient.ts | 7 +++++++ .../src/commands/GetClipCommand.ts | 6 +++++- .../src/commands/GetMediaForFragmentListCommand.ts | 6 +++++- .../src/models/models_0.ts | 5 +++-- .../src/protocols/Aws_restJson1.ts | 9 +++++---- .../src/runtimeConfig.browser.ts | 2 ++ .../src/runtimeConfig.ts | 2 ++ clients/client-kinesis-video-media/package.json | 2 ++ .../src/KinesisVideoMediaClient.ts | 7 +++++++ .../src/commands/GetMediaCommand.ts | 6 +++++- .../client-kinesis-video-media/src/models/models_0.ts | 3 ++- .../src/protocols/Aws_restJson1.ts | 5 +++-- .../src/runtimeConfig.browser.ts | 2 ++ .../client-kinesis-video-media/src/runtimeConfig.ts | 2 ++ clients/client-lakeformation/package.json | 2 ++ .../client-lakeformation/src/LakeFormationClient.ts | 7 +++++++ .../src/commands/GetWorkUnitResultsCommand.ts | 6 +++++- clients/client-lakeformation/src/models/models_0.ts | 3 ++- .../src/protocols/Aws_restJson1.ts | 5 +++-- .../client-lakeformation/src/runtimeConfig.browser.ts | 2 ++ clients/client-lakeformation/src/runtimeConfig.ts | 2 ++ clients/client-lambda/src/models/models_0.ts | 3 ++- clients/client-lex-runtime-service/package.json | 2 ++ .../src/LexRuntimeServiceClient.ts | 7 +++++++ .../src/commands/PostContentCommand.ts | 6 +++++- .../src/commands/PutSessionCommand.ts | 6 +++++- .../client-lex-runtime-service/src/models/models_0.ts | 7 ++++--- .../src/protocols/Aws_restJson1.ts | 9 +++++---- .../src/runtimeConfig.browser.ts | 2 ++ .../client-lex-runtime-service/src/runtimeConfig.ts | 2 ++ clients/client-lex-runtime-v2/package.json | 2 ++ .../client-lex-runtime-v2/src/LexRuntimeV2Client.ts | 7 +++++++ .../src/commands/PutSessionCommand.ts | 6 +++++- .../src/commands/RecognizeUtteranceCommand.ts | 6 +++++- clients/client-lex-runtime-v2/src/models/models_0.ts | 7 ++++--- .../src/protocols/Aws_restJson1.ts | 11 ++++++----- .../src/runtimeConfig.browser.ts | 2 ++ clients/client-lex-runtime-v2/src/runtimeConfig.ts | 2 ++ clients/client-lookoutvision/src/models/models_0.ts | 3 ++- clients/client-medialive/package.json | 2 ++ clients/client-medialive/src/MediaLiveClient.ts | 7 +++++++ .../commands/DescribeInputDeviceThumbnailCommand.ts | 3 ++- clients/client-medialive/src/models/models_1.ts | 3 ++- .../client-medialive/src/protocols/Aws_restJson1.ts | 5 +++-- clients/client-medialive/src/runtimeConfig.browser.ts | 2 ++ clients/client-medialive/src/runtimeConfig.ts | 2 ++ clients/client-mediastore-data/package.json | 2 ++ .../src/MediaStoreDataClient.ts | 7 +++++++ .../src/commands/GetObjectCommand.ts | 6 +++++- clients/client-mediastore-data/src/models/models_0.ts | 5 +++-- .../src/protocols/Aws_restJson1.ts | 5 +++-- .../src/runtimeConfig.browser.ts | 2 ++ clients/client-mediastore-data/src/runtimeConfig.ts | 2 ++ clients/client-polly/package.json | 2 ++ clients/client-polly/src/PollyClient.ts | 7 +++++++ .../src/commands/SynthesizeSpeechCommand.ts | 6 +++++- clients/client-polly/src/models/models_0.ts | 3 ++- clients/client-polly/src/protocols/Aws_restJson1.ts | 5 +++-- clients/client-polly/src/runtimeConfig.browser.ts | 2 ++ clients/client-polly/src/runtimeConfig.ts | 2 ++ clients/client-s3/src/S3Client.ts | 7 +++++++ clients/client-s3/src/commands/GetObjectCommand.ts | 6 +++++- .../client-s3/src/commands/GetObjectTorrentCommand.ts | 6 +++++- clients/client-s3/src/models/models_0.ts | 7 ++++--- clients/client-s3/src/models/models_1.ts | 5 +++-- clients/client-s3/src/protocols/Aws_restXml.ts | 11 ++++++----- clients/client-s3/src/runtimeConfig.browser.ts | 3 ++- clients/client-s3/src/runtimeConfig.ts | 3 ++- .../src/protocols/Aws_restJson1.ts | 4 ++-- clients/client-workmailmessageflow/package.json | 2 ++ .../src/WorkMailMessageFlowClient.ts | 7 +++++++ .../src/commands/GetRawMessageContentCommand.ts | 6 +++++- .../client-workmailmessageflow/src/models/models_0.ts | 3 ++- .../src/protocols/Aws_restJson1.ts | 5 +++-- .../src/runtimeConfig.browser.ts | 2 ++ .../client-workmailmessageflow/src/runtimeConfig.ts | 2 ++ private/aws-protocoltests-restjson/package.json | 2 ++ .../src/RestJsonProtocolClient.ts | 7 +++++++ .../src/commands/StreamingTraitsCommand.ts | 6 +++++- .../commands/StreamingTraitsWithMediaTypeCommand.ts | 3 ++- .../aws-protocoltests-restjson/src/models/models_0.ts | 8 ++++---- .../src/protocols/Aws_restJson1.ts | 9 +++++---- .../src/runtimeConfig.browser.ts | 2 ++ .../aws-protocoltests-restjson/src/runtimeConfig.ts | 2 ++ 115 files changed, 409 insertions(+), 107 deletions(-) diff --git a/clients/client-backupstorage/package.json b/clients/client-backupstorage/package.json index cd7389dcff61b..0aba7a0e0ac1a 100644 --- a/clients/client-backupstorage/package.json +++ b/clients/client-backupstorage/package.json @@ -45,6 +45,8 @@ "@aws-sdk/util-body-length-node": "*", "@aws-sdk/util-defaults-mode-browser": "*", "@aws-sdk/util-defaults-mode-node": "*", + "@aws-sdk/util-stream-browser": "*", + "@aws-sdk/util-stream-node": "*", "@aws-sdk/util-user-agent-browser": "*", "@aws-sdk/util-user-agent-node": "*", "@aws-sdk/util-utf8-browser": "*", diff --git a/clients/client-backupstorage/src/BackupStorageClient.ts b/clients/client-backupstorage/src/BackupStorageClient.ts index 4b2076d547a95..a1abdee67c3ec 100644 --- a/clients/client-backupstorage/src/BackupStorageClient.ts +++ b/clients/client-backupstorage/src/BackupStorageClient.ts @@ -48,6 +48,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent, @@ -214,6 +215,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type BackupStorageClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/clients/client-backupstorage/src/commands/GetChunkCommand.ts b/clients/client-backupstorage/src/commands/GetChunkCommand.ts index c92219f7b4ca0..9468c21a40bc5 100644 --- a/clients/client-backupstorage/src/commands/GetChunkCommand.ts +++ b/clients/client-backupstorage/src/commands/GetChunkCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -92,7 +93,10 @@ export class GetChunkCommand extends $Command< return serializeAws_restJson1GetChunkCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1GetChunkCommand(output, context); } diff --git a/clients/client-backupstorage/src/commands/GetObjectMetadataCommand.ts b/clients/client-backupstorage/src/commands/GetObjectMetadataCommand.ts index 1a2adeb7f9d5e..c4157dfdc8cce 100644 --- a/clients/client-backupstorage/src/commands/GetObjectMetadataCommand.ts +++ b/clients/client-backupstorage/src/commands/GetObjectMetadataCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -92,7 +93,10 @@ export class GetObjectMetadataCommand extends $Command< return serializeAws_restJson1GetObjectMetadataCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1GetObjectMetadataCommand(output, context); } diff --git a/clients/client-backupstorage/src/models/models_0.ts b/clients/client-backupstorage/src/models/models_0.ts index f2a67baad2571..7dcbbf1e2519c 100644 --- a/clients/client-backupstorage/src/models/models_0.ts +++ b/clients/client-backupstorage/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { BackupStorageServiceException as __BaseException } from "./BackupStorageServiceException"; @@ -250,7 +251,7 @@ export interface GetChunkOutput { /** * Chunk data */ - Data: Readable | ReadableStream | Blob | undefined; + Data: SdkStream | undefined; /** * Data length @@ -310,7 +311,7 @@ export interface GetObjectMetadataOutput { /** * Metadata blob. */ - MetadataBlob?: Readable | ReadableStream | Blob; + MetadataBlob?: SdkStream; /** * The size of MetadataBlob. @@ -440,7 +441,7 @@ export interface NotifyObjectCompleteInput { /** * Optional metadata associated with an Object. Maximum length is 4MB. */ - MetadataBlob?: Readable | ReadableStream | Blob; + MetadataBlob?: SdkStream; /** * The size of MetadataBlob. @@ -510,7 +511,7 @@ export interface PutChunkInput { /** * Data to be uploaded */ - Data: Readable | ReadableStream | Blob | undefined; + Data: SdkStream | undefined; /** * Data length @@ -559,7 +560,7 @@ export interface PutObjectInput { /** * Inline chunk data to be uploaded. */ - InlineChunk?: Readable | ReadableStream | Blob; + InlineChunk?: SdkStream; /** * Length of the inline chunk data. diff --git a/clients/client-backupstorage/src/protocols/Aws_restJson1.ts b/clients/client-backupstorage/src/protocols/Aws_restJson1.ts index dcc7eb27af324..1e301b85274a1 100644 --- a/clients/client-backupstorage/src/protocols/Aws_restJson1.ts +++ b/clients/client-backupstorage/src/protocols/Aws_restJson1.ts @@ -15,6 +15,7 @@ import { import { Endpoint as __Endpoint, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -413,7 +414,7 @@ const deserializeAws_restJson1DeleteObjectCommandError = async ( export const deserializeAws_restJson1GetChunkCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1GetChunkCommandError(output, context); @@ -427,7 +428,7 @@ export const deserializeAws_restJson1GetChunkCommand = async ( Checksum: [, output.headers["x-amz-checksum"]], ChecksumAlgorithm: [, output.headers["x-amz-checksum-algorithm"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.Data = data; return contents; }; @@ -476,7 +477,7 @@ const deserializeAws_restJson1GetChunkCommandError = async ( export const deserializeAws_restJson1GetObjectMetadataCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1GetObjectMetadataCommandError(output, context); @@ -491,7 +492,7 @@ export const deserializeAws_restJson1GetObjectMetadataCommand = async ( MetadataBlobChecksum: [, output.headers["x-amz-checksum"]], MetadataBlobChecksumAlgorithm: [, output.headers["x-amz-checksum-algorithm"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.MetadataBlob = data; return contents; }; diff --git a/clients/client-backupstorage/src/runtimeConfig.browser.ts b/clients/client-backupstorage/src/runtimeConfig.browser.ts index 3d063d2afd4ee..ad6617e7317b3 100644 --- a/clients/client-backupstorage/src/runtimeConfig.browser.ts +++ b/clients/client-backupstorage/src/runtimeConfig.browser.ts @@ -9,6 +9,7 @@ import { invalidProvider } from "@aws-sdk/invalid-dependency"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { BackupStorageClientConfig } from "./BackupStorageClient"; @@ -40,6 +41,7 @@ export const getRuntimeConfig = (config: BackupStorageClientConfig) => { region: config?.region ?? invalidProvider("Region is missing"), requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), diff --git a/clients/client-backupstorage/src/runtimeConfig.ts b/clients/client-backupstorage/src/runtimeConfig.ts index dce2e609bd9ba..41149c350c145 100644 --- a/clients/client-backupstorage/src/runtimeConfig.ts +++ b/clients/client-backupstorage/src/runtimeConfig.ts @@ -20,6 +20,7 @@ import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider"; import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/node-http-handler"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { BackupStorageClientConfig } from "./BackupStorageClient"; @@ -58,6 +59,7 @@ export const getRuntimeConfig = (config: BackupStorageClientConfig) => { ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), diff --git a/clients/client-cloudsearch-domain/src/models/models_0.ts b/clients/client-cloudsearch-domain/src/models/models_0.ts index 25cbc2db03095..b1ddec1de700e 100644 --- a/clients/client-cloudsearch-domain/src/models/models_0.ts +++ b/clients/client-cloudsearch-domain/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { CloudSearchDomainServiceException as __BaseException } from "./CloudSearchDomainServiceException"; @@ -598,7 +599,7 @@ export interface UploadDocumentsRequest { /** *

A batch of documents formatted in JSON or HTML.

*/ - documents: Readable | ReadableStream | Blob | undefined; + documents: SdkStream | undefined; /** *

The format of the batch you are uploading. Amazon CloudSearch supports two document batch formats:

diff --git a/clients/client-codeartifact/package.json b/clients/client-codeartifact/package.json index 2da3cda76280d..0f63846c13132 100644 --- a/clients/client-codeartifact/package.json +++ b/clients/client-codeartifact/package.json @@ -45,6 +45,8 @@ "@aws-sdk/util-body-length-node": "*", "@aws-sdk/util-defaults-mode-browser": "*", "@aws-sdk/util-defaults-mode-node": "*", + "@aws-sdk/util-stream-browser": "*", + "@aws-sdk/util-stream-node": "*", "@aws-sdk/util-user-agent-browser": "*", "@aws-sdk/util-user-agent-node": "*", "@aws-sdk/util-utf8-browser": "*", diff --git a/clients/client-codeartifact/src/CodeartifactClient.ts b/clients/client-codeartifact/src/CodeartifactClient.ts index 539fed88979a7..eef16d70c8b8e 100644 --- a/clients/client-codeartifact/src/CodeartifactClient.ts +++ b/clients/client-codeartifact/src/CodeartifactClient.ts @@ -48,6 +48,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent, @@ -361,6 +362,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type CodeartifactClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/clients/client-codeartifact/src/commands/GetPackageVersionAssetCommand.ts b/clients/client-codeartifact/src/commands/GetPackageVersionAssetCommand.ts index a3da897addb45..c4dc6c7196360 100644 --- a/clients/client-codeartifact/src/commands/GetPackageVersionAssetCommand.ts +++ b/clients/client-codeartifact/src/commands/GetPackageVersionAssetCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -96,7 +97,10 @@ export class GetPackageVersionAssetCommand extends $Command< return serializeAws_restJson1GetPackageVersionAssetCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1GetPackageVersionAssetCommand(output, context); } diff --git a/clients/client-codeartifact/src/models/models_0.ts b/clients/client-codeartifact/src/models/models_0.ts index 72de44f80e40a..f410e205b8384 100644 --- a/clients/client-codeartifact/src/models/models_0.ts +++ b/clients/client-codeartifact/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { CodeartifactServiceException as __BaseException } from "./CodeartifactServiceException"; @@ -1978,7 +1979,7 @@ export interface GetPackageVersionAssetResult { /** *

The binary file, or asset, that is downloaded.

*/ - asset?: Readable | ReadableStream | Blob; + asset?: SdkStream; /** *

diff --git a/clients/client-codeartifact/src/protocols/Aws_restJson1.ts b/clients/client-codeartifact/src/protocols/Aws_restJson1.ts index 5d02cd6e48310..d44f4ea4424f4 100644 --- a/clients/client-codeartifact/src/protocols/Aws_restJson1.ts +++ b/clients/client-codeartifact/src/protocols/Aws_restJson1.ts @@ -17,6 +17,7 @@ import { import { Endpoint as __Endpoint, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -2188,7 +2189,7 @@ const deserializeAws_restJson1GetDomainPermissionsPolicyCommandError = async ( export const deserializeAws_restJson1GetPackageVersionAssetCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1GetPackageVersionAssetCommandError(output, context); @@ -2199,7 +2200,7 @@ export const deserializeAws_restJson1GetPackageVersionAssetCommand = async ( packageVersion: [, output.headers["x-packageversion"]], packageVersionRevision: [, output.headers["x-packageversionrevision"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.asset = data; return contents; }; diff --git a/clients/client-codeartifact/src/runtimeConfig.browser.ts b/clients/client-codeartifact/src/runtimeConfig.browser.ts index 64f6ad573f496..7e818c7cc02be 100644 --- a/clients/client-codeartifact/src/runtimeConfig.browser.ts +++ b/clients/client-codeartifact/src/runtimeConfig.browser.ts @@ -9,6 +9,7 @@ import { invalidProvider } from "@aws-sdk/invalid-dependency"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { CodeartifactClientConfig } from "./CodeartifactClient"; @@ -40,6 +41,7 @@ export const getRuntimeConfig = (config: CodeartifactClientConfig) => { region: config?.region ?? invalidProvider("Region is missing"), requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), diff --git a/clients/client-codeartifact/src/runtimeConfig.ts b/clients/client-codeartifact/src/runtimeConfig.ts index e984ed57d1782..2d11dbc399460 100644 --- a/clients/client-codeartifact/src/runtimeConfig.ts +++ b/clients/client-codeartifact/src/runtimeConfig.ts @@ -20,6 +20,7 @@ import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider"; import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/node-http-handler"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { CodeartifactClientConfig } from "./CodeartifactClient"; @@ -58,6 +59,7 @@ export const getRuntimeConfig = (config: CodeartifactClientConfig) => { ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), diff --git a/clients/client-ebs/package.json b/clients/client-ebs/package.json index 662cf00d18c36..f6e3325bf6570 100644 --- a/clients/client-ebs/package.json +++ b/clients/client-ebs/package.json @@ -45,6 +45,8 @@ "@aws-sdk/util-body-length-node": "*", "@aws-sdk/util-defaults-mode-browser": "*", "@aws-sdk/util-defaults-mode-node": "*", + "@aws-sdk/util-stream-browser": "*", + "@aws-sdk/util-stream-node": "*", "@aws-sdk/util-user-agent-browser": "*", "@aws-sdk/util-user-agent-node": "*", "@aws-sdk/util-utf8-browser": "*", diff --git a/clients/client-ebs/src/EBSClient.ts b/clients/client-ebs/src/EBSClient.ts index 17e8ea837905a..b71871a2a39af 100644 --- a/clients/client-ebs/src/EBSClient.ts +++ b/clients/client-ebs/src/EBSClient.ts @@ -48,6 +48,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent, @@ -202,6 +203,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type EBSClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/clients/client-ebs/src/commands/GetSnapshotBlockCommand.ts b/clients/client-ebs/src/commands/GetSnapshotBlockCommand.ts index 49e88c6d44dd1..398567b9e18bc 100644 --- a/clients/client-ebs/src/commands/GetSnapshotBlockCommand.ts +++ b/clients/client-ebs/src/commands/GetSnapshotBlockCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -92,7 +93,10 @@ export class GetSnapshotBlockCommand extends $Command< return serializeAws_restJson1GetSnapshotBlockCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1GetSnapshotBlockCommand(output, context); } diff --git a/clients/client-ebs/src/models/models_0.ts b/clients/client-ebs/src/models/models_0.ts index 385b62ee5c850..45744bd9082dc 100644 --- a/clients/client-ebs/src/models/models_0.ts +++ b/clients/client-ebs/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { EBSServiceException as __BaseException } from "./EBSServiceException"; @@ -368,7 +369,7 @@ export interface GetSnapshotBlockResponse { /** *

The data content of the block.

*/ - BlockData?: Readable | ReadableStream | Blob; + BlockData?: SdkStream; /** *

The checksum generated for the block, which is Base64 encoded.

@@ -554,7 +555,7 @@ export interface PutSnapshotBlockRequest { * Using checksums with the EBS direct APIs in the Amazon Elastic Compute Cloud User * Guide.

*/ - BlockData: Readable | ReadableStream | Blob | undefined; + BlockData: SdkStream | undefined; /** *

The size of the data to write to the block, in bytes. Currently, the only supported diff --git a/clients/client-ebs/src/protocols/Aws_restJson1.ts b/clients/client-ebs/src/protocols/Aws_restJson1.ts index e2571656ee442..ffffae5af58e3 100644 --- a/clients/client-ebs/src/protocols/Aws_restJson1.ts +++ b/clients/client-ebs/src/protocols/Aws_restJson1.ts @@ -18,6 +18,7 @@ import { import { Endpoint as __Endpoint, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; import { v4 as generateIdempotencyToken } from "uuid"; @@ -298,7 +299,7 @@ const deserializeAws_restJson1CompleteSnapshotCommandError = async ( export const deserializeAws_restJson1GetSnapshotBlockCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1GetSnapshotBlockCommandError(output, context); @@ -312,7 +313,7 @@ export const deserializeAws_restJson1GetSnapshotBlockCommand = async ( Checksum: [, output.headers["x-amz-checksum"]], ChecksumAlgorithm: [, output.headers["x-amz-checksum-algorithm"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.BlockData = data; return contents; }; diff --git a/clients/client-ebs/src/runtimeConfig.browser.ts b/clients/client-ebs/src/runtimeConfig.browser.ts index c6cdbfdb6787b..5d9f03d19c75a 100644 --- a/clients/client-ebs/src/runtimeConfig.browser.ts +++ b/clients/client-ebs/src/runtimeConfig.browser.ts @@ -9,6 +9,7 @@ import { invalidProvider } from "@aws-sdk/invalid-dependency"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { EBSClientConfig } from "./EBSClient"; @@ -40,6 +41,7 @@ export const getRuntimeConfig = (config: EBSClientConfig) => { region: config?.region ?? invalidProvider("Region is missing"), requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), diff --git a/clients/client-ebs/src/runtimeConfig.ts b/clients/client-ebs/src/runtimeConfig.ts index 1d4346b77e433..1cba43c972959 100644 --- a/clients/client-ebs/src/runtimeConfig.ts +++ b/clients/client-ebs/src/runtimeConfig.ts @@ -20,6 +20,7 @@ import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider"; import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/node-http-handler"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { EBSClientConfig } from "./EBSClient"; @@ -58,6 +59,7 @@ export const getRuntimeConfig = (config: EBSClientConfig) => { ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), diff --git a/clients/client-glacier/package.json b/clients/client-glacier/package.json index a44798800f3c5..6a7fc2d3a3124 100644 --- a/clients/client-glacier/package.json +++ b/clients/client-glacier/package.json @@ -48,6 +48,8 @@ "@aws-sdk/util-body-length-node": "*", "@aws-sdk/util-defaults-mode-browser": "*", "@aws-sdk/util-defaults-mode-node": "*", + "@aws-sdk/util-stream-browser": "*", + "@aws-sdk/util-stream-node": "*", "@aws-sdk/util-user-agent-browser": "*", "@aws-sdk/util-user-agent-node": "*", "@aws-sdk/util-utf8-browser": "*", diff --git a/clients/client-glacier/src/GlacierClient.ts b/clients/client-glacier/src/GlacierClient.ts index 4cfb639e9be60..b60d8f5d09fe0 100644 --- a/clients/client-glacier/src/GlacierClient.ts +++ b/clients/client-glacier/src/GlacierClient.ts @@ -50,6 +50,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent, @@ -342,6 +343,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type GlacierClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/clients/client-glacier/src/commands/GetJobOutputCommand.ts b/clients/client-glacier/src/commands/GetJobOutputCommand.ts index 82dbba1416dc8..aae8498ecf247 100644 --- a/clients/client-glacier/src/commands/GetJobOutputCommand.ts +++ b/clients/client-glacier/src/commands/GetJobOutputCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -128,7 +129,10 @@ export class GetJobOutputCommand extends $Command< return serializeAws_restJson1GetJobOutputCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1GetJobOutputCommand(output, context); } diff --git a/clients/client-glacier/src/models/models_0.ts b/clients/client-glacier/src/models/models_0.ts index 98edf9f465201..30953d2c91898 100644 --- a/clients/client-glacier/src/models/models_0.ts +++ b/clients/client-glacier/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { GlacierServiceException as __BaseException } from "./GlacierServiceException"; @@ -1145,7 +1146,7 @@ export interface GetJobOutputOutput { /** *

The job data, either archive data or inventory data.

*/ - body?: Readable | ReadableStream | Blob; + body?: SdkStream; /** *

The checksum of the data in the response. This header is returned only when @@ -2179,7 +2180,7 @@ export interface UploadArchiveInput { /** *

The data to upload.

*/ - body?: Readable | ReadableStream | Blob; + body?: SdkStream; } /** @@ -2222,7 +2223,7 @@ export interface UploadMultipartPartInput { /** *

The data to upload.

*/ - body?: Readable | ReadableStream | Blob; + body?: SdkStream; } /** diff --git a/clients/client-glacier/src/protocols/Aws_restJson1.ts b/clients/client-glacier/src/protocols/Aws_restJson1.ts index 9da38521198a5..efd77591d2d04 100644 --- a/clients/client-glacier/src/protocols/Aws_restJson1.ts +++ b/clients/client-glacier/src/protocols/Aws_restJson1.ts @@ -15,6 +15,7 @@ import { import { Endpoint as __Endpoint, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -1688,7 +1689,7 @@ const deserializeAws_restJson1GetDataRetrievalPolicyCommandError = async ( export const deserializeAws_restJson1GetJobOutputCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1GetJobOutputCommandError(output, context); @@ -1701,7 +1702,7 @@ export const deserializeAws_restJson1GetJobOutputCommand = async ( contentType: [, output.headers["content-type"]], archiveDescription: [, output.headers["x-amz-archive-description"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.body = data; map(contents, { status: [, output.statusCode], diff --git a/clients/client-glacier/src/runtimeConfig.browser.ts b/clients/client-glacier/src/runtimeConfig.browser.ts index c4568ae6d7f5b..2f3d4efea38b3 100644 --- a/clients/client-glacier/src/runtimeConfig.browser.ts +++ b/clients/client-glacier/src/runtimeConfig.browser.ts @@ -10,6 +10,7 @@ import { invalidProvider } from "@aws-sdk/invalid-dependency"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { GlacierClientConfig } from "./GlacierClient"; @@ -42,6 +43,7 @@ export const getRuntimeConfig = (config: GlacierClientConfig) => { region: config?.region ?? invalidProvider("Region is missing"), requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), diff --git a/clients/client-glacier/src/runtimeConfig.ts b/clients/client-glacier/src/runtimeConfig.ts index a74390bb3929e..6c748cd9eea2e 100644 --- a/clients/client-glacier/src/runtimeConfig.ts +++ b/clients/client-glacier/src/runtimeConfig.ts @@ -21,6 +21,7 @@ import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider"; import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/node-http-handler"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { GlacierClientConfig } from "./GlacierClient"; @@ -60,6 +61,7 @@ export const getRuntimeConfig = (config: GlacierClientConfig) => { ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), diff --git a/clients/client-kinesis-video-archived-media/package.json b/clients/client-kinesis-video-archived-media/package.json index 5bc60ad6a750d..5d16b28b8e2d8 100644 --- a/clients/client-kinesis-video-archived-media/package.json +++ b/clients/client-kinesis-video-archived-media/package.json @@ -45,6 +45,8 @@ "@aws-sdk/util-body-length-node": "*", "@aws-sdk/util-defaults-mode-browser": "*", "@aws-sdk/util-defaults-mode-node": "*", + "@aws-sdk/util-stream-browser": "*", + "@aws-sdk/util-stream-node": "*", "@aws-sdk/util-user-agent-browser": "*", "@aws-sdk/util-user-agent-node": "*", "@aws-sdk/util-utf8-browser": "*", diff --git a/clients/client-kinesis-video-archived-media/src/KinesisVideoArchivedMediaClient.ts b/clients/client-kinesis-video-archived-media/src/KinesisVideoArchivedMediaClient.ts index bf5ec0308814c..9fe39b8821925 100644 --- a/clients/client-kinesis-video-archived-media/src/KinesisVideoArchivedMediaClient.ts +++ b/clients/client-kinesis-video-archived-media/src/KinesisVideoArchivedMediaClient.ts @@ -48,6 +48,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent, @@ -211,6 +212,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type KinesisVideoArchivedMediaClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/clients/client-kinesis-video-archived-media/src/commands/GetClipCommand.ts b/clients/client-kinesis-video-archived-media/src/commands/GetClipCommand.ts index fcc7974618d46..990684bf8dc4d 100644 --- a/clients/client-kinesis-video-archived-media/src/commands/GetClipCommand.ts +++ b/clients/client-kinesis-video-archived-media/src/commands/GetClipCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -136,7 +137,10 @@ export class GetClipCommand extends $Command< return serializeAws_restJson1GetClipCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1GetClipCommand(output, context); } diff --git a/clients/client-kinesis-video-archived-media/src/commands/GetMediaForFragmentListCommand.ts b/clients/client-kinesis-video-archived-media/src/commands/GetMediaForFragmentListCommand.ts index 588018dadc844..62dc908916b31 100644 --- a/clients/client-kinesis-video-archived-media/src/commands/GetMediaForFragmentListCommand.ts +++ b/clients/client-kinesis-video-archived-media/src/commands/GetMediaForFragmentListCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -132,7 +133,10 @@ export class GetMediaForFragmentListCommand extends $Command< return serializeAws_restJson1GetMediaForFragmentListCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1GetMediaForFragmentListCommand(output, context); } diff --git a/clients/client-kinesis-video-archived-media/src/models/models_0.ts b/clients/client-kinesis-video-archived-media/src/models/models_0.ts index c7277c2d1d361..d5b8d28a7d18c 100644 --- a/clients/client-kinesis-video-archived-media/src/models/models_0.ts +++ b/clients/client-kinesis-video-archived-media/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { KinesisVideoArchivedMediaServiceException as __BaseException } from "./KinesisVideoArchivedMediaServiceException"; @@ -109,7 +110,7 @@ export interface GetClipOutput { * timestamp. For more information, see Kinesis * Video Streams Limits.

*/ - Payload?: Readable | ReadableStream | Blob; + Payload?: SdkStream; } /** @@ -1060,7 +1061,7 @@ export interface GetMediaForFragmentListOutput { * * */ - Payload?: Readable | ReadableStream | Blob; + Payload?: SdkStream; } export enum FragmentSelectorType { diff --git a/clients/client-kinesis-video-archived-media/src/protocols/Aws_restJson1.ts b/clients/client-kinesis-video-archived-media/src/protocols/Aws_restJson1.ts index 5e3d76e504104..f7d7008b3e636 100644 --- a/clients/client-kinesis-video-archived-media/src/protocols/Aws_restJson1.ts +++ b/clients/client-kinesis-video-archived-media/src/protocols/Aws_restJson1.ts @@ -14,6 +14,7 @@ import { import { Endpoint as __Endpoint, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -251,7 +252,7 @@ export const serializeAws_restJson1ListFragmentsCommand = async ( export const deserializeAws_restJson1GetClipCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1GetClipCommandError(output, context); @@ -260,7 +261,7 @@ export const deserializeAws_restJson1GetClipCommand = async ( $metadata: deserializeMetadata(output), ContentType: [, output.headers["content-type"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.Payload = data; return contents; }; @@ -492,7 +493,7 @@ const deserializeAws_restJson1GetImagesCommandError = async ( export const deserializeAws_restJson1GetMediaForFragmentListCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1GetMediaForFragmentListCommandError(output, context); @@ -501,7 +502,7 @@ export const deserializeAws_restJson1GetMediaForFragmentListCommand = async ( $metadata: deserializeMetadata(output), ContentType: [, output.headers["content-type"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.Payload = data; return contents; }; diff --git a/clients/client-kinesis-video-archived-media/src/runtimeConfig.browser.ts b/clients/client-kinesis-video-archived-media/src/runtimeConfig.browser.ts index 5fea8883c687d..c03a1581ddbe7 100644 --- a/clients/client-kinesis-video-archived-media/src/runtimeConfig.browser.ts +++ b/clients/client-kinesis-video-archived-media/src/runtimeConfig.browser.ts @@ -9,6 +9,7 @@ import { invalidProvider } from "@aws-sdk/invalid-dependency"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { KinesisVideoArchivedMediaClientConfig } from "./KinesisVideoArchivedMediaClient"; @@ -40,6 +41,7 @@ export const getRuntimeConfig = (config: KinesisVideoArchivedMediaClientConfig) region: config?.region ?? invalidProvider("Region is missing"), requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), diff --git a/clients/client-kinesis-video-archived-media/src/runtimeConfig.ts b/clients/client-kinesis-video-archived-media/src/runtimeConfig.ts index 8085176320dfe..fe695dee8017d 100644 --- a/clients/client-kinesis-video-archived-media/src/runtimeConfig.ts +++ b/clients/client-kinesis-video-archived-media/src/runtimeConfig.ts @@ -20,6 +20,7 @@ import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider"; import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/node-http-handler"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { KinesisVideoArchivedMediaClientConfig } from "./KinesisVideoArchivedMediaClient"; @@ -58,6 +59,7 @@ export const getRuntimeConfig = (config: KinesisVideoArchivedMediaClientConfig) ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), diff --git a/clients/client-kinesis-video-media/package.json b/clients/client-kinesis-video-media/package.json index bce79c18a2f2f..3281398cbc1c7 100644 --- a/clients/client-kinesis-video-media/package.json +++ b/clients/client-kinesis-video-media/package.json @@ -45,6 +45,8 @@ "@aws-sdk/util-body-length-node": "*", "@aws-sdk/util-defaults-mode-browser": "*", "@aws-sdk/util-defaults-mode-node": "*", + "@aws-sdk/util-stream-browser": "*", + "@aws-sdk/util-stream-node": "*", "@aws-sdk/util-user-agent-browser": "*", "@aws-sdk/util-user-agent-node": "*", "@aws-sdk/util-utf8-browser": "*", diff --git a/clients/client-kinesis-video-media/src/KinesisVideoMediaClient.ts b/clients/client-kinesis-video-media/src/KinesisVideoMediaClient.ts index 790aac82d9a42..acc7d51be1cc9 100644 --- a/clients/client-kinesis-video-media/src/KinesisVideoMediaClient.ts +++ b/clients/client-kinesis-video-media/src/KinesisVideoMediaClient.ts @@ -48,6 +48,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent, @@ -185,6 +186,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type KinesisVideoMediaClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/clients/client-kinesis-video-media/src/commands/GetMediaCommand.ts b/clients/client-kinesis-video-media/src/commands/GetMediaCommand.ts index 355ee8729094d..e34805c17e1cb 100644 --- a/clients/client-kinesis-video-media/src/commands/GetMediaCommand.ts +++ b/clients/client-kinesis-video-media/src/commands/GetMediaCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -141,7 +142,10 @@ export class GetMediaCommand extends $Command< return serializeAws_restJson1GetMediaCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1GetMediaCommand(output, context); } diff --git a/clients/client-kinesis-video-media/src/models/models_0.ts b/clients/client-kinesis-video-media/src/models/models_0.ts index f77ade0a0e276..4aeb8bb1ce171 100644 --- a/clients/client-kinesis-video-media/src/models/models_0.ts +++ b/clients/client-kinesis-video-media/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { KinesisVideoMediaServiceException as __BaseException } from "./KinesisVideoMediaServiceException"; @@ -227,7 +228,7 @@ export interface GetMediaOutput { * * */ - Payload?: Readable | ReadableStream | Blob; + Payload?: SdkStream; } /** diff --git a/clients/client-kinesis-video-media/src/protocols/Aws_restJson1.ts b/clients/client-kinesis-video-media/src/protocols/Aws_restJson1.ts index 83ddebc7c5b50..e4677e2d1b39a 100644 --- a/clients/client-kinesis-video-media/src/protocols/Aws_restJson1.ts +++ b/clients/client-kinesis-video-media/src/protocols/Aws_restJson1.ts @@ -9,6 +9,7 @@ import { import { Endpoint as __Endpoint, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -54,7 +55,7 @@ export const serializeAws_restJson1GetMediaCommand = async ( export const deserializeAws_restJson1GetMediaCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1GetMediaCommandError(output, context); @@ -63,7 +64,7 @@ export const deserializeAws_restJson1GetMediaCommand = async ( $metadata: deserializeMetadata(output), ContentType: [, output.headers["content-type"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.Payload = data; return contents; }; diff --git a/clients/client-kinesis-video-media/src/runtimeConfig.browser.ts b/clients/client-kinesis-video-media/src/runtimeConfig.browser.ts index f454bfbd29719..6dee3484a3651 100644 --- a/clients/client-kinesis-video-media/src/runtimeConfig.browser.ts +++ b/clients/client-kinesis-video-media/src/runtimeConfig.browser.ts @@ -9,6 +9,7 @@ import { invalidProvider } from "@aws-sdk/invalid-dependency"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { KinesisVideoMediaClientConfig } from "./KinesisVideoMediaClient"; @@ -40,6 +41,7 @@ export const getRuntimeConfig = (config: KinesisVideoMediaClientConfig) => { region: config?.region ?? invalidProvider("Region is missing"), requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), diff --git a/clients/client-kinesis-video-media/src/runtimeConfig.ts b/clients/client-kinesis-video-media/src/runtimeConfig.ts index 7dde02d846589..4212345e82053 100644 --- a/clients/client-kinesis-video-media/src/runtimeConfig.ts +++ b/clients/client-kinesis-video-media/src/runtimeConfig.ts @@ -20,6 +20,7 @@ import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider"; import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/node-http-handler"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { KinesisVideoMediaClientConfig } from "./KinesisVideoMediaClient"; @@ -58,6 +59,7 @@ export const getRuntimeConfig = (config: KinesisVideoMediaClientConfig) => { ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), diff --git a/clients/client-lakeformation/package.json b/clients/client-lakeformation/package.json index ce9136cc4eeab..b93edac14df40 100644 --- a/clients/client-lakeformation/package.json +++ b/clients/client-lakeformation/package.json @@ -45,6 +45,8 @@ "@aws-sdk/util-body-length-node": "*", "@aws-sdk/util-defaults-mode-browser": "*", "@aws-sdk/util-defaults-mode-node": "*", + "@aws-sdk/util-stream-browser": "*", + "@aws-sdk/util-stream-node": "*", "@aws-sdk/util-user-agent-browser": "*", "@aws-sdk/util-user-agent-node": "*", "@aws-sdk/util-utf8-browser": "*", diff --git a/clients/client-lakeformation/src/LakeFormationClient.ts b/clients/client-lakeformation/src/LakeFormationClient.ts index ac99cee650128..bd52458ca6831 100644 --- a/clients/client-lakeformation/src/LakeFormationClient.ts +++ b/clients/client-lakeformation/src/LakeFormationClient.ts @@ -48,6 +48,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent, @@ -376,6 +377,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type LakeFormationClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/clients/client-lakeformation/src/commands/GetWorkUnitResultsCommand.ts b/clients/client-lakeformation/src/commands/GetWorkUnitResultsCommand.ts index 6a806517dd95c..406e60cb5385f 100644 --- a/clients/client-lakeformation/src/commands/GetWorkUnitResultsCommand.ts +++ b/clients/client-lakeformation/src/commands/GetWorkUnitResultsCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -92,7 +93,10 @@ export class GetWorkUnitResultsCommand extends $Command< return serializeAws_restJson1GetWorkUnitResultsCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1GetWorkUnitResultsCommand(output, context); } diff --git a/clients/client-lakeformation/src/models/models_0.ts b/clients/client-lakeformation/src/models/models_0.ts index 464ed0ced7866..3ba8005a1a261 100644 --- a/clients/client-lakeformation/src/models/models_0.ts +++ b/clients/client-lakeformation/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { LakeFormationServiceException as __BaseException } from "./LakeFormationServiceException"; @@ -1810,7 +1811,7 @@ export interface GetWorkUnitResultsResponse { /** *

Rows returned from the GetWorkUnitResults operation as a stream of Apache Arrow v1.0 messages.

*/ - ResultStream?: Readable | ReadableStream | Blob; + ResultStream?: SdkStream; } export interface GetWorkUnitsRequest { diff --git a/clients/client-lakeformation/src/protocols/Aws_restJson1.ts b/clients/client-lakeformation/src/protocols/Aws_restJson1.ts index 29cf0afcd359d..dc07fc1870aa1 100644 --- a/clients/client-lakeformation/src/protocols/Aws_restJson1.ts +++ b/clients/client-lakeformation/src/protocols/Aws_restJson1.ts @@ -20,6 +20,7 @@ import { import { Endpoint as __Endpoint, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -2762,7 +2763,7 @@ const deserializeAws_restJson1GetTemporaryGlueTableCredentialsCommandError = asy export const deserializeAws_restJson1GetWorkUnitResultsCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1GetWorkUnitResultsCommandError(output, context); @@ -2770,7 +2771,7 @@ export const deserializeAws_restJson1GetWorkUnitResultsCommand = async ( const contents: any = map({ $metadata: deserializeMetadata(output), }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.ResultStream = data; return contents; }; diff --git a/clients/client-lakeformation/src/runtimeConfig.browser.ts b/clients/client-lakeformation/src/runtimeConfig.browser.ts index 3505c5cfc03a7..811ba637a5a88 100644 --- a/clients/client-lakeformation/src/runtimeConfig.browser.ts +++ b/clients/client-lakeformation/src/runtimeConfig.browser.ts @@ -9,6 +9,7 @@ import { invalidProvider } from "@aws-sdk/invalid-dependency"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { LakeFormationClientConfig } from "./LakeFormationClient"; @@ -40,6 +41,7 @@ export const getRuntimeConfig = (config: LakeFormationClientConfig) => { region: config?.region ?? invalidProvider("Region is missing"), requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), diff --git a/clients/client-lakeformation/src/runtimeConfig.ts b/clients/client-lakeformation/src/runtimeConfig.ts index a6342cd944bc4..4908a366e1c78 100644 --- a/clients/client-lakeformation/src/runtimeConfig.ts +++ b/clients/client-lakeformation/src/runtimeConfig.ts @@ -20,6 +20,7 @@ import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider"; import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/node-http-handler"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { LakeFormationClientConfig } from "./LakeFormationClient"; @@ -58,6 +59,7 @@ export const getRuntimeConfig = (config: LakeFormationClientConfig) => { ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), diff --git a/clients/client-lambda/src/models/models_0.ts b/clients/client-lambda/src/models/models_0.ts index 38043f1707d34..a6235cc44479a 100644 --- a/clients/client-lambda/src/models/models_0.ts +++ b/clients/client-lambda/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { LambdaServiceException as __BaseException } from "./LambdaServiceException"; @@ -3515,7 +3516,7 @@ export interface InvokeAsyncRequest { /** *

The JSON that you want to provide to your Lambda function as input.

*/ - InvokeArgs: Readable | ReadableStream | Blob | undefined; + InvokeArgs: SdkStream | undefined; } /** diff --git a/clients/client-lex-runtime-service/package.json b/clients/client-lex-runtime-service/package.json index 6d7a29ff638c9..2d6b15ef3e4d3 100644 --- a/clients/client-lex-runtime-service/package.json +++ b/clients/client-lex-runtime-service/package.json @@ -47,6 +47,8 @@ "@aws-sdk/util-body-length-node": "*", "@aws-sdk/util-defaults-mode-browser": "*", "@aws-sdk/util-defaults-mode-node": "*", + "@aws-sdk/util-stream-browser": "*", + "@aws-sdk/util-stream-node": "*", "@aws-sdk/util-user-agent-browser": "*", "@aws-sdk/util-user-agent-node": "*", "@aws-sdk/util-utf8-browser": "*", diff --git a/clients/client-lex-runtime-service/src/LexRuntimeServiceClient.ts b/clients/client-lex-runtime-service/src/LexRuntimeServiceClient.ts index fc9101bde6b56..bcd357c75acbe 100644 --- a/clients/client-lex-runtime-service/src/LexRuntimeServiceClient.ts +++ b/clients/client-lex-runtime-service/src/LexRuntimeServiceClient.ts @@ -48,6 +48,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent, @@ -199,6 +200,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type LexRuntimeServiceClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/clients/client-lex-runtime-service/src/commands/PostContentCommand.ts b/clients/client-lex-runtime-service/src/commands/PostContentCommand.ts index b202713705b81..f1f91f6fa93b9 100644 --- a/clients/client-lex-runtime-service/src/commands/PostContentCommand.ts +++ b/clients/client-lex-runtime-service/src/commands/PostContentCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -181,7 +182,10 @@ export class PostContentCommand extends $Command< return serializeAws_restJson1PostContentCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1PostContentCommand(output, context); } diff --git a/clients/client-lex-runtime-service/src/commands/PutSessionCommand.ts b/clients/client-lex-runtime-service/src/commands/PutSessionCommand.ts index 8d2a37d11ea9e..18ea74d82be43 100644 --- a/clients/client-lex-runtime-service/src/commands/PutSessionCommand.ts +++ b/clients/client-lex-runtime-service/src/commands/PutSessionCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -100,7 +101,10 @@ export class PutSessionCommand extends $Command< return serializeAws_restJson1PutSessionCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1PutSessionCommand(output, context); } diff --git a/clients/client-lex-runtime-service/src/models/models_0.ts b/clients/client-lex-runtime-service/src/models/models_0.ts index 2e7b370b5e50e..5ba8a97c9fbc5 100644 --- a/clients/client-lex-runtime-service/src/models/models_0.ts +++ b/clients/client-lex-runtime-service/src/models/models_0.ts @@ -4,6 +4,7 @@ import { LazyJsonString as __LazyJsonString, SENSITIVE_STRING, } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { LexRuntimeServiceServiceException as __BaseException } from "./LexRuntimeServiceServiceException"; @@ -780,7 +781,7 @@ export interface PostContentRequest { * better performance if you stream audio data rather than buffering the data * locally.

*/ - inputStream: Readable | ReadableStream | Blob | undefined; + inputStream: SdkStream | undefined; /** *

A list of contexts active for the request. A context can be activated @@ -1043,7 +1044,7 @@ export interface PostContentResponse { * intent, and sent a message to convey to the user. Then Amazon Lex sends that * message in the response.

*/ - audioStream?: Readable | ReadableStream | Blob; + audioStream?: SdkStream; /** *

The version of the bot that responded to the conversation. You can use @@ -1770,7 +1771,7 @@ export interface PutSessionResponse { /** *

The audio version of the message to convey to the user.

*/ - audioStream?: Readable | ReadableStream | Blob; + audioStream?: SdkStream; /** *

A unique identifier for the session.

diff --git a/clients/client-lex-runtime-service/src/protocols/Aws_restJson1.ts b/clients/client-lex-runtime-service/src/protocols/Aws_restJson1.ts index 28ef5c63f59d1..ea00e546efaea 100644 --- a/clients/client-lex-runtime-service/src/protocols/Aws_restJson1.ts +++ b/clients/client-lex-runtime-service/src/protocols/Aws_restJson1.ts @@ -16,6 +16,7 @@ import { import { Endpoint as __Endpoint, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -349,7 +350,7 @@ const deserializeAws_restJson1GetSessionCommandError = async ( export const deserializeAws_restJson1PostContentCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1PostContentCommandError(output, context); @@ -402,7 +403,7 @@ export const deserializeAws_restJson1PostContentCommand = async ( ), ], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.audioStream = data; return contents; }; @@ -564,7 +565,7 @@ const deserializeAws_restJson1PostTextCommandError = async ( export const deserializeAws_restJson1PutSessionCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1PutSessionCommandError(output, context); @@ -599,7 +600,7 @@ export const deserializeAws_restJson1PutSessionCommand = async ( ), ], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.audioStream = data; return contents; }; diff --git a/clients/client-lex-runtime-service/src/runtimeConfig.browser.ts b/clients/client-lex-runtime-service/src/runtimeConfig.browser.ts index ee856f41f54cd..17fc89a6ee11e 100644 --- a/clients/client-lex-runtime-service/src/runtimeConfig.browser.ts +++ b/clients/client-lex-runtime-service/src/runtimeConfig.browser.ts @@ -9,6 +9,7 @@ import { invalidProvider } from "@aws-sdk/invalid-dependency"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { LexRuntimeServiceClientConfig } from "./LexRuntimeServiceClient"; @@ -40,6 +41,7 @@ export const getRuntimeConfig = (config: LexRuntimeServiceClientConfig) => { region: config?.region ?? invalidProvider("Region is missing"), requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), diff --git a/clients/client-lex-runtime-service/src/runtimeConfig.ts b/clients/client-lex-runtime-service/src/runtimeConfig.ts index 8b220da41b355..b84d3be514395 100644 --- a/clients/client-lex-runtime-service/src/runtimeConfig.ts +++ b/clients/client-lex-runtime-service/src/runtimeConfig.ts @@ -20,6 +20,7 @@ import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider"; import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/node-http-handler"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { LexRuntimeServiceClientConfig } from "./LexRuntimeServiceClient"; @@ -58,6 +59,7 @@ export const getRuntimeConfig = (config: LexRuntimeServiceClientConfig) => { ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), diff --git a/clients/client-lex-runtime-v2/package.json b/clients/client-lex-runtime-v2/package.json index dd4af00bda898..e277d9b5adf2f 100644 --- a/clients/client-lex-runtime-v2/package.json +++ b/clients/client-lex-runtime-v2/package.json @@ -50,6 +50,8 @@ "@aws-sdk/util-body-length-node": "*", "@aws-sdk/util-defaults-mode-browser": "*", "@aws-sdk/util-defaults-mode-node": "*", + "@aws-sdk/util-stream-browser": "*", + "@aws-sdk/util-stream-node": "*", "@aws-sdk/util-user-agent-browser": "*", "@aws-sdk/util-user-agent-node": "*", "@aws-sdk/util-utf8-browser": "*", diff --git a/clients/client-lex-runtime-v2/src/LexRuntimeV2Client.ts b/clients/client-lex-runtime-v2/src/LexRuntimeV2Client.ts index 1e87cb3f8609f..deaa073f70ac9 100644 --- a/clients/client-lex-runtime-v2/src/LexRuntimeV2Client.ts +++ b/clients/client-lex-runtime-v2/src/LexRuntimeV2Client.ts @@ -60,6 +60,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent, @@ -225,6 +226,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type LexRuntimeV2ClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/clients/client-lex-runtime-v2/src/commands/PutSessionCommand.ts b/clients/client-lex-runtime-v2/src/commands/PutSessionCommand.ts index 420626dff02ea..9f63474f08a6b 100644 --- a/clients/client-lex-runtime-v2/src/commands/PutSessionCommand.ts +++ b/clients/client-lex-runtime-v2/src/commands/PutSessionCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -94,7 +95,10 @@ export class PutSessionCommand extends $Command< return serializeAws_restJson1PutSessionCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1PutSessionCommand(output, context); } diff --git a/clients/client-lex-runtime-v2/src/commands/RecognizeUtteranceCommand.ts b/clients/client-lex-runtime-v2/src/commands/RecognizeUtteranceCommand.ts index 14405cbddea7e..062187944380b 100644 --- a/clients/client-lex-runtime-v2/src/commands/RecognizeUtteranceCommand.ts +++ b/clients/client-lex-runtime-v2/src/commands/RecognizeUtteranceCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -163,7 +164,10 @@ export class RecognizeUtteranceCommand extends $Command< return serializeAws_restJson1RecognizeUtteranceCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1RecognizeUtteranceCommand(output, context); } diff --git a/clients/client-lex-runtime-v2/src/models/models_0.ts b/clients/client-lex-runtime-v2/src/models/models_0.ts index 5b2f1744a49af..0573757f640f3 100644 --- a/clients/client-lex-runtime-v2/src/models/models_0.ts +++ b/clients/client-lex-runtime-v2/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { LexRuntimeV2ServiceException as __BaseException } from "./LexRuntimeV2ServiceException"; @@ -696,7 +697,7 @@ export interface PutSessionResponse { *

If the requested content type was audio, the audio version of the * message to convey to the user.

*/ - audioStream?: Readable | ReadableStream | Blob; + audioStream?: SdkStream; } export interface RecognizeUtteranceRequest { @@ -831,7 +832,7 @@ export interface RecognizeUtteranceRequest { *

User input in PCM or Opus audio format or text format as described * in the requestContentType parameter.

*/ - inputStream?: Readable | ReadableStream | Blob; + inputStream?: SdkStream; } export interface RecognizeUtteranceResponse { @@ -924,7 +925,7 @@ export interface RecognizeUtteranceResponse { * to convey to the user. Then Amazon Lex V2 sends that message in the * response.

*/ - audioStream?: Readable | ReadableStream | Blob; + audioStream?: SdkStream; } export enum ConversationMode { diff --git a/clients/client-lex-runtime-v2/src/protocols/Aws_restJson1.ts b/clients/client-lex-runtime-v2/src/protocols/Aws_restJson1.ts index f6b09d228be3a..d9239659991a6 100644 --- a/clients/client-lex-runtime-v2/src/protocols/Aws_restJson1.ts +++ b/clients/client-lex-runtime-v2/src/protocols/Aws_restJson1.ts @@ -17,6 +17,7 @@ import { Message as __Message, MessageHeaders as __MessageHeaders, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -385,7 +386,7 @@ const deserializeAws_restJson1GetSessionCommandError = async ( export const deserializeAws_restJson1PutSessionCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1PutSessionCommandError(output, context); @@ -398,7 +399,7 @@ export const deserializeAws_restJson1PutSessionCommand = async ( requestAttributes: [, output.headers["x-amz-lex-request-attributes"]], sessionId: [, output.headers["x-amz-lex-session-id"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.audioStream = data; return contents; }; @@ -524,7 +525,7 @@ const deserializeAws_restJson1RecognizeTextCommandError = async ( export const deserializeAws_restJson1RecognizeUtteranceCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1RecognizeUtteranceCommandError(output, context); @@ -540,7 +541,7 @@ export const deserializeAws_restJson1RecognizeUtteranceCommand = async ( sessionId: [, output.headers["x-amz-lex-session-id"]], inputTranscript: [, output.headers["x-amz-lex-input-transcript"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.audioStream = data; return contents; }; @@ -600,7 +601,7 @@ export const deserializeAws_restJson1StartConversationCommand = async ( const contents: any = map({ $metadata: deserializeMetadata(output), }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.responseEventStream = deserializeAws_restJson1StartConversationResponseEventStream(data, context); return contents; }; diff --git a/clients/client-lex-runtime-v2/src/runtimeConfig.browser.ts b/clients/client-lex-runtime-v2/src/runtimeConfig.browser.ts index 906779baf08d3..24073ec5a1533 100644 --- a/clients/client-lex-runtime-v2/src/runtimeConfig.browser.ts +++ b/clients/client-lex-runtime-v2/src/runtimeConfig.browser.ts @@ -10,6 +10,7 @@ import { invalidFunction, invalidProvider } from "@aws-sdk/invalid-dependency"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { LexRuntimeV2ClientConfig } from "./LexRuntimeV2Client"; @@ -45,6 +46,7 @@ export const getRuntimeConfig = (config: LexRuntimeV2ClientConfig) => { region: config?.region ?? invalidProvider("Region is missing"), requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), diff --git a/clients/client-lex-runtime-v2/src/runtimeConfig.ts b/clients/client-lex-runtime-v2/src/runtimeConfig.ts index 8f8f8a994aa31..834e1d2c43508 100644 --- a/clients/client-lex-runtime-v2/src/runtimeConfig.ts +++ b/clients/client-lex-runtime-v2/src/runtimeConfig.ts @@ -22,6 +22,7 @@ import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider"; import { NodeHttp2Handler as RequestHandler, streamCollector } from "@aws-sdk/node-http-handler"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { LexRuntimeV2ClientConfig } from "./LexRuntimeV2Client"; @@ -64,6 +65,7 @@ export const getRuntimeConfig = (config: LexRuntimeV2ClientConfig) => { ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), diff --git a/clients/client-lookoutvision/src/models/models_0.ts b/clients/client-lookoutvision/src/models/models_0.ts index fb367d53343dc..d4d13219ec2e8 100644 --- a/clients/client-lookoutvision/src/models/models_0.ts +++ b/clients/client-lookoutvision/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { LookoutVisionServiceException as __BaseException } from "./LookoutVisionServiceException"; @@ -1259,7 +1260,7 @@ export interface DetectAnomaliesRequest { /** *

The unencrypted image bytes that you want to analyze.

*/ - Body: Readable | ReadableStream | Blob | undefined; + Body: SdkStream | undefined; /** *

The type of the image passed in Body. diff --git a/clients/client-medialive/package.json b/clients/client-medialive/package.json index d4a2671807c04..c386f9427851c 100644 --- a/clients/client-medialive/package.json +++ b/clients/client-medialive/package.json @@ -45,6 +45,8 @@ "@aws-sdk/util-body-length-node": "*", "@aws-sdk/util-defaults-mode-browser": "*", "@aws-sdk/util-defaults-mode-node": "*", + "@aws-sdk/util-stream-browser": "*", + "@aws-sdk/util-stream-node": "*", "@aws-sdk/util-user-agent-browser": "*", "@aws-sdk/util-user-agent-node": "*", "@aws-sdk/util-utf8-browser": "*", diff --git a/clients/client-medialive/src/MediaLiveClient.ts b/clients/client-medialive/src/MediaLiveClient.ts index f210201a36cbf..3d73c544c08cf 100644 --- a/clients/client-medialive/src/MediaLiveClient.ts +++ b/clients/client-medialive/src/MediaLiveClient.ts @@ -48,6 +48,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent, @@ -424,6 +425,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type MediaLiveClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/clients/client-medialive/src/commands/DescribeInputDeviceThumbnailCommand.ts b/clients/client-medialive/src/commands/DescribeInputDeviceThumbnailCommand.ts index dfa0968a8ee1f..4e72da554f432 100644 --- a/clients/client-medialive/src/commands/DescribeInputDeviceThumbnailCommand.ts +++ b/clients/client-medialive/src/commands/DescribeInputDeviceThumbnailCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -96,7 +97,7 @@ export class DescribeInputDeviceThumbnailCommand extends $Command< private deserialize( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise { return deserializeAws_restJson1DescribeInputDeviceThumbnailCommand(output, context); } diff --git a/clients/client-medialive/src/models/models_1.ts b/clients/client-medialive/src/models/models_1.ts index 168a50dd4b88f..7a2128b60b73b 100644 --- a/clients/client-medialive/src/models/models_1.ts +++ b/clients/client-medialive/src/models/models_1.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { MediaLiveServiceException as __BaseException } from "./MediaLiveServiceException"; @@ -4730,7 +4731,7 @@ export interface DescribeInputDeviceThumbnailResponse { /** * The binary data for the thumbnail that the Link device has most recently sent to MediaLive. */ - Body?: Readable | ReadableStream | Blob; + Body?: SdkStream; /** * Specifies the media type of the thumbnail. diff --git a/clients/client-medialive/src/protocols/Aws_restJson1.ts b/clients/client-medialive/src/protocols/Aws_restJson1.ts index 5d8cec9fed266..25f652da4c338 100644 --- a/clients/client-medialive/src/protocols/Aws_restJson1.ts +++ b/clients/client-medialive/src/protocols/Aws_restJson1.ts @@ -19,6 +19,7 @@ import { import { Endpoint as __Endpoint, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; import { v4 as generateIdempotencyToken } from "uuid"; @@ -3816,7 +3817,7 @@ const deserializeAws_restJson1DescribeInputDeviceCommandError = async ( export const deserializeAws_restJson1DescribeInputDeviceThumbnailCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1DescribeInputDeviceThumbnailCommandError(output, context); @@ -3834,7 +3835,7 @@ export const deserializeAws_restJson1DescribeInputDeviceThumbnailCommand = async () => __expectNonNull(__parseRfc7231DateTime(output.headers["last-modified"])), ], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.Body = data; return contents; }; diff --git a/clients/client-medialive/src/runtimeConfig.browser.ts b/clients/client-medialive/src/runtimeConfig.browser.ts index 6e9182e4a3649..765f95bfa642d 100644 --- a/clients/client-medialive/src/runtimeConfig.browser.ts +++ b/clients/client-medialive/src/runtimeConfig.browser.ts @@ -9,6 +9,7 @@ import { invalidProvider } from "@aws-sdk/invalid-dependency"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { MediaLiveClientConfig } from "./MediaLiveClient"; @@ -40,6 +41,7 @@ export const getRuntimeConfig = (config: MediaLiveClientConfig) => { region: config?.region ?? invalidProvider("Region is missing"), requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), diff --git a/clients/client-medialive/src/runtimeConfig.ts b/clients/client-medialive/src/runtimeConfig.ts index d940d8ca8264d..061a75ee1ec35 100644 --- a/clients/client-medialive/src/runtimeConfig.ts +++ b/clients/client-medialive/src/runtimeConfig.ts @@ -20,6 +20,7 @@ import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider"; import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/node-http-handler"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { MediaLiveClientConfig } from "./MediaLiveClient"; @@ -58,6 +59,7 @@ export const getRuntimeConfig = (config: MediaLiveClientConfig) => { ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), diff --git a/clients/client-mediastore-data/package.json b/clients/client-mediastore-data/package.json index 4301ebd258d2b..c1ebebea0d32c 100644 --- a/clients/client-mediastore-data/package.json +++ b/clients/client-mediastore-data/package.json @@ -47,6 +47,8 @@ "@aws-sdk/util-body-length-node": "*", "@aws-sdk/util-defaults-mode-browser": "*", "@aws-sdk/util-defaults-mode-node": "*", + "@aws-sdk/util-stream-browser": "*", + "@aws-sdk/util-stream-node": "*", "@aws-sdk/util-user-agent-browser": "*", "@aws-sdk/util-user-agent-node": "*", "@aws-sdk/util-utf8-browser": "*", diff --git a/clients/client-mediastore-data/src/MediaStoreDataClient.ts b/clients/client-mediastore-data/src/MediaStoreDataClient.ts index c6daf31a758b5..5976b652989a1 100644 --- a/clients/client-mediastore-data/src/MediaStoreDataClient.ts +++ b/clients/client-mediastore-data/src/MediaStoreDataClient.ts @@ -48,6 +48,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent, @@ -199,6 +200,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type MediaStoreDataClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/clients/client-mediastore-data/src/commands/GetObjectCommand.ts b/clients/client-mediastore-data/src/commands/GetObjectCommand.ts index 86c33156f32f7..212cf3e766989 100644 --- a/clients/client-mediastore-data/src/commands/GetObjectCommand.ts +++ b/clients/client-mediastore-data/src/commands/GetObjectCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -92,7 +93,10 @@ export class GetObjectCommand extends $Command< return serializeAws_restJson1GetObjectCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1GetObjectCommand(output, context); } diff --git a/clients/client-mediastore-data/src/models/models_0.ts b/clients/client-mediastore-data/src/models/models_0.ts index 48472ed3ace92..8e42e2c689f69 100644 --- a/clients/client-mediastore-data/src/models/models_0.ts +++ b/clients/client-mediastore-data/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { MediaStoreDataServiceException as __BaseException } from "./MediaStoreDataServiceException"; @@ -148,7 +149,7 @@ export interface GetObjectResponse { /** *

The bytes of the object.

*/ - Body?: Readable | ReadableStream | Blob; + Body?: SdkStream; /** *

An optional CacheControl header that allows the caller to control the @@ -309,7 +310,7 @@ export interface PutObjectRequest { /** *

The bytes to be stored.

*/ - Body: Readable | ReadableStream | Blob | undefined; + Body: SdkStream | undefined; /** *

The path (including the file name) where the object is stored in the container. diff --git a/clients/client-mediastore-data/src/protocols/Aws_restJson1.ts b/clients/client-mediastore-data/src/protocols/Aws_restJson1.ts index e89ddf8850a5f..f6e7ebc12ed66 100644 --- a/clients/client-mediastore-data/src/protocols/Aws_restJson1.ts +++ b/clients/client-mediastore-data/src/protocols/Aws_restJson1.ts @@ -18,6 +18,7 @@ import { import { Endpoint as __Endpoint, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -252,7 +253,7 @@ const deserializeAws_restJson1DescribeObjectCommandError = async ( export const deserializeAws_restJson1GetObjectCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1GetObjectCommandError(output, context); @@ -272,7 +273,7 @@ export const deserializeAws_restJson1GetObjectCommand = async ( () => __expectNonNull(__parseRfc7231DateTime(output.headers["last-modified"])), ], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.Body = data; map(contents, { StatusCode: [, output.statusCode], diff --git a/clients/client-mediastore-data/src/runtimeConfig.browser.ts b/clients/client-mediastore-data/src/runtimeConfig.browser.ts index 05704798527dc..287a4413d2eb6 100644 --- a/clients/client-mediastore-data/src/runtimeConfig.browser.ts +++ b/clients/client-mediastore-data/src/runtimeConfig.browser.ts @@ -9,6 +9,7 @@ import { invalidProvider } from "@aws-sdk/invalid-dependency"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { MediaStoreDataClientConfig } from "./MediaStoreDataClient"; @@ -40,6 +41,7 @@ export const getRuntimeConfig = (config: MediaStoreDataClientConfig) => { region: config?.region ?? invalidProvider("Region is missing"), requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), diff --git a/clients/client-mediastore-data/src/runtimeConfig.ts b/clients/client-mediastore-data/src/runtimeConfig.ts index 18236c66cf8a3..da8578a55e387 100644 --- a/clients/client-mediastore-data/src/runtimeConfig.ts +++ b/clients/client-mediastore-data/src/runtimeConfig.ts @@ -20,6 +20,7 @@ import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider"; import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/node-http-handler"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { MediaStoreDataClientConfig } from "./MediaStoreDataClient"; @@ -58,6 +59,7 @@ export const getRuntimeConfig = (config: MediaStoreDataClientConfig) => { ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), diff --git a/clients/client-polly/package.json b/clients/client-polly/package.json index 0bd9cad996bcf..840136dce1e7c 100644 --- a/clients/client-polly/package.json +++ b/clients/client-polly/package.json @@ -45,6 +45,8 @@ "@aws-sdk/util-body-length-node": "*", "@aws-sdk/util-defaults-mode-browser": "*", "@aws-sdk/util-defaults-mode-node": "*", + "@aws-sdk/util-stream-browser": "*", + "@aws-sdk/util-stream-node": "*", "@aws-sdk/util-user-agent-browser": "*", "@aws-sdk/util-user-agent-node": "*", "@aws-sdk/util-utf8-browser": "*", diff --git a/clients/client-polly/src/PollyClient.ts b/clients/client-polly/src/PollyClient.ts index d70202c81e613..cd98561acdc48 100644 --- a/clients/client-polly/src/PollyClient.ts +++ b/clients/client-polly/src/PollyClient.ts @@ -48,6 +48,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent, @@ -220,6 +221,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type PollyClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/clients/client-polly/src/commands/SynthesizeSpeechCommand.ts b/clients/client-polly/src/commands/SynthesizeSpeechCommand.ts index ef30fbda5002f..bc414c1851389 100644 --- a/clients/client-polly/src/commands/SynthesizeSpeechCommand.ts +++ b/clients/client-polly/src/commands/SynthesizeSpeechCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -96,7 +97,10 @@ export class SynthesizeSpeechCommand extends $Command< return serializeAws_restJson1SynthesizeSpeechCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1SynthesizeSpeechCommand(output, context); } diff --git a/clients/client-polly/src/models/models_0.ts b/clients/client-polly/src/models/models_0.ts index 6a6a6819074fc..47c2782615b47 100644 --- a/clients/client-polly/src/models/models_0.ts +++ b/clients/client-polly/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { PollyServiceException as __BaseException } from "./PollyServiceException"; @@ -1157,7 +1158,7 @@ export interface SynthesizeSpeechOutput { /** *

Stream containing the synthesized speech.

*/ - AudioStream?: Readable | ReadableStream | Blob; + AudioStream?: SdkStream; /** *

Specifies the type audio stream. This should reflect the diff --git a/clients/client-polly/src/protocols/Aws_restJson1.ts b/clients/client-polly/src/protocols/Aws_restJson1.ts index 69988136996f1..810da71ad465d 100644 --- a/clients/client-polly/src/protocols/Aws_restJson1.ts +++ b/clients/client-polly/src/protocols/Aws_restJson1.ts @@ -17,6 +17,7 @@ import { import { Endpoint as __Endpoint, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -717,7 +718,7 @@ const deserializeAws_restJson1StartSpeechSynthesisTaskCommandError = async ( export const deserializeAws_restJson1SynthesizeSpeechCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1SynthesizeSpeechCommandError(output, context); @@ -730,7 +731,7 @@ export const deserializeAws_restJson1SynthesizeSpeechCommand = async ( () => __strictParseInt32(output.headers["x-amzn-requestcharacters"]), ], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.AudioStream = data; return contents; }; diff --git a/clients/client-polly/src/runtimeConfig.browser.ts b/clients/client-polly/src/runtimeConfig.browser.ts index fb047315c1211..d77f8c0f5d4a9 100644 --- a/clients/client-polly/src/runtimeConfig.browser.ts +++ b/clients/client-polly/src/runtimeConfig.browser.ts @@ -9,6 +9,7 @@ import { invalidProvider } from "@aws-sdk/invalid-dependency"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { PollyClientConfig } from "./PollyClient"; @@ -40,6 +41,7 @@ export const getRuntimeConfig = (config: PollyClientConfig) => { region: config?.region ?? invalidProvider("Region is missing"), requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), diff --git a/clients/client-polly/src/runtimeConfig.ts b/clients/client-polly/src/runtimeConfig.ts index a21cdf3d5f602..c82525387486d 100644 --- a/clients/client-polly/src/runtimeConfig.ts +++ b/clients/client-polly/src/runtimeConfig.ts @@ -20,6 +20,7 @@ import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider"; import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/node-http-handler"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { PollyClientConfig } from "./PollyClient"; @@ -58,6 +59,7 @@ export const getRuntimeConfig = (config: PollyClientConfig) => { ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), diff --git a/clients/client-s3/src/S3Client.ts b/clients/client-s3/src/S3Client.ts index 9eed461978be2..4cb1de3076f18 100644 --- a/clients/client-s3/src/S3Client.ts +++ b/clients/client-s3/src/S3Client.ts @@ -62,6 +62,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, StreamHasher as __StreamHasher, UrlParser as __UrlParser, @@ -676,6 +677,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type S3ClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/clients/client-s3/src/commands/GetObjectCommand.ts b/clients/client-s3/src/commands/GetObjectCommand.ts index 50eb9e18865b9..28c4c98ea927e 100644 --- a/clients/client-s3/src/commands/GetObjectCommand.ts +++ b/clients/client-s3/src/commands/GetObjectCommand.ts @@ -12,6 +12,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -279,7 +280,10 @@ export class GetObjectCommand extends $Command { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restXmlGetObjectCommand(output, context); } diff --git a/clients/client-s3/src/commands/GetObjectTorrentCommand.ts b/clients/client-s3/src/commands/GetObjectTorrentCommand.ts index fe48aeadc2ac4..1b4617e74f95c 100644 --- a/clients/client-s3/src/commands/GetObjectTorrentCommand.ts +++ b/clients/client-s3/src/commands/GetObjectTorrentCommand.ts @@ -10,6 +10,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -110,7 +111,10 @@ export class GetObjectTorrentCommand extends $Command< return serializeAws_restXmlGetObjectTorrentCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restXmlGetObjectTorrentCommand(output, context); } diff --git a/clients/client-s3/src/models/models_0.ts b/clients/client-s3/src/models/models_0.ts index 36d0b340aecab..a01d188c19470 100644 --- a/clients/client-s3/src/models/models_0.ts +++ b/clients/client-s3/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { S3ServiceException as __BaseException } from "./S3ServiceException"; @@ -6108,7 +6109,7 @@ export interface GetObjectOutput { /** *

Object data.

*/ - Body?: Readable | ReadableStream | Blob; + Body?: SdkStream; /** *

Specifies whether the object retrieved was (true) or was not (false) a Delete Marker. If @@ -7064,7 +7065,7 @@ export interface GetObjectTorrentOutput { /** *

A Bencoded dictionary as defined by the BitTorrent specification

*/ - Body?: Readable | ReadableStream | Blob; + Body?: SdkStream; /** *

If present, indicates that the requester was successfully charged for the @@ -9725,7 +9726,7 @@ export interface PutObjectRequest { /** *

Object data.

*/ - Body?: Readable | ReadableStream | Blob; + Body?: SdkStream; /** *

The bucket name to which the PUT action was initiated.

diff --git a/clients/client-s3/src/models/models_1.ts b/clients/client-s3/src/models/models_1.ts index 4cc237b32df0f..2915384b28f07 100644 --- a/clients/client-s3/src/models/models_1.ts +++ b/clients/client-s3/src/models/models_1.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType, SENSITIVE_STRING } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { @@ -1075,7 +1076,7 @@ export interface UploadPartRequest { /** *

Object data.

*/ - Body?: Readable | ReadableStream | Blob; + Body?: SdkStream; /** *

The name of the bucket to which the multipart upload was initiated.

@@ -1451,7 +1452,7 @@ export interface WriteGetObjectResponseRequest { /** *

The object data.

*/ - Body?: Readable | ReadableStream | Blob; + Body?: SdkStream; /** *

The integer status code for an HTTP response of a corresponding GetObject diff --git a/clients/client-s3/src/protocols/Aws_restXml.ts b/clients/client-s3/src/protocols/Aws_restXml.ts index de9738d1c0e35..d1031d58edd5f 100644 --- a/clients/client-s3/src/protocols/Aws_restXml.ts +++ b/clients/client-s3/src/protocols/Aws_restXml.ts @@ -27,6 +27,7 @@ import { Endpoint as __Endpoint, EventStreamSerdeContext as __EventStreamSerdeContext, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; import { XmlNode as __XmlNode, XmlText as __XmlText } from "@aws-sdk/xml-builder"; @@ -5275,7 +5276,7 @@ const deserializeAws_restXmlGetBucketWebsiteCommandError = async ( export const deserializeAws_restXmlGetObjectCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restXmlGetObjectCommandError(output, context); @@ -5353,7 +5354,7 @@ export const deserializeAws_restXmlGetObjectCommand = async ( }, {} as any), ], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.Body = data; return contents; }; @@ -5634,7 +5635,7 @@ const deserializeAws_restXmlGetObjectTaggingCommandError = async ( export const deserializeAws_restXmlGetObjectTorrentCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restXmlGetObjectTorrentCommandError(output, context); @@ -5643,7 +5644,7 @@ export const deserializeAws_restXmlGetObjectTorrentCommand = async ( $metadata: deserializeMetadata(output), RequestCharged: [, output.headers["x-amz-request-charged"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.Body = data; return contents; }; @@ -7342,7 +7343,7 @@ export const deserializeAws_restXmlSelectObjectContentCommand = async ( const contents: any = map({ $metadata: deserializeMetadata(output), }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.Payload = deserializeAws_restXmlSelectObjectContentEventStream(data, context); return contents; }; diff --git a/clients/client-s3/src/runtimeConfig.browser.ts b/clients/client-s3/src/runtimeConfig.browser.ts index 72e00eba2b424..fa60174c30897 100644 --- a/clients/client-s3/src/runtimeConfig.browser.ts +++ b/clients/client-s3/src/runtimeConfig.browser.ts @@ -13,7 +13,7 @@ import { Md5 } from "@aws-sdk/md5-js"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; -import { getAwsChunkedEncodingStream } from "@aws-sdk/util-stream-browser"; +import { getAwsChunkedEncodingStream, sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { S3ClientConfig } from "./S3Client"; @@ -48,6 +48,7 @@ export const getRuntimeConfig = (config: S3ClientConfig) => { region: config?.region ?? invalidProvider("Region is missing"), requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha1: config?.sha1 ?? Sha1, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, diff --git a/clients/client-s3/src/runtimeConfig.ts b/clients/client-s3/src/runtimeConfig.ts index 8d81c67c05885..bc012cdeb3879 100644 --- a/clients/client-s3/src/runtimeConfig.ts +++ b/clients/client-s3/src/runtimeConfig.ts @@ -24,7 +24,7 @@ import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/nod import { HashConstructor as __HashConstructor } from "@aws-sdk/types"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; -import { getAwsChunkedEncodingStream } from "@aws-sdk/util-stream-node"; +import { getAwsChunkedEncodingStream, sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { S3ClientConfig } from "./S3Client"; @@ -66,6 +66,7 @@ export const getRuntimeConfig = (config: S3ClientConfig) => { ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha1: config?.sha1 ?? Hash.bind(null, "sha1"), sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, diff --git a/clients/client-transcribe-streaming/src/protocols/Aws_restJson1.ts b/clients/client-transcribe-streaming/src/protocols/Aws_restJson1.ts index e353bbf7094a5..4a2baf558580b 100644 --- a/clients/client-transcribe-streaming/src/protocols/Aws_restJson1.ts +++ b/clients/client-transcribe-streaming/src/protocols/Aws_restJson1.ts @@ -196,7 +196,7 @@ export const deserializeAws_restJson1StartMedicalStreamTranscriptionCommand = as ], ContentIdentificationType: [, output.headers["x-amzn-transcribe-content-identification-type"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.TranscriptResultStream = deserializeAws_restJson1MedicalTranscriptResultStream(data, context); return contents; }; @@ -287,7 +287,7 @@ export const deserializeAws_restJson1StartStreamTranscriptionCommand = async ( VocabularyNames: [, output.headers["x-amzn-transcribe-vocabulary-names"]], VocabularyFilterNames: [, output.headers["x-amzn-transcribe-vocabulary-filter-names"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.TranscriptResultStream = deserializeAws_restJson1TranscriptResultStream(data, context); return contents; }; diff --git a/clients/client-workmailmessageflow/package.json b/clients/client-workmailmessageflow/package.json index 95a2911715205..969f7a28913dd 100644 --- a/clients/client-workmailmessageflow/package.json +++ b/clients/client-workmailmessageflow/package.json @@ -45,6 +45,8 @@ "@aws-sdk/util-body-length-node": "*", "@aws-sdk/util-defaults-mode-browser": "*", "@aws-sdk/util-defaults-mode-node": "*", + "@aws-sdk/util-stream-browser": "*", + "@aws-sdk/util-stream-node": "*", "@aws-sdk/util-user-agent-browser": "*", "@aws-sdk/util-user-agent-node": "*", "@aws-sdk/util-utf8-browser": "*", diff --git a/clients/client-workmailmessageflow/src/WorkMailMessageFlowClient.ts b/clients/client-workmailmessageflow/src/WorkMailMessageFlowClient.ts index 5de00922d24cb..137c09ab7cf49 100644 --- a/clients/client-workmailmessageflow/src/WorkMailMessageFlowClient.ts +++ b/clients/client-workmailmessageflow/src/WorkMailMessageFlowClient.ts @@ -48,6 +48,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent, @@ -192,6 +193,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type WorkMailMessageFlowClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/clients/client-workmailmessageflow/src/commands/GetRawMessageContentCommand.ts b/clients/client-workmailmessageflow/src/commands/GetRawMessageContentCommand.ts index b3c0269041604..d79744e5c994d 100644 --- a/clients/client-workmailmessageflow/src/commands/GetRawMessageContentCommand.ts +++ b/clients/client-workmailmessageflow/src/commands/GetRawMessageContentCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -96,7 +97,10 @@ export class GetRawMessageContentCommand extends $Command< return serializeAws_restJson1GetRawMessageContentCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1GetRawMessageContentCommand(output, context); } diff --git a/clients/client-workmailmessageflow/src/models/models_0.ts b/clients/client-workmailmessageflow/src/models/models_0.ts index 40c46ad06a29e..bc4e4af4926d2 100644 --- a/clients/client-workmailmessageflow/src/models/models_0.ts +++ b/clients/client-workmailmessageflow/src/models/models_0.ts @@ -1,5 +1,6 @@ // smithy-typescript generated code import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client"; +import { SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { WorkMailMessageFlowServiceException as __BaseException } from "./WorkMailMessageFlowServiceException"; @@ -15,7 +16,7 @@ export interface GetRawMessageContentResponse { /** *

The raw content of the email message, in MIME format.

*/ - messageContent: Readable | ReadableStream | Blob | undefined; + messageContent: SdkStream | undefined; } /** diff --git a/clients/client-workmailmessageflow/src/protocols/Aws_restJson1.ts b/clients/client-workmailmessageflow/src/protocols/Aws_restJson1.ts index 6375e18a18267..8d57ba61ec3ac 100644 --- a/clients/client-workmailmessageflow/src/protocols/Aws_restJson1.ts +++ b/clients/client-workmailmessageflow/src/protocols/Aws_restJson1.ts @@ -10,6 +10,7 @@ import { import { Endpoint as __Endpoint, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -78,7 +79,7 @@ export const serializeAws_restJson1PutRawMessageContentCommand = async ( export const deserializeAws_restJson1GetRawMessageContentCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1GetRawMessageContentCommandError(output, context); @@ -86,7 +87,7 @@ export const deserializeAws_restJson1GetRawMessageContentCommand = async ( const contents: any = map({ $metadata: deserializeMetadata(output), }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.messageContent = data; return contents; }; diff --git a/clients/client-workmailmessageflow/src/runtimeConfig.browser.ts b/clients/client-workmailmessageflow/src/runtimeConfig.browser.ts index 610b2552a1fc7..b40f332a77cf9 100644 --- a/clients/client-workmailmessageflow/src/runtimeConfig.browser.ts +++ b/clients/client-workmailmessageflow/src/runtimeConfig.browser.ts @@ -9,6 +9,7 @@ import { invalidProvider } from "@aws-sdk/invalid-dependency"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { WorkMailMessageFlowClientConfig } from "./WorkMailMessageFlowClient"; @@ -40,6 +41,7 @@ export const getRuntimeConfig = (config: WorkMailMessageFlowClientConfig) => { region: config?.region ?? invalidProvider("Region is missing"), requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)), diff --git a/clients/client-workmailmessageflow/src/runtimeConfig.ts b/clients/client-workmailmessageflow/src/runtimeConfig.ts index 05b03181e5b65..d973358839ff4 100644 --- a/clients/client-workmailmessageflow/src/runtimeConfig.ts +++ b/clients/client-workmailmessageflow/src/runtimeConfig.ts @@ -20,6 +20,7 @@ import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider"; import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/node-http-handler"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { WorkMailMessageFlowClientConfig } from "./WorkMailMessageFlowClient"; @@ -58,6 +59,7 @@ export const getRuntimeConfig = (config: WorkMailMessageFlowClientConfig) => { ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS), diff --git a/private/aws-protocoltests-restjson/package.json b/private/aws-protocoltests-restjson/package.json index 15d5c06cebb3a..56d4bf16b5f32 100644 --- a/private/aws-protocoltests-restjson/package.json +++ b/private/aws-protocoltests-restjson/package.json @@ -48,6 +48,8 @@ "@aws-sdk/util-body-length-node": "*", "@aws-sdk/util-defaults-mode-browser": "*", "@aws-sdk/util-defaults-mode-node": "*", + "@aws-sdk/util-stream-browser": "*", + "@aws-sdk/util-stream-node": "*", "@aws-sdk/util-user-agent-browser": "*", "@aws-sdk/util-user-agent-node": "*", "@aws-sdk/util-utf8-browser": "*", diff --git a/private/aws-protocoltests-restjson/src/RestJsonProtocolClient.ts b/private/aws-protocoltests-restjson/src/RestJsonProtocolClient.ts index 90f3650dc5f3a..6ed194ac56af6 100644 --- a/private/aws-protocoltests-restjson/src/RestJsonProtocolClient.ts +++ b/private/aws-protocoltests-restjson/src/RestJsonProtocolClient.ts @@ -41,6 +41,7 @@ import { Provider as __Provider, Provider, RegionInfoProvider, + SdkStreamMixinInjector as __SdkStreamMixinInjector, StreamCollector as __StreamCollector, StreamHasher as __StreamHasher, UrlParser as __UrlParser, @@ -587,6 +588,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__ * The {@link DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK. */ defaultsMode?: DefaultsMode | Provider; + + /** + * The internal function that inject utilities to runtime-specific stream to help users consume the data + * @internal + */ + sdkStreamMixin?: __SdkStreamMixinInjector; } type RestJsonProtocolClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & diff --git a/private/aws-protocoltests-restjson/src/commands/StreamingTraitsCommand.ts b/private/aws-protocoltests-restjson/src/commands/StreamingTraitsCommand.ts index ade6f68fe6865..468c0462f3c9f 100644 --- a/private/aws-protocoltests-restjson/src/commands/StreamingTraitsCommand.ts +++ b/private/aws-protocoltests-restjson/src/commands/StreamingTraitsCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -99,7 +100,10 @@ export class StreamingTraitsCommand extends $Command< return serializeAws_restJson1StreamingTraitsCommand(input, context); } - private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + private deserialize( + output: __HttpResponse, + context: __SerdeContext & __SdkStreamSerdeContext + ): Promise { return deserializeAws_restJson1StreamingTraitsCommand(output, context); } diff --git a/private/aws-protocoltests-restjson/src/commands/StreamingTraitsWithMediaTypeCommand.ts b/private/aws-protocoltests-restjson/src/commands/StreamingTraitsWithMediaTypeCommand.ts index 6713cff134e19..86433e73307a8 100644 --- a/private/aws-protocoltests-restjson/src/commands/StreamingTraitsWithMediaTypeCommand.ts +++ b/private/aws-protocoltests-restjson/src/commands/StreamingTraitsWithMediaTypeCommand.ts @@ -9,6 +9,7 @@ import { HttpHandlerOptions as __HttpHandlerOptions, MetadataBearer as __MetadataBearer, MiddlewareStack, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; @@ -106,7 +107,7 @@ export class StreamingTraitsWithMediaTypeCommand extends $Command< private deserialize( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise { return deserializeAws_restJson1StreamingTraitsWithMediaTypeCommand(output, context); } diff --git a/private/aws-protocoltests-restjson/src/models/models_0.ts b/private/aws-protocoltests-restjson/src/models/models_0.ts index a0e36a011952f..c5570652d0eab 100644 --- a/private/aws-protocoltests-restjson/src/models/models_0.ts +++ b/private/aws-protocoltests-restjson/src/models/models_0.ts @@ -3,7 +3,7 @@ import { ExceptionOptionType as __ExceptionOptionType, LazyJsonString as __LazyJsonString, } from "@aws-sdk/smithy-client"; -import { DocumentType as __DocumentType } from "@aws-sdk/types"; +import { DocumentType as __DocumentType, SdkStream } from "@aws-sdk/types"; import { Readable } from "stream"; import { RestJsonProtocolServiceException as __BaseException } from "./RestJsonProtocolServiceException"; @@ -1504,7 +1504,7 @@ export const SimpleScalarPropertiesInputOutputFilterSensitiveLog = (obj: SimpleS export interface StreamingTraitsInputOutput { foo?: string; - blob?: Readable | ReadableStream | Blob; + blob?: SdkStream; } /** @@ -1516,7 +1516,7 @@ export const StreamingTraitsInputOutputFilterSensitiveLog = (obj: StreamingTrait export interface StreamingTraitsRequireLengthInput { foo?: string; - blob?: Readable | ReadableStream | Blob; + blob?: SdkStream; } /** @@ -1528,7 +1528,7 @@ export const StreamingTraitsRequireLengthInputFilterSensitiveLog = (obj: Streami export interface StreamingTraitsWithMediaTypeInputOutput { foo?: string; - blob?: Readable | ReadableStream | Blob; + blob?: SdkStream; } /** diff --git a/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts b/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts index 5868d3126f49f..48f183c5e53ac 100644 --- a/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts +++ b/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts @@ -42,6 +42,7 @@ import { DocumentType as __DocumentType, Endpoint as __Endpoint, ResponseMetadata as __ResponseMetadata, + SdkStreamSerdeContext as __SdkStreamSerdeContext, SerdeContext as __SerdeContext, } from "@aws-sdk/types"; import { v4 as generateIdempotencyToken } from "uuid"; @@ -5509,7 +5510,7 @@ const deserializeAws_restJson1SimpleScalarPropertiesCommandError = async ( export const deserializeAws_restJson1StreamingTraitsCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1StreamingTraitsCommandError(output, context); @@ -5518,7 +5519,7 @@ export const deserializeAws_restJson1StreamingTraitsCommand = async ( $metadata: deserializeMetadata(output), foo: [, output.headers["x-foo"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.blob = data; return contents; }; @@ -5575,7 +5576,7 @@ const deserializeAws_restJson1StreamingTraitsRequireLengthCommandError = async ( export const deserializeAws_restJson1StreamingTraitsWithMediaTypeCommand = async ( output: __HttpResponse, - context: __SerdeContext + context: __SerdeContext & __SdkStreamSerdeContext ): Promise => { if (output.statusCode !== 200 && output.statusCode >= 300) { return deserializeAws_restJson1StreamingTraitsWithMediaTypeCommandError(output, context); @@ -5584,7 +5585,7 @@ export const deserializeAws_restJson1StreamingTraitsWithMediaTypeCommand = async $metadata: deserializeMetadata(output), foo: [, output.headers["x-foo"]], }); - const data: any = output.body; + const data: any = context.sdkStreamMixin(output.body); contents.blob = data; return contents; }; diff --git a/private/aws-protocoltests-restjson/src/runtimeConfig.browser.ts b/private/aws-protocoltests-restjson/src/runtimeConfig.browser.ts index ffde223099dce..4a59235b6f2e3 100644 --- a/private/aws-protocoltests-restjson/src/runtimeConfig.browser.ts +++ b/private/aws-protocoltests-restjson/src/runtimeConfig.browser.ts @@ -10,6 +10,7 @@ import { Md5 } from "@aws-sdk/md5-js"; import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; import { RestJsonProtocolClientConfig } from "./RestJsonProtocolClient"; @@ -39,6 +40,7 @@ export const getRuntimeConfig = (config: RestJsonProtocolClientConfig) => { md5: config?.md5 ?? Md5, requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider), retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Sha256, streamCollector: config?.streamCollector ?? streamCollector, streamHasher: config?.streamHasher ?? streamHasher, diff --git a/private/aws-protocoltests-restjson/src/runtimeConfig.ts b/private/aws-protocoltests-restjson/src/runtimeConfig.ts index 277bda61c7ee6..b9596ee6023b8 100644 --- a/private/aws-protocoltests-restjson/src/runtimeConfig.ts +++ b/private/aws-protocoltests-restjson/src/runtimeConfig.ts @@ -18,6 +18,7 @@ import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/nod import { HashConstructor as __HashConstructor } from "@aws-sdk/types"; import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { sdkStreamMixin } from "@aws-sdk/util-stream-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; import { RestJsonProtocolClientConfig } from "./RestJsonProtocolClient"; @@ -54,6 +55,7 @@ export const getRuntimeConfig = (config: RestJsonProtocolClientConfig) => { ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }), + sdkStreamMixin: config?.sdkStreamMixin ?? sdkStreamMixin, sha256: config?.sha256 ?? Hash.bind(null, "sha256"), streamCollector: config?.streamCollector ?? streamCollector, streamHasher: config?.streamHasher ?? streamHasher,