Skip to content

Commit 5a92d6b

Browse files
authored
chore: use destructuring in xml deserializeMap (#1181)
1 parent 99ec3d1 commit 5a92d6b

File tree

12 files changed

+223
-142
lines changed

12 files changed

+223
-142
lines changed

clients/client-cloudsearch/protocols/Aws_query.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -4902,10 +4902,13 @@ const deserializeAws_queryDomainNameMap = (
49024902
output: any,
49034903
context: __SerdeContext
49044904
): { [key: string]: string } => {
4905-
return output.reduce((acc: any, pair: any) => {
4906-
acc[pair["key"]] = pair["value"];
4907-
return acc;
4908-
}, {});
4905+
return output.reduce(
4906+
(acc: any, pair: any) => ({
4907+
...acc,
4908+
[pair["key"]]: pair["value"]
4909+
}),
4910+
{}
4911+
);
49094912
};
49104913

49114914
const deserializeAws_queryDomainStatus = (

clients/client-cloudwatch/protocols/Aws_query.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -4637,10 +4637,13 @@ const deserializeAws_queryDatapointValueMap = (
46374637
output: any,
46384638
context: __SerdeContext
46394639
): { [key: string]: number } => {
4640-
return output.reduce((acc: any, pair: any) => {
4641-
acc[pair["key"]] = parseFloat(pair["value"]);
4642-
return acc;
4643-
}, {});
4640+
return output.reduce(
4641+
(acc: any, pair: any) => ({
4642+
...acc,
4643+
[pair["key"]]: parseFloat(pair["value"])
4644+
}),
4645+
{}
4646+
);
46444647
};
46454648

46464649
const deserializeAws_queryDatapointValues = (

clients/client-elastic-load-balancing-v2/protocols/Aws_query.ts

+14-8
Original file line numberDiff line numberDiff line change
@@ -6673,10 +6673,13 @@ const deserializeAws_queryAuthenticateCognitoActionAuthenticationRequestExtraPar
66736673
output: any,
66746674
context: __SerdeContext
66756675
): { [key: string]: string } => {
6676-
return output.reduce((acc: any, pair: any) => {
6677-
acc[pair["key"]] = pair["value"];
6678-
return acc;
6679-
}, {});
6676+
return output.reduce(
6677+
(acc: any, pair: any) => ({
6678+
...acc,
6679+
[pair["key"]]: pair["value"]
6680+
}),
6681+
{}
6682+
);
66806683
};
66816684

66826685
const deserializeAws_queryAuthenticateCognitoActionConfig = (
@@ -6736,10 +6739,13 @@ const deserializeAws_queryAuthenticateOidcActionAuthenticationRequestExtraParams
67366739
output: any,
67376740
context: __SerdeContext
67386741
): { [key: string]: string } => {
6739-
return output.reduce((acc: any, pair: any) => {
6740-
acc[pair["key"]] = pair["value"];
6741-
return acc;
6742-
}, {});
6742+
return output.reduce(
6743+
(acc: any, pair: any) => ({
6744+
...acc,
6745+
[pair["key"]]: pair["value"]
6746+
}),
6747+
{}
6748+
);
67436749
};
67446750

67456751
const deserializeAws_queryAuthenticateOidcActionConfig = (

clients/client-iam/protocols/Aws_query.ts

+14-8
Original file line numberDiff line numberDiff line change
@@ -18235,10 +18235,13 @@ const deserializeAws_queryEvalDecisionDetailsType = (
1823518235
output: any,
1823618236
context: __SerdeContext
1823718237
): { [key: string]: PolicyEvaluationDecisionType | string } => {
18238-
return output.reduce((acc: any, pair: any) => {
18239-
acc[pair["key"]] = pair["value"];
18240-
return acc;
18241-
}, {});
18238+
return output.reduce(
18239+
(acc: any, pair: any) => ({
18240+
...acc,
18241+
[pair["key"]]: pair["value"]
18242+
}),
18243+
{}
18244+
);
1824218245
};
1824318246

1824418247
const deserializeAws_queryEvaluationResult = (
@@ -21874,10 +21877,13 @@ const deserializeAws_querysummaryMapType = (
2187421877
output: any,
2187521878
context: __SerdeContext
2187621879
): { [key: string]: number } => {
21877-
return output.reduce((acc: any, pair: any) => {
21878-
acc[pair["key"]] = parseInt(pair["value"]);
21879-
return acc;
21880-
}, {});
21880+
return output.reduce(
21881+
(acc: any, pair: any) => ({
21882+
...acc,
21883+
[pair["key"]]: parseInt(pair["value"])
21884+
}),
21885+
{}
21886+
);
2188121887
};
2188221888

2188321889
const deserializeAws_querytagListType = (

clients/client-s3-control/protocols/Aws_restXml.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -3469,10 +3469,13 @@ const deserializeAws_restXmlS3UserMetadata = (
34693469
output: any,
34703470
context: __SerdeContext
34713471
): { [key: string]: string } => {
3472-
return output.reduce((acc: any, pair: any) => {
3473-
acc[pair["key"]] = pair["value"];
3474-
return acc;
3475-
}, {});
3472+
return output.reduce(
3473+
(acc: any, pair: any) => ({
3474+
...acc,
3475+
[pair["key"]]: pair["value"]
3476+
}),
3477+
{}
3478+
);
34763479
};
34773480

34783481
const deserializeAws_restXmlVpcConfiguration = (

clients/client-ses/protocols/Aws_query.ts

+47-32
Original file line numberDiff line numberDiff line change
@@ -9918,13 +9918,16 @@ const deserializeAws_queryDkimAttributes = (
99189918
output: any,
99199919
context: __SerdeContext
99209920
): { [key: string]: IdentityDkimAttributes } => {
9921-
return output.reduce((acc: any, pair: any) => {
9922-
acc[pair["key"]] = deserializeAws_queryIdentityDkimAttributes(
9923-
pair["value"],
9924-
context
9925-
);
9926-
return acc;
9927-
}, {});
9921+
return output.reduce(
9922+
(acc: any, pair: any) => ({
9923+
...acc,
9924+
[pair["key"]]: deserializeAws_queryIdentityDkimAttributes(
9925+
pair["value"],
9926+
context
9927+
)
9928+
}),
9929+
{}
9930+
);
99289931
};
99299932

99309933
const deserializeAws_queryEventDestination = (
@@ -10877,13 +10880,16 @@ const deserializeAws_queryMailFromDomainAttributes = (
1087710880
output: any,
1087810881
context: __SerdeContext
1087910882
): { [key: string]: IdentityMailFromDomainAttributes } => {
10880-
return output.reduce((acc: any, pair: any) => {
10881-
acc[pair["key"]] = deserializeAws_queryIdentityMailFromDomainAttributes(
10882-
pair["value"],
10883-
context
10884-
);
10885-
return acc;
10886-
}, {});
10883+
return output.reduce(
10884+
(acc: any, pair: any) => ({
10885+
...acc,
10886+
[pair["key"]]: deserializeAws_queryIdentityMailFromDomainAttributes(
10887+
pair["value"],
10888+
context
10889+
)
10890+
}),
10891+
{}
10892+
);
1088710893
};
1088810894

1088910895
const deserializeAws_queryMailFromDomainNotVerifiedException = (
@@ -10936,23 +10942,29 @@ const deserializeAws_queryNotificationAttributes = (
1093610942
output: any,
1093710943
context: __SerdeContext
1093810944
): { [key: string]: IdentityNotificationAttributes } => {
10939-
return output.reduce((acc: any, pair: any) => {
10940-
acc[pair["key"]] = deserializeAws_queryIdentityNotificationAttributes(
10941-
pair["value"],
10942-
context
10943-
);
10944-
return acc;
10945-
}, {});
10945+
return output.reduce(
10946+
(acc: any, pair: any) => ({
10947+
...acc,
10948+
[pair["key"]]: deserializeAws_queryIdentityNotificationAttributes(
10949+
pair["value"],
10950+
context
10951+
)
10952+
}),
10953+
{}
10954+
);
1094610955
};
1094710956

1094810957
const deserializeAws_queryPolicyMap = (
1094910958
output: any,
1095010959
context: __SerdeContext
1095110960
): { [key: string]: string } => {
10952-
return output.reduce((acc: any, pair: any) => {
10953-
acc[pair["key"]] = pair["value"];
10954-
return acc;
10955-
}, {});
10961+
return output.reduce(
10962+
(acc: any, pair: any) => ({
10963+
...acc,
10964+
[pair["key"]]: pair["value"]
10965+
}),
10966+
{}
10967+
);
1095610968
};
1095710969

1095810970
const deserializeAws_queryPolicyNameList = (
@@ -11733,13 +11745,16 @@ const deserializeAws_queryVerificationAttributes = (
1173311745
output: any,
1173411746
context: __SerdeContext
1173511747
): { [key: string]: IdentityVerificationAttributes } => {
11736-
return output.reduce((acc: any, pair: any) => {
11737-
acc[pair["key"]] = deserializeAws_queryIdentityVerificationAttributes(
11738-
pair["value"],
11739-
context
11740-
);
11741-
return acc;
11742-
}, {});
11748+
return output.reduce(
11749+
(acc: any, pair: any) => ({
11750+
...acc,
11751+
[pair["key"]]: deserializeAws_queryIdentityVerificationAttributes(
11752+
pair["value"],
11753+
context
11754+
)
11755+
}),
11756+
{}
11757+
);
1174311758
};
1174411759

1174511760
const deserializeAws_queryVerificationTokenList = (

clients/client-sns/protocols/Aws_query.ts

+21-12
Original file line numberDiff line numberDiff line change
@@ -5914,10 +5914,13 @@ const deserializeAws_queryMapStringToString = (
59145914
output: any,
59155915
context: __SerdeContext
59165916
): { [key: string]: string } => {
5917-
return output.reduce((acc: any, pair: any) => {
5918-
acc[pair["key"]] = pair["value"];
5919-
return acc;
5920-
}, {});
5917+
return output.reduce(
5918+
(acc: any, pair: any) => ({
5919+
...acc,
5920+
[pair["key"]]: pair["value"]
5921+
}),
5922+
{}
5923+
);
59215924
};
59225925

59235926
const deserializeAws_queryNotFoundException = (
@@ -6092,10 +6095,13 @@ const deserializeAws_querySubscriptionAttributesMap = (
60926095
output: any,
60936096
context: __SerdeContext
60946097
): { [key: string]: string } => {
6095-
return output.reduce((acc: any, pair: any) => {
6096-
acc[pair["key"]] = pair["value"];
6097-
return acc;
6098-
}, {});
6098+
return output.reduce(
6099+
(acc: any, pair: any) => ({
6100+
...acc,
6101+
[pair["key"]]: pair["value"]
6102+
}),
6103+
{}
6104+
);
60996105
};
61006106

61016107
const deserializeAws_querySubscriptionLimitExceededException = (
@@ -6215,10 +6221,13 @@ const deserializeAws_queryTopicAttributesMap = (
62156221
output: any,
62166222
context: __SerdeContext
62176223
): { [key: string]: string } => {
6218-
return output.reduce((acc: any, pair: any) => {
6219-
acc[pair["key"]] = pair["value"];
6220-
return acc;
6221-
}, {});
6224+
return output.reduce(
6225+
(acc: any, pair: any) => ({
6226+
...acc,
6227+
[pair["key"]]: pair["value"]
6228+
}),
6229+
{}
6230+
);
62226231
};
62236232

62246233
const deserializeAws_queryTopicLimitExceededException = (

clients/client-sqs/protocols/Aws_query.ts

+31-19
Original file line numberDiff line numberDiff line change
@@ -3251,13 +3251,16 @@ const deserializeAws_queryMessageBodyAttributeMap = (
32513251
output: any,
32523252
context: __SerdeContext
32533253
): { [key: string]: MessageAttributeValue } => {
3254-
return output.reduce((acc: any, pair: any) => {
3255-
acc[pair["Name"]] = deserializeAws_queryMessageAttributeValue(
3256-
pair["Value"],
3257-
context
3258-
);
3259-
return acc;
3260-
}, {});
3254+
return output.reduce(
3255+
(acc: any, pair: any) => ({
3256+
...acc,
3257+
[pair["Name"]]: deserializeAws_queryMessageAttributeValue(
3258+
pair["Value"],
3259+
context
3260+
)
3261+
}),
3262+
{}
3263+
);
32613264
};
32623265

32633266
const deserializeAws_queryMessageList = (
@@ -3283,10 +3286,13 @@ const deserializeAws_queryMessageSystemAttributeMap = (
32833286
output: any,
32843287
context: __SerdeContext
32853288
): { [key: string]: string } => {
3286-
return output.reduce((acc: any, pair: any) => {
3287-
acc[pair["Name"]] = pair["Value"];
3288-
return acc;
3289-
}, {});
3289+
return output.reduce(
3290+
(acc: any, pair: any) => ({
3291+
...acc,
3292+
[pair["Name"]]: pair["Value"]
3293+
}),
3294+
{}
3295+
);
32903296
};
32913297

32923298
const deserializeAws_queryOverLimit = (
@@ -3313,10 +3319,13 @@ const deserializeAws_queryQueueAttributeMap = (
33133319
output: any,
33143320
context: __SerdeContext
33153321
): { [key: string]: string } => {
3316-
return output.reduce((acc: any, pair: any) => {
3317-
acc[pair["Name"]] = pair["Value"];
3318-
return acc;
3319-
}, {});
3322+
return output.reduce(
3323+
(acc: any, pair: any) => ({
3324+
...acc,
3325+
[pair["Name"]]: pair["Value"]
3326+
}),
3327+
{}
3328+
);
33203329
};
33213330

33223331
const deserializeAws_queryQueueDeletedRecently = (
@@ -3502,10 +3511,13 @@ const deserializeAws_queryTagMap = (
35023511
output: any,
35033512
context: __SerdeContext
35043513
): { [key: string]: string } => {
3505-
return output.reduce((acc: any, pair: any) => {
3506-
acc[pair["Key"]] = pair["Value"];
3507-
return acc;
3508-
}, {});
3514+
return output.reduce(
3515+
(acc: any, pair: any) => ({
3516+
...acc,
3517+
[pair["Key"]]: pair["Value"]
3518+
}),
3519+
{}
3520+
);
35093521
};
35103522

35113523
const deserializeAws_queryTooManyEntriesInBatchRequest = (

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/XmlShapeDeserVisitor.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ protected void deserializeMap(GenerationContext context, MapShape shape) {
104104

105105
// Get the right serialization for each entry in the map. Undefined
106106
// outputs won't have this deserializer invoked.
107-
writer.openBlock("return output.reduce((acc: any, pair: any) => {", "}, {});", () -> {
107+
writer.openBlock("return output.reduce((acc: any, pair: any) => ({", "}), {});", () -> {
108+
writer.write("...acc,");
108109
// Dispatch to the output value provider for any additional handling.
109110
String dataSource = getUnnamedTargetWrapper(context, target, "pair[\"" + valueLocation + "\"]");
110-
writer.write("acc[pair[$S]] = $L;", keyLocation, target.accept(getMemberVisitor(dataSource)));
111-
writer.write("return acc;");
111+
writer.write("[pair[$S]]: $L", keyLocation, target.accept(getMemberVisitor(dataSource)));
112112
});
113113
}
114114

0 commit comments

Comments
 (0)