@aws-amplify/api-rest 4.3.1-unstable.6ea70f9.0 → 4.4.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.
|
@@ -20,7 +20,13 @@ const resolveApiUrl = (amplify, apiName, path, queryParams) => {
|
|
|
20
20
|
const urlStr = amplify.getConfig()?.API?.REST?.[apiName]?.endpoint;
|
|
21
21
|
(0, errors_1.assertValidationError)(!!urlStr, errors_1.RestApiValidationErrorCode.InvalidApiName);
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
let url;
|
|
24
|
+
if (utils_1.AmplifyUrl.canParse(urlStr + path)) {
|
|
25
|
+
url = new utils_1.AmplifyUrl(urlStr + path);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
url = new utils_1.AmplifyUrl(urlStr + path, location?.origin);
|
|
29
|
+
}
|
|
24
30
|
if (queryParams) {
|
|
25
31
|
const mergedQueryParams = new utils_1.AmplifyUrlSearchParams(url.searchParams);
|
|
26
32
|
Object.entries(queryParams).forEach(([key, value]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveApiUrl.js","sources":["../../../src/utils/resolveApiUrl.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.resolveApiUrl = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst errors_1 = require(\"../errors\");\n/**\n * Resolve the REST API request URL by:\n * 1. Loading the REST API endpoint from the Amplify configuration with corresponding API name.\n * 2. Appending the path to the endpoint.\n * 3. Merge the query parameters from path and the queryParameter argument which is taken from the public REST API\n * options.\n * 4. Validating the resulting URL string.\n *\n * @internal\n */\nconst resolveApiUrl = (amplify, apiName, path, queryParams) => {\n const urlStr = amplify.getConfig()?.API?.REST?.[apiName]?.endpoint;\n (0, errors_1.assertValidationError)(!!urlStr, errors_1.RestApiValidationErrorCode.InvalidApiName);\n try {\n
|
|
1
|
+
{"version":3,"file":"resolveApiUrl.js","sources":["../../../src/utils/resolveApiUrl.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.resolveApiUrl = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst errors_1 = require(\"../errors\");\n/**\n * Resolve the REST API request URL by:\n * 1. Loading the REST API endpoint from the Amplify configuration with corresponding API name.\n * 2. Appending the path to the endpoint.\n * 3. Merge the query parameters from path and the queryParameter argument which is taken from the public REST API\n * options.\n * 4. Validating the resulting URL string.\n *\n * @internal\n */\nconst resolveApiUrl = (amplify, apiName, path, queryParams) => {\n const urlStr = amplify.getConfig()?.API?.REST?.[apiName]?.endpoint;\n (0, errors_1.assertValidationError)(!!urlStr, errors_1.RestApiValidationErrorCode.InvalidApiName);\n try {\n let url;\n if (utils_1.AmplifyUrl.canParse(urlStr + path)) {\n url = new utils_1.AmplifyUrl(urlStr + path);\n }\n else {\n url = new utils_1.AmplifyUrl(urlStr + path, location?.origin);\n }\n if (queryParams) {\n const mergedQueryParams = new utils_1.AmplifyUrlSearchParams(url.searchParams);\n Object.entries(queryParams).forEach(([key, value]) => {\n mergedQueryParams.set(key, value);\n });\n url.search = new utils_1.AmplifyUrlSearchParams(mergedQueryParams).toString();\n }\n return url;\n }\n catch (error) {\n throw new errors_1.RestApiError({\n name: errors_1.RestApiValidationErrorCode.InvalidApiName,\n ...errors_1.validationErrorMap[errors_1.RestApiValidationErrorCode.InvalidApiName],\n recoverySuggestion: `Please make sure the REST endpoint URL is a valid URL string. Got ${urlStr}`,\n });\n }\n};\nexports.resolveApiUrl = resolveApiUrl;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,K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BAAsB,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE;AACzF,QAAQ;AACR,QAAQ,OAAO,GAAG;AAClB,IAAI;AACJ,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQ,MAAM,IAAI,QAAQ,CAAC,YAAY,CAAC;AACxC,YAAY,IAAI,EAAE,QAAQ,CAAC,0BAA0B,CAAC,cAAc;AACpE,YAAY,GAAG,QAAQ,CAAC,kBAAkB,CAAC,QAAQ,CAAC,0BAA0B,CAAC,cAAc,CAAC;AAC9F,YAAY,kBAAkB,EAAE,CAAC,kEAAkE,EAAE,MAAM,CAAC,CAAC;AAC7G,SAAS,CAAC;AACV,IAAI;AACJ,CAAC;AACD,OAAO,CAAC,aAAa,GAAG,aAAa;;"}
|
|
@@ -19,7 +19,13 @@ const resolveApiUrl = (amplify, apiName, path, queryParams) => {
|
|
|
19
19
|
const urlStr = amplify.getConfig()?.API?.REST?.[apiName]?.endpoint;
|
|
20
20
|
assertValidationError(!!urlStr, RestApiValidationErrorCode.InvalidApiName);
|
|
21
21
|
try {
|
|
22
|
-
|
|
22
|
+
let url;
|
|
23
|
+
if (AmplifyUrl.canParse(urlStr + path)) {
|
|
24
|
+
url = new AmplifyUrl(urlStr + path);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
url = new AmplifyUrl(urlStr + path, location?.origin);
|
|
28
|
+
}
|
|
23
29
|
if (queryParams) {
|
|
24
30
|
const mergedQueryParams = new AmplifyUrlSearchParams(url.searchParams);
|
|
25
31
|
Object.entries(queryParams).forEach(([key, value]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveApiUrl.mjs","sources":["../../../src/utils/resolveApiUrl.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyUrl, AmplifyUrlSearchParams, } from '@aws-amplify/core/internals/utils';\nimport { RestApiError, RestApiValidationErrorCode, assertValidationError, validationErrorMap, } from '../errors';\n/**\n * Resolve the REST API request URL by:\n * 1. Loading the REST API endpoint from the Amplify configuration with corresponding API name.\n * 2. Appending the path to the endpoint.\n * 3. Merge the query parameters from path and the queryParameter argument which is taken from the public REST API\n * options.\n * 4. Validating the resulting URL string.\n *\n * @internal\n */\nexport const resolveApiUrl = (amplify, apiName, path, queryParams) => {\n const urlStr = amplify.getConfig()?.API?.REST?.[apiName]?.endpoint;\n assertValidationError(!!urlStr, RestApiValidationErrorCode.InvalidApiName);\n try {\n
|
|
1
|
+
{"version":3,"file":"resolveApiUrl.mjs","sources":["../../../src/utils/resolveApiUrl.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyUrl, AmplifyUrlSearchParams, } from '@aws-amplify/core/internals/utils';\nimport { RestApiError, RestApiValidationErrorCode, assertValidationError, validationErrorMap, } from '../errors';\n/**\n * Resolve the REST API request URL by:\n * 1. Loading the REST API endpoint from the Amplify configuration with corresponding API name.\n * 2. Appending the path to the endpoint.\n * 3. Merge the query parameters from path and the queryParameter argument which is taken from the public REST API\n * options.\n * 4. Validating the resulting URL string.\n *\n * @internal\n */\nexport const resolveApiUrl = (amplify, apiName, path, queryParams) => {\n const urlStr = amplify.getConfig()?.API?.REST?.[apiName]?.endpoint;\n assertValidationError(!!urlStr, RestApiValidationErrorCode.InvalidApiName);\n try {\n let url;\n if (AmplifyUrl.canParse(urlStr + path)) {\n url = new AmplifyUrl(urlStr + path);\n }\n else {\n url = new AmplifyUrl(urlStr + path, location?.origin);\n }\n if (queryParams) {\n const mergedQueryParams = new AmplifyUrlSearchParams(url.searchParams);\n Object.entries(queryParams).forEach(([key, value]) => {\n mergedQueryParams.set(key, value);\n });\n url.search = new AmplifyUrlSearchParams(mergedQueryParams).toString();\n }\n return url;\n }\n catch (error) {\n throw new RestApiError({\n name: RestApiValidationErrorCode.InvalidApiName,\n ...validationErrorMap[RestApiValidationErrorCode.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|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
2
|
+
"name": "@aws-amplify/api-rest",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "4.4.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.2",
|
|
91
|
+
"@aws-amplify/react-native": "1.1.10",
|
|
92
|
+
"@aws-sdk/types": "3.387.0"
|
|
93
|
+
},
|
|
94
|
+
"gitHead": "21ebe0a1e6f009a419864ed8550d20a3528d8944"
|
|
95
95
|
}
|
|
@@ -33,7 +33,13 @@ export const resolveApiUrl = (
|
|
|
33
33
|
const urlStr = amplify.getConfig()?.API?.REST?.[apiName]?.endpoint;
|
|
34
34
|
assertValidationError(!!urlStr, RestApiValidationErrorCode.InvalidApiName);
|
|
35
35
|
try {
|
|
36
|
-
|
|
36
|
+
let url: URL;
|
|
37
|
+
if (AmplifyUrl.canParse(urlStr + path)) {
|
|
38
|
+
url = new AmplifyUrl(urlStr + path);
|
|
39
|
+
} else {
|
|
40
|
+
url = new AmplifyUrl(urlStr + path, location?.origin);
|
|
41
|
+
}
|
|
42
|
+
|
|
37
43
|
if (queryParams) {
|
|
38
44
|
const mergedQueryParams = new AmplifyUrlSearchParams(url.searchParams);
|
|
39
45
|
Object.entries(queryParams).forEach(([key, value]) => {
|