@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
@@ -9,14 +9,18 @@ const getHomeDirCacheKey = () => {
9
9
  };
10
10
  export const getHomeDir = () => {
11
11
  const { HOME, USERPROFILE, HOMEPATH, HOMEDRIVE = `C:${sep}` } = process.env;
12
- if (HOME)
12
+ if (HOME) {
13
13
  return HOME;
14
- if (USERPROFILE)
14
+ }
15
+ if (USERPROFILE) {
15
16
  return USERPROFILE;
16
- if (HOMEPATH)
17
+ }
18
+ if (HOMEPATH) {
17
19
  return `${HOMEDRIVE}${HOMEPATH}`;
20
+ }
18
21
  const homeDirCacheKey = getHomeDirCacheKey();
19
- if (!homeDirCache[homeDirCacheKey])
22
+ if (!homeDirCache[homeDirCacheKey]) {
20
23
  homeDirCache[homeDirCacheKey] = homedir();
24
+ }
21
25
  return homeDirCache[homeDirCacheKey];
22
26
  };
@@ -1,9 +1,12 @@
1
1
  export const booleanSelector = (obj, key, type) => {
2
- if (!(key in obj))
2
+ if (!(key in obj)) {
3
3
  return undefined;
4
- if (obj[key] === "true")
4
+ }
5
+ if (obj[key] === "true") {
5
6
  return true;
6
- if (obj[key] === "false")
7
+ }
8
+ if (obj[key] === "false") {
7
9
  return false;
10
+ }
8
11
  throw new Error(`Cannot load ${type} "${key}". Expected "true" or "false", got ${obj[key]}.`);
9
12
  };
