@aws-sdk/core 3.433.0 → 3.441.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 (33) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist-cjs/client/emitWarningIfUnsupportedVersion.js +17 -0
  3. package/dist-cjs/client/index.js +4 -0
  4. package/dist-cjs/index.js +1 -0
  5. package/dist-cjs/protocols/coercing-serializers.js +59 -0
  6. package/dist-cjs/protocols/index.js +1 -0
  7. package/dist-es/client/emitWarningIfUnsupportedVersion.js +13 -0
  8. package/dist-es/client/index.js +1 -0
  9. package/dist-es/index.js +1 -0
  10. package/dist-es/protocols/coercing-serializers.js +53 -0
  11. package/dist-es/protocols/index.js +1 -0
  12. package/dist-types/client/emitWarningIfUnsupportedVersion.d.ts +9 -0
  13. package/dist-types/client/index.d.ts +1 -0
  14. package/dist-types/index.d.ts +1 -0
  15. package/dist-types/protocols/coercing-serializers.d.ts +18 -0
  16. package/dist-types/protocols/index.d.ts +1 -0
  17. package/dist-types/ts3.4/client/emitWarningIfUnsupportedVersion.d.ts +1 -0
  18. package/dist-types/ts3.4/client/index.d.ts +1 -0
  19. package/dist-types/ts3.4/index.d.ts +1 -0
  20. package/dist-types/ts3.4/protocols/coercing-serializers.d.ts +3 -0
  21. package/dist-types/ts3.4/protocols/index.d.ts +1 -0
  22. package/package.json +4 -2
  23. package/scripts/lint.js +24 -0
  24. package/src/client/emitWarningIfUnsupportedVersion.spec.ts +70 -0
  25. package/src/client/emitWarningIfUnsupportedVersion.ts +25 -0
  26. package/src/client/index.ts +1 -0
  27. package/src/index.ts +1 -0
  28. package/src/protocols/coercing-serializers.spec.ts +76 -0
  29. package/src/protocols/coercing-serializers.ts +72 -0
  30. package/src/protocols/index.ts +1 -0
  31. package/tsconfig.cjs.tsbuildinfo +1 -1
  32. package/tsconfig.es.tsbuildinfo +1 -1
  33. package/tsconfig.types.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.441.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.440.0...v3.441.0) (2023-11-01)
7
+
8
+ **Note:** Version bump only for package @aws-sdk/core
9
+
10
+
11
+
12
+
13
+
14
+ # [3.436.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.435.0...v3.436.0) (2023-10-25)
15
+
16
+ **Note:** Version bump only for package @aws-sdk/core
17
+
18
+
19
+
20
+
21
+
6
22
  # [3.433.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.432.0...v3.433.0) (2023-10-20)
7
23
 
8
24
 
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emitWarningIfUnsupportedVersion = void 0;
4
+ let warningEmitted = false;
5
+ const emitWarningIfUnsupportedVersion = (version) => {
6
+ if (version && !warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 16) {
7
+ warningEmitted = true;
8
+ process.emitWarning(`NodeDeprecationWarning: The AWS SDK for JavaScript (v3) will
9
+ no longer support Node.js 14.x on May 1, 2024.
10
+
11
+ To continue receiving updates to AWS services, bug fixes, and security
12
+ updates please upgrade to an active Node.js LTS version.
13
+
14
+ More information can be found at: https://a.co/dzr2AJd`);
15
+ }
16
+ };
17
+ exports.emitWarningIfUnsupportedVersion = emitWarningIfUnsupportedVersion;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./emitWarningIfUnsupportedVersion"), exports);
package/dist-cjs/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./client/index"), exports);
4
5
  tslib_1.__exportStar(require("./protocols/index"), exports);
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._toNum = exports._toBool = exports._toStr = void 0;
4
+ const _toStr = (val) => {
5
+ if (val == null) {
6
+ return val;
7
+ }
8
+ if (typeof val === "number" || typeof val === "bigint") {
9
+ const warning = new Error(`Received number ${val} where a string was expected.`);
10
+ warning.name = "Warning";
11
+ console.warn(warning);
12
+ return String(val);
13
+ }
14
+ if (typeof val === "boolean") {
15
+ const warning = new Error(`Received boolean ${val} where a string was expected.`);
16
+ warning.name = "Warning";
17
+ console.warn(warning);
18
+ return String(val);
19
+ }
20
+ return val;
21
+ };
22
+ exports._toStr = _toStr;
23
+ const _toBool = (val) => {
24
+ if (val == null) {
25
+ return val;
26
+ }
27
+ if (typeof val === "number") {
28
+ }
29
+ if (typeof val === "string") {
30
+ const lowercase = val.toLowerCase();
31
+ if (val !== "" && lowercase !== "false" && lowercase !== "true") {
32
+ const warning = new Error(`Received string "${val}" where a boolean was expected.`);
33
+ warning.name = "Warning";
34
+ console.warn(warning);
35
+ }
36
+ return val !== "" && lowercase !== "false";
37
+ }
38
+ return val;
39
+ };
40
+ exports._toBool = _toBool;
41
+ const _toNum = (val) => {
42
+ if (val == null) {
43
+ return val;
44
+ }
45
+ if (typeof val === "boolean") {
46
+ }
47
+ if (typeof val === "string") {
48
+ const num = Number(val);
49
+ if (num.toString() !== val) {
50
+ const warning = new Error(`Received string "${val}" where a number was expected.`);
51
+ warning.name = "Warning";
52
+ console.warn(warning);
53
+ return val;
54
+ }
55
+ return num;
56
+ }
57
+ return val;
58
+ };
59
+ exports._toNum = _toNum;
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./coercing-serializers"), exports);
4
5
  tslib_1.__exportStar(require("./json/awsExpectUnion"), exports);
