@aws-sdk/core 3.862.0 → 3.864.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist-cjs/submodules/protocols/index.js +73 -25
  2. package/dist-es/submodules/protocols/json/AwsJson1_0Protocol.js +5 -1
  3. package/dist-es/submodules/protocols/json/AwsJson1_1Protocol.js +5 -1
  4. package/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +4 -3
  5. package/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +5 -2
  6. package/dist-es/submodules/protocols/json/JsonShapeSerializer.js +11 -7
  7. package/dist-es/submodules/protocols/json/jsonReplacer.js +1 -1
  8. package/dist-es/submodules/protocols/query/AwsQueryProtocol.js +3 -0
  9. package/dist-es/submodules/protocols/query/QueryShapeSerializer.js +6 -2
  10. package/dist-es/submodules/protocols/xml/AwsRestXmlProtocol.js +6 -3
  11. package/dist-es/submodules/protocols/xml/XmlShapeSerializer.js +11 -7
  12. package/dist-types/submodules/protocols/json/AwsJson1_0Protocol.d.ts +6 -1
  13. package/dist-types/submodules/protocols/json/AwsJson1_1Protocol.d.ts +6 -1
  14. package/dist-types/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +3 -1
  15. package/dist-types/submodules/protocols/json/AwsRestJsonProtocol.d.ts +4 -0
  16. package/dist-types/submodules/protocols/query/AwsQueryProtocol.d.ts +4 -0
  17. package/dist-types/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +4 -0
  18. package/dist-types/ts3.4/submodules/protocols/json/AwsJson1_0Protocol.d.ts +8 -1
  19. package/dist-types/ts3.4/submodules/protocols/json/AwsJson1_1Protocol.d.ts +8 -1
  20. package/dist-types/ts3.4/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +8 -1
  21. package/dist-types/ts3.4/submodules/protocols/json/AwsRestJsonProtocol.d.ts +1 -0
  22. package/dist-types/ts3.4/submodules/protocols/query/AwsQueryProtocol.d.ts +1 -0
  23. package/dist-types/ts3.4/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +1 -0
  24. package/package.json +1 -1
