import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http" ; import { expectBoolean as __expectBoolean , expectInt32 as __expectInt32 , expectNonNull as __expectNonNull , expectObject as __expectObject , expectString as __expectString , extendedEncodeURIComponent as __extendedEncodeURIComponent , parseRfc3339DateTime as __parseRfc3339DateTime , } from "@aws-sdk/smithy-client" ; import { Endpoint as __Endpoint , MetadataBearer as __MetadataBearer , ResponseMetadata as __ResponseMetadata , SerdeContext as __SerdeContext , SmithyException as __SmithyException , } from "@aws-sdk/types" ; import { v4 as generateIdempotencyToken } from "uuid" ; import { CreateComponentCommandInput , CreateComponentCommandOutput } from "../commands/CreateComponentCommand" ; import { CreateThemeCommandInput , CreateThemeCommandOutput } from "../commands/CreateThemeCommand" ; import { DeleteComponentCommandInput , DeleteComponentCommandOutput } from "../commands/DeleteComponentCommand" ; import { DeleteThemeCommandInput , DeleteThemeCommandOutput } from "../commands/DeleteThemeCommand" ; import { ExchangeCodeForTokenCommandInput , ExchangeCodeForTokenCommandOutput , } from "../commands/ExchangeCodeForTokenCommand" ; import { ExportComponentsCommandInput , ExportComponentsCommandOutput } from "../commands/ExportComponentsCommand" ; import { ExportThemesCommandInput , ExportThemesCommandOutput } from "../commands/ExportThemesCommand" ; import { GetComponentCommandInput , GetComponentCommandOutput } from "../commands/GetComponentCommand" ; import { GetThemeCommandInput , GetThemeCommandOutput } from "../commands/GetThemeCommand" ; import { ListComponentsCommandInput , ListComponentsCommandOutput } from "../commands/ListComponentsCommand" ; import { ListThemesCommandInput , ListThemesCommandOutput } from "../commands/ListThemesCommand" ; import { RefreshTokenCommandInput , RefreshTokenCommandOutput } from "../commands/RefreshTokenCommand" ; import { UpdateComponentCommandInput , UpdateComponentCommandOutput } from "../commands/UpdateComponentCommand" ; import { UpdateThemeCommandInput , UpdateThemeCommandOutput } from "../commands/UpdateThemeCommand" ; import { Component , ComponentBindingPropertiesValue , ComponentBindingPropertiesValueProperties , ComponentChild , ComponentConditionProperty , ComponentDataConfiguration , ComponentProperty , ComponentPropertyBindingProperties , ComponentSummary , ComponentVariant , CreateComponentData , CreateThemeData , ExchangeCodeForTokenRequestBody , FormBindingElement , InternalServerException , InvalidParameterException , Predicate , RefreshTokenRequestBody , ResourceConflictException , ResourceNotFoundException , ServiceQuotaExceededException , SortProperty , Theme , ThemeSummary , ThemeValue , ThemeValues , UpdateComponentData , UpdateThemeData , } from "../models/models_0" ; export const serializeAws_restJson1CreateComponentCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/app/{appId}/environment/{environmentName}/components" ; if ( input . appId !== undefined ) { const labelValue = input . appId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: appId." ) ; } resolvedPath = resolvedPath . replace ( "{appId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: appId." ) ; } if ( input . environmentName !== undefined ) { const labelValue = input . environmentName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: environmentName." ) ; } resolvedPath = resolvedPath . replace ( "{environmentName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: environmentName." ) ; } const query = { ... ( input . clientToken !== undefined && { clientToken : input . clientToken } ) , } ; let body ; if ( input . componentToCreate !== undefined ) { body = serializeAws_restJson1CreateComponentData ( input . componentToCreate , context ) ; } if ( body === undefined ) { body = { } ; } body = JSON . stringify ( body ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1CreateThemeCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/app/{appId}/environment/{environmentName}/themes" ; if ( input . appId !== undefined ) { const labelValue = input . appId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: appId." ) ; } resolvedPath = resolvedPath . replace ( "{appId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: appId." ) ; } if ( input . environmentName !== undefined ) { const labelValue = input . environmentName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: environmentName." ) ; } resolvedPath = resolvedPath . replace ( "{environmentName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: environmentName." ) ; } const query = { ... ( input . clientToken !== undefined && { clientToken : input . clientToken } ) , } ; let body ; if ( input . themeToCreate !== undefined ) { body = serializeAws_restJson1CreateThemeData ( input . themeToCreate , context ) ; } if ( body === undefined ) { body = { } ; } body = JSON . stringify ( body ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1DeleteComponentCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/app/{appId}/environment/{environmentName}/components/{id}" ; if ( input . appId !== undefined ) { const labelValue = input . appId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: appId." ) ; } resolvedPath = resolvedPath . replace ( "{appId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: appId." ) ; } if ( input . environmentName !== undefined ) { const labelValue = input . environmentName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: environmentName." ) ; } resolvedPath = resolvedPath . replace ( "{environmentName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: environmentName." ) ; } if ( input . id !== undefined ) { const labelValue = input . id ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: id." ) ; } resolvedPath = resolvedPath . replace ( "{id}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: id." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "DELETE" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DeleteThemeCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/app/{appId}/environment/{environmentName}/themes/{id}" ; if ( input . appId !== undefined ) { const labelValue = input . appId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: appId." ) ; } resolvedPath = resolvedPath . replace ( "{appId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: appId." ) ; } if ( input . environmentName !== undefined ) { const labelValue = input . environmentName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: environmentName." ) ; } resolvedPath = resolvedPath . replace ( "{environmentName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: environmentName." ) ; } if ( input . id !== undefined ) { const labelValue = input . id ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: id." ) ; } resolvedPath = resolvedPath . replace ( "{id}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: id." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "DELETE" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ExchangeCodeForTokenCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/tokens/{provider}" ; if ( input . provider !== undefined ) { const labelValue = input . provider ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: provider." ) ; } resolvedPath = resolvedPath . replace ( "{provider}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: provider." ) ; } let body ; if ( input . request !== undefined ) { body = serializeAws_restJson1ExchangeCodeForTokenRequestBody ( input . request , context ) ; } if ( body === undefined ) { body = { } ; } body = JSON . stringify ( body ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ExportComponentsCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/export/app/{appId}/environment/{environmentName}/components" ; if ( input . appId !== undefined ) { const labelValue = input . appId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: appId." ) ; } resolvedPath = resolvedPath . replace ( "{appId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: appId." ) ; } if ( input . environmentName !== undefined ) { const labelValue = input . environmentName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: environmentName." ) ; } resolvedPath = resolvedPath . replace ( "{environmentName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: environmentName." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ExportThemesCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/export/app/{appId}/environment/{environmentName}/themes" ; if ( input . appId !== undefined ) { const labelValue = input . appId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: appId." ) ; } resolvedPath = resolvedPath . replace ( "{appId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: appId." ) ; } if ( input . environmentName !== undefined ) { const labelValue = input . environmentName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: environmentName." ) ; } resolvedPath = resolvedPath . replace ( "{environmentName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: environmentName." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetComponentCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/app/{appId}/environment/{environmentName}/components/{id}" ; if ( input . appId !== undefined ) { const labelValue = input . appId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: appId." ) ; } resolvedPath = resolvedPath . replace ( "{appId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: appId." ) ; } if ( input . environmentName !== undefined ) { const labelValue = input . environmentName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: environmentName." ) ; } resolvedPath = resolvedPath . replace ( "{environmentName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: environmentName." ) ; } if ( input . id !== undefined ) { const labelValue = input . id ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: id." ) ; } resolvedPath = resolvedPath . replace ( "{id}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: id." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetThemeCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/app/{appId}/environment/{environmentName}/themes/{id}" ; if ( input . appId !== undefined ) { const labelValue = input . appId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: appId." ) ; } resolvedPath = resolvedPath . replace ( "{appId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: appId." ) ; } if ( input . environmentName !== undefined ) { const labelValue = input . environmentName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: environmentName." ) ; } resolvedPath = resolvedPath . replace ( "{environmentName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: environmentName." ) ; } if ( input . id !== undefined ) { const labelValue = input . id ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: id." ) ; } resolvedPath = resolvedPath . replace ( "{id}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: id." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ListComponentsCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/app/{appId}/environment/{environmentName}/components" ; if ( input . appId !== undefined ) { const labelValue = input . appId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: appId." ) ; } resolvedPath = resolvedPath . replace ( "{appId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: appId." ) ; } if ( input . environmentName !== undefined ) { const labelValue = input . environmentName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: environmentName." ) ; } resolvedPath = resolvedPath . replace ( "{environmentName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: environmentName." ) ; } const query = { ... ( input . nextToken !== undefined && { nextToken : input . nextToken } ) , ... ( input . maxResults !== undefined && { maxResults : input . maxResults . toString ( ) } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1ListThemesCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/app/{appId}/environment/{environmentName}/themes" ; if ( input . appId !== undefined ) { const labelValue = input . appId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: appId." ) ; } resolvedPath = resolvedPath . replace ( "{appId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: appId." ) ; } if ( input . environmentName !== undefined ) { const labelValue = input . environmentName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: environmentName." ) ; } resolvedPath = resolvedPath . replace ( "{environmentName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: environmentName." ) ; } const query = { ... ( input . nextToken !== undefined && { nextToken : input . nextToken } ) , ... ( input . maxResults !== undefined && { maxResults : input . maxResults . toString ( ) } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1RefreshTokenCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/tokens/{provider}/refresh" ; if ( input . provider !== undefined ) { const labelValue = input . provider ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: provider." ) ; } resolvedPath = resolvedPath . replace ( "{provider}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: provider." ) ; } let body ; if ( input . refreshTokenBody !== undefined ) { body = serializeAws_restJson1RefreshTokenRequestBody ( input . refreshTokenBody , context ) ; } if ( body === undefined ) { body = { } ; } body = JSON . stringify ( body ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1UpdateComponentCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/app/{appId}/environment/{environmentName}/components/{id}" ; if ( input . appId !== undefined ) { const labelValue = input . appId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: appId." ) ; } resolvedPath = resolvedPath . replace ( "{appId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: appId." ) ; } if ( input . environmentName !== undefined ) { const labelValue = input . environmentName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: environmentName." ) ; } resolvedPath = resolvedPath . replace ( "{environmentName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: environmentName." ) ; } if ( input . id !== undefined ) { const labelValue = input . id ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: id." ) ; } resolvedPath = resolvedPath . replace ( "{id}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: id." ) ; } const query = { ... ( input . clientToken !== undefined && { clientToken : input . clientToken } ) , } ; let body ; if ( input . updatedComponent !== undefined ) { body = serializeAws_restJson1UpdateComponentData ( input . updatedComponent , context ) ; } if ( body === undefined ) { body = { } ; } body = JSON . stringify ( body ) ; return new __HttpRequest ( { protocol , hostname , port , method : "PATCH" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1UpdateThemeCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/app/{appId}/environment/{environmentName}/themes/{id}" ; if ( input . appId !== undefined ) { const labelValue = input . appId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: appId." ) ; } resolvedPath = resolvedPath . replace ( "{appId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: appId." ) ; } if ( input . environmentName !== undefined ) { const labelValue = input . environmentName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: environmentName." ) ; } resolvedPath = resolvedPath . replace ( "{environmentName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: environmentName." ) ; } if ( input . id !== undefined ) { const labelValue = input . id ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: id." ) ; } resolvedPath = resolvedPath . replace ( "{id}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: id." ) ; } const query = { ... ( input . clientToken !== undefined && { clientToken : input . clientToken } ) , } ; let body ; if ( input . updatedTheme !== undefined ) { body = serializeAws_restJson1UpdateThemeData ( input . updatedTheme , context ) ; } if ( body === undefined ) { body = { } ; } body = JSON . stringify ( body ) ; return new __HttpRequest ( { protocol , hostname , port , method : "PATCH" , headers , path : resolvedPath , query , body , } ) ; } ; export const deserializeAws_restJson1CreateComponentCommand = async ( output , context ) : Promise < CreateComponentCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateComponentCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , entity : undefined , } ; const data = __expectObject ( await parseBody ( output . body , context ) ) ; contents . entity = deserializeAws_restJson1Component ( data , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateComponentCommandError = async ( output , context ) : Promise < CreateComponentCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.amplifyuibuilder#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.amplifyuibuilder#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceConflictException" : case "com.amazonaws.amplifyuibuilder#ResourceConflictException" : response = { ... ( await deserializeAws_restJson1ResourceConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceQuotaExceededException" : case "com.amazonaws.amplifyuibuilder#ServiceQuotaExceededException" : response = { ... ( await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse ( 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_restJson1CreateThemeCommand = async ( output , context ) : Promise < CreateThemeCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateThemeCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , entity : undefined , } ; const data = __expectObject ( await parseBody ( output . body , context ) ) ; contents . entity = deserializeAws_restJson1Theme ( data , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateThemeCommandError = async ( output , context ) : Promise < CreateThemeCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.amplifyuibuilder#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.amplifyuibuilder#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceConflictException" : case "com.amazonaws.amplifyuibuilder#ResourceConflictException" : response = { ... ( await deserializeAws_restJson1ResourceConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceQuotaExceededException" : case "com.amazonaws.amplifyuibuilder#ServiceQuotaExceededException" : response = { ... ( await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse ( 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_restJson1DeleteComponentCommand = async ( output , context ) : Promise < DeleteComponentCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteComponentCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteComponentCommandError = async ( output , context ) : Promise < DeleteComponentCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.amplifyuibuilder#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.amplifyuibuilder#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.amplifyuibuilder#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1DeleteThemeCommand = async ( output , context ) : Promise < DeleteThemeCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteThemeCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteThemeCommandError = async ( output , context ) : Promise < DeleteThemeCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.amplifyuibuilder#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.amplifyuibuilder#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.amplifyuibuilder#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1ExchangeCodeForTokenCommand = async ( output , context ) : Promise < ExchangeCodeForTokenCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ExchangeCodeForTokenCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , accessToken : undefined , expiresIn : undefined , refreshToken : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . accessToken !== undefined && data . accessToken !== null ) { contents . accessToken = __expectString ( data . accessToken ) ; } if ( data . expiresIn !== undefined && data . expiresIn !== null ) { contents . expiresIn = __expectInt32 ( data . expiresIn ) ; } if ( data . refreshToken !== undefined && data . refreshToken !== null ) { contents . refreshToken = __expectString ( data . refreshToken ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ExchangeCodeForTokenCommandError = async ( output , context ) : Promise < ExchangeCodeForTokenCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidParameterException" : case "com.amazonaws.amplifyuibuilder#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( 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_restJson1ExportComponentsCommand = async ( output , context ) : Promise < ExportComponentsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ExportComponentsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , entities : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . entities !== undefined && data . entities !== null ) { contents . entities = deserializeAws_restJson1ComponentList ( data . entities , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ExportComponentsCommandError = async ( output , context ) : Promise < ExportComponentsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.amplifyuibuilder#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.amplifyuibuilder#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( 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_restJson1ExportThemesCommand = async ( output , context ) : Promise < ExportThemesCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ExportThemesCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , entities : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . entities !== undefined && data . entities !== null ) { contents . entities = deserializeAws_restJson1ThemeList ( data . entities , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ExportThemesCommandError = async ( output , context ) : Promise < ExportThemesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.amplifyuibuilder#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.amplifyuibuilder#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( 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_restJson1GetComponentCommand = async ( output , context ) : Promise < GetComponentCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetComponentCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , component : undefined , } ; const data = __expectObject ( await parseBody ( output . body , context ) ) ; contents . component = deserializeAws_restJson1Component ( data , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetComponentCommandError = async ( output , context ) : Promise < GetComponentCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.amplifyuibuilder#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.amplifyuibuilder#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.amplifyuibuilder#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1GetThemeCommand = async ( output , context ) : Promise < GetThemeCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetThemeCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , theme : undefined , } ; const data = __expectObject ( await parseBody ( output . body , context ) ) ; contents . theme = deserializeAws_restJson1Theme ( data , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetThemeCommandError = async ( output , context ) : Promise < GetThemeCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.amplifyuibuilder#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.amplifyuibuilder#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.amplifyuibuilder#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1ListComponentsCommand = async ( output , context ) : Promise < ListComponentsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListComponentsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , entities : undefined , nextToken : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . entities !== undefined && data . entities !== null ) { contents . entities = deserializeAws_restJson1ComponentSummaryList ( data . entities , context ) ; } if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListComponentsCommandError = async ( output , context ) : Promise < ListComponentsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.amplifyuibuilder#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.amplifyuibuilder#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( 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_restJson1ListThemesCommand = async ( output , context ) : Promise < ListThemesCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListThemesCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , entities : undefined , nextToken : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . entities !== undefined && data . entities !== null ) { contents . entities = deserializeAws_restJson1ThemeSummaryList ( data . entities , context ) ; } if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListThemesCommandError = async ( output , context ) : Promise < ListThemesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.amplifyuibuilder#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.amplifyuibuilder#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( 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_restJson1RefreshTokenCommand = async ( output , context ) : Promise < RefreshTokenCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1RefreshTokenCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , accessToken : undefined , expiresIn : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . accessToken !== undefined && data . accessToken !== null ) { contents . accessToken = __expectString ( data . accessToken ) ; } if ( data . expiresIn !== undefined && data . expiresIn !== null ) { contents . expiresIn = __expectInt32 ( data . expiresIn ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1RefreshTokenCommandError = async ( output , context ) : Promise < RefreshTokenCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidParameterException" : case "com.amazonaws.amplifyuibuilder#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( 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_restJson1UpdateComponentCommand = async ( output , context ) : Promise < UpdateComponentCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateComponentCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , entity : undefined , } ; const data = __expectObject ( await parseBody ( output . body , context ) ) ; contents . entity = deserializeAws_restJson1Component ( data , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateComponentCommandError = async ( output , context ) : Promise < UpdateComponentCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.amplifyuibuilder#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.amplifyuibuilder#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceConflictException" : case "com.amazonaws.amplifyuibuilder#ResourceConflictException" : response = { ... ( await deserializeAws_restJson1ResourceConflictExceptionResponse ( 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_restJson1UpdateThemeCommand = async ( output , context ) : Promise < UpdateThemeCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateThemeCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , entity : undefined , } ; const data = __expectObject ( await parseBody ( output . body , context ) ) ; contents . entity = deserializeAws_restJson1Theme ( data , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateThemeCommandError = async ( output , context ) : Promise < UpdateThemeCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.amplifyuibuilder#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.amplifyuibuilder#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceConflictException" : case "com.amazonaws.amplifyuibuilder#ResourceConflictException" : response = { ... ( await deserializeAws_restJson1ResourceConflictExceptionResponse ( 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_restJson1InternalServerExceptionResponse = async ( parsedOutput , context ) : Promise < InternalServerException > => { const contents = { name : "InternalServerException" , $fault : "server" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1InvalidParameterExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidParameterException > => { const contents = { name : "InvalidParameterException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ResourceConflictExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceConflictException > => { const contents = { name : "ResourceConflictException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ResourceNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceNotFoundException > => { const contents = { name : "ResourceNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ServiceQuotaExceededExceptionResponse = async ( parsedOutput , context ) : Promise < ServiceQuotaExceededException > => { const contents = { name : "ServiceQuotaExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const serializeAws_restJson1ComponentBindingProperties = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : serializeAws_restJson1ComponentBindingPropertiesValue ( value , context ) , } ; } , { } ) ; } ; const serializeAws_restJson1ComponentBindingPropertiesValue = ( input , context ) : any => { return { ... ( input . bindingProperties !== undefined && input . bindingProperties !== null && { bindingProperties : serializeAws_restJson1ComponentBindingPropertiesValueProperties ( input . bindingProperties , context ) , } ) , ... ( input . defaultValue !== undefined && input . defaultValue !== null && { defaultValue : input . defaultValue } ) , ... ( input . type !== undefined && input . type !== null && { type : input . type } ) , } ; } ; const serializeAws_restJson1ComponentBindingPropertiesValueProperties = ( input , context ) : any => { return { ... ( input . bucket !== undefined && input . bucket !== null && { bucket : input . bucket } ) , ... ( input . defaultValue !== undefined && input . defaultValue !== null && { defaultValue : input . defaultValue } ) , ... ( input . field !== undefined && input . field !== null && { field : input . field } ) , ... ( input . key !== undefined && input . key !== null && { key : input . key } ) , ... ( input . model !== undefined && input . model !== null && { model : input . model } ) , ... ( input . predicates !== undefined && input . predicates !== null && { predicates : serializeAws_restJson1PredicateList ( input . predicates , context ) } ) , ... ( input . userAttribute !== undefined && input . userAttribute !== null && { userAttribute : input . userAttribute } ) , } ; } ; const serializeAws_restJson1ComponentChild = ( input , context ) : any => { return { ... ( input . children !== undefined && input . children !== null && { children : serializeAws_restJson1ComponentChildList ( input . children , context ) } ) , ... ( input . componentType !== undefined && input . componentType !== null && { componentType : input . componentType } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . properties !== undefined && input . properties !== null && { properties : serializeAws_restJson1ComponentProperties ( input . properties , context ) , } ) , } ; } ; const serializeAws_restJson1ComponentChildList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1ComponentChild ( entry , context ) ; } ) ; } ; const serializeAws_restJson1ComponentCollectionProperties = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : serializeAws_restJson1ComponentDataConfiguration ( value , context ) , } ; } , { } ) ; } ; const serializeAws_restJson1ComponentConditionProperty = ( input , context ) : any => { return { ... ( input . else !== undefined && input . else !== null && { else : serializeAws_restJson1ComponentProperty ( input . else , context ) } ) , ... ( input . field !== undefined && input . field !== null && { field : input . field } ) , ... ( input . operand !== undefined && input . operand !== null && { operand : input . operand } ) , ... ( input . operator !== undefined && input . operator !== null && { operator : input . operator } ) , ... ( input . property !== undefined && input . property !== null && { property : input . property } ) , ... ( input . then !== undefined && input . then !== null && { then : serializeAws_restJson1ComponentProperty ( input . then , context ) } ) , } ; } ; const serializeAws_restJson1ComponentDataConfiguration = ( input , context ) : any => { return { ... ( input . identifiers !== undefined && input . identifiers !== null && { identifiers : serializeAws_restJson1IdentifierList ( input . identifiers , context ) } ) , ... ( input . model !== undefined && input . model !== null && { model : input . model } ) , ... ( input . predicate !== undefined && input . predicate !== null && { predicate : serializeAws_restJson1Predicate ( input . predicate , context ) } ) , ... ( input . sort !== undefined && input . sort !== null && { sort : serializeAws_restJson1SortPropertyList ( input . sort , context ) } ) , } ; } ; const serializeAws_restJson1ComponentOverrides = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : serializeAws_restJson1ComponentOverridesValue ( value , context ) , } ; } , { } ) ; } ; const serializeAws_restJson1ComponentOverridesValue = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : value , } ; } , { } ) ; } ; const serializeAws_restJson1ComponentProperties = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : serializeAws_restJson1ComponentProperty ( value , context ) , } ; } , { } ) ; } ; const serializeAws_restJson1ComponentProperty = ( input , context ) : any => { return { ... ( input . bindingProperties !== undefined && input . bindingProperties !== null && { bindingProperties : serializeAws_restJson1ComponentPropertyBindingProperties ( input . bindingProperties , context ) , } ) , ... ( input . bindings !== undefined && input . bindings !== null && { bindings : serializeAws_restJson1FormBindings ( input . bindings , context ) } ) , ... ( input . collectionBindingProperties !== undefined && input . collectionBindingProperties !== null && { collectionBindingProperties : serializeAws_restJson1ComponentPropertyBindingProperties ( input . collectionBindingProperties , context ) , } ) , ... ( input . concat !== undefined && input . concat !== null && { concat : serializeAws_restJson1ComponentPropertyList ( input . concat , context ) } ) , ... ( input . condition !== undefined && input . condition !== null && { condition : serializeAws_restJson1ComponentConditionProperty ( input . condition , context ) , } ) , ... ( input . configured !== undefined && input . configured !== null && { configured : input . configured } ) , ... ( input . defaultValue !== undefined && input . defaultValue !== null && { defaultValue : input . defaultValue } ) , ... ( input . event !== undefined && input . event !== null && { event : input . event } ) , ... ( input . importedValue !== undefined && input . importedValue !== null && { importedValue : input . importedValue } ) , ... ( input . model !== undefined && input . model !== null && { model : input . model } ) , ... ( input . type !== undefined && input . type !== null && { type : input . type } ) , ... ( input . userAttribute !== undefined && input . userAttribute !== null && { userAttribute : input . userAttribute } ) , ... ( input . value !== undefined && input . value !== null && { value : input . value } ) , } ; } ; const serializeAws_restJson1ComponentPropertyBindingProperties = ( input , context ) : any => { return { ... ( input . field !== undefined && input . field !== null && { field : input . field } ) , ... ( input . property !== undefined && input . property !== null && { property : input . property } ) , } ; } ; const serializeAws_restJson1ComponentPropertyList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1ComponentProperty ( entry , context ) ; } ) ; } ; const serializeAws_restJson1ComponentVariant = ( input , context ) : any => { return { ... ( input . overrides !== undefined && input . overrides !== null && { overrides : serializeAws_restJson1ComponentOverrides ( input . overrides , context ) } ) , ... ( input . variantValues !== undefined && input . variantValues !== null && { variantValues : serializeAws_restJson1ComponentVariantValues ( input . variantValues , context ) , } ) , } ; } ; const serializeAws_restJson1ComponentVariants = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1ComponentVariant ( entry , context ) ; } ) ; } ; const serializeAws_restJson1ComponentVariantValues = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : value , } ; } , { } ) ; } ; const serializeAws_restJson1CreateComponentData = ( input , context ) : any => { return { ... ( input . bindingProperties !== undefined && input . bindingProperties !== null && { bindingProperties : serializeAws_restJson1ComponentBindingProperties ( input . bindingProperties , context ) , } ) , ... ( input . children !== undefined && input . children !== null && { children : serializeAws_restJson1ComponentChildList ( input . children , context ) } ) , ... ( input . collectionProperties !== undefined && input . collectionProperties !== null && { collectionProperties : serializeAws_restJson1ComponentCollectionProperties ( input . collectionProperties , context ) , } ) , ... ( input . componentType !== undefined && input . componentType !== null && { componentType : input . componentType } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . overrides !== undefined && input . overrides !== null && { overrides : serializeAws_restJson1ComponentOverrides ( input . overrides , context ) } ) , ... ( input . properties !== undefined && input . properties !== null && { properties : serializeAws_restJson1ComponentProperties ( input . properties , context ) , } ) , ... ( input . sourceId !== undefined && input . sourceId !== null && { sourceId : input . sourceId } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1Tags ( input . tags , context ) } ) , ... ( input . variants !== undefined && input . variants !== null && { variants : serializeAws_restJson1ComponentVariants ( input . variants , context ) } ) , } ; } ; const serializeAws_restJson1CreateThemeData = ( input , context ) : any => { return { ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . overrides !== undefined && input . overrides !== null && { overrides : serializeAws_restJson1ThemeValuesList ( input . overrides , context ) } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1Tags ( input . tags , context ) } ) , ... ( input . values !== undefined && input . values !== null && { values : serializeAws_restJson1ThemeValuesList ( input . values , context ) } ) , } ; } ; const serializeAws_restJson1ExchangeCodeForTokenRequestBody = ( input , context ) : any => { return { ... ( input . code !== undefined && input . code !== null && { code : input . code } ) , ... ( input . redirectUri !== undefined && input . redirectUri !== null && { redirectUri : input . redirectUri } ) , } ; } ; const serializeAws_restJson1FormBindingElement = ( input , context ) : any => { return { ... ( input . element !== undefined && input . element !== null && { element : input . element } ) , ... ( input . property !== undefined && input . property !== null && { property : input . property } ) , } ; } ; const serializeAws_restJson1FormBindings = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : serializeAws_restJson1FormBindingElement ( value , context ) , } ; } , { } ) ; } ; const serializeAws_restJson1IdentifierList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1Predicate = ( input , context ) : any => { return { ... ( input . and !== undefined && input . and !== null && { and : serializeAws_restJson1PredicateList ( input . and , context ) } ) , ... ( input . field !== undefined && input . field !== null && { field : input . field } ) , ... ( input . operand !== undefined && input . operand !== null && { operand : input . operand } ) , ... ( input . operator !== undefined && input . operator !== null && { operator : input . operator } ) , ... ( input . or !== undefined && input . or !== null && { or : serializeAws_restJson1PredicateList ( input . or , context ) } ) , } ; } ; const serializeAws_restJson1PredicateList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1Predicate ( entry , context ) ; } ) ; } ; const serializeAws_restJson1RefreshTokenRequestBody = ( input , context ) : any => { return { ... ( input . token !== undefined && input . token !== null && { token : input . token } ) , } ; } ; const serializeAws_restJson1SortProperty = ( input , context ) : any => { return { ... ( input . direction !== undefined && input . direction !== null && { direction : input . direction } ) , ... ( input . field !== undefined && input . field !== null && { field : input . field } ) , } ; } ; const serializeAws_restJson1SortPropertyList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1SortProperty ( entry , context ) ; } ) ; } ; const serializeAws_restJson1Tags = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : value , } ; } , { } ) ; } ; const serializeAws_restJson1ThemeValue = ( input , context ) : any => { return { ... ( input . children !== undefined && input . children !== null && { children : serializeAws_restJson1ThemeValuesList ( input . children , context ) } ) , ... ( input . value !== undefined && input . value !== null && { value : input . value } ) , } ; } ; const serializeAws_restJson1ThemeValues = ( input , context ) : any => { return { ... ( input . key !== undefined && input . key !== null && { key : input . key } ) , ... ( input . value !== undefined && input . value !== null && { value : serializeAws_restJson1ThemeValue ( input . value , context ) } ) , } ; } ; const serializeAws_restJson1ThemeValuesList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1ThemeValues ( entry , context ) ; } ) ; } ; const serializeAws_restJson1UpdateComponentData = ( input , context ) : any => { return { ... ( input . bindingProperties !== undefined && input . bindingProperties !== null && { bindingProperties : serializeAws_restJson1ComponentBindingProperties ( input . bindingProperties , context ) , } ) , ... ( input . children !== undefined && input . children !== null && { children : serializeAws_restJson1ComponentChildList ( input . children , context ) } ) , ... ( input . collectionProperties !== undefined && input . collectionProperties !== null && { collectionProperties : serializeAws_restJson1ComponentCollectionProperties ( input . collectionProperties , context ) , } ) , ... ( input . componentType !== undefined && input . componentType !== null && { componentType : input . componentType } ) , ... ( input . id !== undefined && input . id !== null && { id : input . id } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . overrides !== undefined && input . overrides !== null && { overrides : serializeAws_restJson1ComponentOverrides ( input . overrides , context ) } ) , ... ( input . properties !== undefined && input . properties !== null && { properties : serializeAws_restJson1ComponentProperties ( input . properties , context ) , } ) , ... ( input . sourceId !== undefined && input . sourceId !== null && { sourceId : input . sourceId } ) , ... ( input . variants !== undefined && input . variants !== null && { variants : serializeAws_restJson1ComponentVariants ( input . variants , context ) } ) , } ; } ; const serializeAws_restJson1UpdateThemeData = ( input , context ) : any => { return { ... ( input . id !== undefined && input . id !== null && { id : input . id } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . overrides !== undefined && input . overrides !== null && { overrides : serializeAws_restJson1ThemeValuesList ( input . overrides , context ) } ) , ... ( input . values !== undefined && input . values !== null && { values : serializeAws_restJson1ThemeValuesList ( input . values , context ) } ) , } ; } ; const deserializeAws_restJson1Component = ( output , context ) : Component => { return { appId : __expectString ( output . appId ) , bindingProperties : output . bindingProperties !== undefined && output . bindingProperties !== null ? deserializeAws_restJson1ComponentBindingProperties ( output . bindingProperties , context ) : undefined , children : output . children !== undefined && output . children !== null ? deserializeAws_restJson1ComponentChildList ( output . children , context ) : undefined , collectionProperties : output . collectionProperties !== undefined && output . collectionProperties !== null ? deserializeAws_restJson1ComponentCollectionProperties ( output . collectionProperties , context ) : undefined , componentType : __expectString ( output . componentType ) , createdAt : output . createdAt !== undefined && output . createdAt !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . createdAt ) ) : undefined , environmentName : __expectString ( output . environmentName ) , id : __expectString ( output . id ) , modifiedAt : output . modifiedAt !== undefined && output . modifiedAt !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . modifiedAt ) ) : undefined , name : __expectString ( output . name ) , overrides : output . overrides !== undefined && output . overrides !== null ? deserializeAws_restJson1ComponentOverrides ( output . overrides , context ) : undefined , properties : output . properties !== undefined && output . properties !== null ? deserializeAws_restJson1ComponentProperties ( output . properties , context ) : undefined , sourceId : __expectString ( output . sourceId ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , variants : output . variants !== undefined && output . variants !== null ? deserializeAws_restJson1ComponentVariants ( output . variants , context ) : undefined , } as any ; } ; const deserializeAws_restJson1ComponentBindingProperties = ( output , context ) : { [ key ] : ComponentBindingPropertiesValue ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : deserializeAws_restJson1ComponentBindingPropertiesValue ( value , context ) , } ; } , { } ) ; } ; const deserializeAws_restJson1ComponentBindingPropertiesValue = ( output , context ) : ComponentBindingPropertiesValue => { return { bindingProperties : output . bindingProperties !== undefined && output . bindingProperties !== null ? deserializeAws_restJson1ComponentBindingPropertiesValueProperties ( output . bindingProperties , context ) : undefined , defaultValue : __expectString ( output . defaultValue ) , type : __expectString ( output . type ) , } as any ; } ; const deserializeAws_restJson1ComponentBindingPropertiesValueProperties = ( output , context ) : ComponentBindingPropertiesValueProperties => { return { bucket : __expectString ( output . bucket ) , defaultValue : __expectString ( output . defaultValue ) , field : __expectString ( output . field ) , key : __expectString ( output . key ) , model : __expectString ( output . model ) , predicates : output . predicates !== undefined && output . predicates !== null ? deserializeAws_restJson1PredicateList ( output . predicates , context ) : undefined , userAttribute : __expectString ( output . userAttribute ) , } as any ; } ; const deserializeAws_restJson1ComponentChild = ( output , context ) : ComponentChild => { return { children : output . children !== undefined && output . children !== null ? deserializeAws_restJson1ComponentChildList ( output . children , context ) : undefined , componentType : __expectString ( output . componentType ) , name : __expectString ( output . name ) , properties : output . properties !== undefined && output . properties !== null ? deserializeAws_restJson1ComponentProperties ( output . properties , context ) : undefined , } as any ; } ; const deserializeAws_restJson1ComponentChildList = ( output , context ) : ComponentChild [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ComponentChild ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ComponentCollectionProperties = ( output , context ) : { [ key ] : ComponentDataConfiguration ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : deserializeAws_restJson1ComponentDataConfiguration ( value , context ) , } ; } , { } ) ; } ; const deserializeAws_restJson1ComponentConditionProperty = ( output , context ) : ComponentConditionProperty => { return { else : output . else !== undefined && output . else !== null ? deserializeAws_restJson1ComponentProperty ( output . else , context ) : undefined , field : __expectString ( output . field ) , operand : __expectString ( output . operand ) , operator : __expectString ( output . operator ) , property : __expectString ( output . property ) , then : output . then !== undefined && output . then !== null ? deserializeAws_restJson1ComponentProperty ( output . then , context ) : undefined , } as any ; } ; const deserializeAws_restJson1ComponentDataConfiguration = ( output , context ) : ComponentDataConfiguration => { return { identifiers : output . identifiers !== undefined && output . identifiers !== null ? deserializeAws_restJson1IdentifierList ( output . identifiers , context ) : undefined , model : __expectString ( output . model ) , predicate : output . predicate !== undefined && output . predicate !== null ? deserializeAws_restJson1Predicate ( output . predicate , context ) : undefined , sort : output . sort !== undefined && output . sort !== null ? deserializeAws_restJson1SortPropertyList ( output . sort , context ) : undefined , } as any ; } ; const deserializeAws_restJson1ComponentList = ( output , context ) : Component [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1Component ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ComponentOverrides = ( output , context ) : { [ key ] : { [ key ] : string ; } ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : deserializeAws_restJson1ComponentOverridesValue ( value , context ) , } ; } , { } ) ; } ; const deserializeAws_restJson1ComponentOverridesValue = ( output , context ) : { [ key ] : string ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : __expectString ( value ) as any , } ; } , { } ) ; } ; const deserializeAws_restJson1ComponentProperties = ( output , context ) : { [ key ] : ComponentProperty ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : deserializeAws_restJson1ComponentProperty ( value , context ) , } ; } , { } ) ; } ; const deserializeAws_restJson1ComponentProperty = ( output , context ) : ComponentProperty => { return { bindingProperties : output . bindingProperties !== undefined && output . bindingProperties !== null ? deserializeAws_restJson1ComponentPropertyBindingProperties ( output . bindingProperties , context ) : undefined , bindings : output . bindings !== undefined && output . bindings !== null ? deserializeAws_restJson1FormBindings ( output . bindings , context ) : undefined , collectionBindingProperties : output . collectionBindingProperties !== undefined && output . collectionBindingProperties !== null ? deserializeAws_restJson1ComponentPropertyBindingProperties ( output . collectionBindingProperties , context ) : undefined , concat : output . concat !== undefined && output . concat !== null ? deserializeAws_restJson1ComponentPropertyList ( output . concat , context ) : undefined , condition : output . condition !== undefined && output . condition !== null ? deserializeAws_restJson1ComponentConditionProperty ( output . condition , context ) : undefined , configured : __expectBoolean ( output . configured ) , defaultValue : __expectString ( output . defaultValue ) , event : __expectString ( output . event ) , importedValue : __expectString ( output . importedValue ) , model : __expectString ( output . model ) , type : __expectString ( output . type ) , userAttribute : __expectString ( output . userAttribute ) , value : __expectString ( output . value ) , } as any ; } ; const deserializeAws_restJson1ComponentPropertyBindingProperties = ( output , context ) : ComponentPropertyBindingProperties => { return { field : __expectString ( output . field ) , property : __expectString ( output . property ) , } as any ; } ; const deserializeAws_restJson1ComponentPropertyList = ( output , context ) : ComponentProperty [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ComponentProperty ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ComponentSummary = ( output , context ) : ComponentSummary => { return { appId : __expectString ( output . appId ) , componentType : __expectString ( output . componentType ) , environmentName : __expectString ( output . environmentName ) , id : __expectString ( output . id ) , name : __expectString ( output . name ) , } as any ; } ; const deserializeAws_restJson1ComponentSummaryList = ( output , context ) : ComponentSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ComponentSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ComponentVariant = ( output , context ) : ComponentVariant => { return { overrides : output . overrides !== undefined && output . overrides !== null ? deserializeAws_restJson1ComponentOverrides ( output . overrides , context ) : undefined , variantValues : output . variantValues !== undefined && output . variantValues !== null ? deserializeAws_restJson1ComponentVariantValues ( output . variantValues , context ) : undefined , } as any ; } ; const deserializeAws_restJson1ComponentVariants = ( output , context ) : ComponentVariant [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ComponentVariant ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ComponentVariantValues = ( output , context ) : { [ key ] : string ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : __expectString ( value ) as any , } ; } , { } ) ; } ; const deserializeAws_restJson1FormBindingElement = ( output , context ) : FormBindingElement => { return { element : __expectString ( output . element ) , property : __expectString ( output . property ) , } as any ; } ; const deserializeAws_restJson1FormBindings = ( output , context ) : { [ key ] : FormBindingElement ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : deserializeAws_restJson1FormBindingElement ( value , context ) , } ; } , { } ) ; } ; const deserializeAws_restJson1IdentifierList = ( 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_restJson1Predicate = ( output , context ) : Predicate => { return { and : output . and !== undefined && output . and !== null ? deserializeAws_restJson1PredicateList ( output . and , context ) : undefined , field : __expectString ( output . field ) , operand : __expectString ( output . operand ) , operator : __expectString ( output . operator ) , or : output . or !== undefined && output . or !== null ? deserializeAws_restJson1PredicateList ( output . or , context ) : undefined , } as any ; } ; const deserializeAws_restJson1PredicateList = ( output , context ) : Predicate [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1Predicate ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1SortProperty = ( output , context ) : SortProperty => { return { direction : __expectString ( output . direction ) , field : __expectString ( output . field ) , } as any ; } ; const deserializeAws_restJson1SortPropertyList = ( output , context ) : SortProperty [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1SortProperty ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1Tags = ( output , context ) : { [ key ] : string ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : __expectString ( value ) as any , } ; } , { } ) ; } ; const deserializeAws_restJson1Theme = ( output , context ) : Theme => { return { appId : __expectString ( output . appId ) , createdAt : output . createdAt !== undefined && output . createdAt !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . createdAt ) ) : undefined , environmentName : __expectString ( output . environmentName ) , id : __expectString ( output . id ) , modifiedAt : output . modifiedAt !== undefined && output . modifiedAt !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . modifiedAt ) ) : undefined , name : __expectString ( output . name ) , overrides : output . overrides !== undefined && output . overrides !== null ? deserializeAws_restJson1ThemeValuesList ( output . overrides , context ) : undefined , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , values : output . values !== undefined && output . values !== null ? deserializeAws_restJson1ThemeValuesList ( output . values , context ) : undefined , } as any ; } ; const deserializeAws_restJson1ThemeList = ( output , context ) : Theme [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1Theme ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ThemeSummary = ( output , context ) : ThemeSummary => { return { appId : __expectString ( output . appId ) , environmentName : __expectString ( output . environmentName ) , id : __expectString ( output . id ) , name : __expectString ( output . name ) , } as any ; } ; const deserializeAws_restJson1ThemeSummaryList = ( output , context ) : ThemeSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ThemeSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ThemeValue = ( output , context ) : ThemeValue => { return { children : output . children !== undefined && output . children !== null ? deserializeAws_restJson1ThemeValuesList ( output . children , context ) : undefined , value : __expectString ( output . value ) , } as any ; } ; const deserializeAws_restJson1ThemeValues = ( output , context ) : ThemeValues => { return { key : __expectString ( output . key ) , value : output . value !== undefined && output . value !== null ? deserializeAws_restJson1ThemeValue ( output . value , context ) : undefined , } as any ; } ; const deserializeAws_restJson1ThemeValuesList = ( output , context ) : ThemeValues [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ThemeValues ( entry , context ) ; } ) ; } ; 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 isSerializableHeaderValue = ( value ) : boolean => value !== undefined && value !== null && value !== "" && ( ! Object . getOwnPropertyNames ( value ) . includes ( "length" ) || value . length != 0 ) && ( ! Object . getOwnPropertyNames ( value ) . includes ( "size" ) || value . size != 0 ) ; 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 "" ; } ;