@aws-sdk/core 3.977.0 → 3.977.2

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 (21) hide show
  1. package/dist-cjs/submodules/protocols/index.js +22 -3
  2. package/dist-es/submodules/protocols/index.js +2 -2
  3. package/dist-es/submodules/protocols/json/JsonCodec.js +2 -2
  4. package/dist-es/submodules/protocols/json/{JsonShapeDeserializer.js → codec-v1/JsonShapeDeserializer.js} +6 -6
  5. package/dist-es/submodules/protocols/json/{JsonShapeSerializer.js → codec-v1/JsonShapeSerializer.js} +3 -3
  6. package/dist-es/submodules/protocols/json/{experimental → codec-v2}/ByteJsonShapeSerializer.js +19 -1
  7. package/dist-es/submodules/protocols/json/jsonReviver.js +22 -3
  8. package/dist-types/submodules/protocols/index.d.ts +2 -2
  9. package/dist-types/submodules/protocols/json/JsonCodec.d.ts +2 -2
  10. package/dist-types/submodules/protocols/json/{JsonShapeDeserializer.d.ts → codec-v1/JsonShapeDeserializer.d.ts} +2 -2
  11. package/dist-types/submodules/protocols/json/{JsonShapeSerializer.d.ts → codec-v1/JsonShapeSerializer.d.ts} +2 -2
  12. package/dist-types/submodules/protocols/json/{experimental → codec-v2}/ByteJsonShapeSerializer.d.ts +15 -0
  13. package/dist-types/ts3.4/submodules/protocols/index.d.ts +2 -2
  14. package/dist-types/ts3.4/submodules/protocols/json/JsonCodec.d.ts +2 -2
  15. package/dist-types/ts3.4/submodules/protocols/json/{JsonShapeDeserializer.d.ts → codec-v1/JsonShapeDeserializer.d.ts} +2 -2
  16. package/dist-types/ts3.4/submodules/protocols/json/{JsonShapeSerializer.d.ts → codec-v1/JsonShapeSerializer.d.ts} +2 -2
  17. package/dist-types/ts3.4/submodules/protocols/json/{experimental → codec-v2}/ByteJsonShapeSerializer.d.ts +11 -0
  18. package/package.json +1 -1
  19. /package/dist-es/submodules/protocols/json/{experimental → codec-v2}/BufferJsonShapeDeserializer.js +0 -0
  20. /package/dist-types/submodules/protocols/json/{experimental → codec-v2}/BufferJsonShapeDeserializer.d.ts +0 -0
  21. /package/dist-types/ts3.4/submodules/protocols/json/{experimental → codec-v2}/BufferJsonShapeDeserializer.d.ts +0 -0
