@aws-amplify/api-rest 2.0.49-next.13 → 2.0.49-next.32

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.
@@ -1,138 +0,0 @@
1
- import { apiOptions, ApiInfo } from './types';
2
- import { CancelTokenSource } from 'axios';
3
- /**
4
- * HTTP Client for REST requests. Send and receive JSON data.
5
- * Sign request with AWS credentials if available
6
- * Usage:
7
- <pre>
8
- const restClient = new RestClient();
9
- restClient.get('...')
10
- .then(function(data) {
11
- console.log(data);
12
- })
13
- .catch(err => console.log(err));
14
- </pre>
15
- */
16
- export declare class RestClient {
17
- private _options;
18
- private _region;
19
- private _service;
20
- private _custom_header;
21
- /**
22
- * This weak map provides functionality to let clients cancel
23
- * in-flight axios requests. https://github.com/axios/axios#cancellation
24
- *
25
- * 1. For every axios request, a unique cancel token is generated and added in the request.
26
- * 2. Promise for fulfilling the request is then mapped to that unique cancel token.
27
- * 3. The promise is returned to the client.
28
- * 4. Clients can either wait for the promise to fulfill or call `API.cancel(promise)` to cancel the request.
29
- * 5. If `API.cancel(promise)` is called, then the corresponding cancel token is retrieved from the map below.
30
- * 6. Promise returned to the client will be in rejected state with the error provided during cancel.
31
- * 7. Clients can check if the error is because of cancelling by calling `API.isCancel(error)`.
32
- *
33
- * For more details, see https://github.com/aws-amplify/amplify-js/pull/3769#issuecomment-552660025
34
- */
35
- private _cancelTokenMap;
36
- Credentials: import("@aws-amplify/core").CredentialsClass;
37
- /**
38
- * @param {RestClientOptions} [options] - Instance options
39
- */
40
- constructor(options: apiOptions);
41
- /**
42
- * Update AWS credentials
43
- * @param {AWSCredentials} credentials - AWS credentials
44
- *
45
- updateCredentials(credentials: AWSCredentials) {
46
- this.options.credentials = credentials;
47
- }
48
- */
49
- /**
50
- * Basic HTTP request. Customizable
51
- * @param {string | ApiInfo } urlOrApiInfo - Full request URL or Api information
52
- * @param {string} method - Request HTTP method
53
- * @param {json} [init] - Request extra params
54
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
55
- */
56
- ajax(urlOrApiInfo: string | ApiInfo, method: string, init: any): Promise<any>;
57
- /**
58
- * GET HTTP request
59
- * @param {string | ApiInfo } urlOrApiInfo - Full request URL or Api information
60
- * @param {JSON} init - Request extra params
61
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
62
- */
63
- get(urlOrApiInfo: string | ApiInfo, init: any): Promise<any>;
64
- /**
65
- * PUT HTTP request
66
- * @param {string | ApiInfo } urlOrApiInfo - Full request URL or Api information
67
- * @param {json} init - Request extra params
68
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
69
- */
70
- put(urlOrApiInfo: string | ApiInfo, init: any): Promise<any>;
71
- /**
72
- * PATCH HTTP request
73
- * @param {string | ApiInfo } urlOrApiInfo - Full request URL or Api information
74
- * @param {json} init - Request extra params
75
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
76
- */
77
- patch(urlOrApiInfo: string | ApiInfo, init: any): Promise<any>;
78
- /**
79
- * POST HTTP request
80
- * @param {string | ApiInfo } urlOrApiInfo - Full request URL or Api information
81
- * @param {json} init - Request extra params
82
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
83
- */
84
- post(urlOrApiInfo: string | ApiInfo, init: any): Promise<any>;
85
- /**
86
- * DELETE HTTP request
87
- * @param {string | ApiInfo } urlOrApiInfo - Full request URL or Api information
88
- * @param {json} init - Request extra params
89
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
90
- */
91
- del(urlOrApiInfo: string | ApiInfo, init: any): Promise<any>;
92
- /**
93
- * HEAD HTTP request
94
- * @param {string | ApiInfo } urlOrApiInfo - Full request URL or Api information
95
- * @param {json} init - Request extra params
96
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
97
- */
98
- head(urlOrApiInfo: string | ApiInfo, init: any): Promise<any>;
99
- /**
100
- * Cancel an inflight API request
101
- * @param {Promise<any>} request - The request promise to cancel
102
- * @param {string} [message] - A message to include in the cancelation exception
103
- */
104
- cancel(request: Promise<any>, message?: string): boolean;
105
- /**
106
- * Check if the request has a corresponding cancel token in the WeakMap.
107
- * @params request - The request promise
108
- * @return if the request has a corresponding cancel token.
109
- */
110
- hasCancelToken(request: Promise<any>): boolean;
111
- /**
112
- * Checks to see if an error thrown is from an api request cancellation
113
- * @param {any} error - Any error
114
- * @return {boolean} - A boolean indicating if the error was from an api request cancellation
115
- */
116
- isCancel(error: any): boolean;
117
- /**
118
- * Retrieves a new and unique cancel token which can be
119
- * provided in an axios request to be cancelled later.
120
- */
121
- getCancellableToken(): CancelTokenSource;
122
- /**
123
- * Updates the weakmap with a response promise and its
124
- * cancel token such that the cancel token can be easily
125
- * retrieved (and used for cancelling the request)
126
- */
127
- updateRequestToBeCancellable(promise: Promise<any>, cancelTokenSource: CancelTokenSource): void;
128
- /**
129
- * Getting endpoint for API
130
- * @param {string} apiName - The name of the api
131
- * @return {string} - The endpoint of the api
132
- */
133
- endpoint(apiName: string): string;
134
- /** private methods **/
135
- private _signed;
136
- private _request;
137
- private _parseUrl;
138
- }
package/lib/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { RestAPI } from './RestAPI';
2
- export { RestAPI, RestAPIClass } from './RestAPI';
3
- export { RestClient } from './RestClient';
4
- export default RestAPI;
@@ -1,50 +0,0 @@
1
- /**
2
- * RestClient instance options
3
- */
4
- export declare class RestClientOptions {
5
- /** AWS credentials */
6
- credentials: AWSCredentials;
7
- /**
8
- * Lookup key of AWS credentials.
9
- * If credentials not provided then lookup from sessionStorage.
10
- * Default 'awsCredentials'
11
- */
12
- credentials_key: string;
13
- /** Additional headers for all requests send by this client. e.g. user-agent */
14
- headers: object;
15
- constructor();
16
- }
17
- /**
18
- * AWS credentials needed for RestClient
19
- */
20
- export declare class AWSCredentials {
21
- /**
22
- * Secret Access Key
23
- *
24
- * [Access Key ID and Secret Access Key]
25
- * (http://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys)
26
- */
27
- secretAccessKey: string;
28
- /**
29
- * Access Key ID
30
- *
31
- * [Access Key ID and Secret Access Key]
32
- * (http://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys)
33
- */
34
- accessKeyId: string;
35
- /** Access Token of current session */
36
- sessionToken: string;
37
- }
38
- export interface apiOptions {
39
- headers: object;
40
- endpoints: object;
41
- credentials?: object;
42
- }
43
- export declare type ApiInfo = {
44
- endpoint: string;
45
- region?: string;
46
- service?: string;
47
- custom_header?: () => {
48
- [key: string]: string;
49
- };
50
- };
@@ -1,6 +0,0 @@
1
- var config = require('./webpack.config.js');
2
-
3
- var entry = {
4
- 'aws-amplify-api-rest': './lib-esm/index.js',
5
- };
6
- module.exports = Object.assign(config, { entry, mode: 'development' });