@aws-amplify/api-rest 4.0.1-console-preview.b5a42af.0 → 4.0.1-console-preview.9607e4a.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 (103) hide show
  1. package/lib/{common → apis/common}/handler.d.ts +7 -7
  2. package/lib/{common → apis/common}/handler.js +5 -6
  3. package/{lib-esm → lib/apis}/common/internalPost.d.ts +1 -1
  4. package/lib/{common → apis/common}/internalPost.js +12 -1
  5. package/lib/apis/common/publicApis.d.ts +8 -0
  6. package/lib/apis/common/publicApis.js +50 -0
  7. package/lib/apis/index.d.ts +25 -0
  8. package/lib/apis/index.js +45 -0
  9. package/lib/apis/server.d.ts +26 -0
  10. package/lib/apis/server.js +49 -0
  11. package/lib/errors/validation.d.ts +2 -1
  12. package/lib/errors/validation.js +5 -0
  13. package/lib/index.d.ts +1 -0
  14. package/lib/index.js +8 -1
  15. package/lib/internals/index.d.ts +1 -1
  16. package/lib/internals/index.js +2 -2
  17. package/lib/internals/server.d.ts +1 -1
  18. package/lib/internals/server.js +2 -2
  19. package/lib/server.d.ts +2 -0
  20. package/lib/server.js +14 -0
  21. package/lib/tsconfig.tsbuildinfo +1 -1
  22. package/lib/types/index.d.ts +19 -8
  23. package/lib/utils/createCancellableOperation.d.ts +2 -1
  24. package/lib/utils/createCancellableOperation.js +29 -19
  25. package/lib/utils/index.d.ts +3 -1
  26. package/lib/utils/index.js +7 -3
  27. package/lib/utils/index.native.d.ts +6 -0
  28. package/lib/utils/index.native.js +19 -0
  29. package/lib/utils/logger.d.ts +2 -0
  30. package/lib/utils/logger.js +7 -0
  31. package/lib/utils/normalizeHeaders.d.ts +1 -1
  32. package/lib/utils/parseSigningInfo.d.ts +14 -0
  33. package/lib/utils/parseSigningInfo.js +42 -0
  34. package/lib/utils/resolveApiUrl.d.ts +12 -0
  35. package/lib/utils/resolveApiUrl.js +38 -0
  36. package/lib/utils/resolveCredentials.d.ts +2 -2
  37. package/lib/utils/resolveCredentials.js +1 -1
  38. package/lib/utils/serviceError.d.ts +1 -1
  39. package/lib/utils/serviceError.js +8 -6
  40. package/lib-esm/{common → apis/common}/handler.d.ts +7 -7
  41. package/lib-esm/{common → apis/common}/handler.js +5 -6
  42. package/{lib → lib-esm/apis}/common/internalPost.d.ts +1 -1
  43. package/lib-esm/{common → apis/common}/internalPost.js +12 -1
  44. package/lib-esm/apis/common/publicApis.d.ts +8 -0
  45. package/lib-esm/apis/common/publicApis.js +41 -0
  46. package/lib-esm/apis/index.d.ts +25 -0
  47. package/lib-esm/apis/index.js +36 -0
  48. package/lib-esm/apis/server.d.ts +26 -0
  49. package/lib-esm/apis/server.js +40 -0
  50. package/lib-esm/errors/validation.d.ts +2 -1
  51. package/lib-esm/errors/validation.js +5 -0
  52. package/lib-esm/index.d.ts +1 -0
  53. package/lib-esm/index.js +1 -0
  54. package/lib-esm/internals/index.d.ts +1 -1
  55. package/lib-esm/internals/index.js +2 -2
  56. package/lib-esm/internals/server.d.ts +1 -1
  57. package/lib-esm/internals/server.js +2 -2
  58. package/lib-esm/server.d.ts +2 -0
  59. package/lib-esm/server.js +4 -0
  60. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  61. package/lib-esm/types/index.d.ts +19 -8
  62. package/lib-esm/utils/createCancellableOperation.d.ts +2 -1
  63. package/lib-esm/utils/createCancellableOperation.js +31 -21
  64. package/lib-esm/utils/index.d.ts +3 -1
  65. package/lib-esm/utils/index.js +3 -1
  66. package/lib-esm/utils/index.native.d.ts +6 -0
  67. package/lib-esm/utils/index.native.js +10 -0
  68. package/lib-esm/utils/logger.d.ts +2 -0
  69. package/lib-esm/utils/logger.js +4 -0
  70. package/lib-esm/utils/normalizeHeaders.d.ts +1 -1
  71. package/lib-esm/utils/parseSigningInfo.d.ts +14 -0
  72. package/lib-esm/utils/parseSigningInfo.js +38 -0
  73. package/lib-esm/utils/resolveApiUrl.d.ts +12 -0
  74. package/lib-esm/utils/resolveApiUrl.js +34 -0
  75. package/lib-esm/utils/resolveCredentials.d.ts +2 -2
  76. package/lib-esm/utils/resolveCredentials.js +1 -1
  77. package/lib-esm/utils/serviceError.d.ts +1 -1
  78. package/lib-esm/utils/serviceError.js +8 -6
  79. package/package.json +6 -7
  80. package/src/{common → apis/common}/handler.ts +8 -9
  81. package/src/{common → apis/common}/internalPost.ts +13 -2
  82. package/src/apis/common/publicApis.ts +99 -0
  83. package/src/apis/index.ts +60 -0
  84. package/src/apis/server.ts +83 -0
  85. package/src/errors/validation.ts +6 -0
  86. package/src/index.ts +1 -0
  87. package/src/internals/index.ts +5 -2
  88. package/src/internals/server.ts +5 -2
  89. package/src/server.ts +5 -0
  90. package/src/types/index.ts +19 -8
  91. package/src/utils/createCancellableOperation.ts +37 -19
  92. package/src/utils/index.native.ts +13 -0
  93. package/src/utils/index.ts +3 -1
  94. package/src/utils/logger.ts +6 -0
  95. package/src/utils/normalizeHeaders.ts +1 -1
  96. package/src/utils/{parseUrl.ts → parseSigningInfo.ts} +20 -7
  97. package/src/utils/resolveApiUrl.ts +47 -0
  98. package/src/utils/resolveCredentials.ts +1 -1
  99. package/src/utils/serviceError.ts +9 -7
  100. package/lib/utils/parseUrl.d.ts +0 -10
  101. package/lib/utils/parseUrl.js +0 -41
  102. package/lib-esm/utils/parseUrl.d.ts +0 -10
  103. package/lib-esm/utils/parseUrl.js +0 -37