@@ -1,6 +1,7 @@
1
1
  export const numberSelector = (obj, key, type) => {
2
- if (!(key in obj))
2
+ if (!(key in obj)) {
3
3
  return undefined;
4
+ }
4
5
  const numberValue = parseInt(obj[key], 10);
5
6
  if (Number.isNaN(numberValue)) {
6
7
  throw new TypeError(`Cannot load ${type} '${key}'. Expected number, got '${obj[key]}'.`);
@@ -5,11 +5,13 @@ export const getEndpointUrlConfig = (serviceId) => ({
5
5
  environmentVariableSelector: (env) => {
6
6
  const serviceSuffixParts = serviceId.split(" ").map((w) => w.toUpperCase());
7
7
  const serviceEndpointUrl = env[[ENV_ENDPOINT_URL, ...serviceSuffixParts].join("_")];
8
- if (serviceEndpointUrl)
8
+ if (serviceEndpointUrl) {
9
9
  return serviceEndpointUrl;
10
+ }
10
11
  const endpointUrl = env[ENV_ENDPOINT_URL];
11
- if (endpointUrl)
12
+ if (endpointUrl) {
12
13
  return endpointUrl;
14
+ }
13
15
  return undefined;
14
16
  },
15
17
  configFileSelector: (profile, config) => {
@@ -21,12 +23,14 @@ export const getEndpointUrlConfig = (serviceId) => ({
21
23
  const servicesSection = config[servicesSectionKey];
22
24
  const servicePrefixParts = serviceId.split(" ").map((w) => w.toLowerCase());
23
25
  const endpointUrl = servicesSection[[servicePrefixParts.join("_"), CONFIG_ENDPOINT_URL].join(CONFIG_PREFIX_SEPARATOR)];
24
- if (endpointUrl)
26
+ if (endpointUrl) {
25
27
  return endpointUrl;
28
+ }
26
29
  }
27
30
  const endpointUrl = profile[CONFIG_ENDPOINT_URL];
28
- if (endpointUrl)
31
+ if (endpointUrl) {
29
32
  return endpointUrl;
33
+ }
30
34
  return undefined;
31
35
  },
32
36
  default: undefined,
@@ -7,8 +7,9 @@ export const resolveEndpoint = (ruleSetObject, options) => {
7
7
  const { parameters, rules } = ruleSetObject;
8
8
  options.logger?.debug?.(`${debugId} Initial EndpointParams: ${toDebugString(endpointParams)}`);
9
9
  for (const paramKey in parameters) {
10
- if (!hasOwn(parameters, paramKey))
10
+ if (!hasOwn(parameters, paramKey)) {
11
11
  continue;
12
+ }
12
13
  const parameter = parameters[paramKey];
13
14
  const endpointParam = endpointParams[paramKey];
14
15
  if (endpointParam == null && parameter.default != null) {
@@ -53,8 +53,9 @@ export class EventStreamSerde {
53
53
  }
54
54
  let unionMember = "";
55
55
  for (const key in event) {
56
- if (!hasOwn(event, key))
56
+ if (!hasOwn(event, key)) {
57
57
  continue;
58
+ }
58
59
  if (key !== "__type") {
59
60
  unionMember = key;
60
61
  break;
@@ -82,8 +83,9 @@ export class EventStreamSerde {
82
83
  const asyncIterable = marshaller.deserialize(response.body, async (event) => {
83
84
  let unionMember = "";
84
85
  for (const key in event) {
85
- if (!hasOwn(event, key))
86
+ if (!hasOwn(event, key)) {
86
87
  continue;
88
+ }
87
89
  if (key !== "__type") {
88
90
  unionMember = key;
89
91
  break;
@@ -158,8 +160,9 @@ export class EventStreamSerde {
158
160
  throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");
159
161
  }
160
162
  for (const key in firstEvent.value) {
161
- if (!hasOwn(firstEvent.value, key))
163
+ if (!hasOwn(firstEvent.value, key)) {
162
164
  continue;
165
+ }
163
166
  initialResponseContainer[key] = firstEvent.value[key];
164
167
  }
165
168
  }
@@ -11,8 +11,9 @@ export class HeaderMarshaller {
11
11
  format(headers) {
12
12
  const chunks = [];
13
13
  for (const headerName in headers) {
14
- if (!hasOwn(headers, headerName))
14
+ if (!hasOwn(headers, headerName)) {
15
15
  continue;
16
+ }
16
17
  const bytes = this.fromUtf8(headerName);
17
18
  if (bytes.byteLength > 255) {
18
19
  throw new Error(`@smithy/core/event-streams - header name exceeds 255 bytes: ${bytes.byteLength}`);
@@ -38,7 +38,8 @@ function negate(bytes) {
38
38
  }
39
39
  for (let i = 7; i > -1; i--) {
40
40
  bytes[i]++;
41
- if (bytes[i] !== 0)
41
+ if (bytes[i] !== 0) {
42
42
  break;
43
+ }
43
44
  }
44
45
  }
@@ -9,8 +9,9 @@ export class SmithyMessageDecoderStream {
9
9
  async *asyncIterator() {
10
10
  for await (const message of this.options.messageStream) {
11
11
  const deserialized = await this.options.deserializer(message);
12
- if (deserialized === undefined)
12
+ if (deserialized === undefined) {
13
13
  continue;
14
+ }
14
15
  yield deserialized;
15
16
  }
16
17
  }
@@ -4,8 +4,9 @@ export const readableStreamToIterable = (readableStream) => ({
4
4
  try {
5
5
  while (true) {
6
6
  const { done, value } = await reader.read();
7
- if (done)
7
+ if (done) {
8
8
  return;
9
+ }
9
10
  yield value;
10
11
  }
11
12
  }
@@ -5,8 +5,9 @@ export function getUnmarshalledStream(source, options) {
5
5
  for await (const chunk of source) {
6
6
  const message = options.eventStreamCodec.decode(chunk);
7
7
  const type = await messageUnmarshaller(message);
8
- if (type === undefined)
8
+ if (type === undefined) {
9
9
  continue;
10
+ }
10
11
  yield type;
11
12
  }
12
13
  },
@@ -36,8 +37,9 @@ export function getMessageUnmarshaller(deserializer, toUtf8) {
36
37
  [message.headers[":event-type"].value]: message,
37
38
  };
38
39
  const deserialized = await deserializer(event);
39
- if (deserialized.$unknown)
40
+ if (deserialized.$unknown) {
40
41
  return;
42
+ }
41
43
  return deserialized;
42
44
  }
43
45
  else {
@@ -0,0 +1,35 @@
1
+ import { deref } from "@smithy/core/schema";
2
+ import { getSmithyContext } from "@smithy/core/transport";
3
+ import { RpcProtocol } from "./RpcProtocol";
4
+ export class AbstractRpcV2Protocol extends RpcProtocol {
5
+ constructor({ defaultNamespace, errorTypeRegistries, }) {
6
+ super({ defaultNamespace, errorTypeRegistries });
7
+ }
8
+ async serializeRequest(operationSchema, input, context) {
9
+ const request = await super.serializeRequest(operationSchema, input, context);
10
+ Object.assign(request.headers, {
11
+ "content-type": this.getDefaultContentType(),
12
+ "smithy-protocol": this.getSmithyProtocolHeaderValue(),
13
+ accept: this.getDefaultContentType(),
14
+ });
15
+ if (deref(operationSchema.input) === "unit") {
16
+ delete request.body;
17
+ delete request.headers["content-type"];
18
+ }
19
+ else {
20
+ this.applyEmptyBody(request);
21
+ }
22
+ const { service, operation } = getSmithyContext(context);
23
+ const path = `/service/${service}/operation/${operation}`;
24
+ if (request.path.endsWith("/")) {
25
+ request.path += path.slice(1);
26
+ }
27
+ else {
28
+ request.path += path;
29
+ }
30
+ return request;
31
+ }
32
+ isErrorResponse(statusCode) {
33
+ return statusCode !== 200;
34
+ }
35
+ }
@@ -94,8 +94,9 @@ export class HttpBindingProtocol extends HttpProtocol {
94
94
  }
95
95
  else if (typeof memberTraits.httpPrefixHeaders === "string") {
96
96
  for (const key in inputMemberValue) {
97
- if (!hasOwn(inputMemberValue, key))
97
+ if (!hasOwn(inputMemberValue, key)) {
98
98
  continue;
99
+ }
99
100
  const val = inputMemberValue[key];
100
101
  const amalgam = memberTraits.httpPrefixHeaders + key;
101
102
  serializer.write([memberNs.getValueSchema(), { httpHeader: amalgam }], val);
@@ -142,8 +143,9 @@ export class HttpBindingProtocol extends HttpProtocol {
142
143
  const traits = ns.getMergedTraits();
143
144
  if (traits.httpQueryParams) {
144
145
  for (const key in data) {
145
- if (!hasOwn(data, key))
146
+ if (!hasOwn(data, key)) {
146
147
  continue;
148
+ }
147
149
  if (!(key in query)) {
148
150
  const val = data[key];
149
151
  const valueSchema = ns.getValueSchema();
@@ -187,8 +189,9 @@ export class HttpBindingProtocol extends HttpProtocol {
187
189
  throw new Error("@smithy/core/protocols - HTTP Protocol error handler failed to throw.");
188
190
  }
189
191
  for (const header in response.headers) {
190
- if (!hasOwn(response.headers, header))
192
+ if (!hasOwn(response.headers, header)) {
191
193
  continue;
194
+ }
192
195
  const value = response.headers[header];
193
196
  delete response.headers[header];
194
197
  response.headers[header.toLowerCase()] = value;
@@ -276,8 +279,9 @@ export class HttpBindingProtocol extends HttpProtocol {
276
279
  else if (memberTraits.httpPrefixHeaders !== undefined) {
277
280
  dataObject[memberName] = {};
278
281
  for (const header in response.headers) {
279
- if (!hasOwn(response.headers, header))
282
+ if (!hasOwn(response.headers, header)) {
280
283
  continue;
284
+ }
281
285
  if (header.startsWith(memberTraits.httpPrefixHeaders)) {
282
286
  const value = response.headers[header];
283
287
  const valueSchema = memberSchema.getValueSchema();
@@ -44,8 +44,9 @@ export class HttpProtocol extends SerdeContext {
44
44
  }
45
45
  if (endpoint.headers) {
46
46
  for (const name in endpoint.headers) {
47
- if (!hasOwn(endpoint.headers, name))
47
+ if (!hasOwn(endpoint.headers, name)) {
48
48
  continue;
49
+ }
49
50
  request.headers[name] = endpoint.headers[name].join(", ");
50
51
  }
51
52
  }
@@ -61,8 +62,9 @@ export class HttpProtocol extends SerdeContext {
61
62
  };
62
63
  if (endpoint.headers) {
63
64
  for (const name in endpoint.headers) {
64
- if (!hasOwn(endpoint.headers, name))
65
+ if (!hasOwn(endpoint.headers, name)) {
65
66
  continue;
67
+ }
66
68
  request.headers[name] = endpoint.headers[name];
67
69
  }
68
70
  }
@@ -59,7 +59,7 @@ export class RpcProtocol extends HttpProtocol {
59
59
  const deserializer = this.deserializer;
60
60
  const ns = NormalizedSchema.of(operationSchema.output);
61
61
  const dataObject = {};
62
- if (response.statusCode >= 300) {
62
+ if (this.isErrorResponse(response.statusCode)) {
63
63
  const bytes = await collectBody(response.body, context);
64
64
  if (bytes.byteLength > 0) {
65
65
  Object.assign(dataObject, await deserializer.read(15, bytes));
@@ -68,8 +68,9 @@ export class RpcProtocol extends HttpProtocol {
68
68
  throw new Error("@smithy/core/protocols - RPC Protocol error handler failed to throw.");
69
69
  }
70
70
  for (const header in response.headers) {
71
- if (!hasOwn(response.headers, header))
71
+ if (!hasOwn(response.headers, header)) {
72
72
  continue;
73
+ }
73
74
  const value = response.headers[header];
74
75
  delete response.headers[header];
75
76
  response.headers[header.toLowerCase()] = value;
@@ -91,4 +92,7 @@ export class RpcProtocol extends HttpProtocol {
91
92
  dataObject.$metadata = this.deserializeMetadata(response);
92
93
  return dataObject;
93
94
  }
95
+ isErrorResponse(statusCode) {
96
+ return statusCode >= 300;
97
+ }
94
98
  }
@@ -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,9 +1,8 @@
1
- import { RpcProtocol } from "../RpcProtocol";
2
- import { NormalizedSchema, TypeRegistry, deref } from "@smithy/core/schema";
3
- import { getSmithyContext } from "@smithy/core/transport";
1
+ import { AbstractRpcV2Protocol } from "../AbstractRpcV2Protocol";
2
+ import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
4
3
  import { JsonCodec2 } from "./codec-v2/JsonCodec2";
5
4
  import { loadSmithyRpcV2JsonErrorCode } from "./parseJsonBody";
6
- export class SmithyRpcV2JsonProtocol extends RpcProtocol {
5
+ export class SmithyRpcV2JsonProtocol extends AbstractRpcV2Protocol {
7
6
  codec = new JsonCodec2({
8
7
  timestampFormat: {
9
8
  useTrait: false,
@@ -14,41 +13,19 @@ export class SmithyRpcV2JsonProtocol extends RpcProtocol {
14
13
  });
15
14
  serializer = this.codec.createSerializer();
16
15
  deserializer = this.codec.createDeserializer();
17
- constructor({ defaultNamespace, errorTypeRegistries, }) {
18
- super({ defaultNamespace, errorTypeRegistries });
19
- }
20
16
  getShapeId() {
21
17
  return "smithy.protocols#rpcv2Json";
22
18
  }
23
19
  getPayloadCodec() {
24
20
  return this.codec;
25
21
  }
26
- async serializeRequest(operationSchema, input, context) {
27
- const request = await super.serializeRequest(operationSchema, input, context);
28
- Object.assign(request.headers, {
29
- "content-type": this.getDefaultContentType(),
30
- "smithy-protocol": "rpc-v2-json",
31
- accept: this.getDefaultContentType(),
32
- });
33
- if (deref(operationSchema.input) === "unit") {
34
- delete request.body;
35
- delete request.headers["content-type"];
36
- }
37
- else if (!request.body) {
22
+ getSmithyProtocolHeaderValue() {
23
+ return "rpc-v2-json";
24
+ }
25
+ applyEmptyBody(request) {
26
+ if (!request.body) {
38
27
  request.body = "{}";
39
28
  }
40
- const { service, operation } = getSmithyContext(context);
41
- const path = `/service/${service}/operation/${operation}`;
42
- if (request.path.endsWith("/")) {
43
- request.path += path.slice(1);
44
- }
45
- else {
46
- request.path += path;
47
- }
48
- return request;
49
- }
50
- async deserializeResponse(operationSchema, context, response) {
51
- return super.deserializeResponse(operationSchema, context, response);
52
29
  }
53
30
  async handleError(operationSchema, context, response, dataObject, metadata) {
54
31
  const errorName = loadSmithyRpcV2JsonErrorCode(response, dataObject) ?? "Unknown";
@@ -1,6 +1,6 @@
1
1
  import { determineTimestampFormat } from "../../serde/determineTimestampFormat";
2
2
  import { NormalizedSchema } from "@smithy/core/schema";
3
- import { LazyJsonString, NumericValue, parseEpochTimestamp, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, } from "@smithy/core/serde";
3
+ import { LazyJsonString, NumericValue, parseEpochTimestamp, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, writeKey, } from "@smithy/core/serde";
4
4
  import { fromBase64 } from "@smithy/core/serde";
5
5
  import { hasOwn } from "@smithy/core/transport";
6
6
  import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
@@ -8,7 +8,6 @@ import { UnionSerde } from "../../UnionSerde";
8
8
  import { jsonReviver } from "../jsonReviver";
9
9
  import { needsReviver } from "../needsReviver";
10
10
  import { parseJsonBody } from "../parseJsonBody";
11
- import { writeKey } from "../../writeKey";
12
11
  export class JsonShapeDeserializer extends SerdeContextConfig {
13
12
  settings;
14
13
  constructor(settings) {
@@ -57,8 +56,9 @@ export class JsonShapeDeserializer extends SerdeContextConfig {
57
56
  }
58
57
  else if (typeof record.__type === "string") {
59
58
  for (const k in record) {
60
- if (!hasOwn(record, k))
59
+ if (!hasOwn(record, k)) {
61
60
  continue;
61
+ }
62
62
  const v = record[k];
63
63
  const t = jsonName ? (nameMap[k] ?? k) : k;
64
64
  if (!(t in out)) {
@@ -80,8 +80,9 @@ export class JsonShapeDeserializer extends SerdeContextConfig {
80
80
  const mapMember = ns.getValueSchema();
81
81
  const out = {};
82
82
  for (const _k in value) {
83
- if (!hasOwn(value, _k))
83
+ if (!hasOwn(value, _k)) {
84
84
  continue;
85
+ }
85
86
  if (_k === "__proto__") {
86
87
  writeKey(out);
87
88
  }
@@ -143,8 +144,9 @@ export class JsonShapeDeserializer extends SerdeContextConfig {
143
144
  if (isObject) {
144
145
  const out = Array.isArray(value) ? [] : {};
145
146
  for (const k in value) {
146
- if (!hasOwn(value, k))
147
+ if (!hasOwn(value, k)) {
147
148
  continue;
149
+ }
148
150
  if (k === "__proto__") {
149
151
  writeKey(out);
150
152
  }
@@ -1,9 +1,8 @@
1
1
  import { determineTimestampFormat } from "../../serde/determineTimestampFormat";
2
2
  import { NormalizedSchema } from "@smithy/core/schema";
3
- import { dateToUtcString, generateIdempotencyToken, LazyJsonString, NumericValue, toBase64 } from "@smithy/core/serde";
3
+ import { dateToUtcString, generateIdempotencyToken, LazyJsonString, NumericValue, toBase64, writeKey, } from "@smithy/core/serde";
4
4
  import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
5
5
  import { JsonReplacer } from "../jsonReplacer";
6
- import { writeKey } from "../../writeKey";
7
6
  import { hasOwn } from "@smithy/core/transport";
8
7
  export class JsonShapeSerializer extends SerdeContextConfig {
9
8
  settings;
@@ -74,8 +73,9 @@ export class JsonShapeSerializer extends SerdeContextConfig {
74
73
  }
75
74
  else if (typeof record.__type === "string") {
76
75
  for (const k in record) {
77
- if (!hasOwn(record, k))
76
+ if (!hasOwn(record, k)) {
78
77
  continue;
78
+ }
79
79
  const v = record[k];
80
80
  const targetKey = jsonName ? (nameMap[k] ?? k) : k;
81
81
  if (!(targetKey in out)) {
@@ -101,8 +101,9 @@ export class JsonShapeSerializer extends SerdeContextConfig {
101
101
  const out = {};
102
102
  const sparse = !!ns.getMergedTraits().sparse;
103
103
  for (const _k in value) {
104
- if (!hasOwn(value, _k))
104
+ if (!hasOwn(value, _k)) {
105
105
  continue;
106
+ }
106
107
  const _v = value[_k];
107
108
  if (sparse || _v != null) {
108
109
  if (_k === "__proto__") {
@@ -175,8 +176,9 @@ export class JsonShapeSerializer extends SerdeContextConfig {
175
176
  }
176
177
  const out = Array.isArray(value) ? [] : {};
177
178
  for (const k in value) {
178
- if (!hasOwn(value, k))
179
+ if (!hasOwn(value, k)) {
179
180
  continue;
181
+ }
180
182
  const v = value[k];
181
183
  if (k === "__proto__") {
182
184
  writeKey(out);
@@ -1,13 +1,12 @@
1
1
  import { determineTimestampFormat } from "../../serde/determineTimestampFormat";
2
2
  import { NormalizedSchema } from "@smithy/core/schema";
3
- import { fromBase64, LazyJsonString, NumericValue, parseEpochTimestamp, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, } from "@smithy/core/serde";
3
+ import { fromBase64, LazyJsonString, NumericValue, parseEpochTimestamp, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, writeKey, } from "@smithy/core/serde";
4
4
  import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
5
5
  import { UnionSerde } from "../../UnionSerde";
6
6
  import { detectBufferParsing } from "../detectBufferParsing";
7
7
  import { jsonReviver } from "../jsonReviver";
8
8
  import { needsReviver } from "../needsReviver";
9
9
  import { parseJsonBody } from "../parseJsonBody";
10
- import { writeKey } from "../../writeKey";
11
10
  import { hasOwn } from "@smithy/core/transport";
12
11
  export class JsonShapeDeserializer2 extends SerdeContextConfig {
13
12
  settings;
@@ -60,8 +59,9 @@ export class JsonShapeDeserializer2 extends SerdeContextConfig {
60
59
  const map = value;
61
60
  if (this.needsTransform(mapMember)) {
62
61
  for (const k in map) {
63
- if (!hasOwn(map, k))
62
+ if (!hasOwn(map, k)) {
64
63
  continue;
64
+ }
65
65
  if (k === "__proto__") {
66
66
  writeKey(map);
67
67
  }
@@ -133,8 +133,9 @@ export class JsonShapeDeserializer2 extends SerdeContextConfig {
133
133
  else {
134
134
  const doc = value;
135
135
  for (const k in doc) {
136
- if (!hasOwn(doc, k))
136
+ if (!hasOwn(doc, k)) {
137
137
  continue;
138
+ }
138
139
  if (k === "__proto__") {
139
140
  writeKey(doc);
140
141
  }
@@ -181,8 +182,9 @@ export class JsonShapeDeserializer2 extends SerdeContextConfig {
181
182
  }
182
183
  else if (hasType) {
183
184
  for (const k in record) {
184
- if (!hasOwn(record, k))
185
+ if (!hasOwn(record, k)) {
185
186
  continue;
187
+ }
186
188
  const v = record[k];
187
189
  const t = jsonName ? (nameMap[k] ?? k) : k;
188
190
  if (!(t in out)) {
@@ -417,8 +417,9 @@ export class JsonShapeSerializer2 extends SerdeContextConfig {
417
417
  const out = [];
418
418
  for (let i = 0; i < value.length; ++i) {
419
419
  const v = value[i];
420
- if (v == null && !sparse)
420
+ if (v == null && !sparse) {
421
421
  continue;
422
+ }
422
423
  if (Number.isNaN(v) || v === Infinity || v === -Infinity) {
423
424
  out.push(String(v));
424
425
  }
@@ -458,8 +459,9 @@ export class JsonShapeSerializer2 extends SerdeContextConfig {
458
459
  if (valueSchema.isStringSchema() || valueSchema.isNumericSchema() || valueSchema.isBooleanSchema()) {
459
460
  let modifications;
460
461
  for (const k in value) {
461
- if (!hasOwn(value, k))
462
+ if (!hasOwn(value, k)) {
462
463
  continue;
464
+ }
463
465
  const v = value[k];
464
466
  if (Number.isNaN(v) || v === Infinity || v === -Infinity) {
465
467
  (modifications ??= {})[k] = v;
@@ -483,8 +485,9 @@ export class JsonShapeSerializer2 extends SerdeContextConfig {
483
485
  this.json[this.i++] = OPEN_BRACE;
484
486
  let first = true;
485
487
  for (const k in value) {
486
- if (!hasOwn(value, k))
488
+ if (!hasOwn(value, k)) {
487
489
  continue;
490
+ }
488
491
  const v = value[k];
489
492
  if (isDocument ? v === undefined : v == null && !sparse) {
490
493
  continue;
@@ -2,6 +2,9 @@ export const getHttpHandlerExtensionConfiguration = (runtimeConfig) => {
2
2
  if (runtimeConfig.logger && runtimeConfig.logger.constructor?.name !== "NoOpLogger") {
3
3
  runtimeConfig.requestHandler?.updateHttpClientConfig?.(Symbol.for("logger"), runtimeConfig.logger);
4
4
  }
5
+ if (runtimeConfig.defaultSocketTimeout) {
6
+ runtimeConfig.requestHandler?.updateHttpClientConfig?.(Symbol.for("@smithy/defaultSocketTimeout"), runtimeConfig.defaultSocketTimeout);
7
+ }
5
8
  return {
6
9
  setHttpHandler(handler) {
7
10
  runtimeConfig.requestHandler = handler;
@@ -8,8 +8,9 @@ export const CONFIG_MAX_ATTEMPTS = "max_attempts";
8
8
  export const NODE_MAX_ATTEMPT_CONFIG_OPTIONS = {
9
9
  environmentVariableSelector: (env) => {
10
10
  const value = env[ENV_MAX_ATTEMPTS];
11
- if (!value)
11
+ if (!value) {
12
12
  return undefined;
13
+ }
13
14
  const maxAttempt = parseInt(value);
14
15
  if (Number.isNaN(maxAttempt)) {
15
16
  throw new Error(`Environment variable ${ENV_MAX_ATTEMPTS} mast be a number, got "${value}"`);
@@ -18,8 +19,9 @@ export const NODE_MAX_ATTEMPT_CONFIG_OPTIONS = {
18
19
  },
19
20
  configFileSelector: (profile) => {
20
21
  const value = profile[CONFIG_MAX_ATTEMPTS];
21
- if (!value)
22
+ if (!value) {
22
23
  return undefined;
24
+ }
23
25
  const maxAttempt = parseInt(value);
24
26
  if (Number.isNaN(maxAttempt)) {
25
27
  throw new Error(`Shared config file entry ${CONFIG_MAX_ATTEMPTS} mast be a number, got "${value}"`);
@@ -6,8 +6,9 @@ export function parseRetryAfterHeader(response, logger) {
6
6
  return;
7
7
  }
8
8
  for (const header in response.headers) {
9
- if (!hasOwn(response.headers, header))
9
+ if (!hasOwn(response.headers, header)) {
10
10
  continue;
11
+ }
11
12
  const h = header.toLowerCase();
12
13
  if (h === "retry-after") {
13
14
  const retryAfter = response.headers[header];
@@ -81,15 +81,18 @@ export class StandardRetryStrategy {
81
81
  }
82
82
  }
83
83
  const getDelayFromRetryAfterHeader = (response) => {
84
- if (!HttpResponse.isInstance(response))
84
+ if (!HttpResponse.isInstance(response)) {
85
85
  return;
86
+ }
86
87
  const retryAfterHeaderName = Object.keys(response.headers).find((key) => key.toLowerCase() === "retry-after");
87
- if (!retryAfterHeaderName)
88
+ if (!retryAfterHeaderName) {
88
89
  return;
90
+ }
89
91
  const retryAfter = response.headers[retryAfterHeaderName];
90
92
  const retryAfterSeconds = Number(retryAfter);
91
- if (!Number.isNaN(retryAfterSeconds))
93
+ if (!Number.isNaN(retryAfterSeconds)) {
92
94
  return Math.min(retryAfterSeconds * 1000, 20_000);
95
+ }
93
96
  const retryAfterDate = new Date(retryAfter);
94
97
  return Math.min(retryAfterDate.getTime() - Date.now(), 20_000);
95
98
  };