@aws-amplify/api-rest 4.0.17-unstable.e316a2e.0 → 4.0.17

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 (40) hide show
  1. package/dist/cjs/apis/common/internalPost.js +2 -2
  2. package/dist/cjs/apis/common/internalPost.js.map +1 -1
  3. package/dist/cjs/apis/server.js +0 -1
  4. package/dist/cjs/apis/server.js.map +1 -1
  5. package/dist/cjs/utils/createCancellableOperation.js +1 -1
  6. package/dist/cjs/utils/createCancellableOperation.js.map +1 -1
  7. package/dist/cjs/utils/resolveHeaders.js.map +1 -1
  8. package/dist/cjs/utils/serviceError.js +2 -5
  9. package/dist/cjs/utils/serviceError.js.map +1 -1
  10. package/dist/esm/apis/common/handler.d.ts +3 -3
  11. package/dist/esm/apis/common/handler.mjs.map +1 -1
  12. package/dist/esm/apis/common/internalPost.mjs +2 -2
  13. package/dist/esm/apis/common/internalPost.mjs.map +1 -1
  14. package/dist/esm/apis/common/publicApis.d.ts +1 -1
  15. package/dist/esm/apis/common/publicApis.mjs.map +1 -1
  16. package/dist/esm/apis/index.mjs.map +1 -1
  17. package/dist/esm/apis/server.d.ts +0 -1
  18. package/dist/esm/apis/server.mjs +0 -1
  19. package/dist/esm/apis/server.mjs.map +1 -1
  20. package/dist/esm/types/index.d.ts +14 -14
  21. package/dist/esm/utils/createCancellableOperation.mjs +1 -1
  22. package/dist/esm/utils/createCancellableOperation.mjs.map +1 -1
  23. package/dist/esm/utils/resolveHeaders.mjs.map +1 -1
  24. package/dist/esm/utils/serviceError.mjs +2 -5
  25. package/dist/esm/utils/serviceError.mjs.map +1 -1
  26. package/package.json +101 -100
  27. package/src/apis/common/handler.ts +10 -8
  28. package/src/apis/common/internalPost.ts +11 -6
  29. package/src/apis/common/publicApis.ts +19 -16
  30. package/src/apis/index.ts +10 -8
  31. package/src/apis/server.ts +16 -15
  32. package/src/errors/CanceledError.ts +1 -0
  33. package/src/errors/assertValidatonError.ts +1 -1
  34. package/src/internals/server.ts +1 -1
  35. package/src/types/index.ts +14 -14
  36. package/src/utils/createCancellableOperation.ts +10 -6
  37. package/src/utils/parseSigningInfo.ts +2 -1
  38. package/src/utils/resolveApiUrl.ts +3 -1
  39. package/src/utils/resolveHeaders.ts +2 -2
  40. package/src/utils/serviceError.ts +7 -4
