@aws-amplify/api-rest 3.5.6-api-v6-models.b3abc9b.0 → 4.0.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 (147) hide show
  1. package/README.md +3 -0
  2. package/internals/package.json +8 -0
  3. package/internals/server/package.json +8 -0
  4. package/lib/apis/common/handler.d.ts +27 -0
  5. package/lib/apis/common/handler.js +73 -0
  6. package/lib/apis/common/internalPost.d.ts +16 -0
  7. package/lib/apis/common/internalPost.js +65 -0
  8. package/lib/apis/common/publicApis.d.ts +8 -0
  9. package/lib/apis/common/publicApis.js +44 -0
  10. package/lib/apis/index.d.ts +203 -0
  11. package/lib/apis/index.js +215 -0
  12. package/lib/apis/server.d.ts +151 -0
  13. package/lib/apis/server.js +162 -0
  14. package/lib/errors/CanceledError.d.ts +17 -0
  15. package/lib/errors/CanceledError.js +32 -0
  16. package/lib/errors/RestApiError.d.ts +4 -0
  17. package/lib/errors/RestApiError.js +15 -0
  18. package/lib/errors/assertValidatonError.d.ts +5 -0
  19. package/lib/errors/assertValidatonError.js +17 -0
  20. package/lib/errors/index.d.ts +4 -0
  21. package/lib/errors/index.js +15 -0
  22. package/lib/errors/validation.d.ts +6 -0
  23. package/lib/errors/validation.js +19 -0
  24. package/lib/index.d.ts +2 -2
  25. package/lib/index.js +10 -6
  26. package/lib/internals/index.d.ts +19 -0
  27. package/lib/internals/index.js +30 -0
  28. package/lib/internals/server.d.ts +20 -0
  29. package/lib/internals/server.js +30 -0
  30. package/lib/server.d.ts +2 -0
  31. package/lib/server.js +14 -0
  32. package/lib/tsconfig.tsbuildinfo +1 -0
  33. package/lib/types/index.d.ts +90 -37
  34. package/lib/types/index.js +0 -23
  35. package/lib/utils/constants.d.ts +8 -0
  36. package/lib/utils/constants.js +13 -0
  37. package/lib/utils/createCancellableOperation.d.ts +12 -0
  38. package/lib/utils/createCancellableOperation.js +63 -0
  39. package/lib/utils/index.d.ts +6 -0
  40. package/lib/utils/index.js +17 -0
  41. package/lib/utils/logger.d.ts +2 -0
  42. package/lib/utils/logger.js +7 -0
  43. package/lib/utils/normalizeHeaders.d.ts +1 -0
  44. package/lib/utils/normalizeHeaders.js +13 -0
  45. package/lib/utils/parseSigningInfo.d.ts +14 -0
  46. package/lib/utils/parseSigningInfo.js +41 -0
  47. package/lib/utils/resolveApiUrl.d.ts +12 -0
  48. package/lib/utils/resolveApiUrl.js +40 -0
  49. package/lib/utils/resolveCredentials.d.ts +5 -0
  50. package/lib/utils/resolveCredentials.js +15 -0
  51. package/lib/utils/serviceError.d.ts +10 -0
  52. package/lib/utils/serviceError.js +30 -0
  53. package/lib-esm/apis/common/handler.d.ts +27 -0
  54. package/lib-esm/apis/common/handler.js +69 -0
  55. package/lib-esm/apis/common/internalPost.d.ts +16 -0
  56. package/lib-esm/apis/common/internalPost.js +59 -0
  57. package/lib-esm/apis/common/publicApis.d.ts +8 -0
  58. package/lib-esm/apis/common/publicApis.js +35 -0
  59. package/lib-esm/apis/index.d.ts +203 -0
  60. package/lib-esm/apis/index.js +206 -0
  61. package/lib-esm/apis/server.d.ts +151 -0
  62. package/lib-esm/apis/server.js +153 -0
  63. package/lib-esm/errors/CanceledError.d.ts +17 -0
  64. package/lib-esm/errors/CanceledError.js +27 -0
  65. package/lib-esm/errors/RestApiError.d.ts +4 -0
  66. package/lib-esm/errors/RestApiError.js +11 -0
  67. package/lib-esm/errors/assertValidatonError.d.ts +5 -0
  68. package/lib-esm/errors/assertValidatonError.js +13 -0
  69. package/lib-esm/errors/index.d.ts +4 -0
  70. package/lib-esm/errors/index.js +6 -0
  71. package/lib-esm/errors/validation.d.ts +6 -0
  72. package/lib-esm/errors/validation.js +16 -0
  73. package/lib-esm/index.d.ts +2 -2
  74. package/lib-esm/index.js +2 -3
  75. package/lib-esm/internals/index.d.ts +19 -0
  76. package/lib-esm/internals/index.js +24 -0
  77. package/lib-esm/internals/server.d.ts +20 -0
  78. package/lib-esm/internals/server.js +24 -0
  79. package/lib-esm/server.d.ts +2 -0
  80. package/lib-esm/server.js +4 -0
  81. package/lib-esm/tsconfig.tsbuildinfo +1 -0
  82. package/lib-esm/types/index.d.ts +90 -37
  83. package/lib-esm/types/index.js +1 -23
  84. package/lib-esm/utils/constants.d.ts +8 -0
  85. package/lib-esm/utils/constants.js +10 -0
  86. package/lib-esm/utils/createCancellableOperation.d.ts +12 -0
  87. package/lib-esm/utils/createCancellableOperation.js +59 -0
  88. package/lib-esm/utils/index.d.ts +6 -0
  89. package/lib-esm/utils/index.js +8 -0
  90. package/lib-esm/utils/logger.d.ts +2 -0
  91. package/lib-esm/utils/logger.js +4 -0
  92. package/lib-esm/utils/normalizeHeaders.d.ts +1 -0
  93. package/lib-esm/utils/normalizeHeaders.js +9 -0
  94. package/lib-esm/utils/parseSigningInfo.d.ts +14 -0
  95. package/lib-esm/utils/parseSigningInfo.js +37 -0
  96. package/lib-esm/utils/resolveApiUrl.d.ts +12 -0
  97. package/lib-esm/utils/resolveApiUrl.js +36 -0
  98. package/lib-esm/utils/resolveCredentials.d.ts +5 -0
  99. package/lib-esm/utils/resolveCredentials.js +11 -0
  100. package/lib-esm/utils/serviceError.d.ts +10 -0
  101. package/lib-esm/utils/serviceError.js +25 -0
  102. package/package.json +113 -105
  103. package/server/package.json +8 -0
  104. package/src/apis/common/handler.ts +109 -0
  105. package/src/apis/common/internalPost.ts +81 -0
  106. package/src/apis/common/publicApis.ts +99 -0
  107. package/src/apis/index.ts +239 -0
  108. package/src/apis/server.ts +209 -0
  109. package/src/errors/CanceledError.ts +33 -0
  110. package/src/errors/RestApiError.ts +17 -0
  111. package/src/errors/assertValidatonError.ts +19 -0
  112. package/src/errors/index.ts +7 -0
  113. package/src/errors/validation.ts +20 -0
  114. package/src/index.ts +2 -2
  115. package/src/internals/index.ts +31 -0
  116. package/src/internals/server.ts +37 -0
  117. package/src/server.ts +5 -0
  118. package/src/types/index.ts +95 -44
  119. package/src/utils/constants.ts +15 -0
  120. package/src/utils/createCancellableOperation.ts +94 -0
  121. package/src/utils/index.ts +9 -0
  122. package/src/utils/logger.ts +6 -0
  123. package/src/utils/normalizeHeaders.ts +10 -0
  124. package/src/utils/parseSigningInfo.ts +52 -0
  125. package/src/utils/resolveApiUrl.ts +51 -0
  126. package/src/utils/resolveCredentials.ts +17 -0
  127. package/src/utils/serviceError.ts +35 -0
  128. package/lib/.tsbuildinfo +0 -3
  129. package/lib/RestAPI.d.ts +0 -108
  130. package/lib/RestAPI.js +0 -282
  131. package/lib/RestAPI.js.map +0 -1
  132. package/lib/RestClient.d.ts +0 -138
  133. package/lib/RestClient.js +0 -368
  134. package/lib/RestClient.js.map +0 -1
  135. package/lib/index.js.map +0 -1
  136. package/lib/types/index.js.map +0 -1
  137. package/lib-esm/.tsbuildinfo +0 -3
  138. package/lib-esm/RestAPI.d.ts +0 -108
  139. package/lib-esm/RestAPI.js +0 -280
  140. package/lib-esm/RestAPI.js.map +0 -1
  141. package/lib-esm/RestClient.d.ts +0 -138
  142. package/lib-esm/RestClient.js +0 -366
  143. package/lib-esm/RestClient.js.map +0 -1
  144. package/lib-esm/index.js.map +0 -1
  145. package/lib-esm/types/index.js.map +0 -1
  146. package/src/RestAPI.ts +0 -338
  147. package/src/RestClient.ts +0 -417