@@ -1,6 +1,7 @@
1
1
  import { AmplifyClassV6 } from '@aws-amplify/core';
2
2
  import { HttpRequest, Headers } from '@aws-amplify/core/internals/aws-client-utils';
3
3
  import { DocumentType } from '@aws-amplify/core/internals/utils';
4
+ import { RestApiResponse } from '../../types';
4
5
  type HandlerOptions = Omit<HttpRequest, 'body' | 'headers'> & {
5
6
  body?: DocumentType | FormData;
6
7
  headers?: Headers;
@@ -15,17 +16,16 @@ type SigningServiceInfo = {
15
16
  * @param amplify Amplify instance to to resolve credentials and tokens. Should use different instance in client-side
16
17
  * and SSR
17
18
  * @param options Options accepted from public API options when calling the handlers.
18
- * @param signingServiceInfo Internal-only options for graphql client to overwrite the IAM signing service and region.
19
- * MUST ONLY be used by internal post method consumed by GraphQL when auth mode is IAM. Otherwise IAM auth may not be
20
- * used.
19
+ * @param signingServiceInfo Internal-only options enable IAM auth as well as to to overwrite the IAM signing service
20
+ * and region. If specified, and NONE of API Key header or Auth header is present, IAM auth will be used.
21
21
  *
22
22
  * @internal
23
23
  */
24
24
  export declare const transferHandler: (amplify: AmplifyClassV6, options: Omit<HttpRequest, "body" | "headers"> & {
25
- body?: DocumentType | FormData;
26
- headers?: Headers;
27
- withCredentials?: boolean;
25
+ body?: FormData | DocumentType | undefined;
26
+ headers?: Headers | undefined;
27
+ withCredentials?: boolean | undefined;
28
28
  } & {
29
29
  abortSignal: AbortSignal;
30
- }, signingServiceInfo?: SigningServiceInfo) => Promise<import("@aws-amplify/core/internals/aws-client-utils").HttpResponse>;
30
+ }, signingServiceInfo?: SigningServiceInfo) => Promise<RestApiResponse>;
31
31
  export {};