package/package.json CHANGED
@@ -1,102 +1,103 @@
1
1
  {
2
- "name": "@aws-amplify/api-rest",
3
- "private": false,
4
- "version": "4.0.17-unstable.e316a2e.0+e316a2e",
5
- "description": "Api-rest category of aws-amplify",
6
- "main": "./dist/cjs/index.js",
7
- "module": "./dist/esm/index.mjs",
8
- "typings": "./dist/esm/index.d.ts",
9
- "react-native": "./src/index.ts",
10
- "publishConfig": {
11
- "access": "public"
12
- },
13
- "scripts": {
14
- "test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
15
- "test:watch": "tslint 'src/**/*.ts' && jest -w 1 --watch",
16
- "build-with-test": "npm test && npm build",
17
- "build:umd": "webpack && webpack --config ./webpack.config.dev.js",
18
- "build:esm-cjs": "rollup -c rollup.config.mjs",
19
- "build:watch": "npm run build:esm-cjs -- --watch",
20
- "build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
21
- "clean": "npm run clean:size && rimraf dist lib lib-esm",
22
- "clean:size": "rimraf dual-publish-tmp tmp*",
23
- "format": "echo \"Not implemented\"",
24
- "lint": "tslint 'src/**/*.ts' && npm run ts-coverage",
25
- "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 70.0"
26
- },
27
- "exports": {
28
- ".": {
29
- "types": "./dist/esm/index.d.ts",
30
- "import": "./dist/esm/index.mjs",
31
- "require": "./dist/cjs/index.js",
32
- "react-native": "./src/index.ts"
33
- },
34
- "./server": {
35
- "types": "./dist/esm/server.d.ts",
36
- "import": "./dist/esm/server.mjs",
37
- "require": "./dist/cjs/server.js"
38
- },
39
- "./internals": {
40
- "types": "./dist/esm/internals/index.d.ts",
41
- "import": "./dist/esm/internals/index.mjs",
42
- "require": "./dist/cjs/internals/index.js",
43
- "react-native": "./src/internals/index.ts"
44
- },
45
- "./internals/server": {
46
- "types": "./dist/esm/internals/server.d.ts",
47
- "import": "./dist/esm/internals/server.mjs",
48
- "require": "./dist/cjs/internals/server.js"
49
- },
50
- "./package.json": "./package.json"
51
- },
52
- "typesVersions": {
53
- ">=4.2": {
54
- "server": [
55
- "./dist/esm/server.d.ts"
56
- ],
57
- "internals": [
58
- "./dist/esm/internals/index.d.ts"
59
- ],
60
- "internals/server": [
61
- "./dist/esm/internals/server.d.ts"
62
- ]
63
- }
64
- },
65
- "repository": {
66
- "type": "git",
67
- "url": "https://github.com/aws-amplify/amplify-js.git"
68
- },
69
- "author": "Amazon Web Services",
70
- "license": "Apache-2.0",
71
- "bugs": {
72
- "url": "https://github.com/aws/aws-amplify/issues"
73
- },
74
- "homepage": "https://aws-amplify.github.io/",
75
- "files": [
76
- "dist/cjs",
77
- "dist/esm",
78
- "src",
79
- "internals",
80
- "server"
81
- ],
82
- "dependencies": {
83
- "tslib": "^2.5.0"
84
- },
85
- "peerDependencies": {
86
- "@aws-amplify/core": "6.0.17-unstable.e316a2e.0+e316a2e"
87
- },
88
- "devDependencies": {
89
- "@aws-amplify/core": "6.0.17-unstable.e316a2e.0+e316a2e",
90
- "@aws-amplify/react-native": "1.0.17-unstable.e316a2e.0+e316a2e",
91
- "typescript": "5.0.2"
92
- },
93
- "size-limit": [
94
- {
95
- "name": "API (rest client)",
96
- "path": "./dist/esm/index.mjs",
97
- "import": "{ Amplify, RestAPI }",
98
- "limit": "31.5 kB"
99
- }
100
- ],
101
- "gitHead": "e316a2eb6129a30a16008892e7cdc17aefd914f9"
2
+ "name": "@aws-amplify/api-rest",
3
+ "private": false,
4
+ "version": "4.0.17",
5
+ "description": "Api-rest category of aws-amplify",
6
+ "main": "./dist/cjs/index.js",
7
+ "module": "./dist/esm/index.mjs",
8
+ "typings": "./dist/esm/index.d.ts",
9
+ "react-native": "./src/index.ts",
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "scripts": {
14
+ "test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
15
+ "test:watch": "tslint 'src/**/*.ts' && jest -w 1 --watch",
16
+ "build-with-test": "npm test && npm build",
17
+ "build:umd": "webpack && webpack --config ./webpack.config.dev.js",
18
+ "build:esm-cjs": "rollup -c rollup.config.mjs",
19
+ "build:watch": "npm run build:esm-cjs -- --watch",
20
+ "build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
21
+ "clean": "npm run clean:size && rimraf dist lib lib-esm",
22
+ "clean:size": "rimraf dual-publish-tmp tmp*",
23
+ "format": "echo \"Not implemented\"",
24
+ "lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
25
+ "lint:fix": "eslint '**/*.{ts,tsx}' --fix",
26
+ "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 70.0"
27
+ },
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/esm/index.d.ts",
31
+ "import": "./dist/esm/index.mjs",
32
+ "require": "./dist/cjs/index.js",
33
+ "react-native": "./src/index.ts"
34
+ },
35
+ "./server": {
36
+ "types": "./dist/esm/server.d.ts",
37
+ "import": "./dist/esm/server.mjs",
38
+ "require": "./dist/cjs/server.js"
39
+ },
40
+ "./internals": {
41
+ "types": "./dist/esm/internals/index.d.ts",
42
+ "import": "./dist/esm/internals/index.mjs",
43
+ "require": "./dist/cjs/internals/index.js",
44
+ "react-native": "./src/internals/index.ts"
45
+ },
46
+ "./internals/server": {
47
+ "types": "./dist/esm/internals/server.d.ts",
48
+ "import": "./dist/esm/internals/server.mjs",
49
+ "require": "./dist/cjs/internals/server.js"
50
+ },
51
+ "./package.json": "./package.json"
52
+ },
53
+ "typesVersions": {
54
+ ">=4.2": {
55
+ "server": [
56
+ "./dist/esm/server.d.ts"
57
+ ],
58
+ "internals": [
59
+ "./dist/esm/internals/index.d.ts"
60
+ ],
61
+ "internals/server": [
62
+ "./dist/esm/internals/server.d.ts"
63
+ ]
64
+ }
65
+ },
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "https://github.com/aws-amplify/amplify-js.git"
69
+ },
70
+ "author": "Amazon Web Services",
71
+ "license": "Apache-2.0",
72
+ "bugs": {
73
+ "url": "https://github.com/aws/aws-amplify/issues"
74
+ },
75
+ "homepage": "https://aws-amplify.github.io/",
76
+ "files": [
77
+ "dist/cjs",
78
+ "dist/esm",
79
+ "src",
80
+ "internals",
81
+ "server"
82
+ ],
83
+ "dependencies": {
84
+ "tslib": "^2.5.0"
85
+ },
86
+ "peerDependencies": {
87
+ "@aws-amplify/core": "^6.0.0"
88
+ },
89
+ "devDependencies": {
90
+ "@aws-amplify/core": "6.0.17",
91
+ "@aws-amplify/react-native": "1.0.17",
92
+ "typescript": "5.0.2"
93
+ },
94
+ "size-limit": [
95
+ {
96
+ "name": "API (rest client)",
97
+ "path": "./dist/esm/index.mjs",
98
+ "import": "{ Amplify, RestAPI }",
99
+ "limit": "31.5 kB"
100
+ }
101
+ ],
102
+ "gitHead": "c54a19c8a654a47d559cb0fd41c74bd2c3eb79ca"
102
103
  }
