Skip to content

Commit 423a7d1

Browse files
author
Chase Coalwell
committed
fix: await body parsing
1 parent cbe55c3 commit 423a7d1

File tree

1 file changed

+53
-17
lines changed

1 file changed

+53
-17
lines changed

clients/node/client-rds-data-node/protocol/AwsRestJson1_1.ts

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { SerializerUtils, DeserializerUtils } from "@aws-sdk/types";
1010
import * as __aws_sdk_stream_collector_node from "@aws-sdk/stream-collector-node";
1111
import * as __aws_sdk_util_utf8_node from "@aws-sdk/util-utf8-node";
1212
import { ResponseMetadata } from "@aws-sdk/types";
13+
import { forOfStatement } from "@babel/types";
1314

1415
type Utils = { [key: string]: any };
1516

@@ -65,14 +66,14 @@ export function executeStatementAwsRestJson1_1Serialize(
6566
});
6667
}
6768

68-
export function executeStatementAwsRestJson1_1Deserialize(
69+
export async function executeStatementAwsRestJson1_1Deserialize(
6970
output: HttpResponse,
7071
utils?: Utils
7172
): Promise<ExecuteStatementResponse> {
7273
if (output.statusCode !== 200) {
7374
return executeStatementAwsRestJson1_1DeserializeError(output);
7475
}
75-
let data: any = parseBody(output.body, utils);
76+
let data: any = await parseBody(output.body, utils);
7677
return Promise.resolve({
7778
$metadata: deserializeMetadata(output),
7879
__type: "com.amazon.rdsdataservice#ExecuteStatementResponse",
@@ -87,10 +88,10 @@ export function executeStatementAwsRestJson1_1Deserialize(
8788
});
8889
}
8990

90-
function executeStatementAwsRestJson1_1DeserializeError(
91+
async function executeStatementAwsRestJson1_1DeserializeError(
9192
output: HttpResponse
9293
): Promise<ExecuteStatementResponse> {
93-
let data = parseBody(output);
94+
let data = await parseBody(output);
9495
if (output.statusCode === 400 && data.dbConnectionId !== undefined) {
9596
return Promise.reject({
9697
__type: "com.amazon.rdsdataservice#StatementTimeoutException",
@@ -263,36 +264,70 @@ function columnMetadataListAwsRestJson1_1Deserialize(
263264
input: any
264265
): Array<ColumnMetadata> {
265266
let list: Array<ColumnMetadata> = [];
266-
for (let ColumnMetadata of input) {
267-
list.push(columnMetadataAwsRestJson1_1Deserialize(ColumnMetadata));
267+
if (input !== undefined) {
268+
for (let ColumnMetadata of input) {
269+
list.push(columnMetadataAwsRestJson1_1Deserialize(ColumnMetadata));
270+
}
268271
}
269272
return list;
270273
}
271274

272-
function fieldAwsRestJson1_1Deserialize(input: any): Field {
273-
return input.visit(input, {});
275+
function fieldAwsRestJson1_1Deserialize(input: any): any {
276+
return Field.visit(input, {
277+
blobValue: value => {
278+
value;
279+
},
280+
booleanValue: value => {
281+
return value;
282+
},
283+
arrayValue: value => {
284+
return value;
285+
},
286+
structValue: value => {
287+
return value;
288+
},
289+
longValue: value => {
290+
return value;
291+
},
292+
isNull: value => {
293+
return value;
294+
},
295+
doubleValue: value => {
296+
return value;
297+
},
298+
stringValue: value => {
299+
return value;
300+
},
301+
_: value => {
302+
return value;
303+
}
304+
});
274305
}
275306

276307
function generatedFieldsAwsRestJson1_1Deserialize(input: any): Array<Field> {
277308
let list: Array<Field> = [];
278-
for (let Field of input) {
279-
list.push(fieldAwsRestJson1_1Deserialize(Field));
309+
if (input !== undefined) {
310+
for (let Field of input) {
311+
list.push(fieldAwsRestJson1_1Deserialize(Field));
312+
}
280313
}
281314
return list;
282315
}
283316

284317
function recordsAwsRestJson1_1Deserialize(input: any): Array<Array<Field>> {
285318
let list: Array<Array<Field>> = [];
286-
for (let recordsList of input) {
287-
list.push(recordsListAwsRestJson1_1Deserialize(input));
319+
if (input !== undefined) {
320+
for (let recordsList of input) {
321+
list.push(recordsListAwsRestJson1_1Deserialize(recordsList));
322+
}
288323
}
289324
return list;
290325
}
291326

292327
function recordsListAwsRestJson1_1Deserialize(input: any): Array<Field> {
293328
let list: Array<Field> = [];
294-
for (let Field of input) {
295-
list.push(fieldAwsRestJson1_1Serialize(input));
329+
for (let field of input) {
330+
list.push(fieldAwsRestJson1_1Deserialize(field));
296331
}
297332
return list;
298333
}
@@ -301,7 +336,7 @@ function deserializeMetadata(output: HttpResponse): ResponseMetadata {
301336
return {
302337
httpStatusCode: output.statusCode,
303338
httpHeaders: output.headers,
304-
requestId: output.headers["x-amzn-RequestId"]
339+
requestId: output.headers["x-amzn-requestid"]
305340
};
306341
}
307342

@@ -314,7 +349,8 @@ function parseBody(streamBody: any, utils?: Utils): any {
314349
utils && utils["streamCollector"]
315350
? (<DeserializerUtils>utils)["utf8Encoder"]
316351
: __aws_sdk_util_utf8_node.toUtf8;
317-
streamCollector(streamBody).then(body => {
318-
return toUtf8(body);
352+
353+
return streamCollector(streamBody).then(body => {
354+
return JSON.parse(toUtf8(body));
319355
});
320356
}

0 commit comments

Comments
 (0)