@@ -3,16 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transferHandler = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var aws_client_utils_1 = require("@aws-amplify/core/internals/aws-client-utils");
6
- var utils_1 = require("../utils");
7
- var normalizeHeaders_1 = require("../utils/normalizeHeaders");
6
+ var utils_1 = require("../../utils");
7
+ var normalizeHeaders_1 = require("../../utils/normalizeHeaders");
8
8
  /**
9
9
  * Make REST API call with best-effort IAM auth.
10
10
  * @param amplify Amplify instance to to resolve credentials and tokens. Should use different instance in client-side
11
11
  * and SSR
12
12
  * @param options Options accepted from public API options when calling the handlers.
13
- * @param signingServiceInfo Internal-only options for graphql client to overwrite the IAM signing service and region.
14
- * MUST ONLY be used by internal post method consumed by GraphQL when auth mode is IAM. Otherwise IAM auth may not be
15
- * used.
13
+ * @param signingServiceInfo Internal-only options enable IAM auth as well as to to overwrite the IAM signing service
14
+ * and region. If specified, and NONE of API Key header or Auth header is present, IAM auth will be used.
16
15
  *
17
16
  * @internal
18
17
  */
@@ -49,7 +48,7 @@ var transferHandler = function (amplify, options, signingServiceInfo) { return t
49
48
  };
50
49
  isIamAuthApplicable = iamAuthApplicable(request, signingServiceInfo);
51
50
  if (!isIamAuthApplicable) return [3 /*break*/, 3];
52
- signingInfoFromUrl = (0, utils_1.parseUrl)(url);
51
+ signingInfoFromUrl = (0, utils_1.parseSigningInfo)(url);
53
52
  signingService = (_a = signingServiceInfo === null || signingServiceInfo === void 0 ? void 0 : signingServiceInfo.service) !== null && _a !== void 0 ? _a : signingInfoFromUrl.service;
54
53
  signingRegion = (_b = signingServiceInfo === null || signingServiceInfo === void 0 ? void 0 : signingServiceInfo.region) !== null && _b !== void 0 ? _b : signingInfoFromUrl.region;
55
54
  return [4 /*yield*/, (0, utils_1.resolveCredentials)(amplify)];
@@ -1,5 +1,5 @@
1
1
  import { AmplifyClassV6 } from '@aws-amplify/core';
2
- import { InternalPostInput, RestApiResponse } from '../types';
2
+ import { InternalPostInput, RestApiResponse } from '../../types';
3
3
  /**
4
4
  * @internal
5
5
  */
@@ -5,7 +5,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.updateRequestToBeCancellable = exports.cancel = exports.post = void 0;
6
6
  var tslib_1 = require("tslib");
7
7
  var handler_1 = require("./handler");
8
- var utils_1 = require("../utils");
8
+ var utils_1 = require("../../utils");
9
+ /**
10
+ * This weak map provides functionality to cancel a request given the promise containing the `post` request.
11
+ *
12
+ * 1. For every GraphQL POST request, an abort controller is created and supplied to the request.
13
+ * 2. The promise fulfilled by GraphGL POST request is then mapped to that abort controller.
14
+ * 3. The promise is returned to the external caller.
15
+ * 4. The caller can either wait for the promise to fulfill or call `cancel(promise)` to cancel the request.
16
+ * 5. If `cancel(promise)` is called, then the corresponding abort controller is retrieved from the map below.
17
+ * 6. GraphQL POST request will be rejected with the error message provided during cancel.
18
+ * 7. Caller can check if the error is because of cancelling by calling `isCancelError(error)`.
19
+ */
9
20
  var cancelTokenMap = new WeakMap();