@@ -0,0 +1,13 @@
1
+ let warningEmitted = false;
2
+ export const emitWarningIfUnsupportedVersion = (version) => {
3
+ if (version && !warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 16) {
4
+ warningEmitted = true;
5
+ process.emitWarning(`NodeDeprecationWarning: The AWS SDK for JavaScript (v3) will
6
+ no longer support Node.js 14.x on May 1, 2024.
7
+
8
+ To continue receiving updates to AWS services, bug fixes, and security
9
+ updates please upgrade to an active Node.js LTS version.
10
+
11
+ More information can be found at: https://a.co/dzr2AJd`);
12
+ }
13
+ };
@@ -0,0 +1 @@
1
+ export * from "./emitWarningIfUnsupportedVersion";
package/dist-es/index.js CHANGED
@@ -1 +1,2 @@
1
+ export * from "./client/index";
1
2
  export * from "./protocols/index";
@@ -0,0 +1,53 @@
1
+ export const _toStr = (val) => {
2
+ if (val == null) {
3
+ return val;
4
+ }
5
+ if (typeof val === "number" || typeof val === "bigint") {
6
+ const warning = new Error(`Received number ${val} where a string was expected.`);
7
+ warning.name = "Warning";
8
+ console.warn(warning);
9
+ return String(val);
10
+ }
11
+ if (typeof val === "boolean") {
12
+ const warning = new Error(`Received boolean ${val} where a string was expected.`);
13
+ warning.name = "Warning";
14
+ console.warn(warning);
15
+ return String(val);
16
+ }
17
+ return val;
18
+ };
19
+ export const _toBool = (val) => {
20
+ if (val == null) {
21
+ return val;
22
+ }
23
+ if (typeof val === "number") {
24
+ }
25
+ if (typeof val === "string") {
26
+ const lowercase = val.toLowerCase();
27
+ if (val !== "" && lowercase !== "false" && lowercase !== "true") {
28
+ const warning = new Error(`Received string "${val}" where a boolean was expected.`);
29
+ warning.name = "Warning";
30
+ console.warn(warning);
31
+ }
32
+ return val !== "" && lowercase !== "false";
33
+ }
34
+ return val;
35
+ };
36
+ export const _toNum = (val) => {
37
+ if (val == null) {
38
+ return val;
39
+ }
40
+ if (typeof val === "boolean") {
41
+ }
42
+ if (typeof val === "string") {
43
+ const num = Number(val);
44
+ if (num.toString() !== val) {
45
+ const warning = new Error(`Received string "${val}" where a number was expected.`);
46
+ warning.name = "Warning";
47
+ console.warn(warning);
48
+ return val;
49
+ }
50
+ return num;
51
+ }
52
+ return val;
53
+ };
@@ -1 +1,2 @@
1
+ export * from "./coercing-serializers";
1
2
  export * from "./json/awsExpectUnion";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @internal
