@aws-amplify/api-rest 4.0.1-console-preview.3d7f188.0 → 4.0.1-mjs-test.20ead30.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.
- package/dist/cjs/apis/common/handler.js +75 -0
- package/dist/cjs/apis/common/handler.js.map +1 -0
- package/{lib → dist/cjs}/apis/common/internalPost.js +21 -19
- package/dist/cjs/apis/common/internalPost.js.map +1 -0
- package/dist/cjs/apis/common/publicApis.js +46 -0
- package/dist/cjs/apis/common/publicApis.js.map +1 -0
- package/{lib → dist/cjs}/apis/index.js +11 -17
- package/dist/cjs/apis/index.js.map +1 -0
- package/{lib → dist/cjs}/apis/server.js +11 -21
- package/dist/cjs/apis/server.js.map +1 -0
- package/{lib → dist/cjs}/errors/CanceledError.js +15 -16
- package/dist/cjs/errors/CanceledError.js.map +1 -0
- package/dist/cjs/errors/RestApiError.js +17 -0
- package/dist/cjs/errors/RestApiError.js.map +1 -0
- package/{lib → dist/cjs}/errors/assertValidatonError.js +7 -5
- package/dist/cjs/errors/assertValidatonError.js.map +1 -0
- package/{lib → dist/cjs}/errors/index.js +3 -1
- package/dist/cjs/errors/index.js.map +1 -0
- package/{lib → dist/cjs}/errors/validation.js +7 -6
- package/dist/cjs/errors/validation.js.map +1 -0
- package/{lib → dist/cjs}/index.js +3 -1
- package/dist/cjs/index.js.map +1 -0
- package/{lib → dist/cjs}/internals/index.js +6 -4
- package/dist/cjs/internals/index.js.map +1 -0
- package/{lib → dist/cjs}/internals/server.js +6 -4
- package/dist/cjs/internals/server.js.map +1 -0
- package/{lib → dist/cjs}/server.js +3 -1
- package/dist/cjs/server.js.map +1 -0
- package/{lib → dist/cjs}/types/index.js +3 -1
- package/dist/cjs/types/index.js.map +1 -0
- package/{lib → dist/cjs}/utils/constants.js +3 -1
- package/dist/cjs/utils/constants.js.map +1 -0
- package/dist/cjs/utils/createCancellableOperation.js +65 -0
- package/dist/cjs/utils/createCancellableOperation.js.map +1 -0
- package/{lib → dist/cjs}/utils/index.js +3 -1
- package/dist/cjs/utils/index.js.map +1 -0
- package/{lib → dist/cjs}/utils/logger.js +4 -2
- package/dist/cjs/utils/logger.js.map +1 -0
- package/{lib → dist/cjs}/utils/normalizeHeaders.js +6 -4
- package/dist/cjs/utils/normalizeHeaders.js.map +1 -0
- package/dist/cjs/utils/parseSigningInfo.js +43 -0
- package/dist/cjs/utils/parseSigningInfo.js.map +1 -0
- package/dist/cjs/utils/resolveApiUrl.js +42 -0
- package/dist/cjs/utils/resolveApiUrl.js.map +1 -0
- package/dist/cjs/utils/resolveCredentials.js +17 -0
- package/dist/cjs/utils/resolveCredentials.js.map +1 -0
- package/dist/cjs/utils/serviceError.js +32 -0
- package/dist/cjs/utils/serviceError.js.map +1 -0
- package/{lib-esm → dist/esm}/apis/common/handler.d.ts +1 -5
- package/dist/esm/apis/common/handler.mjs +78 -0
- package/dist/esm/apis/common/handler.mjs.map +1 -0
- package/{lib-esm/apis/common/internalPost.js → dist/esm/apis/common/internalPost.mjs} +26 -18
- package/dist/esm/apis/common/internalPost.mjs.map +1 -0
- package/dist/esm/apis/common/publicApis.mjs +45 -0
- package/dist/esm/apis/common/publicApis.mjs.map +1 -0
- package/{lib-esm/apis/index.js → dist/esm/apis/index.mjs} +12 -16
- package/dist/esm/apis/index.mjs.map +1 -0
- package/{lib-esm/apis/server.js → dist/esm/apis/server.mjs} +12 -20
- package/dist/esm/apis/server.mjs.map +1 -0
- package/dist/esm/errors/CanceledError.mjs +31 -0
- package/dist/esm/errors/CanceledError.mjs.map +1 -0
- package/dist/esm/errors/RestApiError.mjs +15 -0
- package/dist/esm/errors/RestApiError.mjs.map +1 -0
- package/dist/esm/errors/assertValidatonError.mjs +17 -0
- package/dist/esm/errors/assertValidatonError.mjs.map +1 -0
- package/dist/esm/errors/index.mjs +5 -0
- package/dist/esm/errors/index.mjs.map +1 -0
- package/{lib-esm/errors/validation.js → dist/esm/errors/validation.mjs} +8 -6
- package/dist/esm/errors/validation.mjs.map +1 -0
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/index.mjs.map +1 -0
- package/{lib-esm/internals/index.js → dist/esm/internals/index.mjs} +9 -5
- package/dist/esm/internals/index.mjs.map +1 -0
- package/{lib-esm/internals/server.js → dist/esm/internals/server.mjs} +9 -5
- package/dist/esm/internals/server.mjs.map +1 -0
- package/dist/esm/server.mjs +3 -0
- package/dist/esm/server.mjs.map +1 -0
- package/dist/esm/types/index.mjs +2 -0
- package/dist/esm/types/index.mjs.map +1 -0
- package/dist/esm/utils/constants.mjs +13 -0
- package/dist/esm/utils/constants.mjs.map +1 -0
- package/dist/esm/utils/createCancellableOperation.mjs +65 -0
- package/dist/esm/utils/createCancellableOperation.mjs.map +1 -0
- package/dist/esm/utils/index.mjs +7 -0
- package/dist/esm/utils/index.mjs.map +1 -0
- package/{lib-esm/utils/logger.js → dist/esm/utils/logger.mjs} +6 -2
- package/dist/esm/utils/logger.mjs.map +1 -0
- package/{lib-esm/utils/normalizeHeaders.js → dist/esm/utils/normalizeHeaders.mjs} +6 -3
- package/dist/esm/utils/normalizeHeaders.mjs.map +1 -0
- package/dist/esm/utils/parseSigningInfo.mjs +41 -0
- package/dist/esm/utils/parseSigningInfo.mjs.map +1 -0
- package/dist/esm/utils/resolveApiUrl.mjs +42 -0
- package/dist/esm/utils/resolveApiUrl.mjs.map +1 -0
- package/{lib → dist/esm}/utils/resolveCredentials.d.ts +1 -1
- package/dist/esm/utils/resolveCredentials.mjs +17 -0
- package/dist/esm/utils/resolveCredentials.mjs.map +1 -0
- package/dist/esm/utils/serviceError.mjs +30 -0
- package/dist/esm/utils/serviceError.mjs.map +1 -0
- package/internals/package.json +4 -4
- package/internals/server/package.json +3 -4
- package/package.json +63 -26
- package/server/package.json +3 -4
- package/lib/apis/common/handler.d.ts +0 -31
- package/lib/apis/common/handler.js +0 -79
- package/lib/apis/common/internalPost.d.ts +0 -16
- package/lib/apis/common/publicApis.d.ts +0 -8
- package/lib/apis/common/publicApis.js +0 -50
- package/lib/apis/index.d.ts +0 -203
- package/lib/apis/server.d.ts +0 -151
- package/lib/errors/CanceledError.d.ts +0 -17
- package/lib/errors/RestApiError.d.ts +0 -4
- package/lib/errors/RestApiError.js +0 -19
- package/lib/errors/assertValidatonError.d.ts +0 -5
- package/lib/errors/index.d.ts +0 -4
- package/lib/errors/validation.d.ts +0 -6
- package/lib/index.d.ts +0 -2
- package/lib/internals/index.d.ts +0 -19
- package/lib/internals/server.d.ts +0 -20
- package/lib/server.d.ts +0 -2
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/types/index.d.ts +0 -103
- package/lib/utils/constants.d.ts +0 -8
- package/lib/utils/createCancellableOperation.d.ts +0 -12
- package/lib/utils/createCancellableOperation.js +0 -70
- package/lib/utils/index.d.ts +0 -6
- package/lib/utils/logger.d.ts +0 -2
- package/lib/utils/normalizeHeaders.d.ts +0 -1
- package/lib/utils/parseSigningInfo.d.ts +0 -14
- package/lib/utils/parseSigningInfo.js +0 -42
- package/lib/utils/resolveApiUrl.d.ts +0 -12
- package/lib/utils/resolveApiUrl.js +0 -39
- package/lib/utils/resolveCredentials.js +0 -23
- package/lib/utils/serviceError.d.ts +0 -10
- package/lib/utils/serviceError.js +0 -38
- package/lib-esm/apis/common/handler.js +0 -75
- package/lib-esm/apis/common/publicApis.js +0 -41
- package/lib-esm/errors/CanceledError.js +0 -31
- package/lib-esm/errors/RestApiError.js +0 -16
- package/lib-esm/errors/assertValidatonError.js +0 -13
- package/lib-esm/errors/index.js +0 -6
- package/lib-esm/index.js +0 -4
- package/lib-esm/server.js +0 -4
- package/lib-esm/tsconfig.tsbuildinfo +0 -1
- package/lib-esm/types/index.js +0 -1
- package/lib-esm/utils/constants.js +0 -10
- package/lib-esm/utils/createCancellableOperation.js +0 -66
- package/lib-esm/utils/index.js +0 -8
- package/lib-esm/utils/parseSigningInfo.js +0 -38
- package/lib-esm/utils/resolveApiUrl.js +0 -35
- package/lib-esm/utils/resolveCredentials.d.ts +0 -5
- package/lib-esm/utils/resolveCredentials.js +0 -19
- package/lib-esm/utils/serviceError.js +0 -33
- /package/{lib-esm → dist/esm}/apis/common/internalPost.d.ts +0 -0
- /package/{lib-esm → dist/esm}/apis/common/publicApis.d.ts +0 -0
- /package/{lib-esm → dist/esm}/apis/index.d.ts +0 -0
- /package/{lib-esm → dist/esm}/apis/server.d.ts +0 -0
- /package/{lib-esm → dist/esm}/errors/CanceledError.d.ts +0 -0
- /package/{lib-esm → dist/esm}/errors/RestApiError.d.ts +0 -0
- /package/{lib-esm → dist/esm}/errors/assertValidatonError.d.ts +0 -0
- /package/{lib-esm → dist/esm}/errors/index.d.ts +0 -0
- /package/{lib-esm → dist/esm}/errors/validation.d.ts +0 -0
- /package/{lib-esm → dist/esm}/index.d.ts +0 -0
- /package/{lib-esm → dist/esm}/internals/index.d.ts +0 -0
- /package/{lib-esm → dist/esm}/internals/server.d.ts +0 -0
- /package/{lib-esm → dist/esm}/server.d.ts +0 -0
- /package/{lib-esm → dist/esm}/types/index.d.ts +0 -0
- /package/{lib-esm → dist/esm}/utils/constants.d.ts +0 -0
- /package/{lib-esm → dist/esm}/utils/createCancellableOperation.d.ts +0 -0
- /package/{lib-esm → dist/esm}/utils/index.d.ts +0 -0
- /package/{lib-esm → dist/esm}/utils/logger.d.ts +0 -0
- /package/{lib-esm → dist/esm}/utils/normalizeHeaders.d.ts +0 -0
- /package/{lib-esm → dist/esm}/utils/parseSigningInfo.d.ts +0 -0
- /package/{lib-esm → dist/esm}/utils/resolveApiUrl.d.ts +0 -0
- /package/{lib-esm → dist/esm}/utils/serviceError.d.ts +0 -0
|
@@ -0,0 +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 { transferHandler } from './handler';\nimport { createCancellableOperation } from '../../utils';\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 */\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 }, 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;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,cAAc,GAAG,IAAI,OAAO,EAAE,CAAC;AACrC;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,CAAC;AAChE,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,OAAO,EAAE,kBAAkB,CAAC,CAAC;AACxC,QAAQ,OAAO,QAAQ,CAAC;AACxB,KAAK,EAAE,UAAU,CAAC,CAAC;AACnB,IAAI,MAAM,mBAAmB,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM;AAC9D,QAAQ,cAAc,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;AACnD,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,mBAAmB,CAAC;AAC/B,EAAE;AACF;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK;AAC5C,IAAI,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACnD,IAAI,IAAI,UAAU,EAAE;AACpB,QAAQ,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAClC,QAAQ,IAAI,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE;AAC7D;AACA;AACA,YAAY,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC;AAClD,SAAS;AACT,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,OAAO,KAAK,CAAC;AACjB,EAAE;AACF;AACA;AACA;AACY,MAAC,4BAA4B,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK;AACrE,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAC5C;;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createCancellableOperation } from '../../utils/createCancellableOperation.mjs';
|
|
2
|
+
import '@aws-amplify/core/internals/utils';
|
|
3
|
+
import '../../errors/validation.mjs';
|
|
4
|
+
import { parseSigningInfo } from '../../utils/parseSigningInfo.mjs';
|
|
5
|
+
import '@aws-amplify/core/internals/aws-client-utils';
|
|
6
|
+
import { resolveApiUrl } from '../../utils/resolveApiUrl.mjs';
|
|
7
|
+
import { logger } from '../../utils/logger.mjs';
|
|
8
|
+
import { transferHandler } from './handler.mjs';
|
|
9
|
+
|
|
10
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
11
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
const publicHandler = (amplify, options, method) => createCancellableOperation(async (abortSignal) => {
|
|
13
|
+
const { apiName, options: apiOptions = {}, path: apiPath } = options;
|
|
14
|
+
const url = resolveApiUrl(amplify, apiName, apiPath, apiOptions?.queryParams);
|
|
15
|
+
const libraryOptionsHeaders = await amplify.libraryOptions?.API?.REST?.headers?.({
|
|
16
|
+
apiName,
|
|
17
|
+
});
|
|
18
|
+
const { headers: invocationHeaders = {} } = apiOptions;
|
|
19
|
+
const headers = {
|
|
20
|
+
// custom headers from invocation options should precede library options
|
|
21
|
+
...libraryOptionsHeaders,
|
|
22
|
+
...invocationHeaders,
|
|
23
|
+
};
|
|
24
|
+
const signingServiceInfo = parseSigningInfo(url, {
|
|
25
|
+
amplify,
|
|
26
|
+
apiName,
|
|
27
|
+
});
|
|
28
|
+
logger.debug(method, url, headers, `IAM signing options: ${JSON.stringify(signingServiceInfo)}`);
|
|
29
|
+
return transferHandler(amplify, {
|
|
30
|
+
...apiOptions,
|
|
31
|
+
url,
|
|
32
|
+
method,
|
|
33
|
+
headers,
|
|
34
|
+
abortSignal,
|
|
35
|
+
}, signingServiceInfo);
|
|
36
|
+
});
|
|
37
|
+
const get = (amplify, input) => publicHandler(amplify, input, 'GET');
|
|
38
|
+
const post = (amplify, input) => publicHandler(amplify, input, 'POST');
|
|
39
|
+
const put = (amplify, input) => publicHandler(amplify, input, 'PUT');
|
|
40
|
+
const del = (amplify, input) => publicHandler(amplify, input, 'DELETE');
|
|
41
|
+
const head = (amplify, input) => publicHandler(amplify, input, 'HEAD');
|
|
42
|
+
const patch = (amplify, input) => publicHandler(amplify, input, 'PATCH');
|
|
43
|
+
|
|
44
|
+
export { del, get, head, patch, post, put };
|
|
45
|
+
//# sourceMappingURL=publicApis.mjs.map
|
|
@@ -0,0 +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 { resolveApiUrl, createCancellableOperation, logger, parseSigningInfo, } from '../../utils';\nimport { transferHandler } from './handler';\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 libraryOptionsHeaders = 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 ...libraryOptionsHeaders,\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 }, 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;AAGA,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,GAAG,OAAO,CAAC;AACzE,IAAI,MAAM,GAAG,GAAG,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;AAClF,IAAI,MAAM,qBAAqB,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,GAAG;AACrF,QAAQ,OAAO;AACf,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,EAAE,EAAE,GAAG,UAAU,CAAC;AAC3D,IAAI,MAAM,OAAO,GAAG;AACpB;AACA,QAAQ,GAAG,qBAAqB;AAChC,QAAQ,GAAG,iBAAiB;AAC5B,KAAK,CAAC;AACN,IAAI,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,GAAG,EAAE;AACrD,QAAQ,OAAO;AACf,QAAQ,OAAO;AACf,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,qBAAqB,EAAE,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AACrG,IAAI,OAAO,eAAe,CAAC,OAAO,EAAE;AACpC,QAAQ,GAAG,UAAU;AACrB,QAAQ,GAAG;AACX,QAAQ,MAAM;AACd,QAAQ,OAAO;AACf,QAAQ,WAAW;AACnB,KAAK,EAAE,kBAAkB,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC;AACS,MAAC,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE;AAChE,MAAC,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE;AAClE,MAAC,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE;AAChE,MAAC,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE;AACnE,MAAC,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE;AAClE,MAAC,KAAK,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO;;;;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Amplify } from '@aws-amplify/core';
|
|
2
|
+
import { get as get$1, post as post$1, put as put$1, del as del$1, head as head$1, patch as patch$1 } from './common/publicApis.mjs';
|
|
3
|
+
|
|
1
4
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
5
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { Amplify } from '@aws-amplify/core';
|
|
4
|
-
import { get as commonGet, post as commonPost, put as commonPut, del as commonDel, head as commonHead, patch as commonPatch, } from './common/publicApis';
|
|
5
6
|
/**
|
|
6
7
|
* GET HTTP request
|
|
7
8
|
* @param {GetInput} input - Input for GET operation
|
|
@@ -41,7 +42,7 @@ import { get as commonGet, post as commonPost, put as commonPut, del as commonDe
|
|
|
41
42
|
* }
|
|
42
43
|
* ```
|
|
43
44
|
*/
|
|
44
|
-
|
|
45
|
+
const get = (input) => get$1(Amplify, input);
|
|
45
46
|
/**
|
|
46
47
|
* POST HTTP request
|
|
47
48
|
* @param {PostInput} input - Input for POST operation
|
|
@@ -81,9 +82,7 @@ export var get = function (input) { return commonGet(Amplify, input); };
|
|
|
81
82
|
* }
|
|
82
83
|
* ```
|
|
83
84
|
*/
|
|
84
|
-
|
|
85
|
-
return commonPost(Amplify, input);
|
|
86
|
-
};
|
|
85
|
+
const post = (input) => post$1(Amplify, input);
|
|
87
86
|
/**
|
|
88
87
|
* PUT HTTP request
|
|
89
88
|
* @param {PutInput} input - Input for PUT operation
|
|
@@ -122,7 +121,7 @@ export var post = function (input) {
|
|
|
122
121
|
* }
|
|
123
122
|
* ```
|
|
124
123
|
*/
|
|
125
|
-
|
|
124
|
+
const put = (input) => put$1(Amplify, input);
|
|
126
125
|
/**
|
|
127
126
|
* DELETE HTTP request
|
|
128
127
|
* @param {DeleteInput} input - Input for DELETE operation
|
|
@@ -143,9 +142,7 @@ export var put = function (input) { return commonPut(Amplify, input); };
|
|
|
143
142
|
* }).response;
|
|
144
143
|
* ```
|
|
145
144
|
*/
|
|
146
|
-
|
|
147
|
-
return commonDel(Amplify, input);
|
|
148
|
-
};
|
|
145
|
+
const del = (input) => del$1(Amplify, input);
|
|
149
146
|
/**
|
|
150
147
|
* HEAD HTTP request
|
|
151
148
|
* @param {HeadInput} input - Input for HEAD operation
|
|
@@ -167,9 +164,7 @@ export var del = function (input) {
|
|
|
167
164
|
* ```
|
|
168
165
|
*
|
|
169
166
|
*/
|
|
170
|
-
|
|
171
|
-
return commonHead(Amplify, input);
|
|
172
|
-
};
|
|
167
|
+
const head = (input) => head$1(Amplify, input);
|
|
173
168
|
/**
|
|
174
169
|
* PATCH HTTP request
|
|
175
170
|
* @param {PatchInput} input - Input for PATCH operation
|
|
@@ -209,6 +204,7 @@ export var head = function (input) {
|
|
|
209
204
|
* }
|
|
210
205
|
* ```
|
|
211
206
|
*/
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
};
|
|
207
|
+
const patch = (input) => patch$1(Amplify, input);
|
|
208
|
+
|
|
209
|
+
export { del, get, head, patch, post, put };
|
|
210
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/apis/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { get as commonGet, post as commonPost, put as commonPut, del as commonDel, head as commonHead, patch as commonPatch, } from './common/publicApis';\n/**\n * GET HTTP request\n * @param {GetInput} input - Input for GET operation\n * @returns {GetOperation} Operation for GET request\n * @throws - {@link RestApiError}\n * @example\n * Send a GET request\n * ```js\n * import { get, isCancelError } from '@aws-amplify/api';\n *\n * const { body } = await get({\n * apiName,\n * path,\n * options: {\n * headers, // Optional, A map of custom header key/values\n * body, // Optional, JSON object or FormData\n * queryParams, // Optional, A map of query strings\n * }\n * }).response;\n * const data = await body.json();\n * ```\n * @example\n * Cancel a GET request\n *\n * ```js\n * import { get, isCancelError } from '@aws-amplify/api';\n *\n * const { response, cancel } = get({apiName, path, options});\n * cancel(message);\n * try {\n * await response;\n * } cache (e) {\n * if (isCancelError(e)) {\n * // handle request cancellation\n * }\n * //...\n * }\n * ```\n */\nexport const get = (input) => commonGet(Amplify, input);\n/**\n * POST HTTP request\n * @param {PostInput} input - Input for POST operation\n * @returns {PostOperation} Operation for POST request\n * @throws - {@link RestApiError}\n * @example\n * Send a POST request\n * ```js\n * import { post, isCancelError } from '@aws-amplify/api';\n *\n * const { body } = await post({\n * apiName,\n * path,\n * options: {\n * headers, // Optional, A map of custom header key/values\n * body, // Optional, JSON object or FormData\n * queryParams, // Optional, A map of query strings\n * }\n * }).response;\n * const data = await body.json();\n * ```\n * @example\n * Cancel a POST request\n *\n * ```js\n * import { post, isCancelError } from '@aws-amplify/api';\n *\n * const { response, cancel } = post({apiName, path, options});\n * cancel(message);\n * try {\n * await response;\n * } cache (e) {\n * if (isCancelError(e)) {\n * // handle request cancellation\n * }\n * //...\n * }\n * ```\n */\nexport const post = (input) => commonPost(Amplify, input);\n/**\n * PUT HTTP request\n * @param {PutInput} input - Input for PUT operation\n * @returns {PutOperation} Operation for PUT request\n * @throws - {@link RestApiError}\n * @example\n * Send a PUT request\n * ```js\n * import { put, isCancelError } from '@aws-amplify/api';\n *\n * const { body } = await put({\n * apiName,\n * path,\n * options: {\n * headers, // Optional, A map of custom header key/values\n * body, // Optional, JSON object or FormData\n * queryParams, // Optional, A map of query strings\n * }\n * }).response;\n * const data = await body.json();\n * ```\n * @example\n * Cancel a PUT request\n * ```js\n * import { put, isCancelError } from '@aws-amplify/api';\n *\n * const { response, cancel } = put({apiName, path, options});\n * cancel(message);\n * try {\n * await response;\n * } cache (e) {\n * if (isCancelError(e)) {\n * // handle request cancellation\n * }\n * //...\n * }\n * ```\n */\nexport const put = (input) => commonPut(Amplify, input);\n/**\n * DELETE HTTP request\n * @param {DeleteInput} input - Input for DELETE operation\n * @returns {DeleteOperation} Operation for DELETE request\n * @throws - {@link RestApiError}\n * @example\n * Send a DELETE request\n * ```js\n * import { del } from '@aws-amplify/api';\n *\n * const { statusCode } = await del({\n * apiName,\n * path,\n * options: {\n * headers, // Optional, A map of custom header key/values\n * queryParams, // Optional, A map of query strings\n * }\n * }).response;\n * ```\n */\nexport const del = (input) => commonDel(Amplify, input);\n/**\n * HEAD HTTP request\n * @param {HeadInput} input - Input for HEAD operation\n * @returns {HeadOperation} Operation for HEAD request\n * @throws - {@link RestApiError}\n * @example\n * Send a HEAD request\n * ```js\n * import { head, isCancelError } from '@aws-amplify/api';\n *\n * const { headers, statusCode } = await head({\n * apiName,\n * path,\n * options: {\n * headers, // Optional, A map of custom header key/values\n * queryParams, // Optional, A map of query strings\n * }\n * }),response;\n * ```\n *\n */\nexport const head = (input) => commonHead(Amplify, input);\n/**\n * PATCH HTTP request\n * @param {PatchInput} input - Input for PATCH operation\n * @returns {PatchOperation} Operation for PATCH request\n * @throws - {@link RestApiError}\n * @example\n * Send a PATCH request\n * ```js\n * import { patch } from '@aws-amplify/api';\n *\n * const { body } = await patch({\n * apiName,\n * path,\n * options: {\n * headers, // Optional, A map of custom header key/values\n * body, // Optional, JSON object or FormData\n * queryParams, // Optional, A map of query strings\n * }\n * }).response;\n * const data = await body.json();\n * ```\n *\n * @example\n * Cancel a PATCH request\n * ```js\n * import { patch, isCancelError } from '@aws-amplify/api';\n *\n * const { response, cancel } = patch({apiName, path, options});\n * cancel(message);\n * try {\n * await response;\n * } cache (e) {\n * if (isCancelError(e)) {\n * // handle request cancellation\n * }\n * //...\n * }\n * ```\n */\nexport const patch = (input) => commonPatch(Amplify, input);\n"],"names":["commonGet","commonPost","commonPut","commonDel","commonHead","commonPatch"],"mappings":";;;AAAA;AACA;AAGA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,KAAK,KAAKA,KAAS,CAAC,OAAO,EAAE,KAAK,EAAE;AACxD;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,CAAC,KAAK,KAAKC,MAAU,CAAC,OAAO,EAAE,KAAK,EAAE;AAC1D;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,KAAK,KAAKC,KAAS,CAAC,OAAO,EAAE,KAAK,EAAE;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,KAAK,KAAKC,KAAS,CAAC,OAAO,EAAE,KAAK,EAAE;AACxD;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,KAAK,KAAKC,MAAU,CAAC,OAAO,EAAE,KAAK,EAAE;AAC1D;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,KAAK,GAAG,CAAC,KAAK,KAAKC,OAAW,CAAC,OAAO,EAAE,KAAK;;;;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { getAmplifyServerContext } from '@aws-amplify/core/internals/adapter-core';
|
|
2
|
+
import { get as get$1, post as post$1, put as put$1, del as del$1, head as head$1, patch as patch$1 } from './common/publicApis.mjs';
|
|
3
|
+
|
|
1
4
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
5
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { getAmplifyServerContext, } from '@aws-amplify/core/internals/adapter-core';
|
|
4
|
-
import { get as commonGet, post as commonPost, put as commonPut, del as commonDel, head as commonHead, patch as commonPatch, } from './common/publicApis';
|
|
5
6
|
/**
|
|
6
7
|
* GET HTTP request (server-side)
|
|
7
8
|
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
@@ -27,9 +28,7 @@ import { get as commonGet, post as commonPost, put as commonPut, del as commonDe
|
|
|
27
28
|
* ```
|
|
28
29
|
* @see {@link clientGet}
|
|
29
30
|
*/
|
|
30
|
-
|
|
31
|
-
return commonGet(getAmplifyServerContext(contextSpec).amplify, input);
|
|
32
|
-
};
|
|
31
|
+
const get = (contextSpec, input) => get$1(getAmplifyServerContext(contextSpec).amplify, input);
|
|
33
32
|
/**
|
|
34
33
|
* POST HTTP request (server-side)
|
|
35
34
|
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
@@ -54,9 +53,7 @@ export var get = function (contextSpec, input) {
|
|
|
54
53
|
* });
|
|
55
54
|
* ```
|
|
56
55
|
*/
|
|
57
|
-
|
|
58
|
-
return commonPost(getAmplifyServerContext(contextSpec).amplify, input);
|
|
59
|
-
};
|
|
56
|
+
const post = (contextSpec, input) => post$1(getAmplifyServerContext(contextSpec).amplify, input);
|
|
60
57
|
/**
|
|
61
58
|
* PUT HTTP request (server-side)
|
|
62
59
|
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
@@ -81,9 +78,7 @@ export var post = function (contextSpec, input) {
|
|
|
81
78
|
* });
|
|
82
79
|
* ```
|
|
83
80
|
*/
|
|
84
|
-
|
|
85
|
-
return commonPut(getAmplifyServerContext(contextSpec).amplify, input);
|
|
86
|
-
};
|
|
81
|
+
const put = (contextSpec, input) => put$1(getAmplifyServerContext(contextSpec).amplify, input);
|
|
87
82
|
/**
|
|
88
83
|
* DELETE HTTP request (server-side)
|
|
89
84
|
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
@@ -107,9 +102,7 @@ export var put = function (contextSpec, input) {
|
|
|
107
102
|
* });
|
|
108
103
|
* ```
|
|
109
104
|
*/
|
|
110
|
-
|
|
111
|
-
return commonDel(getAmplifyServerContext(contextSpec).amplify, input);
|
|
112
|
-
};
|
|
105
|
+
const del = (contextSpec, input) => del$1(getAmplifyServerContext(contextSpec).amplify, input);
|
|
113
106
|
/**
|
|
114
107
|
* HEAD HTTP request (server-side)
|
|
115
108
|
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
@@ -133,9 +126,7 @@ export var del = function (contextSpec, input) {
|
|
|
133
126
|
* });
|
|
134
127
|
* ```
|
|
135
128
|
*/
|
|
136
|
-
|
|
137
|
-
return commonHead(getAmplifyServerContext(contextSpec).amplify, input);
|
|
138
|
-
};
|
|
129
|
+
const head = (contextSpec, input) => head$1(getAmplifyServerContext(contextSpec).amplify, input);
|
|
139
130
|
/**
|
|
140
131
|
* PATCH HTTP request (server-side)
|
|
141
132
|
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
@@ -160,6 +151,7 @@ export var head = function (contextSpec, input) {
|
|
|
160
151
|
* });
|
|
161
152
|
* ```
|
|
162
153
|
*/
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
};
|
|
154
|
+
const patch = (contextSpec, input) => patch$1(getAmplifyServerContext(contextSpec).amplify, input);
|
|
155
|
+
|
|
156
|
+
export { del, get, head, patch, post, put };
|
|
157
|
+
//# sourceMappingURL=server.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.mjs","sources":["../../../src/apis/server.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getAmplifyServerContext, } from '@aws-amplify/core/internals/adapter-core';\nimport { get as commonGet, post as commonPost, put as commonPut, del as commonDel, head as commonHead, patch as commonPatch, } from './common/publicApis';\n/**\n * GET HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {GetInput} input - Input for GET operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a GET request\n * ```js\n * import { get } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: async (contextSpec) => {\n * try {\n * const { body } = await get(contextSpec, input).response;\n * return await body.json();\n * } catch (error) {\n * console.log(error);\n * return false;\n * }\n * },\n * });\n * ```\n * @see {@link clientGet}\n */\nexport const get = (contextSpec, input) => commonGet(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * POST HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {PostInput} input - Input for POST operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a POST request\n * ```js\n * import { post } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: async (contextSpec) => {\n * try {\n * const { body } = await post(contextSpec, input).response;\n * return await body.json();\n * } catch (error) {\n * console.log(error);\n * return false;\n * }\n * },\n * });\n * ```\n */\nexport const post = (contextSpec, input) => commonPost(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * PUT HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {PutInput} input - Input for PUT operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a PUT request\n * ```js\n * import { put } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: async (contextSpec) => {\n * try {\n * const { body } = await put(contextSpec, input).response;\n * return await body.json();\n * } catch (error) {\n * console.log(error);\n * return false;\n * }\n * },\n * });\n * ```\n */\nexport const put = (contextSpec, input) => commonPut(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * DELETE HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {DeleteInput} input - Input for DELETE operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a DELETE request\n * ```js\n * import { del } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: async (contextSpec) => {\n * try {\n * const { headers } = await del(contextSpec, input).response;\n * } catch (error) {\n * console.log(error);\n * return false;\n * }\n * },\n * });\n * ```\n */\nexport const del = (contextSpec, input) => commonDel(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * HEAD HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {HeadInput} input - Input for HEAD operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a HEAD request\n * ```js\n * import { head } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: async (contextSpec) => {\n * try {\n * const { headers } = await head(contextSpec, input).response;\n * } catch (error) {\n * console.log(error);\n * return false;\n * }\n * },\n * });\n * ```\n */\nexport const head = (contextSpec, input) => commonHead(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * PATCH HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {PatchInput} input - Input for PATCH operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a PATCH request\n * ```js\n * import { patch } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: async (contextSpec) => {\n * try {\n * const { body } = await patch(contextSpec, input).response;\n * return await body.json();\n * } catch (error) {\n * console.log(error);\n * return false;\n * }\n * },\n * });\n * ```\n */\nexport const patch = (contextSpec, input) => commonPatch(getAmplifyServerContext(contextSpec).amplify, input);\n"],"names":["commonGet","commonPost","commonPut","commonDel","commonHead","commonPatch"],"mappings":";;;AAAA;AACA;AAGA;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,GAAG,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKA,KAAS,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE;AAC1G;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,WAAW,EAAE,KAAK,KAAKC,MAAU,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE;AAC5G;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,GAAG,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKC,KAAS,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE;AAC1G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKC,KAAS,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE;AAC1G;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,WAAW,EAAE,KAAK,KAAKC,MAAU,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE;AAC5G;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,KAAK,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKC,OAAW,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RestApiError } from './RestApiError.mjs';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
/**
|
|
6
|
+
* Internal-only class for CanceledError.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
class CanceledError extends RestApiError {
|
|
11
|
+
constructor(params = {}) {
|
|
12
|
+
super({
|
|
13
|
+
name: 'CanceledError',
|
|
14
|
+
message: 'Request is canceled by user',
|
|
15
|
+
...params,
|
|
16
|
+
});
|
|
17
|
+
// TODO: Delete the following 2 lines after we change the build target to >= es2015
|
|
18
|
+
this.constructor = CanceledError;
|
|
19
|
+
Object.setPrototypeOf(this, CanceledError.prototype);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check if an error is caused by user calling `cancel()` in REST API.
|
|
24
|
+
*
|
|
25
|
+
* @note This function works **ONLY** for errors thrown by REST API. For GraphQL APIs, use `client.isCancelError(error)`
|
|
26
|
+
* instead. `client` is generated from `generateClient()` API from `aws-amplify/api`.
|
|
27
|
+
*/
|
|
28
|
+
const isCancelError = (error) => !!error && error instanceof CanceledError;
|
|
29
|
+
|
|
30
|
+
export { CanceledError, isCancelError };
|
|
31
|
+
//# sourceMappingURL=CanceledError.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CanceledError.mjs","sources":["../../../src/errors/CanceledError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { RestApiError } from './RestApiError';\n/**\n * Internal-only class for CanceledError.\n *\n * @internal\n */\nexport class CanceledError extends RestApiError {\n constructor(params = {}) {\n super({\n name: 'CanceledError',\n message: 'Request is canceled by user',\n ...params,\n });\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = CanceledError;\n Object.setPrototypeOf(this, CanceledError.prototype);\n }\n}\n/**\n * Check if an error is caused by user calling `cancel()` in REST API.\n *\n * @note This function works **ONLY** for errors thrown by REST API. For GraphQL APIs, use `client.isCancelError(error)`\n * instead. `client` is generated from `generateClient()` API from `aws-amplify/api`.\n */\nexport const isCancelError = (error) => !!error && error instanceof CanceledError;\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,aAAa,SAAS,YAAY,CAAC;AAChD,IAAI,WAAW,CAAC,MAAM,GAAG,EAAE,EAAE;AAC7B,QAAQ,KAAK,CAAC;AACd,YAAY,IAAI,EAAE,eAAe;AACjC,YAAY,OAAO,EAAE,6BAA6B;AAClD,YAAY,GAAG,MAAM;AACrB,SAAS,CAAC,CAAC;AACX;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC;AACzC,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;AAC7D,KAAK;AACL,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,aAAa,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,IAAI,KAAK,YAAY;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AmplifyError } from '@aws-amplify/core/internals/utils';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
class RestApiError extends AmplifyError {
|
|
6
|
+
constructor(params) {
|
|
7
|
+
super(params);
|
|
8
|
+
// TODO: Delete the following 2 lines after we change the build target to >= es2015
|
|
9
|
+
this.constructor = RestApiError;
|
|
10
|
+
Object.setPrototypeOf(this, RestApiError.prototype);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { RestApiError };
|
|
15
|
+
//# sourceMappingURL=RestApiError.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RestApiError.mjs","sources":["../../../src/errors/RestApiError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyError, } from '@aws-amplify/core/internals/utils';\nexport class RestApiError extends AmplifyError {\n constructor(params) {\n super(params);\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = RestApiError;\n Object.setPrototypeOf(this, RestApiError.prototype);\n }\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEO,MAAM,YAAY,SAAS,YAAY,CAAC;AAC/C,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,KAAK,CAAC,MAAM,CAAC,CAAC;AACtB;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,YAAY,CAAC;AACxC,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;AAC5D,KAAK;AACL;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RestApiError } from './RestApiError.mjs';
|
|
2
|
+
import { validationErrorMap } from './validation.mjs';
|
|
3
|
+
|
|
4
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
function assertValidationError(assertion, name) {
|
|
10
|
+
const { message, recoverySuggestion } = validationErrorMap[name];
|
|
11
|
+
if (!assertion) {
|
|
12
|
+
throw new RestApiError({ name, message, recoverySuggestion });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { assertValidationError };
|
|
17
|
+
//# sourceMappingURL=assertValidatonError.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertValidatonError.mjs","sources":["../../../src/errors/assertValidatonError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { RestApiError } from './RestApiError';\nimport { validationErrorMap } from './validation';\n/**\n * @internal\n */\nexport function assertValidationError(assertion, name) {\n const { message, recoverySuggestion } = validationErrorMap[name];\n if (!assertion) {\n throw new RestApiError({ name, message, recoverySuggestion });\n }\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACO,SAAS,qBAAqB,CAAC,SAAS,EAAE,IAAI,EAAE;AACvD,IAAI,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;AACrE,IAAI,IAAI,CAAC,SAAS,EAAE;AACpB,QAAQ,MAAM,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAC;AACtE,KAAK;AACL;;;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { CanceledError, isCancelError } from './CanceledError.mjs';
|
|
2
|
+
export { RestApiError } from './RestApiError.mjs';
|
|
3
|
+
export { assertValidationError } from './assertValidatonError.mjs';
|
|
4
|
+
export { RestApiValidationErrorCode, validationErrorMap } from './validation.mjs';
|
|
5
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
var
|
|
4
|
-
export var RestApiValidationErrorCode;
|
|
3
|
+
var RestApiValidationErrorCode;
|
|
5
4
|
(function (RestApiValidationErrorCode) {
|
|
6
5
|
RestApiValidationErrorCode["NoCredentials"] = "NoCredentials";
|
|
7
6
|
RestApiValidationErrorCode["InvalidApiName"] = "InvalidApiName";
|
|
8
7
|
})(RestApiValidationErrorCode || (RestApiValidationErrorCode = {}));
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const validationErrorMap = {
|
|
9
|
+
[RestApiValidationErrorCode.NoCredentials]: {
|
|
11
10
|
message: 'Credentials should not be empty.',
|
|
12
11
|
},
|
|
13
|
-
|
|
12
|
+
[RestApiValidationErrorCode.InvalidApiName]: {
|
|
14
13
|
message: 'API name is invalid.',
|
|
15
14
|
recoverySuggestion: 'Check if the API name matches the one in your configuration or `aws-exports.js`',
|
|
16
15
|
},
|
|
17
|
-
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { RestApiValidationErrorCode, validationErrorMap };
|
|
19
|
+
//# sourceMappingURL=validation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.mjs","sources":["../../../src/errors/validation.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport var RestApiValidationErrorCode;\n(function (RestApiValidationErrorCode) {\n RestApiValidationErrorCode[\"NoCredentials\"] = \"NoCredentials\";\n RestApiValidationErrorCode[\"InvalidApiName\"] = \"InvalidApiName\";\n})(RestApiValidationErrorCode || (RestApiValidationErrorCode = {}));\nexport const validationErrorMap = {\n [RestApiValidationErrorCode.NoCredentials]: {\n message: 'Credentials should not be empty.',\n },\n [RestApiValidationErrorCode.InvalidApiName]: {\n message: 'API name is invalid.',\n recoverySuggestion: 'Check if the API name matches the one in your configuration or `aws-exports.js`',\n },\n};\n"],"names":[],"mappings":"AAAA;AACA;AACU,IAAC,2BAA2B;AACtC,CAAC,UAAU,0BAA0B,EAAE;AACvC,IAAI,0BAA0B,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;AAClE,IAAI,0BAA0B,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;AACpE,CAAC,EAAE,0BAA0B,KAAK,0BAA0B,GAAG,EAAE,CAAC,CAAC,CAAC;AACxD,MAAC,kBAAkB,GAAG;AAClC,IAAI,CAAC,0BAA0B,CAAC,aAAa,GAAG;AAChD,QAAQ,OAAO,EAAE,kCAAkC;AACnD,KAAK;AACL,IAAI,CAAC,0BAA0B,CAAC,cAAc,GAAG;AACjD,QAAQ,OAAO,EAAE,sBAAsB;AACvC,QAAQ,kBAAkB,EAAE,iFAAiF;AAC7G,KAAK;AACL;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Amplify } from '@aws-amplify/core';
|
|
2
|
+
import { post as post$1 } from '../apis/common/internalPost.mjs';
|
|
3
|
+
export { cancel, updateRequestToBeCancellable } from '../apis/common/internalPost.mjs';
|
|
4
|
+
|
|
1
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { Amplify } from '@aws-amplify/core';
|
|
4
|
-
import { post as internalPost } from '../apis/common/internalPost';
|
|
5
7
|
/**
|
|
6
8
|
* Internal-only REST POST handler to send GraphQL request to given endpoint. By default, it will use IAM to authorize
|
|
7
9
|
* the request. In some auth modes, the IAM auth has to be disabled. Here's how to set up the request auth correctly:
|
|
@@ -18,7 +20,9 @@ import { post as internalPost } from '../apis/common/internalPost';
|
|
|
18
20
|
*
|
|
19
21
|
* @internal
|
|
20
22
|
*/
|
|
21
|
-
|
|
22
|
-
return
|
|
23
|
+
const post = (input) => {
|
|
24
|
+
return post$1(Amplify, input);
|
|
23
25
|
};
|
|
24
|
-
|
|
26
|
+
|
|
27
|
+
export { post };
|
|
28
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/internals/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { post as internalPost } from '../apis/common/internalPost';\n/**\n * Internal-only 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 * @internal\n */\nexport const post = (input) => {\n return internalPost(Amplify, input);\n};\nexport { cancel, updateRequestToBeCancellable, } from '../apis/common/internalPost';\n"],"names":["internalPost"],"mappings":";;;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,CAAC,KAAK,KAAK;AAC/B,IAAI,OAAOA,MAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACxC;;;;"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { getAmplifyServerContext } from '@aws-amplify/core/internals/adapter-core';
|
|
2
|
+
import { post as post$1 } from '../apis/common/internalPost.mjs';
|
|
3
|
+
export { cancel, updateRequestToBeCancellable } from '../apis/common/internalPost.mjs';
|
|
4
|
+
|
|
1
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { getAmplifyServerContext, } from '@aws-amplify/core/internals/adapter-core';
|
|
4
|
-
import { post as internalPost } from '../apis/common/internalPost';
|
|
5
7
|
/**
|
|
6
8
|
* Internal-only REST POST handler to send GraphQL request to given endpoint. By default, it will use IAM to authorize
|
|
7
9
|
* the request. In some auth modes, the IAM auth has to be disabled. Here's how to set up the request auth correctly:
|
|
@@ -18,7 +20,9 @@ import { post as internalPost } from '../apis/common/internalPost';
|
|
|
18
20
|
*
|
|
19
21
|
* @internal
|
|
20
22
|
*/
|
|
21
|
-
|
|
22
|
-
return
|
|
23
|
+
const post = (contextSpec, input) => {
|
|
24
|
+
return post$1(getAmplifyServerContext(contextSpec).amplify, input);
|
|
23
25
|
};
|
|
24
|
-
|
|
26
|
+
|
|
27
|
+
export { post };
|
|
28
|
+
//# sourceMappingURL=server.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.mjs","sources":["../../../src/internals/server.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getAmplifyServerContext, } from '@aws-amplify/core/internals/adapter-core';\nimport { post as internalPost } from '../apis/common/internalPost';\n/**\n * Internal-only 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 * @internal\n */\nexport const post = (contextSpec, input) => {\n return internalPost(getAmplifyServerContext(contextSpec).amplify, input);\n};\nexport { cancel, updateRequestToBeCancellable, } from '../apis/common/internalPost';\n"],"names":["internalPost"],"mappings":";;;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,KAAK;AAC5C,IAAI,OAAOA,MAAY,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC7E;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
const DEFAULT_REST_IAM_SIGNING_SERVICE = 'execute-api';
|
|
4
|
+
const DEFAULT_APPSYNC_API_SERVICE = 'appsync-api';
|
|
5
|
+
const DEFAULT_IAM_SIGNING_REGION = 'us-east-1';
|
|
6
|
+
/**
|
|
7
|
+
* The REST endpoints generated by API Gateway
|
|
8
|
+
* @see {@link https://docs.aws.amazon.com/general/latest/gr/apigateway.html#apigateway_region_data_plane}
|
|
9
|
+
*/
|
|
10
|
+
const APIG_HOSTNAME_PATTERN = /^.+\.([a-z0-9-]+)\.([a-z0-9-]+)\.amazonaws\.com/;
|
|
11
|
+
|
|
12
|
+
export { APIG_HOSTNAME_PATTERN, DEFAULT_APPSYNC_API_SERVICE, DEFAULT_IAM_SIGNING_REGION, DEFAULT_REST_IAM_SIGNING_SERVICE };
|
|
13
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sources":["../../../src/utils/constants.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport const DEFAULT_REST_IAM_SIGNING_SERVICE = 'execute-api';\nexport const DEFAULT_APPSYNC_API_SERVICE = 'appsync-api';\nexport const DEFAULT_IAM_SIGNING_REGION = 'us-east-1';\n/**\n * The REST endpoints generated by API Gateway\n * @see {@link https://docs.aws.amazon.com/general/latest/gr/apigateway.html#apigateway_region_data_plane}\n */\nexport const APIG_HOSTNAME_PATTERN = /^.+\\.([a-z0-9-]+)\\.([a-z0-9-]+)\\.amazonaws\\.com/;\n"],"names":[],"mappings":"AAAA;AACA;AACY,MAAC,gCAAgC,GAAG,cAAc;AAClD,MAAC,2BAA2B,GAAG,cAAc;AAC7C,MAAC,0BAA0B,GAAG,YAAY;AACtD;AACA;AACA;AACA;AACY,MAAC,qBAAqB,GAAG;;;;"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CanceledError } from '../errors/CanceledError.mjs';
|
|
2
|
+
import '@aws-amplify/core/internals/utils';
|
|
3
|
+
import '../errors/validation.mjs';
|
|
4
|
+
import { parseRestApiServiceError } from './serviceError.mjs';
|
|
5
|
+
import { logger } from './logger.mjs';
|
|
6
|
+
|
|
7
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
function createCancellableOperation(handler, abortController) {
|
|
13
|
+
const isInternalPost = (handler) => !!abortController;
|
|
14
|
+
// For creating a cancellable operation for public REST APIs, we need to create an AbortController
|
|
15
|
+
// internally. Whereas for internal POST APIs, we need to accept in the AbortController from the
|
|
16
|
+
// callers.
|
|
17
|
+
const publicApisAbortController = new AbortController();
|
|
18
|
+
const publicApisAbortSignal = publicApisAbortController.signal;
|
|
19
|
+
const internalPostAbortSignal = abortController?.signal;
|
|
20
|
+
const job = async () => {
|
|
21
|
+
try {
|
|
22
|
+
const response = await (isInternalPost(handler)
|
|
23
|
+
? handler()
|
|
24
|
+
: handler(publicApisAbortSignal));
|
|
25
|
+
if (response.statusCode >= 300) {
|
|
26
|
+
throw await parseRestApiServiceError(response);
|
|
27
|
+
}
|
|
28
|
+
return response;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
const abortSignal = internalPostAbortSignal ?? publicApisAbortSignal;
|
|
32
|
+
if (error.name === 'AbortError' || abortSignal?.aborted === true) {
|
|
33
|
+
const canceledError = new CanceledError({
|
|
34
|
+
...(abortSignal.reason ? { message: abortSignal.reason } : undefined),
|
|
35
|
+
underlyingError: error,
|
|
36
|
+
});
|
|
37
|
+
logger.debug(error);
|
|
38
|
+
throw canceledError;
|
|
39
|
+
}
|
|
40
|
+
logger.debug(error);
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
if (isInternalPost()) {
|
|
45
|
+
return job();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const cancel = (abortMessage) => {
|
|
49
|
+
if (publicApisAbortSignal.aborted === true) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
publicApisAbortController.abort(abortMessage);
|
|
53
|
+
// Abort reason is not widely support enough across runtimes and and browsers, so we set it
|
|
54
|
+
// if it is not already set.
|
|
55
|
+
if (abortMessage && publicApisAbortSignal.reason !== abortMessage) {
|
|
56
|
+
publicApisAbortSignal['reason'] =
|
|
57
|
+
abortMessage;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return { response: job(), cancel };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { createCancellableOperation };
|
|
65
|
+
//# sourceMappingURL=createCancellableOperation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createCancellableOperation.mjs","sources":["../../../src/utils/createCancellableOperation.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { CanceledError } from '../errors';\nimport { parseRestApiServiceError } from './serviceError';\nimport { logger } from './logger';\n/**\n * @internal\n */\nexport function createCancellableOperation(handler, abortController) {\n const isInternalPost = (handler) => !!abortController;\n // For creating a cancellable operation for public REST APIs, we need to create an AbortController\n // internally. Whereas for internal POST APIs, we need to accept in the AbortController from the\n // callers.\n const publicApisAbortController = new AbortController();\n const publicApisAbortSignal = publicApisAbortController.signal;\n const internalPostAbortSignal = abortController?.signal;\n const job = async () => {\n try {\n const response = await (isInternalPost(handler)\n ? handler()\n : handler(publicApisAbortSignal));\n if (response.statusCode >= 300) {\n throw await parseRestApiServiceError(response);\n }\n return response;\n }\n catch (error) {\n const abortSignal = internalPostAbortSignal ?? publicApisAbortSignal;\n if (error.name === 'AbortError' || abortSignal?.aborted === true) {\n const canceledError = new CanceledError({\n ...(abortSignal.reason ? { message: abortSignal.reason } : undefined),\n underlyingError: error,\n });\n logger.debug(error);\n throw canceledError;\n }\n logger.debug(error);\n throw error;\n }\n };\n if (isInternalPost(handler)) {\n return job();\n }\n else {\n const cancel = (abortMessage) => {\n if (publicApisAbortSignal.aborted === true) {\n return;\n }\n publicApisAbortController.abort(abortMessage);\n // Abort reason is not widely support enough across runtimes and and browsers, so we set it\n // if it is not already set.\n if (abortMessage && publicApisAbortSignal.reason !== abortMessage) {\n publicApisAbortSignal['reason'] =\n abortMessage;\n }\n };\n return { response: job(), cancel };\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AAIA;AACA;AACA;AACO,SAAS,0BAA0B,CAAC,OAAO,EAAE,eAAe,EAAE;AACrE,IAAI,MAAM,cAAc,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,eAAe,CAAC;AAC1D;AACA;AACA;AACA,IAAI,MAAM,yBAAyB,GAAG,IAAI,eAAe,EAAE,CAAC;AAC5D,IAAI,MAAM,qBAAqB,GAAG,yBAAyB,CAAC,MAAM,CAAC;AACnE,IAAI,MAAM,uBAAuB,GAAG,eAAe,EAAE,MAAM,CAAC;AAC5D,IAAI,MAAM,GAAG,GAAG,YAAY;AAC5B,QAAQ,IAAI;AACZ,YAAY,MAAM,QAAQ,GAAG,OAAO,cAAc,CAAC,OAAO,CAAC;AAC3D,kBAAkB,OAAO,EAAE;AAC3B,kBAAkB,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC;AAClD,YAAY,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AAC5C,gBAAgB,MAAM,MAAM,wBAAwB,CAAC,QAAQ,CAAC,CAAC;AAC/D,aAAa;AACb,YAAY,OAAO,QAAQ,CAAC;AAC5B,SAAS;AACT,QAAQ,OAAO,KAAK,EAAE;AACtB,YAAY,MAAM,WAAW,GAAG,uBAAuB,IAAI,qBAAqB,CAAC;AACjF,YAAY,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,IAAI,WAAW,EAAE,OAAO,KAAK,IAAI,EAAE;AAC9E,gBAAgB,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC;AACxD,oBAAoB,IAAI,WAAW,CAAC,MAAM,GAAG,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC;AACzF,oBAAoB,eAAe,EAAE,KAAK;AAC1C,iBAAiB,CAAC,CAAC;AACnB,gBAAgB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACpC,gBAAgB,MAAM,aAAa,CAAC;AACpC,aAAa;AACb,YAAY,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAChC,YAAY,MAAM,KAAK,CAAC;AACxB,SAAS;AACT,KAAK,CAAC;AACN,IAAI,IAAI,cAAc,CAAQ,CAAC,EAAE;AACjC,QAAQ,OAAO,GAAG,EAAE,CAAC;AACrB,KAAK;AACL,SAAS;AACT,QAAQ,MAAM,MAAM,GAAG,CAAC,YAAY,KAAK;AACzC,YAAY,IAAI,qBAAqB,CAAC,OAAO,KAAK,IAAI,EAAE;AACxD,gBAAgB,OAAO;AACvB,aAAa;AACb,YAAY,yBAAyB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAC1D;AACA;AACA,YAAY,IAAI,YAAY,IAAI,qBAAqB,CAAC,MAAM,KAAK,YAAY,EAAE;AAC/E,gBAAgB,qBAAqB,CAAC,QAAQ,CAAC;AAC/C,oBAAoB,YAAY,CAAC;AACjC,aAAa;AACb,SAAS,CAAC;AACV,QAAQ,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC;AAC3C,KAAK;AACL;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createCancellableOperation } from './createCancellableOperation.mjs';
|
|
2
|
+
export { resolveCredentials } from './resolveCredentials.mjs';
|
|
3
|
+
export { parseSigningInfo } from './parseSigningInfo.mjs';
|
|
4
|
+
export { parseRestApiServiceError } from './serviceError.mjs';
|
|
5
|
+
export { resolveApiUrl } from './resolveApiUrl.mjs';
|
|
6
|
+
export { logger } from './logger.mjs';
|
|
7
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { ConsoleLogger } from '@aws-amplify/core';
|
|
2
|
+
|
|
1
3
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
const logger = new ConsoleLogger('RestApis');
|
|
6
|
+
|
|
7
|
+
export { logger };
|
|
8
|
+
//# sourceMappingURL=logger.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.mjs","sources":["../../../src/utils/logger.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '@aws-amplify/core';\nexport const logger = new ConsoleLogger('RestApis');\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,MAAM,GAAG,IAAI,aAAa,CAAC,UAAU;;;;"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
for (
|
|
3
|
+
const normalizeHeaders = (headers) => {
|
|
4
|
+
const normalizedHeaders = {};
|
|
5
|
+
for (const key in headers) {
|
|
6
6
|
normalizedHeaders[key.toLowerCase()] = headers[key];
|
|
7
7
|
}
|
|
8
8
|
return normalizedHeaders;
|
|
9
9
|
};
|
|
10
|
+
|
|
11
|
+
export { normalizeHeaders };
|
|
12
|
+
//# sourceMappingURL=normalizeHeaders.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeHeaders.mjs","sources":["../../../src/utils/normalizeHeaders.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport const normalizeHeaders = (headers) => {\n const normalizedHeaders = {};\n for (const key in headers) {\n normalizedHeaders[key.toLowerCase()] = headers[key];\n }\n return normalizedHeaders;\n};\n"],"names":[],"mappings":"AAAA;AACA;AACY,MAAC,gBAAgB,GAAG,CAAC,OAAO,KAAK;AAC7C,IAAI,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACjC,IAAI,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE;AAC/B,QAAQ,iBAAiB,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;AAC5D,KAAK;AACL,IAAI,OAAO,iBAAiB,CAAC;AAC7B;;;;"}
|