package/lib/RestAPI.js DELETED
@@ -1,282 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
- // SPDX-License-Identifier: Apache-2.0
6
- var RestClient_1 = require("./RestClient");
7
- var core_1 = require("@aws-amplify/core");
8
- var logger = new core_1.ConsoleLogger('RestAPI');
9
- /**
10
- * Export Cloud Logic APIs
11
- */
12
- var RestAPIClass = /** @class */ (function () {
13
- /**
14
- * Initialize Rest API with AWS configuration
15
- * @param {Object} options - Configuration object for API
16
- */
17
- function RestAPIClass(options) {
18
- this._api = null;
19
- this.Credentials = core_1.Credentials;
20
- this._options = options;
21
- logger.debug('API Options', this._options);
22
- }
23
- RestAPIClass.prototype.getModuleName = function () {
24
- return 'RestAPI';
25
- };
26
- /**
27
- * Configure API part with aws configurations
28
- * @param {Object} config - Configuration of the API
29
- * @return {Object} - The current configuration
30
- */
31
- RestAPIClass.prototype.configure = function (options) {
32
- var _a = options || {}, _b = _a.API, API = _b === void 0 ? {} : _b, otherOptions = tslib_1.__rest(_a, ["API"]);
33
- var opt = tslib_1.__assign(tslib_1.__assign({}, otherOptions), API);
34
- logger.debug('configure Rest API', { opt: opt });
35
- if (opt['aws_project_region']) {
36
- if (opt['aws_cloud_logic_custom']) {
37
- var custom = opt['aws_cloud_logic_custom'];
38
- opt.endpoints =
39
- typeof custom === 'string' ? JSON.parse(custom) : custom;
40
- }
41
- opt = Object.assign({}, opt, {
42
- region: opt['aws_project_region'],
43
- header: {},
44
- });
45
- }
46
- if (Array.isArray(opt.endpoints)) {
47
- // Check if endpoints has custom_headers and validate if is a function
48
- opt.endpoints.forEach(function (endpoint) {
49
- if (typeof endpoint.custom_header !== 'undefined' &&
50
- typeof endpoint.custom_header !== 'function') {
51
- logger.warn('Rest API ' + endpoint.name + ', custom_header should be a function');
52
- endpoint.custom_header = undefined;
53
- }
54
- });
55
- }
56
- else if (this._options && Array.isArray(this._options.endpoints)) {
57
- opt.endpoints = this._options.endpoints;
58
- }
59
- else {
60
- opt.endpoints = [];
61
- }
62
- this._options = Object.assign({}, this._options, opt);
63
- this.createInstance();
64
- return this._options;
65
- };
66
- /**
67
- * Create an instance of API for the library
68
- * @return - A promise of true if Success
69
- */
70
- RestAPIClass.prototype.createInstance = function () {
71
- logger.debug('create Rest API instance');
72
- this._api = new RestClient_1.RestClient(this._options);
73
- // Share Amplify instance with client for SSR
74
- this._api.Credentials = this.Credentials;
75
- return true;
76
- };
77
- /**
78
- * Make a GET request
79
- * @param {string} apiName - The api name of the request
80
- * @param {string} path - The path of the request
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
- RestAPIClass.prototype.get = function (apiName, path, init) {
85
- try {
86
- var apiInfo = this.getEndpointInfo(apiName, path);
87
- var cancellableToken = this._api.getCancellableToken();
88
- var initParams = Object.assign({}, init);
89
- initParams.cancellableToken = cancellableToken;
90
- var responsePromise = this._api.get(apiInfo, initParams);
91
- this._api.updateRequestToBeCancellable(responsePromise, cancellableToken);
92
- return responsePromise;
93
- }
94
- catch (err) {
95
- return Promise.reject(err.message);
96
- }
97
- };
98
- /**
99
- * Make a POST request
100
- * @param {string} apiName - The api name of the request
101
- * @param {string} path - The path of the request
102
- * @param {json} [init] - Request extra params
103
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
104
- */
105
- RestAPIClass.prototype.post = function (apiName, path, init) {
106
- try {
107
- var apiInfo = this.getEndpointInfo(apiName, path);
108
- var cancellableToken = this._api.getCancellableToken();
109
- var initParams = Object.assign({}, init);
110
- initParams.cancellableToken = cancellableToken;
111
- var responsePromise = this._api.post(apiInfo, initParams);
112
- this._api.updateRequestToBeCancellable(responsePromise, cancellableToken);
113
- return responsePromise;
114
- }
115
- catch (err) {
116
- return Promise.reject(err.message);
117
- }
118
- };
119
- /**
120
- * Make a PUT request
121
- * @param {string} apiName - The api name of the request
122
- * @param {string} path - The path of the request
123
- * @param {json} [init] - Request extra params
124
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
125
- */
126
- RestAPIClass.prototype.put = function (apiName, path, init) {
127
- try {
128
- var apiInfo = this.getEndpointInfo(apiName, path);
129
- var cancellableToken = this._api.getCancellableToken();
130
- var initParams = Object.assign({}, init);
131
- initParams.cancellableToken = cancellableToken;
132
- var responsePromise = this._api.put(apiInfo, initParams);
133
- this._api.updateRequestToBeCancellable(responsePromise, cancellableToken);
134
- return responsePromise;
135
- }
136
- catch (err) {
137
- return Promise.reject(err.message);
138
- }
139
- };
140
- /**
141
- * Make a PATCH request
142
- * @param {string} apiName - The api name of the request
143
- * @param {string} path - The path of the request
144
- * @param {json} [init] - Request extra params
145
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
146
- */
147
- RestAPIClass.prototype.patch = function (apiName, path, init) {
148
- try {
149
- var apiInfo = this.getEndpointInfo(apiName, path);
150
- var cancellableToken = this._api.getCancellableToken();
151
- var initParams = Object.assign({}, init);
152
- initParams.cancellableToken = cancellableToken;
153
- var responsePromise = this._api.patch(apiInfo, initParams);
154
- this._api.updateRequestToBeCancellable(responsePromise, cancellableToken);
155
- return responsePromise;
156
- }
157
- catch (err) {
158
- return Promise.reject(err.message);
159
- }
160
- };
161
- /**
162
- * Make a DEL request
163
- * @param {string} apiName - The api name of the request
164
- * @param {string} path - The path of the request
165
- * @param {json} [init] - Request extra params
166
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
167
- */
168
- RestAPIClass.prototype.del = function (apiName, path, init) {
169
- try {
170
- var apiInfo = this.getEndpointInfo(apiName, path);
171
- var cancellableToken = this._api.getCancellableToken();
172
- var initParams = Object.assign({}, init);
173
- initParams.cancellableToken = cancellableToken;
174
- var responsePromise = this._api.del(apiInfo, initParams);
175
- this._api.updateRequestToBeCancellable(responsePromise, cancellableToken);
176
- return responsePromise;
177
- }
178
- catch (err) {
179
- return Promise.reject(err.message);
180
- }
181
- };
182
- /**
183
- * Make a HEAD request
184
- * @param {string} apiName - The api name of the request
185
- * @param {string} path - The path of the request
186
- * @param {json} [init] - Request extra params
187
- * @return {Promise} - A promise that resolves to an object with response status and JSON data, if successful.
188
- */
189
- RestAPIClass.prototype.head = function (apiName, path, init) {
190
- try {
191
- var apiInfo = this.getEndpointInfo(apiName, path);
192
- var cancellableToken = this._api.getCancellableToken();
193
- var initParams = Object.assign({}, init);
194
- initParams.cancellableToken = cancellableToken;
195
- var responsePromise = this._api.head(apiInfo, initParams);
196
- this._api.updateRequestToBeCancellable(responsePromise, cancellableToken);
197
- return responsePromise;
198
- }
199
- catch (err) {
200
- return Promise.reject(err.message);
201
- }
202
- };
203
- /**
204
- * Checks to see if an error thrown is from an api request cancellation
205
- * @param {any} error - Any error
206
- * @return {boolean} - A boolean indicating if the error was from an api request cancellation
207
- */
208
- RestAPIClass.prototype.isCancel = function (error) {
209
- return this._api.isCancel(error);
210
- };
211
- /**
212
- * Cancels an inflight request
213
- * @param {any} request - request to cancel
214
- * @return {boolean} - A boolean indicating if the request was cancelled
215
- */
216
- RestAPIClass.prototype.cancel = function (request, message) {
217
- return this._api.cancel(request, message);
218
- };
219
- /**
220
- * Check if the request has a corresponding cancel token in the WeakMap.
221
- * @params request - The request promise
222
- * @return if the request has a corresponding cancel token.
223
- */
224
- RestAPIClass.prototype.hasCancelToken = function (request) {
225
- return this._api.hasCancelToken(request);
226
- };
227
- /**
228
- * Getting endpoint for API
229
- * @param {string} apiName - The name of the api
230
- * @return {string} - The endpoint of the api
231
- */
232
- RestAPIClass.prototype.endpoint = function (apiName) {
233
- return tslib_1.__awaiter(this, void 0, void 0, function () {
234
- return tslib_1.__generator(this, function (_a) {
235
- return [2 /*return*/, this._api.endpoint(apiName)];
236
- });
237
- });
238
- };
239
- /**
240
- * Getting endpoint info for API
241
- * @param {string} apiName - The name of the api
242
- * @param {string} path - The path of the api that is going to accessed
243
- * @return {ApiInfo} - The endpoint information for that api-name
244
- */
245
- RestAPIClass.prototype.getEndpointInfo = function (apiName, path) {
246
- var cloud_logic_array = this._options.endpoints;
247
- if (!Array.isArray(cloud_logic_array)) {
248
- throw new Error("API category not configured");
249
- }
250
- var apiConfig = cloud_logic_array.find(function (api) { return api.name === apiName; });
251
- if (!apiConfig) {
252
- throw new Error("API " + apiName + " does not exist");
253
- }
254
- var response = {
255
- endpoint: apiConfig.endpoint + path,
256
- };
257
- if (typeof apiConfig.region === 'string') {
258
- response.region = apiConfig.region;
259
- }
260
- else if (typeof this._options.region === 'string') {
261
- response.region = this._options.region;
262
- }
263
- if (typeof apiConfig.service === 'string') {
264
- response.service = apiConfig.service || 'execute-api';
265
- }
266
- else {
267
- response.service = 'execute-api';
268
- }
269
- if (typeof apiConfig.custom_header === 'function') {
270
- response.custom_header = apiConfig.custom_header;
271
- }
272
- else {
273
- response.custom_header = undefined;
274
- }
275
- return response;
276
- };
277
- return RestAPIClass;
278
- }());
279
- exports.RestAPIClass = RestAPIClass;
280
- exports.RestAPI = new RestAPIClass(null);
281
- core_1.Amplify.register(exports.RestAPI);
282
- //# sourceMappingURL=RestAPI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RestAPI.js","sourceRoot":"","sources":["../src/RestAPI.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,sCAAsC;AACtC,2CAA0C;AAC1C,0CAI2B;AAG3B,IAAM,MAAM,GAAG,IAAI,oBAAM,CAAC,SAAS,CAAC,CAAC;AAErC;;GAEG;AACH;IASC;;;OAGG;IACH,sBAAY,OAAO;QARX,SAAI,GAAe,IAAI,CAAC;QAEhC,gBAAW,GAAG,kBAAW,CAAC;QAOzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAEM,oCAAa,GAApB;QACC,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACH,gCAAS,GAAT,UAAU,OAAO;QAChB,IAAM,kBAA6C,EAA3C,WAAQ,EAAR,6BAAQ,EAAE,0CAAiC,CAAC;QACpD,IAAI,GAAG,yCAAQ,YAAY,GAAK,GAAG,CAAE,CAAC;QACtC,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,EAAE,GAAG,KAAA,EAAE,CAAC,CAAC;QAE5C,IAAI,GAAG,CAAC,oBAAoB,CAAC,EAAE;YAC9B,IAAI,GAAG,CAAC,wBAAwB,CAAC,EAAE;gBAClC,IAAM,MAAM,GAAG,GAAG,CAAC,wBAAwB,CAAC,CAAC;gBAC7C,GAAG,CAAC,SAAS;oBACZ,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC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GAAG,IAAI,OAAA,GAAG,CAAC,IAAI,KAAK,OAAO,EAApB,CAAoB,CAAC,CAAC;QAEtE,IAAI,CAAC,SAAS,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,SAAO,OAAO,oBAAiB,CAAC,CAAC;SACjD;QAED,IAAM,QAAQ,GAAY;YACzB,QAAQ,EAAE,SAAS,CAAC,QAAQ,GAAG,IAAI;SACnC,CAAC;QAEF,IAAI,OAAO,SAAS,CAAC,MAAM,KAAK,QAAQ,EAAE;YACzC,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;SACnC;aAAM,IAAI,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,QAAQ,EAAE;YACpD,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;SACvC;QAED,IAAI,OAAO,SAAS,CAAC,OAAO,KAAK,QAAQ,EAAE;YAC1C,QAAQ,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,IAAI,aAAa,CAAC;SACtD;aAAM;YACN,QAAQ,CAAC,OAAO,GAAG,aAAa,CAAC;SACjC;QAED,IAAI,OAAO,SAAS,CAAC,aAAa,KAAK,UAAU,EAAE;YAClD,QAAQ,CAAC,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC;SACjD;aAAM;YACN,QAAQ,CAAC,aAAa,GAAG,SAAS,CAAC;SACnC;QAED,OAAO,QAAQ,CAAC;IACjB,CAAC;IACF,mBAAC;AAAD,CAAC,AA/TD,IA+TC;AA/TY,oCAAY;AAiUZ,QAAA,OAAO,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;AAC9C,cAAO,CAAC,QAAQ,CAAC,eAAO,CAAC,CAAC"}
@@ -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): 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): 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): 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): 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): 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): 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): 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 _sign;
136
- private _request;
137
- private _parseUrl;
138
- }