@smithy/core 3.36.2 → 3.38.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 (90) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist-cjs/index.js +4 -2
  3. package/dist-cjs/submodules/cbor/index.js +45 -53
  4. package/dist-cjs/submodules/client/index.js +26 -13
  5. package/dist-cjs/submodules/config/index.browser.js +8 -4
  6. package/dist-cjs/submodules/config/index.js +16 -8
  7. package/dist-cjs/submodules/config/index.native.js +8 -4
  8. package/dist-cjs/submodules/endpoints/index.browser.js +2 -1
  9. package/dist-cjs/submodules/endpoints/index.js +10 -5
  10. package/dist-cjs/submodules/event-streams/index.browser.js +18 -9
  11. package/dist-cjs/submodules/event-streams/index.js +18 -9
  12. package/dist-cjs/submodules/protocols/index.js +86 -53
  13. package/dist-cjs/submodules/retry/index.browser.js +20 -10
  14. package/dist-cjs/submodules/retry/index.js +24 -12
  15. package/dist-cjs/submodules/serde/index.browser.js +13 -4
  16. package/dist-cjs/submodules/serde/index.js +7 -1
  17. package/dist-cjs/submodules/serde/index.native.js +13 -4
  18. package/dist-cjs/submodules/transport/index.js +6 -3
  19. package/dist-es/legacy-root-exports/util-identity-and-auth/DefaultIdentityProviderConfig.js +2 -1
  20. package/dist-es/normalizeProvider.js +2 -1
  21. package/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +12 -37
  22. package/dist-es/submodules/cbor/codec-v1/CborShapeDeserializer.js +8 -4
  23. package/dist-es/submodules/cbor/codec-v1/CborShapeSerializer.js +6 -3
  24. package/dist-es/submodules/cbor/codec-v2/CborShapeDeserializer2.js +12 -6
  25. package/dist-es/submodules/cbor/codec-v2/CborShapeSerializer2.js +4 -2
  26. package/dist-es/submodules/cbor/parseCborBody.js +2 -1
  27. package/dist-es/submodules/client/middleware-stack/MiddlewareStack.js +10 -5
  28. package/dist-es/submodules/client/smithy-client/create-aggregated-client.js +2 -1
  29. package/dist-es/submodules/client/smithy-client/exceptions.js +4 -2
  30. package/dist-es/submodules/client/smithy-client/extensions/checksum.js +2 -1
  31. package/dist-es/submodules/client/smithy-client/get-value-from-text-node.js +2 -1
  32. package/dist-es/submodules/client/smithy-client/object-mapping.js +4 -2
  33. package/dist-es/submodules/client/smithy-client/serde-json.js +2 -1
  34. package/dist-es/submodules/config/shared-ini-file-loader/getHomeDir.js +8 -4
  35. package/dist-es/submodules/config/util-config-provider/booleanSelector.js +6 -3
  36. package/dist-es/submodules/config/util-config-provider/numberSelector.js +2 -1
  37. package/dist-es/submodules/endpoints/middleware-endpoint/adaptors/getEndpointUrlConfig.js +8 -4
  38. package/dist-es/submodules/endpoints/util-endpoints/resolveEndpoint.js +2 -1
  39. package/dist-es/submodules/event-streams/EventStreamSerde.js +6 -3
  40. package/dist-es/submodules/event-streams/eventstream-codec/HeaderMarshaller.js +2 -1
  41. package/dist-es/submodules/event-streams/eventstream-codec/Int64.js +2 -1
  42. package/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageDecoderStream.js +2 -1
  43. package/dist-es/submodules/event-streams/eventstream-serde/utils.js +2 -1
  44. package/dist-es/submodules/event-streams/eventstream-serde-universal/getUnmarshalledStream.js +4 -2
  45. package/dist-es/submodules/protocols/AbstractRpcV2Protocol.js +35 -0
  46. package/dist-es/submodules/protocols/HttpBindingProtocol.js +8 -4
  47. package/dist-es/submodules/protocols/HttpProtocol.js +4 -2
  48. package/dist-es/submodules/protocols/RpcProtocol.js +6 -2
  49. package/dist-es/submodules/protocols/index.js +1 -0
  50. package/dist-es/submodules/protocols/json/SmithyRpcV2JsonProtocol.js +8 -31
  51. package/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js +7 -5
  52. package/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js +7 -5
  53. package/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js +7 -5
  54. package/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js +6 -3
  55. package/dist-es/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.js +3 -0
  56. package/dist-es/submodules/retry/middleware-retry/configurations.js +4 -2
  57. package/dist-es/submodules/retry/middleware-retry/parseRetryAfterHeader.js +2 -1
  58. package/dist-es/submodules/retry/middleware-retry/retry-pre-sra-deprecated/StandardRetryStrategy.js +6 -3
  59. package/dist-es/submodules/retry/middleware-retry/retryMiddleware.js +6 -3
  60. package/dist-es/submodules/retry/middleware-retry/util.js +6 -3
  61. package/dist-es/submodules/serde/index.browser.js +1 -0
  62. package/dist-es/submodules/serde/index.js +1 -0
  63. package/dist-es/submodules/serde/index.native.js +1 -0
  64. package/dist-es/submodules/serde/parse-utils.js +2 -1
  65. package/dist-es/submodules/serde/util-body-length/calculateBodyLength.browser.js +6 -3
  66. package/dist-es/submodules/transport/httpResponse.js +2 -1
  67. package/dist-es/submodules/transport/normalizeProvider.js +2 -1
  68. package/dist-es/submodules/transport/toEndpointV1.js +2 -1
  69. package/dist-types/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +5 -14
  70. package/dist-types/submodules/protocols/AbstractRpcV2Protocol.d.ts +45 -0
  71. package/dist-types/submodules/protocols/RpcProtocol.d.ts +12 -0
  72. package/dist-types/submodules/protocols/index.d.ts +1 -0
  73. package/dist-types/submodules/protocols/json/SmithyRpcV2JsonProtocol.d.ts +5 -14
  74. package/dist-types/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.d.ts +1 -0
  75. package/dist-types/submodules/serde/index.browser.d.ts +1 -0
  76. package/dist-types/submodules/serde/index.d.ts +1 -0
  77. package/dist-types/submodules/serde/index.native.d.ts +1 -0
  78. package/dist-types/ts3.4/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +5 -14
  79. package/dist-types/ts3.4/submodules/protocols/AbstractRpcV2Protocol.d.ts +45 -0
  80. package/dist-types/ts3.4/submodules/protocols/RpcProtocol.d.ts +12 -0
  81. package/dist-types/ts3.4/submodules/protocols/index.d.ts +1 -0
  82. package/dist-types/ts3.4/submodules/protocols/json/SmithyRpcV2JsonProtocol.d.ts +5 -14
  83. package/dist-types/ts3.4/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.d.ts +1 -0
  84. package/dist-types/ts3.4/submodules/serde/index.browser.d.ts +1 -0
  85. package/dist-types/ts3.4/submodules/serde/index.d.ts +1 -0
  86. package/dist-types/ts3.4/submodules/serde/index.native.d.ts +1 -0
  87. package/package.json +1 -1
  88. /package/dist-es/submodules/{protocols → serde}/writeKey.js +0 -0
  89. /package/dist-types/submodules/{protocols → serde}/writeKey.d.ts +0 -0
  90. /package/dist-types/ts3.4/submodules/{protocols → serde}/writeKey.d.ts +0 -0