10
21
  /**
11
22
  * @internal
@@ -0,0 +1,8 @@
1
+ import { AmplifyClassV6 } from '@aws-amplify/core';
2
+ import { GetInput, GetOperation, PostInput, PostOperation, PutInput, PutOperation, DeleteInput, DeleteOperation, HeadInput, HeadOperation, PatchInput, PatchOperation } from '../../types';
3
+ export declare const get: (amplify: AmplifyClassV6, input: GetInput) => GetOperation;
4
+ export declare const post: (amplify: AmplifyClassV6, input: PostInput) => PostOperation;
5
+ export declare const put: (amplify: AmplifyClassV6, input: PutInput) => PutOperation;
6
+ export declare const del: (amplify: AmplifyClassV6, input: DeleteInput) => DeleteOperation;
7
+ export declare const head: (amplify: AmplifyClassV6, input: HeadInput) => HeadOperation;
8
+ export declare const patch: (amplify: AmplifyClassV6, input: PatchInput) => PatchOperation;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.patch = exports.head = exports.del = exports.put = exports.post = exports.get = void 0;
6
+ var tslib_1 = require("tslib");
7
+ var utils_1 = require("../../utils");
8
+ var handler_1 = require("./handler");
9
+ var publicHandler = function (amplify, options, method) {
10
+ return (0, utils_1.createCancellableOperation)(function (abortSignal) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
11
+ var apiName, _a, apiOptions, apiPath, url, libraryOptionsHeaders, _b, invocationHeaders, headers, signingServiceInfo;
12
+ var _c, _d, _e, _f;
13
+ return tslib_1.__generator(this, function (_g) {
14
+ switch (_g.label) {
15
+ case 0:
16
+ apiName = options.apiName, _a = options.options, apiOptions = _a === void 0 ? {} : _a, apiPath = options.path;
17
+ url = (0, utils_1.resolveApiUrl)(amplify, apiName, apiPath, apiOptions === null || apiOptions === void 0 ? void 0 : apiOptions.queryParams);
18
+ return [4 /*yield*/, ((_f = (_e = (_d = (_c = amplify.libraryOptions) === null || _c === void 0 ? void 0 : _c.API) === null || _d === void 0 ? void 0 : _d.REST) === null || _e === void 0 ? void 0 : _e.headers) === null || _f === void 0 ? void 0 : _f.call(_e, {
19
+ apiName: apiName,
20
+ }))];
21
+ case 1:
22
+ libraryOptionsHeaders = _g.sent();
23
+ _b = apiOptions.headers, invocationHeaders = _b === void 0 ? {} : _b;
24
+ headers = tslib_1.__assign(tslib_1.__assign({}, libraryOptionsHeaders), invocationHeaders);
25
+ signingServiceInfo = (0, utils_1.parseSigningInfo)(url, {
26
+ amplify: amplify,
27
+ apiName: apiName,
28
+ });
29
+ utils_1.logger.debug(method, url, headers, "IAM signing options: ".concat(JSON.stringify(signingServiceInfo)));
30
+ return [2 /*return*/, (0, handler_1.transferHandler)(amplify, tslib_1.__assign(tslib_1.__assign({}, apiOptions), { url: url, method: method, headers: headers, abortSignal: abortSignal }), signingServiceInfo)];
31
+ }
32
+ });
33
+ }); });
34
+ };
35
+ var get = function (amplify, input) {
36
+ return publicHandler(amplify, input, 'GET');
37
+ };
38
+ exports.get = get;
39
+ var post = function (amplify, input) { return publicHandler(amplify, input, 'POST'); };
40
+ exports.post = post;
41
+ var put = function (amplify, input) {
42
+ return publicHandler(amplify, input, 'PUT');
43
+ };
44
+ exports.put = put;
45
+ var del = function (amplify, input) { return publicHandler(amplify, input, 'DELETE'); };
46
+ exports.del = del;
47
+ var head = function (amplify, input) { return publicHandler(amplify, input, 'HEAD'); };
48
+ exports.head = head;
49
+ var patch = function (amplify, input) { return publicHandler(amplify, input, 'PATCH'); };
50
+ exports.patch = patch;
@@ -0,0 +1,25 @@
1
+ import { DeleteInput, DeleteOperation, GetInput, GetOperation, HeadInput, HeadOperation, PatchInput, PatchOperation, PostInput, PostOperation, PutInput, PutOperation } from '../types';
2
+ /**
3
+ * GET HTTP request
4
+ */
5
+ export declare const get: (input: GetInput) => GetOperation;
6
+ /**
7
+ * POST HTTP request
8
+ */
9
+ export declare const post: (input: PostInput) => PostOperation;
10
+ /**
11
+ * PUT HTTP request
12
+ */
13
+ export declare const put: (input: PutInput) => PutOperation;
14
+ /**
15
+ * DELETE HTTP request
16
+ */
17
+ export declare const del: (input: DeleteInput) => DeleteOperation;
18
+ /**
19
+ * HEAD HTTP request
20
+ */
21
+ export declare const head: (input: HeadInput) => HeadOperation;
22
+ /**
23
+ * PATCH HTTP request
24
+ */
25
+ export declare const patch: (input: PatchInput) => PatchOperation;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.patch = exports.head = exports.del = exports.put = exports.post = exports.get = void 0;
6
+ var core_1 = require("@aws-amplify/core");
7
+ var publicApis_1 = require("./common/publicApis");
8
+ /**
9
+ * GET HTTP request
10
+ */
11
+ var get = function (input) { return (0, publicApis_1.get)(core_1.Amplify, input); };
12
+ exports.get = get;
13
+ /**
14
+ * POST HTTP request
15
+ */
16
+ var post = function (input) {
17
+ return (0, publicApis_1.post)(core_1.Amplify, input);
18
+ };
19
+ exports.post = post;
20
+ /**
21
+ * PUT HTTP request
22
+ */
23
+ var put = function (input) { return (0, publicApis_1.put)(core_1.Amplify, input); };
24
+ exports.put = put;
25
+ /**
26
+ * DELETE HTTP request
27
+ */
28
+ var del = function (input) {
29
+ return (0, publicApis_1.del)(core_1.Amplify, input);
30
+ };
31
+ exports.del = del;
32
+ /**
33
+ * HEAD HTTP request
34
+ */
35
+ var head = function (input) {
36
+ return (0, publicApis_1.head)(core_1.Amplify, input);
37
+ };
38
+ exports.head = head;
39
+ /**
40
+ * PATCH HTTP request
41
+ */
42
+ var patch = function (input) {
43
+ return (0, publicApis_1.patch)(core_1.Amplify, input);
44
+ };
45
+ exports.patch = patch;
@@ -0,0 +1,26 @@
1
+ import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
2
+ import { DeleteInput, DeleteOperation, GetInput, GetOperation, HeadInput, HeadOperation, PatchInput, PatchOperation, PostInput, PostOperation, PutInput, PutOperation } from '../types';
3
+ /**
4
+ * GET HTTP request (server-side)
5
+ */
6
+ export declare const get: (contextSpec: AmplifyServer.ContextSpec, input: GetInput) => GetOperation;
7
+ /**
8
+ * POST HTTP request (server-side)
9
+ */
10
+ export declare const post: (contextSpec: AmplifyServer.ContextSpec, input: PostInput) => PostOperation;
11
+ /**
12
+ * PUT HTTP request (server-side)
13
+ */
14
+ export declare const put: (contextSpec: AmplifyServer.ContextSpec, input: PutInput) => PutOperation;
15
+ /**
16
+ * DELETE HTTP request (server-side)
17
+ */
18
+ export declare const del: (contextSpec: AmplifyServer.ContextSpec, input: DeleteInput) => DeleteOperation;
19
+ /**
20
+ * HEAD HTTP request (server-side)
21
+ */
22
+ export declare const head: (contextSpec: AmplifyServer.ContextSpec, input: HeadInput) => HeadOperation;
23
+ /**
24
+ * PATCH HTTP request (server-side)
25
+ */
26
+ export declare const patch: (contextSpec: AmplifyServer.ContextSpec, input: PatchInput) => PatchOperation;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.patch = exports.head = exports.del = exports.put = exports.post = exports.get = void 0;
6
+ var adapter_core_1 = require("@aws-amplify/core/internals/adapter-core");
7
+ var publicApis_1 = require("./common/publicApis");
8
+ /**
9
+ * GET HTTP request (server-side)
10
+ */
11
+ var get = function (contextSpec, input) {
12
+ return (0, publicApis_1.get)((0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify, input);
13
+ };
14
+ exports.get = get;
15
+ /**
16
+ * POST HTTP request (server-side)
17
+ */
18
+ var post = function (contextSpec, input) {
19
+ return (0, publicApis_1.post)((0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify, input);
20
+ };
21
+ exports.post = post;
22
+ /**
23
+ * PUT HTTP request (server-side)
24
+ */
25
+ var put = function (contextSpec, input) {
26
+ return (0, publicApis_1.put)((0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify, input);
27
+ };
28
+ exports.put = put;
29
+ /**
30
+ * DELETE HTTP request (server-side)
31
+ */
32
+ var del = function (contextSpec, input) {
33
+ return (0, publicApis_1.del)((0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify, input);
34
+ };
35
+ exports.del = del;
36
+ /**
37
+ * HEAD HTTP request (server-side)
38
+ */
39
+ var head = function (contextSpec, input) {
40
+ return (0, publicApis_1.head)((0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify, input);
41
+ };
42
+ exports.head = head;
43
+ /**
44
+ * PATCH HTTP request (server-side)
45
+ */
46
+ var patch = function (contextSpec, input) {
47
+ return (0, publicApis_1.patch)((0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify, input);
48
+ };
49
+ exports.patch = patch;
@@ -1,5 +1,6 @@
1
1
  import { AmplifyErrorMap } from '@aws-amplify/core/internals/utils';
2
2
  export declare enum RestApiValidationErrorCode {
3
- NoCredentials = "NoCredentials"
3
+ NoCredentials = "NoCredentials",
4
+ InvalidApiName = "InvalidApiName"
4
5
  }
5
6
  export declare const validationErrorMap: AmplifyErrorMap<RestApiValidationErrorCode>;
@@ -7,9 +7,14 @@ exports.validationErrorMap = exports.RestApiValidationErrorCode = void 0;
7
7
  var RestApiValidationErrorCode;
8
8
  (function (RestApiValidationErrorCode) {
9
9
  RestApiValidationErrorCode["NoCredentials"] = "NoCredentials";
10
+ RestApiValidationErrorCode["InvalidApiName"] = "InvalidApiName";
10
11
  })(RestApiValidationErrorCode = exports.RestApiValidationErrorCode || (exports.RestApiValidationErrorCode = {}));
11
12
  exports.validationErrorMap = (_a = {},
12
13
  _a[RestApiValidationErrorCode.NoCredentials] = {
13
14
  message: 'Credentials should not be empty.',
14
15
  },
16
+ _a[RestApiValidationErrorCode.InvalidApiName] = {
17
+ message: 'API name is invalid.',
18
+ recoverySuggestion: 'Check if the API name matches the one in your configuration or `aws-exports.js`',
19
+ },
15
20
  _a);
package/lib/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { isCancelError } from './errors/CancelledError';
2
+ export { get, post, put, del, head, patch } from './apis';
package/lib/index.js CHANGED
@@ -2,6 +2,13 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.isCancelError = void 0;
5
+ exports.patch = exports.head = exports.del = exports.put = exports.post = exports.get = exports.isCancelError = void 0;
6
6
  var CancelledError_1 = require("./errors/CancelledError");
7
7
  Object.defineProperty(exports, "isCancelError", { enumerable: true, get: function () { return CancelledError_1.isCancelError; } });
8
+ var apis_1 = require("./apis");
9
+ Object.defineProperty(exports, "get", { enumerable: true, get: function () { return apis_1.get; } });
10
+ Object.defineProperty(exports, "post", { enumerable: true, get: function () { return apis_1.post; } });
11
+ Object.defineProperty(exports, "put", { enumerable: true, get: function () { return apis_1.put; } });
12
+ Object.defineProperty(exports, "del", { enumerable: true, get: function () { return apis_1.del; } });
13
+ Object.defineProperty(exports, "head", { enumerable: true, get: function () { return apis_1.head; } });
14
+ Object.defineProperty(exports, "patch", { enumerable: true, get: function () { return apis_1.patch; } });
@@ -16,4 +16,4 @@ import { InternalPostInput } from '../types';
16
16
  * @internal
17
17
  */
18
18
  export declare const post: (input: InternalPostInput) => Promise<import("../types").RestApiResponse>;
19
- export { cancel, updateRequestToBeCancellable } from '../common/internalPost';
19
+ export { cancel, updateRequestToBeCancellable, } from '../apis/common/internalPost';
@@ -4,7 +4,7 @@ exports.updateRequestToBeCancellable = exports.cancel = exports.post = void 0;
4
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
5
  // SPDX-License-Identifier: Apache-2.0
6
6
  var core_1 = require("@aws-amplify/core");
7
- var internalPost_1 = require("../common/internalPost");
7
+ var internalPost_1 = require("../apis/common/internalPost");
8
8
  /**
9
9
  * Internal-only REST POST handler to send GraphQL request to given endpoint. By default, it will use IAM to authorize
10
10
  * the request. In some auth modes, the IAM auth has to be disabled. Here's how to set up the request auth correctly:
@@ -25,6 +25,6 @@ var post = function (input) {
25
25
  return (0, internalPost_1.post)(core_1.Amplify, input);
26
26
  };
27
27
  exports.post = post;
28
- var internalPost_2 = require("../common/internalPost");
28
+ var internalPost_2 = require("../apis/common/internalPost");
29
29
  Object.defineProperty(exports, "cancel", { enumerable: true, get: function () { return internalPost_2.cancel; } });
30
30
  Object.defineProperty(exports, "updateRequestToBeCancellable", { enumerable: true, get: function () { return internalPost_2.updateRequestToBeCancellable; } });
@@ -17,4 +17,4 @@ import { InternalPostInput } from '../types';
17
17
  * @internal
18
18
  */
19
19
  export declare const post: (contextSpec: AmplifyServer.ContextSpec, input: InternalPostInput) => Promise<import("../types").RestApiResponse>;
20
- export { cancel, updateRequestToBeCancellable } from '../common/internalPost';
20
+ export { cancel, updateRequestToBeCancellable, } from '../apis/common/internalPost';
@@ -4,7 +4,7 @@ exports.updateRequestToBeCancellable = exports.cancel = exports.post = void 0;
4
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
5
  // SPDX-License-Identifier: Apache-2.0
6
6
  var adapter_core_1 = require("@aws-amplify/core/internals/adapter-core");
7
- var internalPost_1 = require("../common/internalPost");
7
+ var internalPost_1 = require("../apis/common/internalPost");
8
8
  /**
9
9
  * Internal-only REST POST handler to send GraphQL request to given endpoint. By default, it will use IAM to authorize
10
10
  * the request. In some auth modes, the IAM auth has to be disabled. Here's how to set up the request auth correctly:
@@ -25,6 +25,6 @@ var post = function (contextSpec, input) {
25
25
  return (0, internalPost_1.post)((0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify, input);
26
26
  };
27
27
  exports.post = post;
28
- var internalPost_2 = require("../common/internalPost");
28
+ var internalPost_2 = require("../apis/common/internalPost");
29
29
  Object.defineProperty(exports, "cancel", { enumerable: true, get: function () { return internalPost_2.cancel; } });
30
30
  Object.defineProperty(exports, "updateRequestToBeCancellable", { enumerable: true, get: function () { return internalPost_2.updateRequestToBeCancellable; } });
@@ -0,0 +1,2 @@
1
+ export { isCancelError } from './errors/CancelledError';
2
+ export { get, post, put, del, head, patch } from './apis/server';
package/lib/server.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.patch = exports.head = exports.del = exports.put = exports.post = exports.get = exports.isCancelError = void 0;
6
+ var CancelledError_1 = require("./errors/CancelledError");
7
+ Object.defineProperty(exports, "isCancelError", { enumerable: true, get: function () { return CancelledError_1.isCancelError; } });
8
+ var server_1 = require("./apis/server");
9
+ Object.defineProperty(exports, "get", { enumerable: true, get: function () { return server_1.get; } });
10
+ Object.defineProperty(exports, "post", { enumerable: true, get: function () { return server_1.post; } });
11
+ Object.defineProperty(exports, "put", { enumerable: true, get: function () { return server_1.put; } });
12
+ Object.defineProperty(exports, "del", { enumerable: true, get: function () { return server_1.del; } });
13
+ Object.defineProperty(exports, "head", { enumerable: true, get: function () { return server_1.head; } });
14
+ Object.defineProperty(exports, "patch", { enumerable: true, get: function () { return server_1.patch; } });