@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.
Files changed (174) hide show
  1. package/dist/cjs/apis/common/handler.js +75 -0
  2. package/dist/cjs/apis/common/handler.js.map +1 -0
  3. package/{lib → dist/cjs}/apis/common/internalPost.js +21 -19
  4. package/dist/cjs/apis/common/internalPost.js.map +1 -0
  5. package/dist/cjs/apis/common/publicApis.js +46 -0
  6. package/dist/cjs/apis/common/publicApis.js.map +1 -0
  7. package/{lib → dist/cjs}/apis/index.js +11 -17
  8. package/dist/cjs/apis/index.js.map +1 -0
  9. package/{lib → dist/cjs}/apis/server.js +11 -21
  10. package/dist/cjs/apis/server.js.map +1 -0
  11. package/{lib → dist/cjs}/errors/CanceledError.js +15 -16
  12. package/dist/cjs/errors/CanceledError.js.map +1 -0
  13. package/dist/cjs/errors/RestApiError.js +17 -0
  14. package/dist/cjs/errors/RestApiError.js.map +1 -0
  15. package/{lib → dist/cjs}/errors/assertValidatonError.js +7 -5
  16. package/dist/cjs/errors/assertValidatonError.js.map +1 -0
  17. package/{lib → dist/cjs}/errors/index.js +3 -1
  18. package/dist/cjs/errors/index.js.map +1 -0
  19. package/{lib → dist/cjs}/errors/validation.js +7 -6
  20. package/dist/cjs/errors/validation.js.map +1 -0
  21. package/{lib → dist/cjs}/index.js +3 -1
  22. package/dist/cjs/index.js.map +1 -0
  23. package/{lib → dist/cjs}/internals/index.js +6 -4
  24. package/dist/cjs/internals/index.js.map +1 -0
  25. package/{lib → dist/cjs}/internals/server.js +6 -4
  26. package/dist/cjs/internals/server.js.map +1 -0
  27. package/{lib → dist/cjs}/server.js +3 -1
  28. package/dist/cjs/server.js.map +1 -0
  29. package/{lib → dist/cjs}/types/index.js +3 -1
  30. package/dist/cjs/types/index.js.map +1 -0
  31. package/{lib → dist/cjs}/utils/constants.js +3 -1
  32. package/dist/cjs/utils/constants.js.map +1 -0
  33. package/dist/cjs/utils/createCancellableOperation.js +65 -0
  34. package/dist/cjs/utils/createCancellableOperation.js.map +1 -0
  35. package/{lib → dist/cjs}/utils/index.js +3 -1
  36. package/dist/cjs/utils/index.js.map +1 -0
  37. package/{lib → dist/cjs}/utils/logger.js +4 -2
  38. package/dist/cjs/utils/logger.js.map +1 -0
  39. package/{lib → dist/cjs}/utils/normalizeHeaders.js +6 -4
  40. package/dist/cjs/utils/normalizeHeaders.js.map +1 -0
  41. package/dist/cjs/utils/parseSigningInfo.js +43 -0
  42. package/dist/cjs/utils/parseSigningInfo.js.map +1 -0
  43. package/dist/cjs/utils/resolveApiUrl.js +42 -0
  44. package/dist/cjs/utils/resolveApiUrl.js.map +1 -0
  45. package/dist/cjs/utils/resolveCredentials.js +17 -0
  46. package/dist/cjs/utils/resolveCredentials.js.map +1 -0
  47. package/dist/cjs/utils/serviceError.js +32 -0
  48. package/dist/cjs/utils/serviceError.js.map +1 -0
  49. package/{lib-esm → dist/esm}/apis/common/handler.d.ts +1 -5
  50. package/dist/esm/apis/common/handler.mjs +78 -0
  51. package/dist/esm/apis/common/handler.mjs.map +1 -0
  52. package/{lib-esm/apis/common/internalPost.js → dist/esm/apis/common/internalPost.mjs} +26 -18
  53. package/dist/esm/apis/common/internalPost.mjs.map +1 -0
  54. package/dist/esm/apis/common/publicApis.mjs +45 -0
  55. package/dist/esm/apis/common/publicApis.mjs.map +1 -0
  56. package/{lib-esm/apis/index.js → dist/esm/apis/index.mjs} +12 -16
  57. package/dist/esm/apis/index.mjs.map +1 -0
  58. package/{lib-esm/apis/server.js → dist/esm/apis/server.mjs} +12 -20
  59. package/dist/esm/apis/server.mjs.map +1 -0
  60. package/dist/esm/errors/CanceledError.mjs +31 -0
  61. package/dist/esm/errors/CanceledError.mjs.map +1 -0
  62. package/dist/esm/errors/RestApiError.mjs +15 -0
  63. package/dist/esm/errors/RestApiError.mjs.map +1 -0
  64. package/dist/esm/errors/assertValidatonError.mjs +17 -0
  65. package/dist/esm/errors/assertValidatonError.mjs.map +1 -0
  66. package/dist/esm/errors/index.mjs +5 -0
  67. package/dist/esm/errors/index.mjs.map +1 -0
  68. package/{lib-esm/errors/validation.js → dist/esm/errors/validation.mjs} +8 -6
  69. package/dist/esm/errors/validation.mjs.map +1 -0
  70. package/dist/esm/index.mjs +3 -0
  71. package/dist/esm/index.mjs.map +1 -0
  72. package/{lib-esm/internals/index.js → dist/esm/internals/index.mjs} +9 -5
  73. package/dist/esm/internals/index.mjs.map +1 -0
  74. package/{lib-esm/internals/server.js → dist/esm/internals/server.mjs} +9 -5
  75. package/dist/esm/internals/server.mjs.map +1 -0
  76. package/dist/esm/server.mjs +3 -0
  77. package/dist/esm/server.mjs.map +1 -0
  78. package/dist/esm/types/index.mjs +2 -0
  79. package/dist/esm/types/index.mjs.map +1 -0
  80. package/dist/esm/utils/constants.mjs +13 -0
  81. package/dist/esm/utils/constants.mjs.map +1 -0
  82. package/dist/esm/utils/createCancellableOperation.mjs +65 -0
  83. package/dist/esm/utils/createCancellableOperation.mjs.map +1 -0
  84. package/dist/esm/utils/index.mjs +7 -0
  85. package/dist/esm/utils/index.mjs.map +1 -0
  86. package/{lib-esm/utils/logger.js → dist/esm/utils/logger.mjs} +6 -2
  87. package/dist/esm/utils/logger.mjs.map +1 -0
  88. package/{lib-esm/utils/normalizeHeaders.js → dist/esm/utils/normalizeHeaders.mjs} +6 -3
  89. package/dist/esm/utils/normalizeHeaders.mjs.map +1 -0
  90. package/dist/esm/utils/parseSigningInfo.mjs +41 -0
  91. package/dist/esm/utils/parseSigningInfo.mjs.map +1 -0
  92. package/dist/esm/utils/resolveApiUrl.mjs +42 -0
  93. package/dist/esm/utils/resolveApiUrl.mjs.map +1 -0
  94. package/{lib → dist/esm}/utils/resolveCredentials.d.ts +1 -1
  95. package/dist/esm/utils/resolveCredentials.mjs +17 -0
  96. package/dist/esm/utils/resolveCredentials.mjs.map +1 -0
  97. package/dist/esm/utils/serviceError.mjs +30 -0
  98. package/dist/esm/utils/serviceError.mjs.map +1 -0
  99. package/internals/package.json +4 -4
  100. package/internals/server/package.json +3 -4
  101. package/package.json +63 -26
  102. package/server/package.json +3 -4
  103. package/lib/apis/common/handler.d.ts +0 -31
  104. package/lib/apis/common/handler.js +0 -79
  105. package/lib/apis/common/internalPost.d.ts +0 -16
  106. package/lib/apis/common/publicApis.d.ts +0 -8
  107. package/lib/apis/common/publicApis.js +0 -50
  108. package/lib/apis/index.d.ts +0 -203
  109. package/lib/apis/server.d.ts +0 -151
  110. package/lib/errors/CanceledError.d.ts +0 -17
  111. package/lib/errors/RestApiError.d.ts +0 -4
  112. package/lib/errors/RestApiError.js +0 -19
  113. package/lib/errors/assertValidatonError.d.ts +0 -5
  114. package/lib/errors/index.d.ts +0 -4
  115. package/lib/errors/validation.d.ts +0 -6
  116. package/lib/index.d.ts +0 -2
  117. package/lib/internals/index.d.ts +0 -19
  118. package/lib/internals/server.d.ts +0 -20
  119. package/lib/server.d.ts +0 -2
  120. package/lib/tsconfig.tsbuildinfo +0 -1
  121. package/lib/types/index.d.ts +0 -103
  122. package/lib/utils/constants.d.ts +0 -8
  123. package/lib/utils/createCancellableOperation.d.ts +0 -12
  124. package/lib/utils/createCancellableOperation.js +0 -70
  125. package/lib/utils/index.d.ts +0 -6
  126. package/lib/utils/logger.d.ts +0 -2
  127. package/lib/utils/normalizeHeaders.d.ts +0 -1
  128. package/lib/utils/parseSigningInfo.d.ts +0 -14
  129. package/lib/utils/parseSigningInfo.js +0 -42
  130. package/lib/utils/resolveApiUrl.d.ts +0 -12
  131. package/lib/utils/resolveApiUrl.js +0 -39
  132. package/lib/utils/resolveCredentials.js +0 -23
  133. package/lib/utils/serviceError.d.ts +0 -10
  134. package/lib/utils/serviceError.js +0 -38
  135. package/lib-esm/apis/common/handler.js +0 -75
  136. package/lib-esm/apis/common/publicApis.js +0 -41
  137. package/lib-esm/errors/CanceledError.js +0 -31
  138. package/lib-esm/errors/RestApiError.js +0 -16
  139. package/lib-esm/errors/assertValidatonError.js +0 -13
  140. package/lib-esm/errors/index.js +0 -6
  141. package/lib-esm/index.js +0 -4
  142. package/lib-esm/server.js +0 -4
  143. package/lib-esm/tsconfig.tsbuildinfo +0 -1
  144. package/lib-esm/types/index.js +0 -1
  145. package/lib-esm/utils/constants.js +0 -10
  146. package/lib-esm/utils/createCancellableOperation.js +0 -66
  147. package/lib-esm/utils/index.js +0 -8
  148. package/lib-esm/utils/parseSigningInfo.js +0 -38
  149. package/lib-esm/utils/resolveApiUrl.js +0 -35
  150. package/lib-esm/utils/resolveCredentials.d.ts +0 -5
  151. package/lib-esm/utils/resolveCredentials.js +0 -19
  152. package/lib-esm/utils/serviceError.js +0 -33
  153. /package/{lib-esm → dist/esm}/apis/common/internalPost.d.ts +0 -0
  154. /package/{lib-esm → dist/esm}/apis/common/publicApis.d.ts +0 -0
  155. /package/{lib-esm → dist/esm}/apis/index.d.ts +0 -0
  156. /package/{lib-esm → dist/esm}/apis/server.d.ts +0 -0
  157. /package/{lib-esm → dist/esm}/errors/CanceledError.d.ts +0 -0
  158. /package/{lib-esm → dist/esm}/errors/RestApiError.d.ts +0 -0
  159. /package/{lib-esm → dist/esm}/errors/assertValidatonError.d.ts +0 -0
  160. /package/{lib-esm → dist/esm}/errors/index.d.ts +0 -0
  161. /package/{lib-esm → dist/esm}/errors/validation.d.ts +0 -0
  162. /package/{lib-esm → dist/esm}/index.d.ts +0 -0
  163. /package/{lib-esm → dist/esm}/internals/index.d.ts +0 -0
  164. /package/{lib-esm → dist/esm}/internals/server.d.ts +0 -0
  165. /package/{lib-esm → dist/esm}/server.d.ts +0 -0
  166. /package/{lib-esm → dist/esm}/types/index.d.ts +0 -0
  167. /package/{lib-esm → dist/esm}/utils/constants.d.ts +0 -0
  168. /package/{lib-esm → dist/esm}/utils/createCancellableOperation.d.ts +0 -0
  169. /package/{lib-esm → dist/esm}/utils/index.d.ts +0 -0
  170. /package/{lib-esm → dist/esm}/utils/logger.d.ts +0 -0
  171. /package/{lib-esm → dist/esm}/utils/normalizeHeaders.d.ts +0 -0
  172. /package/{lib-esm → dist/esm}/utils/parseSigningInfo.d.ts +0 -0
  173. /package/{lib-esm → dist/esm}/utils/resolveApiUrl.d.ts +0 -0
  174. /package/{lib-esm → dist/esm}/utils/serviceError.d.ts +0 -0