3
+ *
4
+ * Emits warning if the provided Node.js version string is
5
+ * pending deprecation by AWS SDK JSv3.
6
+ *
7
+ * @param version - The Node.js version string.
8
+ */
9
+ export declare const emitWarningIfUnsupportedVersion: (version: string) => void;
@@ -0,0 +1 @@
1
+ export * from "./emitWarningIfUnsupportedVersion";
@@ -1 +1,2 @@
1
+ export * from "./client/index";
1
2
  export * from "./protocols/index";
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @internal
3
+ *
4
+ * Used for awsQueryCompatibility trait.
5
+ */
6
+ export declare const _toStr: (val: unknown) => string | undefined;
7
+ /**
8
+ * @internal
9
+ *
10
+ * Used for awsQueryCompatibility trait.
11
+ */
12
+ export declare const _toBool: (val: unknown) => boolean | undefined;
13
+ /**
14
+ * @internal
15
+ *
16
+ * Used for awsQueryCompatibility trait.
17
+ */
18
+ export declare const _toNum: (val: unknown) => number | undefined;
@@ -1 +1,2 @@
1
+ export * from "./coercing-serializers";
1
2
  export * from "./json/awsExpectUnion";
@@ -0,0 +1 @@
1
+ export declare const emitWarningIfUnsupportedVersion: (version: string) => void;
@@ -0,0 +1 @@
1
+ export * from "./emitWarningIfUnsupportedVersion";
@@ -1 +1,2 @@
1
+ export * from "./client/index";
1
2
  export * from "./protocols/index";
@@ -0,0 +1,3 @@
1
+ export declare const _toStr: (val: unknown) => string | undefined;
2
+ export declare const _toBool: (val: unknown) => boolean | undefined;
3
+ export declare const _toNum: (val: unknown) => number | undefined;
@@ -1 +1,2 @@
1
+ export * from "./coercing-serializers";
1
2
  export * from "./json/awsExpectUnion";
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@aws-sdk/core",
3
- "version": "3.433.0",
3
+ "version": "3.441.0",
4
4
  "description": "Core functions & classes shared by multiple AWS SDK clients",
