@aws-sdk/core 3.930.0 → 3.931.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.
package/dist-cjs/index.js CHANGED
@@ -1048,11 +1048,21 @@ class AwsRestJsonProtocol extends protocols.HttpBindingProtocol {
1048
1048
  request.headers["content-type"] = contentType;
1049
1049
  }
1050
1050
  }
1051
- if (request.headers["content-type"] && !request.body) {
1051
+ if (request.body == null && request.headers["content-type"] === this.getDefaultContentType()) {
1052
1052
  request.body = "{}";
1053
1053
  }
1054
1054
  return request;
1055
1055
  }
1056
+ async deserializeResponse(operationSchema, context, response) {
1057
+ const output = await super.deserializeResponse(operationSchema, context, response);
1058
+ const outputSchema = schema.NormalizedSchema.of(operationSchema.output);
1059
+ for (const [name, member] of outputSchema.structIterator()) {
1060
+ if (member.getMemberTraits().httpPayload && !(name in output)) {
1061
+ output[name] = null;
1062
+ }
1063
+ }
1064
+ return output;
1065
+ }
1056
1066
  async handleError(operationSchema, context, response, dataObject, metadata) {
1057
1067
  const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
1058
1068
  const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
@@ -718,11 +718,21 @@ class AwsRestJsonProtocol extends protocols.HttpBindingProtocol {
718
718
  request.headers["content-type"] = contentType;
719
719
  }
720
720
  }
721
- if (request.headers["content-type"] && !request.body) {
721
+ if (request.body == null && request.headers["content-type"] === this.getDefaultContentType()) {
722
722
  request.body = "{}";
723
723
  }
724
724
  return request;
725
725
  }
726
+ async deserializeResponse(operationSchema, context, response) {
727
+ const output = await super.deserializeResponse(operationSchema, context, response);
728
+ const outputSchema = schema.NormalizedSchema.of(operationSchema.output);
729
+ for (const [name, member] of outputSchema.structIterator()) {
730
+ if (member.getMemberTraits().httpPayload && !(name in output)) {
731
+ output[name] = null;
732
+ }
733
+ }
734
+ return output;
735
+ }
726
736
  async handleError(operationSchema, context, response, dataObject, metadata) {
727
737
  const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
728
738
  const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
@@ -43,11 +43,21 @@ export class AwsRestJsonProtocol extends HttpBindingProtocol {
43
43
  request.headers["content-type"] = contentType;
44
44
  }
45
45
  }
46
- if (request.headers["content-type"] && !request.body) {
46
+ if (request.body == null && request.headers["content-type"] === this.getDefaultContentType()) {
47
47
  request.body = "{}";
48
48
  }
49
49
  return request;
50
50
  }
51
+ async deserializeResponse(operationSchema, context, response) {
52
+ const output = await super.deserializeResponse(operationSchema, context, response);
53
+ const outputSchema = NormalizedSchema.of(operationSchema.output);
54
+ for (const [name, member] of outputSchema.structIterator()) {
55
+ if (member.getMemberTraits().httpPayload && !(name in output)) {
56
+ output[name] = null;
57
+ }
58
+ }
59
+ return output;
60
+ }
51
61
  async handleError(operationSchema, context, response, dataObject, metadata) {
52
62
  const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
53
63
  const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
@@ -1,5 +1,5 @@
1
1
  import { HttpBindingProtocol } from "@smithy/core/protocols";
2
- import type { EndpointBearer, HandlerExecutionContext, HttpRequest, HttpResponse, OperationSchema, ResponseMetadata, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
2
+ import type { EndpointBearer, HandlerExecutionContext, HttpRequest, HttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
3
3
  import { JsonCodec } from "./JsonCodec";
4
4
  /**
5
5
  * @public
@@ -15,7 +15,17 @@ export declare class AwsRestJsonProtocol extends HttpBindingProtocol {
15
15
  getShapeId(): string;
16
16
  getPayloadCodec(): JsonCodec;
17
17
  setSerdeContext(serdeContext: SerdeFunctions): void;
18
+ /**
19
+ * @override
20
+ */
18
21
  serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<HttpRequest>;
22
+ /**
23
+ * @override
24
+ */
25
+ deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: HttpResponse): Promise<Output>;
26
+ /**
27
+ * @override
28
+ */
19
29
  protected handleError(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: HttpResponse, dataObject: any, metadata: ResponseMetadata): Promise<never>;
20
30
  /**
21
31
  * @override
@@ -4,6 +4,7 @@ import {
4
4
  HandlerExecutionContext,
5
5
  HttpRequest,
6
6
  HttpResponse,
7
+ MetadataBearer,
7
8
  OperationSchema,
8
9
  ResponseMetadata,
9
10
  SerdeFunctions,
@@ -25,6 +26,11 @@ export declare class AwsRestJsonProtocol extends HttpBindingProtocol {
25
26
  input: Input,
26
27
  context: HandlerExecutionContext & SerdeFunctions & EndpointBearer
27
28
  ): Promise<HttpRequest>;
29
+ deserializeResponse<Output extends MetadataBearer>(
30
+ operationSchema: OperationSchema,
31
+ context: HandlerExecutionContext & SerdeFunctions,
32
+ response: HttpResponse
33
+ ): Promise<Output>;
28
34
  protected handleError(
29
35
  operationSchema: OperationSchema,
30
36
  context: HandlerExecutionContext & SerdeFunctions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/core",
3
- "version": "3.930.0",
3
+ "version": "3.931.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'",