@@ -1,38 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { __read } from "tslib";
4
- import { APIG_HOSTNAME_PATTERN, DEFAULT_IAM_SIGNING_REGION, DEFAULT_REST_IAM_SIGNING_SERVICE, } from './constants';
5
- /**
6
- * Infer the signing service and region from the given URL, and for REST API only, from the Amplify configuration.
7
- * It supports raw API Gateway endpoint and AppSync endpoint.
8
- *
9
- * @internal
10
- */
11
- export var parseSigningInfo = function (url, restApiOptions) {
12
- var _a, _b, _c, _d, _e;
13
- var _f = (_d = (_c = (_b = (_a = restApiOptions === null || restApiOptions === void 0 ? void 0 : restApiOptions.amplify.getConfig()) === null || _a === void 0 ? void 0 : _a.API) === null || _b === void 0 ? void 0 : _b.REST) === null || _c === void 0 ? void 0 : _c[restApiOptions === null || restApiOptions === void 0 ? void 0 : restApiOptions.apiName]) !== null && _d !== void 0 ? _d : {}, _g = _f.service, signingService = _g === void 0 ? DEFAULT_REST_IAM_SIGNING_SERVICE : _g, _h = _f.region, signingRegion = _h === void 0 ? DEFAULT_IAM_SIGNING_REGION : _h;
14
- var hostname = url.hostname;
15
- var _j = __read((_e = APIG_HOSTNAME_PATTERN.exec(hostname)) !== null && _e !== void 0 ? _e : [], 3), service = _j[1], region = _j[2];
16
- if (service === DEFAULT_REST_IAM_SIGNING_SERVICE) {
17
- // The configured endpoint is an API Gateway endpoint
18
- // @see: https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-call-api.html
19
- return {
20
- service: service,
21
- region: region !== null && region !== void 0 ? region : signingRegion,
22
- };
23
- }
24
- else if (service === 'appsync-api') {
25
- // AppSync endpoint is internally supported because GraphQL operation will send request using POST handler.
26
- // example: https://xxxx.appsync-api.us-east-1.amazonaws.com/graphql
27
- return {
28
- service: 'appsync',
29
- region: region !== null && region !== void 0 ? region : signingRegion,
30
- };
31
- }
32
- else {
33
- return {
34
- service: signingService,
35
- region: signingRegion,
36
- };
37
- }
38
- };
@@ -1,35 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { __assign, __read } from "tslib";
4
- import { AmplifyUrl, AmplifyUrlSearchParams, } from '@aws-amplify/core/internals/utils';
5
- import { RestApiError, RestApiValidationErrorCode, assertValidationError, validationErrorMap, } from '../errors';
6
- /**
7
- * Resolve the REST API request URL by:
8
- * 1. Loading the REST API endpoint from the Amplify configuration with corresponding API name.
9
- * 2. Appending the path to the endpoint.
10
- * 3. Merge the query parameters from path and the queryParameter argument which is taken from the public REST API
11
- * options.
12
- * 4. Validating the resulting URL string.
13
- *
14
- * @internal
15
- */
16
- export var resolveApiUrl = function (amplify, apiName, path, queryParams) {
17
- var _a, _b, _c, _d;
18
- var urlStr = (_d = (_c = (_b = (_a = amplify.getConfig()) === null || _a === void 0 ? void 0 : _a.API) === null || _b === void 0 ? void 0 : _b.REST) === null || _c === void 0 ? void 0 : _c[apiName]) === null || _d === void 0 ? void 0 : _d.endpoint;
19
- assertValidationError(!!urlStr, RestApiValidationErrorCode.InvalidApiName);
20
- try {
21
- var url = new AmplifyUrl(urlStr + path);
22
- if (queryParams) {
23
- var mergedQueryParams_1 = new AmplifyUrlSearchParams(url.searchParams);
24
- Object.entries(queryParams).forEach(function (_a) {
25
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
26
- mergedQueryParams_1.set(key, value);
27
- });
28
- url.search = new AmplifyUrlSearchParams(mergedQueryParams_1).toString();
29
- }
30
- return url;
31
- }
32
- catch (error) {
33
- throw new RestApiError(__assign(__assign({ name: RestApiValidationErrorCode.InvalidApiName }, validationErrorMap[RestApiValidationErrorCode.InvalidApiName]), { recoverySuggestion: "Please make sure the REST endpoint URL is a valid URL string. Got ".concat(urlStr) }));
34
- }
35
- };
@@ -1,5 +0,0 @@
1
- import { AmplifyClassV6 } from '@aws-amplify/core';
2
- /**
3
- * @internal
4
- */
5
- export declare const resolveCredentials: (amplify: AmplifyClassV6) => Promise<import("@aws-amplify/core/lib-esm/libraryUtils").AWSCredentials>;
@@ -1,19 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { __awaiter, __generator } from "tslib";
4
- import { RestApiValidationErrorCode, assertValidationError } from '../errors';
5
- /**
6
- * @internal
7
- */
8
- export var resolveCredentials = function (amplify) { return __awaiter(void 0, void 0, void 0, function () {
9
- var credentials;
10
- return __generator(this, function (_a) {
11
- switch (_a.label) {
12
- case 0: return [4 /*yield*/, amplify.Auth.fetchAuthSession()];
13
- case 1:
14
- credentials = (_a.sent()).credentials;
15
- assertValidationError(!!credentials && !!credentials.accessKeyId && !!credentials.secretAccessKey, RestApiValidationErrorCode.NoCredentials);
16
- return [2 /*return*/, credentials];
17
- }
18
- });
19
- }); };
@@ -1,33 +0,0 @@
1
- import { __awaiter, __generator } from "tslib";
2
- import { parseJsonError, } from '@aws-amplify/core/internals/aws-client-utils';
3
- import { RestApiError } from '../errors';
4
- /**
5
- * Internal-only method to create a new RestApiError from a service error.
6
- *
7
- * @internal
8
- */
9
- export var buildRestApiServiceError = function (error) {
10
- var restApiError = new RestApiError({
11
- name: error === null || error === void 0 ? void 0 : error.name,
12
- message: error.message,
13
- underlyingError: error,
14
- });
15
- return restApiError;
16
- };
17
- export var parseRestApiServiceError = function (response) { return __awaiter(void 0, void 0, void 0, function () {
18
- var parsedError;
19
- return __generator(this, function (_a) {
20
- switch (_a.label) {
21
- case 0: return [4 /*yield*/, parseJsonError(response)];
22
- case 1:
23
- parsedError = _a.sent();
24
- if (!parsedError) {
25
- // Response is not an error.
26
- return [2 /*return*/];
27
- }
28
- return [2 /*return*/, Object.assign(buildRestApiServiceError(parsedError), {
29
- $metadata: parsedError.$metadata,
30
- })];
31
- }
32
- });
33
- }); };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes