import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http" ; import { expectBoolean as __expectBoolean , expectLong as __expectLong , expectNonNull as __expectNonNull , expectNumber as __expectNumber , expectString as __expectString , expectUnion as __expectUnion , parseEpochTimestamp as __parseEpochTimestamp , } from "@aws-sdk/smithy-client" ; import { Endpoint as __Endpoint , HeaderBag as __HeaderBag , MetadataBearer as __MetadataBearer , ResponseMetadata as __ResponseMetadata , SerdeContext as __SerdeContext , SmithyException as __SmithyException , } from "@aws-sdk/types" ; import { DescribeStreamCommandInput , DescribeStreamCommandOutput } from "../commands/DescribeStreamCommand" ; import { GetRecordsCommandInput , GetRecordsCommandOutput } from "../commands/GetRecordsCommand" ; import { GetShardIteratorCommandInput , GetShardIteratorCommandOutput } from "../commands/GetShardIteratorCommand" ; import { ListStreamsCommandInput , ListStreamsCommandOutput } from "../commands/ListStreamsCommand" ; import { _Record , _Stream , AttributeValue , DescribeStreamInput , DescribeStreamOutput , ExpiredIteratorException , GetRecordsInput , GetRecordsOutput , GetShardIteratorInput , GetShardIteratorOutput , Identity , InternalServerError , KeySchemaElement , LimitExceededException , ListStreamsInput , ListStreamsOutput , ResourceNotFoundException , SequenceNumberRange , Shard , StreamDescription , StreamRecord , TrimmedDataAccessException , } from "../models/models_0" ; export const serializeAws_json1_0DescribeStreamCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "DynamoDBStreams_20120810.DescribeStream" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0DescribeStreamInput ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0GetRecordsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "DynamoDBStreams_20120810.GetRecords" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0GetRecordsInput ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0GetShardIteratorCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "DynamoDBStreams_20120810.GetShardIterator" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0GetShardIteratorInput ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_0ListStreamsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.0" , "x-amz-target" : "DynamoDBStreams_20120810.ListStreams" , } ; let body ; body = JSON . stringify ( serializeAws_json1_0ListStreamsInput ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const deserializeAws_json1_0DescribeStreamCommand = async ( output , context ) : Promise < DescribeStreamCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0DescribeStreamCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0DescribeStreamOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0DescribeStreamCommandError = async ( output , context ) : Promise < DescribeStreamCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerError" : case "com.amazonaws.dynamodbstreams#InternalServerError" : response = { ... ( await deserializeAws_json1_0InternalServerErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.dynamodbstreams#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0GetRecordsCommand = async ( output , context ) : Promise < GetRecordsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0GetRecordsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0GetRecordsOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0GetRecordsCommandError = async ( output , context ) : Promise < GetRecordsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ExpiredIteratorException" : case "com.amazonaws.dynamodbstreams#ExpiredIteratorException" : response = { ... ( await deserializeAws_json1_0ExpiredIteratorExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerError" : case "com.amazonaws.dynamodbstreams#InternalServerError" : response = { ... ( await deserializeAws_json1_0InternalServerErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.dynamodbstreams#LimitExceededException" : response = { ... ( await deserializeAws_json1_0LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.dynamodbstreams#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TrimmedDataAccessException" : case "com.amazonaws.dynamodbstreams#TrimmedDataAccessException" : response = { ... ( await deserializeAws_json1_0TrimmedDataAccessExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0GetShardIteratorCommand = async ( output , context ) : Promise < GetShardIteratorCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0GetShardIteratorCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0GetShardIteratorOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0GetShardIteratorCommandError = async ( output , context ) : Promise < GetShardIteratorCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerError" : case "com.amazonaws.dynamodbstreams#InternalServerError" : response = { ... ( await deserializeAws_json1_0InternalServerErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.dynamodbstreams#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TrimmedDataAccessException" : case "com.amazonaws.dynamodbstreams#TrimmedDataAccessException" : response = { ... ( await deserializeAws_json1_0TrimmedDataAccessExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_0ListStreamsCommand = async ( output , context ) : Promise < ListStreamsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_0ListStreamsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_0ListStreamsOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_0ListStreamsCommandError = async ( output , context ) : Promise < ListStreamsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerError" : case "com.amazonaws.dynamodbstreams#InternalServerError" : response = { ... ( await deserializeAws_json1_0InternalServerErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.dynamodbstreams#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_0ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; const deserializeAws_json1_0ExpiredIteratorExceptionResponse = async ( parsedOutput , context ) : Promise < ExpiredIteratorException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_0ExpiredIteratorException ( body , context ) ; const contents = { name : "ExpiredIteratorException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_0InternalServerErrorResponse = async ( parsedOutput , context ) : Promise < InternalServerError > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_0InternalServerError ( body , context ) ; const contents = { name : "InternalServerError" , $fault : "server" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_0LimitExceededExceptionResponse = async ( parsedOutput , context ) : Promise < LimitExceededException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_0LimitExceededException ( body , context ) ; const contents = { name : "LimitExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_0ResourceNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceNotFoundException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_0ResourceNotFoundException ( body , context ) ; const contents = { name : "ResourceNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_0TrimmedDataAccessExceptionResponse = async ( parsedOutput , context ) : Promise < TrimmedDataAccessException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_0TrimmedDataAccessException ( body , context ) ; const contents = { name : "TrimmedDataAccessException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const serializeAws_json1_0DescribeStreamInput = ( input , context ) : any => { return { ... ( input . ExclusiveStartShardId !== undefined && input . ExclusiveStartShardId !== null && { ExclusiveStartShardId : input . ExclusiveStartShardId } ) , ... ( input . Limit !== undefined && input . Limit !== null && { Limit : input . Limit } ) , ... ( input . StreamArn !== undefined && input . StreamArn !== null && { StreamArn : input . StreamArn } ) , } ; } ; const serializeAws_json1_0GetRecordsInput = ( input , context ) : any => { return { ... ( input . Limit !== undefined && input . Limit !== null && { Limit : input . Limit } ) , ... ( input . ShardIterator !== undefined && input . ShardIterator !== null && { ShardIterator : input . ShardIterator } ) , } ; } ; const serializeAws_json1_0GetShardIteratorInput = ( input , context ) : any => { return { ... ( input . SequenceNumber !== undefined && input . SequenceNumber !== null && { SequenceNumber : input . SequenceNumber } ) , ... ( input . ShardId !== undefined && input . ShardId !== null && { ShardId : input . ShardId } ) , ... ( input . ShardIteratorType !== undefined && input . ShardIteratorType !== null && { ShardIteratorType : input . ShardIteratorType } ) , ... ( input . StreamArn !== undefined && input . StreamArn !== null && { StreamArn : input . StreamArn } ) , } ; } ; const serializeAws_json1_0ListStreamsInput = ( input , context ) : any => { return { ... ( input . ExclusiveStartStreamArn !== undefined && input . ExclusiveStartStreamArn !== null && { ExclusiveStartStreamArn : input . ExclusiveStartStreamArn } ) , ... ( input . Limit !== undefined && input . Limit !== null && { Limit : input . Limit } ) , ... ( input . TableName !== undefined && input . TableName !== null && { TableName : input . TableName } ) , } ; } ; const deserializeAws_json1_0AttributeMap = ( output , context ) : { [ key ] : AttributeValue ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : deserializeAws_json1_0AttributeValue ( __expectUnion ( value ) , context ) , } ; } , { } ) ; } ; const deserializeAws_json1_0AttributeValue = ( output , context ) : AttributeValue => { if ( output . B !== undefined && output . B !== null ) { return { B : context . base64Decoder ( output . B ) , } ; } if ( __expectBoolean ( output . BOOL ) !== undefined ) { return { BOOL : __expectBoolean ( output . BOOL ) as any } ; } if ( output . BS !== undefined && output . BS !== null ) { return { BS : deserializeAws_json1_0BinarySetAttributeValue ( output . BS , context ) , } ; } if ( output . L !== undefined && output . L !== null ) { return { L : deserializeAws_json1_0ListAttributeValue ( output . L , context ) , } ; } if ( output . M !== undefined && output . M !== null ) { return { M : deserializeAws_json1_0MapAttributeValue ( output . M , context ) , } ; } if ( __expectString ( output . N ) !== undefined ) { return { N : __expectString ( output . N ) as any } ; } if ( output . NS !== undefined && output . NS !== null ) { return { NS : deserializeAws_json1_0NumberSetAttributeValue ( output . NS , context ) , } ; } if ( __expectBoolean ( output . NULL ) !== undefined ) { return { NULL : __expectBoolean ( output . NULL ) as any } ; } if ( __expectString ( output . S ) !== undefined ) { return { S : __expectString ( output . S ) as any } ; } if ( output . SS !== undefined && output . SS !== null ) { return { SS : deserializeAws_json1_0StringSetAttributeValue ( output . SS , context ) , } ; } return { $unknown : Object . entries ( output ) [ 0 ] } ; } ; const deserializeAws_json1_0BinarySetAttributeValue = ( output , context ) : Uint8Array [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return context . base64Decoder ( entry ) ; } ) ; } ; const deserializeAws_json1_0DescribeStreamOutput = ( output , context ) : DescribeStreamOutput => { return { StreamDescription : output . StreamDescription !== undefined && output . StreamDescription !== null ? deserializeAws_json1_0StreamDescription ( output . StreamDescription , context ) : undefined , } as any ; } ; const deserializeAws_json1_0ExpiredIteratorException = ( output , context ) : ExpiredIteratorException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_0GetRecordsOutput = ( output , context ) : GetRecordsOutput => { return { NextShardIterator : __expectString ( output . NextShardIterator ) , Records : output . Records !== undefined && output . Records !== null ? deserializeAws_json1_0RecordList ( output . Records , context ) : undefined , } as any ; } ; const deserializeAws_json1_0GetShardIteratorOutput = ( output , context ) : GetShardIteratorOutput => { return { ShardIterator : __expectString ( output . ShardIterator ) , } as any ; } ; const deserializeAws_json1_0Identity = ( output , context ) : Identity => { return { PrincipalId : __expectString ( output . PrincipalId ) , Type : __expectString ( output . Type ) , } as any ; } ; const deserializeAws_json1_0InternalServerError = ( output , context ) : InternalServerError => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_0KeySchema = ( output , context ) : KeySchemaElement [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_0KeySchemaElement ( entry , context ) ; } ) ; } ; const deserializeAws_json1_0KeySchemaElement = ( output , context ) : KeySchemaElement => { return { AttributeName : __expectString ( output . AttributeName ) , KeyType : __expectString ( output . KeyType ) , } as any ; } ; const deserializeAws_json1_0LimitExceededException = ( output , context ) : LimitExceededException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_0ListAttributeValue = ( output , context ) : AttributeValue [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_0AttributeValue ( __expectUnion ( entry ) , context ) ; } ) ; } ; const deserializeAws_json1_0ListStreamsOutput = ( output , context ) : ListStreamsOutput => { return { LastEvaluatedStreamArn : __expectString ( output . LastEvaluatedStreamArn ) , Streams : output . Streams !== undefined && output . Streams !== null ? deserializeAws_json1_0StreamList ( output . Streams , context ) : undefined , } as any ; } ; const deserializeAws_json1_0MapAttributeValue = ( output , context ) : { [ key ] : AttributeValue ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : deserializeAws_json1_0AttributeValue ( __expectUnion ( value ) , context ) , } ; } , { } ) ; } ; const deserializeAws_json1_0NumberSetAttributeValue = ( output , context ) : string [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_json1_0_Record = ( output , context ) : _Record => { return { awsRegion : __expectString ( output . awsRegion ) , dynamodb : output . dynamodb !== undefined && output . dynamodb !== null ? deserializeAws_json1_0StreamRecord ( output . dynamodb , context ) : undefined , eventID : __expectString ( output . eventID ) , eventName : __expectString ( output . eventName ) , eventSource : __expectString ( output . eventSource ) , eventVersion : __expectString ( output . eventVersion ) , userIdentity : output . userIdentity !== undefined && output . userIdentity !== null ? deserializeAws_json1_0Identity ( output . userIdentity , context ) : undefined , } as any ; } ; const deserializeAws_json1_0RecordList = ( output , context ) : _Record [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_0_Record ( entry , context ) ; } ) ; } ; const deserializeAws_json1_0ResourceNotFoundException = ( output , context ) : ResourceNotFoundException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_0SequenceNumberRange = ( output , context ) : SequenceNumberRange => { return { EndingSequenceNumber : __expectString ( output . EndingSequenceNumber ) , StartingSequenceNumber : __expectString ( output . StartingSequenceNumber ) , } as any ; } ; const deserializeAws_json1_0Shard = ( output , context ) : Shard => { return { ParentShardId : __expectString ( output . ParentShardId ) , SequenceNumberRange : output . SequenceNumberRange !== undefined && output . SequenceNumberRange !== null ? deserializeAws_json1_0SequenceNumberRange ( output . SequenceNumberRange , context ) : undefined , ShardId : __expectString ( output . ShardId ) , } as any ; } ; const deserializeAws_json1_0ShardDescriptionList = ( output , context ) : Shard [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_0Shard ( entry , context ) ; } ) ; } ; const deserializeAws_json1_0_Stream = ( output , context ) : _Stream => { return { StreamArn : __expectString ( output . StreamArn ) , StreamLabel : __expectString ( output . StreamLabel ) , TableName : __expectString ( output . TableName ) , } as any ; } ; const deserializeAws_json1_0StreamDescription = ( output , context ) : StreamDescription => { return { CreationRequestDateTime : output . CreationRequestDateTime !== undefined && output . CreationRequestDateTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreationRequestDateTime ) ) ) : undefined , KeySchema : output . KeySchema !== undefined && output . KeySchema !== null ? deserializeAws_json1_0KeySchema ( output . KeySchema , context ) : undefined , LastEvaluatedShardId : __expectString ( output . LastEvaluatedShardId ) , Shards : output . Shards !== undefined && output . Shards !== null ? deserializeAws_json1_0ShardDescriptionList ( output . Shards , context ) : undefined , StreamArn : __expectString ( output . StreamArn ) , StreamLabel : __expectString ( output . StreamLabel ) , StreamStatus : __expectString ( output . StreamStatus ) , StreamViewType : __expectString ( output . StreamViewType ) , TableName : __expectString ( output . TableName ) , } as any ; } ; const deserializeAws_json1_0StreamList = ( output , context ) : _Stream [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_0_Stream ( entry , context ) ; } ) ; } ; const deserializeAws_json1_0StreamRecord = ( output , context ) : StreamRecord => { return { ApproximateCreationDateTime : output . ApproximateCreationDateTime !== undefined && output . ApproximateCreationDateTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . ApproximateCreationDateTime ) ) ) : undefined , Keys : output . Keys !== undefined && output . Keys !== null ? deserializeAws_json1_0AttributeMap ( output . Keys , context ) : undefined , NewImage : output . NewImage !== undefined && output . NewImage !== null ? deserializeAws_json1_0AttributeMap ( output . NewImage , context ) : undefined , OldImage : output . OldImage !== undefined && output . OldImage !== null ? deserializeAws_json1_0AttributeMap ( output . OldImage , context ) : undefined , SequenceNumber : __expectString ( output . SequenceNumber ) , SizeBytes : __expectLong ( output . SizeBytes ) , StreamViewType : __expectString ( output . StreamViewType ) , } as any ; } ; const deserializeAws_json1_0StringSetAttributeValue = ( output , context ) : string [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_json1_0TrimmedDataAccessException = ( output , context ) : TrimmedDataAccessException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeMetadata = ( output ) : __ResponseMetadata => ( { httpStatusCode : output . statusCode , requestId : output . headers [ "x-amzn-requestid" ] ?? output . headers [ "x-amzn-request-id" ] , extendedRequestId : output . headers [ "x-amz-id-2" ] , cfId : output . headers [ "x-amz-cf-id" ] , } ) ; const collectBody = ( streamBody = new Uint8Array ( ) , context ) : Promise < Uint8Array > => { if ( streamBody instanceof Uint8Array ) { return Promise . resolve ( streamBody ) ; } return context . streamCollector ( streamBody ) || Promise . resolve ( new Uint8Array ( ) ) ; } ; const collectBodyString = ( streamBody , context ) : Promise < string > => collectBody ( streamBody , context ) . then ( ( body ) => context . utf8Encoder ( body ) ) ; const buildHttpRpcRequest = async ( context , headers , path , resolvedHostname , body ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const contents = { protocol , hostname , port , method : "POST" , path : basePath . endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) + path : basePath + path , headers , } ; if ( resolvedHostname !== undefined ) { contents . hostname = resolvedHostname ; } if ( body !== undefined ) { contents . body = body ; } return new __HttpRequest ( contents ) ; } ; const parseBody = ( streamBody , context ) : any => collectBodyString ( streamBody , context ) . then ( ( encoded ) => { if ( encoded . length ) { return JSON . parse ( encoded ) ; } return { } ; } ) ; /**
 * Load an error code for the aws.rest-json-1.1 protocol.
 */ const loadRestJsonErrorCode = ( output , data ) : string => { const findKey = ( object , key ) => Object . keys ( object ) . find ( ( k ) => k . toLowerCase ( ) === key . toLowerCase ( ) ) ; const sanitizeErrorCode = ( rawValue ) : string => { let cleanValue = rawValue ; if ( cleanValue . indexOf ( ":" ) >= 0 ) { cleanValue = cleanValue . split ( ":" ) [ 0 ] ; } if ( cleanValue . indexOf ( "#" ) >= 0 ) { cleanValue = cleanValue . split ( "#" ) [ 1 ] ; } return cleanValue ; } ; const headerKey = findKey ( output . headers , "x-amzn-errortype" ) ; if ( headerKey !== undefined ) { return sanitizeErrorCode ( output . headers [ headerKey ] ) ; } if ( data . code !== undefined ) { return sanitizeErrorCode ( data . code ) ; } if ( data [ "__type" ] !== undefined ) { return sanitizeErrorCode ( data [ "__type" ] ) ; } return "" ; } ;