5
5
  "scripts": {
6
6
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
7
- "build:cjs": "tsc -p tsconfig.cjs.json",
7
+ "build:cjs": "tsc -p tsconfig.cjs.json && yarn lint",
8
8
  "build:es": "tsc -p tsconfig.es.json",
9
9
  "build:include:deps": "lerna run --scope $npm_package_name --include-dependencies build",
10
10
  "build:types": "tsc -p tsconfig.types.json",
11
11
  "build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
12
+ "lint": "node ./scripts/lint.js",
12
13
  "clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
13
14
  "extract:docs": "api-extractor run --local",
14
15
  "test": "jest --passWithNoTests"
@@ -16,6 +17,7 @@
16
17
  "main": "./dist-cjs/index.js",
17
18
  "module": "./dist-es/index.js",
18
19
  "types": "./dist-types/index.d.ts",
20
+ "sideEffects": false,
19
21
  "author": {
20
22
  "name": "AWS SDK for JavaScript Team",
21
23
  "url": "https://aws.amazon.com/javascript/"
@@ -0,0 +1,24 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const assert = require("assert");
4
+
5
+ const root = path.join(__dirname, "..");
6
+
7
+ const pkgJson = require(path.join(root, "package.json"));
8
+ const srcFolders = fs.readdirSync(path.join(root, "src"));
9
+
10
+ assert(pkgJson.exports === undefined, "We cannot support package.json exports yet.");
11
+
12
+ /**
13
+ * We probably can't enable package.json exports until
14
+ * dropping support for Node.js 14.x and TypeScript 4.6.
15
+ */
16
+ process.exit(0);
17
+
18
+ for (const srcFolder of srcFolders) {
19
+ if (fs.lstatSync(path.join(root, "src", srcFolder)).isDirectory()) {
20
+ if (!pkgJson.exports["./" + srcFolder]) {
21
+ throw new Error(`${srcFolder} is missing exports statement in package.json`);
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,70 @@
1
+ describe("emitWarningIfUnsupportedVersion", () => {
2
+ let emitWarningIfUnsupportedVersion;
3
+ const emitWarning = process.emitWarning;
4
+ const supportedVersion = "16.0.0";
5
+
6
+ beforeEach(() => {
7
+ const module = require("./emitWarningIfUnsupportedVersion");
8
+ emitWarningIfUnsupportedVersion = module.emitWarningIfUnsupportedVersion;
9
+ });
10
+
11
+ afterEach(() => {
12
+ jest.clearAllMocks();
13
+ jest.resetModules();
14
+ process.emitWarning = emitWarning;
15
+ });
16
+
17
+ describe(`emits warning for Node.js <${supportedVersion}`, () => {
18
+ const getPreviousMajorVersion = (major: number) => (major === 0 ? 0 : major - 1);
19
+
20
+ const getPreviousMinorVersion = ([major, minor]: [number, number]) =>
21
+ minor === 0 ? [getPreviousMajorVersion(major), 9] : [major, minor - 1];
22
+
23
+ const getPreviousPatchVersion = ([major, minor, patch]: [number, number, number]) =>
24
+ patch === 0 ? [...getPreviousMinorVersion([major, minor]), 9] : [major, minor, patch - 1];
25
+
26
+ const [major, minor, patch] = supportedVersion.split(".").map(Number);
27
+ it.each(
28
+ [
29
+ getPreviousPatchVersion([major, minor, patch]),
30
+ [...getPreviousMinorVersion([major, minor]), 0],
31
+ [getPreviousMajorVersion(major), 0, 0],
32
+ ].map((arr) => `v${arr.join(".")}`)
33
+ )(`%s`, async (unsupportedVersion) => {
34
+ process.emitWarning = jest.fn();
35
+ emitWarningIfUnsupportedVersion(unsupportedVersion);
36
+
37
+ // Verify that the warning was emitted.
38
+ expect(process.emitWarning).toHaveBeenCalledTimes(1);
39
+ expect(process.emitWarning).toHaveBeenCalledWith(
40
+ `NodeDeprecationWarning: The AWS SDK for JavaScript (v3) will
41
+ no longer support Node.js 14.x on May 1, 2024.
42
+
43
+ To continue receiving updates to AWS services, bug fixes, and security
44
+ updates please upgrade to an active Node.js LTS version.
45
+
46
+ More information can be found at: https://a.co/dzr2AJd`
47
+ );
48
+
49
+ // Verify that the warning emits only once.
50
+ emitWarningIfUnsupportedVersion(unsupportedVersion);
51
+ expect(process.emitWarning).toHaveBeenCalledTimes(1);
52
+ });
53
+ });
54
+
55
+ describe(`emits no warning for Node.js >=${supportedVersion}`, () => {
56
+ const [major, minor, patch] = supportedVersion.split(".").map(Number);
57
+ it.each(
58
+ [
59
+ [major, minor, patch],
60
+ [major, minor, patch + 1],
61
+ [major, minor + 1, 0],
62
+ [major + 1, 0, 0],
63
+ ].map((arr) => `v${arr.join(".")}`)
64
+ )(`%s`, async (unsupportedVersion) => {
65
+ process.emitWarning = jest.fn();
66
+ emitWarningIfUnsupportedVersion(unsupportedVersion);
67
+ expect(process.emitWarning).not.toHaveBeenCalled();
68
+ });
69
+ });
70
+ });
@@ -0,0 +1,25 @@
1
+ // Stores whether the warning was already emitted.
2
+ let warningEmitted = false;
3
+
4
+ /**
5
+ * @internal
6
+ *
7
+ * Emits warning if the provided Node.js version string is
8
+ * pending deprecation by AWS SDK JSv3.
9
+ *
10
+ * @param version - The Node.js version string.
11
+ */
12
+ export const emitWarningIfUnsupportedVersion = (version: string) => {
13
+ if (version && !warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 16) {
14
+ warningEmitted = true;
15
+ process.emitWarning(
16
+ `NodeDeprecationWarning: The AWS SDK for JavaScript (v3) will
17
+ no longer support Node.js 14.x on May 1, 2024.
18
+
19
+ To continue receiving updates to AWS services, bug fixes, and security
20
+ updates please upgrade to an active Node.js LTS version.
21
+
22
+ More information can be found at: https://a.co/dzr2AJd`
23
+ );
24
+ }
25
+ };
@@ -0,0 +1 @@
1
+ export * from "./emitWarningIfUnsupportedVersion";
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
+ export * from "./client/index";
1
2
  export * from "./protocols/index";
@@ -0,0 +1,76 @@
1
+ import { _toBool, _toNum, _toStr } from "./coercing-serializers";
2
+
3
+ const consoleWarn = console.warn;
4
+
5
+ beforeAll(() => {
6
+ console.warn = () => {};
7
+ });
8
+
9
+ afterAll(() => {
10
+ console.warn = consoleWarn;
11
+ });
12
+
13
+ describe(_toBool.name, () => {
14
+ it("ignores nullish", () => {
15
+ expect(_toBool(null)).toBe(null);
16
+ expect(_toBool(undefined)).toBe(undefined);
17
+ });
18
+
19
+ it("converts strings", () => {
20
+ expect(_toBool("false")).toEqual(false);
21
+ expect(_toBool("true")).toEqual(true);
22
+
23
+ expect(_toBool("False")).toEqual(false);
24
+ expect(_toBool("True")).toEqual(true);
25
+
26
+ expect(_toBool("")).toEqual(false);
27
+ expect(_toBool("a")).toEqual(true); // warns
28
+ });
29
+
30
+ it("does not convert numbers", () => {
31
+ expect(_toBool(0)).toEqual(0);
32
+ expect(_toBool(1)).toEqual(1);
33
+ });
34
+ });
35
+
36
+ describe(_toStr.name, () => {
37
+ it("ignores nullish", () => {
38
+ expect(_toStr(null)).toBe(null);
39
+ expect(_toStr(undefined)).toBe(undefined);
40
+ });
41
+
42
+ it("converts numbers", () => {
43
+ expect(_toStr(0)).toEqual("0");
44
+ expect(_toStr(1)).toEqual("1");
45
+ });
46
+
47
+ it("converts booleans", () => {
48
+ expect(_toStr(false)).toEqual("false");
49
+ expect(_toStr(true)).toEqual("true");
50
+ });
51
+ });
52
+
53
+ describe(_toNum.name, () => {
54
+ it("ignores nullish", () => {
55
+ expect(_toNum(null)).toBe(null);
56
+ expect(_toNum(undefined)).toBe(undefined);
57
+ });
58
+
59
+ it("converts numeric strings", () => {
60
+ expect(_toNum("1234")).toEqual(1234);
61
+ expect(_toNum("1234.56")).toEqual(1234.56);
62
+ });
63
+
64
+ it("does not convert prefix-numeric strings", () => {
65
+ expect(_toNum("1234abc")).toEqual("1234abc");
66
+ expect(_toNum("1234.56abc")).toEqual("1234.56abc");
67
+ });
68
+
69
+ it("does not convert non-numeric strings", () => {
70
+ expect(_toNum("abcdef")).toEqual("abcdef");
71
+ });
72
+ it("does not convert bools", () => {
73
+ expect(_toNum(false)).toEqual(false);
74
+ expect(_toNum(true)).toEqual(true);
75
+ });
76
+ });
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @internal
3
+ *
4
+ * Used for awsQueryCompatibility trait.
5
+ */
6
+ export const _toStr = (val: unknown): string | undefined => {
7
+ if (val == null) {
8
+ return val as undefined;
9
+ }
10
+ if (typeof val === "number" || typeof val === "bigint") {
11
+ const warning = new Error(`Received number ${val} where a string was expected.`);
12
+ warning.name = "Warning";
13
+ console.warn(warning);
14
+ return String(val);
15
+ }
16
+ if (typeof val === "boolean") {
17
+ const warning = new Error(`Received boolean ${val} where a string was expected.`);
18
+ warning.name = "Warning";
19
+ console.warn(warning);
20
+ return String(val);
21
+ }
22
+ return val as string;
23
+ };
24
+
25
+ /**
26
+ * @internal
27
+ *
28
+ * Used for awsQueryCompatibility trait.
29
+ */
30
+ export const _toBool = (val: unknown): boolean | undefined => {
31
+ if (val == null) {
32
+ return val as undefined;
33
+ }
34
+ if (typeof val === "number") {
35
+ // transmit to service to be rejected.
36
+ }
37
+ if (typeof val === "string") {
38
+ const lowercase = val.toLowerCase();
39
+ if (val !== "" && lowercase !== "false" && lowercase !== "true") {
40
+ const warning = new Error(`Received string "${val}" where a boolean was expected.`);
41
+ warning.name = "Warning";
42
+ console.warn(warning);
43
+ }
44
+ return val !== "" && lowercase !== "false";
45
+ }
46
+ return val as boolean;
47
+ };
48
+
49
+ /**
50
+ * @internal
51
+ *
52
+ * Used for awsQueryCompatibility trait.
53
+ */
54
+ export const _toNum = (val: unknown): number | undefined => {
55
+ if (val == null) {
56
+ return val as undefined;
57
+ }
58
+ if (typeof val === "boolean") {
59
+ // transmit to service to be rejected.
60
+ }
61
+ if (typeof val === "string") {
62
+ const num = Number(val);
63
+ if (num.toString() !== val) {
64
+ const warning = new Error(`Received string "${val}" where a number was expected.`);
65
+ warning.name = "Warning";
66
+ console.warn(warning);
67
+ return val as unknown as undefined;
68
+ }
69
+ return num;
70
+ }
71
+ return val as number;
72
+ };
@@ -1 +1,2 @@
1
+ export * from "./coercing-serializers";
1
2
  export * from "./json/awsExpectUnion";