@@ -281,12 +281,18 @@ function jsonReviver(key, value, context) {
281
281
  if (context?.source) {
282
282
  const numericString = context.source;
283
283
  if (typeof value === "number") {
284
- if (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER || numericString !== String(value)) {
285
- const isFractional = numericString.includes(".");
286
- if (isFractional) {
284
+ const inSafeRange = value <= Number.MAX_SAFE_INTEGER && value >= Number.MIN_SAFE_INTEGER;
285
+ if (!inSafeRange || numericString !== String(value)) {
286
+ if (inSafeRange && /[eE]/.test(numericString) && String(Number(numericString)) === String(value)) {
287
+ return value;
288
+ }
289
+ if (isFractionalNumeric(numericString)) {
287
290
  return new NumericValue(numericString, "bigDecimal");
288
291
  }
289
292
  else {
293
+ if (/[eE]/.test(numericString)) {
294
+ return BigInt(Number(numericString));
295
+ }
290
296
  return BigInt(numericString);
291
297
  }
292
298
  }
@@ -294,6 +300,19 @@ function jsonReviver(key, value, context) {
294
300
  }
295
301
  return value;
296
302
  }
303
+ function isFractionalNumeric(s) {
304
+ const dotIndex = s.indexOf(".");
305
+ if (dotIndex === -1) {
306
+ return false;
307
+ }
308
+ const eIndex = s.search(/[eE]/);
309
+ if (eIndex === -1) {
310
+ return true;
311
+ }
312
+ const fracDigits = eIndex - dotIndex - 1;
313
+ const exp = parseInt(s.slice(eIndex + 1), 10);
314
+ return exp < fracDigits;
315
+ }
297
316
 
298
317
  const REVIVER_SYMBOL = Symbol.for("@aws-sdk/reviver");
299
318
  function needsReviver(schema) {
@@ -5,8 +5,8 @@ export { AwsJson1_1Protocol } from "./json/AwsJson1_1Protocol";
5
5
  export { AwsJsonRpcProtocol } from "./json/AwsJsonRpcProtocol";
6
6
  export { AwsRestJsonProtocol } from "./json/AwsRestJsonProtocol";
7
7
  export { JsonCodec } from "./json/JsonCodec";
8
- export { JsonShapeDeserializer } from "./json/JsonShapeDeserializer";
9
- export { JsonShapeSerializer } from "./json/JsonShapeSerializer";
8
+ export { JsonShapeDeserializer } from "./json/codec-v1/JsonShapeDeserializer";
9
+ export { JsonShapeSerializer } from "./json/codec-v1/JsonShapeSerializer";
10
10
  export { awsExpectUnion } from "./json/awsExpectUnion";
11
11
  export { parseJsonBody, parseJsonErrorBody, loadRestJsonErrorCode, loadJsonRpcErrorCode } from "./json/parseJsonBody";
12
12
  export { AwsEc2QueryProtocol } from "./query/AwsEc2QueryProtocol";
@@ -1,6 +1,6 @@
1
1
  import { SerdeContextConfig } from "../ConfigurableSerdeContext";
2
- import { JsonShapeDeserializer } from "./JsonShapeDeserializer";
3
- import { JsonShapeSerializer } from "./JsonShapeSerializer";
2
+ import { JsonShapeDeserializer } from "./codec-v1/JsonShapeDeserializer";
3
+ import { JsonShapeSerializer } from "./codec-v1/JsonShapeSerializer";
4
4
  export class JsonCodec extends SerdeContextConfig {
5
5
  settings;
6
6
  constructor(settings) {
@@ -2,12 +2,12 @@ import { determineTimestampFormat } from "@smithy/core/protocols";
2
2
  import { NormalizedSchema } from "@smithy/core/schema";
3
3
  import { LazyJsonString, NumericValue, parseEpochTimestamp, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, } from "@smithy/core/serde";
4
4
  import { fromBase64 } from "@smithy/core/serde";
5
- import { SerdeContextConfig } from "../ConfigurableSerdeContext";
6
- import { UnionSerde } from "../UnionSerde";
7
- import { jsonReviver } from "./jsonReviver";
8
- import { needsReviver } from "./needsReviver";
9
- import { parseJsonBody } from "./parseJsonBody";
10
- import { writeKey } from "../writeKey";
5
+ import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
6
+ import { UnionSerde } from "../../UnionSerde";
7
+ import { jsonReviver } from "../jsonReviver";
8
+ import { needsReviver } from "../needsReviver";
9
+ import { parseJsonBody } from "../parseJsonBody";
10
+ import { writeKey } from "../../writeKey";
11
11
  export class JsonShapeDeserializer extends SerdeContextConfig {
12
12
  settings;
13
13
  constructor(settings) {
@@ -1,9 +1,9 @@
1
1
  import { determineTimestampFormat } from "@smithy/core/protocols";
2
2
  import { NormalizedSchema } from "@smithy/core/schema";
3
3
  import { dateToUtcString, generateIdempotencyToken, LazyJsonString, NumericValue, toBase64 } from "@smithy/core/serde";
4
- import { SerdeContextConfig } from "../ConfigurableSerdeContext";
5
- import { JsonReplacer } from "./jsonReplacer";
6
- import { writeKey } from "../writeKey";
4
+ import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
5
+ import { JsonReplacer } from "../jsonReplacer";
6
+ import { writeKey } from "../../writeKey";
7
7
  export class JsonShapeSerializer extends SerdeContextConfig {
8
8
  settings;
9
9
  buffer;
@@ -1,6 +1,6 @@
1
1
  import { determineTimestampFormat } from "@smithy/core/protocols";
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, toUtf8, } from "@smithy/core/serde";
4
4
  import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
5
5
  import { writeKey } from "../../writeKey";
6
6
  const encoder = new TextEncoder();
@@ -481,3 +481,21 @@ export class ByteJsonShapeSerializer extends SerdeContextConfig {
481
481
  }
482
482
  }
483
483
  }
484
+ export class StringJsonShapeSerializer extends SerdeContextConfig {
485
+ settings;
486
+ byteSerializer;
487
+ constructor(settings) {
488
+ super();
489
+ this.settings = settings;
490
+ this.byteSerializer = new ByteJsonShapeSerializer(settings);
491
+ }
492
+ write(schema, value) {
493
+ this.byteSerializer.write(schema, value);
494
+ }
495
+ writeDiscriminatedDocument(schema, value) {
496
+ this.byteSerializer.writeDiscriminatedDocument(schema, value);
497
+ }
498
+ flush() {
499
+ return (this.serdeContext?.utf8Encoder ?? toUtf8)(this.byteSerializer.flush());
500
+ }
501
+ }
@@ -3,12 +3,18 @@ export function jsonReviver(key, value, context) {
3
3
  if (context?.source) {
4
4
  const numericString = context.source;
5
5
  if (typeof value === "number") {
6
- if (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER || numericString !== String(value)) {
7
- const isFractional = numericString.includes(".");
8
- if (isFractional) {
6
+ const inSafeRange = value <= Number.MAX_SAFE_INTEGER && value >= Number.MIN_SAFE_INTEGER;
7
+ if (!inSafeRange || numericString !== String(value)) {
8
+ if (inSafeRange && /[eE]/.test(numericString) && String(Number(numericString)) === String(value)) {
9
+ return value;
10
+ }
11
+ if (isFractionalNumeric(numericString)) {
9
12
  return new NumericValue(numericString, "bigDecimal");
10
13
  }
11
14
  else {
15
+ if (/[eE]/.test(numericString)) {
16
+ return BigInt(Number(numericString));
17
+ }
12
18
  return BigInt(numericString);
13
19
  }
14
20
  }
@@ -16,3 +22,16 @@ export function jsonReviver(key, value, context) {
16
22
  }
17
23
  return value;
18
24
  }
25
+ function isFractionalNumeric(s) {
26
+ const dotIndex = s.indexOf(".");
27
+ if (dotIndex === -1) {
28
+ return false;
29
+ }
30
+ const eIndex = s.search(/[eE]/);
31
+ if (eIndex === -1) {
32
+ return true;
33
+ }
34
+ const fracDigits = eIndex - dotIndex - 1;
35
+ const exp = parseInt(s.slice(eIndex + 1), 10);
36
+ return exp < fracDigits;
37
+ }
@@ -6,8 +6,8 @@ export { AwsJsonRpcProtocol } from "./json/AwsJsonRpcProtocol";
6
6
  export { AwsRestJsonProtocol } from "./json/AwsRestJsonProtocol";
7
7
  export { JsonCodec } from "./json/JsonCodec";
8
8
  export type { JsonSettings } from "./json/JsonCodec";
9
- export { JsonShapeDeserializer } from "./json/JsonShapeDeserializer";
10
- export { JsonShapeSerializer } from "./json/JsonShapeSerializer";
9
+ export { JsonShapeDeserializer } from "./json/codec-v1/JsonShapeDeserializer";
10
+ export { JsonShapeSerializer } from "./json/codec-v1/JsonShapeSerializer";
11
11
  export { awsExpectUnion } from "./json/awsExpectUnion";
12
12
  export { parseJsonBody, parseJsonErrorBody, loadRestJsonErrorCode, loadJsonRpcErrorCode } from "./json/parseJsonBody";
13
13
  export { AwsEc2QueryProtocol } from "./query/AwsEc2QueryProtocol";
@@ -1,7 +1,7 @@
1
1
  import type { Codec, CodecSettings } from "@smithy/types";
2
2
  import { SerdeContextConfig } from "../ConfigurableSerdeContext";
3
- import { JsonShapeDeserializer } from "./JsonShapeDeserializer";
4
- import { JsonShapeSerializer } from "./JsonShapeSerializer";
3
+ import { JsonShapeDeserializer } from "./codec-v1/JsonShapeDeserializer";
4
+ import { JsonShapeSerializer } from "./codec-v1/JsonShapeSerializer";
5
5
  /**
6
6
  * @public
7
7
  */
@@ -1,6 +1,6 @@
1
1
  import type { DocumentType, Schema, ShapeDeserializer } from "@smithy/types";
2
- import { SerdeContextConfig } from "../ConfigurableSerdeContext";
3
- import type { JsonSettings } from "./JsonCodec";
2
+ import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
3
+ import type { JsonSettings } from "../JsonCodec";
4
4
  /**
5
5
  * @public
6
6
  */
@@ -1,7 +1,7 @@
1
1
  import { NormalizedSchema } from "@smithy/core/schema";
2
2
  import type { Schema, ShapeSerializer } from "@smithy/types";
3
- import { SerdeContextConfig } from "../ConfigurableSerdeContext";
4
- import type { JsonSettings } from "./JsonCodec";
3
+ import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
4
+ import type { JsonSettings } from "../JsonCodec";
5
5
  /**
6
6
  * @public
7
7
  */
@@ -55,3 +55,18 @@ export declare class ByteJsonShapeSerializer extends SerdeContextConfig implemen
55
55
  private writeMap;
56
56
  private writeTimestamp;
57
57
  }
58
+ /**
59
+ * A string adapter for the byte serializer, for backwards compatibility.
60
+ * @public
61
+ */
62
+ export declare class StringJsonShapeSerializer extends SerdeContextConfig implements ShapeSerializer<string> {
63
+ readonly settings: JsonSettings;
64
+ private byteSerializer;
65
+ constructor(settings: JsonSettings);
66
+ write(schema: Schema, value: unknown): void;
67
+ /**
68
+ * @internal
69
+ */
70
+ writeDiscriminatedDocument(schema: Schema, value: unknown): void;
71
+ flush(): string;
72
+ }
@@ -6,8 +6,8 @@ export { AwsJsonRpcProtocol } from "./json/AwsJsonRpcProtocol";
6
6
  export { AwsRestJsonProtocol } from "./json/AwsRestJsonProtocol";
7
7
  export { JsonCodec } from "./json/JsonCodec";
8
8
  export { JsonSettings } from "./json/JsonCodec";
9
- export { JsonShapeDeserializer } from "./json/JsonShapeDeserializer";
10
- export { JsonShapeSerializer } from "./json/JsonShapeSerializer";
9
+ export { JsonShapeDeserializer } from "./json/codec-v1/JsonShapeDeserializer";
10
+ export { JsonShapeSerializer } from "./json/codec-v1/JsonShapeSerializer";
11
11
  export { awsExpectUnion } from "./json/awsExpectUnion";
12
12
  export {
13
13
  parseJsonBody,
@@ -1,7 +1,7 @@
1
1
  import { Codec, CodecSettings } from "@smithy/types";
2
2
  import { SerdeContextConfig } from "../ConfigurableSerdeContext";
3
- import { JsonShapeDeserializer } from "./JsonShapeDeserializer";
4
- import { JsonShapeSerializer } from "./JsonShapeSerializer";
3
+ import { JsonShapeDeserializer } from "./codec-v1/JsonShapeDeserializer";
4
+ import { JsonShapeSerializer } from "./codec-v1/JsonShapeSerializer";
5
5
  export type JsonSettings = CodecSettings & {
6
6
  jsonName: boolean;
7
7
  };
@@ -1,6 +1,6 @@
1
1
  import { DocumentType, Schema, ShapeDeserializer } from "@smithy/types";
2
- import { SerdeContextConfig } from "../ConfigurableSerdeContext";
3
- import { JsonSettings } from "./JsonCodec";
2
+ import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
3
+ import { JsonSettings } from "../JsonCodec";
4
4
  export declare class JsonShapeDeserializer
5
5
  extends SerdeContextConfig
6
6
  implements ShapeDeserializer<string>
@@ -1,7 +1,7 @@
1
1
  import { NormalizedSchema } from "@smithy/core/schema";
2
2
  import { Schema, ShapeSerializer } from "@smithy/types";
3
- import { SerdeContextConfig } from "../ConfigurableSerdeContext";
4
- import { JsonSettings } from "./JsonCodec";
3
+ import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
4
+ import { JsonSettings } from "../JsonCodec";
5
5
  export declare class JsonShapeSerializer
6
6
  extends SerdeContextConfig
7
7
  implements ShapeSerializer<string>
@@ -26,3 +26,14 @@ export declare class ByteJsonShapeSerializer
26
26
  private writeMap;
27
27
  private writeTimestamp;
28
28
  }
29
+ export declare class StringJsonShapeSerializer
30
+ extends SerdeContextConfig
31
+ implements ShapeSerializer<string>
32
+ {
33
+ readonly settings: JsonSettings;
34
+ private byteSerializer;
35
+ constructor(settings: JsonSettings);
36
+ write(schema: Schema, value: unknown): void;
37
+ writeDiscriminatedDocument(schema: Schema, value: unknown): void;
38
+ flush(): string;
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/core",
3
- "version": "3.977.0",
3
+ "version": "3.977.2",
4
4
  "description": "Core functions & classes shared by multiple AWS SDK clients.",
5
5
  "homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages-internal/core",
6
6
  "license": "Apache-2.0",