@@ -2,12 +2,12 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { AmplifyClassV6 } from '@aws-amplify/core';
4
4
  import {
5
- HttpRequest,
6
- unauthenticatedHandler,
7
5
  Headers,
6
+ HttpRequest,
7
+ authenticatedHandler,
8
8
  getRetryDecider,
9
9
  jitteredBackoff,
10
- authenticatedHandler,
10
+ unauthenticatedHandler,
11
11
  } from '@aws-amplify/core/internals/aws-client-utils';
12
12
  import {
13
13
  AWSCredentials,
@@ -28,10 +28,10 @@ type HandlerOptions = Omit<HttpRequest, 'body' | 'headers'> & {
28
28
  withCredentials?: boolean;
29
29
  };
30
30
 
31
- type SigningServiceInfo = {
31
+ interface SigningServiceInfo {
32
32
  service?: string;
33
33
  region?: string;
34
- };
34
+ }
35
35
 
36
36
  /**
37
37
  * Make REST API call with best-effort IAM auth.
@@ -46,7 +46,7 @@ type SigningServiceInfo = {
46
46
  export const transferHandler = async (
47
47
  amplify: AmplifyClassV6,
48
48
  options: HandlerOptions & { abortSignal: AbortSignal },
49
- signingServiceInfo?: SigningServiceInfo
49
+ signingServiceInfo?: SigningServiceInfo,
50
50
  ): Promise<RestApiResponse> => {
51
51
  const { url, method, headers, body, withCredentials, abortSignal } = options;
52
52
  const resolvedBody = body
@@ -88,6 +88,7 @@ export const transferHandler = async (
88
88
  ...baseOptions,
89
89
  });
90
90
  }
91
+
91
92
  // Clean-up un-modeled properties from response.
92
93
  return {
93
94
  statusCode: response.statusCode,
@@ -98,11 +99,11 @@ export const transferHandler = async (
98
99
 
99
100
  const iamAuthApplicable = (
100
101
  { headers }: HttpRequest,
101
- signingServiceInfo?: SigningServiceInfo
102
+ signingServiceInfo?: SigningServiceInfo,
102
103
  ) => !headers.authorization && !headers['x-api-key'] && !!signingServiceInfo;
103
104
 
104
105
  const resolveCredentials = async (
105
- amplify: AmplifyClassV6
106
+ amplify: AmplifyClassV6,
106
107
  ): Promise<AWSCredentials | null> => {
107
108
  try {
108
109
  const { credentials } = await amplify.Auth.fetchAuthSession();
@@ -112,5 +113,6 @@ const resolveCredentials = async (
112
113
  } catch (e) {
113
114
  logger.debug('No credentials available, the request will be unsigned.');
114
115
  }
116
+
115
117
  return null;
116
118
  };
@@ -4,9 +4,10 @@
4
4
  import { AmplifyClassV6 } from '@aws-amplify/core';
5
5
 
6
6
  import { InternalPostInput, RestApiResponse } from '../../types';
7
- import { transferHandler } from './handler';
8
7
  import { createCancellableOperation } from '../../utils';
9
8
 
9
+ import { transferHandler } from './handler';
10
+
10
11
  /**
11
12
  * This weak map provides functionality to cancel a request given the promise containing the `post` request.
12
13
  *
@@ -25,7 +26,7 @@ const cancelTokenMap = new WeakMap<Promise<any>, AbortController>();
25
26
  */
26
27
  export const post = (
27
28
  amplify: AmplifyClassV6,
28
- { url, options, abortController }: InternalPostInput
29
+ { url, options, abortController }: InternalPostInput,
29
30
  ): Promise<RestApiResponse> => {
30
31
  const controller = abortController ?? new AbortController();
31
32
  const responsePromise = createCancellableOperation(async () => {
@@ -37,14 +38,16 @@ export const post = (
37
38
  ...options,
38
39
  abortSignal: controller.signal,
39
40
  },
40
- options?.signingServiceInfo
41
+ options?.signingServiceInfo,
41
42
  );
43
+
42
44
  return response;
43
45
  }, controller);
44
46
 
45
47
  const responseWithCleanUp = responsePromise.finally(() => {
46
48
  cancelTokenMap.delete(responseWithCleanUp);
47
49
  });
50
+
48
51
  return responseWithCleanUp;
49
52
  };