@@ -83,12 +83,15 @@ const getRetryErrorInfo = (error, logger) => {
83
83
  return errorInfo;
84
84
  };
85
85
  const getRetryErrorType = (error) => {
86
- if (isThrottlingError(error))
86
+ if (isThrottlingError(error)) {
87
87
  return "THROTTLING";
88
- if (isTransientError(error))
88
+ }
89
+ if (isTransientError(error)) {
89
90
  return "TRANSIENT";
90
- if (isServerError(error))
91
+ }
92
+ if (isServerError(error)) {
91
93
  return "SERVER_ERROR";
94
+ }
92
95
  return "CLIENT_ERROR";
93
96
  };
94
97
  export const retryMiddlewareOptions = {
@@ -1,9 +1,12 @@
1
1
  export const asSdkError = (error) => {
2
- if (error instanceof Error)
2
+ if (error instanceof Error) {
3
3
  return error;
4
- if (error instanceof Object)
4
+ }
5
+ if (error instanceof Object) {
5
6
  return Object.assign(new Error(), error);
6
- if (typeof error === "string")
7
+ }
8
+ if (typeof error === "string") {
7
9
  return new Error(error);
10
+ }
8
11
  return new Error(`AWS SDK error wrapper for ${error}`);
9
12
  };
@@ -42,3 +42,4 @@ const _getRandomValues = (array) => crypto.getRandomValues(array);
42
42
  export const v4 = bindV4(_getRandomValues);
43
43
  export const generateIdempotencyToken = v4;
44
44
  export { hasOwn } from "@smithy/core/transport";
45
+ export { writeKey } from "./writeKey";
@@ -41,3 +41,4 @@ const _getRandomValues = getRandomValues;
41
41
  export const v4 = bindV4(_getRandomValues);
42
42
  export const generateIdempotencyToken = v4;
43
43
  export { hasOwn } from "@smithy/core/transport";
44
+ export { writeKey } from "./writeKey";
@@ -44,3 +44,4 @@ const _getRandomValues = (array) => crypto.getRandomValues(array);
44
44
  export const v4 = bindV4(_getRandomValues);
45
45
  export const generateIdempotencyToken = v4;
46
46
  export { hasOwn } from "@smithy/core/transport";
47
+ export { writeKey } from "./writeKey";
@@ -138,8 +138,9 @@ export const expectUnion = (value) => {
138
138
  const asObject = expectObject(value);
139
139
  const setKeys = [];
140
140
  for (const k in asObject) {
141
- if (!hasOwn(asObject, k))
141
+ if (!hasOwn(asObject, k)) {
142
142
  continue;
143
+ }
143
144
  if (asObject[k] != null) {
144
145
  setKeys.push(k);
145
146
  }
@@ -7,12 +7,15 @@ export const calculateBodyLength = (body) => {
7
7
  let len = body.length;
8
8
  for (let i = len - 1; i >= 0; i--) {
9
9
  const code = body.charCodeAt(i);
10
- if (code > 0x7f && code <= 0x7ff)
10
+ if (code > 0x7f && code <= 0x7ff) {
11
11
  len++;
12
- else if (code > 0x7ff && code <= 0xffff)
12
+ }
13
+ else if (code > 0x7ff && code <= 0xffff) {
13
14
  len += 2;
14
- if (code >= 0xdc00 && code <= 0xdfff)
15
+ }
16
+ if (code >= 0xdc00 && code <= 0xdfff) {
15
17
  i--;
18
+ }
16
19
  }
17
20
  return len;
18
21
  }
@@ -10,8 +10,9 @@ export class HttpResponse {
10
10
  this.body = options.body;
11
11
  }
12
12
  static isInstance(response) {
13
- if (!response)
13
+ if (!response) {
14
14
  return false;
15
+ }
15
16
  const resp = response;
16
17
  return typeof resp.statusCode === "number" && typeof resp.headers === "object";
17
18
  }
@@ -1,6 +1,7 @@
1
1
  export const normalizeProvider = (input) => {
2
- if (typeof input === "function")
2
+ if (typeof input === "function") {
3
3
  return input;
4
+ }
4
5
  const promisified = Promise.resolve(input);
5
6
  return () => promisified;
6
7
  };
@@ -7,8 +7,9 @@ export const toEndpointV1 = (endpoint) => {
7
7
  if (endpoint.headers) {
8
8
  v1Endpoint.headers = {};
9
9
  for (const name in endpoint.headers) {
10
- if (!hasOwn(endpoint.headers, name))
10
+ if (!hasOwn(endpoint.headers, name)) {
11
11
  continue;
12
+ }
12
13
  v1Endpoint.headers[name.toLowerCase()] = endpoint.headers[name].join(", ");
13
14
  }
14
15
  }
@@ -1,28 +1,19 @@
1
- import { RpcProtocol } from "@smithy/core/protocols";
2
- import { TypeRegistry } from "@smithy/core/schema";
3
- import type { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, SerdeFunctions } from "@smithy/types";
1
+ import { AbstractRpcV2Protocol } from "@smithy/core/protocols";
2
+ import type { HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, OperationSchema, ResponseMetadata, SerdeFunctions } from "@smithy/types";
4
3
  import { CborCodec } from "./CborCodec";
5
4
  /**
6
5
  * Client protocol for Smithy RPCv2 CBOR.
7
6
  *
8
7
  * @public
9
8
  */
10
- export declare class SmithyRpcV2CborProtocol extends RpcProtocol {
11
- /**
12
- * @override
13
- */
14
- protected compositeErrorRegistry: TypeRegistry;
9
+ export declare class SmithyRpcV2CborProtocol extends AbstractRpcV2Protocol {
15
10
  private codec;
16
11
  protected serializer: import(".").CborShapeSerializer2;
17
12
  protected deserializer: import(".").CborShapeDeserializer2;
18
- constructor({ defaultNamespace, errorTypeRegistries, }: {
19
- defaultNamespace: string;
20
- errorTypeRegistries?: TypeRegistry[];
21
- });
22
13
  getShapeId(): string;
23
14
  getPayloadCodec(): CborCodec;
24
- serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
25
- deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
15
+ protected getSmithyProtocolHeaderValue(): string;
16
+ protected applyEmptyBody(request: IHttpRequest): void;
26
17
  protected handleError(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any, metadata: ResponseMetadata): Promise<never>;
27
18
  protected getDefaultContentType(): string;
28
19
  }
@@ -0,0 +1,45 @@
1
+ import type { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, OperationSchema, SerdeFunctions } from "@smithy/types";
2
+ import type { TypeRegistry } from "@smithy/core/schema";
3
+ import { RpcProtocol } from "./RpcProtocol";
4
+ /**
5
+ * Shared abstract base for the Smithy RPC v2 client protocols (JSON and CBOR).
6
+ *
7
+ * Factors out the request-framing flow and response status handling that are
8
+ * identical across both RPC v2 protocols. Concrete protocols supply their
9
+ * codec, error handling, content type, shape id, and the two per-protocol
10
+ * request details via {@link getSmithyProtocolHeaderValue} and
11
+ * {@link applyEmptyBody}.
12
+ *
13
+ * @internal
14
+ */
15
+ export declare abstract class AbstractRpcV2Protocol extends RpcProtocol {
16
+ /**
17
+ * @override
18
+ */
19
+ protected compositeErrorRegistry: TypeRegistry;
20
+ constructor({ defaultNamespace, errorTypeRegistries, }: {
21
+ defaultNamespace: string;
22
+ errorTypeRegistries?: TypeRegistry[];
23
+ });
24
+ serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
25
+ /**
26
+ * @override
27
+ *
28
+ * Per the Smithy RPC v2 specification, the only successful response status
29
+ * code is 200; any other status code MUST be handled as an error.
30
+ */
31
+ protected isErrorResponse(statusCode: number): boolean;
32
+ /**
33
+ * @returns the value of the `smithy-protocol` header for this protocol,
34
+ * e.g. `rpc-v2-json` or `rpc-v2-cbor`.
35
+ */
36
+ protected abstract getSmithyProtocolHeaderValue(): string;
37
+ /**
38
+ * Applies this protocol's representation of an empty request body when the
39
+ * operation has a non-unit input but produced no serialized body. Called
40
+ * only for non-unit inputs.
41
+ *
42
+ * @param request - the request being serialized, mutated in place.
43
+ */
44
+ protected abstract applyEmptyBody(request: IHttpRequest): void;
45
+ }
@@ -13,4 +13,16 @@ export declare abstract class RpcProtocol extends HttpProtocol {
13
13
  protected compositeErrorRegistry: TypeRegistry;
14
14
  serializeRequest<Input extends object>(operationSchema: OperationSchema, _input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
15
15
  deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
16
+ /**
17
+ * Determines whether a response status code indicates an error response that
18
+ * should be routed to {@link handleError} rather than deserialized as output.
19
+ *
20
+ * The default treats any status code of 300 or greater as an error,
21
+ * preserving the historical behavior for RPC-over-HTTP protocols. Subclasses
22
+ * whose specification is stricter SHOULD override this.
23
+ *
24
+ * @param statusCode - the HTTP response status code.
25
+ * @returns true if the response should be handled as an error.
26
+ */
27
+ protected isErrorResponse(statusCode: number): boolean;
16
28
  }
@@ -3,6 +3,7 @@ export { extendedEncodeURIComponent } from "./extended-encode-uri-component";
3
3
  export { HttpBindingProtocol } from "./HttpBindingProtocol";
4
4
  export { HttpProtocol } from "./HttpProtocol";
5
5
  export { RpcProtocol } from "./RpcProtocol";
6
+ export { AbstractRpcV2Protocol } from "./AbstractRpcV2Protocol";
6
7
  export { RequestBuilder, requestBuilder } from "./requestBuilder";
7
8
  export { resolvedPath } from "./resolve-path";
8
9
  export { FromStringShapeDeserializer } from "./serde/FromStringShapeDeserializer";
@@ -1,28 +1,19 @@
1
- import { RpcProtocol } from "../RpcProtocol";
2
- import { TypeRegistry } from "@smithy/core/schema";
3
- import type { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
1
+ import { AbstractRpcV2Protocol } from "../AbstractRpcV2Protocol";
2
+ import type { HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, OperationSchema, ResponseMetadata, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
4
3
  import { JsonCodec2 } from "./codec-v2/JsonCodec2";
5
4
  /**
6
5
  * Client protocol for Smithy RPCv2 JSON.
7
6
  *
8
7
  * @public
9
8
  */
10
- export declare class SmithyRpcV2JsonProtocol extends RpcProtocol {
11
- /**
12
- * @override
13
- */
14
- protected compositeErrorRegistry: TypeRegistry;
9
+ export declare class SmithyRpcV2JsonProtocol extends AbstractRpcV2Protocol {
15
10
  private codec;
16
11
  protected serializer: ShapeSerializer<string | Uint8Array>;
17
12
  protected deserializer: ShapeDeserializer<string | Uint8Array>;
18
- constructor({ defaultNamespace, errorTypeRegistries, }: {
19
- defaultNamespace: string;
20
- errorTypeRegistries?: TypeRegistry[];
21
- });
22
13
  getShapeId(): string;
23
14
  getPayloadCodec(): JsonCodec2;
24
- serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
25
- deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
15
+ protected getSmithyProtocolHeaderValue(): string;
16
+ protected applyEmptyBody(request: IHttpRequest): void;
26
17
  protected handleError(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any, metadata: ResponseMetadata): Promise<never>;
27
18
  protected getDefaultContentType(): string;
28
19
  }
@@ -24,6 +24,7 @@ export declare const getHttpHandlerExtensionConfiguration: <HandlerConfig extend
24
24
  logger?: Logger;
25
25
  }>(runtimeConfig: HttpHandlerExtensionConfigType<HandlerConfig> & {
26
26
  logger?: Logger;
27
+ defaultSocketTimeout?: number;
27
28
  }) => {
28
29
  setHttpHandler(handler: HttpHandler<HandlerConfig>): void;
29
30
  httpHandler(): HttpHandler<HandlerConfig>;
@@ -40,3 +40,4 @@ export { streamCollector } from "./util-stream/stream-collector.browser";
40
40
  export declare const v4: () => string;
41
41
  export declare const generateIdempotencyToken: () => string;
42
42
  export { hasOwn } from "@smithy/core/transport";
43
+ export { writeKey } from "./writeKey";
@@ -38,3 +38,4 @@ export { streamCollector } from "./util-stream/stream-collector";
38
38
  export declare const v4: () => string;
39
39
  export declare const generateIdempotencyToken: () => string;
40
40
  export { hasOwn } from "@smithy/core/transport";
41
+ export { writeKey } from "./writeKey";
@@ -38,3 +38,4 @@ export { streamCollector } from "./util-stream/stream-collector.browser";
38
38
  export declare const v4: () => string;
39
39
  export declare const generateIdempotencyToken: () => string;
40
40
  export { hasOwn } from "@smithy/core/transport";
41
+ export { writeKey } from "./writeKey";
@@ -1,28 +1,19 @@
1
- import { RpcProtocol } from "@smithy/core/protocols";
2
- import { TypeRegistry } from "@smithy/core/schema";
3
- import { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, SerdeFunctions } from "@smithy/types";
1
+ import { AbstractRpcV2Protocol } from "@smithy/core/protocols";
2
+ import { HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, OperationSchema, ResponseMetadata, SerdeFunctions } from "@smithy/types";
4
3
  import { CborCodec } from "./CborCodec";
5
4
  /**
6
5
  * Client protocol for Smithy RPCv2 CBOR.
7
6
  *
8
7
  * @public
9
8
  */
10
- export declare class SmithyRpcV2CborProtocol extends RpcProtocol {
11
- /**
12
- * @override
13
- */
14
- protected compositeErrorRegistry: TypeRegistry;
9
+ export declare class SmithyRpcV2CborProtocol extends AbstractRpcV2Protocol {
15
10
  private codec;
16
11
  protected serializer: import(".").CborShapeSerializer2;
17
12
  protected deserializer: import(".").CborShapeDeserializer2;
18
- constructor({ defaultNamespace, errorTypeRegistries, }: {
19
- defaultNamespace: string;
20
- errorTypeRegistries?: TypeRegistry[];
21
- });
22
13
  getShapeId(): string;
23
14
  getPayloadCodec(): CborCodec;
24
- serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
25
- deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
15
+ protected getSmithyProtocolHeaderValue(): string;
16
+ protected applyEmptyBody(request: IHttpRequest): void;
26
17
  protected handleError(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any, metadata: ResponseMetadata): Promise<never>;
27
18
  protected getDefaultContentType(): string;
28
19
  }
@@ -0,0 +1,45 @@
1
+ import { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, OperationSchema, SerdeFunctions } from "@smithy/types";
2
+ import { TypeRegistry } from "@smithy/core/schema";
3
+ import { RpcProtocol } from "./RpcProtocol";
4
+ /**
5
+ * Shared abstract base for the Smithy RPC v2 client protocols (JSON and CBOR).
6
+ *
7
+ * Factors out the request-framing flow and response status handling that are
8
+ * identical across both RPC v2 protocols. Concrete protocols supply their
9
+ * codec, error handling, content type, shape id, and the two per-protocol
10
+ * request details via {@link getSmithyProtocolHeaderValue} and
11
+ * {@link applyEmptyBody}.
12
+ *
13
+ * @internal
14
+ */
15
+ export declare abstract class AbstractRpcV2Protocol extends RpcProtocol {
16
+ /**
17
+ * @override
18
+ */
19
+ protected compositeErrorRegistry: TypeRegistry;
20
+ constructor({ defaultNamespace, errorTypeRegistries, }: {
21
+ defaultNamespace: string;
22
+ errorTypeRegistries?: TypeRegistry[];
23
+ });
24
+ serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
25
+ /**
26
+ * @override
27
+ *
28
+ * Per the Smithy RPC v2 specification, the only successful response status
29
+ * code is 200; any other status code MUST be handled as an error.
30
+ */
31
+ protected isErrorResponse(statusCode: number): boolean;
32
+ /**
33
+ * @returns the value of the `smithy-protocol` header for this protocol,
34
+ * e.g. `rpc-v2-json` or `rpc-v2-cbor`.
35
+ */
36
+ protected abstract getSmithyProtocolHeaderValue(): string;
37
+ /**
38
+ * Applies this protocol's representation of an empty request body when the
39
+ * operation has a non-unit input but produced no serialized body. Called
40
+ * only for non-unit inputs.
41
+ *
42
+ * @param request - the request being serialized, mutated in place.
43
+ */
44
+ protected abstract applyEmptyBody(request: IHttpRequest): void;
45
+ }
@@ -13,4 +13,16 @@ export declare abstract class RpcProtocol extends HttpProtocol {
13
13
  protected compositeErrorRegistry: TypeRegistry;
14
14
  serializeRequest<Input extends object>(operationSchema: OperationSchema, _input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
15
15
  deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
16
+ /**
17
+ * Determines whether a response status code indicates an error response that
18
+ * should be routed to {@link handleError} rather than deserialized as output.
19
+ *
20
+ * The default treats any status code of 300 or greater as an error,
21
+ * preserving the historical behavior for RPC-over-HTTP protocols. Subclasses
22
+ * whose specification is stricter SHOULD override this.
23
+ *
24
+ * @param statusCode - the HTTP response status code.
25
+ * @returns true if the response should be handled as an error.
26
+ */
27
+ protected isErrorResponse(statusCode: number): boolean;
16
28
  }
@@ -3,6 +3,7 @@ export { extendedEncodeURIComponent } from "./extended-encode-uri-component";
3
3
  export { HttpBindingProtocol } from "./HttpBindingProtocol";
4
4
  export { HttpProtocol } from "./HttpProtocol";
5
5
  export { RpcProtocol } from "./RpcProtocol";
6
+ export { AbstractRpcV2Protocol } from "./AbstractRpcV2Protocol";
6
7
  export { RequestBuilder, requestBuilder } from "./requestBuilder";
7
8
  export { resolvedPath } from "./resolve-path";
8
9
  export { FromStringShapeDeserializer } from "./serde/FromStringShapeDeserializer";
@@ -1,28 +1,19 @@
1
- import { RpcProtocol } from "../RpcProtocol";
2
- import { TypeRegistry } from "@smithy/core/schema";
3
- import { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
1
+ import { AbstractRpcV2Protocol } from "../AbstractRpcV2Protocol";
2
+ import { HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, OperationSchema, ResponseMetadata, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
4
3
  import { JsonCodec2 } from "./codec-v2/JsonCodec2";
5
4
  /**
6
5
  * Client protocol for Smithy RPCv2 JSON.
7
6
  *
8
7
  * @public
9
8
  */
10
- export declare class SmithyRpcV2JsonProtocol extends RpcProtocol {
11
- /**
12
- * @override
13
- */
14
- protected compositeErrorRegistry: TypeRegistry;
9
+ export declare class SmithyRpcV2JsonProtocol extends AbstractRpcV2Protocol {
15
10
  private codec;
16
11
  protected serializer: ShapeSerializer<string | Uint8Array>;
17
12
  protected deserializer: ShapeDeserializer<string | Uint8Array>;
18
- constructor({ defaultNamespace, errorTypeRegistries, }: {
19
- defaultNamespace: string;
20
- errorTypeRegistries?: TypeRegistry[];
21
- });
22
13
  getShapeId(): string;
23
14
  getPayloadCodec(): JsonCodec2;
24
- serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
25
- deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
15
+ protected getSmithyProtocolHeaderValue(): string;
16
+ protected applyEmptyBody(request: IHttpRequest): void;
26
17
  protected handleError(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any, metadata: ResponseMetadata): Promise<never>;
27
18
  protected getDefaultContentType(): string;
28
19
  }
@@ -24,6 +24,7 @@ export declare const getHttpHandlerExtensionConfiguration: <HandlerConfig extend
24
24
  logger?: Logger;
25
25
  }>(runtimeConfig: HttpHandlerExtensionConfigType<HandlerConfig> & {
26
26
  logger?: Logger;
27
+ defaultSocketTimeout?: number;
27
28
  }) => {
28
29
  setHttpHandler(handler: HttpHandler<HandlerConfig>): void;
29
30
  httpHandler(): HttpHandler<HandlerConfig>;
@@ -40,3 +40,4 @@ export { streamCollector } from "./util-stream/stream-collector.browser";
40
40
  export declare const v4: () => string;
41
41
  export declare const generateIdempotencyToken: () => string;
42
42
  export { hasOwn } from "@smithy/core/transport";
43
+ export { writeKey } from "./writeKey";
@@ -38,3 +38,4 @@ export { streamCollector } from "./util-stream/stream-collector";
38
38
  export declare const v4: () => string;
39
39
  export declare const generateIdempotencyToken: () => string;
40
40
  export { hasOwn } from "@smithy/core/transport";
41
+ export { writeKey } from "./writeKey";
@@ -38,3 +38,4 @@ export { streamCollector } from "./util-stream/stream-collector.browser";
38
38
  export declare const v4: () => string;
39
39
  export declare const generateIdempotencyToken: () => string;
40
40
  export { hasOwn } from "@smithy/core/transport";
41
+ export { writeKey } from "./writeKey";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.36.2",
3
+ "version": "3.38.0",
4
4
  "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/core",
5
5
  "license": "Apache-2.0",
6
6
  "author": {