@aws-amplify/api-rest 4.2.0 → 4.2.1-unstable.2212704.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.
@@ -10,7 +10,14 @@ const resolveHeaders = (headers, body) => {
10
10
  normalizedHeaders[key.toLowerCase()] = headers[key];
11
11
  }
12
12
  if (body) {
13
- normalizedHeaders['content-type'] = 'application/json; charset=UTF-8';
13
+ const contentType = normalizedHeaders['content-type'];
14
+ const isJsonCompatible = contentType &&
15
+ (contentType.startsWith('application/json') ||
16
+ (contentType.startsWith('application/') &&
17
+ contentType.includes('+json')));
18
+ if (!isJsonCompatible) {
19
+ normalizedHeaders['content-type'] = 'application/json; charset=UTF-8';
20
+ }
14
21
  if (body instanceof FormData) {
15
22
  /**
16
23
  * If body is a FormData we should not allow setting content-type.
@@ -1 +1 @@
1
- {"version":3,"file":"resolveHeaders.js","sources":["../../../src/utils/resolveHeaders.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveHeaders = void 0;\nconst resolveHeaders = (headers, body) => {\n const normalizedHeaders = {};\n for (const key in headers) {\n normalizedHeaders[key.toLowerCase()] = headers[key];\n }\n if (body) {\n normalizedHeaders['content-type'] = 'application/json; charset=UTF-8';\n if (body instanceof FormData) {\n /**\n * If body is a FormData we should not allow setting content-type.\n * It's because runtime HTTP handlers(xhr, fetch, undici, node-fetch,\n * etc.) will modify the content-type value when setting multipart\n * boundary.\n */\n delete normalizedHeaders['content-type'];\n }\n }\n return normalizedHeaders;\n};\nexports.resolveHeaders = resolveHeaders;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,cAAc,GAAG,MAAM;AAC/B,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK;AAC1C,IAAI,MAAM,iBAAiB,GAAG,EAAE;AAChC,IAAI,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE;AAC/B,QAAQ,iBAAiB,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;AAC3D,IAAI;AACJ,IAAI,IAAI,IAAI,EAAE;AACd,QAAQ,iBAAiB,CAAC,cAAc,CAAC,GAAG,iCAAiC;AAC7E,QAAQ,IAAI,IAAI,YAAY,QAAQ,EAAE;AACtC;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO,iBAAiB,CAAC,cAAc,CAAC;AACpD,QAAQ;AACR,IAAI;AACJ,IAAI,OAAO,iBAAiB;AAC5B,CAAC;AACD,OAAO,CAAC,cAAc,GAAG,cAAc;;"}
1
+ {"version":3,"file":"resolveHeaders.js","sources":["../../../src/utils/resolveHeaders.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveHeaders = void 0;\nconst resolveHeaders = (headers, body) => {\n const normalizedHeaders = {};\n for (const key in headers) {\n normalizedHeaders[key.toLowerCase()] = headers[key];\n }\n if (body) {\n const contentType = normalizedHeaders['content-type'];\n const isJsonCompatible = contentType &&\n (contentType.startsWith('application/json') ||\n (contentType.startsWith('application/') &&\n contentType.includes('+json')));\n if (!isJsonCompatible) {\n normalizedHeaders['content-type'] = 'application/json; charset=UTF-8';\n }\n if (body instanceof FormData) {\n /**\n * If body is a FormData we should not allow setting content-type.\n * It's because runtime HTTP handlers(xhr, fetch, undici, node-fetch,\n * etc.) will modify the content-type value when setting multipart\n * boundary.\n */\n delete normalizedHeaders['content-type'];\n }\n }\n return normalizedHeaders;\n};\nexports.resolveHeaders = resolveHeaders;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,cAAc,GAAG,MAAM;AAC/B,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK;AAC1C,IAAI,MAAM,iBAAiB,GAAG,EAAE;AAChC,IAAI,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE;AAC/B,QAAQ,iBAAiB,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;AAC3D,IAAI;AACJ,IAAI,IAAI,IAAI,EAAE;AACd,QAAQ,MAAM,WAAW,GAAG,iBAAiB,CAAC,cAAc,CAAC;AAC7D,QAAQ,MAAM,gBAAgB,GAAG,WAAW;AAC5C,aAAa,WAAW,CAAC,UAAU,CAAC,kBAAkB,CAAC;AACvD,iBAAiB,WAAW,CAAC,UAAU,CAAC,cAAc,CAAC;AACvD,oBAAoB,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AACnD,QAAQ,IAAI,CAAC,gBAAgB,EAAE;AAC/B,YAAY,iBAAiB,CAAC,cAAc,CAAC,GAAG,iCAAiC;AACjF,QAAQ;AACR,QAAQ,IAAI,IAAI,YAAY,QAAQ,EAAE;AACtC;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO,iBAAiB,CAAC,cAAc,CAAC;AACpD,QAAQ;AACR,IAAI;AACJ,IAAI,OAAO,iBAAiB;AAC5B,CAAC;AACD,OAAO,CAAC,cAAc,GAAG,cAAc;;"}
@@ -6,7 +6,14 @@ const resolveHeaders = (headers, body) => {
6
6
  normalizedHeaders[key.toLowerCase()] = headers[key];
7
7
  }
8
8
  if (body) {
9
- normalizedHeaders['content-type'] = 'application/json; charset=UTF-8';
9
+ const contentType = normalizedHeaders['content-type'];
10
+ const isJsonCompatible = contentType &&
11
+ (contentType.startsWith('application/json') ||
12
+ (contentType.startsWith('application/') &&
13
+ contentType.includes('+json')));
14
+ if (!isJsonCompatible) {
15
+ normalizedHeaders['content-type'] = 'application/json; charset=UTF-8';
16
+ }
10
17
  if (body instanceof FormData) {
11
18
  /**
12
19
  * If body is a FormData we should not allow setting content-type.
@@ -1 +1 @@
1
- {"version":3,"file":"resolveHeaders.mjs","sources":["../../../src/utils/resolveHeaders.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport const resolveHeaders = (headers, body) => {\n const normalizedHeaders = {};\n for (const key in headers) {\n normalizedHeaders[key.toLowerCase()] = headers[key];\n }\n if (body) {\n normalizedHeaders['content-type'] = 'application/json; charset=UTF-8';\n if (body instanceof FormData) {\n /**\n * If body is a FormData we should not allow setting content-type.\n * It's because runtime HTTP handlers(xhr, fetch, undici, node-fetch,\n * etc.) will modify the content-type value when setting multipart\n * boundary.\n */\n delete normalizedHeaders['content-type'];\n }\n }\n return normalizedHeaders;\n};\n"],"names":[],"mappings":"AAAA;AACA;AACY,MAAC,cAAc,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK;AACjD,IAAI,MAAM,iBAAiB,GAAG,EAAE;AAChC,IAAI,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE;AAC/B,QAAQ,iBAAiB,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;AAC3D,IAAI;AACJ,IAAI,IAAI,IAAI,EAAE;AACd,QAAQ,iBAAiB,CAAC,cAAc,CAAC,GAAG,iCAAiC;AAC7E,QAAQ,IAAI,IAAI,YAAY,QAAQ,EAAE;AACtC;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO,iBAAiB,CAAC,cAAc,CAAC;AACpD,QAAQ;AACR,IAAI;AACJ,IAAI,OAAO,iBAAiB;AAC5B;;;;"}
1
+ {"version":3,"file":"resolveHeaders.mjs","sources":["../../../src/utils/resolveHeaders.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport const resolveHeaders = (headers, body) => {\n const normalizedHeaders = {};\n for (const key in headers) {\n normalizedHeaders[key.toLowerCase()] = headers[key];\n }\n if (body) {\n const contentType = normalizedHeaders['content-type'];\n const isJsonCompatible = contentType &&\n (contentType.startsWith('application/json') ||\n (contentType.startsWith('application/') &&\n contentType.includes('+json')));\n if (!isJsonCompatible) {\n normalizedHeaders['content-type'] = 'application/json; charset=UTF-8';\n }\n if (body instanceof FormData) {\n /**\n * If body is a FormData we should not allow setting content-type.\n * It's because runtime HTTP handlers(xhr, fetch, undici, node-fetch,\n * etc.) will modify the content-type value when setting multipart\n * boundary.\n */\n delete normalizedHeaders['content-type'];\n }\n }\n return normalizedHeaders;\n};\n"],"names":[],"mappings":"AAAA;AACA;AACY,MAAC,cAAc,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK;AACjD,IAAI,MAAM,iBAAiB,GAAG,EAAE;AAChC,IAAI,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE;AAC/B,QAAQ,iBAAiB,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;AAC3D,IAAI;AACJ,IAAI,IAAI,IAAI,EAAE;AACd,QAAQ,MAAM,WAAW,GAAG,iBAAiB,CAAC,cAAc,CAAC;AAC7D,QAAQ,MAAM,gBAAgB,GAAG,WAAW;AAC5C,aAAa,WAAW,CAAC,UAAU,CAAC,kBAAkB,CAAC;AACvD,iBAAiB,WAAW,CAAC,UAAU,CAAC,cAAc,CAAC;AACvD,oBAAoB,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AACnD,QAAQ,IAAI,CAAC,gBAAgB,EAAE;AAC/B,YAAY,iBAAiB,CAAC,cAAc,CAAC,GAAG,iCAAiC;AACjF,QAAQ;AACR,QAAQ,IAAI,IAAI,YAAY,QAAQ,EAAE;AACtC;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO,iBAAiB,CAAC,cAAc,CAAC;AACpD,QAAQ;AACR,IAAI;AACJ,IAAI,OAAO,iBAAiB;AAC5B;;;;"}
package/package.json CHANGED
@@ -1,95 +1,95 @@
1
1
  {
2
- "name": "@aws-amplify/api-rest",
3
- "private": false,
4
- "version": "4.2.0",
5
- "description": "Api-rest category of aws-amplify",
6
- "main": "./dist/cjs/index.js",
7
- "module": "./dist/esm/index.mjs",
8
- "typings": "./dist/esm/index.d.ts",
9
- "react-native": "./dist/cjs/index.js",
10
- "publishConfig": {
11
- "access": "public"
12
- },
13
- "scripts": {
14
- "test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
15
- "test:watch": "jest -w 1 --watch",
16
- "build-with-test": "npm test && npm build",
17
- "build:umd": "webpack && webpack --config ./webpack.config.dev.js",
18
- "build:esm-cjs": "rollup --forceExit -c rollup.config.mjs",
19
- "build:watch": "npm run build:esm-cjs -- --watch",
20
- "build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
21
- "clean": "npm run clean:size && rimraf dist lib lib-esm",
22
- "clean:size": "rimraf dual-publish-tmp tmp*",
23
- "format": "echo \"Not implemented\"",
24
- "lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
25
- "lint:fix": "eslint '**/*.{ts,tsx}' --fix",
26
- "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 70.0"
27
- },
28
- "exports": {
29
- ".": {
30
- "react-native": "./dist/cjs/index.js",
31
- "types": "./dist/esm/index.d.ts",
32
- "import": "./dist/esm/index.mjs",
33
- "require": "./dist/cjs/index.js"
34
- },
35
- "./server": {
36
- "types": "./dist/esm/server.d.ts",
37
- "import": "./dist/esm/server.mjs",
38
- "require": "./dist/cjs/server.js"
39
- },
40
- "./internals": {
41
- "react-native": "./dist/cjs/internals/index.js",
42
- "types": "./dist/esm/internals/index.d.ts",
43
- "import": "./dist/esm/internals/index.mjs",
44
- "require": "./dist/cjs/internals/index.js"
45
- },
46
- "./internals/server": {
47
- "types": "./dist/esm/internals/server.d.ts",
48
- "import": "./dist/esm/internals/server.mjs",
49
- "require": "./dist/cjs/internals/server.js"
50
- },
51
- "./package.json": "./package.json"
52
- },
53
- "typesVersions": {
54
- ">=4.2": {
55
- "server": [
56
- "./dist/esm/server.d.ts"
57
- ],
58
- "internals": [
59
- "./dist/esm/internals/index.d.ts"
60
- ],
61
- "internals/server": [
62
- "./dist/esm/internals/server.d.ts"
63
- ]
64
- }
65
- },
66
- "repository": {
67
- "type": "git",
68
- "url": "https://github.com/aws-amplify/amplify-js.git"
69
- },
70
- "author": "Amazon Web Services",
71
- "license": "Apache-2.0",
72
- "bugs": {
73
- "url": "https://github.com/aws/aws-amplify/issues"
74
- },
75
- "homepage": "https://aws-amplify.github.io/",
76
- "files": [
77
- "dist/cjs",
78
- "dist/esm",
79
- "src",
80
- "internals",
81
- "server"
82
- ],
83
- "dependencies": {
84
- "tslib": "^2.5.0"
85
- },
86
- "peerDependencies": {
87
- "@aws-amplify/core": "^6.1.0"
88
- },
89
- "devDependencies": {
90
- "@aws-amplify/core": "6.13.0",
91
- "@aws-amplify/react-native": "1.1.10",
92
- "@aws-sdk/types": "3.387.0"
93
- },
94
- "gitHead": "4c55a0bc68f5ea90c93e50c652964c74393e847a"
2
+ "name": "@aws-amplify/api-rest",
3
+ "private": false,
4
+ "version": "4.2.1-unstable.2212704.0+2212704",
5
+ "description": "Api-rest category of aws-amplify",
6
+ "main": "./dist/cjs/index.js",
7
+ "module": "./dist/esm/index.mjs",
8
+ "typings": "./dist/esm/index.d.ts",
9
+ "react-native": "./dist/cjs/index.js",
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "scripts": {
14
+ "test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
15
+ "test:watch": "jest -w 1 --watch",
16
+ "build-with-test": "npm test && npm build",
17
+ "build:umd": "webpack && webpack --config ./webpack.config.dev.js",
18
+ "build:esm-cjs": "rollup --forceExit -c rollup.config.mjs",
19
+ "build:watch": "npm run build:esm-cjs -- --watch",
20
+ "build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
21
+ "clean": "npm run clean:size && rimraf dist lib lib-esm",
22
+ "clean:size": "rimraf dual-publish-tmp tmp*",
23
+ "format": "echo \"Not implemented\"",
24
+ "lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
25
+ "lint:fix": "eslint '**/*.{ts,tsx}' --fix",
26
+ "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 70.0"
27
+ },
28
+ "exports": {
29
+ ".": {
30
+ "react-native": "./dist/cjs/index.js",
31
+ "types": "./dist/esm/index.d.ts",
32
+ "import": "./dist/esm/index.mjs",
33
+ "require": "./dist/cjs/index.js"
34
+ },
35
+ "./server": {
36
+ "types": "./dist/esm/server.d.ts",
37
+ "import": "./dist/esm/server.mjs",
38
+ "require": "./dist/cjs/server.js"
39
+ },
40
+ "./internals": {
41
+ "react-native": "./dist/cjs/internals/index.js",
42
+ "types": "./dist/esm/internals/index.d.ts",
43
+ "import": "./dist/esm/internals/index.mjs",
44
+ "require": "./dist/cjs/internals/index.js"
45
+ },
46
+ "./internals/server": {
47
+ "types": "./dist/esm/internals/server.d.ts",
48
+ "import": "./dist/esm/internals/server.mjs",
49
+ "require": "./dist/cjs/internals/server.js"
50
+ },
51
+ "./package.json": "./package.json"
52
+ },
53
+ "typesVersions": {
54
+ ">=4.2": {
55
+ "server": [
56
+ "./dist/esm/server.d.ts"
57
+ ],
58
+ "internals": [
59
+ "./dist/esm/internals/index.d.ts"
60
+ ],
61
+ "internals/server": [
62
+ "./dist/esm/internals/server.d.ts"
63
+ ]
64
+ }
65
+ },
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "https://github.com/aws-amplify/amplify-js.git"
69
+ },
70
+ "author": "Amazon Web Services",
71
+ "license": "Apache-2.0",
72
+ "bugs": {
73
+ "url": "https://github.com/aws/aws-amplify/issues"
74
+ },
75
+ "homepage": "https://aws-amplify.github.io/",
76
+ "files": [
77
+ "dist/cjs",
78
+ "dist/esm",
79
+ "src",
80
+ "internals",
81
+ "server"
82
+ ],
83
+ "dependencies": {
84
+ "tslib": "^2.5.0"
85
+ },
86
+ "peerDependencies": {
87
+ "@aws-amplify/core": "6.13.1-unstable.2212704.0+2212704"
88
+ },
89
+ "devDependencies": {
90
+ "@aws-amplify/core": "6.13.1-unstable.2212704.0+2212704",
91
+ "@aws-amplify/react-native": "1.1.11-unstable.2212704.0+2212704",
92
+ "@aws-sdk/types": "3.387.0"
93
+ },
94
+ "gitHead": "2212704a2a35b40e60984a0a79770a4b59aae52d"
95
95
  }
@@ -10,7 +10,17 @@ export const resolveHeaders = (
10
10
  normalizedHeaders[key.toLowerCase()] = headers[key];
11
11
  }
12
12
  if (body) {
13
- normalizedHeaders['content-type'] = 'application/json; charset=UTF-8';
13
+ const contentType = normalizedHeaders['content-type'];
14
+ const isJsonCompatible =
15
+ contentType &&
16
+ (contentType.startsWith('application/json') ||
17
+ (contentType.startsWith('application/') &&
18
+ contentType.includes('+json')));
19
+
20
+ if (!isJsonCompatible) {
21
+ normalizedHeaders['content-type'] = 'application/json; charset=UTF-8';
22
+ }
23
+
14
24
  if (body instanceof FormData) {
15
25
  /**
16
26
  * If body is a FormData we should not allow setting content-type.