50
53
 
@@ -55,7 +58,7 @@ export const post = (
55
58
  */
56
59
  export const cancel = (
57
60
  promise: Promise<RestApiResponse>,
58
- message?: string
61
+ message?: string,
59
62
  ): boolean => {
60
63
  const controller = cancelTokenMap.get(promise);
61
64
  if (controller) {
@@ -63,10 +66,12 @@ export const cancel = (
63
66
  if (message && controller.signal.reason !== message) {
64
67
  // In runtimes where `AbortSignal.reason` is not supported, we track the reason ourselves.
65
68
  // @ts-expect-error reason is read-only property.
66
- controller.signal['reason'] = message;
69
+ controller.signal.reason = message;
67
70
  }
71
+
68
72
  return true;
69
73
  }
74
+
70
75
  return false;
71
76
  };
72
77
 
@@ -75,7 +80,7 @@ export const cancel = (
75
80
  */
76
81
  export const updateRequestToBeCancellable = (
77
82
  promise: Promise<any>,
78
- controller: AbortController
83
+ controller: AbortController,
79
84
  ) => {
80
85
  cancelTokenMap.set(promise, controller);
81
86
  };
@@ -2,34 +2,36 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { AmplifyClassV6 } from '@aws-amplify/core';
5
+
5
6
  import {
6
- GetInput,
7
- GetOperation,
8
- PostInput,
9
- PostOperation,
10
- PutInput,
11
- PutOperation,
7
+ ApiInput,
12
8
  DeleteInput,
13
9
  DeleteOperation,
10
+ GetInput,
11
+ GetOperation,
14
12
  HeadInput,
15
13
  HeadOperation,
16
14
  PatchInput,
17
15
  PatchOperation,
18
- ApiInput,
16
+ PostInput,
17
+ PostOperation,
18
+ PutInput,
19
+ PutOperation,
19
20
  RestApiOptionsBase,
20
21
  } from '../../types';
21
22
  import {
22
- resolveApiUrl,
23
23
  createCancellableOperation,
24
24
  logger,
25
25
  parseSigningInfo,
26
+ resolveApiUrl,
26
27
  } from '../../utils';
28
+
27
29
  import { transferHandler } from './handler';
28
30
 
29
31
  const publicHandler = (
30
32
  amplify: AmplifyClassV6,
31
33
  options: ApiInput<RestApiOptionsBase>,
32
- method: string
34
+ method: string,
33
35
  ) =>
34
36
  createCancellableOperation(async abortSignal => {
35
37
  const { apiName, options: apiOptions = {}, path: apiPath } = options;
@@ -37,7 +39,7 @@ const publicHandler = (
37
39
  amplify,
38
40
  apiName,
39
41
  apiPath,
40
- apiOptions?.queryParams
42
+ apiOptions?.queryParams,
41
43
  );
42
44
  const libraryConfigHeaders =
43
45
  await amplify.libraryOptions?.API?.REST?.headers?.({
@@ -57,8 +59,9 @@ const publicHandler = (
57
59
  method,
58
60
  url,
59
61
  headers,
60
- `IAM signing options: ${JSON.stringify(signingServiceInfo)}`
62
+ `IAM signing options: ${JSON.stringify(signingServiceInfo)}`,
61
63
  );
64
+
62
65
  return transferHandler(
63
66
  amplify,
64
67
  {
@@ -68,7 +71,7 @@ const publicHandler = (
68
71
  headers,
69
72
  abortSignal,
70
73
  },
71
- signingServiceInfo
74
+ signingServiceInfo,
72
75
  );
73
76
  });
74
77
 
@@ -77,7 +80,7 @@ export const get = (amplify: AmplifyClassV6, input: GetInput): GetOperation =>
77
80
 
78
81
  export const post = (
79
82
  amplify: AmplifyClassV6,
80
- input: PostInput
83
+ input: PostInput,
81
84
  ): PostOperation => publicHandler(amplify, input, 'POST');
82
85
 
83
86
  export const put = (amplify: AmplifyClassV6, input: PutInput): PutOperation =>
@@ -85,15 +88,15 @@ export const put = (amplify: AmplifyClassV6, input: PutInput): PutOperation =>
85
88
 
86
89
  export const del = (
87
90
  amplify: AmplifyClassV6,
88
- input: DeleteInput
91
+ input: DeleteInput,
89
92
  ): DeleteOperation => publicHandler(amplify, input, 'DELETE');
90
93
 
91
94
  export const head = (
92
95
  amplify: AmplifyClassV6,
93
- input: HeadInput
96
+ input: HeadInput,
94
97
  ): HeadOperation => publicHandler(amplify, input, 'HEAD');
95
98
 
96
99
  export const patch = (
97
100
  amplify: AmplifyClassV6,
98
- input: PatchInput
101
+ input: PatchInput,
99
102
  ): PatchOperation => publicHandler(amplify, input, 'PATCH');
package/src/apis/index.ts CHANGED
@@ -2,14 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { Amplify } from '@aws-amplify/core';
5
- import {
6
- get as commonGet,
7
- post as commonPost,
8
- put as commonPut,
9
- del as commonDel,
10
- head as commonHead,
11
- patch as commonPatch,
12
- } from './common/publicApis';
5
+
13
6
  import {
14
7
  DeleteInput,
15
8
  DeleteOperation,
@@ -26,6 +19,15 @@ import {
26
19
  } from '../types';
27
20
  import { RestApiError } from '../errors';
28
21
 
22
+ import {
23
+ del as commonDel,
24
+ get as commonGet,
25
+ head as commonHead,
26
+ patch as commonPatch,
27
+ post as commonPost,
28
+ put as commonPut,
29
+ } from './common/publicApis';
30
+
29
31
  /**
30
32
  * GET HTTP request
31
33
  * @param {GetInput} input - Input for GET operation
@@ -5,14 +5,7 @@ import {
5
5
  AmplifyServer,
6
6
  getAmplifyServerContext,
7
7
  } from '@aws-amplify/core/internals/adapter-core';
8
- import {
9
- get as commonGet,
10
- post as commonPost,
11
- put as commonPut,
12
- del as commonDel,
13
- head as commonHead,
14
- patch as commonPatch,
15
- } from './common/publicApis';
8
+
16
9
  import {
17
10
  DeleteInput,
18
11
  DeleteOperation,
@@ -29,6 +22,15 @@ import {
29
22
  } from '../types';
30
23
  import { RestApiError } from '../errors';
31
24
 
25
+ import {
26
+ del as commonDel,
27
+ get as commonGet,
28
+ head as commonHead,
29
+ patch as commonPatch,
30
+ post as commonPost,
31
+ put as commonPut,
32
+ } from './common/publicApis';
33
+
32
34
  /**
33
35
  * GET HTTP request (server-side)
34
36
  * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
@@ -52,11 +54,10 @@ import { RestApiError } from '../errors';
52
54
  * },
53
55
  * });
54
56
  * ```
55
- * @see {@link clientGet}
56
57
  */
57
58
  export const get = (
58
59
  contextSpec: AmplifyServer.ContextSpec,
59
- input: GetInput
60
+ input: GetInput,
60
61
  ): GetOperation =>
61
62
  commonGet(getAmplifyServerContext(contextSpec).amplify, input);
62
63
 
@@ -86,7 +87,7 @@ export const get = (
86
87
  */
87
88
  export const post = (
88
89
  contextSpec: AmplifyServer.ContextSpec,
89
- input: PostInput
90
+ input: PostInput,
90
91
  ): PostOperation =>
91
92
  commonPost(getAmplifyServerContext(contextSpec).amplify, input);
92
93
 
@@ -116,7 +117,7 @@ export const post = (
116
117
  */
117
118
  export const put = (
118
119
  contextSpec: AmplifyServer.ContextSpec,
119
- input: PutInput
120
+ input: PutInput,
120
121
  ): PutOperation =>
121
122
  commonPut(getAmplifyServerContext(contextSpec).amplify, input);
122
123
 
@@ -145,7 +146,7 @@ export const put = (
145
146
  */
146
147
  export const del = (
147
148
  contextSpec: AmplifyServer.ContextSpec,
148
- input: DeleteInput
149
+ input: DeleteInput,
149
150
  ): DeleteOperation =>
150
151
  commonDel(getAmplifyServerContext(contextSpec).amplify, input);
151
152
 
@@ -174,7 +175,7 @@ export const del = (
174
175
  */
175
176
  export const head = (
176
177
  contextSpec: AmplifyServer.ContextSpec,
177
- input: HeadInput
178
+ input: HeadInput,
178
179
  ): HeadOperation =>
179
180
  commonHead(getAmplifyServerContext(contextSpec).amplify, input);
180
181
 
@@ -204,6 +205,6 @@ export const head = (
204
205
  */
205
206
  export const patch = (
206
207
  contextSpec: AmplifyServer.ContextSpec,
207
- input: PatchInput
208
+ input: PatchInput,
208
209
  ): PatchOperation =>
209
210
  commonPatch(getAmplifyServerContext(contextSpec).amplify, input);
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { AmplifyErrorParams } from '@aws-amplify/core/internals/utils';
5
+
5
6
  import { RestApiError } from './RestApiError';
6
7
 
7
8
  /**
@@ -9,7 +9,7 @@ import { RestApiValidationErrorCode, validationErrorMap } from './validation';
9
9
  */
10
10
  export function assertValidationError(
11
11
  assertion: boolean,
12
- name: RestApiValidationErrorCode
12
+ name: RestApiValidationErrorCode,
13
13
  ): asserts assertion {
14
14
  const { message, recoverySuggestion } = validationErrorMap[name];
15
15
 
@@ -26,7 +26,7 @@ import { InternalPostInput } from '../types';
26
26
  */
27
27
  export const post = (
28
28
  contextSpec: AmplifyServer.ContextSpec,
29
- input: InternalPostInput
29
+ input: InternalPostInput,
30
30
  ) => {
31
31
  return internalPost(getAmplifyServerContext(contextSpec).amplify, input);
32
32
  };
@@ -19,7 +19,7 @@ export type HeadOperation = Operation<Omit<RestApiResponse, 'body'>>;
19
19
  /**
20
20
  * @internal
21
21
  */
22
- export type RestApiOptionsBase = {
22
+ export interface RestApiOptionsBase {
23
23
  headers?: Headers;
24
24
  queryParams?: Record<string, string>;
25
25
  body?: DocumentType | FormData;
@@ -35,7 +35,7 @@ export type RestApiOptionsBase = {
35
35
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials}
36
36
  */
37
37
  withCredentials?: boolean;
38
- };
38
+ }
39
39
 
40
40
  type Headers = Record<string, string>;
41
41
 
@@ -44,16 +44,16 @@ type Headers = Record<string, string>;
44
44
  *
45
45
  * @internal
46
46
  */
47
- export type Operation<Response> = {
47
+ export interface Operation<Response> {
48
48
  response: Promise<Response>;
49
- cancel: (abortMessage?: string) => void;
50
- };
49
+ cancel(abortMessage?: string): void;
50
+ }
51
51
 
52
- type ResponsePayload = {
53
- blob: () => Promise<Blob>;
54
- json: () => Promise<DocumentType>;
55
- text: () => Promise<string>;
56
- };
52
+ interface ResponsePayload {
53
+ blob(): Promise<Blob>;
54
+ json(): Promise<DocumentType>;
55
+ text(): Promise<string>;
56
+ }
57
57
 
58
58
  /**
59
59
  * Basic response type of REST API.
@@ -69,7 +69,7 @@ export interface RestApiResponse {
69
69
  /**
70
70
  * @internal
71
71
  */
72
- export type ApiInput<Options> = {
72
+ export interface ApiInput<Options> {
73
73
  /**
74
74
  * Name of the REST API configured in Amplify singleton.
75
75
  */
@@ -82,13 +82,13 @@ export type ApiInput<Options> = {
82
82
  * Options to overwrite the REST API call behavior.
83
83
  */
84
84
  options?: Options;
85
- };
85
+ }
86
86
 
87
87
  /**
88
88
  * Input type to invoke REST POST API from GraphQl client.
89
89
  * @internal
90
90
  */
91
- export type InternalPostInput = {
91
+ export interface InternalPostInput {
92
92
  // Resolved GraphQl endpoint url
93
93
  url: URL;
94
94
  options?: RestApiOptionsBase & {
@@ -111,4 +111,4 @@ export type InternalPostInput = {
111
111
  * controller.
112
112
  */
113
113
  abortController?: AbortController;
114
- };
114
+ }