@aws-amplify/api-rest 4.0.76-unstable.b188564.0 → 4.1.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.
@@ -57,6 +57,9 @@ const post = (amplify, { url, options, abortController }) => {
57
57
  method: 'POST',
58
58
  ...options,
59
59
  abortSignal: controller.signal,
60
+ retryStrategy: {
61
+ strategy: 'jittered-exponential-backoff',
62
+ },
60
63
  }, isIamAuthApplicable_1.isIamAuthApplicableForGraphQL, options?.signingServiceInfo);
61
64
  return response;
62
65
  }, controller);
@@ -1 +1 @@
1
- {"version":3,"file":"internalPost.js","sources":["../../../../src/apis/common/internalPost.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.updateRequestToBeCancellable = exports.cancel = exports.post = void 0;\nconst utils_1 = require(\"../../utils\");\nconst isIamAuthApplicable_1 = require(\"../../utils/isIamAuthApplicable\");\nconst transferHandler_1 = require(\"./transferHandler\");\n/**\n * This weak map provides functionality to cancel a request given the promise containing the `post` request.\n *\n * 1. For every GraphQL POST request, an abort controller is created and supplied to the request.\n * 2. The promise fulfilled by GraphGL POST request is then mapped to that abort controller.\n * 3. The promise is returned to the external caller.\n * 4. The caller can either wait for the promise to fulfill or call `cancel(promise)` to cancel the request.\n * 5. If `cancel(promise)` is called, then the corresponding abort controller is retrieved from the map below.\n * 6. GraphQL POST request will be rejected with the error message provided during cancel.\n * 7. Caller can check if the error is because of cancelling by calling `isCancelError(error)`.\n */\nconst cancelTokenMap = new WeakMap();\n/**\n * @internal\n *\n * REST POST handler to send GraphQL request to given endpoint. By default, it will use IAM to authorize\n * the request. In some auth modes, the IAM auth has to be disabled. Here's how to set up the request auth correctly:\n * * If auth mode is 'iam', you MUST NOT set 'authorization' header and 'x-api-key' header, since it would disable IAM\n * auth. You MUST also set 'input.options.signingServiceInfo' option.\n * * The including 'input.options.signingServiceInfo.service' and 'input.options.signingServiceInfo.region' are\n * optional. If omitted, the signing service and region will be inferred from url.\n * * If auth mode is 'none', you MUST NOT set 'options.signingServiceInfo' option.\n * * If auth mode is 'apiKey', you MUST set 'x-api-key' custom header.\n * * If auth mode is 'oidc' or 'lambda' or 'userPool', you MUST set 'authorization' header.\n *\n * To make the internal post cancellable, you must also call `updateRequestToBeCancellable()` with the promise from\n * internal post call and the abort controller supplied to the internal post call.\n *\n * @param amplify the AmplifyClassV6 instance - it may be the singleton used on Web, or an instance created within\n * a context created by `runWithAmplifyServerContext`\n * @param postInput an object of {@link InternalPostInput}\n * @param postInput.url The URL that the POST request sends to\n * @param postInput.options Options of the POST request\n * @param postInput.abortController The abort controller used to cancel the POST request\n * @returns a {@link RestApiResponse}\n *\n * @throws an {@link AmplifyError} with `Network Error` as the `message` when the external resource is unreachable due to one\n * of the following reasons:\n * 1. no network connection\n * 2. CORS error\n * @throws a {@link CanceledError} when the ongoing POST request get cancelled\n */\nconst post = (amplify, { url, options, abortController }) => {\n const controller = abortController ?? new AbortController();\n const responsePromise = (0, utils_1.createCancellableOperation)(async () => {\n const response = (0, transferHandler_1.transferHandler)(amplify, {\n url,\n method: 'POST',\n ...options,\n abortSignal: controller.signal,\n }, isIamAuthApplicable_1.isIamAuthApplicableForGraphQL, options?.signingServiceInfo);\n return response;\n }, controller);\n const responseWithCleanUp = responsePromise.finally(() => {\n cancelTokenMap.delete(responseWithCleanUp);\n });\n return responseWithCleanUp;\n};\nexports.post = post;\n/**\n * Cancels a request given the promise returned by `post`.\n * If the request is already completed, this function does nothing.\n * It MUST be used after `updateRequestToBeCancellable` is called.\n */\nconst cancel = (promise, message) => {\n const controller = cancelTokenMap.get(promise);\n if (controller) {\n controller.abort(message);\n if (message && controller.signal.reason !== message) {\n // In runtimes where `AbortSignal.reason` is not supported, we track the reason ourselves.\n // @ts-expect-error reason is read-only property.\n controller.signal.reason = message;\n }\n return true;\n }\n return false;\n};\nexports.cancel = cancel;\n/**\n * MUST be used to make a promise including internal `post` API call cancellable.\n */\nconst updateRequestToBeCancellable = (promise, controller) => {\n cancelTokenMap.set(promise, controller);\n};\nexports.updateRequestToBeCancellable = updateRequestToBeCancellable;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,4BAA4B,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM;AAC7E,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;AACtC,MAAM,qBAAqB,GAAG,OAAO,CAAC,iCAAiC,CAAC;AACxE,MAAM,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,cAAc,GAAG,IAAI,OAAO,EAAE;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK;AAC7D,IAAI,MAAM,UAAU,GAAG,eAAe,IAAI,IAAI,eAAe,EAAE;AAC/D,IAAI,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC,0BAA0B,EAAE,YAAY;AAChF,QAAQ,MAAM,QAAQ,GAAG,IAAI,iBAAiB,CAAC,eAAe,EAAE,OAAO,EAAE;AACzE,YAAY,GAAG;AACf,YAAY,MAAM,EAAE,MAAM;AAC1B,YAAY,GAAG,OAAO;AACtB,YAAY,WAAW,EAAE,UAAU,CAAC,MAAM;AAC1C,SAAS,EAAE,qBAAqB,CAAC,6BAA6B,EAAE,OAAO,EAAE,kBAAkB,CAAC;AAC5F,QAAQ,OAAO,QAAQ;AACvB,KAAK,EAAE,UAAU,CAAC;AAClB,IAAI,MAAM,mBAAmB,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM;AAC9D,QAAQ,cAAc,CAAC,MAAM,CAAC,mBAAmB,CAAC;AAClD,KAAK,CAAC;AACN,IAAI,OAAO,mBAAmB;AAC9B,CAAC;AACD,OAAO,CAAC,IAAI,GAAG,IAAI;AACnB;AACA;AACA;AACA;AACA;AACA,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK;AACrC,IAAI,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC;AAClD,IAAI,IAAI,UAAU,EAAE;AACpB,QAAQ,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC;AACjC,QAAQ,IAAI,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE;AAC7D;AACA;AACA,YAAY,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO;AAC9C;AACA,QAAQ,OAAO,IAAI;AACnB;AACA,IAAI,OAAO,KAAK;AAChB,CAAC;AACD,OAAO,CAAC,MAAM,GAAG,MAAM;AACvB;AACA;AACA;AACA,MAAM,4BAA4B,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK;AAC9D,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC;AAC3C,CAAC;AACD,OAAO,CAAC,4BAA4B,GAAG,4BAA4B;;"}
1
+ {"version":3,"file":"internalPost.js","sources":["../../../../src/apis/common/internalPost.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.updateRequestToBeCancellable = exports.cancel = exports.post = void 0;\nconst utils_1 = require(\"../../utils\");\nconst isIamAuthApplicable_1 = require(\"../../utils/isIamAuthApplicable\");\nconst transferHandler_1 = require(\"./transferHandler\");\n/**\n * This weak map provides functionality to cancel a request given the promise containing the `post` request.\n *\n * 1. For every GraphQL POST request, an abort controller is created and supplied to the request.\n * 2. The promise fulfilled by GraphGL POST request is then mapped to that abort controller.\n * 3. The promise is returned to the external caller.\n * 4. The caller can either wait for the promise to fulfill or call `cancel(promise)` to cancel the request.\n * 5. If `cancel(promise)` is called, then the corresponding abort controller is retrieved from the map below.\n * 6. GraphQL POST request will be rejected with the error message provided during cancel.\n * 7. Caller can check if the error is because of cancelling by calling `isCancelError(error)`.\n */\nconst cancelTokenMap = new WeakMap();\n/**\n * @internal\n *\n * REST POST handler to send GraphQL request to given endpoint. By default, it will use IAM to authorize\n * the request. In some auth modes, the IAM auth has to be disabled. Here's how to set up the request auth correctly:\n * * If auth mode is 'iam', you MUST NOT set 'authorization' header and 'x-api-key' header, since it would disable IAM\n * auth. You MUST also set 'input.options.signingServiceInfo' option.\n * * The including 'input.options.signingServiceInfo.service' and 'input.options.signingServiceInfo.region' are\n * optional. If omitted, the signing service and region will be inferred from url.\n * * If auth mode is 'none', you MUST NOT set 'options.signingServiceInfo' option.\n * * If auth mode is 'apiKey', you MUST set 'x-api-key' custom header.\n * * If auth mode is 'oidc' or 'lambda' or 'userPool', you MUST set 'authorization' header.\n *\n * To make the internal post cancellable, you must also call `updateRequestToBeCancellable()` with the promise from\n * internal post call and the abort controller supplied to the internal post call.\n *\n * @param amplify the AmplifyClassV6 instance - it may be the singleton used on Web, or an instance created within\n * a context created by `runWithAmplifyServerContext`\n * @param postInput an object of {@link InternalPostInput}\n * @param postInput.url The URL that the POST request sends to\n * @param postInput.options Options of the POST request\n * @param postInput.abortController The abort controller used to cancel the POST request\n * @returns a {@link RestApiResponse}\n *\n * @throws an {@link AmplifyError} with `Network Error` as the `message` when the external resource is unreachable due to one\n * of the following reasons:\n * 1. no network connection\n * 2. CORS error\n * @throws a {@link CanceledError} when the ongoing POST request get cancelled\n */\nconst post = (amplify, { url, options, abortController }) => {\n const controller = abortController ?? new AbortController();\n const responsePromise = (0, utils_1.createCancellableOperation)(async () => {\n const response = (0, transferHandler_1.transferHandler)(amplify, {\n url,\n method: 'POST',\n ...options,\n abortSignal: controller.signal,\n retryStrategy: {\n strategy: 'jittered-exponential-backoff',\n },\n }, isIamAuthApplicable_1.isIamAuthApplicableForGraphQL, options?.signingServiceInfo);\n return response;\n }, controller);\n const responseWithCleanUp = responsePromise.finally(() => {\n cancelTokenMap.delete(responseWithCleanUp);\n });\n return responseWithCleanUp;\n};\nexports.post = post;\n/**\n * Cancels a request given the promise returned by `post`.\n * If the request is already completed, this function does nothing.\n * It MUST be used after `updateRequestToBeCancellable` is called.\n */\nconst cancel = (promise, message) => {\n const controller = cancelTokenMap.get(promise);\n if (controller) {\n controller.abort(message);\n if (message && controller.signal.reason !== message) {\n // In runtimes where `AbortSignal.reason` is not supported, we track the reason ourselves.\n // @ts-expect-error reason is read-only property.\n controller.signal.reason = message;\n }\n return true;\n }\n return false;\n};\nexports.cancel = cancel;\n/**\n * MUST be used to make a promise including internal `post` API call cancellable.\n */\nconst updateRequestToBeCancellable = (promise, controller) => {\n cancelTokenMap.set(promise, controller);\n};\nexports.updateRequestToBeCancellable = updateRequestToBeCancellable;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,4BAA4B,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM;AAC7E,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;AACtC,MAAM,qBAAqB,GAAG,OAAO,CAAC,iCAAiC,CAAC;AACxE,MAAM,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,cAAc,GAAG,IAAI,OAAO,EAAE;AACpC;AACA;AACA;AACA;A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KAAK,OAAO,EAAE;AAC7D;AACA;AACA,YAAY,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO;AAC9C;AACA,QAAQ,OAAO,IAAI;AACnB;AACA,IAAI,OAAO,KAAK;AAChB,CAAC;AACD,OAAO,CAAC,MAAM,GAAG,MAAM;AACvB;AACA;AACA;AACA,MAAM,4BAA4B,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK;AAC9D,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC;AAC3C,CAAC;AACD,OAAO,CAAC,4BAA4B,GAAG,4BAA4B;;"}
@@ -8,7 +8,7 @@ const utils_1 = require("../../utils");
8
8
  const isIamAuthApplicable_1 = require("../../utils/isIamAuthApplicable");
9
9
  const transferHandler_1 = require("./transferHandler");
10
10
  const publicHandler = (amplify, options, method) => (0, utils_1.createCancellableOperation)(async (abortSignal) => {
11
- const { apiName, options: apiOptions = {}, path: apiPath } = options;
11
+ const { apiName, options: apiOptions = {}, path: apiPath, retryStrategy, } = options;
12
12
  const url = (0, utils_1.resolveApiUrl)(amplify, apiName, apiPath, apiOptions?.queryParams);
13
13
  const libraryConfigHeaders = await amplify.libraryOptions?.API?.REST?.headers?.({
14
14
  apiName,
@@ -30,6 +30,7 @@ const publicHandler = (amplify, options, method) => (0, utils_1.createCancellabl
30
30
  method,
31
31
  headers,
32
32
  abortSignal,
33
+ retryStrategy,
33
34
  }, isIamAuthApplicable_1.isIamAuthApplicableForRest, signingServiceInfo);
34
35
  });
35
36
  const get = (amplify, input) => publicHandler(amplify, input, 'GET');
@@ -1 +1 @@
1
- {"version":3,"file":"publicApis.js","sources":["../../../../src/apis/common/publicApis.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.patch = exports.head = exports.del = exports.put = exports.post = exports.get = void 0;\nconst utils_1 = require(\"../../utils\");\nconst isIamAuthApplicable_1 = require(\"../../utils/isIamAuthApplicable\");\nconst transferHandler_1 = require(\"./transferHandler\");\nconst publicHandler = (amplify, options, method) => (0, utils_1.createCancellableOperation)(async (abortSignal) => {\n const { apiName, options: apiOptions = {}, path: apiPath } = options;\n const url = (0, utils_1.resolveApiUrl)(amplify, apiName, apiPath, apiOptions?.queryParams);\n const libraryConfigHeaders = await amplify.libraryOptions?.API?.REST?.headers?.({\n apiName,\n });\n const { headers: invocationHeaders = {} } = apiOptions;\n const headers = {\n // custom headers from invocation options should precede library options\n ...libraryConfigHeaders,\n ...invocationHeaders,\n };\n const signingServiceInfo = (0, utils_1.parseSigningInfo)(url, {\n amplify,\n apiName,\n });\n utils_1.logger.debug(method, url, headers, `IAM signing options: ${JSON.stringify(signingServiceInfo)}`);\n return (0, transferHandler_1.transferHandler)(amplify, {\n ...apiOptions,\n url,\n method,\n headers,\n abortSignal,\n }, isIamAuthApplicable_1.isIamAuthApplicableForRest, signingServiceInfo);\n});\nconst get = (amplify, input) => publicHandler(amplify, input, 'GET');\nexports.get = get;\nconst post = (amplify, input) => publicHandler(amplify, input, 'POST');\nexports.post = post;\nconst put = (amplify, input) => publicHandler(amplify, input, 'PUT');\nexports.put = put;\nconst del = (amplify, input) => publicHandler(amplify, input, 'DELETE');\nexports.del = del;\nconst head = (amplify, input) => publicHandler(amplify, input, 'HEAD');\nexports.head = head;\nconst patch = (amplify, input) => publicHandler(amplify, input, 'PATCH');\nexports.patch = patch;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,GAAG,MAAM;AAC9F,MAAM,OAAO,GAAG,OAAO,CAAC,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AACnB,KAAK,EAAE,qBAAqB,CAAC,0BAA0B,EAAE,kBAAkB,CAAC;AAC5E,CAAC,CAAC;AACF,MAAM,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC;AACpE,OAAO,CAAC,GAAG,GAAG,GAAG;AACjB,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC;AACtE,OAAO,CAAC,IAAI,GAAG,IAAI;AACnB,MAAM,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC;AACpE,OAAO,CAAC,GAAG,GAAG,GAAG;AACjB,MAAM,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC;AACvE,OAAO,CAAC,GAAG,GAAG,GAAG;AACjB,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC;AACtE,OAAO,CAAC,IAAI,GAAG,IAAI;AACnB,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC;AACxE,OAAO,CAAC,KAAK,GAAG,KAAK;;"}
1
+ {"version":3,"file":"publicApis.js","sources":["../../../../src/apis/common/publicApis.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.patch = exports.head = exports.del = exports.put = exports.post = exports.get = void 0;\nconst utils_1 = require(\"../../utils\");\nconst isIamAuthApplicable_1 = require(\"../../utils/isIamAuthApplicable\");\nconst transferHandler_1 = require(\"./transferHandler\");\nconst publicHandler = (amplify, options, method) => (0, utils_1.createCancellableOperation)(async (abortSignal) => {\n const { apiName, options: apiOptions = {}, path: apiPath, retryStrategy, } = options;\n const url = (0, utils_1.resolveApiUrl)(amplify, apiName, apiPath, apiOptions?.queryParams);\n const libraryConfigHeaders = await amplify.libraryOptions?.API?.REST?.headers?.({\n apiName,\n });\n const { headers: invocationHeaders = {} } = apiOptions;\n const headers = {\n // custom headers from invocation options should precede library options\n ...libraryConfigHeaders,\n ...invocationHeaders,\n };\n const signingServiceInfo = (0, utils_1.parseSigningInfo)(url, {\n amplify,\n apiName,\n });\n utils_1.logger.debug(method, url, headers, `IAM signing options: ${JSON.stringify(signingServiceInfo)}`);\n return (0, transferHandler_1.transferHandler)(amplify, {\n ...apiOptions,\n url,\n method,\n headers,\n abortSignal,\n retryStrategy,\n }, isIamAuthApplicable_1.isIamAuthApplicableForRest, signingServiceInfo);\n});\nconst get = (amplify, input) => publicHandler(amplify, input, 'GET');\nexports.get = get;\nconst post = (amplify, input) => publicHandler(amplify, input, 'POST');\nexports.post = post;\nconst put = (amplify, input) => publicHandler(amplify, input, 'PUT');\nexports.put = put;\nconst del = (amplify, input) => publicHandler(amplify, input, 'DELETE');\nexports.del = del;\nconst head = (amplify, input) => publicHandler(amplify, input, 'HEAD');\nexports.head = head;\nconst patch = (amplify, input) => publicHandler(amplify, input, 'PATCH');\nexports.patch = patch;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,GAAG,MAAM;AAC9F,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;AACtC,MAAM,qBAAqB,GAAG,OAAO,CAAC,iCA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qB,CAAC,0BAA0B,EAAE,kBAAkB,CAAC;AAC5E,CAAC,CAAC;AACF,MAAM,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC;AACpE,OAAO,CAAC,GAAG,GAAG,GAAG;AACjB,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC;AACtE,OAAO,CAAC,IAAI,GAAG,IAAI;AACnB,MAAM,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC;AACpE,OAAO,CAAC,GAAG,GAAG,GAAG;AACjB,MAAM,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC;AACvE,OAAO,CAAC,GAAG,GAAG,GAAG;AACjB,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC;AACtE,OAAO,CAAC,IAAI,GAAG,IAAI;AACnB,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC;AACxE,OAAO,CAAC,KAAK,GAAG,KAAK;;"}
@@ -19,7 +19,7 @@ const unauthenticatedHandler_1 = require("./baseHandlers/unauthenticatedHandler"
19
19
  * @internal
20
20
  */
21
21
  const transferHandler = async (amplify, options, iamAuthApplicable, signingServiceInfo) => {
22
- const { url, method, headers, body, withCredentials, abortSignal } = options;
22
+ const { url, method, headers, body, withCredentials, abortSignal, retryStrategy, } = options;
23
23
  const resolvedBody = body
24
24
  ? body instanceof FormData
25
25
  ? body
@@ -33,7 +33,7 @@ const transferHandler = async (amplify, options, iamAuthApplicable, signingServi
33
33
  body: resolvedBody,
34
34
  };
35
35
  const baseOptions = {
36
- retryDecider: (0, aws_client_utils_1.getRetryDecider)(utils_1.parseRestApiServiceError),
36
+ retryDecider: getRetryDeciderFromStrategy(retryStrategy ?? amplify?.libraryOptions?.API?.REST?.retryStrategy),
37
37
  computeDelay: aws_client_utils_1.jitteredBackoff,
38
38
  withCrossDomainCredentials: withCredentials,
39
39
  abortSignal,
@@ -65,6 +65,13 @@ const transferHandler = async (amplify, options, iamAuthApplicable, signingServi
65
65
  };
66
66
  };
67
67
  exports.transferHandler = transferHandler;
68
+ const getRetryDeciderFromStrategy = (retryStrategy) => {
69
+ const strategy = retryStrategy?.strategy;
70
+ if (strategy === 'no-retry') {
71
+ return () => Promise.resolve({ retryable: false });
72
+ }
73
+ return (0, aws_client_utils_1.getRetryDecider)(utils_1.parseRestApiServiceError);
74
+ };
68
75
  const resolveCredentials = async (amplify) => {
69
76
  try {
70
77
  const { credentials } = await amplify.Auth.fetchAuthSession();
@@ -1 +1 @@
1
- {"version":3,"file":"transferHandler.js","sources":["../../../../src/apis/common/transferHandler.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.transferHandler = void 0;\nconst aws_client_utils_1 = require(\"@aws-amplify/core/internals/aws-client-utils\");\nconst utils_1 = require(\"../../utils\");\nconst resolveHeaders_1 = require(\"../../utils/resolveHeaders\");\nconst authenticatedHandler_1 = require(\"./baseHandlers/authenticatedHandler\");\nconst unauthenticatedHandler_1 = require(\"./baseHandlers/unauthenticatedHandler\");\n/**\n * Make REST API call with best-effort IAM auth.\n * @param amplify Amplify instance to to resolve credentials and tokens. Should use different instance in client-side\n * and SSR\n * @param options Options accepted from public API options when calling the handlers.\n * @param signingServiceInfo Internal-only options enable IAM auth as well as to to overwrite the IAM signing service\n * and region. If specified, and NONE of API Key header or Auth header is present, IAM auth will be used.\n * @param iamAuthApplicable Callback function that is used to determine if IAM Auth should be used or not.\n *\n * @internal\n */\nconst transferHandler = async (amplify, options, iamAuthApplicable, signingServiceInfo) => {\n const { url, method, headers, body, withCredentials, abortSignal } = options;\n const resolvedBody = body\n ? body instanceof FormData\n ? body\n : JSON.stringify(body ?? '')\n : undefined;\n const resolvedHeaders = (0, resolveHeaders_1.resolveHeaders)(headers, body);\n const request = {\n url,\n headers: resolvedHeaders,\n method,\n body: resolvedBody,\n };\n const baseOptions = {\n retryDecider: (0, aws_client_utils_1.getRetryDecider)(utils_1.parseRestApiServiceError),\n computeDelay: aws_client_utils_1.jitteredBackoff,\n withCrossDomainCredentials: withCredentials,\n abortSignal,\n };\n const isIamAuthApplicable = iamAuthApplicable(request, signingServiceInfo);\n let response;\n const credentials = await resolveCredentials(amplify);\n if (isIamAuthApplicable && credentials) {\n const signingInfoFromUrl = (0, utils_1.parseSigningInfo)(url);\n const signingService = signingServiceInfo?.service ?? signingInfoFromUrl.service;\n const signingRegion = signingServiceInfo?.region ?? signingInfoFromUrl.region;\n response = await (0, authenticatedHandler_1.authenticatedHandler)(request, {\n ...baseOptions,\n credentials,\n region: signingRegion,\n service: signingService,\n });\n }\n else {\n response = await (0, unauthenticatedHandler_1.unauthenticatedHandler)(request, {\n ...baseOptions,\n });\n }\n // Clean-up un-modeled properties from response.\n return {\n statusCode: response.statusCode,\n headers: response.headers,\n body: response.body,\n };\n};\nexports.transferHandler = transferHandler;\nconst resolveCredentials = async (amplify) => {\n try {\n const { credentials } = await amplify.Auth.fetchAuthSession();\n if (credentials) {\n return credentials;\n }\n }\n catch (e) {\n utils_1.logger.debug('No credentials available, the request will be unsigned.');\n }\n return null;\n};\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,eAAe,GAAG,MAAM;AAChC,MAAM,kBAAkB,GAAG,OAAO,CAAC,8CAA8C,CAAC;AAClF,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;AACtC,MAAM,gBAAgB,GA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AC,gBAAgB,EAAE,GAAG,CAAC;AACrE,QAAQ,MAAM,cAAc,GAAG,kBAAkB,EAAE,OAAO,IAAI,kBAAkB,CAAC,OAAO;AACxF,QAAQ,MAAM,aAAa,GAAG,kBAAkB,EAAE,MAAM,IAAI,kBAAkB,CAAC,MAAM;AACrF,QAAQ,QAAQ,GAAG,MAAM,IAAI,sBAAsB,CAAC,oBAAoB,EAAE,OAAO,EAAE;AACnF,YAAY,GAAG,WAAW;AAC1B,YAAY,WAAW;AACvB,YAAY,MAAM,EAAE,aAAa;AACjC,YAAY,OAAO,EAAE,cAAc;AACnC,SAAS,CAAC;AACV;AACA,SAAS;AACT,QAAQ,QAAQ,GAAG,MAAM,IAAI,wBAAwB,CAAC,sBAAsB,EAAE,OAAO,EAAE;AACvF,YAAY,GAAG,WAAW;AAC1B,SAAS,CAAC;AACV;AACA;AACA,IAAI,OAAO;AACX,QAAQ,UAAU,EAAE,QAAQ,CAAC,UAAU;AACvC,QAAQ,OAAO,EAAE,QAAQ,CAAC,OAAO;AACjC,QAAQ,IAAI,EAAE,QAAQ,CAAC,IAAI;AAC3B,KAAK;AACL,CAAC;AACD,OAAO,CAAC,eAAe,GAAG,eAAe;AACzC,MAAM,kBAAkB,GAAG,OAAO,OAAO,KAAK;AAC9C,IAAI,IAAI;AACR,QAAQ,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE;AACrE,QAAQ,IAAI,WAAW,EAAE;AACzB,YAAY,OAAO,WAAW;AAC9B;AACA;AACA,IAAI,OAAO,CAAC,EAAE;AACd,QAAQ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yDAAyD,CAAC;AACvF;AACA,IAAI,OAAO,IAAI;AACf,CAAC;;"}
1
+ {"version":3,"file":"transferHandler.js","sources":["../../../../src/apis/common/transferHandler.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.transferHandler = void 0;\nconst aws_client_utils_1 = require(\"@aws-amplify/core/internals/aws-client-utils\");\nconst utils_1 = require(\"../../utils\");\nconst resolveHeaders_1 = require(\"../../utils/resolveHeaders\");\nconst authenticatedHandler_1 = require(\"./baseHandlers/authenticatedHandler\");\nconst unauthenticatedHandler_1 = require(\"./baseHandlers/unauthenticatedHandler\");\n/**\n * Make REST API call with best-effort IAM auth.\n * @param amplify Amplify instance to to resolve credentials and tokens. Should use different instance in client-side\n * and SSR\n * @param options Options accepted from public API options when calling the handlers.\n * @param signingServiceInfo Internal-only options enable IAM auth as well as to to overwrite the IAM signing service\n * and region. If specified, and NONE of API Key header or Auth header is present, IAM auth will be used.\n * @param iamAuthApplicable Callback function that is used to determine if IAM Auth should be used or not.\n *\n * @internal\n */\nconst transferHandler = async (amplify, options, iamAuthApplicable, signingServiceInfo) => {\n const { url, method, headers, body, withCredentials, abortSignal, retryStrategy, } = options;\n const resolvedBody = body\n ? body instanceof FormData\n ? body\n : JSON.stringify(body ?? '')\n : undefined;\n const resolvedHeaders = (0, resolveHeaders_1.resolveHeaders)(headers, body);\n const request = {\n url,\n headers: resolvedHeaders,\n method,\n body: resolvedBody,\n };\n const baseOptions = {\n retryDecider: getRetryDeciderFromStrategy(retryStrategy ?? amplify?.libraryOptions?.API?.REST?.retryStrategy),\n computeDelay: aws_client_utils_1.jitteredBackoff,\n withCrossDomainCredentials: withCredentials,\n abortSignal,\n };\n const isIamAuthApplicable = iamAuthApplicable(request, signingServiceInfo);\n let response;\n const credentials = await resolveCredentials(amplify);\n if (isIamAuthApplicable && credentials) {\n const signingInfoFromUrl = (0, utils_1.parseSigningInfo)(url);\n const signingService = signingServiceInfo?.service ?? signingInfoFromUrl.service;\n const signingRegion = signingServiceInfo?.region ?? signingInfoFromUrl.region;\n response = await (0, authenticatedHandler_1.authenticatedHandler)(request, {\n ...baseOptions,\n credentials,\n region: signingRegion,\n service: signingService,\n });\n }\n else {\n response = await (0, unauthenticatedHandler_1.unauthenticatedHandler)(request, {\n ...baseOptions,\n });\n }\n // Clean-up un-modeled properties from response.\n return {\n statusCode: response.statusCode,\n headers: response.headers,\n body: response.body,\n };\n};\nexports.transferHandler = transferHandler;\nconst getRetryDeciderFromStrategy = (retryStrategy) => {\n const strategy = retryStrategy?.strategy;\n if (strategy === 'no-retry') {\n return () => Promise.resolve({ retryable: false });\n }\n return (0, aws_client_utils_1.getRetryDecider)(utils_1.parseRestApiServiceError);\n};\nconst resolveCredentials = async (amplify) => {\n try {\n const { credentials } = await amplify.Auth.fetchAuthSession();\n if (credentials) {\n return credentials;\n }\n }\n catch (e) {\n utils_1.logger.debug('No credentials available, the request will be unsigned.');\n }\n return null;\n};\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,eAAe,GAAG,MAAM;AAChC,MAAM,kBAAkB,GAAG,OAAO,CAAC,8CAA8C,CAAC;AAClF,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;AACtC,MAAM,gBAAgB,GAAG,OAAO,CAAC,4BAA4B,CAAC;AAC9D,MAAM,sBAAsB,GAAG,OAAO,CAAC,qCAAqC,CAAC;AAC7E,MAAM,wBAAwB,GAAG,OAAO,CAAC,uCAAuC,CAAC;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,eAAe,GAAG,OAAO,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,KAAK;AAC3F,IAAI,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,GAAG,GAAG,OAAO;AAChG,IAAI,MAAM,YAAY,GAAG;AACzB,UAAU,IAAI,YAAY;AAC1B,cAAc;AACd,cAAc,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE;AACvC,UAAU,SAAS;AACnB,IAAI,MAAM,eAAe,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AAC;AACV;AACA;AACA,IAAI,OAAO;AACX,QAAQ,UAAU,EAAE,QAAQ,CAAC,UAAU;AACvC,QAAQ,OAAO,EAAE,QAAQ,CAAC,OAAO;AACjC,QAAQ,IAAI,EAAE,QAAQ,CAAC,IAAI;AAC3B,KAAK;AACL,CAAC;AACD,OAAO,CAAC,eAAe,GAAG,eAAe;AACzC,MAAM,2BAA2B,GAAG,CAAC,aAAa,KAAK;AACvD,IAAI,MAAM,QAAQ,GAAG,aAAa,EAAE,QAAQ;AAC5C,IAAI,IAAI,QAAQ,KAAK,UAAU,EAAE;AACjC,QAAQ,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAC1D;AACA,IAAI,OAAO,IAAI,kBAAkB,CAAC,eAAe,EAAE,OAAO,CAAC,wBAAwB,CAAC;AACpF,CAAC;AACD,MAAM,kBAAkB,GAAG,OAAO,OAAO,KAAK;AAC9C,IAAI,IAAI;AACR,QAAQ,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE;AACrE,QAAQ,IAAI,WAAW,EAAE;AACzB,YAAY,OAAO,WAAW;AAC9B;AACA;AACA,IAAI,OAAO,CAAC,EAAE;AACd,QAAQ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yDAAyD,CAAC;AACvF;AACA,IAAI,OAAO,IAAI;AACf,CAAC;;"}
@@ -58,6 +58,9 @@ const post = (amplify, { url, options, abortController }) => {
58
58
  method: 'POST',
59
59
  ...options,
60
60
  abortSignal: controller.signal,
61
+ retryStrategy: {
62
+ strategy: 'jittered-exponential-backoff',
63
+ },
61
64
  }, isIamAuthApplicableForGraphQL, options?.signingServiceInfo);
62
65
  return response;
63
66
  }, controller);
@@ -1 +1 @@
1
- {"version":3,"file":"internalPost.mjs","sources":["../../../../src/apis/common/internalPost.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createCancellableOperation } from '../../utils';\nimport { isIamAuthApplicableForGraphQL } from '../../utils/isIamAuthApplicable';\nimport { transferHandler } from './transferHandler';\n/**\n * This weak map provides functionality to cancel a request given the promise containing the `post` request.\n *\n * 1. For every GraphQL POST request, an abort controller is created and supplied to the request.\n * 2. The promise fulfilled by GraphGL POST request is then mapped to that abort controller.\n * 3. The promise is returned to the external caller.\n * 4. The caller can either wait for the promise to fulfill or call `cancel(promise)` to cancel the request.\n * 5. If `cancel(promise)` is called, then the corresponding abort controller is retrieved from the map below.\n * 6. GraphQL POST request will be rejected with the error message provided during cancel.\n * 7. Caller can check if the error is because of cancelling by calling `isCancelError(error)`.\n */\nconst cancelTokenMap = new WeakMap();\n/**\n * @internal\n *\n * REST POST handler to send GraphQL request to given endpoint. By default, it will use IAM to authorize\n * the request. In some auth modes, the IAM auth has to be disabled. Here's how to set up the request auth correctly:\n * * If auth mode is 'iam', you MUST NOT set 'authorization' header and 'x-api-key' header, since it would disable IAM\n * auth. You MUST also set 'input.options.signingServiceInfo' option.\n * * The including 'input.options.signingServiceInfo.service' and 'input.options.signingServiceInfo.region' are\n * optional. If omitted, the signing service and region will be inferred from url.\n * * If auth mode is 'none', you MUST NOT set 'options.signingServiceInfo' option.\n * * If auth mode is 'apiKey', you MUST set 'x-api-key' custom header.\n * * If auth mode is 'oidc' or 'lambda' or 'userPool', you MUST set 'authorization' header.\n *\n * To make the internal post cancellable, you must also call `updateRequestToBeCancellable()` with the promise from\n * internal post call and the abort controller supplied to the internal post call.\n *\n * @param amplify the AmplifyClassV6 instance - it may be the singleton used on Web, or an instance created within\n * a context created by `runWithAmplifyServerContext`\n * @param postInput an object of {@link InternalPostInput}\n * @param postInput.url The URL that the POST request sends to\n * @param postInput.options Options of the POST request\n * @param postInput.abortController The abort controller used to cancel the POST request\n * @returns a {@link RestApiResponse}\n *\n * @throws an {@link AmplifyError} with `Network Error` as the `message` when the external resource is unreachable due to one\n * of the following reasons:\n * 1. no network connection\n * 2. CORS error\n * @throws a {@link CanceledError} when the ongoing POST request get cancelled\n */\nexport const post = (amplify, { url, options, abortController }) => {\n const controller = abortController ?? new AbortController();\n const responsePromise = createCancellableOperation(async () => {\n const response = transferHandler(amplify, {\n url,\n method: 'POST',\n ...options,\n abortSignal: controller.signal,\n }, isIamAuthApplicableForGraphQL, options?.signingServiceInfo);\n return response;\n }, controller);\n const responseWithCleanUp = responsePromise.finally(() => {\n cancelTokenMap.delete(responseWithCleanUp);\n });\n return responseWithCleanUp;\n};\n/**\n * Cancels a request given the promise returned by `post`.\n * If the request is already completed, this function does nothing.\n * It MUST be used after `updateRequestToBeCancellable` is called.\n */\nexport const cancel = (promise, message) => {\n const controller = cancelTokenMap.get(promise);\n if (controller) {\n controller.abort(message);\n if (message && controller.signal.reason !== message) {\n // In runtimes where `AbortSignal.reason` is not supported, we track the reason ourselves.\n // @ts-expect-error reason is read-only property.\n controller.signal.reason = message;\n }\n return true;\n }\n return false;\n};\n/**\n * MUST be used to make a promise including internal `post` API call cancellable.\n */\nexport const updateRequestToBeCancellable = (promise, controller) => {\n cancelTokenMap.set(promise, controller);\n};\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,cAAc,GAAG,IAAI,OAAO,EAAE;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK;AACpE,IAAI,MAAM,UAAU,GAAG,eAAe,IAAI,IAAI,eAAe,EAAE;AAC/D,IAAI,MAAM,eAAe,GAAG,0BAA0B,CAAC,YAAY;AACnE,QAAQ,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,EAAE;AAClD,YAAY,GAAG;AACf,YAAY,MAAM,EAAE,MAAM;AAC1B,YAAY,GAAG,OAAO;AACtB,YAAY,WAAW,EAAE,UAAU,CAAC,MAAM;AAC1C,SAAS,EAAE,6BAA6B,EAAE,OAAO,EAAE,kBAAkB,CAAC;AACtE,QAAQ,OAAO,QAAQ;AACvB,KAAK,EAAE,UAAU,CAAC;AAClB,IAAI,MAAM,mBAAmB,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM;AAC9D,QAAQ,cAAc,CAAC,MAAM,CAAC,mBAAmB,CAAC;AAClD,KAAK,CAAC;AACN,IAAI,OAAO,mBAAmB;AAC9B;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK;AAC5C,IAAI,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC;AAClD,IAAI,IAAI,UAAU,EAAE;AACpB,QAAQ,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC;AACjC,QAAQ,IAAI,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE;AAC7D;AACA;AACA,YAAY,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO;AAC9C;AACA,QAAQ,OAAO,IAAI;AACnB;AACA,IAAI,OAAO,KAAK;AAChB;AACA;AACA;AACA;AACY,MAAC,4BAA4B,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK;AACrE,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC;AAC3C;;;;"}
1
+ {"version":3,"file":"internalPost.mjs","sources":["../../../../src/apis/common/internalPost.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createCancellableOperation } from '../../utils';\nimport { isIamAuthApplicableForGraphQL } from '../../utils/isIamAuthApplicable';\nimport { transferHandler } from './transferHandler';\n/**\n * This weak map provides functionality to cancel a request given the promise containing the `post` request.\n *\n * 1. For every GraphQL POST request, an abort controller is created and supplied to the request.\n * 2. The promise fulfilled by GraphGL POST request is then mapped to that abort controller.\n * 3. The promise is returned to the external caller.\n * 4. The caller can either wait for the promise to fulfill or call `cancel(promise)` to cancel the request.\n * 5. If `cancel(promise)` is called, then the corresponding abort controller is retrieved from the map below.\n * 6. GraphQL POST request will be rejected with the error message provided during cancel.\n * 7. Caller can check if the error is because of cancelling by calling `isCancelError(error)`.\n */\nconst cancelTokenMap = new WeakMap();\n/**\n * @internal\n *\n * REST POST handler to send GraphQL request to given endpoint. By default, it will use IAM to authorize\n * the request. In some auth modes, the IAM auth has to be disabled. Here's how to set up the request auth correctly:\n * * If auth mode is 'iam', you MUST NOT set 'authorization' header and 'x-api-key' header, since it would disable IAM\n * auth. You MUST also set 'input.options.signingServiceInfo' option.\n * * The including 'input.options.signingServiceInfo.service' and 'input.options.signingServiceInfo.region' are\n * optional. If omitted, the signing service and region will be inferred from url.\n * * If auth mode is 'none', you MUST NOT set 'options.signingServiceInfo' option.\n * * If auth mode is 'apiKey', you MUST set 'x-api-key' custom header.\n * * If auth mode is 'oidc' or 'lambda' or 'userPool', you MUST set 'authorization' header.\n *\n * To make the internal post cancellable, you must also call `updateRequestToBeCancellable()` with the promise from\n * internal post call and the abort controller supplied to the internal post call.\n *\n * @param amplify the AmplifyClassV6 instance - it may be the singleton used on Web, or an instance created within\n * a context created by `runWithAmplifyServerContext`\n * @param postInput an object of {@link InternalPostInput}\n * @param postInput.url The URL that the POST request sends to\n * @param postInput.options Options of the POST request\n * @param postInput.abortController The abort controller used to cancel the POST request\n * @returns a {@link RestApiResponse}\n *\n * @throws an {@link AmplifyError} with `Network Error` as the `message` when the external resource is unreachable due to one\n * of the following reasons:\n * 1. no network connection\n * 2. CORS error\n * @throws a {@link CanceledError} when the ongoing POST request get cancelled\n */\nexport const post = (amplify, { url, options, abortController }) => {\n const controller = abortController ?? new AbortController();\n const responsePromise = createCancellableOperation(async () => {\n const response = transferHandler(amplify, {\n url,\n method: 'POST',\n ...options,\n abortSignal: controller.signal,\n retryStrategy: {\n strategy: 'jittered-exponential-backoff',\n },\n }, isIamAuthApplicableForGraphQL, options?.signingServiceInfo);\n return response;\n }, controller);\n const responseWithCleanUp = responsePromise.finally(() => {\n cancelTokenMap.delete(responseWithCleanUp);\n });\n return responseWithCleanUp;\n};\n/**\n * Cancels a request given the promise returned by `post`.\n * If the request is already completed, this function does nothing.\n * It MUST be used after `updateRequestToBeCancellable` is called.\n */\nexport const cancel = (promise, message) => {\n const controller = cancelTokenMap.get(promise);\n if (controller) {\n controller.abort(message);\n if (message && controller.signal.reason !== message) {\n // In runtimes where `AbortSignal.reason` is not supported, we track the reason ourselves.\n // @ts-expect-error reason is read-only property.\n controller.signal.reason = message;\n }\n return true;\n }\n return false;\n};\n/**\n * MUST be used to make a promise including internal `post` API call cancellable.\n */\nexport const updateRequestToBeCancellable = (promise, controller) => {\n cancelTokenMap.set(promise, controller);\n};\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,cAAc,GAAG,IAAI,OAAO,EAAE;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK;AACpE,IAAI,MAAM,UAAU,GAAG,eAAe,IAAI,IAAI,eAAe,EAAE;AAC/D,IAAI,MAAM,eAAe,GAAG,0BAA0B,CAAC,YAAY;AACnE,QAAQ,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,EAAE;AAClD,YAAY,GAAG;AACf,YAAY,MAAM,EAAE,MAAM;AAC1B,YAAY,GAAG,OAAO;AACtB,YAAY,WAAW,EAAE,UAAU,CAAC,MAAM;AAC1C,YAAY,aAAa,EAAE;AAC3B,gBAAgB,QAAQ,EAAE,8BAA8B;AACxD,aAAa;AACb,SAAS,EAAE,6BAA6B,EAAE,OAAO,EAAE,kBAAkB,CAAC;AACtE,QAAQ,OAAO,QAAQ;AACvB,KAAK,EAAE,UAAU,CAAC;AAClB,IAAI,MAAM,mBAAmB,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM;AAC9D,QAAQ,cAAc,CAAC,MAAM,CAAC,mBAAmB,CAAC;AAClD,KAAK,CAAC;AACN,IAAI,OAAO,mBAAmB;AAC9B;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK;AAC5C,IAAI,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC;AAClD,IAAI,IAAI,UAAU,EAAE;AACpB,QAAQ,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC;AACjC,QAAQ,IAAI,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE;AAC7D;AACA;AACA,YAAY,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO;AAC9C;AACA,QAAQ,OAAO,IAAI;AACnB;AACA,IAAI,OAAO,KAAK;AAChB;AACA;AACA;AACA;AACY,MAAC,4BAA4B,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK;AACrE,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC;AAC3C;;;;"}
@@ -11,7 +11,7 @@ import { transferHandler } from './transferHandler.mjs';
11
11
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
12
12
  // SPDX-License-Identifier: Apache-2.0
13
13
  const publicHandler = (amplify, options, method) => createCancellableOperation(async (abortSignal) => {
14
- const { apiName, options: apiOptions = {}, path: apiPath } = options;
14
+ const { apiName, options: apiOptions = {}, path: apiPath, retryStrategy, } = options;
15
15
  const url = resolveApiUrl(amplify, apiName, apiPath, apiOptions?.queryParams);
16
16
  const libraryConfigHeaders = await amplify.libraryOptions?.API?.REST?.headers?.({
17
17
  apiName,
@@ -33,6 +33,7 @@ const publicHandler = (amplify, options, method) => createCancellableOperation(a
33
33
  method,
34
34
  headers,
35
35
  abortSignal,
36
+ retryStrategy,
36
37
  }, isIamAuthApplicableForRest, signingServiceInfo);
37
38
  });
38
39
  const get = (amplify, input) => publicHandler(amplify, input, 'GET');
@@ -1 +1 @@
1
- {"version":3,"file":"publicApis.mjs","sources":["../../../../src/apis/common/publicApis.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createCancellableOperation, logger, parseSigningInfo, resolveApiUrl, } from '../../utils';\nimport { isIamAuthApplicableForRest } from '../../utils/isIamAuthApplicable';\nimport { transferHandler } from './transferHandler';\nconst publicHandler = (amplify, options, method) => createCancellableOperation(async (abortSignal) => {\n const { apiName, options: apiOptions = {}, path: apiPath } = options;\n const url = resolveApiUrl(amplify, apiName, apiPath, apiOptions?.queryParams);\n const libraryConfigHeaders = await amplify.libraryOptions?.API?.REST?.headers?.({\n apiName,\n });\n const { headers: invocationHeaders = {} } = apiOptions;\n const headers = {\n // custom headers from invocation options should precede library options\n ...libraryConfigHeaders,\n ...invocationHeaders,\n };\n const signingServiceInfo = parseSigningInfo(url, {\n amplify,\n apiName,\n });\n logger.debug(method, url, headers, `IAM signing options: ${JSON.stringify(signingServiceInfo)}`);\n return transferHandler(amplify, {\n ...apiOptions,\n url,\n method,\n headers,\n abortSignal,\n }, isIamAuthApplicableForRest, signingServiceInfo);\n});\nexport const get = (amplify, input) => publicHandler(amplify, input, 'GET');\nexport const post = (amplify, input) => publicHandler(amplify, input, 'POST');\nexport const put = (amplify, input) => publicHandler(amplify, input, 'PUT');\nexport const del = (amplify, input) => publicHandler(amplify, input, 'DELETE');\nexport const head = (amplify, input) => publicHandler(amplify, input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,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK;AAC9D,MAAC,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM;AAChE,MAAC,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK;AAC9D,MAAC,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ;AACjE,MAAC,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM;AAChE,MAAC,KAAK,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO;;;;"}
1
+ {"version":3,"file":"publicApis.mjs","sources":["../../../../src/apis/common/publicApis.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createCancellableOperation, logger, parseSigningInfo, resolveApiUrl, } from '../../utils';\nimport { isIamAuthApplicableForRest } from '../../utils/isIamAuthApplicable';\nimport { transferHandler } from './transferHandler';\nconst publicHandler = (amplify, options, method) => createCancellableOperation(async (abortSignal) => {\n const { apiName, options: apiOptions = {}, path: apiPath, retryStrategy, } = options;\n const url = resolveApiUrl(amplify, apiName, apiPath, apiOptions?.queryParams);\n const libraryConfigHeaders = await amplify.libraryOptions?.API?.REST?.headers?.({\n apiName,\n });\n const { headers: invocationHeaders = {} } = apiOptions;\n const headers = {\n // custom headers from invocation options should precede library options\n ...libraryConfigHeaders,\n ...invocationHeaders,\n };\n const signingServiceInfo = parseSigningInfo(url, {\n amplify,\n apiName,\n });\n logger.debug(method, url, headers, `IAM signing options: ${JSON.stringify(signingServiceInfo)}`);\n return transferHandler(amplify, {\n ...apiOptions,\n url,\n method,\n headers,\n abortSignal,\n retryStrategy,\n }, isIamAuthApplicableForRest, signingServiceInfo);\n});\nexport const get = (amplify, input) => publicHandler(amplify, input, 'GET');\nexport const post = (amplify, input) => publicHandler(amplify, input, 'POST');\nexport const put = (amplify, input) => publicHandler(amplify, input, 'PUT');\nexport const del = (amplify, input) => publicHandler(amplify, input, 'DELETE');\nexport const head = (amplify, input) => publicHandler(amplify, input, 'HEAD');\nexport const patch = (amplify, input) => publicHandler(amplify, input, 'PATCH');\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AACA;AAIA,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,0BAA0B,CAAC,OAAO,WAAW,KAAK;AACtG,IAAI,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,GAAG,GAAG,OAAO;AACxF,IAAI,MAAM,GAAG,GAAG,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC;AACjF,IAAI,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,GAAG;AACpF,QAAQ,OAAO;AACf,KAAK,CAAC;AACN,IAAI,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,EAAE,EAAE,GAAG,UAAU;AAC1D,IAAI,MAAM,OAAO,GAAG;AACpB;AACA,QAAQ,GAAG,oBAAoB;AAC/B,QAAQ,GAAG,iBAAiB;AAC5B,KAAK;AACL,IAAI,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,GAAG,EAAE;AACrD,QAAQ,OAAO;AACf,QAAQ,OAAO;AACf,KAAK,CAAC;AACN,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,qBAAqB,EAAE,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;AACpG,IAAI,OAAO,eAAe,CAAC,OAAO,EAAE;AACpC,QAAQ,GAAG,UAAU;AACrB,QAAQ,GAAG;AACX,QAAQ,MAAM;AACd,QAAQ,OAAO;AACf,QAAQ,WAAW;AACnB,QAAQ,aAAa;AACrB,KAAK,EAAE,0BAA0B,EAAE,kBAAkB,CAAC;AACtD,CAAC,CAAC;AACU,MAAC,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK;AAC9D,MAAC,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM;AAChE,MAAC,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK;AAC9D,MAAC,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ;AACjE,MAAC,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM;AAChE,MAAC,KAAK,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO;;;;"}
@@ -1,11 +1,12 @@
1
1
  import { AmplifyClassV6 } from '@aws-amplify/core';
2
2
  import { Headers, HttpRequest } from '@aws-amplify/core/internals/aws-client-utils';
3
- import { DocumentType } from '@aws-amplify/core/internals/utils';
3
+ import { DocumentType, RetryStrategy } from '@aws-amplify/core/internals/utils';
4
4
  import { RestApiResponse, SigningServiceInfo } from '../../types';
5
5
  type HandlerOptions = Omit<HttpRequest, 'body' | 'headers'> & {
6
6
  body?: DocumentType | FormData;
7
7
  headers?: Headers;
8
8
  withCredentials?: boolean;
9
+ retryStrategy?: RetryStrategy;
9
10
  };
10
11
  /**
11
12
  * Make REST API call with best-effort IAM auth.
@@ -1,4 +1,4 @@
1
- import { getRetryDecider, jitteredBackoff } from '@aws-amplify/core/internals/aws-client-utils';
1
+ import { jitteredBackoff, getRetryDecider } from '@aws-amplify/core/internals/aws-client-utils';
2
2
  import '@aws-amplify/core/internals/utils';
3
3
  import '../../errors/validation.mjs';
4
4
  import { parseRestApiServiceError } from '../../utils/serviceError.mjs';
@@ -20,7 +20,7 @@ import { unauthenticatedHandler } from './baseHandlers/unauthenticatedHandler.mj
20
20
  * @internal
21
21
  */
22
22
  const transferHandler = async (amplify, options, iamAuthApplicable, signingServiceInfo) => {
23
- const { url, method, headers, body, withCredentials, abortSignal } = options;
23
+ const { url, method, headers, body, withCredentials, abortSignal, retryStrategy, } = options;
24
24
  const resolvedBody = body
25
25
  ? body instanceof FormData
26
26
  ? body
@@ -34,7 +34,7 @@ const transferHandler = async (amplify, options, iamAuthApplicable, signingServi
34
34
  body: resolvedBody,
35
35
  };
36
36
  const baseOptions = {
37
- retryDecider: getRetryDecider(parseRestApiServiceError),
37
+ retryDecider: getRetryDeciderFromStrategy(retryStrategy ?? amplify?.libraryOptions?.API?.REST?.retryStrategy),
38
38
  computeDelay: jitteredBackoff,
39
39
  withCrossDomainCredentials: withCredentials,
40
40
  abortSignal,
@@ -65,6 +65,13 @@ const transferHandler = async (amplify, options, iamAuthApplicable, signingServi
65
65
  body: response.body,
66
66
  };
67
67
  };
68
+ const getRetryDeciderFromStrategy = (retryStrategy) => {
69
+ const strategy = retryStrategy?.strategy;
70
+ if (strategy === 'no-retry') {
71
+ return () => Promise.resolve({ retryable: false });
72
+ }
73
+ return getRetryDecider(parseRestApiServiceError);
74
+ };
68
75
  const resolveCredentials = async (amplify) => {
69
76
  try {
70
77
  const { credentials } = await amplify.Auth.fetchAuthSession();
@@ -1 +1 @@
1
- {"version":3,"file":"transferHandler.mjs","sources":["../../../../src/apis/common/transferHandler.ts"],"sourcesContent":["import { getRetryDecider, jitteredBackoff, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { logger, parseRestApiServiceError, parseSigningInfo, } from '../../utils';\nimport { resolveHeaders } from '../../utils/resolveHeaders';\nimport { authenticatedHandler } from './baseHandlers/authenticatedHandler';\nimport { unauthenticatedHandler } from './baseHandlers/unauthenticatedHandler';\n/**\n * Make REST API call with best-effort IAM auth.\n * @param amplify Amplify instance to to resolve credentials and tokens. Should use different instance in client-side\n * and SSR\n * @param options Options accepted from public API options when calling the handlers.\n * @param signingServiceInfo Internal-only options enable IAM auth as well as to to overwrite the IAM signing service\n * and region. If specified, and NONE of API Key header or Auth header is present, IAM auth will be used.\n * @param iamAuthApplicable Callback function that is used to determine if IAM Auth should be used or not.\n *\n * @internal\n */\nexport const transferHandler = async (amplify, options, iamAuthApplicable, signingServiceInfo) => {\n const { url, method, headers, body, withCredentials, abortSignal } = options;\n const resolvedBody = body\n ? body instanceof FormData\n ? body\n : JSON.stringify(body ?? '')\n : undefined;\n const resolvedHeaders = resolveHeaders(headers, body);\n const request = {\n url,\n headers: resolvedHeaders,\n method,\n body: resolvedBody,\n };\n const baseOptions = {\n retryDecider: getRetryDecider(parseRestApiServiceError),\n computeDelay: jitteredBackoff,\n withCrossDomainCredentials: withCredentials,\n abortSignal,\n };\n const isIamAuthApplicable = iamAuthApplicable(request, signingServiceInfo);\n let response;\n const credentials = await resolveCredentials(amplify);\n if (isIamAuthApplicable && credentials) {\n const signingInfoFromUrl = parseSigningInfo(url);\n const signingService = signingServiceInfo?.service ?? signingInfoFromUrl.service;\n const signingRegion = signingServiceInfo?.region ?? signingInfoFromUrl.region;\n response = await authenticatedHandler(request, {\n ...baseOptions,\n credentials,\n region: signingRegion,\n service: signingService,\n });\n }\n else {\n response = await unauthenticatedHandler(request, {\n ...baseOptions,\n });\n }\n // Clean-up un-modeled properties from response.\n return {\n statusCode: response.statusCode,\n headers: response.headers,\n body: response.body,\n };\n};\nconst resolveCredentials = async (amplify) => {\n try {\n const { credentials } = await amplify.Auth.fetchAuthSession();\n if (credentials) {\n return credentials;\n }\n }\n catch (e) {\n logger.debug('No credentials available, the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,CAAC,MAAM;AACrF,QAAQ,QAAQ,GAAG,MAAM,oBAAoB,CAAC,OAAO,EAAE;AACvD,YAAY,GAAG,WAAW;AAC1B,YAAY,WAAW;AACvB,YAAY,MAAM,EAAE,aAAa;AACjC,YAAY,OAAO,EAAE,cAAc;AACnC,SAAS,CAAC;AACV;AACA,SAAS;AACT,QAAQ,QAAQ,GAAG,MAAM,sBAAsB,CAAC,OAAO,EAAE;AACzD,YAAY,GAAG,WAAW;AAC1B,SAAS,CAAC;AACV;AACA;AACA,IAAI,OAAO;AACX,QAAQ,UAAU,EAAE,QAAQ,CAAC,UAAU;AACvC,QAAQ,OAAO,EAAE,QAAQ,CAAC,OAAO;AACjC,QAAQ,IAAI,EAAE,QAAQ,CAAC,IAAI;AAC3B,KAAK;AACL;AACA,MAAM,kBAAkB,GAAG,OAAO,OAAO,KAAK;AAC9C,IAAI,IAAI;AACR,QAAQ,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE;AACrE,QAAQ,IAAI,WAAW,EAAE;AACzB,YAAY,OAAO,WAAW;AAC9B;AACA;AACA,IAAI,OAAO,CAAC,EAAE;AACd,QAAQ,MAAM,CAAC,KAAK,CAAC,yDAAyD,CAAC;AAC/E;AACA,IAAI,OAAO,IAAI;AACf,CAAC;;;;"}
1
+ {"version":3,"file":"transferHandler.mjs","sources":["../../../../src/apis/common/transferHandler.ts"],"sourcesContent":["import { getRetryDecider, jitteredBackoff, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { logger, parseRestApiServiceError, parseSigningInfo, } from '../../utils';\nimport { resolveHeaders } from '../../utils/resolveHeaders';\nimport { authenticatedHandler } from './baseHandlers/authenticatedHandler';\nimport { unauthenticatedHandler } from './baseHandlers/unauthenticatedHandler';\n/**\n * Make REST API call with best-effort IAM auth.\n * @param amplify Amplify instance to to resolve credentials and tokens. Should use different instance in client-side\n * and SSR\n * @param options Options accepted from public API options when calling the handlers.\n * @param signingServiceInfo Internal-only options enable IAM auth as well as to to overwrite the IAM signing service\n * and region. If specified, and NONE of API Key header or Auth header is present, IAM auth will be used.\n * @param iamAuthApplicable Callback function that is used to determine if IAM Auth should be used or not.\n *\n * @internal\n */\nexport const transferHandler = async (amplify, options, iamAuthApplicable, signingServiceInfo) => {\n const { url, method, headers, body, withCredentials, abortSignal, retryStrategy, } = options;\n const resolvedBody = body\n ? body instanceof FormData\n ? body\n : JSON.stringify(body ?? '')\n : undefined;\n const resolvedHeaders = resolveHeaders(headers, body);\n const request = {\n url,\n headers: resolvedHeaders,\n method,\n body: resolvedBody,\n };\n const baseOptions = {\n retryDecider: getRetryDeciderFromStrategy(retryStrategy ?? amplify?.libraryOptions?.API?.REST?.retryStrategy),\n computeDelay: jitteredBackoff,\n withCrossDomainCredentials: withCredentials,\n abortSignal,\n };\n const isIamAuthApplicable = iamAuthApplicable(request, signingServiceInfo);\n let response;\n const credentials = await resolveCredentials(amplify);\n if (isIamAuthApplicable && credentials) {\n const signingInfoFromUrl = parseSigningInfo(url);\n const signingService = signingServiceInfo?.service ?? signingInfoFromUrl.service;\n const signingRegion = signingServiceInfo?.region ?? signingInfoFromUrl.region;\n response = await authenticatedHandler(request, {\n ...baseOptions,\n credentials,\n region: signingRegion,\n service: signingService,\n });\n }\n else {\n response = await unauthenticatedHandler(request, {\n ...baseOptions,\n });\n }\n // Clean-up un-modeled properties from response.\n return {\n statusCode: response.statusCode,\n headers: response.headers,\n body: response.body,\n };\n};\nconst getRetryDeciderFromStrategy = (retryStrategy) => {\n const strategy = retryStrategy?.strategy;\n if (strategy === 'no-retry') {\n return () => Promise.resolve({ retryable: false });\n }\n return getRetryDecider(parseRestApiServiceError);\n};\nconst resolveCredentials = async (amplify) => {\n try {\n const { credentials } = await amplify.Auth.fetchAuthSession();\n if (credentials) {\n return credentials;\n }\n }\n catch (e) {\n logger.debug('No credentials available, the request will be unsigned.');\n }\n return null;\n};\n"],"names":[],"mappings":";;;;;;;;;;AAKA;AACA;AAC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AAkB,CAAC,MAAM;AACrF,QAAQ,QAAQ,GAAG,MAAM,oBAAoB,CAAC,OAAO,EAAE;AACvD,YAAY,GAAG,WAAW;AAC1B,YAAY,WAAW;AACvB,YAAY,MAAM,EAAE,aAAa;AACjC,YAAY,OAAO,EAAE,cAAc;AACnC,SAAS,CAAC;AACV;AACA,SAAS;AACT,QAAQ,QAAQ,GAAG,MAAM,sBAAsB,CAAC,OAAO,EAAE;AACzD,YAAY,GAAG,WAAW;AAC1B,SAAS,CAAC;AACV;AACA;AACA,IAAI,OAAO;AACX,QAAQ,UAAU,EAAE,QAAQ,CAAC,UAAU;AACvC,QAAQ,OAAO,EAAE,QAAQ,CAAC,OAAO;AACjC,QAAQ,IAAI,EAAE,QAAQ,CAAC,IAAI;AAC3B,KAAK;AACL;AACA,MAAM,2BAA2B,GAAG,CAAC,aAAa,KAAK;AACvD,IAAI,MAAM,QAAQ,GAAG,aAAa,EAAE,QAAQ;AAC5C,IAAI,IAAI,QAAQ,KAAK,UAAU,EAAE;AACjC,QAAQ,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAC1D;AACA,IAAI,OAAO,eAAe,CAAC,wBAAwB,CAAC;AACpD,CAAC;AACD,MAAM,kBAAkB,GAAG,OAAO,OAAO,KAAK;AAC9C,IAAI,IAAI;AACR,QAAQ,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE;AACrE,QAAQ,IAAI,WAAW,EAAE;AACzB,YAAY,OAAO,WAAW;AAC9B;AACA;AACA,IAAI,OAAO,CAAC,EAAE;AACd,QAAQ,MAAM,CAAC,KAAK,CAAC,yDAAyD,CAAC;AAC/E;AACA,IAAI,OAAO,IAAI;AACf,CAAC;;;;"}
@@ -1,4 +1,4 @@
1
- import { DocumentType } from '@aws-amplify/core/internals/utils';
1
+ import { DocumentType, RetryStrategy } from '@aws-amplify/core/internals/utils';
2
2
  export type GetInput = ApiInput<RestApiOptionsBase>;
3
3
  export type PostInput = ApiInput<RestApiOptionsBase>;
4
4
  export type PutInput = ApiInput<RestApiOptionsBase>;
@@ -72,6 +72,12 @@ export interface ApiInput<Options> {
72
72
  * Options to overwrite the REST API call behavior.
73
73
  */
74
74
  options?: Options;
75
+ /**
76
+ * Retry strategy for the REST API calls. It will take precedence over REST `retryStrategy` in Amplify configuration libraryOptions.
77
+ *
78
+ * @default ` { strategy: 'jittered-exponential-backoff' } `
79
+ */
80
+ retryStrategy?: RetryStrategy;
75
81
  }
76
82
  /**
77
83
  * Input type to invoke REST POST API from GraphQl client.
package/package.json CHANGED
@@ -1,96 +1,96 @@
1
1
  {
2
- "name": "@aws-amplify/api-rest",
3
- "private": false,
4
- "version": "4.0.76-unstable.b188564.0+b188564",
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": "./src/index.ts",
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
- "types": "./dist/esm/index.d.ts",
31
- "import": "./dist/esm/index.mjs",
32
- "require": "./dist/cjs/index.js",
33
- "react-native": "./src/index.ts"
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
- "types": "./dist/esm/internals/index.d.ts",
42
- "import": "./dist/esm/internals/index.mjs",
43
- "require": "./dist/cjs/internals/index.js",
44
- "react-native": "./src/internals/index.ts"
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.10.7-unstable.b188564.0+b188564"
88
- },
89
- "devDependencies": {
90
- "@aws-amplify/core": "6.10.7-unstable.b188564.0+b188564",
91
- "@aws-amplify/react-native": "1.1.8-unstable.b188564.0+b188564",
92
- "@aws-sdk/types": "3.387.0",
93
- "typescript": "5.0.2"
94
- },
95
- "gitHead": "b1885648589e0549c0e7c257e8be5fb4936d5bde"
2
+ "name": "@aws-amplify/api-rest",
3
+ "private": false,
4
+ "version": "4.1.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": "./src/index.ts",
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
+ "types": "./dist/esm/index.d.ts",
31
+ "import": "./dist/esm/index.mjs",
32
+ "require": "./dist/cjs/index.js",
33
+ "react-native": "./src/index.ts"
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
+ "types": "./dist/esm/internals/index.d.ts",
42
+ "import": "./dist/esm/internals/index.mjs",
43
+ "require": "./dist/cjs/internals/index.js",
44
+ "react-native": "./src/internals/index.ts"
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.11.0",
91
+ "@aws-amplify/react-native": "1.1.7",
92
+ "@aws-sdk/types": "3.387.0",
93
+ "typescript": "5.0.2"
94
+ },
95
+ "gitHead": "2997fc99e95e6d69a2dcb7e124059dbbe822e74e"
96
96
  }
@@ -66,6 +66,9 @@ export const post = (
66
66
  method: 'POST',
67
67
  ...options,
68
68
  abortSignal: controller.signal,
69
+ retryStrategy: {
70
+ strategy: 'jittered-exponential-backoff',
71
+ },
69
72
  },
70
73
  isIamAuthApplicableForGraphQL,
71
74
  options?.signingServiceInfo,
@@ -35,7 +35,12 @@ const publicHandler = (
35
35
  method: string,
36
36
  ) =>
37
37
  createCancellableOperation(async abortSignal => {
38
- const { apiName, options: apiOptions = {}, path: apiPath } = options;
38
+ const {
39
+ apiName,
40
+ options: apiOptions = {},
41
+ path: apiPath,
42
+ retryStrategy,
43
+ } = options;
39
44
  const url = resolveApiUrl(
40
45
  amplify,
41
46
  apiName,
@@ -71,6 +76,7 @@ const publicHandler = (
71
76
  method,
72
77
  headers,
73
78
  abortSignal,
79
+ retryStrategy,
74
80
  },
75
81
  isIamAuthApplicableForRest,
76
82
  signingServiceInfo,
@@ -4,12 +4,14 @@ import { AmplifyClassV6 } from '@aws-amplify/core';
4
4
  import {
5
5
  Headers,
6
6
  HttpRequest,
7
+ RetryOptions,
7
8
  getRetryDecider,
8
9
  jitteredBackoff,
9
10
  } from '@aws-amplify/core/internals/aws-client-utils';
10
11
  import {
11
12
  AWSCredentials,
12
13
  DocumentType,
14
+ RetryStrategy,
13
15
  } from '@aws-amplify/core/internals/utils';
14
16
 
15
17
  import {
@@ -27,8 +29,11 @@ type HandlerOptions = Omit<HttpRequest, 'body' | 'headers'> & {
27
29
  body?: DocumentType | FormData;
28
30
  headers?: Headers;
29
31
  withCredentials?: boolean;
32
+ retryStrategy?: RetryStrategy;
30
33
  };
31
34
 
35
+ type RetryDecider = RetryOptions['retryDecider'];
36
+
32
37
  /**
33
38
  * Make REST API call with best-effort IAM auth.
34
39
  * @param amplify Amplify instance to to resolve credentials and tokens. Should use different instance in client-side
@@ -49,7 +54,15 @@ export const transferHandler = async (
49
54
  ) => boolean,
50
55
  signingServiceInfo?: SigningServiceInfo,
51
56
  ): Promise<RestApiResponse> => {
52
- const { url, method, headers, body, withCredentials, abortSignal } = options;
57
+ const {
58
+ url,
59
+ method,
60
+ headers,
61
+ body,
62
+ withCredentials,
63
+ abortSignal,
64
+ retryStrategy,
65
+ } = options;
53
66
  const resolvedBody = body
54
67
  ? body instanceof FormData
55
68
  ? body
@@ -63,7 +76,9 @@ export const transferHandler = async (
63
76
  body: resolvedBody,
64
77
  };
65
78
  const baseOptions = {
66
- retryDecider: getRetryDecider(parseRestApiServiceError),
79
+ retryDecider: getRetryDeciderFromStrategy(
80
+ retryStrategy ?? amplify?.libraryOptions?.API?.REST?.retryStrategy,
81
+ ),
67
82
  computeDelay: jitteredBackoff,
68
83
  withCrossDomainCredentials: withCredentials,
69
84
  abortSignal,
@@ -99,6 +114,17 @@ export const transferHandler = async (
99
114
  };
100
115
  };
101
116
 
117
+ const getRetryDeciderFromStrategy = (
118
+ retryStrategy: RetryStrategy | undefined,
119
+ ): RetryDecider => {
120
+ const strategy = retryStrategy?.strategy;
121
+ if (strategy === 'no-retry') {
122
+ return () => Promise.resolve({ retryable: false });
123
+ }
124
+
125
+ return getRetryDecider(parseRestApiServiceError);
126
+ };
127
+
102
128
  const resolveCredentials = async (
103
129
  amplify: AmplifyClassV6,
104
130
  ): Promise<AWSCredentials | null> => {
@@ -1,6 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { DocumentType } from '@aws-amplify/core/internals/utils';
3
+ import { DocumentType, RetryStrategy } from '@aws-amplify/core/internals/utils';
4
4
 
5
5
  export type GetInput = ApiInput<RestApiOptionsBase>;
6
6
  export type PostInput = ApiInput<RestApiOptionsBase>;
@@ -82,6 +82,12 @@ export interface ApiInput<Options> {
82
82
  * Options to overwrite the REST API call behavior.
83
83
  */
84
84
  options?: Options;
85
+ /**
86
+ * Retry strategy for the REST API calls. It will take precedence over REST `retryStrategy` in Amplify configuration libraryOptions.
87
+ *
88
+ * @default ` { strategy: 'jittered-exponential-backoff' } `
89
+ */
90
+ retryStrategy?: RetryStrategy;
85
91
  }
86
92
 
87
93
  /**