api-def 0.6.0-alpha15 → 0.6.0-alpha17
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.
- package/cjs/Api.d.ts +1 -0
- package/cjs/Api.js +1 -0
- package/cjs/ApiConstants.d.ts +1 -0
- package/cjs/ApiConstants.js +1 -0
- package/cjs/Requester.js +2 -2
- package/cjs/backend/AxiosRequestBackend.d.ts +2 -2
- package/cjs/backend/AxiosRequestBackend.js +1 -0
- package/cjs/backend/FetchRequestBackend.d.ts +2 -2
- package/cjs/backend/RequestBackend.d.ts +4 -1
- package/esm/Api.d.ts +1 -0
- package/esm/Api.js +1 -0
- package/esm/ApiConstants.d.ts +1 -0
- package/esm/ApiConstants.js +1 -0
- package/esm/Requester.js +2 -2
- package/esm/backend/AxiosRequestBackend.d.ts +2 -2
- package/esm/backend/AxiosRequestBackend.js +1 -0
- package/esm/backend/FetchRequestBackend.d.ts +2 -2
- package/esm/backend/RequestBackend.d.ts +4 -1
- package/package.json +1 -1
package/cjs/Api.d.ts
CHANGED
|
@@ -28,4 +28,5 @@ export declare class Api implements ApiInfo {
|
|
|
28
28
|
post: <R = unknown>(path: string, config: RequestConfig) => Promise<ApiResponse<R>>;
|
|
29
29
|
put: <R = unknown>(path: string, config: RequestConfig) => Promise<ApiResponse<R>>;
|
|
30
30
|
delete: <R = unknown>(path: string, config: RequestConfig) => Promise<ApiResponse<R>>;
|
|
31
|
+
patch: <R = unknown>(path: string, config: RequestConfig) => Promise<ApiResponse<R>>;
|
|
31
32
|
}
|
package/cjs/Api.js
CHANGED
|
@@ -98,6 +98,7 @@ var Api = /** @class */ (function () {
|
|
|
98
98
|
this.post = this.hotRequest(ApiConstants_1.RequestMethod.POST);
|
|
99
99
|
this.put = this.hotRequest(ApiConstants_1.RequestMethod.PUT);
|
|
100
100
|
this.delete = this.hotRequest(ApiConstants_1.RequestMethod.DELETE);
|
|
101
|
+
this.patch = this.hotRequest(ApiConstants_1.RequestMethod.PATCH);
|
|
101
102
|
this.name = info.name;
|
|
102
103
|
this.baseUrl = info.baseUrl;
|
|
103
104
|
this.middleware = info.middleware || [];
|
package/cjs/ApiConstants.d.ts
CHANGED
package/cjs/ApiConstants.js
CHANGED
package/cjs/Requester.js
CHANGED
|
@@ -221,11 +221,11 @@ var parseResponse = function (context, response, error) { return __awaiter(void
|
|
|
221
221
|
case 1:
|
|
222
222
|
parsedResponse_1 = _b.sent();
|
|
223
223
|
// lowercase all header names
|
|
224
|
-
parsedResponse_1.headers = Object.keys(parsedResponse_1.headers).reduce(function (headers, header) {
|
|
224
|
+
parsedResponse_1.headers = parsedResponse_1.__lowercaseHeaders || Object.keys(parsedResponse_1.headers).reduce(function (headers, header) {
|
|
225
225
|
headers[header.toLowerCase()] = parsedResponse_1.headers[header];
|
|
226
226
|
return headers;
|
|
227
227
|
}, {});
|
|
228
|
-
contentType = parsedResponse_1.headers["
|
|
228
|
+
contentType = parsedResponse_1.headers["content-type"];
|
|
229
229
|
inferredResponseType = ApiUtils_1.inferResponseType(contentType);
|
|
230
230
|
if (!error) {
|
|
231
231
|
// expand to array buffer once we support that in inferResponseType
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import RequestBackend, { RequestBackendErrorInfo, RequestOperation } from "./RequestBackend";
|
|
1
|
+
import RequestBackend, { ConvertedApiResponse, RequestBackendErrorInfo, RequestOperation } from "./RequestBackend";
|
|
2
2
|
import { ApiResponse } from "../ApiTypes";
|
|
3
3
|
import type { AxiosError, AxiosResponse } from "axios";
|
|
4
4
|
import RequestContext from "../RequestContext";
|
|
@@ -7,7 +7,7 @@ export default class AxiosRequestBackend implements RequestBackend<AxiosResponse
|
|
|
7
7
|
readonly id = "axios";
|
|
8
8
|
constructor(axiosLibrary: any);
|
|
9
9
|
extractResponseFromError(error: Error): Promise<AxiosResponse | null | undefined>;
|
|
10
|
-
convertResponse<T>(context: RequestContext, response: AxiosResponse): Promise<
|
|
10
|
+
convertResponse<T>(context: RequestContext, response: AxiosResponse): Promise<ConvertedApiResponse<T>>;
|
|
11
11
|
makeRequest(context: RequestContext): RequestOperation<AxiosResponse>;
|
|
12
12
|
getErrorInfo(error: Error, response: ApiResponse | undefined | null): RequestBackendErrorInfo | undefined;
|
|
13
13
|
}
|
|
@@ -61,6 +61,7 @@ var AxiosRequestBackend = /** @class */ (function () {
|
|
|
61
61
|
AxiosRequestBackend.prototype.convertResponse = function (context, response) {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function () {
|
|
63
63
|
return __generator(this, function (_a) {
|
|
64
|
+
response.__lowercaseHeaders = response._lowerCaseResponseHeaders;
|
|
64
65
|
return [2 /*return*/, response];
|
|
65
66
|
});
|
|
66
67
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import RequestBackend, { RequestBackendErrorInfo, RequestOperation } from "./RequestBackend";
|
|
1
|
+
import RequestBackend, { ConvertedApiResponse, RequestBackendErrorInfo, RequestOperation } from "./RequestBackend";
|
|
2
2
|
import { ApiResponse } from "../ApiTypes";
|
|
3
3
|
import RequestContext from "../RequestContext";
|
|
4
4
|
import { Fetch } from "../Utils";
|
|
@@ -9,7 +9,7 @@ export default class FetchRequestBackend implements RequestBackend<Response> {
|
|
|
9
9
|
extractResponseFromError(error: Error): Promise<Response | null | undefined>;
|
|
10
10
|
convertResponse<T>(context: RequestContext, response: Response & {
|
|
11
11
|
__text?: string;
|
|
12
|
-
}): Promise<
|
|
12
|
+
}): Promise<ConvertedApiResponse<T>>;
|
|
13
13
|
makeRequest(context: RequestContext): RequestOperation<Response>;
|
|
14
14
|
getErrorInfo(error: Error, response: ApiResponse | undefined | null): RequestBackendErrorInfo | undefined;
|
|
15
15
|
}
|
|
@@ -7,10 +7,13 @@ export interface RequestOperation<R> {
|
|
|
7
7
|
export interface RequestBackendErrorInfo {
|
|
8
8
|
code: string;
|
|
9
9
|
}
|
|
10
|
+
export declare type ConvertedApiResponse<T> = ApiResponse<T> & {
|
|
11
|
+
__lowercaseHeaders?: any;
|
|
12
|
+
};
|
|
10
13
|
export default interface RequestBackend<R = any> {
|
|
11
14
|
readonly id: string;
|
|
12
15
|
makeRequest(context: RequestContext): RequestOperation<R>;
|
|
13
|
-
convertResponse<T>(context: RequestContext, response: R): Promise<
|
|
16
|
+
convertResponse<T>(context: RequestContext, response: R): Promise<ConvertedApiResponse<T>>;
|
|
14
17
|
extractResponseFromError(error: Error): Promise<R | null | undefined>;
|
|
15
18
|
getErrorInfo(error: Error, response: ApiResponse | undefined | null): RequestBackendErrorInfo | undefined;
|
|
16
19
|
}
|
package/esm/Api.d.ts
CHANGED
|
@@ -28,4 +28,5 @@ export declare class Api implements ApiInfo {
|
|
|
28
28
|
post: <R = unknown>(path: string, config: RequestConfig) => Promise<ApiResponse<R>>;
|
|
29
29
|
put: <R = unknown>(path: string, config: RequestConfig) => Promise<ApiResponse<R>>;
|
|
30
30
|
delete: <R = unknown>(path: string, config: RequestConfig) => Promise<ApiResponse<R>>;
|
|
31
|
+
patch: <R = unknown>(path: string, config: RequestConfig) => Promise<ApiResponse<R>>;
|
|
31
32
|
}
|
package/esm/Api.js
CHANGED
|
@@ -92,6 +92,7 @@ var Api = /** @class */ (function () {
|
|
|
92
92
|
this.post = this.hotRequest(RequestMethod.POST);
|
|
93
93
|
this.put = this.hotRequest(RequestMethod.PUT);
|
|
94
94
|
this.delete = this.hotRequest(RequestMethod.DELETE);
|
|
95
|
+
this.patch = this.hotRequest(RequestMethod.PATCH);
|
|
95
96
|
this.name = info.name;
|
|
96
97
|
this.baseUrl = info.baseUrl;
|
|
97
98
|
this.middleware = info.middleware || [];
|
package/esm/ApiConstants.d.ts
CHANGED
package/esm/ApiConstants.js
CHANGED
package/esm/Requester.js
CHANGED
|
@@ -217,11 +217,11 @@ var parseResponse = function (context, response, error) { return __awaiter(void
|
|
|
217
217
|
case 1:
|
|
218
218
|
parsedResponse_1 = _b.sent();
|
|
219
219
|
// lowercase all header names
|
|
220
|
-
parsedResponse_1.headers = Object.keys(parsedResponse_1.headers).reduce(function (headers, header) {
|
|
220
|
+
parsedResponse_1.headers = parsedResponse_1.__lowercaseHeaders || Object.keys(parsedResponse_1.headers).reduce(function (headers, header) {
|
|
221
221
|
headers[header.toLowerCase()] = parsedResponse_1.headers[header];
|
|
222
222
|
return headers;
|
|
223
223
|
}, {});
|
|
224
|
-
contentType = parsedResponse_1.headers["
|
|
224
|
+
contentType = parsedResponse_1.headers["content-type"];
|
|
225
225
|
inferredResponseType = inferResponseType(contentType);
|
|
226
226
|
if (!error) {
|
|
227
227
|
// expand to array buffer once we support that in inferResponseType
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import RequestBackend, { RequestBackendErrorInfo, RequestOperation } from "./RequestBackend";
|
|
1
|
+
import RequestBackend, { ConvertedApiResponse, RequestBackendErrorInfo, RequestOperation } from "./RequestBackend";
|
|
2
2
|
import { ApiResponse } from "../ApiTypes";
|
|
3
3
|
import type { AxiosError, AxiosResponse } from "axios";
|
|
4
4
|
import RequestContext from "../RequestContext";
|
|
@@ -7,7 +7,7 @@ export default class AxiosRequestBackend implements RequestBackend<AxiosResponse
|
|
|
7
7
|
readonly id = "axios";
|
|
8
8
|
constructor(axiosLibrary: any);
|
|
9
9
|
extractResponseFromError(error: Error): Promise<AxiosResponse | null | undefined>;
|
|
10
|
-
convertResponse<T>(context: RequestContext, response: AxiosResponse): Promise<
|
|
10
|
+
convertResponse<T>(context: RequestContext, response: AxiosResponse): Promise<ConvertedApiResponse<T>>;
|
|
11
11
|
makeRequest(context: RequestContext): RequestOperation<AxiosResponse>;
|
|
12
12
|
getErrorInfo(error: Error, response: ApiResponse | undefined | null): RequestBackendErrorInfo | undefined;
|
|
13
13
|
}
|
|
@@ -57,6 +57,7 @@ var AxiosRequestBackend = /** @class */ (function () {
|
|
|
57
57
|
AxiosRequestBackend.prototype.convertResponse = function (context, response) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function () {
|
|
59
59
|
return __generator(this, function (_a) {
|
|
60
|
+
response.__lowercaseHeaders = response._lowerCaseResponseHeaders;
|
|
60
61
|
return [2 /*return*/, response];
|
|
61
62
|
});
|
|
62
63
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import RequestBackend, { RequestBackendErrorInfo, RequestOperation } from "./RequestBackend";
|
|
1
|
+
import RequestBackend, { ConvertedApiResponse, RequestBackendErrorInfo, RequestOperation } from "./RequestBackend";
|
|
2
2
|
import { ApiResponse } from "../ApiTypes";
|
|
3
3
|
import RequestContext from "../RequestContext";
|
|
4
4
|
import { Fetch } from "../Utils";
|
|
@@ -9,7 +9,7 @@ export default class FetchRequestBackend implements RequestBackend<Response> {
|
|
|
9
9
|
extractResponseFromError(error: Error): Promise<Response | null | undefined>;
|
|
10
10
|
convertResponse<T>(context: RequestContext, response: Response & {
|
|
11
11
|
__text?: string;
|
|
12
|
-
}): Promise<
|
|
12
|
+
}): Promise<ConvertedApiResponse<T>>;
|
|
13
13
|
makeRequest(context: RequestContext): RequestOperation<Response>;
|
|
14
14
|
getErrorInfo(error: Error, response: ApiResponse | undefined | null): RequestBackendErrorInfo | undefined;
|
|
15
15
|
}
|
|
@@ -7,10 +7,13 @@ export interface RequestOperation<R> {
|
|
|
7
7
|
export interface RequestBackendErrorInfo {
|
|
8
8
|
code: string;
|
|
9
9
|
}
|
|
10
|
+
export declare type ConvertedApiResponse<T> = ApiResponse<T> & {
|
|
11
|
+
__lowercaseHeaders?: any;
|
|
12
|
+
};
|
|
10
13
|
export default interface RequestBackend<R = any> {
|
|
11
14
|
readonly id: string;
|
|
12
15
|
makeRequest(context: RequestContext): RequestOperation<R>;
|
|
13
|
-
convertResponse<T>(context: RequestContext, response: R): Promise<
|
|
16
|
+
convertResponse<T>(context: RequestContext, response: R): Promise<ConvertedApiResponse<T>>;
|
|
14
17
|
extractResponseFromError(error: Error): Promise<R | null | undefined>;
|
|
15
18
|
getErrorInfo(error: Error, response: ApiResponse | undefined | null): RequestBackendErrorInfo | undefined;
|
|
16
19
|
}
|