@@ -304,7 +304,6 @@ var JsonShapeDeserializer = class extends SerdeContextConfig {
304
304
  // src/submodules/protocols/json/JsonShapeSerializer.ts
305
305
  var import_schema2 = require("@smithy/core/schema");
306
306
  var import_serde4 = require("@smithy/core/serde");
307
- var import_serde5 = require("@smithy/core/serde");
308
307
 
309
308
  // src/submodules/protocols/json/jsonReplacer.ts
310
309
  var import_serde3 = require("@smithy/core/serde");
@@ -333,7 +332,7 @@ var JsonReplacer = class {
333
332
  this.stage = 1;
334
333
  return (key, value) => {
335
334
  if (value instanceof import_serde3.NumericValue) {
336
- const v = `${NUMERIC_CONTROL_CHAR + +"nv" + this.counter++}_` + value.string;
335
+ const v = `${NUMERIC_CONTROL_CHAR + "nv" + this.counter++}_` + value.string;
337
336
  this.values.set(`"${v}"`, value.string);
338
337
  return v;
339
338
  }
@@ -455,11 +454,16 @@ var JsonShapeSerializer = class extends SerdeContextConfig {
455
454
  return String(value);
456
455
  }
457
456
  }
458
- const mediaType = ns.getMergedTraits().mediaType;
459
- if (ns.isStringSchema() && typeof value === "string" && mediaType) {
460
- const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
461
- if (isJson) {
462
- return import_serde5.LazyJsonString.from(value);
457
+ if (ns.isStringSchema()) {
458
+ if (typeof value === "undefined" && ns.isIdempotencyToken()) {
459
+ return (0, import_serde4.generateIdempotencyToken)();
460
+ }
461
+ const mediaType = ns.getMergedTraits().mediaType;
462
+ if (typeof value === "string" && mediaType) {
463
+ const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
464
+ if (isJson) {
465
+ return import_serde4.LazyJsonString.from(value);
466
+ }
463
467
  }
464
468
  }
465
469
  return value;
@@ -494,11 +498,13 @@ var AwsJsonRpcProtocol = class extends import_protocols.RpcProtocol {
494
498
  }
495
499
  serializer;
496
500
  deserializer;
501
+ serviceTarget;
497
502
  codec;
498
- constructor({ defaultNamespace }) {
503
+ constructor({ defaultNamespace, serviceTarget }) {
499
504
  super({
500
505
  defaultNamespace
501
506
  });
507
+ this.serviceTarget = serviceTarget;
502
508
  this.codec = new JsonCodec({
503
509
  timestampFormat: {
504
510
  useTrait: true,
@@ -516,7 +522,7 @@ var AwsJsonRpcProtocol = class extends import_protocols.RpcProtocol {
516
522
  }
517
523
  Object.assign(request.headers, {
518
524
  "content-type": `application/x-amz-json-${this.getJsonRpcVersion()}`,
519
- "x-amz-target": (this.getJsonRpcVersion() === "1.0" ? `JsonRpc10.` : `JsonProtocol.`) + import_schema3.NormalizedSchema.of(operationSchema).getName()
525
+ "x-amz-target": `${this.serviceTarget}.${import_schema3.NormalizedSchema.of(operationSchema).getName()}`
520
526
  });
521
527
  if ((0, import_schema3.deref)(operationSchema.input) === "unit" || !request.body) {
522
528
  request.body = "{}";
@@ -574,9 +580,10 @@ var AwsJson1_0Protocol = class extends AwsJsonRpcProtocol {
574
580
  static {
575
581
  __name(this, "AwsJson1_0Protocol");
576
582
  }
577
- constructor({ defaultNamespace }) {
583
+ constructor({ defaultNamespace, serviceTarget }) {
578
584
  super({
579
- defaultNamespace
585
+ defaultNamespace,
586
+ serviceTarget
580
587
  });
581
588
  }
582
589
  getShapeId() {
@@ -585,6 +592,12 @@ var AwsJson1_0Protocol = class extends AwsJsonRpcProtocol {
585
592
  getJsonRpcVersion() {
586
593
  return "1.0";
587
594
  }
595
+ /**
596
+ * @override
597
+ */
598
+ getDefaultContentType() {
599
+ return "application/x-amz-json-1.0";
600
+ }
588
601
  };
589
602
 
590
603
  // src/submodules/protocols/json/AwsJson1_1Protocol.ts
@@ -592,9 +605,10 @@ var AwsJson1_1Protocol = class extends AwsJsonRpcProtocol {
592
605
  static {
593
606
  __name(this, "AwsJson1_1Protocol");
594
607
  }
595
- constructor({ defaultNamespace }) {
608
+ constructor({ defaultNamespace, serviceTarget }) {
596
609
  super({
597
- defaultNamespace
610
+ defaultNamespace,
611
+ serviceTarget
598
612
  });
599
613
  }
600
614
  getShapeId() {
@@ -603,6 +617,12 @@ var AwsJson1_1Protocol = class extends AwsJsonRpcProtocol {
603
617
  getJsonRpcVersion() {
604
618
  return "1.1";
605
619
  }
620
+ /**
621
+ * @override
622
+ */
623
+ getDefaultContentType() {
624
+ return "application/x-amz-json-1.1";
625
+ }
606
626
  };
607
627
 
608
628
  // src/submodules/protocols/json/AwsRestJsonProtocol.ts
@@ -659,7 +679,7 @@ var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
659
679
  } else if (httpPayloadMember.isBlobSchema()) {
660
680
  request.headers["content-type"] = "application/octet-stream";
661
681
  } else {
662
- request.headers["content-type"] = "application/json";
682
+ request.headers["content-type"] = this.getDefaultContentType();
663
683
  }
664
684
  } else if (!inputSchema.isUnitSchema()) {
665
685
  const hasBody = Object.values(members).find((m) => {
@@ -667,7 +687,7 @@ var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
667
687
  return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && httpPrefixHeaders === void 0;
668
688
  });
669
689
  if (hasBody) {
670
- request.headers["content-type"] = "application/json";
690
+ request.headers["content-type"] = this.getDefaultContentType();
671
691
  }
672
692
  }
673
693
  }
@@ -719,6 +739,12 @@ var AwsRestJsonProtocol = class extends import_protocols2.HttpBindingProtocol {
719
739
  });
720
740
  throw exception;
721
741
  }
742
+ /**
743
+ * @override
744
+ */
745
+ getDefaultContentType() {
746
+ return "application/json";
747
+ }
722
748
  };
723
749
 
724
750
  // src/submodules/protocols/json/awsExpectUnion.ts
@@ -893,7 +919,7 @@ var XmlShapeDeserializer = class extends SerdeContextConfig {
893
919
  // src/submodules/protocols/query/QueryShapeSerializer.ts
894
920
  var import_protocols4 = require("@smithy/core/protocols");
895
921
  var import_schema6 = require("@smithy/core/schema");
896
- var import_serde6 = require("@smithy/core/serde");
922
+ var import_serde5 = require("@smithy/core/serde");
897
923
  var import_smithy_client4 = require("@smithy/smithy-client");
898
924
  var import_util_base642 = require("@smithy/util-base64");
899
925
  var QueryShapeSerializer = class extends SerdeContextConfig {
@@ -922,6 +948,9 @@ var QueryShapeSerializer = class extends SerdeContextConfig {
922
948
  if (value != null) {
923
949
  this.writeKey(prefix);
924
950
  this.writeValue(String(value));
951
+ } else if (ns.isIdempotencyToken()) {
952
+ this.writeKey(prefix);
953
+ this.writeValue((0, import_serde5.generateIdempotencyToken)());
925
954
  }
926
955
  } else if (ns.isBigIntegerSchema()) {
927
956
  if (value != null) {
@@ -931,7 +960,7 @@ var QueryShapeSerializer = class extends SerdeContextConfig {
931
960
  } else if (ns.isBigDecimalSchema()) {
932
961
  if (value != null) {
933
962
  this.writeKey(prefix);
934
- this.writeValue(value instanceof import_serde6.NumericValue ? value.string : String(value));
963
+ this.writeValue(value instanceof import_serde5.NumericValue ? value.string : String(value));
935
964
  }
936
965
  } else if (ns.isTimestampSchema()) {
937
966
  if (value instanceof Date) {
@@ -995,7 +1024,7 @@ var QueryShapeSerializer = class extends SerdeContextConfig {
995
1024
  } else if (ns.isStructSchema()) {
996
1025
  if (value && typeof value === "object") {
997
1026
  for (const [memberName, member] of ns.structIterator()) {
998
- if (value[memberName] == null) {
1027
+ if (value[memberName] == null && !member.isIdempotencyToken()) {
999
1028
  continue;
1000
1029
  }
1001
1030
  const suffix = this.getKey(memberName, member.getMergedTraits().xmlName);
@@ -1186,6 +1215,12 @@ var AwsQueryProtocol = class extends import_protocols5.RpcProtocol {
1186
1215
  const errorData = this.loadQueryError(data);
1187
1216
  return errorData?.message ?? errorData?.Message ?? data.message ?? data.Message ?? "Unknown";
1188
1217
  }
1218
+ /**
1219
+ * @override
1220
+ */
1221
+ getDefaultContentType() {
1222
+ return "application/x-www-form-urlencoded";
1223
+ }
1189
1224
  };
1190
1225
 
1191
1226
  // src/submodules/protocols/query/AwsEc2QueryProtocol.ts
@@ -1276,7 +1311,7 @@ var loadRestXmlErrorCode = /* @__PURE__ */ __name((output, data) => {
1276
1311
  // src/submodules/protocols/xml/XmlShapeSerializer.ts
1277
1312
  var import_xml_builder = require("@aws-sdk/xml-builder");
1278
1313
  var import_schema8 = require("@smithy/core/schema");
1279
- var import_serde7 = require("@smithy/core/serde");
1314
+ var import_serde6 = require("@smithy/core/serde");
1280
1315
  var import_smithy_client6 = require("@smithy/smithy-client");
1281
1316
  var import_util_base643 = require("@smithy/util-base64");
1282
1317
  var XmlShapeSerializer = class extends SerdeContextConfig {
@@ -1341,7 +1376,7 @@ var XmlShapeSerializer = class extends SerdeContextConfig {
1341
1376
  }
1342
1377
  for (const [memberName, memberSchema] of ns.structIterator()) {
1343
1378
  const val = value[memberName];
1344
- if (val != null) {
1379
+ if (val != null || memberSchema.isIdempotencyToken()) {
1345
1380
  if (memberSchema.getMergedTraits().xmlAttribute) {
1346
1381
  structXmlNode.addAttribute(
1347
1382
  memberSchema.getMergedTraits().xmlName ?? memberName,
@@ -1502,7 +1537,7 @@ var XmlShapeSerializer = class extends SerdeContextConfig {
1502
1537
  break;
1503
1538
  }
1504
1539
  } else if (ns.isBigDecimalSchema() && value) {
1505
- if (value instanceof import_serde7.NumericValue) {
1540
+ if (value instanceof import_serde6.NumericValue) {
1506
1541
  return value.string;
1507
1542
  }
1508
1543
  return String(value);
@@ -1518,9 +1553,16 @@ var XmlShapeSerializer = class extends SerdeContextConfig {
1518
1553
  );
1519
1554
  }
1520
1555
  }
1521
- if (ns.isStringSchema() || ns.isBooleanSchema() || ns.isNumericSchema() || ns.isBigIntegerSchema() || ns.isBigDecimalSchema()) {
1556
+ if (ns.isBooleanSchema() || ns.isNumericSchema() || ns.isBigIntegerSchema() || ns.isBigDecimalSchema()) {
1522
1557
  nodeContents = String(value);
1523
1558
  }
1559
+ if (ns.isStringSchema()) {
1560
+ if (value === void 0 && ns.isIdempotencyToken()) {
1561
+ nodeContents = (0, import_serde6.generateIdempotencyToken)();
1562
+ } else {
1563
+ nodeContents = String(value);
1564
+ }
1565
+ }
1524
1566
  if (nodeContents === null) {
1525
1567
  throw new Error(`Unhandled schema-value pair ${ns.getName(true)}=${value}`);
1526
1568
  }
@@ -1616,7 +1658,7 @@ var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
1616
1658
  } else if (httpPayloadMember.isBlobSchema()) {
1617
1659
  request.headers["content-type"] = "application/octet-stream";
1618
1660
  } else {
1619
- request.headers["content-type"] = "application/xml";
1661
+ request.headers["content-type"] = this.getDefaultContentType();
1620
1662
  }
1621
1663
  } else if (!ns.isUnitSchema()) {
1622
1664
  const hasBody = Object.values(members).find((m) => {
@@ -1624,11 +1666,11 @@ var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
1624
1666
  return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && httpPrefixHeaders === void 0;
1625
1667
  });
1626
1668
  if (hasBody) {
1627
- request.headers["content-type"] = "application/xml";
1669
+ request.headers["content-type"] = this.getDefaultContentType();
1628
1670
  }
1629
1671
  }
1630
1672
  }
1631
- if (request.headers["content-type"] === "application/xml") {
1673
+ if (request.headers["content-type"] === this.getDefaultContentType()) {
1632
1674
  if (typeof request.body === "string") {
1633
1675
  request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
1634
1676
  }
@@ -1682,6 +1724,12 @@ var AwsRestXmlProtocol = class extends import_protocols6.HttpBindingProtocol {
1682
1724
  });
1683
1725
  throw exception;
1684
1726
  }
1727
+ /**
1728
+ * @override
1729
+ */
1730
+ getDefaultContentType() {
1731
+ return "application/xml";
1732
+ }
1685
1733
  };
1686
1734
  // Annotate the CommonJS export names for ESM import in node:
1687
1735
  0 && (module.exports = {
@@ -1,8 +1,9 @@
1
1
  import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol";
2
2
  export class AwsJson1_0Protocol extends AwsJsonRpcProtocol {
3
- constructor({ defaultNamespace }) {
3
+ constructor({ defaultNamespace, serviceTarget }) {
4
4
  super({
5
5
  defaultNamespace,
6
+ serviceTarget,
6
7
  });
7
8
  }
8
9
  getShapeId() {
@@ -11,4 +12,7 @@ export class AwsJson1_0Protocol extends AwsJsonRpcProtocol {
11
12
  getJsonRpcVersion() {
12
13
  return "1.0";
13
14
  }
15
+ getDefaultContentType() {
16
+ return "application/x-amz-json-1.0";
17
+ }
14
18
  }
@@ -1,8 +1,9 @@
1
1
  import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol";
2
2
  export class AwsJson1_1Protocol extends AwsJsonRpcProtocol {
3
- constructor({ defaultNamespace }) {
3
+ constructor({ defaultNamespace, serviceTarget }) {
4
4
  super({
5
5
  defaultNamespace,
6
+ serviceTarget,
6
7
  });
7
8
  }
8
9
  getShapeId() {
@@ -11,4 +12,7 @@ export class AwsJson1_1Protocol extends AwsJsonRpcProtocol {
11
12
  getJsonRpcVersion() {
12
13
  return "1.1";
13
14
  }
15
+ getDefaultContentType() {
16
+ return "application/x-amz-json-1.1";
17
+ }
14
18
  }
@@ -6,11 +6,13 @@ import { loadRestJsonErrorCode } from "./parseJsonBody";
6
6
  export class AwsJsonRpcProtocol extends RpcProtocol {
7
7
  serializer;
8
8
  deserializer;
9
+ serviceTarget;
9
10
  codec;
10
- constructor({ defaultNamespace }) {
11
+ constructor({ defaultNamespace, serviceTarget }) {
11
12
  super({
12
13
  defaultNamespace,
13
14
  });
15
+ this.serviceTarget = serviceTarget;
14
16
  this.codec = new JsonCodec({
15
17
  timestampFormat: {
16
18
  useTrait: true,
@@ -28,8 +30,7 @@ export class AwsJsonRpcProtocol extends RpcProtocol {
28
30
  }
29
31
  Object.assign(request.headers, {
30
32
  "content-type": `application/x-amz-json-${this.getJsonRpcVersion()}`,
31
- "x-amz-target": (this.getJsonRpcVersion() === "1.0" ? `JsonRpc10.` : `JsonProtocol.`) +
32
- NormalizedSchema.of(operationSchema).getName(),
33
+ "x-amz-target": `${this.serviceTarget}.${NormalizedSchema.of(operationSchema).getName()}`,
33
34
  });
34
35
  if (deref(operationSchema.input) === "unit" || !request.body) {
35
36
  request.body = "{}";
@@ -53,7 +53,7 @@ export class AwsRestJsonProtocol extends HttpBindingProtocol {
53
53
  request.headers["content-type"] = "application/octet-stream";
54
54
  }
55
55
  else {
56
- request.headers["content-type"] = "application/json";
56
+ request.headers["content-type"] = this.getDefaultContentType();
57
57
  }
58
58
  }
59
59
  else if (!inputSchema.isUnitSchema()) {
@@ -62,7 +62,7 @@ export class AwsRestJsonProtocol extends HttpBindingProtocol {
62
62
  return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && httpPrefixHeaders === void 0;
63
63
  });
64
64
  if (hasBody) {
65
- request.headers["content-type"] = "application/json";
65
+ request.headers["content-type"] = this.getDefaultContentType();
66
66
  }
67
67
  }
68
68
  }
@@ -115,4 +115,7 @@ export class AwsRestJsonProtocol extends HttpBindingProtocol {
115
115
  });
116
116
  throw exception;
117
117
  }
118
+ getDefaultContentType() {
119
+ return "application/json";
120
+ }
118
121
  }
@@ -1,6 +1,5 @@
1
1
  import { NormalizedSchema, SCHEMA } from "@smithy/core/schema";
2
- import { dateToUtcString } from "@smithy/core/serde";
3
- import { LazyJsonString } from "@smithy/core/serde";
2
+ import { dateToUtcString, generateIdempotencyToken, LazyJsonString } from "@smithy/core/serde";
4
3
  import { SerdeContextConfig } from "../ConfigurableSerdeContext";
5
4
  import { JsonReplacer } from "./jsonReplacer";
6
5
  export class JsonShapeSerializer extends SerdeContextConfig {
@@ -94,11 +93,16 @@ export class JsonShapeSerializer extends SerdeContextConfig {
94
93
  return String(value);
95
94
  }
96
95
  }
97
- const mediaType = ns.getMergedTraits().mediaType;
98
- if (ns.isStringSchema() && typeof value === "string" && mediaType) {
99
- const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
100
- if (isJson) {
101
- return LazyJsonString.from(value);
96
+ if (ns.isStringSchema()) {
97
+ if (typeof value === "undefined" && ns.isIdempotencyToken()) {
98
+ return generateIdempotencyToken();
99
+ }
100
+ const mediaType = ns.getMergedTraits().mediaType;
101
+ if (typeof value === "string" && mediaType) {
102
+ const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
103
+ if (isJson) {
104
+ return LazyJsonString.from(value);
105
+ }
102
106
  }
103
107
  }
104
108
  return value;
@@ -14,7 +14,7 @@ export class JsonReplacer {
14
14
  this.stage = 1;
15
15
  return (key, value) => {
16
16
  if (value instanceof NumericValue) {
17
- const v = `${NUMERIC_CONTROL_CHAR + +"nv" + this.counter++}_` + value.string;
17
+ const v = `${NUMERIC_CONTROL_CHAR + "nv" + this.counter++}_` + value.string;
18
18
  this.values.set(`"${v}"`, value.string);
19
19
  return v;
20
20
  }
@@ -144,4 +144,7 @@ export class AwsQueryProtocol extends RpcProtocol {
144
144
  const errorData = this.loadQueryError(data);
145
145
  return errorData?.message ?? errorData?.Message ?? data.message ?? data.Message ?? "Unknown";
146
146
  }
147
+ getDefaultContentType() {
148
+ return "application/x-www-form-urlencoded";
149
+ }
147
150
  }
@@ -1,6 +1,6 @@
1
1
  import { determineTimestampFormat, extendedEncodeURIComponent } from "@smithy/core/protocols";
2
2
  import { NormalizedSchema, SCHEMA } from "@smithy/core/schema";
3
- import { NumericValue } from "@smithy/core/serde";
3
+ import { generateIdempotencyToken, NumericValue } from "@smithy/core/serde";
4
4
  import { dateToUtcString } from "@smithy/smithy-client";
5
5
  import { toBase64 } from "@smithy/util-base64";
6
6
  import { SerdeContextConfig } from "../ConfigurableSerdeContext";
@@ -30,6 +30,10 @@ export class QueryShapeSerializer extends SerdeContextConfig {
30
30
  this.writeKey(prefix);
31
31
  this.writeValue(String(value));
32
32
  }
33
+ else if (ns.isIdempotencyToken()) {
34
+ this.writeKey(prefix);
35
+ this.writeValue(generateIdempotencyToken());
36
+ }
33
37
  }
34
38
  else if (ns.isBigIntegerSchema()) {
35
39
  if (value != null) {
@@ -110,7 +114,7 @@ export class QueryShapeSerializer extends SerdeContextConfig {
110
114
  else if (ns.isStructSchema()) {
111
115
  if (value && typeof value === "object") {
112
116
  for (const [memberName, member] of ns.structIterator()) {
113
- if (value[memberName] == null) {
117
+ if (value[memberName] == null && !member.isIdempotencyToken()) {
114
118
  continue;
115
119
  }
116
120
  const suffix = this.getKey(memberName, member.getMergedTraits().xmlName);
@@ -55,7 +55,7 @@ export class AwsRestXmlProtocol extends HttpBindingProtocol {
55
55
  request.headers["content-type"] = "application/octet-stream";
56
56
  }
57
57
  else {
58
- request.headers["content-type"] = "application/xml";
58
+ request.headers["content-type"] = this.getDefaultContentType();
59
59
  }
60
60
  }
61
61
  else if (!ns.isUnitSchema()) {
@@ -64,11 +64,11 @@ export class AwsRestXmlProtocol extends HttpBindingProtocol {
64
64
  return !httpQuery && !httpQueryParams && !httpHeader && !httpLabel && httpPrefixHeaders === void 0;
65
65
  });
66
66
  if (hasBody) {
67
- request.headers["content-type"] = "application/xml";
67
+ request.headers["content-type"] = this.getDefaultContentType();
68
68
  }
69
69
  }
70
70
  }
71
- if (request.headers["content-type"] === "application/xml") {
71
+ if (request.headers["content-type"] === this.getDefaultContentType()) {
72
72
  if (typeof request.body === "string") {
73
73
  request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
74
74
  }
@@ -123,4 +123,7 @@ export class AwsRestXmlProtocol extends HttpBindingProtocol {
123
123
  });
124
124
  throw exception;
125
125
  }
126
+ getDefaultContentType() {
127
+ return "application/xml";
128
+ }
126
129
  }
@@ -1,6 +1,6 @@
1
1
  import { XmlNode, XmlText } from "@aws-sdk/xml-builder";
2
2
  import { NormalizedSchema, SCHEMA } from "@smithy/core/schema";
3
- import { NumericValue } from "@smithy/core/serde";
3
+ import { generateIdempotencyToken, NumericValue } from "@smithy/core/serde";
4
4
  import { dateToUtcString } from "@smithy/smithy-client";
5
5
  import { fromBase64, toBase64 } from "@smithy/util-base64";
6
6
  import { SerdeContextConfig } from "../ConfigurableSerdeContext";
@@ -67,7 +67,7 @@ export class XmlShapeSerializer extends SerdeContextConfig {
67
67
  }
68
68
  for (const [memberName, memberSchema] of ns.structIterator()) {
69
69
  const val = value[memberName];
70
- if (val != null) {
70
+ if (val != null || memberSchema.isIdempotencyToken()) {
71
71
  if (memberSchema.getMergedTraits().xmlAttribute) {
72
72
  structXmlNode.addAttribute(memberSchema.getMergedTraits().xmlName ?? memberName, this.writeSimple(memberSchema, val));
73
73
  continue;
@@ -246,13 +246,17 @@ export class XmlShapeSerializer extends SerdeContextConfig {
246
246
  throw new Error(`@aws-sdk/core/protocols - xml serializer, unhandled schema type for object value and schema: ${ns.getName(true)}`);
247
247
  }
248
248
  }
249
- if (ns.isStringSchema() ||
250
- ns.isBooleanSchema() ||
251
- ns.isNumericSchema() ||
252
- ns.isBigIntegerSchema() ||
253
- ns.isBigDecimalSchema()) {
249
+ if (ns.isBooleanSchema() || ns.isNumericSchema() || ns.isBigIntegerSchema() || ns.isBigDecimalSchema()) {
254
250
  nodeContents = String(value);
255
251
  }
252
+ if (ns.isStringSchema()) {
253
+ if (value === undefined && ns.isIdempotencyToken()) {
254
+ nodeContents = generateIdempotencyToken();
255
+ }
256
+ else {
257
+ nodeContents = String(value);
258
+ }
259
+ }
256
260
  if (nodeContents === null) {
257
261
  throw new Error(`Unhandled schema-value pair ${ns.getName(true)}=${value}`);
258
262
  }
@@ -4,9 +4,14 @@ import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol";
4
4
  * @see https://smithy.io/2.0/aws/protocols/aws-json-1_1-protocol.html#differences-between-awsjson1-0-and-awsjson1-1
5
5
  */
6
6
  export declare class AwsJson1_0Protocol extends AwsJsonRpcProtocol {
7
- constructor({ defaultNamespace }: {
7
+ constructor({ defaultNamespace, serviceTarget }: {
8
8
  defaultNamespace: string;
9
+ serviceTarget: string;
9
10
  });
10
11
  getShapeId(): string;
11
12
  protected getJsonRpcVersion(): "1.0";
13
+ /**
14
+ * @override
15
+ */
16
+ protected getDefaultContentType(): string;
12
17
  }
@@ -4,9 +4,14 @@ import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol";
4
4
  * @see https://smithy.io/2.0/aws/protocols/aws-json-1_1-protocol.html#differences-between-awsjson1-0-and-awsjson1-1
5
5
  */
6
6
  export declare class AwsJson1_1Protocol extends AwsJsonRpcProtocol {
7
- constructor({ defaultNamespace }: {
7
+ constructor({ defaultNamespace, serviceTarget }: {
8
8
  defaultNamespace: string;
9
+ serviceTarget: string;
9
10
  });
10
11
  getShapeId(): string;
11
12
  protected getJsonRpcVersion(): "1.1";
13
+ /**
14
+ * @override
15
+ */
16
+ protected getDefaultContentType(): string;
12
17
  }
@@ -7,9 +7,11 @@ import { JsonCodec } from "./JsonCodec";
7
7
  export declare abstract class AwsJsonRpcProtocol extends RpcProtocol {
8
8
  protected serializer: ShapeSerializer<string | Uint8Array>;
9
9
  protected deserializer: ShapeDeserializer<string | Uint8Array>;
10
+ protected serviceTarget: string;
10
11
  private codec;
11
- protected constructor({ defaultNamespace }: {
12
+ protected constructor({ defaultNamespace, serviceTarget }: {
12
13
  defaultNamespace: string;
14
+ serviceTarget: string;
13
15
  });
14
16
  serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<HttpRequest>;
15
17
  getPayloadCodec(): JsonCodec;
@@ -16,4 +16,8 @@ export declare class AwsRestJsonProtocol extends HttpBindingProtocol {
16
16
  setSerdeContext(serdeContext: SerdeFunctions): void;
17
17
  serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<HttpRequest>;
18
18
  protected handleError(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: HttpResponse, dataObject: any, metadata: ResponseMetadata): Promise<never>;
19
+ /**
20
+ * @override
21
+ */
22
+ protected getDefaultContentType(): string;
19
23
  }
@@ -36,4 +36,8 @@ export declare class AwsQueryProtocol extends RpcProtocol {
36
36
  protected loadQueryErrorCode(output: IHttpResponse, data: any): string | undefined;
37
37
  protected loadQueryError(data: any): any | undefined;
38
38
  protected loadQueryErrorMessage(data: any): string;
39
+ /**
40
+ * @override
41
+ */
42
+ protected getDefaultContentType(): string;
39
43
  }
@@ -18,4 +18,8 @@ export declare class AwsRestXmlProtocol extends HttpBindingProtocol {
18
18
  serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
19
19
  deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
20
20
  protected handleError(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any, metadata: ResponseMetadata): Promise<never>;
21
+ /**
22
+ * @override
23
+ */
24
+ protected getDefaultContentType(): string;
21
25
  }
@@ -1,6 +1,13 @@
1
1
  import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol";
2
2
  export declare class AwsJson1_0Protocol extends AwsJsonRpcProtocol {
3
- constructor({ defaultNamespace }: { defaultNamespace: string });
3
+ constructor({
4
+ defaultNamespace,
5
+ serviceTarget,
6
+ }: {
7
+ defaultNamespace: string;
8
+ serviceTarget: string;
9
+ });
4
10
  getShapeId(): string;
5
11
  protected getJsonRpcVersion(): "1.0";
12
+ protected getDefaultContentType(): string;
6
13
  }
@@ -1,6 +1,13 @@
1
1
  import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol";
2
2
  export declare class AwsJson1_1Protocol extends AwsJsonRpcProtocol {
3
- constructor({ defaultNamespace }: { defaultNamespace: string });
3
+ constructor({
4
+ defaultNamespace,
5
+ serviceTarget,
6
+ }: {
7
+ defaultNamespace: string;
8
+ serviceTarget: string;
9
+ });
4
10
  getShapeId(): string;
5
11
  protected getJsonRpcVersion(): "1.1";
12
+ protected getDefaultContentType(): string;
6
13
  }
@@ -14,8 +14,15 @@ import { JsonCodec } from "./JsonCodec";
14
14
  export declare abstract class AwsJsonRpcProtocol extends RpcProtocol {
15
15
  protected serializer: ShapeSerializer<string | Uint8Array>;
16
16
  protected deserializer: ShapeDeserializer<string | Uint8Array>;
17
+ protected serviceTarget: string;
17
18
  private codec;
18
- protected constructor({ defaultNamespace }: { defaultNamespace: string });
19
+ protected constructor({
20
+ defaultNamespace,
21
+ serviceTarget,
22
+ }: {
23
+ defaultNamespace: string;
24
+ serviceTarget: string;
25
+ });
19
26
  serializeRequest<Input extends object>(
20
27
  operationSchema: OperationSchema,
21
28
  input: Input,
@@ -31,4 +31,5 @@ export declare class AwsRestJsonProtocol extends HttpBindingProtocol {
31
31
  dataObject: any,
32
32
  metadata: ResponseMetadata
33
33
  ): Promise<never>;
34
+ protected getDefaultContentType(): string;
34
35
  }
@@ -52,4 +52,5 @@ export declare class AwsQueryProtocol extends RpcProtocol {
52
52
  ): string | undefined;
53
53
  protected loadQueryError(data: any): any | undefined;
54
54
  protected loadQueryErrorMessage(data: any): string;
55
+ protected getDefaultContentType(): string;
55
56
  }
@@ -36,4 +36,5 @@ export declare class AwsRestXmlProtocol extends HttpBindingProtocol {
36
36
  dataObject: any,
37
37
  metadata: ResponseMetadata
38
38
  ): Promise<never>;
39
+ protected getDefaultContentType(): string;
39
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/core",
3
- "version": "3.862.0",
3
+ "version": "3.864.0",
4
4
  "description": "Core functions & classes shared by multiple AWS SDK clients.",
5
5
  "scripts": {
6
6
  "build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",